<?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>Quatrux Blog &#187; PHP</title>
	<atom:link href="http://qblog.quatrux.net/category/webmastering/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://qblog.quatrux.net</link>
	<description>Quatrux related Blog</description>
	<lastBuildDate>Wed, 02 Apr 2008 00:58:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>file_put_contents() for PHP4!</title>
		<link>http://qblog.quatrux.net/2007/07/30/file_put_contents-for-php4/</link>
		<comments>http://qblog.quatrux.net/2007/07/30/file_put_contents-for-php4/#comments</comments>
		<pubDate>Mon, 30 Jul 2007 06:13:59 +0000</pubDate>
		<dc:creator>Quatrux</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://qblog.quatrux.net/2007/07/30/file_put_contents-for-php4/</guid>
		<description><![CDATA[When I was using PHP4 for my web stuff, I wrote a quite good function for usage with PHP4, as a lot of you know on PHP5 a very handy function file_put_contents(); exist, but not in PHP4, but if you want to use it on PHP4, due to your server still has it running, which [...]]]></description>
			<content:encoded><![CDATA[<p>When I was using PHP4 for my web stuff, I wrote a quite good function for usage with PHP4, as a lot of you know on PHP5 a very handy function file_put_contents(); exist, but not in PHP4, but if you want to use it on PHP4, due to your server still has it running, which in my opinion is still quite normal, I will share another of my functions, I just browsed around my sources which usually never is finished and found it, so thought to share, it is in my opinion quite different when the one offered on the PEAR package, but it does the same, just is a little bit expanded.. I will explain a little! Firstly I named it put_file_contents(); to avoid the risk of duplication, but for instance, just do a check with the simple function function_exists(); Moreover, I recommend to include your functions only once, I mean use include_once() and/or require_once() <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<div class="synthi_code" style="display:none;" id ="plain_synthi_4c51dd544c512">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('styled_synthi_4c51dd544c512').style.display='block';document.getElementById('plain_synthi_4c51dd544c512').style.display='none';return false">Show Styled Code</a>]:</span></div>
<pre style="width:100%;overflow:auto;">

function put_file_contents($file, $data, $mode = 'a', $path = '0', $y = '') {
	/* check if file exists and atempt to Create it */
	if (!file_exists($file) &#038;&#038; !touch($file)) {
		user_error('put_file_contents() Can not create the file', E_USER_WARNING);
		return FALSE;
	/* check if Directory exists */
	} elseif (is_dir($file)) {
		user_error('put_file_contents() Can not write to a directory', E_USER_WARNING);
		return FALSE;
	/* check if file is regular */
	} elseif (is_file($file)) {
		/* check the Flags */
		if (!strpos('**|a|w|t|', '|'.$mode.'|')) {
			$mode = 'a';
		/* Change Owner if required */
		} elseif ($mode == 't' AND !qcreate_file($file)) {
			user_error('put_file_contents() Can not change file owner', E_USER_WARNING);
			return FALSE;
		}
		/* check if file is writable otherwise try to change permsissions */
		if (!is_writable($file) &#038;&#038; (!chmod($file, 0666) OR !qftp_chmod($file))) {
			user_error('put_file_contents() Can not write to file, permission denied', E_USER_WARNING);
			return FALSE;
		/* Change Data Array to String */
		} elseif (is_array($data)) {
			$data = implode($y, $data);
		/* Check Input Data */
		} elseif (!is_scalar($data)) {
			user_error('put_file_contents() The 2nd parameter should be either a string or an array', E_USER_WARNING);
			return FALSE;
		}
		/* Open and Store Data to File */
		if (($fo = fopen($file, $mode, $path)) === FALSE) {
			user_error('put_file_contents() Failed to open stream: Unknown reason', E_USER_WARNING);
			return FALSE;
		}
		if (fputs($fo, $data) === FALSE) {
			user_error('put_file_contents() Failed to write to file: Unknown reason', E_USER_WARNING);
			return FALSE;
		}
		/* Close Handle */
		fclose($fo);
		return TRUE;
	} else {
		user_error('put_file_contents() Can not continue: Not a file', E_USER_WARNING);
		return FALSE;
	}
}
</pre>
</div>
<div class="synthi_code" style="display:block;" id ="styled_synthi_4c51dd544c512">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('plain_synthi_4c51dd544c512').style.display='block';document.getElementById('styled_synthi_4c51dd544c512').style.display='none';return false">Show Plain Code</a>]:</span></div>
<div class="php" style="font-family: monospace;">
<ol>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> put_file_contents<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file</span>, <span style="color: #0000ff;">$data</span>, <span style="color: #0000ff;">$mode</span> = <span style="color: #ff0000;">&#8216;a&#8217;</span>, <span style="color: #0000ff;">$path</span> = <span style="color: #ff0000;">&#8216;0&#8242;</span>, <span style="color: #0000ff;">$y</span> = <span style="color: #ff0000;">&#8221;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* check if file exists and atempt to Create it */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/file_exists"><span style="color: #000066;">file_exists</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; !<a href="http://www.php.net/touch"><span style="color: #000066;">touch</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/user_error"><span style="color: #000066;">user_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;put_file_contents() Can not create the file&#8217;</span>, <span style="color: #000000; font-weight: bold;">E_USER_WARNING</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* check if Directory exists */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/is_dir"><span style="color: #000066;">is_dir</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/user_error"><span style="color: #000066;">user_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;put_file_contents() Can not write to a directory&#8217;</span>, <span style="color: #000000; font-weight: bold;">E_USER_WARNING</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* check if file is regular */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/is_file"><span style="color: #000066;">is_file</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* check the Flags */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/strpos"><span style="color: #000066;">strpos</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;**|a|w|t|&#8217;</span>, <span style="color: #ff0000;">&#8216;|&#8217;</span>.<span style="color: #0000ff;">$mode</span>.<span style="color: #ff0000;">&#8216;|&#8217;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$mode</span> = <span style="color: #ff0000;">&#8216;a&#8217;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Change Owner if required */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$mode</span> == <span style="color: #ff0000;">&#8216;t&#8217;</span> AND !qcreate_file<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/user_error"><span style="color: #000066;">user_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;put_file_contents() Can not change file owner&#8217;</span>, <span style="color: #000000; font-weight: bold;">E_USER_WARNING</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* check if file is writable otherwise try to change permsissions */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/is_writable"><span style="color: #000066;">is_writable</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; <span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/chmod"><span style="color: #000066;">chmod</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file</span>, <span style="color: #cc66cc;">0666</span><span style="color: #66cc66;">&#41;</span> OR !qftp_chmod<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/user_error"><span style="color: #000066;">user_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;put_file_contents() Can not write to file, permission denied&#8217;</span>, <span style="color: #000000; font-weight: bold;">E_USER_WARNING</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Change Data Array to String */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/is_array"><span style="color: #000066;">is_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$data</span> = <a href="http://www.php.net/implode"><span style="color: #000066;">implode</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$y</span>, <span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Check Input Data */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/is_scalar"><span style="color: #000066;">is_scalar</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/user_error"><span style="color: #000066;">user_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;put_file_contents() The 2nd parameter should be either a string or an array&#8217;</span>, <span style="color: #000000; font-weight: bold;">E_USER_WARNING</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Open and Store Data to File */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fo</span> = <a href="http://www.php.net/fopen"><span style="color: #000066;">fopen</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file</span>, <span style="color: #0000ff;">$mode</span>, <span style="color: #0000ff;">$path</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> === <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/user_error"><span style="color: #000066;">user_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;put_file_contents() Failed to open stream: Unknown reason&#8217;</span>, <span style="color: #000000; font-weight: bold;">E_USER_WARNING</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/fputs"><span style="color: #000066;">fputs</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fo</span>, <span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#41;</span> === <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/user_error"><span style="color: #000066;">user_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;put_file_contents() Failed to write to file: Unknown reason&#8217;</span>, <span style="color: #000000; font-weight: bold;">E_USER_WARNING</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Close Handle */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/fclose"><span style="color: #000066;">fclose</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fo</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">TRUE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/user_error"><span style="color: #000066;">user_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;put_file_contents() Can not continue: Not a file&#8217;</span>, <span style="color: #000000; font-weight: bold;">E_USER_WARNING</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
<p>As you can see, several times more of my stupid custom functions were used, you can remove them, but I will still share them, even though I don&#8217;t think they are useful.. I just tried to paste them, but I saw even more custom things <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  So I think I will only leave and idea and not an actually working code.</p>
]]></content:encoded>
			<wfw:commentRss>http://qblog.quatrux.net/2007/07/30/file_put_contents-for-php4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Designer 2007</title>
		<link>http://qblog.quatrux.net/2007/06/03/php-designer-2007/</link>
		<comments>http://qblog.quatrux.net/2007/06/03/php-designer-2007/#comments</comments>
		<pubDate>Sun, 03 Jun 2007 21:01:38 +0000</pubDate>
		<dc:creator>Quatrux</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://qblog.quatrux.net/2007/06/03/php-designer-2007/</guid>
		<description><![CDATA[I wrote to the author of this software, which now is commercial, but doesn&#8217;t cost a lot a feature I want to see in PHP Designer, because without it, it really annoyed me and I was searching for alternative PHP IDE and was unhappy, due to most of those free ones sucked and others were [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote to the author of this software, which now is commercial, but doesn&#8217;t cost a lot a feature I want to see in PHP Designer, because without it, it really annoyed me and I was searching for alternative PHP IDE and was unhappy, due to most of those free ones sucked and others were costing to much.. So in the version of 5.3.2 in the changelog I saw my wanted feature.. Before that it could open last opened file or no files or all recent opened files, but it sucked, I wanted to open all the files which were opened before I closed the program, so it now does it and all I can say is that PHP Designer 2007 is one of the best IDE for PHP!</p>
<p><a href="http://www.mpsoftware.dk/">Get PHP Designer 2007</a></p>
]]></content:encoded>
			<wfw:commentRss>http://qblog.quatrux.net/2007/06/03/php-designer-2007/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Want to delete a PHP Session?</title>
		<link>http://qblog.quatrux.net/2007/03/15/want-to-delete-a-php-session/</link>
		<comments>http://qblog.quatrux.net/2007/03/15/want-to-delete-a-php-session/#comments</comments>
		<pubDate>Thu, 15 Mar 2007 00:18:35 +0000</pubDate>
		<dc:creator>Quatrux</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://qblog.quatrux.net/2007/03/15/want-to-delete-a-php-session/</guid>
		<description><![CDATA[A lot of PHP novice programmers which don&#8217;t want to understand how the sessions work in the beginning, usually doesn&#8217;t delete a session the right way, so I wanted to post an example PHP script session_delete(); which deletes everything as needed.

 PHP [Show Styled Code]:


function session_delete($sname = 'Current User') {
	# Set Session Name to a [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of PHP novice programmers which don&#8217;t want to understand how the sessions work in the beginning, usually doesn&#8217;t delete a session the right way, so I wanted to post an example PHP script session_delete(); which deletes everything as needed.</p>
<div class="synthi_code" style="display:none;" id ="plain_synthi_4c51dd54770aa">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('styled_synthi_4c51dd54770aa').style.display='block';document.getElementById('plain_synthi_4c51dd54770aa').style.display='none';return false">Show Styled Code</a>]:</span></div>
<pre style="width:100%;overflow:auto;">

function session_delete($sname = 'Current User') {
	# Set Session Name to a Variable
	$name = session_name();
	/* Empty the Cookie from Session */
	if (!headers_sent() ) { setcookie($name,&#034;&#034;,0,&#034;/&#034;); }
	/* Remove the Cookie Value */
	unset($_COOKIE[$name]);
	/* Remove all the Info from the Super Global */
	$_SESSION = array();
	/* Free all session variables */
	session_unset();
	/* Destroy all data registered to a session */
	if (session_destroy() === FALSE) {
		return FALSE;
	} else {
		return TRUE;
	}
}
</pre>
</div>
<div class="synthi_code" style="display:block;" id ="styled_synthi_4c51dd54770aa">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('plain_synthi_4c51dd54770aa').style.display='block';document.getElementById('styled_synthi_4c51dd54770aa').style.display='none';return false">Show Plain Code</a>]:</span></div>
<div class="php" style="font-family: monospace;">
<ol>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> session_delete<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$sname</span> = <span style="color: #ff0000;">&#8216;Current User&#8217;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Set Session Name to a Variable</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$name</span> = <a href="http://www.php.net/session_name"><span style="color: #000066;">session_name</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Empty the Cookie from Session */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/headers_sent"><span style="color: #000066;">headers_sent</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <a href="http://www.php.net/setcookie"><span style="color: #000066;">setcookie</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$name</span>,<span style="color: #ff0000;">&quot;&quot;</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Remove the Cookie Value */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/unset"><span style="color: #000066;">unset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_COOKIE</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$name</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Remove all the Info from the Super Global */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$_SESSION</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Free all session variables */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/session_unset"><span style="color: #000066;">session_unset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Destroy all data registered to a session */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/session_destroy"><span style="color: #000066;">session_destroy</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> === <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">TRUE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>&nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://qblog.quatrux.net/2007/03/15/want-to-delete-a-php-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is the difference between [&quot;PHP_SELF&quot;], [&quot;SCRIPT_NAME&quot;] and [&quot;REQUEST_URI&quot;]?</title>
		<link>http://qblog.quatrux.net/2007/03/15/what-is-the-difference-between-php_self-script_name-and-request_uri/</link>
		<comments>http://qblog.quatrux.net/2007/03/15/what-is-the-difference-between-php_self-script_name-and-request_uri/#comments</comments>
		<pubDate>Thu, 15 Mar 2007 00:06:24 +0000</pubDate>
		<dc:creator>Quatrux</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://qblog.quatrux.net/2007/03/15/what-is-the-difference-between-php_self-script_name-and-request_uri/</guid>
		<description><![CDATA[What is the difference between &#8216;PHP_SELF&#8217;, &#8216;SCRIPT_NAME&#8217; and &#8216;REQUEST_URI&#8217; in the superglobal $_SERVER[] or also known as $HTTP_SERVER_VARS which is deprecated since PHP 4.1.0 and isn&#8217;t really a superglobal, but anyway, what is the difference? On different support channels and forums people ask this question and I tried to search google and didn&#8217;t find an [...]]]></description>
			<content:encoded><![CDATA[<p>What is the difference between &#8216;PHP_SELF&#8217;, &#8216;SCRIPT_NAME&#8217; and &#8216;REQUEST_URI&#8217; in the superglobal $_SERVER[] or also known as $HTTP_SERVER_VARS which is deprecated since PHP 4.1.0 and isn&#8217;t really a superglobal, but anyway, what is the difference? On different support channels and forums people ask this question and I tried to search google and didn&#8217;t find an answer, so I thought to write it here.</p>
<p><strong>$_SERVER['PHP_SELF'];</strong></p>
<blockquote><p><em>The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar.</em></p></blockquote>
<ul>
<li>http://example.com/ &#8212; &#8211; &#8212; /index.php</li>
<li>http://example.com/test/index.php &#8212; &#8211; &#8212; /test/index.php</li>
<li>http://example.com/index.php?q=submit &#8212; &#8211; &#8212; /index.php</li>
<li>http://example.com/index.php/test/ &#8212; &#8211; &#8212; /index.php/test</li>
</ul>
<p>So actually it returns the path to the current filename typed in the url without the QUERY_STRING, but when we us index.php/test/download/ it shows the path to ../test/download/ as we want it to do that, because usually using PHP_SELF is very useful with submitting forms, so having the PATH_INFO included in the PHP_SELF is a good idea and if you don&#8217;t want it, just use SCRIPT_NAME which will always show the executing file.</p>
<p><strong>$_SERVER['SCRIPT_NAME'];</strong></p>
<blockquote><p><em>Contains the current script&#8217;s path. This is useful for pages which need to point to themselves.</em></p></blockquote>
<ul>
<li>http://example.com/ &#8212; &#8211; &#8212; /index.php</li>
<li>http://example.com/test/index.php &#8212; &#8211; &#8212; /test/index.php</li>
<li>http://example.com/index.php?q=submit &#8212; &#8211; &#8212; /index.php</li>
<li>http://example.com/index.php/test/ &#8212; &#8211; &#8212; /index.php/</li>
</ul>
<p>So it is similar to PHP_SELF, just the PATH_INFO isn&#8217;t included, so you just point to the current filename executing. Note; that SCRIPT_FILENAME actually is the same, but it also returns the server root and acts the same as $_SERVER['DOCUMENT_ROOT']; . &#8221; . $_SERVER['SCRIPT_NAME'];</p>
<p>$_SERVER['REQUEST_URI'];</p>
<blockquote><p><em>The URI which was given in order to access this page; for instance, &#8216;/index.html&#8217;.</em></p></blockquote>
<p>A lot of people usually don&#8217;t understand the usage of this, for example if you wanted to access index.html but it didn&#8217;t exist on the server, you get redirected to say 404.php page which says that the filename doesn&#8217;t exist, when you will try to use any other value, like PHP_SELF or SCRIPT_NAME it will print you /404.php and not the file you requested, but when you will use REQUEST_URI, it will print the full URL which you typed in order to get to that page, this sometimes is quite useful.</p>
<p>In addition, I recommend to use the constant __FILE__ if you want to get the absolute path to your current dir and if you want to set an include path, it is best to do it also with this constant by adding the function dirname(); like this: dirname(__FILE__);</p>
<div class="synthi_code" style="display:none;" id ="plain_synthi_4c51dd5488602">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('styled_synthi_4c51dd5488602').style.display='block';document.getElementById('plain_synthi_4c51dd5488602').style.display='none';return false">Show Styled Code</a>]:</span></div>
<pre style="width:100%;overflow:auto;">
/* Change Super Global */
$s =&#038; $_SERVER;
/* Set the Default Include Path */
set_include_path( dirname( $s['SCRIPT_FILENAME'] ).'/includes'. PATH_SEPARATOR . dirname(__FILE__) );
</pre>
</div>
<div class="synthi_code" style="display:block;" id ="styled_synthi_4c51dd5488602">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('plain_synthi_4c51dd5488602').style.display='block';document.getElementById('styled_synthi_4c51dd5488602').style.display='none';return false">Show Plain Code</a>]:</span></div>
<div class="php" style="font-family: monospace;">
<ol>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Change Super Global */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$s</span> =&amp; <span style="color: #0000ff;">$_SERVER</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Set the Default Include Path */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/set_include_path"><span style="color: #000066;">set_include_path</span></a><span style="color: #66cc66;">&#40;</span> <a href="http://www.php.net/dirname"><span style="color: #000066;">dirname</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$s</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&#8216;SCRIPT_FILENAME&#8217;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">&#8216;/includes&#8217;</span>. PATH_SEPARATOR . <a href="http://www.php.net/dirname"><span style="color: #000066;">dirname</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">__FILE__</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
<p>If you ask if this is different, when I will say yes it is. The first value points to the currently executing file like /index.php and the second value is pointing to the current included file directory, it even can be outside /public_html/ somewhere in /home/user</p>
<p>Sometimes people don&#8217;t want to get the filename, but only the Query of the GET method, so there is a value $_SERVER['QUERY_STRING']; which returns everything after the ?</p>
<ul>
<li>http://example.com// &#8212; &#8211; &#8212; (nothing)</li>
<li>http://example.com/test/index.php &#8212; &#8211; &#8212; (nothing)</li>
<li>http://example.com/index.php?q=submit &#8212; &#8211; &#8212; q=submit</li>
<li>http://example.com/index.php/test/ &#8212; &#8211; &#8212; (nothing)</li>
<li>http://example.com/index.php/test/?q=submit &#8212; &#8211; &#8212; q=submit</li>
</ul>
<p>Furthermore, if you want to get the server root, you can use $_SERVER['DOCUMENT_ROOT']; which usually returns something like /home/user/public_html/</p>
<p>Moreover, sometimes you can have an headache if you want to get the domain the script is currently running on, you ask why? because sometimes you can use not the right $_SERVER array key for that.. if you&#8217;ll be using $_SERVER['SERVER_NAME']; you will get the domain of the server, but say you&#8217;re using CPanel and added a domain through it and you will execute under it, you will still get the original server domain, this is called virtual host, in order to get it you need to use $_SERVER['HTTP_HOST'];</p>
<p>Read more about <a href="http://php.net/manual/en/reserved.variables.php#reserved.variables.server">Reserved Server Variables</a> on PHP dot net Manual!</p>
]]></content:encoded>
			<wfw:commentRss>http://qblog.quatrux.net/2007/03/15/what-is-the-difference-between-php_self-script_name-and-request_uri/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP function scan_dir();</title>
		<link>http://qblog.quatrux.net/2007/01/23/php-function-scan_dir/</link>
		<comments>http://qblog.quatrux.net/2007/01/23/php-function-scan_dir/#comments</comments>
		<pubDate>Tue, 23 Jan 2007 11:08:01 +0000</pubDate>
		<dc:creator>Quatrux</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://qblog.quatrux.net/2007/01/23/php-function-scan_dir/</guid>
		<description><![CDATA[As a lot of who knows,PHP5 has a very good function called scan dir, but ash many of use still like to use PHP4 we need to find aletrnatives for it so here is a good function I wrote years ago and want to share it with you  

 PHP [Show Styled Code]:

/* #### [...]]]></description>
			<content:encoded><![CDATA[<p>As a lot of who knows,PHP5 has a very good function called scan dir, but ash many of use still like to use PHP4 we need to find aletrnatives for it so here is a good function I wrote years ago and want to share it with you <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="synthi_code" style="display:none;" id ="plain_synthi_4c51dd54a2be0">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('styled_synthi_4c51dd54a2be0').style.display='block';document.getElementById('plain_synthi_4c51dd54a2be0').style.display='none';return false">Show Styled Code</a>]:</span></div>
<pre style="width:100%;overflow:auto;">
/* #### SCAN DIR ####
Input: Directory, 1 to rsort() and files to not index to the Array
Output: makes an Array with filenames and dirs on Success or False
Status: Complete
Last Editor: Quatrux
*/

function scan_dir($dir, $s = '0', $u = '') {
/* Check if input is a Directory and Open it */
if (is_dir($dir)) {
if ($d['open'] = opendir($dir)) {
$u = &#034;**.|..|$u|&#034;;
while (($d['file'] = readdir($d['open'])) !== false) {
/* Don't add unneeded Files */
if (!strpos($u, $d['file']) ) {
/* Make an array with all left Files */
$d['array'][] = $d['file'];
}
}
closedir($d['open']);
} else {
return FALSE;
}
} else {
return FALSE;
}
/* Check if Directory is not Empty */
if (!isset($d['array'])) {
return FALSE;
/* Sort the Array by Request */
} elseif (is_array($d['array'])) {
if ($s == '1') {
rsort($d['array']);
} else {
sort($d['array']);
}
}
return $d['array'];
}
</pre>
</div>
<div class="synthi_code" style="display:block;" id ="styled_synthi_4c51dd54a2be0">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('plain_synthi_4c51dd54a2be0').style.display='block';document.getElementById('styled_synthi_4c51dd54a2be0').style.display='none';return false">Show Plain Code</a>]:</span></div>
<div class="php" style="font-family: monospace;">
<ol>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* #### SCAN DIR ####</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">Input: Directory, 1 to rsort() and files to not index to the Array</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">Output: makes an Array with filenames and dirs on Success or False</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">Status: Complete</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">Last Editor: Quatrux</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">*/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> scan_dir<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$dir</span>, <span style="color: #0000ff;">$s</span> = <span style="color: #ff0000;">&#8216;0&#8242;</span>, <span style="color: #0000ff;">$u</span> = <span style="color: #ff0000;">&#8221;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Check if input is a Directory and Open it */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/is_dir"><span style="color: #000066;">is_dir</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$dir</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$d</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&#8216;open&#8217;</span><span style="color: #66cc66;">&#93;</span> = <a href="http://www.php.net/opendir"><span style="color: #000066;">opendir</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$dir</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$u</span> = <span style="color: #ff0000;">&quot;**.|..|$u|&quot;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$d</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&#8216;file&#8217;</span><span style="color: #66cc66;">&#93;</span> = <a href="http://www.php.net/readdir"><span style="color: #000066;">readdir</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$d</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&#8216;open&#8217;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> !== <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Don&#8217;t add unneeded Files */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/strpos"><span style="color: #000066;">strpos</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$u</span>, <span style="color: #0000ff;">$d</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&#8216;file&#8217;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Make an array with all left Files */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$d</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&#8216;array&#8217;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #0000ff;">$d</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&#8216;file&#8217;</span><span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/closedir"><span style="color: #000066;">closedir</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$d</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&#8216;open&#8217;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Check if Directory is not Empty */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$d</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&#8216;array&#8217;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Sort the Array by Request */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/is_array"><span style="color: #000066;">is_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$d</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&#8216;array&#8217;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$s</span> == <span style="color: #ff0000;">&#8216;1&#8242;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/rsort"><span style="color: #000066;">rsort</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$d</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&#8216;array&#8217;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/sort"><span style="color: #000066;">sort</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$d</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&#8216;array&#8217;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$d</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&#8216;array&#8217;</span><span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
<p>Well, will need to find a plugin or something which would highlight the code or something, because now, I don&#8217;t even see tabs, oh well.. Stupid Javascript Editor for Wordpress <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://qblog.quatrux.net/2007/01/23/php-function-scan_dir/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Site Security ?</title>
		<link>http://qblog.quatrux.net/2006/04/02/site-security/</link>
		<comments>http://qblog.quatrux.net/2006/04/02/site-security/#comments</comments>
		<pubDate>Sun, 02 Apr 2006 21:14:33 +0000</pubDate>
		<dc:creator>Quatrux</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Webmastering]]></category>

		<guid isPermaLink="false">http://qblog.quatrux.net/2006/04/02/site-security/</guid>
		<description><![CDATA[Every Site wants to be secure ? right ? Well, I think I have overdone, but I feel alright now, I totally rewrote my Quatrux theSite CMS and now it is very secure, in fact I can run several sites on it in different directories.. cool isn&#8217;t it ? there are library files which is [...]]]></description>
			<content:encoded><![CDATA[<p>Every Site wants to be secure ? right ? Well, I think I have overdone, but I feel alright now, I totally rewrote my Quatrux theSite CMS and now it is very secure, in fact I can run several sites on it in different directories.. cool isn&#8217;t it ? there are library files which is always used, they are placed in a non public directory, I mean /home/user/private/theSite-library/ which are included with php include function. No one can access that directory except for the owner of the files, ftp user and I made a quite cool chmod for it.</p>
<p>The site runs on one index.php file which has several lines to define stuff, and some files in /dir/ directory which is protected by password using .htaccess so no one can access it except for php, perl etc. all the passwords in settings file are hashed using random hasher numbers and I just check the value and never can know it, but for mysql passwords I made it like this ? decrypt($settings['mysql']['password']); and it returns the value, this function is my own written custom function. The other files is just the template for the site. <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I made two mysql users for my database, one which is selected when you&#8217;re browsing the site, his privileges is only to use SELECT and another who is selected while browsing the Panel, it can SELECT, UPDATE and INSERT and nothing more, my database is frequently backed up automatically if something was changed in the panel. <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>The PHP scripts are written nicely and does not throw any errors, I have changed to xHTML 1.0 Transitional and it is Valid, same as CSS. In Fact I am waiting for CSS 3 version <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  and with time I will integrate AJAX on my Panel for easy usage, I have learned javascript, now only need practice. <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://qblog.quatrux.net/2006/04/02/site-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.htaccess files</title>
		<link>http://qblog.quatrux.net/2005/12/11/htaccess-files/</link>
		<comments>http://qblog.quatrux.net/2005/12/11/htaccess-files/#comments</comments>
		<pubDate>Sun, 11 Dec 2005 22:09:10 +0000</pubDate>
		<dc:creator>Quatrux</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Webmastering]]></category>

		<guid isPermaLink="false">http://www.qzone.astahost.com/qblog/?p=13</guid>
		<description><![CDATA[Using .htaccess files on your server is really useful, I found out that you can change php.ini and httpd.conf/apache.conf configuration but if the server lets to do it, well so I will show an example of my htaccess file  

 Apache [Show Styled Code]:

#######################################
# APACHE CONFIGURATION FILE BEGINNING #
#######################################

#****************************************************+
# Enable this, but some google [...]]]></description>
			<content:encoded><![CDATA[<p>Using .htaccess files on your server is really useful, I found out that you can change php.ini and httpd.conf/apache.conf configuration but if the server lets to do it, well so I will show an example of my htaccess file <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<div class="synthi_code" style="display:none;" id ="plain_synthi_4c51dd54d120d">
<div class="synthi_header" style="font-weight:bold;"> Apache <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('styled_synthi_4c51dd54d120d').style.display='block';document.getElementById('plain_synthi_4c51dd54d120d').style.display='none';return false">Show Styled Code</a>]:</span></div>
<pre style="width:100%;overflow:auto;">
#######################################
# APACHE CONFIGURATION FILE BEGINNING #
#######################################

#****************************************************+
# Enable this, but some google bots get an 406 error *
#****************************************************+

#Options MultiViews

#*********************************************+
# Alternative to above and googlebot is happy *
#*********************************************+

#Options -Multiviews
#RewriteEngine On
#RewriteBase /
#RewriteRule ^quatrux/(.*) /quatrux.php/$1
#RewriteRule ^quatrux$ /quatrux.php

#******************************************************+
# Manage Index Options                                 *
#                     you can also include HEADER.html *
#                             and README.html files    *
#******************************************************+

#IndexOptions FancyIndexing SuppressHTMLPreamble DescriptionWidth=*
#AddDescription &#034;JPG File&#034; *.jpg
#AddDescription &#034;GIF File&#034; *.gif

#****************************+
# Add new Extensions for PHP *
#****************************+

AddType application/x-httpd-php .q .do

#*************************************************+
# Default Extension for Files having no Extension *
#*************************************************+

 # DefaultType application/x-httpd-php

#************************+
# Default Index Settings *
#************************+

DirectoryIndex index.html index.php
IndexIgnore *

#******************************************************+
# Change default PHP.ini Settings                      *
#            Not all Options are allowed to be changed *
#                             www.php.net/manual/en/   *
#******************************************************+

#===========================\
# ASP TAGS on/off (Boolean) +
#===========================/
php_flag asp_tags off
#=================================\
# SHORT OPEN TAG on/off (Boolean) +
#=================================/
 #php_flag short_open_tag off
#===================================\
# REGISTER GLOBALS on/off (Boolean) +
#===================================/
php_flag register_globals off
#========================================\
# SESSION USE TRANS SID on/off (Boolean) +
#========================================/
php_flag session.use_trans_sid off
#===================================\
# MAGIC QUOTES GPC on/off (Boolean) +
#===================================/
 #php_flag magic_quotes_gpc off
#=======================================\
# MAGIC QUOTES RUNTIME on/off (Boolean) +
#=======================================/
 #php_flag magic_quotes_runtime off

#==============================================\
# MAX EXECUTION TIME time in seconds (Integer) +
#==============================================/
php_value max_execution_time &#034;10&#034;
#=====================================\
# ARG SEPERATOR OUTPUT value (String) +
#=====================================/
php_value arg_separator.output &#034;&amp;&#034;
#=============================\
# URL REWRITER value (String) +
#=============================/
php_value url_rewriter.tags &#034;frame=src&#034;
#=============================\
# INCLUDE PATH value (String) +
#=============================/
 #php_value include_path &#034;.:/home/user/public_html/includes/&#034;
#===========================\
# USER AGENT value (String) +
#===========================/
php_value user_agent &#034;Opera/8.51 (Windows NT 5.1; U; en)&#034;
#====================================\
# UPLOAD MAX FILESIZE size (Integer) +
#====================================/
php_value upload_max_filesize 8M
#==================================\
# Error Reporting number (Integer) +
#==================================/
php_value error_reporting 2047

#******************************************************+
# Error Documents Handler                              *
#          Custom Error Documents are generated by PHP *
#               Valid HTML META and HEADERS are Send   *
#******************************************************+

ErrorDocument 400 /e.do?error=400
ErrorDocument 401 /e.do?error=401
ErrorDocument 402 /e.do?error=402
ErrorDocument 403 /e.do?error=403
ErrorDocument 404 /e.do?error=404
ErrorDocument 405 /e.do?error=405
ErrorDocument 406 /e.do?error=406
ErrorDocument 407 /e.do?error=407
ErrorDocument 408 /e.do?error=408
ErrorDocument 409 /e.do?error=409
ErrorDocument 410 /e.do?error=410
ErrorDocument 411 /e.do?error=411
ErrorDocument 412 /e.do?error=412
ErrorDocument 413 /e.do?error=413
ErrorDocument 414 /e.do?error=414
ErrorDocument 415 /e.do?error=415
ErrorDocument 416 /e.do?error=416
ErrorDocument 417 /e.do?error=417
ErrorDocument 500 /e.do?error=500
ErrorDocument 501 /e.do?error=501
ErrorDocument 502 /e.do?error=502
ErrorDocument 503 /e.do?error=503
ErrorDocument 504 /e.do?error=504
ErrorDocument 505 /e.do?error=505

####################################
# APACHE CONFIGURATION FILE ENDING #
####################################
</pre>
</div>
<div class="synthi_code" style="display:block;" id ="styled_synthi_4c51dd54d120d">
<div class="synthi_header" style="font-weight:bold;"> Apache <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('plain_synthi_4c51dd54d120d').style.display='block';document.getElementById('styled_synthi_4c51dd54d120d').style.display='none';return false">Show Plain Code</a>]:</span></div>
<div class="apache" style="font-family: monospace;">
<ol>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#######################################</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># APACHE CONFIGURATION FILE BEGINNING #</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#######################################</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#****************************************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># Enable this, but some google bots get an 406 error *</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#****************************************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#Options MultiViews</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#*********************************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># Alternative to above and googlebot is happy *</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#*********************************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#Options -Multiviews</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#RewriteEngine On</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#RewriteBase /</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#RewriteRule ^quatrux/(.*) /quatrux.php/$1</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#RewriteRule ^quatrux$ /quatrux.php</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#******************************************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># Manage Index Options&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;you can also include HEADER.html *</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and README.html files&nbsp; &nbsp; *</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#******************************************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#IndexOptions FancyIndexing SuppressHTMLPreamble DescriptionWidth=*</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#AddDescription &quot;JPG File&quot; *.jpg</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#AddDescription &quot;GIF File&quot; *.gif</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#****************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># Add new Extensions for PHP *</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#****************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">AddType</span> application/x-httpd-php .q .do</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#*************************************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># Default Extension for Files having no Extension *</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#*************************************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #adadad; font-style: italic;"># DefaultType application/x-httpd-php</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># Default Index Settings *</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">DirectoryIndex</span> index.html index.php</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">IndexIgnore</span> *</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#******************************************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># Change default PHP.ini Settings&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Not all Options are allowed to be changed *</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;www.php.net/manual/en/&nbsp; &nbsp;*</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#******************************************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#===========================\</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># ASP TAGS on/off (Boolean) +</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#===========================/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">php_flag asp_tags <span style="color: #0000ff;">off</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#=================================\</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># SHORT OPEN TAG on/off (Boolean) +</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#=================================/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #adadad; font-style: italic;">#php_flag short_open_tag off</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#===================================\</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># REGISTER GLOBALS on/off (Boolean) +</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#===================================/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">php_flag register_globals <span style="color: #0000ff;">off</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#========================================\</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># SESSION USE TRANS SID on/off (Boolean) +</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#========================================/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">php_flag session.use_trans_sid <span style="color: #0000ff;">off</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#===================================\</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># MAGIC QUOTES GPC on/off (Boolean) +</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#===================================/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #adadad; font-style: italic;">#php_flag magic_quotes_gpc off</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#=======================================\</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># MAGIC QUOTES RUNTIME on/off (Boolean) +</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#=======================================/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #adadad; font-style: italic;">#php_flag magic_quotes_runtime off</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#==============================================\</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># MAX EXECUTION TIME time in seconds (Integer) +</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#==============================================/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">php_value max_execution_time <span style="color: #7f007f;">&quot;10&quot;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#=====================================\</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># ARG SEPERATOR OUTPUT value (String) +</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#=====================================/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">php_value arg_separator.output <span style="color: #7f007f;">&quot;&amp;amp;&quot;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#=============================\</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># URL REWRITER value (String) +</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#=============================/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">php_value url_rewriter.tags <span style="color: #7f007f;">&quot;frame=src&quot;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#=============================\</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># INCLUDE PATH value (String) +</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#=============================/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #adadad; font-style: italic;">#php_value include_path &quot;.:/home/user/public_html/includes/&quot;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#===========================\</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># USER AGENT value (String) +</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#===========================/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">php_value user_agent <span style="color: #7f007f;">&quot;Opera/8.51 (Windows NT 5.1; U; en)&quot;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#====================================\</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># UPLOAD MAX FILESIZE size (Integer) +</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#====================================/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">php_value upload_max_filesize 8M</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#==================================\</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># Error Reporting number (Integer) +</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#==================================/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">php_value error_reporting <span style="color: #ff0000;">2047</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#******************************************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># Error Documents Handler&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Custom Error Documents are generated by PHP *</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Valid HTML META and HEADERS are Send&nbsp; &nbsp;*</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#******************************************************+</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">400</span> /e.do?error=<span style="color: #ff0000;">400</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">401</span> /e.do?error=<span style="color: #ff0000;">401</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">402</span> /e.do?error=<span style="color: #ff0000;">402</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">403</span> /e.do?error=<span style="color: #ff0000;">403</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">404</span> /e.do?error=<span style="color: #ff0000;">404</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">405</span> /e.do?error=<span style="color: #ff0000;">405</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">406</span> /e.do?error=<span style="color: #ff0000;">406</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">407</span> /e.do?error=<span style="color: #ff0000;">407</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">408</span> /e.do?error=<span style="color: #ff0000;">408</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">409</span> /e.do?error=<span style="color: #ff0000;">409</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">410</span> /e.do?error=<span style="color: #ff0000;">410</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">411</span> /e.do?error=<span style="color: #ff0000;">411</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">412</span> /e.do?error=<span style="color: #ff0000;">412</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">413</span> /e.do?error=<span style="color: #ff0000;">413</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">414</span> /e.do?error=<span style="color: #ff0000;">414</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">415</span> /e.do?error=<span style="color: #ff0000;">415</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">416</span> /e.do?error=<span style="color: #ff0000;">416</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">417</span> /e.do?error=<span style="color: #ff0000;">417</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">500</span> /e.do?error=<span style="color: #ff0000;">500</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">501</span> /e.do?error=<span style="color: #ff0000;">501</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">502</span> /e.do?error=<span style="color: #ff0000;">502</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">503</span> /e.do?error=<span style="color: #ff0000;">503</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">504</span> /e.do?error=<span style="color: #ff0000;">504</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">505</span> /e.do?error=<span style="color: #ff0000;">505</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">####################################</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;"># APACHE CONFIGURATION FILE ENDING #</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #adadad; font-style: italic;">#################################### </span></div>
</li>
</ol>
</div>
</div>
<p>well and you could create your own file.php as a custom error page and do anything you like, hope this helps <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://qblog.quatrux.net/2005/12/11/htaccess-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Your guestbook has Spam ?</title>
		<link>http://qblog.quatrux.net/2005/12/06/your-guestbook-has-spam/</link>
		<comments>http://qblog.quatrux.net/2005/12/06/your-guestbook-has-spam/#comments</comments>
		<pubDate>Tue, 06 Dec 2005 06:29:15 +0000</pubDate>
		<dc:creator>Quatrux</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Webmastering]]></category>

		<guid isPermaLink="false">http://www.qzone.astahost.com/qblog/?p=10</guid>
		<description><![CDATA[Well a lot of people have problems with this, usually the bots find your guestbook and with time start adding some content about casino, gambling, viagra and medicine etc. this is so annoying, you get an email that somebody signed and you need to clean it, wow, what a waste of time ?! and other [...]]]></description>
			<content:encoded><![CDATA[<p>Well a lot of people have problems with this, usually the bots find your guestbook and with time start adding some content about casino, gambling, viagra and medicine etc. this is so annoying, you get an email that somebody signed and you need to clean it, wow, what a waste of time ?! and other good robots might index it and that won&#8217;t look nice, your site might be thought of being spam one having links to porno sites <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  so how can you protect from them, the bad robots ? well the first thing is banning, but as usually they have different IPs it does not help to much, the other thing is cookies, but usually those bots have cookies disabled and sends false headers, so it only might help from some guys spamming your guestbook, those idiots should be shot or their balls could be cut with a big big knife <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  The best way is to have a random value of letters and numbers, though I prefer numbers, they look much nicer in the image, yeah so using for example with GD library create an image with that random value, do not forget to have random backgrounds, don&#8217;t use one colour, random positions of the letters or numbers, you might even use upper/lower case, but well this protection sometimes annoys the real users.. but that is life, you also should use sessions for this thing to work properly or any method you want. Here is a good PHP function which you can use to generate a value:</p>
<div class="synthi_code" style="display:none;" id ="plain_synthi_4c51dd54f38d4">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('styled_synthi_4c51dd54f38d4').style.display='block';document.getElementById('plain_synthi_4c51dd54f38d4').style.display='none';return false">Show Styled Code</a>]:</span></div>
<pre style="width:100%;overflow:auto;">
< ?php

function random_chars($length = '6') {
	/* Make Random Seed */ 	$value = '';
	mt_srand((double) microtime() * 1000000);
	$letters = &#034;abcdefghijklmnopqrstuvwxyz&#034;; /* add it if needed '123456789' 'ABCDEFGHIJKLMOPQRSTUVWXZ' */
		for ($i = 0; $i < $length; $i++) {
			$value .= substr($letters, (mt_rand()%(strlen($letters))), 1);
		}
	return $value;
}

?>
</pre>
</div>
<div class="synthi_code" style="display:block;" id ="styled_synthi_4c51dd54f38d4">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('plain_synthi_4c51dd54f38d4').style.display='block';document.getElementById('styled_synthi_4c51dd54f38d4').style.display='none';return false">Show Plain Code</a>]:</span></div>
<div class="php" style="font-family: monospace;">
<ol>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt; ?php</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> random_chars<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$length</span> = <span style="color: #ff0000;">&#8216;6&#8242;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Make Random Seed */</span> &nbsp;<span style="color: #0000ff;">$value</span> = <span style="color: #ff0000;">&#8221;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/mt_srand"><span style="color: #000066;">mt_srand</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>double<span style="color: #66cc66;">&#41;</span> <a href="http://www.php.net/microtime"><span style="color: #000066;">microtime</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #cc66cc;">1000000</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$letters</span> = <span style="color: #ff0000;">&quot;abcdefghijklmnopqrstuvwxyz&quot;</span>; <span style="color: #808080; font-style: italic;">/* add it if needed &#8216;123456789&#8242; &#8216;ABCDEFGHIJKLMOPQRSTUVWXZ&#8217; */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$i</span> = <span style="color: #cc66cc;">0</span>; <span style="color: #0000ff;">$i</span> &lt; <span style="color: #0000ff;">$length</span>; <span style="color: #0000ff;">$i</span>++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$value</span> .= <a href="http://www.php.net/substr"><span style="color: #000066;">substr</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$letters</span>, <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/mt_rand"><span style="color: #000066;">mt_rand</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>%<span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/strlen"><span style="color: #000066;">strlen</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$letters</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$value</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
<p>So echo random_chars(); will parse a random value every time with the default length of 6, you can change the length you want.</p>
]]></content:encoded>
			<wfw:commentRss>http://qblog.quatrux.net/2005/12/06/your-guestbook-has-spam/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Functions in PHP</title>
		<link>http://qblog.quatrux.net/2005/12/04/functions-in-php/</link>
		<comments>http://qblog.quatrux.net/2005/12/04/functions-in-php/#comments</comments>
		<pubDate>Sun, 04 Dec 2005 21:35:01 +0000</pubDate>
		<dc:creator>Quatrux</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Webmastering]]></category>

		<guid isPermaLink="false">http://www.qzone.astahost.com/qblog/?p=6</guid>
		<description><![CDATA[custom Functions in PHP is one of the best things available to optimize your code, the things you can do with it are enormous, here is my two examples of some functions which you can use.

 PHP [Show Styled Code]:


< ?php

function pw_encode($pass) {
	/* Check Input */
	if (is_string($pass) AND !empty($pass)) {
		/* Make a Random Seed */	$s [...]]]></description>
			<content:encoded><![CDATA[<p>custom Functions in PHP is one of the best things available to optimize your code, the things you can do with it are enormous, here is my two examples of some functions which you can use.</p>
<div class="synthi_code" style="display:none;" id ="plain_synthi_4c51dd5521973">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('styled_synthi_4c51dd5521973').style.display='block';document.getElementById('plain_synthi_4c51dd5521973').style.display='none';return false">Show Styled Code</a>]:</span></div>
<pre style="width:100%;overflow:auto;">

< ?php

function pw_encode($pass) {
	/* Check Input */
	if (is_string($pass) AND !empty($pass)) {
		/* Make a Random Seed */	$s = '';
		for ($i = 0; $i < 8; $i++) {
			$s .= substr('0123456789abcdef', mt_rand(0,15), 1);
		}
		return md5($s.$pass).$s;
	} else {
		user_error('pw_encode() The input should be non empty string', E_USER_WARNING);
		return FALSE;
	}
}

function pw_check($pass, $value) {
	/* Check Input */
	if (is_string($pass) AND is_string($value) AND !empty($pass) AND !empty($value)) {
		/* Get the Seed */
		$s = substr($value, 32, 8 );
		/* Check the Passwords */
		if (md5($s.$pass).$s == $value) {
			return TRUE;
		} else {
			return FALSE;
		}
	} else {
		user_error('pw_decode() The both input values should be non empty strings', E_USER_WARNING);
		return FALSE;
	}
}
</pre>
</div>
<div class="synthi_code" style="display:block;" id ="styled_synthi_4c51dd5521973">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('plain_synthi_4c51dd5521973').style.display='block';document.getElementById('styled_synthi_4c51dd5521973').style.display='none';return false">Show Plain Code</a>]:</span></div>
<div class="php" style="font-family: monospace;">
<ol>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt; ?php</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> pw_encode<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$pass</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Check Input */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/is_string"><span style="color: #000066;">is_string</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$pass</span><span style="color: #66cc66;">&#41;</span> AND !<a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$pass</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Make a Random Seed */</span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$s</span> = <span style="color: #ff0000;">''</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$i</span> = <span style="color: #cc66cc;">0</span>; <span style="color: #0000ff;">$i</span> &lt; <span style="color: #cc66cc;">8</span>; <span style="color: #0000ff;">$i</span>++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$s</span> .= <a href="http://www.php.net/substr"><span style="color: #000066;">substr</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'0123456789abcdef'</span>, <a href="http://www.php.net/mt_rand"><span style="color: #000066;">mt_rand</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">15</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/md5"><span style="color: #000066;">md5</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$s</span>.<span style="color: #0000ff;">$pass</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0000ff;">$s</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/user_error"><span style="color: #000066;">user_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'pw_encode() The input should be non empty string'</span>, <span style="color: #000000; font-weight: bold;">E_USER_WARNING</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> pw_check<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$pass</span>, <span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Check Input */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/is_string"><span style="color: #000066;">is_string</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$pass</span><span style="color: #66cc66;">&#41;</span> AND <a href="http://www.php.net/is_string"><span style="color: #000066;">is_string</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span> AND !<a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$pass</span><span style="color: #66cc66;">&#41;</span> AND !<a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Get the Seed */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$s</span> = <a href="http://www.php.net/substr"><span style="color: #000066;">substr</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span>, <span style="color: #cc66cc;">32</span>, <span style="color: #cc66cc;">8</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Check the Passwords */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/md5"><span style="color: #000066;">md5</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$s</span>.<span style="color: #0000ff;">$pass</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0000ff;">$s</span> == <span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">TRUE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/user_error"><span style="color: #000066;">user_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'pw_decode() The both input values should be non empty strings'</span>, <span style="color: #000000; font-weight: bold;">E_USER_WARNING</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
<p>so now, how would you use those functions ? it is really simple, if you know some PHP, here is an example, you just need to call the function like an ordinary compiled php function <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
</pre>
<div class="synthi_code" style="display:none;" id ="plain_synthi_4c51dd552a614">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('styled_synthi_4c51dd552a614').style.display='block';document.getElementById('plain_synthi_4c51dd552a614').style.display='none';return false">Show Styled Code</a>]:</span></div>
<pre style="width:100%;overflow:auto;">

< ?php
/* Encode the Password */
$password = pw_encode('my_pass');
// it is recommended to store the password somewhere in your database
/* Check the Password */
// the password could come from a Post method and the $password from the database or a txt file etc.
if (pw_check($password, 'my pass')) {
	echo 'the password is correct';
} else {
	echo 'you forgot your password ?';
}
?>
</pre>
</div>
<div class="synthi_code" style="display:block;" id ="styled_synthi_4c51dd552a614">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('plain_synthi_4c51dd552a614').style.display='block';document.getElementById('styled_synthi_4c51dd552a614').style.display='none';return false">Show Plain Code</a>]:</span></div>
<div class="php" style="font-family: monospace;">
<ol>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt; ?php</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Encode the Password */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$password</span> = pw_encode<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;my_pass&#8217;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// it is recommended to store the password somewhere in your database</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Check the Password */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// the password could come from a Post method and the $password from the database or a txt file etc.</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>pw_check<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$password</span>, <span style="color: #ff0000;">&#8216;my pass&#8217;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&#8216;the password is correct&#8217;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&#8216;you forgot your password ?&#8217;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
<p>This is just one example, in functions you can&#8217;t use variables from outside the script, unless you make them global, or you can use super globals like $_SERVER, $_GET, $_POST, $_SESSION inside the functions also $GLOBALS[] array and constants which you defined using define() like if you would like to use mysql_resource in the function, just pass it through into the function: function name($a, $b, $mysql_connection) {} and whola you can use mysql in the function without needing to connect inside the function, same for ftp and irc gateway connections. Don&#8217;t forget that include() function works well in the functions or you can use file() and everything you want, as I said it is enormous thing, imagine your simple site: file index.php</p>
<div class="synthi_code" style="display:none;" id ="plain_synthi_4c51dd552e491">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('styled_synthi_4c51dd552e491').style.display='block';document.getElementById('plain_synthi_4c51dd552e491').style.display='none';return false">Show Styled Code</a>]:</span></div>
<pre style="width:100%;overflow:auto;">

< ?php

/* My Site*/
include &#034;functions.php&#034;;
echo_site();
?>
</pre>
</div>
<div class="synthi_code" style="display:block;" id ="styled_synthi_4c51dd552e491">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('plain_synthi_4c51dd552e491').style.display='block';document.getElementById('styled_synthi_4c51dd552e491').style.display='none';return false">Show Plain Code</a>]:</span></div>
<div class="php" style="font-family: monospace;">
<ol>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt; ?php</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* My Site*/</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">include</span> <span style="color: #ff0000;">&quot;functions.php&quot;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">echo_site<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
<p>and the function will just output everything, well it is not the best way but it is possible. <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Enough for today <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://qblog.quatrux.net/2005/12/04/functions-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Output Buffering</title>
		<link>http://qblog.quatrux.net/2005/12/04/3/</link>
		<comments>http://qblog.quatrux.net/2005/12/04/3/#comments</comments>
		<pubDate>Sun, 04 Dec 2005 01:51:06 +0000</pubDate>
		<dc:creator>Quatrux</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Webmastering]]></category>

		<guid isPermaLink="false">http://www.qzone.astahost.com/qblog/?p=3</guid>
		<description><![CDATA[What I found interesting is that output buffering can be really handy and that using it for half of year I had no problems with it, I mean using ob_start() function with gz_handler here is an example, put it somewhere in top of your file:

 PHP [Show Styled Code]:

< ?php
/* Start GZipped or Plain Output [...]]]></description>
			<content:encoded><![CDATA[<p>What I found interesting is that output buffering can be really handy and that using it for half of year I had no problems with it, I mean using ob_start() function with gz_handler here is an example, put it somewhere in top of your file:</p>
<div class="synthi_code" style="display:none;" id ="plain_synthi_4c51dd554309e">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('styled_synthi_4c51dd554309e').style.display='block';document.getElementById('plain_synthi_4c51dd554309e').style.display='none';return false">Show Styled Code</a>]:</span></div>
<pre style="width:100%;overflow:auto;">
< ?php
/* Start GZipped or Plain Output Buffering */
if (extension_loaded('zlib') AND (ini_get('zlib.output_compression') != '1' OR ini_get('output_handler') != 'ob_gzhandler')) {
	ob_start(&#034;ob_gzhandler&#034;);
} else {
	ob_start();
}
?>
</pre>
</div>
<div class="synthi_code" style="display:block;" id ="styled_synthi_4c51dd554309e">
<div class="synthi_header" style="font-weight:bold;"> PHP <span  class="synthi_button"style="font-weight:lighter;font-size:smaller;">[<a href="#" onClick="javascript:document.getElementById('plain_synthi_4c51dd554309e').style.display='block';document.getElementById('styled_synthi_4c51dd554309e').style.display='none';return false">Show Plain Code</a>]:</span></div>
<div class="php" style="font-family: monospace;">
<ol>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt; ?php</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Start GZipped or Plain Output Buffering */</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/extension_loaded"><span style="color: #000066;">extension_loaded</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;zlib&#8217;</span><span style="color: #66cc66;">&#41;</span> AND <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/ini_get"><span style="color: #000066;">ini_get</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;zlib.output_compression&#8217;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #ff0000;">&#8216;1&#8242;</span> OR <a href="http://www.php.net/ini_get"><span style="color: #000066;">ini_get</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;output_handler&#8217;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #ff0000;">&#8216;ob_gzhandler&#8217;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/ob_start"><span style="color: #000066;">ob_start</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ob_gzhandler&quot;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/ob_start"><span style="color: #000066;">ob_start</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
<p>using it you can use header() function anywhere in the files even if you wrote echo or made some output, you can edit the output, just read about output buffering functions in the php manual &#8211; <a href="http://www.php.net/ob_gzhandler">www.php.net/ob_gzhandler</a></p>
<p>because our html has so many the same tags it is just perfect for using gzip on it, it can compress up to 60% of your source, in this way you save bandwidth and time for the user to get the file and it works great because if the user browser can&#8217;t decode gzip it won&#8217;t be sent with gzip encoding, it saves time because apache does not need to use the resources of sending the file, but it uses a bit of resources to encode using gzip, all in all it is a thing which I found to late, but I am happy I found it, it opened me new possibilities. <img src='http://qblog.quatrux.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://qblog.quatrux.net/2005/12/04/3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
