<?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>Ryan Stemkoski &#187; PHP Development</title>
	<atom:link href="http://www.stemkoski.com/category/php-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stemkoski.com</link>
	<description>Web design tips &#38; tricks plus anything else I want to talk about...</description>
	<lastBuildDate>Sat, 07 Jan 2012 18:34:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Redefining or changing a PHP $_SERVER variable for an entire website.</title>
		<link>http://www.stemkoski.com/redefining-or-changing-a-php-_server-variable-for-an-entire-website/</link>
		<comments>http://www.stemkoski.com/redefining-or-changing-a-php-_server-variable-for-an-entire-website/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 22:54:57 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1516</guid>
		<description><![CDATA[Today, I was faced with the need to redefine a PHP $_SERVER variable for an entire application, made up of hundreds of PHP pages. In this case, I needed to redefine $_SERVER['DOCUMENT_ROOT'] for an entire website. The application was built by another company under the assumption that $_SERVER['DOCUMENT_ROOT'] would always point to the document root, [...]


Related posts:<ol><li><a href='http://www.stemkoski.com/how-to-detect-a-users-language-with-php/' rel='bookmark' title='Permanent Link: How to Detect a User&#8217;s Language with PHP'>How to Detect a User&#8217;s Language with PHP</a> <small>I was recently looking for a simple way to automatically...</small></li>
<li><a href='http://www.stemkoski.com/remove-unnecessary-querystring-from-htaccess-301-permanent-redirects/' rel='bookmark' title='Permanent Link: Remove Unnecessary Querystring From .htaccess 301 Permanent Redirects'>Remove Unnecessary Querystring From .htaccess 301 Permanent Redirects</a> <small>Today I ran into an odd problem while trying to...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Today, I was faced with the need to redefine a PHP $_SERVER variable for an entire application, made up of hundreds of PHP pages. In this case, I needed to redefine $_SERVER['DOCUMENT_ROOT'] for an entire website.  The application was built by another company under the assumption that $_SERVER['DOCUMENT_ROOT'] would always point to the document root, however, on some virtual servers this is not the case.  The solution actually proved to be very easy, and could be used to redefine other PHP $_SERVER variables as required.</p>
<h2>Solution:</h2>
<h3>Step 1:</h3>
<p>Create a PHP file, in this case we are naming it document_root.php.   The PHP file should contain the following code (Make sure to replace our path with your path to your document root):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;DOCUMENT_ROOT&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/usr/local/www/htdocs/domainname.com/www&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>Step 2:</h3>
<p>Add the following code at the top of your .htaccess file (Make sure to replace the document_root.php with your file.  If your file is nested in a directory include the file path as well):</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">php_value auto_prepend_file &quot;document_root.php&quot;</pre></div></div>

<p>Reload your website and poof, Apache will parse the document_root.php file and set the $_SERVER['DOCUMENT_ROOT'] value on every page you load. </p>
<p>Note: If you are redefining a different global variable or multiple global variables you can revise the PHP file accordingly.</p>


<p>Related posts:<ol><li><a href='http://www.stemkoski.com/how-to-detect-a-users-language-with-php/' rel='bookmark' title='Permanent Link: How to Detect a User&#8217;s Language with PHP'>How to Detect a User&#8217;s Language with PHP</a> <small>I was recently looking for a simple way to automatically...</small></li>
<li><a href='http://www.stemkoski.com/remove-unnecessary-querystring-from-htaccess-301-permanent-redirects/' rel='bookmark' title='Permanent Link: Remove Unnecessary Querystring From .htaccess 301 Permanent Redirects'>Remove Unnecessary Querystring From .htaccess 301 Permanent Redirects</a> <small>Today I ran into an odd problem while trying to...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/redefining-or-changing-a-php-_server-variable-for-an-entire-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove Unnecessary Querystring From .htaccess 301 Permanent Redirects</title>
		<link>http://www.stemkoski.com/remove-unnecessary-querystring-from-htaccess-301-permanent-redirects/</link>
		<comments>http://www.stemkoski.com/remove-unnecessary-querystring-from-htaccess-301-permanent-redirects/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 16:53:47 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[301]]></category>
		<category><![CDATA[redirect]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1430</guid>
		<description><![CDATA[Today I ran into an odd problem while trying to create permanent redirects on a website to help with search engine optimization. The website I was working on used a fairly standard URL rewrite rule that rewrite all portions of the URL to a querystring and then the application handled the querystring internally. This methodology [...]


Related posts:<ol><li><a href='http://www.stemkoski.com/how-to-detect-a-users-language-with-php/' rel='bookmark' title='Permanent Link: How to Detect a User&#8217;s Language with PHP'>How to Detect a User&#8217;s Language with PHP</a> <small>I was recently looking for a simple way to automatically...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Today I ran into an odd problem while trying to create permanent redirects on a website to help with search engine optimization.  The website I was working on used a fairly standard URL rewrite rule that rewrite all portions of the URL to a querystring and then the application handled the querystring internally.  This methodology is common in many CMS systems and also in the popular Codeigniter framework.  When I attempted to use standard .htaccess 301 permanent redirects they would add an unexpected querystring to the URL containing the previous URL that we were rewriting.</p>
<p>To illustrate the problem.  I was attempting to rewrite /old-page to http://www.website.com/new-page and when the redirection occurred I would get something along the address of http://www.website.com/new-page/?url=old-page.</p>
<p>I couldn&#8217;t figure out a solution for the problem using standard redirects such as:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">Redirect 301 /old-url http://www.website.com/new-url</pre></div></div>

<p>I tried different variations and position and nothing seemed to work.  After some experimentation I decided to approach the problem from another direction.  Instead I created a RewriteRule to handle the rewriting and then included two designations [L] indicating this is the final rule and to tell apache to stop looking for additional rules if this condition is met and then I specified [R=301] indicating this is 301 redirect.  (CAUTION: Do not just use [R] as this is recorded as  302 redirect which is not a preferred redirect type for SEO)</p>
<p>The final redirect looks like this in .htaccess and seems to work as expected.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">RewriteRule ^old-url?/?$ http://www.website.com/new-url [L,R=301]</pre></div></div>

<p>There are likely other ways to approach this problem but this one is working great for me. Let me know if you have any problems implementing this methodology into your .htaccess file.</p>


<p>Related posts:<ol><li><a href='http://www.stemkoski.com/how-to-detect-a-users-language-with-php/' rel='bookmark' title='Permanent Link: How to Detect a User&#8217;s Language with PHP'>How to Detect a User&#8217;s Language with PHP</a> <small>I was recently looking for a simple way to automatically...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/remove-unnecessary-querystring-from-htaccess-301-permanent-redirects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Detect a User&#8217;s Language with PHP</title>
		<link>http://www.stemkoski.com/how-to-detect-a-users-language-with-php/</link>
		<comments>http://www.stemkoski.com/how-to-detect-a-users-language-with-php/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 14:20:26 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1424</guid>
		<description><![CDATA[I was recently looking for a simple way to automatically detect a user&#8217;s language using PHP. There are a number of ways this could be accomplished but after some thought I realized the easiest is to get that information from the users web browser. Users are most likely to browse the web in a language [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I was recently looking for a simple way to automatically detect a user&#8217;s language using PHP.  There are a number of ways this could be accomplished but after some thought I realized the easiest is to get that information from the users web browser.  Users are most likely to browse the web in a language they are comfortable with and your browser will send your accepted language in the HTTP headers when loading a page. After some quick research we realized this is indeed correct and the data is contained within the $_SERVER object, it just happened to be one of the variables we hadn&#8217;t used previously.</p>
<p>I put together a quick snippet below that extracts the two digit language code and stores it as a variable.  You could use this to load different content, to redirect to another version of the website using the proper language, or to sculpt the user experience.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?PHP</span> 
&nbsp;
    <span style="color: #666666; font-style: italic;">//EXTRACT THE TWO DIGIT LANGUAGE CODE FROM THE HTTP HEADERS</span>
    <span style="color: #000088;">$lang</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_ACCEPT_LANGUAGE'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>



<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/how-to-detect-a-users-language-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Start MySQL Auto-Increment at a Number Other Than 1</title>
		<link>http://www.stemkoski.com/start-mysql-auto-increment-at-a-number-other-than-1/</link>
		<comments>http://www.stemkoski.com/start-mysql-auto-increment-at-a-number-other-than-1/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 23:11:31 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1418</guid>
		<description><![CDATA[By default, MySQL will start auto incrementing from 1 with each new entry. This means the first entry in a database is 1, the second is 2, and so on. Occasionally, it may be helpful to start this number at another value. It could be for sequential product numbers, better disguised customer ID numbers, or [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>By default, MySQL will start auto incrementing from 1 with each new entry.  This means the first entry in a database is 1, the second is 2, and so on.  Occasionally, it may be helpful to start this number at another value.  It could be for sequential product numbers, better disguised customer ID numbers, or any number of other programmatic reasons.  Many regular MySQL users don&#8217;t realize it but MySQL has a simple method of choosing the auto increment starting value for a given table.  You can adjust the number to whatever you would like by executing the following SQL:</p>

<div class="wp_syntax"><div class="code"><pre class="html5strict" style="font-family:monospace;">ALTER TABLE table AUTO_INCREMENT = 1000;</pre></div></div>

<p>(Where 1000 is the number you would like to start the auto incrementing at)</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/start-mysql-auto-increment-at-a-number-other-than-1/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Christmas 2009</title>
		<link>http://www.stemkoski.com/christmas-2009/</link>
		<comments>http://www.stemkoski.com/christmas-2009/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 13:36:04 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Christmas]]></category>
		<category><![CDATA[Family]]></category>
		<category><![CDATA[Kayla]]></category>
		<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1362</guid>
		<description><![CDATA[This year we had 3 Christmas events. The first was with my side of the family the week prior to Christmas and the last two were with Kayla’s family on Christmas Eve and Christmas day. Since I have been too busy lately with work and family to sit down and write I thought I would [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>This year we had 3 Christmas events.  The first was with my side of the family the week prior to Christmas and the last two were with Kayla’s family on Christmas Eve and Christmas day.  Since I have been too busy lately with work and family to sit down and write I thought I would share a few photos from Christmas Eve.  They’re mostly of Holden, Leah, and Mya our nieces and nephews on Kayla’s side.<br />

<a href='http://www.stemkoski.com/christmas-2009/img_5739/' title='IMG_5739'><img width="150" height="150" src="http://www.stemkoski.com/wp-content/uploads/2009/12/IMG_5739-150x150.jpg" class="attachment-thumbnail" alt="IMG_5739" title="IMG_5739" /></a>
<a href='http://www.stemkoski.com/christmas-2009/img_5751/' title='IMG_5751'><img width="150" height="150" src="http://www.stemkoski.com/wp-content/uploads/2009/12/IMG_5751-150x150.jpg" class="attachment-thumbnail" alt="IMG_5751" title="IMG_5751" /></a>
<a href='http://www.stemkoski.com/christmas-2009/img_5765/' title='IMG_5765'><img width="150" height="150" src="http://www.stemkoski.com/wp-content/uploads/2009/12/IMG_5765-150x150.jpg" class="attachment-thumbnail" alt="IMG_5765" title="IMG_5765" /></a>
<a href='http://www.stemkoski.com/christmas-2009/img_5806/' title='IMG_5806'><img width="150" height="150" src="http://www.stemkoski.com/wp-content/uploads/2009/12/IMG_5806-150x150.jpg" class="attachment-thumbnail" alt="IMG_5806" title="IMG_5806" /></a>
<a href='http://www.stemkoski.com/christmas-2009/img_5811/' title='IMG_5811'><img width="150" height="150" src="http://www.stemkoski.com/wp-content/uploads/2009/12/IMG_5811-150x150.jpg" class="attachment-thumbnail" alt="IMG_5811" title="IMG_5811" /></a>
<a href='http://www.stemkoski.com/christmas-2009/img_5818/' title='IMG_5818'><img width="150" height="150" src="http://www.stemkoski.com/wp-content/uploads/2009/12/IMG_5818-150x150.jpg" class="attachment-thumbnail" alt="IMG_5818" title="IMG_5818" /></a>
<a href='http://www.stemkoski.com/christmas-2009/img_5847/' title='IMG_5847'><img width="150" height="150" src="http://www.stemkoski.com/wp-content/uploads/2009/12/IMG_5847-150x150.jpg" class="attachment-thumbnail" alt="IMG_5847" title="IMG_5847" /></a>
<a href='http://www.stemkoski.com/christmas-2009/img_5862/' title='IMG_5862'><img width="150" height="150" src="http://www.stemkoski.com/wp-content/uploads/2009/12/IMG_5862-150x150.jpg" class="attachment-thumbnail" alt="IMG_5862" title="IMG_5862" /></a>
<a href='http://www.stemkoski.com/christmas-2009/img_5889/' title='IMG_5889'><img width="150" height="150" src="http://www.stemkoski.com/wp-content/uploads/2009/12/IMG_5889-150x150.jpg" class="attachment-thumbnail" alt="IMG_5889" title="IMG_5889" /></a>
<a href='http://www.stemkoski.com/christmas-2009/img_5903/' title='IMG_5903'><img width="150" height="150" src="http://www.stemkoski.com/wp-content/uploads/2009/12/IMG_5903-150x150.jpg" class="attachment-thumbnail" alt="IMG_5903" title="IMG_5903" /></a>
<a href='http://www.stemkoski.com/christmas-2009/img_5925/' title='IMG_5925'><img width="150" height="150" src="http://www.stemkoski.com/wp-content/uploads/2009/12/IMG_5925-150x150.jpg" class="attachment-thumbnail" alt="IMG_5925" title="IMG_5925" /></a>
<a href='http://www.stemkoski.com/christmas-2009/img_5948/' title='IMG_5948'><img width="150" height="150" src="http://www.stemkoski.com/wp-content/uploads/2009/12/IMG_5948-150x150.jpg" class="attachment-thumbnail" alt="IMG_5948" title="IMG_5948" /></a>
</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/christmas-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Read a Remote Text File with PHP</title>
		<link>http://www.stemkoski.com/how-to-read-a-remote-text-file-with-php/</link>
		<comments>http://www.stemkoski.com/how-to-read-a-remote-text-file-with-php/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 16:34:17 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Zipline]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Remote]]></category>
		<category><![CDATA[Text Files]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1347</guid>
		<description><![CDATA[Reading text files with PHP isn’t really too difficult. I have done it quite a few times but it isn’t something I do everyday. A few weeks ago, I wrote a simple script to read a text file and it has been working great, until today. Originally, the script I wrote was reading a very [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Reading text files with PHP isn’t really too difficult.  I have done it quite a few times but it isn’t something I do everyday.  A few weeks ago, I wrote a simple script to read a text file and it has been working great, until today.  Originally, the script I wrote was reading a very simple text file and it had no problems. Unfortunately, today I tried to use it to read a larger text file and discovered that when reading remote files fopen will stop after a packet is available. If you need to read a larger file this can be a real problem.</p>
<p><strong>Original </strong><br />
Below is the original script that had the problem with larger files, it works great with local files and also with short remote files. Check it out here:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?PHP</span>
	<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.ietf.org/rfc/rfc2396.txt&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;rb&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fread</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">8192</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>Improved</strong><br />
If you have a longer file then you can solve the packet issue by concatenating the file together in several groupings.  An example of the revised and working script has been included below:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?PHP</span>
	<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.ietf.org/rfc/rfc2396.txt&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;rb&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">feof</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	 	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">fread</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">8192</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><em>Note: I have no idea what the text file used in this example is for. I just grabbed it from a Google search because it was large enough to demonstrate the problem I am illustrating.</em></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/how-to-read-a-remote-text-file-with-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Software to Automatically Make a HTML version of a Dynamic Website</title>
		<link>http://www.stemkoski.com/software-to-automatically-make-a-html-version-of-a-dynamic-website/</link>
		<comments>http://www.stemkoski.com/software-to-automatically-make-a-html-version-of-a-dynamic-website/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 14:00:07 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Zipline]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Website Backup]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1351</guid>
		<description><![CDATA[It seems like there are a million different content management systems out there. Some like the ZLCMS system we use at Zipline are transferrable to another web host but occasionally we have run into web development companies with ‘proprietary’ content management systems. Many of these companies won’t allow their customers to transfer their website to [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>It seems like there are a million different content management systems out there.  Some like the ZLCMS system we use at Zipline are transferrable to another web host but occasionally we have run into web development companies with ‘proprietary’ content management systems. Many of these companies won’t allow their customers to transfer their website to another hosting company. Often, when we run into these situations the customers are willing to forfeit their content management just to get away from the web development company they are working with.  On a few of these occasions we have been forced to hand backup an entire HTML website, updating images, links, etc.</p>
<p>Years ago I had a software program that would copy down an entire HTML site fairly accurately.  Unfortunately, as the web transitioned to dynamic websites this software package could not keep up with the advances.</p>
<p>Today, I discovered a website backup utility that has done a fantastic job in my tests.   I backed up several of our complicated dynamic websites and it has done a great job making them work in an HTML version.  If you run into a situation where your website, or your customers website is being held hostage by a web design company this could be the perfect solution for you.</p>
<p>The software is called HTTrack Website Copier and it is a free GPL licensed software package.</p>
<h3><a href="http://download.httrack.com/cserv.php3?File=httrack.exe">Click here to download HTTrack</a></h3>
<p></p>
<p>If you have any comments or questions please leave a comment below. </p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/software-to-automatically-make-a-html-version-of-a-dynamic-website/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to use PHP in .htm or .html Files</title>
		<link>http://www.stemkoski.com/how-to-use-php-in-htm-or-html-files/</link>
		<comments>http://www.stemkoski.com/how-to-use-php-in-htm-or-html-files/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 16:15:48 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[htm]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1313</guid>
		<description><![CDATA[The need to execute PHP in HTM or HTML files may occur for a number of reasons. The most common of which seems to be adding content managed portions to an existing HTML website. The .htm or .html pages will be part of the navigation, previously indexed by search engines, and likely linked to by [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>The need to execute PHP in HTM or HTML files may occur for a number of reasons.  The most common of which seems to be adding content managed portions to an existing HTML website.  The .htm or .html pages will be part of the navigation, previously indexed by search engines, and likely linked to by other websites. Instead of changing the URL to .php for our updates we can convince the server to execute .htm or .html just as it would a .php file saving both the developer and customer from a number of headaches.<br />
This can be done by adding the following lines to your .htaccess file.<br />
<strong><br />
If your web server is using PHP as an Apache Module:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">AddType application/x-httpd-php .html .htm</pre></div></div>

<p><strong>For web servers funning PHP as CGI </strong></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">AddHandler application/x-httpd-php .html .htm</pre></div></div>

<p>If you happen to be running IIS this can still be done but it is a bit more difficult and a topic for another post on another day.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/how-to-use-php-in-htm-or-html-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Detect IE6 Browser with JavaScript</title>
		<link>http://www.stemkoski.com/how-to-detect-ie6-with-javascript/</link>
		<comments>http://www.stemkoski.com/how-to-detect-ie6-with-javascript/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 15:20:56 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Browser Detection]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[Internet Explorer 6]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1306</guid>
		<description><![CDATA[I have been doing a lot of work with jQuery lately. The jQuery library offers great cross browser support for most functions but unfortunately even this magic wand can’t solve all the problems with Internet Explorer 6 (IE6) compatibility. Previously, jQuery had a browser() function that helped detect a browser so that a developer could [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I have been doing a lot of work with jQuery lately. The jQuery library offers great cross browser support for most functions but unfortunately even this magic wand can’t solve all the problems with Internet Explorer 6 (IE6) compatibility. Previously, jQuery had a browser() function that helped detect a browser so that a developer could build  a work around. The browser() function has been removed in favor of a new function called support() which helps determine if the current browser offers support for a specific piece of functionality.  For many tasks this strategy works just fine but I have found some occasions where I need to sniff out IE6 and it can be done easily using standard JavaScript.</p>
<h3>JavaScript function to determine if the current browser is IE6:</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//CHECK FOR IE6</span>
<span style="color: #003366; font-weight: bold;">function</span> is_ie6<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">XMLHttpRequest</span> <span style="color: #339933;">==</span> undefined<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>ActiveXObject <span style="color: #339933;">!=</span> undefined<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>There are many other ways to find IE6 but this one works great.  If you have another good method please list it in the comments below.  </p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/how-to-detect-ie6-with-javascript/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Block .inc Files from Displaying on an Apache Web Server</title>
		<link>http://www.stemkoski.com/block-inc-files-from-displaying-on-apache-web-server/</link>
		<comments>http://www.stemkoski.com/block-inc-files-from-displaying-on-apache-web-server/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 21:37:55 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[.inc]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[httpd.conf]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1278</guid>
		<description><![CDATA[Block .inc Files from Displaying on Apache Web ServerBlock .inc Files from Displaying on Apache Web ServerMany PHP developers use the .inc file extension to signify a script that is included within another. This can be very handy when scanning a directory or block of code looking for specific references or calls. One of the [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Block .inc Files from Displaying on Apache Web ServerBlock .inc Files from Displaying on Apache Web ServerMany PHP developers use the .inc file extension to signify a script that is included within another.  This can be very handy when scanning a directory or block of code looking for specific references or calls. </p>
<p>One of the major benefits of using a .inc file as opposed to a PHP file is that a .inc will not execute code when called directly from the browser and instead displays the file contents as a text.  This technique can help portions of your script from being run out of context by clever hackers.  The downside to this functionality is that since Apache, by default treats a .inc file as a text file it will send the contents of your file to the browser.  This can obviously pose a serious security risk to your application.  For example, a connection.inc file containing database connection information called directly would output the connection information for your application allowing a hacker direct access to your database.</p>
<p>Thankfully, there is an easy solution to this problem. Apache allows you to provide special instructions in your httpd.conf file to disallow direct access to an .inc file.  This prevents a user from executing it outside the context of another script and prevents the file from being sent as text. To disallow access to .inc files, add the following information to your httpd.conf:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">&lt;files &quot;*.inc&quot;&gt;
order allow,deny
deny from all
&lt;/files&gt;</pre></div></div>



<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/block-inc-files-from-displaying-on-apache-web-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

