<?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>Gray Matter Blog &#187; Code Library</title>
	<atom:link href="http://www.henriemedia.com/blog/view/code-library/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.henriemedia.com/blog</link>
	<description>The faculty of intelligence and reason.</description>
	<lastBuildDate>Thu, 05 Aug 2010 16:27:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Break sentence between words</title>
		<link>http://www.henriemedia.com/blog/code-library/php/break-sentence-between-words/</link>
		<comments>http://www.henriemedia.com/blog/code-library/php/break-sentence-between-words/#comments</comments>
		<pubDate>Wed, 05 May 2010 17:07:37 +0000</pubDate>
		<dc:creator>Henrie Media Inc.</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.henriemedia.com/blog/?p=616</guid>
		<description><![CDATA[This is a useful script for anybody who wishes to get the beginning of a string up to the word break before $num of characters. Usually the use of substr will break half way through a word and leave things looking a little untidy on your site. This little function allows you to set the [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-346" href="http://www.henriemedia.com/blog/code-library/javascript-timer/attachment/computer-icon/"><img class="alignright size-full wp-image-346" title="Computer" src="http://www.henriemedia.com/blog/wp-content/uploads/computer-icon.jpg" alt="" width="150" height="130" /></a>This is a useful script for anybody who wishes to get the beginning of a  string up to the word break before $num of characters. Usually the use  of substr will break half way through a word and leave things looking a  little untidy on your site. This little function allows you to set the  maximum length of the string, then it returns all the whole words before  it. If the supplied string is shorter than the maximum length, the  whole string is returned.</p>
<blockquote><p><code>&lt;?php</code></p>
<p>/**<br />
*<br />
* @break a string at the end of the last word<br />
* before $maxlength chars<br />
*<br />
* @param string $string<br />
*<br />
* @param int $maxlength<br />
*<br />
* @return string<br />
*<br />
*/<br />
function wordbreak($string, $maxlength)<br />
{<br />
$string = substr($string, 0, $maxlength);<br />
return substr($string, 0, strrpos($string, &#8221; &#8221;));<br />
}</p>
<p>/*** example usage ***/<br />
$string = &#8217;Kyle was hoping to be finished before he left on his vacation to Hawaii! He also wanted to make sure the dog was fed, the house was clean and the lawn was mowed&#8217;;</p>
<p>echo wordbreak($string, 50).&#8217; &#8230;&#8217;;</p>
<p>?&gt;</p></blockquote>

<div class="sociable">
<div class="sociable_tagline">
<strong>Print, Email, Share, Enjoy!</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fphp%2Fbreak-sentence-between-words%2F&amp;partner=sociable" title="Print"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Break%20sentence%20between%20words&amp;body=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fphp%2Fbreak-sentence-between-words%2F" title="email"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Break%20sentence%20between%20words%20-%20http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fphp%2Fbreak-sentence-between-words%2F" title="Twitter"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fphp%2Fbreak-sentence-between-words%2F&amp;t=Break%20sentence%20between%20words" title="Facebook"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fphp%2Fbreak-sentence-between-words%2F&amp;title=Break%20sentence%20between%20words&amp;bodytext=This%20is%20a%20useful%20script%20for%20anybody%20who%20wishes%20to%20get%20the%20beginning%20of%20a%20%20string%20up%20to%20the%20word%20break%20before%20%24num%20of%20characters.%20Usually%20the%20use%20%20of%20substr%20will%20break%20half%20way%20through%20a%20word%20and%20leave%20things%20looking%20a%20%20little%20untidy%20on%20your%20site.%20Thi" title="Digg"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fphp%2Fbreak-sentence-between-words%2F&amp;t=Break%20sentence%20between%20words" title="MySpace"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fphp%2Fbreak-sentence-between-words%2F&amp;title=Break%20sentence%20between%20words" title="Mixx"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fphp%2Fbreak-sentence-between-words%2F&amp;title=Break%20sentence%20between%20words&amp;notes=This%20is%20a%20useful%20script%20for%20anybody%20who%20wishes%20to%20get%20the%20beginning%20of%20a%20%20string%20up%20to%20the%20word%20break%20before%20%24num%20of%20characters.%20Usually%20the%20use%20%20of%20substr%20will%20break%20half%20way%20through%20a%20word%20and%20leave%20things%20looking%20a%20%20little%20untidy%20on%20your%20site.%20Thi" title="del.icio.us"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fphp%2Fbreak-sentence-between-words%2F" title="Technorati"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fphp%2Fbreak-sentence-between-words%2F&amp;title=Break%20sentence%20between%20words" title="StumbleUpon"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.henriemedia.com/blog/code-library/php/break-sentence-between-words/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Show the current weather on your website</title>
		<link>http://www.henriemedia.com/blog/code-library/show-the-current-weather-on-your-website/</link>
		<comments>http://www.henriemedia.com/blog/code-library/show-the-current-weather-on-your-website/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 16:44:11 +0000</pubDate>
		<dc:creator>Henrie Media Inc.</dc:creator>
				<category><![CDATA[Code Library]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.henriemedia.com/blog/?p=600</guid>
		<description><![CDATA[Many times it is neat to display the current temperature on your website, and there are a lot of different ways to go about this. I’d like to show you the easiest way to display the temperature on your site using XML from the National Weather Service (NOAA) and simple XML commands in PHP. Get [...]]]></description>
			<content:encoded><![CDATA[<p>Many times it is neat to display the current temperature on your  website, and there are a lot of different ways to go about this. I’d  like to show you the easiest way to display the temperature on your site  using XML from the National Weather Service (NOAA) and simple XML  commands in PHP.</p>
<p><strong>Get Started</strong></p>
<p>To get started, you will need to find weather data. The National  Weather Service offers this data in free XML feeds, which you can find  at <a href="http://www.weather.gov/xml/current_obs/" target="_blank">http://www.weather.gov/xml/current_obs/</a>.  To get started, select an XML feed you’d like to use. I’m using a  Salt Lake City, Utah, ID feed, which looks like:</p>
<blockquote><p>http://www.weather.gov/xml/current_obs/KSLC.xml</p></blockquote>
<p>You will is this URL in the PHP code to get your location’s current  temperature.</p>
<p><strong>The Code</strong></p>
<p>To get the data we want from the XML feed, we will be using the  simplexml_load_file() function. This will, essentially, parse the XML  for us, making it ready to use as text online. Here is the code you will  need:</p>
<blockquote><p>&lt;?php<br />
// Load the XML<br />
$xml_slc = simplexml_load_file(&#8216;http://www.weather.gov/xml/current_obs/KSLC.xml&#8217;);<br />
// Get the current temperature<br />
$slc_temp = $xml_slc-&gt;temp_f;<br />
//echo $slc_temp.&#8221;&amp;deg; F&#8221;;<br />
?&gt;</p></blockquote>
<p>The output you get should be something similar to 64°. It&#8217;s that easy and and it&#8217;s FREE! Enjoy!</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Print, Email, Share, Enjoy!</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fshow-the-current-weather-on-your-website%2F&amp;partner=sociable" title="Print"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Show%20the%20current%20weather%20on%20your%20website&amp;body=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fshow-the-current-weather-on-your-website%2F" title="email"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Show%20the%20current%20weather%20on%20your%20website%20-%20http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fshow-the-current-weather-on-your-website%2F" title="Twitter"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fshow-the-current-weather-on-your-website%2F&amp;t=Show%20the%20current%20weather%20on%20your%20website" title="Facebook"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fshow-the-current-weather-on-your-website%2F&amp;title=Show%20the%20current%20weather%20on%20your%20website&amp;bodytext=Many%20times%20it%20is%20neat%20to%20display%20the%20current%20temperature%20on%20your%20%20website%2C%20and%20there%20are%20a%20lot%20of%20different%20ways%20to%20go%20about%20this.%20I%E2%80%99d%20%20like%20to%20show%20you%20the%20easiest%20way%20to%20display%20the%20temperature%20on%20your%20site%20%20using%20XML%20from%20the%20National%20Weather%20Se" title="Digg"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fshow-the-current-weather-on-your-website%2F&amp;t=Show%20the%20current%20weather%20on%20your%20website" title="MySpace"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fshow-the-current-weather-on-your-website%2F&amp;title=Show%20the%20current%20weather%20on%20your%20website" title="Mixx"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fshow-the-current-weather-on-your-website%2F&amp;title=Show%20the%20current%20weather%20on%20your%20website&amp;notes=Many%20times%20it%20is%20neat%20to%20display%20the%20current%20temperature%20on%20your%20%20website%2C%20and%20there%20are%20a%20lot%20of%20different%20ways%20to%20go%20about%20this.%20I%E2%80%99d%20%20like%20to%20show%20you%20the%20easiest%20way%20to%20display%20the%20temperature%20on%20your%20site%20%20using%20XML%20from%20the%20National%20Weather%20Se" title="del.icio.us"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fshow-the-current-weather-on-your-website%2F" title="Technorati"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fshow-the-current-weather-on-your-website%2F&amp;title=Show%20the%20current%20weather%20on%20your%20website" title="StumbleUpon"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.henriemedia.com/blog/code-library/show-the-current-weather-on-your-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use multiple lines with document.write()</title>
		<link>http://www.henriemedia.com/blog/code-library/javascript/use-multiple-lines-with-document-write/</link>
		<comments>http://www.henriemedia.com/blog/code-library/javascript/use-multiple-lines-with-document-write/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 14:45:45 +0000</pubDate>
		<dc:creator>Henrie Media Inc.</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.henriemedia.com/blog/?p=594</guid>
		<description><![CDATA[I often get the question if it&#8217;s possible to use document.write() in JavaScript to output multiple likes instread of having to put &#8211; document.write(&#8216; &#8211; at the beginning of every line and &#8211; &#8216;); &#8211; at the end. The answer is Yes. Here is how - document.write( &#8216;line1&#8242; +&#8217;line2&#8242; +&#8217;line3&#8242; ) OR - document.write( &#8216;line1&#8242; [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-346" href="http://www.henriemedia.com/blog/code-library/javascript-timer/attachment/computer-icon/"><img class="alignright size-full wp-image-346" title="Computer" src="http://www.henriemedia.com/blog/wp-content/uploads/computer-icon.jpg" alt="" width="150" height="130" /></a>I often get the question if it&#8217;s possible to use document.write() in JavaScript to output multiple likes instread of having to put &#8211; document.write(&#8216; &#8211; at the beginning of every line and &#8211; &#8216;); &#8211; at the end. The answer is Yes. Here is how -</p>
<blockquote><p>document.write(<br />
&#8216;line1&#8242;<br />
+&#8217;line2&#8242;<br />
+&#8217;line3&#8242;<br />
)</p>
<p>OR -</p>
<p>document.write(<br />
&#8216;line1&#8242; + &#8216;\n&#8217;<br />
+&#8217;line2&#8242; + &#8216;\n&#8217;<br />
+&#8217;line3&#8242; + &#8216;\n&#8217;<br />
)</p>
<p>..or use a single string -</p>
<p>document.write(<br />
&#8216;line1\<br />
line2\<br />
line3&#8242;<br />
)</p></blockquote>
<p>JavaScript is a little funny, so make sure you test! Hope this helps!</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Print, Email, Share, Enjoy!</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Fuse-multiple-lines-with-document-write%2F&amp;partner=sociable" title="Print"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Use%20multiple%20lines%20with%20document.write%28%29&amp;body=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Fuse-multiple-lines-with-document-write%2F" title="email"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Use%20multiple%20lines%20with%20document.write%28%29%20-%20http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Fuse-multiple-lines-with-document-write%2F" title="Twitter"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Fuse-multiple-lines-with-document-write%2F&amp;t=Use%20multiple%20lines%20with%20document.write%28%29" title="Facebook"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Fuse-multiple-lines-with-document-write%2F&amp;title=Use%20multiple%20lines%20with%20document.write%28%29&amp;bodytext=I%20often%20get%20the%20question%20if%20it%27s%20possible%20to%20use%20document.write%28%29%20in%20JavaScript%20to%20output%20multiple%20likes%20instread%20of%20having%20to%20put%20-%20document.write%28%27%20-%20at%20the%20beginning%20of%20every%20line%20and%20-%20%27%29%3B%20-%20at%20the%20end.%20The%20answer%20is%20Yes.%20Here%20is%20how%20-%0D%0Adocument." title="Digg"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Fuse-multiple-lines-with-document-write%2F&amp;t=Use%20multiple%20lines%20with%20document.write%28%29" title="MySpace"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Fuse-multiple-lines-with-document-write%2F&amp;title=Use%20multiple%20lines%20with%20document.write%28%29" title="Mixx"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Fuse-multiple-lines-with-document-write%2F&amp;title=Use%20multiple%20lines%20with%20document.write%28%29&amp;notes=I%20often%20get%20the%20question%20if%20it%27s%20possible%20to%20use%20document.write%28%29%20in%20JavaScript%20to%20output%20multiple%20likes%20instread%20of%20having%20to%20put%20-%20document.write%28%27%20-%20at%20the%20beginning%20of%20every%20line%20and%20-%20%27%29%3B%20-%20at%20the%20end.%20The%20answer%20is%20Yes.%20Here%20is%20how%20-%0D%0Adocument." title="del.icio.us"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Fuse-multiple-lines-with-document-write%2F" title="Technorati"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Fuse-multiple-lines-with-document-write%2F&amp;title=Use%20multiple%20lines%20with%20document.write%28%29" title="StumbleUpon"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.henriemedia.com/blog/code-library/javascript/use-multiple-lines-with-document-write/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to prevent leeching</title>
		<link>http://www.henriemedia.com/blog/code-library/configuration/how-to-prevent-leeching/</link>
		<comments>http://www.henriemedia.com/blog/code-library/configuration/how-to-prevent-leeching/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 17:36:39 +0000</pubDate>
		<dc:creator>Henrie Media Inc.</dc:creator>
				<category><![CDATA[Configuration]]></category>

		<guid isPermaLink="false">http://www.henriemedia.com/blog/?p=434</guid>
		<description><![CDATA[If you notice an unreasonable consumption of your bandwidth, there is a good chance that some of your interesting images are being virtually stolen by other websites. They issue links to your content and leave you with the bill. Here is a sure way to prevent this from happening once and for all! RewriteEngine On [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: larger;"><img class="alignright size-full wp-image-338" title="Apache logo" src="http://www.henriemedia.com/blog/wp-content/uploads/apache-logo.jpg" alt="Apache logo" width="150" height="134" />If you notice an unreasonable consumption of your bandwidth, there is a good chance that some of your interesting images are being virtually stolen by other websites. They issue links to your content and leave you with the bill. Here is a sure way to prevent this from happening once and for all!</span></p>
<pre>RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteCond %{HTTP_REFERER} !^http://yourdomainname.com [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yourdomainname.com [NC]
RewriteRule [^/]+.(gif|jpg)$ http://eboundhost.com/images/leeching.jpg [R,L]</pre>
<p>Of course, you will need to change &#8220;yourdomainname.com&#8221; to match your actual domain name.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Print, Email, Share, Enjoy!</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fconfiguration%2Fhow-to-prevent-leeching%2F&amp;partner=sociable" title="Print"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=How%20to%20prevent%20leeching&amp;body=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fconfiguration%2Fhow-to-prevent-leeching%2F" title="email"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=How%20to%20prevent%20leeching%20-%20http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fconfiguration%2Fhow-to-prevent-leeching%2F" title="Twitter"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fconfiguration%2Fhow-to-prevent-leeching%2F&amp;t=How%20to%20prevent%20leeching" title="Facebook"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fconfiguration%2Fhow-to-prevent-leeching%2F&amp;title=How%20to%20prevent%20leeching&amp;bodytext=If%20you%20notice%20an%20unreasonable%20consumption%20of%20your%20bandwidth%2C%20there%20is%20a%20good%20chance%20that%20some%20of%20your%20interesting%20images%20are%20being%20virtually%20stolen%20by%20other%20websites.%20They%20issue%20links%20to%20your%20content%20and%20leave%20you%20with%20the%20bill.%20Here%20is%20a%20sure%20way%20to" title="Digg"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fconfiguration%2Fhow-to-prevent-leeching%2F&amp;t=How%20to%20prevent%20leeching" title="MySpace"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fconfiguration%2Fhow-to-prevent-leeching%2F&amp;title=How%20to%20prevent%20leeching" title="Mixx"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fconfiguration%2Fhow-to-prevent-leeching%2F&amp;title=How%20to%20prevent%20leeching&amp;notes=If%20you%20notice%20an%20unreasonable%20consumption%20of%20your%20bandwidth%2C%20there%20is%20a%20good%20chance%20that%20some%20of%20your%20interesting%20images%20are%20being%20virtually%20stolen%20by%20other%20websites.%20They%20issue%20links%20to%20your%20content%20and%20leave%20you%20with%20the%20bill.%20Here%20is%20a%20sure%20way%20to" title="del.icio.us"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fconfiguration%2Fhow-to-prevent-leeching%2F" title="Technorati"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fconfiguration%2Fhow-to-prevent-leeching%2F&amp;title=How%20to%20prevent%20leeching" title="StumbleUpon"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.henriemedia.com/blog/code-library/configuration/how-to-prevent-leeching/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Random numbers in JavaScript</title>
		<link>http://www.henriemedia.com/blog/code-library/javascript/random-numbers/</link>
		<comments>http://www.henriemedia.com/blog/code-library/javascript/random-numbers/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 14:39:36 +0000</pubDate>
		<dc:creator>Henrie Media Inc.</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.henriemedia.com/blog/?p=386</guid>
		<description><![CDATA[I am often asked the question of how to generate random numbers in JavaScript. It&#8217;s a little tricky and the results may be unpredictable, but the technique to getting them certainly is not. To generate a random number in JavaScript, simply use the following code: var randomnumber=Math.floor(Math.random()*11) where 11 dictates that the random number will [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-346" title="Computer" src="http://www.henriemedia.com/blog/wp-content/uploads/computer-icon.jpg" alt="Computer" width="150" height="130" />I am often asked the question of how to generate random numbers in JavaScript. It&#8217;s a little tricky and the results may be unpredictable, but the technique to getting them      certainly is not. To generate a random number in JavaScript, simply use the      following code:</p>
<div>
<pre>var randomnumber=Math.floor(Math.random()*11)</pre>
</div>
<p>where 11 dictates that the random number will fall between 0-10. To increase      the range to, say, 100, simply change 11 to 101 instead.</p>
<p>Some of you may be curious as to why Math.floor(), instead of Math.round(),      is used in the above code. While both successfully round off its containing      parameter to an integer within the designated range, Math.floor does so more      &#8220;evenly&#8221;, so the resulting integer isn&#8217;t lopsided towards either end of the      number spectrum. In other words, a more random number is returned using      Math.floor().</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Print, Email, Share, Enjoy!</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Frandom-numbers%2F&amp;partner=sociable" title="Print"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Random%20numbers%20in%20JavaScript&amp;body=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Frandom-numbers%2F" title="email"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Random%20numbers%20in%20JavaScript%20-%20http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Frandom-numbers%2F" title="Twitter"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Frandom-numbers%2F&amp;t=Random%20numbers%20in%20JavaScript" title="Facebook"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Frandom-numbers%2F&amp;title=Random%20numbers%20in%20JavaScript&amp;bodytext=I%20am%20often%20asked%20the%20question%20of%20how%20to%20generate%20random%20numbers%20in%20JavaScript.%20It%27s%20a%20little%20tricky%20and%20the%20results%20may%20be%20unpredictable%2C%20but%20the%20technique%20to%20getting%20them%20%20%20%20%20%20certainly%20is%20not.%20To%20generate%20a%20random%20number%20in%20JavaScript%2C%20simply%20use%20t" title="Digg"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Frandom-numbers%2F&amp;t=Random%20numbers%20in%20JavaScript" title="MySpace"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Frandom-numbers%2F&amp;title=Random%20numbers%20in%20JavaScript" title="Mixx"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Frandom-numbers%2F&amp;title=Random%20numbers%20in%20JavaScript&amp;notes=I%20am%20often%20asked%20the%20question%20of%20how%20to%20generate%20random%20numbers%20in%20JavaScript.%20It%27s%20a%20little%20tricky%20and%20the%20results%20may%20be%20unpredictable%2C%20but%20the%20technique%20to%20getting%20them%20%20%20%20%20%20certainly%20is%20not.%20To%20generate%20a%20random%20number%20in%20JavaScript%2C%20simply%20use%20t" title="del.icio.us"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Frandom-numbers%2F" title="Technorati"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript%2Frandom-numbers%2F&amp;title=Random%20numbers%20in%20JavaScript" title="StumbleUpon"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.henriemedia.com/blog/code-library/javascript/random-numbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript Timer</title>
		<link>http://www.henriemedia.com/blog/code-library/javascript-timer/</link>
		<comments>http://www.henriemedia.com/blog/code-library/javascript-timer/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 21:24:18 +0000</pubDate>
		<dc:creator>Henrie Media Inc.</dc:creator>
				<category><![CDATA[Code Library]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.henriemedia.com/?p=270</guid>
		<description><![CDATA[Sometimes you need to perform a function after a set time has passed. This script is a simple to use JavaScript timer. Here&#8217;s the script: &#60;SCRIPT LANGUAGE = "JavaScript"&#62; &#60;!-- var secs var timerID = null var timerRunning = false var delay = 1000 function InitializeTimer() { // Set the length of the timer, in [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-346" title="Computer" src="http://www.henriemedia.com/blog/wp-content/uploads/computer-icon.jpg" alt="Computer" width="150" height="130" />Sometimes you need to perform a function after a set time has passed. This script is a simple to use JavaScript timer.</p>
<p>Here&#8217;s the script:</p>
<pre>&lt;SCRIPT LANGUAGE = "JavaScript"&gt;
&lt;!--
var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 10
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        alert("You have just wasted 10 seconds of your life.")
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}
//--&gt;
&lt;/SCRIPT&gt;</pre>
<p>To use this script, copy everything between and including the &lt;SCRIPT&gt;  and &lt;/SCRIPT&gt; tags and insert it on your page between the  &lt;/HEAD&gt; and &lt;BODY&gt; tags.</p>
<p>The following line sets the length, in seconds, of the timer:</p>
<p><tt>secs = 10</tt></p>
<p>The code decreases the &#8220;secs&#8221; variable by 1 each second. When &#8220;secs&#8221; gets to 0, the clock is stopped and that&#8217;s when you do whatever it is you want to do once the timer is done (such as display a message or send the user to another page).</p>
<p>In the example above, I use a simple form button to start the timer (it also displays the countdown in the status bar). You could also start the timer (that is, run the <strong>InitializeTimer()</strong> function) automatically by adding the following to the &lt;BODY&gt; tag:</p>
<p><tt>onLoad="InitializeTimer()"</tt></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Print, Email, Share, Enjoy!</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript-timer%2F&amp;partner=sociable" title="Print"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=JavaScript%20Timer&amp;body=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript-timer%2F" title="email"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=JavaScript%20Timer%20-%20http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript-timer%2F" title="Twitter"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript-timer%2F&amp;t=JavaScript%20Timer" title="Facebook"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript-timer%2F&amp;title=JavaScript%20Timer&amp;bodytext=Sometimes%20you%20need%20to%20perform%20a%20function%20after%20a%20set%20time%20has%20passed.%20This%20script%20is%20a%20simple%20to%20use%20JavaScript%20timer.%0D%0A%0D%0AHere%27s%20the%20script%3A%0D%0A%26lt%3BSCRIPT%20LANGUAGE%20%3D%20%22JavaScript%22%26gt%3B%0D%0A%26lt%3B%21--%0D%0Avar%20secs%0D%0Avar%20timerID%20%3D%20null%0D%0Avar%20timerRunning%20%3D%20false%0D%0Avar" title="Digg"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript-timer%2F&amp;t=JavaScript%20Timer" title="MySpace"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript-timer%2F&amp;title=JavaScript%20Timer" title="Mixx"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript-timer%2F&amp;title=JavaScript%20Timer&amp;notes=Sometimes%20you%20need%20to%20perform%20a%20function%20after%20a%20set%20time%20has%20passed.%20This%20script%20is%20a%20simple%20to%20use%20JavaScript%20timer.%0D%0A%0D%0AHere%27s%20the%20script%3A%0D%0A%26lt%3BSCRIPT%20LANGUAGE%20%3D%20%22JavaScript%22%26gt%3B%0D%0A%26lt%3B%21--%0D%0Avar%20secs%0D%0Avar%20timerID%20%3D%20null%0D%0Avar%20timerRunning%20%3D%20false%0D%0Avar" title="del.icio.us"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript-timer%2F" title="Technorati"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fjavascript-timer%2F&amp;title=JavaScript%20Timer" title="StumbleUpon"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.henriemedia.com/blog/code-library/javascript-timer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirect to a Different URL using .htaccess</title>
		<link>http://www.henriemedia.com/blog/code-library/redirect-to-a-different-url-using-htaccess/</link>
		<comments>http://www.henriemedia.com/blog/code-library/redirect-to-a-different-url-using-htaccess/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 17:02:05 +0000</pubDate>
		<dc:creator>Henrie Media Inc.</dc:creator>
				<category><![CDATA[Code Library]]></category>
		<category><![CDATA[Configuration]]></category>

		<guid isPermaLink="false">http://www.henriemedia.com/?p=266</guid>
		<description><![CDATA[You can use .htaccess to redirect users to a different URL. The .htaccess looks for any request for a specific page and if it finds that request, it forwards it to a new page you have specified. The syntax is: redirect accessed-file URL-to-go-to There are 3 parts; (1) the Redirect command, (2) the location of [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-338" title="Apache logo" src="http://www.henriemedia.com/blog/wp-content/uploads/apache-logo.jpg" alt="Apache logo" width="150" height="134" />You can use .htaccess to redirect users to a different URL. The .htaccess looks for any request for a specific page and if it finds that request, it forwards it to a new page you have specified.</p>
<p>The syntax is:</p>
<p>redirect accessed-file URL-to-go-to</p>
<p>There are 3 parts;</p>
<p>(1) the Redirect command,<br />
(2) the location of the file/directory you want redirected, and<br />
(3) the full URL of the location you want that request sent to.</p>
<p>These parts are separated by a single space and should be on one line.</p>
<p>For example, if you want to redirect users from oldfile.html in the www directory of your account, myaccount, to newpage.html, the syntax should be</p>
<p>redirect /oldfile.html http://www.carefreetrip.com/newpage.html</p>
<p>Anyone going to http://www.carefreetrip.com/oldfile.html will end up on http://www.carefreetrip.com/newpage.html.</p>
<p>You must use a full URL even if you&#8217;re going to send the users to another page on your own site.<br />
You can also redirect an entire directory:</p>
<p>redirect /old_dir/ http://www.carefreetrip.com/new_dir/</p>
<p>Anyone going to http://www.carefreetrip.com/old_dir/filename.html will end up on http://www.carefreetrip.com/new_dir/filename.html.</p>
<p>After you set up the redirect, you should test it by going to the old URL.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Print, Email, Share, Enjoy!</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fredirect-to-a-different-url-using-htaccess%2F&amp;partner=sociable" title="Print"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Redirect%20to%20a%20Different%20URL%20using%20.htaccess&amp;body=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fredirect-to-a-different-url-using-htaccess%2F" title="email"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Redirect%20to%20a%20Different%20URL%20using%20.htaccess%20-%20http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fredirect-to-a-different-url-using-htaccess%2F" title="Twitter"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fredirect-to-a-different-url-using-htaccess%2F&amp;t=Redirect%20to%20a%20Different%20URL%20using%20.htaccess" title="Facebook"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fredirect-to-a-different-url-using-htaccess%2F&amp;title=Redirect%20to%20a%20Different%20URL%20using%20.htaccess&amp;bodytext=You%20can%20use%20.htaccess%20to%20redirect%20users%20to%20a%20different%20URL.%20The%20.htaccess%20looks%20for%20any%20request%20for%20a%20specific%20page%20and%20if%20it%20finds%20that%20request%2C%20it%20forwards%20it%20to%20a%20new%20page%20you%20have%20specified.%0D%0A%0D%0AThe%20syntax%20is%3A%0D%0A%0D%0Aredirect%20accessed-file%20URL-to-go-t" title="Digg"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fredirect-to-a-different-url-using-htaccess%2F&amp;t=Redirect%20to%20a%20Different%20URL%20using%20.htaccess" title="MySpace"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fredirect-to-a-different-url-using-htaccess%2F&amp;title=Redirect%20to%20a%20Different%20URL%20using%20.htaccess" title="Mixx"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fredirect-to-a-different-url-using-htaccess%2F&amp;title=Redirect%20to%20a%20Different%20URL%20using%20.htaccess&amp;notes=You%20can%20use%20.htaccess%20to%20redirect%20users%20to%20a%20different%20URL.%20The%20.htaccess%20looks%20for%20any%20request%20for%20a%20specific%20page%20and%20if%20it%20finds%20that%20request%2C%20it%20forwards%20it%20to%20a%20new%20page%20you%20have%20specified.%0D%0A%0D%0AThe%20syntax%20is%3A%0D%0A%0D%0Aredirect%20accessed-file%20URL-to-go-t" title="del.icio.us"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fredirect-to-a-different-url-using-htaccess%2F" title="Technorati"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fredirect-to-a-different-url-using-htaccess%2F&amp;title=Redirect%20to%20a%20Different%20URL%20using%20.htaccess" title="StumbleUpon"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.henriemedia.com/blog/code-library/redirect-to-a-different-url-using-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pausing the timeline in Flash</title>
		<link>http://www.henriemedia.com/blog/code-library/pausing-the-timeline-in-flash/</link>
		<comments>http://www.henriemedia.com/blog/code-library/pausing-the-timeline-in-flash/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 16:13:14 +0000</pubDate>
		<dc:creator>Henrie Media Inc.</dc:creator>
				<category><![CDATA[Code Library]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.henriemedia.com/?p=261</guid>
		<description><![CDATA[I had a need to pause the timeline in a Flash project I was working on and found this script. I thought I would post it for others if they need to accomplish the same thing. Enjoy! stop(); var nInterval = setInterval(Play, 5000); function Play() { clearInterval(nInterval); gotoAndPlay(_currentframe+1); } so what does Every line mean [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-336" title="Flash" src="http://www.henriemedia.com/blog/wp-content/uploads/flash-logo.jpg" alt="Flash" width="168" height="148" />I had a need to pause the timeline in a Flash project I was working on and found this script. I thought I would post it for others if they need to accomplish the same thing. Enjoy!</p>
<blockquote><p>stop();</p>
<p>var nInterval = setInterval(Play, 5000);</p>
<p>function Play() {<br />
clearInterval(nInterval);<br />
gotoAndPlay(_currentframe+1);<br />
}</p></blockquote>
<p>so what does Every line mean …</p>
<blockquote><p><em>stop();</em><br />
//stop at your desired frame .</p></blockquote>
<p>//Build the interval<br />
// 1 second = 1000 milliseconds  1 x 1000<br />
//  setinterval(the-function , time[in milliseconds])</p>
<blockquote><p><em>var nInterval = setInterval(Play, 5000);</em></p></blockquote>
<p>/*function which will excute and clear the interval &amp; Will play the next<br />
Frame after 5 sec.*/</p>
<p><em>function Play() {<br />
clearInterval(nInterval);<br />
gotoAndPlay(_currentframe+1);</em></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Print, Email, Share, Enjoy!</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fpausing-the-timeline-in-flash%2F&amp;partner=sociable" title="Print"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Pausing%20the%20timeline%20in%20Flash&amp;body=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fpausing-the-timeline-in-flash%2F" title="email"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Pausing%20the%20timeline%20in%20Flash%20-%20http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fpausing-the-timeline-in-flash%2F" title="Twitter"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fpausing-the-timeline-in-flash%2F&amp;t=Pausing%20the%20timeline%20in%20Flash" title="Facebook"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fpausing-the-timeline-in-flash%2F&amp;title=Pausing%20the%20timeline%20in%20Flash&amp;bodytext=I%20had%20a%20need%20to%20pause%20the%20timeline%20in%20a%20Flash%20project%20I%20was%20working%20on%20and%20found%20this%20script.%20I%20thought%20I%20would%20post%20it%20for%20others%20if%20they%20need%20to%20accomplish%20the%20same%20thing.%20Enjoy%21%0D%0Astop%28%29%3B%0D%0A%0D%0Avar%20nInterval%20%3D%20setInterval%28Play%2C%205000%29%3B%0D%0A%0D%0Afunction%20Play" title="Digg"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fpausing-the-timeline-in-flash%2F&amp;t=Pausing%20the%20timeline%20in%20Flash" title="MySpace"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fpausing-the-timeline-in-flash%2F&amp;title=Pausing%20the%20timeline%20in%20Flash" title="Mixx"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fpausing-the-timeline-in-flash%2F&amp;title=Pausing%20the%20timeline%20in%20Flash&amp;notes=I%20had%20a%20need%20to%20pause%20the%20timeline%20in%20a%20Flash%20project%20I%20was%20working%20on%20and%20found%20this%20script.%20I%20thought%20I%20would%20post%20it%20for%20others%20if%20they%20need%20to%20accomplish%20the%20same%20thing.%20Enjoy%21%0D%0Astop%28%29%3B%0D%0A%0D%0Avar%20nInterval%20%3D%20setInterval%28Play%2C%205000%29%3B%0D%0A%0D%0Afunction%20Play" title="del.icio.us"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fpausing-the-timeline-in-flash%2F" title="Technorati"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fpausing-the-timeline-in-flash%2F&amp;title=Pausing%20the%20timeline%20in%20Flash" title="StumbleUpon"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.henriemedia.com/blog/code-library/pausing-the-timeline-in-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Displaying Load Time using PHP</title>
		<link>http://www.henriemedia.com/blog/code-library/displaying-load-time-using-php/</link>
		<comments>http://www.henriemedia.com/blog/code-library/displaying-load-time-using-php/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 15:26:30 +0000</pubDate>
		<dc:creator>Henrie Media Inc.</dc:creator>
				<category><![CDATA[Code Library]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.henriemedia.com/?p=258</guid>
		<description><![CDATA[When developing PHP-driven websites its often very useful to know how long your pages took to process.  This not only gives you some idea of the efficiency of your websites and of the server running them, but may help you diagnose problems, benchmark code corrections/additions, etc.  The best way to do this is program PHP [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-334" title="php-logo" src="http://www.henriemedia.com/blog/wp-content/uploads/php-logo.jpg" alt="php-logo" width="150" height="79" />When developing PHP-driven websites its often very useful to know how long your pages took to process.  This not only gives you some idea of the efficiency of your websites and of the server running them, but may help you diagnose problems, benchmark code corrections/additions, etc.  The best way to do this is program PHP to read the system time at the beginning of the page, scan it again near the end, and then work out the difference between the values.  To get us started, just add the following basic code near the top of your page, before all the main content:</p>
<p>&lt;?php<br />
$starttime = microtime();<br />
$startarray = explode(&#8221; &#8220;, $starttime);<br />
$starttime = $startarray[1] + $startarray[0];<br />
?&gt;</p>
<p>It may look complex, but the above code is actually dead simple.  Microtime is a function that returns a value giving the current time in seconds and milliseconds from the UNIX Epoch (internationally set as 0:00:00 January 1, 1970 GMT).   Explode then splits this value into its two component parts (seconds and milliseconds), and then inserts both values separately into an array.   With those values determined, of course, we can go on to insert the following code near the end of the webpage, after all the main code:</p>
<p>&lt;?php<br />
$endtime = microtime();<br />
$endarray = explode(&#8221; &#8220;, $endtime);<br />
$endtime = $endarray[1] + $endarray[0];<br />
$totaltime = $endtime &#8211; $starttime;<br />
$totaltime = round($totaltime,5);<br />
echo &#8220;This page loaded in $totaltime seconds.&#8221;;<br />
?&gt;</p>
<p>The microtime is determined again and inserted into the endtime array.  We then delete the starttime array from it and come up with a brand new value, totaltime (which is the value we&#8217;ve wanted all along).  The number is then rounded to 5 significant figures, and output by the ECHO command.  If you&#8217;ve entered everything correctly, you should end up with a line of text saying something like this:</p>
<p>Page generated in 0.27283 seconds</p>
<p>That is all there is to it. Make sure you keep in mind that this measure depends heavily on server load levels, mySQL commands, etc. Make sure you take into account all of these factors when determine load time.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Print, Email, Share, Enjoy!</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fdisplaying-load-time-using-php%2F&amp;partner=sociable" title="Print"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Displaying%20Load%20Time%20using%20PHP&amp;body=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fdisplaying-load-time-using-php%2F" title="email"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Displaying%20Load%20Time%20using%20PHP%20-%20http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fdisplaying-load-time-using-php%2F" title="Twitter"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fdisplaying-load-time-using-php%2F&amp;t=Displaying%20Load%20Time%20using%20PHP" title="Facebook"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fdisplaying-load-time-using-php%2F&amp;title=Displaying%20Load%20Time%20using%20PHP&amp;bodytext=When%20developing%20PHP-driven%20websites%20its%20often%20very%20useful%20to%20know%20how%20long%20your%20pages%20took%20to%20process.%C2%A0%20This%20not%20only%20gives%20you%20some%20idea%20of%20the%20efficiency%20of%20your%20websites%20and%20of%20the%20server%20running%20them%2C%20but%20may%20help%20you%20diagnose%20problems%2C%20benchmar" title="Digg"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fdisplaying-load-time-using-php%2F&amp;t=Displaying%20Load%20Time%20using%20PHP" title="MySpace"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fdisplaying-load-time-using-php%2F&amp;title=Displaying%20Load%20Time%20using%20PHP" title="Mixx"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fdisplaying-load-time-using-php%2F&amp;title=Displaying%20Load%20Time%20using%20PHP&amp;notes=When%20developing%20PHP-driven%20websites%20its%20often%20very%20useful%20to%20know%20how%20long%20your%20pages%20took%20to%20process.%C2%A0%20This%20not%20only%20gives%20you%20some%20idea%20of%20the%20efficiency%20of%20your%20websites%20and%20of%20the%20server%20running%20them%2C%20but%20may%20help%20you%20diagnose%20problems%2C%20benchmar" title="del.icio.us"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fdisplaying-load-time-using-php%2F" title="Technorati"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fdisplaying-load-time-using-php%2F&amp;title=Displaying%20Load%20Time%20using%20PHP" title="StumbleUpon"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.henriemedia.com/blog/code-library/displaying-load-time-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use a 301 Redirect</title>
		<link>http://www.henriemedia.com/blog/code-library/how-to-use-a-301-redirect/</link>
		<comments>http://www.henriemedia.com/blog/code-library/how-to-use-a-301-redirect/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 17:59:18 +0000</pubDate>
		<dc:creator>Henrie Media Inc.</dc:creator>
				<category><![CDATA[Code Library]]></category>
		<category><![CDATA[Configuration]]></category>

		<guid isPermaLink="false">http://www.henriemedia.com/?p=170</guid>
		<description><![CDATA[A 301 redirect is the best method to preserve your current search engine rankings when redirecting web pages or a website. The code &#8220;301&#8243; is interpreted as &#8220;moved permanently&#8221;. After the code, the URL of the missing or renamed page is noted, followed by a space, then followed by the new location or file name. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-338" title="Apache logo" src="http://www.henriemedia.com/blog/wp-content/uploads/apache-logo.jpg" alt="Apache logo" width="150" height="134" />A 301 redirect is the best method to preserve your current search engine rankings when redirecting web pages or a website. The code &#8220;301&#8243; is interpreted as &#8220;moved permanently&#8221;. After the code, the URL of the missing or renamed page is noted, followed by a space, then followed by the new location or file name. You implement the 301 redirect by<br />
creating a .htaccess file.</p>
<p>What is a .htaccess file?</p>
<p>When a visitor/spider requests a web page, your web server checks for a .htaccess file. The .htaccess file contains specific instructions for certain requests, including security, redirection issues and how to handle certain errors.</p>
<p><strong>How to implement the 301 Redirect</strong></p>
<ol>
<li>To create a .htaccess file, open notepad, name and save the file as .htaccess (there is no extension).</li>
<li>If you already have a .htaccess file on your server, download it to your desktop for editing.</li>
<li>Place this code in your .htaccess file: redirect 301 /old/old.htm http://www.you.com/new.htm</li>
<li>If the .htaccess file already has lines of code in it, skip a line, then add the above code.</li>
<li>Save the .htaccess file</li>
<li>Upload this file to the root folder of your server.</li>
<li>Test it by typing in the old address to the page you&#8217;ve changed. You should be immediately taken to the new location.</li>
</ol>
<p>CONSIDER THIS: Don&#8217;t add &#8220;http://www&#8221; to the first part of the statement &#8211; place the path from the top level of your site to the page. Also ensure that you leave a single space between these elements:</p>
<blockquote><p>redirect 301 (the instruction that the page has moved)</p>
<p>/old/old.htm (the original folder path and file name)</p>
<p>http://www.you.com/new.htm (new path and file name)</p></blockquote>
<p>When the search engines spider your site again they will follow the rule you have created in your .htaccess file. The search engine spider doesn&#8217;t actually read the .htaccess file, but recognizes the response from the server as valid.</p>
<p>During the next update, the old file name and path will be dropped and replaced with the new one. Sometimes you may see alternating old/new file names during the transition period, plus some fluctuations in rankings. According to<br />
Google it will take 6-8 weeks to see the changes reflected on your pages.<br />
<strong><br />
Other ways to implement the 301 redirect:</strong></p>
<ul>
<li>To redirect ALL files on your domain use this in your .htaccess file if you are on a unix web server:</li>
</ul>
<blockquote><p>redirectMatch 301 ^(.*)$ http://www.domain.com<br />
redirectMatch permanent ^(.*)$ http://www.domain.com</p>
<p>You can also use one of these in your .htaccess file:</p>
<p>redirect 301 /index.html http://www.domain.com/index.html<br />
redirect permanent /index.html http://www.domain.com/index.html<br />
redirectpermanent /index.html http://www.domain.com/index.html</p>
<p>This will redirect &#8220;index.html&#8221; to another domain using a 301-Moved permanently redirect.</p></blockquote>
<ul>
<li>If you need to redirect http://mysite.com to http://www.mysite.com and you&#8217;ve got mod_rewrite enabled on your server you can put this in your .htaccess file:</li>
</ul>
<blockquote><p>Options +FollowSymLinks<br />
RewriteEngine on<br />
RewriteCond %{HTTP_HOST} ^example.com<br />
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]</p>
<p>or this:</p>
<p>Options +FollowSymLinks<br />
RewriteEngine On<br />
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]<br />
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]</p>
<p>Use your full URL (ie http://www.domain.com) when obtaining incoming links to your site. Also use your full URL for the internal linking of your site.</p></blockquote>
<ul>
<li> If you want to redirect your .htm pages to .php pages and you&#8217;ve got mod_rewrite enabled on your server you can put this in your .htaccess file:</li>
</ul>
<blockquote><p>RewriteEngine on<br />
RewriteBase /<br />
RewriteRule (.*).htm$ /$1.php</p></blockquote>
<ul>
<li>If you wish to redirect your .html or .htm pages to .shtml pages because you are using Server Side Includes (SSI) add this code to your .htaccess file:</li>
</ul>
<blockquote><p>AddType text/html .shtml<br />
AddHandler server-parsed .shtml .html .htm<br />
Options Indexes FollowSymLinks Includes<br />
DirectoryIndex index.shtml index.html</p></blockquote>
<p><em><strong>What&#8217;s the difference in using a 301 redirect versus a meta redirect?</strong></em></p>
<p>Meta Redirect<br />
To send someone to a new page (or site) put this in the head of your document:</p>
<p>&lt;meta http-equiv=&#8221;refresh&#8221; content=&#8221;10; url=http://mynewsite.com/&#8221;&gt;</p>
<p>Content=&#8221;10; tells the browser to wait 10 seconds before transfer, choose however long you would like, you can even choose 0 to give a smoother transition, but some (really old) browsers aren&#8217;t capable of using this so I&#8217;d suggest putting a link on that page to your new site for them.</p>
<p>With a meta redirect the page with the redirect issues a 200 OK status and some other mechanism moves the browser over to the new URL. With a 200 OK on both pages, the search engine wants to index both the start page and the target page &#8211; and that is a known spam method (set up 10,000 domains full of keywords for the search engines to index then meta redirect the &#8220;real visitor&#8221; after 0 or 1 seconds to the &#8220;real site&#8221; ) so using it gets you penalized.</p>
<p>The 301 redirect simply issues a Permanently Moved message in the HTTP header which tells the search engine to only index the target URL.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Print, Email, Share, Enjoy!</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fhow-to-use-a-301-redirect%2F&amp;partner=sociable" title="Print"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=How%20to%20use%20a%20301%20Redirect&amp;body=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fhow-to-use-a-301-redirect%2F" title="email"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=How%20to%20use%20a%20301%20Redirect%20-%20http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fhow-to-use-a-301-redirect%2F" title="Twitter"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fhow-to-use-a-301-redirect%2F&amp;t=How%20to%20use%20a%20301%20Redirect" title="Facebook"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fhow-to-use-a-301-redirect%2F&amp;title=How%20to%20use%20a%20301%20Redirect&amp;bodytext=A%20301%20redirect%20is%20the%20best%20method%20to%20preserve%20your%20current%20search%20engine%20rankings%20when%20redirecting%20web%20pages%20or%20a%20website.%20The%20code%20%22301%22%20is%20interpreted%20as%20%22moved%20permanently%22.%20After%20the%20code%2C%20the%20URL%20of%20the%20missing%20or%20renamed%20page%20is%20noted%2C%20followed" title="Digg"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fhow-to-use-a-301-redirect%2F&amp;t=How%20to%20use%20a%20301%20Redirect" title="MySpace"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fhow-to-use-a-301-redirect%2F&amp;title=How%20to%20use%20a%20301%20Redirect" title="Mixx"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fhow-to-use-a-301-redirect%2F&amp;title=How%20to%20use%20a%20301%20Redirect&amp;notes=A%20301%20redirect%20is%20the%20best%20method%20to%20preserve%20your%20current%20search%20engine%20rankings%20when%20redirecting%20web%20pages%20or%20a%20website.%20The%20code%20%22301%22%20is%20interpreted%20as%20%22moved%20permanently%22.%20After%20the%20code%2C%20the%20URL%20of%20the%20missing%20or%20renamed%20page%20is%20noted%2C%20followed" title="del.icio.us"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fhow-to-use-a-301-redirect%2F" title="Technorati"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.henriemedia.com%2Fblog%2Fcode-library%2Fhow-to-use-a-301-redirect%2F&amp;title=How%20to%20use%20a%20301%20Redirect" title="StumbleUpon"><img src="http://www.henriemedia.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.henriemedia.com/blog/code-library/how-to-use-a-301-redirect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
