<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>1-800-HOSTING Blog &#187; tips</title>
	<atom:link href="http://blog.800hosting.com/tag/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.800hosting.com</link>
	<description>Inside 1-800-HOSTING</description>
	<lastBuildDate>Wed, 02 Nov 2011 17:00:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PHP Script Tips and Resources</title>
		<link>http://blog.800hosting.com/2010/02/php-script-tips-and-resources/</link>
		<comments>http://blog.800hosting.com/2010/02/php-script-tips-and-resources/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 17:30:41 +0000</pubDate>
		<dc:creator>John Cunningham</dc:creator>
				<category><![CDATA[Fun Stuff]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[free php scripts]]></category>
		<category><![CDATA[google crawler]]></category>
		<category><![CDATA[googlebot]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[osCommerce]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[website]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://blog.800hosting.com/?p=1205</guid>
		<description><![CDATA[PHP is a language absolutely made for websites. PHP code can be inserted into an html page to enable dynamic creation. Many content management systems like Drupal, Joomla, and osCommerce  use PHP together with MySQL to build webpages. You can use PHP to detect crawling activity, rotate images/banners, and process forms. Here is an example [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://static.php.net/www.php.net/images/php.gif" alt="php" /> PHP is a language absolutely made for websites. <a title="php" href="http://php.net/" target="_blank">PHP</a> code can be inserted into an html page to enable dynamic creation. Many content management systems like Drupal, Joomla, and osCommerce  use PHP together with MySQL to build webpages.<span id="more-1205"></span></p>
<p>You can use PHP to detect crawling activity, rotate images/banners, and process forms. Here is an example of code that will email you whenever Google crawler Googlebot visits your page by detecting the useragent. You could expand the code to include other crawlers, add date and time stamp, and validate the IP to exclude impostors. I left that stuff out for simplicity and because you can  get that info from your webstats/logs. Just copy and paste this code in your web page to try it out. Note that the page may have to end with .php file extension to work, it depends on how your web server is setup.</p>
<blockquote><p>&lt;?<br />
if(eregi(&#8220;Googlebot&#8221;,$_SERVER['HTTP_USER_AGENT'])){</p>
<p>//put your email address below<br />
$address=youname@yourdomain.com;<br />
$subject=&#8221;Google visited &#8220;.$_SERVER[’HTTP_HOST’];<br />
$message=&#8221;Googlebot visited today.&#8221;;<br />
mail($address, $subject, $message);<br />
}<br />
?&gt;</p></blockquote>
<p>Here is an example of how to display  random images in a web page, it will pick one of the three banners each time the page loads. You could easily add more cases here or change the img src line to make this a random text function.</p>
<blockquote><p>&lt;?<br />
$randomimage = Rand (1,3) ;</p>
<p>//put your image name at bannerx<br />
switch ($randomimage)<br />
{<br />
case 1:<br />
&#8220;banner1&#8243;;<br />
break;</p>
<p>case 2:<br />
&#8220;banner2&#8243;;<br />
break;</p>
<p>case 3:<br />
&#8220;banner3&#8243;;<br />
break;<br />
}</p>
<p>echo &#8216;&lt;img src=&#8221;&#8216;$randomimage.&#8217;&#8221; border=0&gt;&#8217;;</p>
<p>?&gt;</p></blockquote>
<p>Another cool thing you can do is filter form data to by blocking bad words, banning ip addresses, and setting a timer with a cookie. There is nothing worse than having your website form spammed. You can get the visitor&#8217;s IP address with a built in php function and then check it against a list of bad IP addresses you have stored in a list called an <em>array</em>. You can modify this to include words by replacing the IP addresses with words. This is useful if there is a relatively small number of abusers. In the case of larger numbers, blocking at the server level using <a title="iptables wikipedia definition" href="http://en.wikipedia.org/wiki/Iptables" target="_blank">iptables</a> or a firewall may work better for you.</p>
<p>Here is the code for blocking IPs and you can add more IPs to the array if needed:</p>
<blockquote><p>&lt;?<br />
$banned_ip_addresses = array(&#8217;4.2.5.5&#8242;, &#8217;64.43.67.19&#8242;, &#8217;207.22.32.152&#8242;);</p>
<p>if(in_array($_SERVER['REMOTE_ADDR'], $banned_ip_addresses))<br />
{<br />
echo &#8220;You are banned.&#8221;;<br />
} else {<br />
continue with form processing&#8230;<br />
}</p></blockquote>
<p>If you are having problems with abusive surfers filling out your forms with constantly changing ip addresses, you can stop them by adding a cookie. A cookie is a small piece of code sent to the user&#8217;s pc to identify them.  Note that not all browsers will accept cookies, but most will. Once the cookie is set, you check for the existence of it in your form processing. Here is an example:</p>
<blockquote><p>//this sets time to 7200 seconds, 2 hours<br />
&lt;?<br />
setcookie(&#8220;userx&#8221;, &#8220;cookie1&#8243;, time()+7200);<br />
?&gt;</p>
<p>Then add the code below to find out if this person has been on your page before:</p>
<p>&lt;?<br />
if (isset($_COOKIE1["userx"])){<br />
echo &#8220;You have already filled out this form recently&#8221;;</p>
<p>} else {<br />
continue with form processing&#8230;<br />
}<br />
?&gt;</p></blockquote>
<p>There is a plethora of PHP support websites on the Internet. My longtime favorite is  <a title="php freaks forum" href="http://www.phpfreaks.com/forums/" target="_blank">PHP Freaks Forum</a> where you can post  technical questions and read responses. Another good one is the <a title="digital point php forum" href="http://forums.digitalpoint.com/forumdisplay.php?f=37" target="_blank">Digital Point PHP Forum</a>. If you are looking for scripts then visit <a title="hotscripts" href="http://www.hotscripts.com/category/php/scripts-programs/" target="_blank">Hotscripts</a>, where you will find many, some free and some paid. Also check out <a title="free scripts directory" href="http://gscripts.net/" target="_blank">Free Scripts Directory</a>,  <a title="script repository" href="http://www.sitescripts.com/PHP/" target="_blank">Script Repository</a>, and <a title="php resource index" href="http://php.resourceindex.com/Complete_Scripts/" target="_blank">PHP Resource Index</a>. They have scripts for: counters, auctions, voting, calculators, searching, support ticketing, etc.</p>
<p>PHP works fine on both Linux and Windows systems. If you have a Linux box then chances are good that it is already installed; if not, visit <a title="php" href="http://php.net/" target="_blank">php.net</a> to download it. PHP is not standard on Windows but it can be installed. If you need technical support we can help you with installing or upgrading.</p>
<p>PHP is very powerful. In an upcoming post I will explain how to speed it up using accelerators, pull data from a database, write it to a webpage, and add functionality using extensions.</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://blog.800hosting.com/2011/07/workstation-backup-solutions-pt-3-redundancy/" title="Workstation Backup Solutions Pt. 3: Redundancy">Workstation Backup Solutions Pt. 3: Redundancy</a></li><li><a href="http://blog.800hosting.com/2011/07/workstation-backup-solutions-pt-2-methods-retention/" title=" Workstation Backup Solutions Pt. 2: Methods &amp; Retention"> Workstation Backup Solutions Pt. 2: Methods &amp; Retention</a></li><li><a href="http://blog.800hosting.com/2011/06/workstation-backup-solutions-pt-1-having-one/" title="Workstation Backup Solutions Pt. 1: Having One">Workstation Backup Solutions Pt. 1: Having One</a></li><li><a href="http://blog.800hosting.com/2009/12/drupal-free-website-building-tool/" title="Drupal &#8211; Free Website Building Tool">Drupal &#8211; Free Website Building Tool</a></li><li><a href="http://blog.800hosting.com/2009/05/linux-shell-insights-volume-2/" title="Linux Shell Insights: Volume 2">Linux Shell Insights: Volume 2</a></li><li><a href="http://blog.800hosting.com/2009/05/linux-shell-insights-volume-1/" title="Linux Shell Insights: Volume 1">Linux Shell Insights: Volume 1</a></li><li><a href="http://blog.800hosting.com/2011/08/mysql-error-in-the-errmsg-sys-file/" title="MySQL Error in the errmsg.sys file">MySQL Error in the errmsg.sys file</a></li><li><a href="http://blog.800hosting.com/2010/01/mysql-version-6-preview/" title="MySQL Version 6 Preview">MySQL Version 6 Preview</a></li><li><a href="http://blog.800hosting.com/2009/12/a-little-security-goes-a-loooong-way/" title="A Little Security Goes a LOOOONG Way">A Little Security Goes a LOOOONG Way</a></li><li><a href="http://blog.800hosting.com/2009/11/linux-tip-setting-up-key-based-authentication/" title="Linux Tip: Setting up key-based authentication.">Linux Tip: Setting up key-based authentication.</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.800hosting.com/2010/02/php-script-tips-and-resources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Shell Insights: Volume 2</title>
		<link>http://blog.800hosting.com/2009/05/linux-shell-insights-volume-2/</link>
		<comments>http://blog.800hosting.com/2009/05/linux-shell-insights-volume-2/#comments</comments>
		<pubDate>Tue, 26 May 2009 23:40:14 +0000</pubDate>
		<dc:creator>John Cunningham</dc:creator>
				<category><![CDATA[Fun Stuff]]></category>
		<category><![CDATA[Industry]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[1-800-HOSTING]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://blog.800hosting.com/?p=548</guid>
		<description><![CDATA[My last volume Linux Shell Insights: Volume 1 had some talk on the social plane about it so here&#8217;s Volume 2. Enjoy. Here are a few more one-liners. I also call for the assistance of our audience; if anyone has more reliable or efficient methods to accomplish the ends in this article, get involved and [...]]]></description>
			<content:encoded><![CDATA[<p>My last volume <a href="http://blog.800hosting.com/2009/05/linux-shell-insights-volume-1/">Linux Shell Insights: Volume 1</a> had some talk on the social plane about it so here&#8217;s Volume 2. Enjoy.</p>
<p>Here are a few more one-liners. I also call for the assistance of our audience; if anyone has more reliable or efficient methods to accomplish the ends in this article, get involved and comment!<span id="more-548"></span></p>
<ol>
<li><strong>Obtain your internet IP</strong><br />
There are two ways to do this (both below.) This can be useful in bash scripts that require your IP address. It&#8217;s useful in a dynamic IP environment when handling dynamic DNS in some fashion; though can be useful in a variety of scripts in which NAT may exist making eth0 unreliable for this information.</p>
<div style="overflow: auto; font-family: Courier New; background-color: black; border: medium double grey; color: white">shell# wget -O &#8211; -q checkip.dyndns.org | grep -o &#8220;[[:digit:].]+&#8221;</div>
<p>You can also use curl if it&#8217;s your tool-of-choice.</p>
<div style="overflow: auto; font-family: Courier New; background-color: black; border: medium double grey; color: white">shell# curl -s http://checkip.dydns.org/ | grep -o &#8220;[[:digit:].]+&#8221;</div>
<p>If you&#8217;ve got a static IP that is directly connected to the internet; it&#8217;s best to just scrape the information out of ifconfig.</p>
<div style="white-space: pre-wrap; word-wrap: break-word; overflow: auto; font-family: Courier New; background-color: black; border: medium double grey; color: white">shell# /sbin/ifconfig eth0 | grep inet | grep -o &#8220;[[:digit:].]+&#8221; | head -n 1</div>
</li>
<li><strong>Get Distribution Information/Version</strong><br />
From time to time we get support tickets or calls asking &#8220;What distribution of Linux am I running?&#8221;. Here&#8217;s a way to ascertain this under most modern Linux distributions we offer.</p>
<p>Most Linux distributions follow the &#8220;<a href="http://en.wikipedia.org/wiki/Linux_Standard_Base">Linux Standard Base</a>&#8221; and have a file in /etc matching *release. You can take a look by running:</p>
<div style="overflow: auto; font-family: Courier New; background-color: black; border: medium double grey; color: white">shell# cat /etc/*release</div>
<p>This does the same thing if you find it easier to remember.</p>
<div style="overflow: auto; font-family: Courier New; background-color: black; border: medium double grey; color: white">shell# lsb_release &#8211;all</div>
<p>NOTE: You may have to cat the file /etc/debian_version on some Debian releases.</li>
<li><strong>Shortcut to list all system users</strong><br />
I stumbled upon this one by a typo once where you can get a peek of system users. This shouldn&#8217;t be considered authoritative, as /etc/passwd is your daddy; but it&#8217;s quick to verify the spelling of that strange developer who insists on the username supercalifragilistic_expialidocious.<br />
Tested on: Debian, Redhat</p>
<div style="overflow: auto; font-family: Courier New; background-color: black; border: medium double grey; color: white">shell# ~(HIT TAB TWICE HERE)</div>
</li>
<li><strong>Lost Plesk Password</strong><br />
Here&#8217;s one of those gems that we keep close to our chest, but I&#8217;m willing to reveal it to you. If you misplace your Plesk Admin password, on UNIX it stores it in /etc/psa/.psa.shadow. This is a read-only file, changing the password here does not change it for Plesk. It&#8217;s a good way to jot your memory if you forget though.</p>
<div style="overflow: auto; font-family: Courier New; background-color: black; border: medium double grey; color: white">shell# cat /etc/psa/.psa.shadow</div>
</li>
</ol>
<p>Continue to keep an eye out for my next list!</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://blog.800hosting.com/2009/05/linux-shell-insights-volume-1/" title="Linux Shell Insights: Volume 1">Linux Shell Insights: Volume 1</a></li><li><a href="http://blog.800hosting.com/2010/02/php-script-tips-and-resources/" title="PHP Script Tips and Resources">PHP Script Tips and Resources</a></li><li><a href="http://blog.800hosting.com/2009/12/drupal-free-website-building-tool/" title="Drupal &#8211; Free Website Building Tool">Drupal &#8211; Free Website Building Tool</a></li><li><a href="http://blog.800hosting.com/2011/07/workstation-backup-solutions-pt-3-redundancy/" title="Workstation Backup Solutions Pt. 3: Redundancy">Workstation Backup Solutions Pt. 3: Redundancy</a></li><li><a href="http://blog.800hosting.com/2011/07/workstation-backup-solutions-pt-2-methods-retention/" title=" Workstation Backup Solutions Pt. 2: Methods &amp; Retention"> Workstation Backup Solutions Pt. 2: Methods &amp; Retention</a></li><li><a href="http://blog.800hosting.com/2011/07/send-us-your-postcards/" title="Send Us Your Postcards!">Send Us Your Postcards!</a></li><li><a href="http://blog.800hosting.com/2011/06/workstation-backup-solutions-pt-1-having-one/" title="Workstation Backup Solutions Pt. 1: Having One">Workstation Backup Solutions Pt. 1: Having One</a></li><li><a href="http://blog.800hosting.com/2010/01/employee-appreciation-and-the-lost-art-of-the-road-trip/" title="Employee Appreciation and the Lost Art of the Road Trip">Employee Appreciation and the Lost Art of the Road Trip</a></li><li><a href="http://blog.800hosting.com/2010/01/a-resolution-to-keep-resolutions/" title="A Resolution to Keep Resolutions">A Resolution to Keep Resolutions</a></li><li><a href="http://blog.800hosting.com/2009/12/happy-holidays/" title="Happy Holidays!">Happy Holidays!</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.800hosting.com/2009/05/linux-shell-insights-volume-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Shell Insights: Volume 1</title>
		<link>http://blog.800hosting.com/2009/05/linux-shell-insights-volume-1/</link>
		<comments>http://blog.800hosting.com/2009/05/linux-shell-insights-volume-1/#comments</comments>
		<pubDate>Wed, 06 May 2009 20:57:43 +0000</pubDate>
		<dc:creator>John Cunningham</dc:creator>
				<category><![CDATA[Fun Stuff]]></category>
		<category><![CDATA[Industry]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[1-800-HOSTING]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://blog.800hosting.com/?p=433</guid>
		<description><![CDATA[Hello readers, I thought I&#8217;d share some intriguing and useful one-liners that could make your life easier on the Linux/Unix shell environment. I hope to offer a regular multi-part series for those who are fans of the Linux platform. View Physical Console via SSH This will view the console (and makes assumption that the console [...]]]></description>
			<content:encoded><![CDATA[<p>Hello readers,</p>
<p>I thought I&#8217;d share some intriguing and useful one-liners that could make your life easier on the Linux/Unix shell environment. I hope to offer a regular multi-part series for those who are fans of the Linux platform.<span id="more-433"></span></p>
<ol>
<li><strong>View Physical Console via SSH</strong><br />
This will view the console (and makes assumption that the console is an 80 character screen.) It&#8217;s helpful to scrape error messages that are printed to the local console. Great for when you don&#8217;t have physical access to the server and need to see the terminal; we also find it useful here by eliminating unnecessary trips to the data center floor.</p>
<p><span style="auto: visible; font-family: Courier New; background-color: black; border: medium double grey; color: white">shell# sudo cat /dev/vcs1 | fold -w 80</span></li>
<li><strong>Remove multiple RPM packages by a defined pattern</strong><br />
This is useful for remove all packages that are part of a common suite. This example would uninstall any package in the system with &#8216;php&#8217; in the name. (Disclaimer: Check what packages contain the string prior to running this. Unpredictable results could remove system critical packages! I&#8217;d suggest this for advanced shell users only.)</p>
<p><span style="auto: visible; font-family: Courier New; background-color: black; border: medium double grey; color: white">shell# yum erase `yum list installed | grep &#8216;php&#8217;`</span></li>
<li><strong>Reduce a file to zero bytes</strong><br />
I&#8217;m sure every administrator has needed to zero out a log file taking too much space; or clear a users mail spool. Many commands involve piping /dev/null to the file or similar. The following command is probably the easiest and quickest way that many users overlook.</p>
<p><span style="auto: visible; font-family: Courier New; background-color: black; border: medium double grey; color: white">shell# &gt; file_to_wipe.txt</span></li>
<li><strong>Look at the strings stored in RAM</strong><br />
This one is more for fun; though it could be used for security auditing. This command will access the system RAM and reveal text strings stored in memory. Don&#8217;t worry, this file is read-only by the kernel. You can usually find interesting data stored in memory with this command.</p>
<p><span style="auto: visible; font-family: Courier New; background-color: black; border: medium double grey; color: white">shell# sudo dd if=/dev/mem | cat | strings</span></li>
</ol>
<p>That&#8217;s it for now; more in this series coming soon.</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://blog.800hosting.com/2009/05/linux-shell-insights-volume-2/" title="Linux Shell Insights: Volume 2">Linux Shell Insights: Volume 2</a></li><li><a href="http://blog.800hosting.com/2010/02/php-script-tips-and-resources/" title="PHP Script Tips and Resources">PHP Script Tips and Resources</a></li><li><a href="http://blog.800hosting.com/2009/12/drupal-free-website-building-tool/" title="Drupal &#8211; Free Website Building Tool">Drupal &#8211; Free Website Building Tool</a></li><li><a href="http://blog.800hosting.com/2011/07/workstation-backup-solutions-pt-3-redundancy/" title="Workstation Backup Solutions Pt. 3: Redundancy">Workstation Backup Solutions Pt. 3: Redundancy</a></li><li><a href="http://blog.800hosting.com/2011/07/workstation-backup-solutions-pt-2-methods-retention/" title=" Workstation Backup Solutions Pt. 2: Methods &amp; Retention"> Workstation Backup Solutions Pt. 2: Methods &amp; Retention</a></li><li><a href="http://blog.800hosting.com/2011/07/send-us-your-postcards/" title="Send Us Your Postcards!">Send Us Your Postcards!</a></li><li><a href="http://blog.800hosting.com/2011/06/workstation-backup-solutions-pt-1-having-one/" title="Workstation Backup Solutions Pt. 1: Having One">Workstation Backup Solutions Pt. 1: Having One</a></li><li><a href="http://blog.800hosting.com/2010/01/employee-appreciation-and-the-lost-art-of-the-road-trip/" title="Employee Appreciation and the Lost Art of the Road Trip">Employee Appreciation and the Lost Art of the Road Trip</a></li><li><a href="http://blog.800hosting.com/2010/01/a-resolution-to-keep-resolutions/" title="A Resolution to Keep Resolutions">A Resolution to Keep Resolutions</a></li><li><a href="http://blog.800hosting.com/2009/12/happy-holidays/" title="Happy Holidays!">Happy Holidays!</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.800hosting.com/2009/05/linux-shell-insights-volume-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

