<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Poudo.com - Blogs</title>
		<link>http://www.poudo.com/blog.php</link>
		<language>en</language>
		<lastBuildDate>Sat, 11 Oct 2008 01:05:42 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.poudo.com/{IF}/misc/rss.jpg</url>
			<title>Poudo.com - Blogs</title>
			<link>http://www.poudo.com/blog.php</link>
		</image>
		<item>
			<title>Clicks heatmap</title>
			<link>http://www.poudo.com/blog.php?b=52</link>
			<pubDate>Wed, 21 Nov 2007 17:05:44 GMT</pubDate>
			<description>It is a visual heatmap of clicks on a HTML page, showing hot and cold click zones.

Image: http://www.ajaxrain.com/rainImage/092201.jpg...</description>
			<content:encoded><![CDATA[<div>It is a visual heatmap of clicks on a HTML page, showing hot and cold click zones.<br />
<br />
<img src="http://www.ajaxrain.com/rainImage/092201.jpg" border="0" alt="" /><br />
<br />
<a href="http://www.labsmedia.com/clickheat/index.html" target="_blank">Demo|Information|Download</a></div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=52</guid>
		</item>
		<item>
			<title>Whizzywig - Rich text editor</title>
			<link>http://www.poudo.com/blog.php?b=51</link>
			<pubDate>Wed, 21 Nov 2007 17:03:14 GMT</pubDate>
			<description>It lets people create rich, formatted text through a web form. It creates html or xhtml.

Image: http://www.ajaxrain.com/rainImage/093001.jpg...</description>
			<content:encoded><![CDATA[<div>It lets people create rich, formatted text through a web form. It creates html or xhtml.<br />
<br />
<img src="http://www.ajaxrain.com/rainImage/093001.jpg" border="0" alt="" /><br />
<br />
<a href="http://www.unverse.net/whizzywig-cross-browser-html-editor.html" target="_blank">Demo|Instructions|Download</a></div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=51</guid>
		</item>
		<item>
			<title>Table Editor : jQuery</title>
			<link>http://www.poudo.com/blog.php?b=50</link>
			<pubDate>Wed, 21 Nov 2007 17:00:17 GMT</pubDate>
			<description>TableEditor provides flexible in place editing of HTML tables.

Image: http://www.ajaxrain.com/rainImage/100403.jpg 

Demonstration and Download...</description>
			<content:encoded><![CDATA[<div>TableEditor provides flexible in place editing of HTML tables.<br />
<br />
<img src="http://www.ajaxrain.com/rainImage/100403.jpg" border="0" alt="" /><br />
<br />
<a href="http://dev.iceburg.net/jquery/tableEditor/demo.php" target="_blank">Demonstration and Download</a></div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=50</guid>
		</item>
		<item>
			<title>Tab container themes</title>
			<link>http://www.poudo.com/blog.php?b=49</link>
			<pubDate>Wed, 21 Nov 2007 16:57:33 GMT</pubDate>
			<description>Great collection of Sample AjaxControlToolkit TabContainer Themes.

Image: http://www.ajaxrain.com/rainImage/101001.jpg 

Demo...</description>
			<content:encoded><![CDATA[<div>Great collection of Sample AjaxControlToolkit TabContainer Themes.<br />
<br />
<img src="http://www.ajaxrain.com/rainImage/101001.jpg" border="0" alt="" /><br />
<br />
<a href="http://mattberseth2.com/tab%5Ftheme%5FII/" target="_blank">Demo</a><br />
<br />
<a href="http://mattberseth.com/blog/2007/09/more_sample_ajaxcontroltoolkit.html" target="_blank">More Information</a><br />
<br />
<a href="http://mattberseth2.com/downloads/tab_theme_II.zip" target="_blank">Download</a></div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=49</guid>
		</item>
		<item>
			<title>Lightbox for videos</title>
			<link>http://www.poudo.com/blog.php?b=48</link>
			<pubDate>Wed, 21 Nov 2007 16:55:00 GMT</pubDate>
			<description><![CDATA[Videobox is a 6kb script, which shows your videos in the page with an overlay.

Image: http://www.ajaxrain.com/rainImage/102101.jpg 

*Demo & Usage:*...]]></description>
			<content:encoded><![CDATA[<div>Videobox is a 6kb script, which shows your videos in the page with an overlay.<br />
<br />
<img src="http://www.ajaxrain.com/rainImage/102101.jpg" border="0" alt="" /><br />
<br />
<b>Demo &amp; Usage:</b> <a href="http://videobox-lb.sourceforge.net/" target="_blank">Lightbox for videos</a><br />
<br />
<a href="http://sourceforge.net/project/showfiles.php?group_id=203672" target="_blank">Download</a></div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=48</guid>
		</item>
		<item>
			<title>jQuery Ajax Rater Plugin</title>
			<link>http://www.poudo.com/blog.php?b=47</link>
			<pubDate>Wed, 21 Nov 2007 16:51:17 GMT</pubDate>
			<description><![CDATA[*Demo & use here:* jQuery Ajax Rater Plugin (http://www.m3nt0r.de/devel/raterDemo/)

*Download:*
jquery.rater.js...]]></description>
			<content:encoded><![CDATA[<div><b>Demo &amp; use here:</b> <a href="http://www.m3nt0r.de/devel/raterDemo/" target="_blank">jQuery Ajax Rater Plugin</a><br />
<br />
<b>Download:</b><br />
<a href="http://www.m3nt0r.de/devel/raterDemo/jquery.rater.js" target="_blank">jquery.rater.js</a> - <b>Size:</b> 4,35K<br />
<a href="http://www.m3nt0r.de/devel/raterDemo/jquery.rater.packed.js" target="_blank">jquery.rater.packed.js</a> - <b>Size:</b> 1,59K<br />
<a href="http://www.m3nt0r.de/devel/raterDemo/jquery.rater-1.0.zip" target="_blank">jquery.rater-1.0.zip</a> - <b>Size:</b> 5K<br />
<br />
<img src="http://www.ajaxrain.com/rainImage/nov1004.jpg" border="0" alt="" /></div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=47</guid>
		</item>
		<item>
			<title>Page rank using ajax</title>
			<link>http://www.poudo.com/blog.php?b=46</link>
			<pubDate>Wed, 21 Nov 2007 16:47:36 GMT</pubDate>
			<description>Google Pagerank function done using Ajax and php. Very handy and useful.

Demo: click here (http://213.198.89.146/chi/)
Download files: click here...</description>
			<content:encoded><![CDATA[<div>Google Pagerank function done using Ajax and php. Very handy and useful.<br />
<br />
Demo: <a href="http://213.198.89.146/chi/" target="_blank">click here</a><br />
Download files: <a href="http://joeabiraad.com/demos/pagerank/ajax_pagerank.rar" target="_blank">click here</a><br />
<br />
<img src="http://www.ajaxrain.com/rainImage/arc19nov01.JPG" border="0" alt="" /></div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=46</guid>
		</item>
		<item>
			<title>Starting with PHP and AJAX</title>
			<link>http://www.poudo.com/blog.php?b=44</link>
			<pubDate>Thu, 25 Oct 2007 22:52:49 GMT</pubDate>
			<description><![CDATA[This tutorial makes use of prototype AJAX library which can be downloaded here (http://www.prototypejs.org/assets/2007/6/20/prototype.js). It's a...]]></description>
			<content:encoded><![CDATA[<div>This tutorial makes use of prototype AJAX library which can be <a href="http://www.prototypejs.org/assets/2007/6/20/prototype.js" target="_blank">downloaded here</a>. It's a single JavaScript file which can be simply embed in the header section of your HTML code:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">HTML Code:</div>
	<pre class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 66px;
		text-align: left;
		overflow: auto"><span style="color:#000080">&lt;head&gt;</span>
	<span style="color:#800000">&lt;script type=<span style="color:#0000FF">&quot;text/javascript&quot;</span> src=<span style="color:#0000FF">&quot;prototype.js&quot;</span>&gt;</span><span style="color:#800000">&lt;/script&gt;</span>
<span style="color:#000080">&lt;/head&gt;</span></pre>
</div>So in this <a href="http://www.php-learn-it.com/tutorials/demos/starting_with_php_ajax/test.html" target="_blank">demo</a>, we have two files. The first file test.html contains a form with one input text box and a submit button. It also contains the javascript code for making the ajax request to test.php.<br />
<br />
The 2nd file is the test.php which receives the ajax request when we click on the submit button.<br />
<br />
When you fill in the test box and click the submit button, it displays the value of the text box without refreshing the page. <a href="http://www.php-learn-it.com/tutorials/demos/starting_with_php_ajax/test.html" target="_blank">See demo here</a>. This is achieved using AJAX and it is really simple to accomplish.<br />
<br />
First, I'll just copy the code for both files for you to see and explain the code line by line.<br />
<br />
<b>text.html</b><br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">HTML Code:</div>
	<pre class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 498px;
		text-align: left;
		overflow: auto"><span style="color:#000080">&lt;html&gt;</span>
	<span style="color:#000080">&lt;head&gt;</span>		
		<span style="color:#800000">&lt;script type=<span style="color:#0000FF">&quot;text/javascript&quot;</span> src=<span style="color:#0000FF">&quot;prototype.js&quot;</span>&gt;</span><span style="color:#800000">&lt;/script&gt;</span>
		<span style="color:#800000">&lt;script&gt;</span>

			function sendRequest() {
				new Ajax.Request(&quot;test.php&quot;, 
					{ 
					method: 'post', 
					postBody: 'name='+ $F('name'),
					onComplete: showResponse 
					});
				}

			function showResponse(req){
				$('show').innerHTML= req.responseText;
			}
		<span style="color:#800000">&lt;/script&gt;</span>
	<span style="color:#000080">&lt;/head&gt;</span>

	<span style="color:#000080">&lt;body&gt;</span>
		<span style="color:#FF8000">&lt;form id=<span style="color:#0000FF">&quot;test&quot;</span> onsubmit=<span style="color:#0000FF">&quot;return false;&quot;</span>&gt;</span>
			<span style="color:#FF8000">&lt;input type=<span style="color:#0000FF">&quot;text&quot;</span> name=<span style="color:#0000FF">&quot;name&quot;</span> id=<span style="color:#0000FF">&quot;name&quot;</span> &gt;</span>
			<span style="color:#FF8000">&lt;input type=<span style="color:#0000FF">&quot;submit&quot;</span> value=<span style="color:#0000FF">&quot;submit&quot;</span> onClick=<span style="color:#0000FF">&quot;sendRequest()&quot;</span>&gt;</span>
		<span style="color:#FF8000">&lt;/form&gt;</span>
		
		<span style="color:#000080">&lt;div id=<span style="color:#0000FF">&quot;show&quot;</span>&gt;</span><span style="color:#000080">&lt;/div&gt;</span>
	<span style="color:#000080">&lt;/body&gt;</span>

<span style="color:#000080">&lt;/html&gt;</span></pre>
</div><b>test.php</b><br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 130px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br /></font><font color="#007700">if(</font><font color="#0000BB">$_POST</font><font color="#007700">&#91;</font><font color="#DD0000">"name"</font><font color="#007700">&#93;&nbsp;==&nbsp;</font><font color="#DD0000">""</font><font color="#007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</font><font color="#DD0000">"name&nbsp;is&nbsp;empty"</font><font color="#007700">;<br />else<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</font><font color="#DD0000">"you&nbsp;typed&nbsp;"</font><font color="#007700">.</font><font color="#0000BB">$_POST</font><font color="#007700">&#91;</font><font color="#DD0000">"name"</font><font color="#007700">&#93;;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div><b><br />
Code Explained</b><br />
<br />
<b>Making AJAX Request</b><br />
<br />
The function below sends the request out to our text.php script using the method post with the value filled in the input text box 'name' using $F(‘name') which retrieves the values we put in the text box. The onComplete: showResponse returns the repose from test.php<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 162px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB"></font><font color="#007700">function&nbsp;</font><font color="#0000BB">sendRequest</font><font color="#007700">()&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;new&nbsp;</font><font color="#0000BB">Ajax</font><font color="#007700">.</font><font color="#0000BB">Request</font><font color="#007700">(</font><font color="#DD0000">"test.php"</font><font color="#007700">,&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">method</font><font color="#007700">:&nbsp;</font><font color="#DD0000">'post'</font><font color="#007700">,&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">postBody</font><font color="#007700">:&nbsp;</font><font color="#DD0000">'name='</font><font color="#007700">+&nbsp;</font><font color="#0000BB">$F</font><font color="#007700">(</font><font color="#DD0000">'name'</font><font color="#007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">onComplete</font><font color="#007700">:&nbsp;</font><font color="#0000BB">showResponse&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">});<br />}&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div><b>Displaying Response</b><br />
<br />
Next we show the response we get from the text.php in the &lt;div id=”show”&gt;&lt;/div&gt;.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 98px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB"></font><font color="#007700">function&nbsp;</font><font color="#0000BB">showResponse</font><font color="#007700">(</font><font color="#0000BB">req</font><font color="#007700">){<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;$(</font><font color="#DD0000">'show'</font><font color="#007700">).</font><font color="#0000BB">innerHTML</font><font color="#007700">=&nbsp;</font><font color="#0000BB">req</font><font color="#007700">.</font><font color="#0000BB">responseText</font><font color="#007700">;<br /><br />}&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>So, when you click on submit you will either get a response saying 'name is empty' if the text box was left empty or &quot;you typed &lt;yourname&gt;&quot;.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 114px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">if(</font><font color="#0000BB">$_POST</font><font color="#007700">&#91;</font><font color="#DD0000">"name"</font><font color="#007700">&#93;&nbsp;==&nbsp;</font><font color="#DD0000">""</font><font color="#007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</font><font color="#DD0000">"name&nbsp;is&nbsp;empty"</font><font color="#007700">;<br />else<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</font><font color="#DD0000">"you&nbsp;typed&nbsp;"</font><font color="#007700">.</font><font color="#0000BB">$_POST</font><font color="#007700">&#91;</font><font color="#DD0000">"name"</font><font color="#007700">&#93;;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div></div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=44</guid>
		</item>
		<item>
			<title>A Simple .gif Gallery</title>
			<link>http://www.poudo.com/blog.php?b=43</link>
			<pubDate>Thu, 25 Oct 2007 22:47:15 GMT</pubDate>
			<description><![CDATA[PHP:
---------
<?php 

    $handle=opendir('.'); 
    $strSought = "gif"; 
    $imgCount = 5;  

    while ($file = readdir($handle))]]></description>
			<content:encoded><![CDATA[<div><div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 498px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?php&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;$handle</font><font color="#007700">=</font><font color="#0000BB">opendir</font><font color="#007700">(</font><font color="#DD0000">'.'</font><font color="#007700">);&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$strSought&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">"gif"</font><font color="#007700">;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$imgCount&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">5</font><font color="#007700">;&nbsp;&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(</font><font color="#0000BB">$file&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">readdir</font><font color="#007700">(</font><font color="#0000BB">$handle</font><font color="#007700">))&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</font><font color="#0000BB">$strSought&nbsp;</font><font color="#007700">==&nbsp;</font><font color="#0000BB">substr</font><font color="#007700">(</font><font color="#0000BB">$file</font><font color="#007700">,&nbsp;-</font><font color="#0000BB">3</font><font color="#007700">))&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$imgCount&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$imgCount&nbsp;</font><font color="#007700">+&nbsp;</font><font color="#0000BB">1</font><font color="#007700">;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">closedir</font><font color="#007700">(</font><font color="#0000BB">$handle</font><font color="#007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</font><font color="#0000BB">$imgCount&nbsp;</font><font color="#007700">!=&nbsp;</font><font color="#0000BB">5</font><font color="#007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$handle</font><font color="#007700">=</font><font color="#0000BB">opendir</font><font color="#007700">(</font><font color="#DD0000">'.'</font><font color="#007700">);&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$perRow&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">4</font><font color="#007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$numRows&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$imgCount</font><font color="#007700">/</font><font color="#0000BB">$perRow</font><font color="#007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$imgNum&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">0</font><font color="#007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</font><font color="#DD0000">"&lt;table&nbsp;width=\"300\"&nbsp;border=\"0\"&gt;"</font><font color="#007700">;&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF9900">//Note:&nbsp;readdir&nbsp;returns&nbsp;filenames&nbsp;in&nbsp;the&nbsp;order&nbsp;in&nbsp;which&nbsp;they&nbsp;are&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&nbsp;&nbsp;stored&nbsp;by&nbsp;the&nbsp;filesystem.&nbsp;Future&nbsp;enhancement:&nbsp;sort&nbsp;by&nbsp;filename&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&nbsp;&nbsp;(sequence&nbsp;they&nbsp;were&nbsp;shot)&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">while&nbsp;(</font><font color="#0000BB">false&nbsp;</font><font color="#007700">!==&nbsp;(</font><font color="#0000BB">$file&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">readdir</font><font color="#007700">(</font><font color="#0000BB">$handle</font><font color="#007700">)))&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</font><font color="#0000BB">$strSought&nbsp;</font><font color="#007700">==&nbsp;</font><font color="#0000BB">substr</font><font color="#007700">(</font><font color="#0000BB">$file</font><font color="#007700">,&nbsp;-</font><font color="#0000BB">3</font><font color="#007700">))&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$imgNum</font><font color="#007700">++;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$size&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">GetImageSize</font><font color="#007700">(</font><font color="#0000BB">$file</font><font color="#007700">);&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$jpglink&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">substr</font><font color="#007700">(</font><font color="#0000BB">$file</font><font color="#007700">,&nbsp;</font><font color="#0000BB">0</font><font color="#007700">,&nbsp;</font><font color="#0000BB">8</font><font color="#007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</font><font color="#DD0000">"&lt;td&gt;&lt;img&nbsp;src=\"$file\"&nbsp;height=\"$size&#91;1&#93;\"&nbsp;width=\"$size&#91;0&#93;\"&nbsp;border=\"0\"&nbsp;hspace=\"5\"&nbsp;vspace=\"5\"&gt;"</font><font color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF9900">//modulus&nbsp;(%)&nbsp;$a&nbsp;%&nbsp;$b&nbsp;remainder&nbsp;of&nbsp;$a&nbsp;divided&nbsp;by&nbsp;$b&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">if&nbsp;(</font><font color="#0000BB">$imgNum</font><font color="#007700">%</font><font color="#0000BB">$perRow</font><font color="#007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</font><font color="#DD0000">"&lt;/td&gt;"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</font><font color="#DD0000">"&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">closedir</font><font color="#007700">(</font><font color="#0000BB">$handle</font><font color="#007700">);&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</font><font color="#DD0000">"&lt;/table&gt;"</font><font color="#007700">;&nbsp;<br />&nbsp;&nbsp;}<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>you can change this:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 34px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&nbsp;$imgCount&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">5</font><font color="#007700">;&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>to however many images you want in a row</div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=43</guid>
		</item>
		<item>
			<title>Reading and Writing files in PHP</title>
			<link>http://www.poudo.com/blog.php?b=42</link>
			<pubDate>Thu, 25 Oct 2007 22:45:09 GMT</pubDate>
			<description>PHP follows almost same way of writing and manipulating files as in standard C. That is why it becomes so easy for a developer with C lanaguage...</description>
			<content:encoded><![CDATA[<div>PHP follows almost same way of writing and manipulating files as in standard C. That is why it becomes so easy for a developer with C lanaguage background to create php application that uses files to save and retrieve data. It is a short tutoril that will get you started with writng and manipulating text files.<br />
<br />
To open a file either for writing, manipulating (adding new data, or appending new data at end of file), we use single function called fopen, but the second argument of the function changes accordingly.<br />
<br />
For example: <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 34px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$F&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">,</font><font color="#DD0000">"w"</font><font color="#007700">);&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>Here the second argument passed was &quot;w&quot; only, which means write the file, if it does not exists then create it, and if does not exist create new file.<br />
Now, if a file with name myfile.txt already exists, it will be rewritten and all of its bytes are lost, if it was not existing a new file with name myfile.txt is created.<br />
<br />
The second argument (we used &quot;w&quot;) is the file opening mode, is dependant upon your requirement. In general disadvantage of using &quot;w&quot; as mode is if your ifle already exists, it is rewritten, and you loose all existing bytes. So it is recomended that you use mode &quot;w&quot; only when you need to create a new file or really wish to turn filesize to 0 (zero).<br />
<br />
Second mode is &quot;r&quot;, which is using for reading and writing. Using this filemode you can open a file for reading and writing. Although modes &quot;r&quot; as well as (append &quot;a&quot;) allows read and write but they do not affect the file while opening it, so the &quot;w&quot; also allows writing + reading but as mentioned, it rewrites the file.<br />
<br />
So, to open a file for reading and writing we will write: <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 34px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$F&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">,</font><font color="#DD0000">"r"</font><font color="#007700">);&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>And same if we need to open a file which starts writing data to the end of file (appends data), we will srite: <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 34px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$F&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">,</font><font color="#DD0000">"a"</font><font color="#007700">);&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>Remember : With both of these modes you can read as well as write data anywhere in the file.<br />
<br />
<br />
Now question appears, if I open a file with mode &quot;r&quot; now I have ended up reading soem data, how can I force my script to start writing data on the end of file ?<br />
<br />
Two answers:<br />
1. If you have read entire data, the next writing automatically starts at the end of file.<br />
2. If you read data less then the file size, you must be somewhere within file, and if you start writing data, the script will write data to the last position of data you ended up reading with.<br />
<br />
To obtain filesize we use a function filesize, to which we only pass name of file alongwith path (if not current directory) and it returns us the size of the file in bytes. e.g. <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 34px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$size&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">filesize</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">);&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>Now, when you have opened a file for reading and you wish to jump to a certain position (in this case end of file), you use a function fseek which lets you jump within file to any possible position. e.g.<br />
<br />
suppose your file size is 10 bytes, you read very first two characters. Now you wish to jum pto the end of file. <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 130px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB"></font><font color="#FF9900">//reading&nbsp;done,&nbsp;assume&nbsp;$F&nbsp;is&nbsp;file&nbsp;variable<br /><br /></font><font color="#0000BB">$size&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">filesize</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">fseek</font><font color="#007700">(</font><font color="#0000BB">$F</font><font color="#007700">,&nbsp;</font><font color="#0000BB">$size</font><font color="#007700">);&nbsp;</font><font color="#FF9900">//now&nbsp;we&nbsp;are&nbsp;at&nbsp;end&nbsp;of&nbsp;file<br /><br />//start&nbsp;writing&nbsp;here&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>The same we will do when we need to jump to the start of file as:<br />
fseek($F,0); //0 means very first byte position<br />
<br />
Bytes position in a file have zero based indexes, 0 means 1st character, 9 means 10th character and so on.<br />
<br />
<br />
<b>Now come to core of reading and wrting:</b><br />
<br />
Writing is very simple, as I have mentioned in all above talk the writing starts where pointer (position) currently is so the reading too.<br />
<br />
<b>Example 1:</b> Create new file and write string &quot;My name is Ali&quot; in it <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 98px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$F&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">,</font><font color="#DD0000">"w"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">fwrite</font><font color="#007700">(</font><font color="#0000BB">$F</font><font color="#007700">,</font><font color="#0000BB">My&nbsp;name&nbsp;is&nbsp;Ali</font><font color="#007700">);<br /><br /></font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$f</font><font color="#007700">);&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>In this example you see two new functions fwrite and fclose.<br />
fwrite is used to write something in a file at current position, since we created new file so writing starts at very first byte autoatically. And fclose is used to stop using a file anymore. This is necessary, becuase there is always a limit of opened files in operating system, so if your script is used much and leaves every file open without closing, it will results in no more file openable until system restart, either an http server (a web host) and/or local host. So, a new file is created and stirng &quot;My name is Ali&quot; is written in it (14 bytes written).<br />
<br />
<br />
<b>Example 2:</b> Read first 7 bytes from file we created in example 1 and print them to browser <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 130px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$F&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">,</font><font color="#DD0000">"r"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$data&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fread</font><font color="#007700">(</font><font color="#0000BB">$F</font><font color="#007700">,&nbsp;</font><font color="#0000BB">7</font><font color="#007700">);<br /><br /></font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$f</font><font color="#007700">);<br /><br />print&nbsp;</font><font color="#0000BB">$data</font><font color="#007700">;&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>In this example you encounter a ne function, called fread. This function is used to read specific number of bytes from a file. Its first argument is the file variable, and second is number of bytes to read. So we passed 7, becuase our rquirement at this time, is to read 7 bytes only. This function returned us the bytes read and we simpyl displayed them using print function, so it will display &quot;My name&quot; only the first7 bytes we read. Take a look at next example<br />
<br />
<b>Example 3:</b> Read all data from file we created in example 1 and print it to browser <br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 162px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$F&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">,</font><font color="#DD0000">"r"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$size&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">filesize</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$data&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fread</font><font color="#007700">(</font><font color="#0000BB">$F</font><font color="#007700">,&nbsp;</font><font color="#0000BB">$size</font><font color="#007700">);<br /><br /></font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$f</font><font color="#007700">);<br /><br />print&nbsp;</font><font color="#0000BB">$data</font><font color="#007700">;&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>In this example we used function filesize, which returned us the exact file size in bytes, we saved that size in a varible $size and then passed it to fread as secnd argument, so that the fread function reads all the data in file. I think it is simple to understand. It will display &quot;My name is Ali&quot; in the browser.<br />
<br />
<b>Modifying data</b><br />
<br />
<b>Example 4:</b> Jump to byte # 12 and write string &quot;Imran&quot; <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 162px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$F&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">,</font><font color="#DD0000">"r"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">fseek</font><font color="#007700">(</font><font color="#0000BB">$F</font><font color="#007700">,&nbsp;</font><font color="#0000BB">11</font><font color="#007700">);<br /><br /></font><font color="#0000BB">fwrite</font><font color="#007700">(</font><font color="#0000BB">$F</font><font color="#007700">,</font><font color="#DD0000">"Imran"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$f</font><font color="#007700">);<br /><br />print&nbsp;</font><font color="#0000BB">$data</font><font color="#007700">;&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>We opened file, jumped to byte number 12 using fseek function. Why used 11 when we need to start modifying from byte 12 ? Because I already mentioned that bytes in a file are accessed using zero based index, 11 means 12, 59 means 60, and 0 means 1st byte. Now run the example 3 and you will see the display in browser is &quot;My name is Imran&quot;, which means we successfully have modified the file.<br />
<br />
<b>Example 5:</b> Add string &quot;. My age is 30&quot; to the end of file we created in example 1 <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 130px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$F&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">,</font><font color="#DD0000">"a"</font><font color="#007700">);&nbsp;</font><font color="#FF9900">//note&nbsp;"a"<br /><br /></font><font color="#0000BB">fwrite</font><font color="#007700">(</font><font color="#0000BB">$F</font><font color="#007700">,</font><font color="#DD0000">".&nbsp;My&nbsp;age&nbsp;is&nbsp;30"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$f</font><font color="#007700">);<br /><br />print&nbsp;</font><font color="#0000BB">$data</font><font color="#007700">;&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>We opened file with append mode, using &quot;a&quot; as second argumen to function fopen, which automatically takes position to the end of file, s owe dont need to use fseek in thsi regards. Now if you repeat running example 3 you will get the output as &quot;My name is Imran. My age is 30&quot;.<br />
<br />
<br />
Extra things:<br />
<br />
1. Another method to read entire file data in a variable <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 34px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$data&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">get_file_contents</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">);&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>2. Read text file as an array of strings, where each line of text is an ite of array <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 34px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$arr&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">file</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">);&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>3. If you dont have above function in your php distribution, use following ot read entire data <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 34px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$data&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">implode</font><font color="#007700">(</font><font color="#DD0000">""</font><font color="#007700">,</font><font color="#0000BB">file</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">));&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>4. to delete a file <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 34px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">unlink</font><font color="#007700">(</font><font color="#DD0000">"myfile.txt"</font><font color="#007700">);&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>5. read page from internet<br />
pass url instead of fileme in ne of first 3 examples.<br />
<br />
I hope I have explained some.<br />
<br />
Let me know if you have any question.</div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=42</guid>
		</item>
		<item>
			<title>Easy way to Upload files using PHP</title>
			<link>http://www.poudo.com/blog.php?b=41</link>
			<pubDate>Thu, 25 Oct 2007 22:38:46 GMT</pubDate>
			<description>There is a traditional way of uploading files in php usually developers use, that is, use functions is_uploaded_file() and move_uplaoded_file()....</description>
			<content:encoded><![CDATA[<div>There is a traditional way of uploading files in php usually developers use, that is, use functions is_uploaded_file() and move_uplaoded_file(). These functions my create problems sometimes. function move_uplaoded_file() sometimes does not let you move file to a specific folder, may be becuase your account does not have permission to move a temporary file to some folder in your account. I encountered same problem when my client reported me that he has ful permissions to write a file anywhere in any folder, and he has successfully chmod-ed the folders to 777 / 666 (on unix server), but he still cannot get the admin panel script to perform uploading of image. Then I came to know that I must not use move_uplaoded_file, but find some other way to read the file data and write it myself whereever I want. So I came up with following things. <br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 130px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB"></font><font color="#FF9900">//First&nbsp;check&nbsp;types&nbsp;and&nbsp;errors&nbsp;and&nbsp;make&nbsp;sure&nbsp;file&nbsp;is&nbsp;right<br /><br /><br /><br /></font><font color="#0000BB">$file_to_read&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$_FILES</font><font color="#007700">&#91;</font><font color="#DD0000">'myfilevar'</font><font color="#007700">&#93;&#91;</font><font color="#DD0000">'tmp_name'</font><font color="#007700">&#93;;&nbsp;</font><font color="#FF9900">//access&nbsp;tmp_name&nbsp;that&nbsp;is&nbsp;temporary&nbsp;file<br /><br /></font><font color="#0000BB">$file_data&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">implode</font><font color="#007700">(</font><font color="#DD0000">""</font><font color="#007700">,</font><font color="#0000BB">file</font><font color="#007700">(</font><font color="#0000BB">$file_to_read</font><font color="#007700">));&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>Now we have full data of file in variable $file_data and we can use it to write the file anywhere allowed.<br />
<br />
For example you wish to write the uplaoded file 'mynewfile.png' to a sub folder called 'myfiles', you write as. <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 98px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$f&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#DD0000">"./myfiles/mynewfile.png"</font><font color="#007700">,</font><font color="#DD0000">"w"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">fwrite</font><font color="#007700">(</font><font color="#0000BB">$f</font><font color="#007700">,</font><font color="#0000BB">$file_data</font><font color="#007700">);<br /><br /></font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$f</font><font color="#007700">);&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>That's it - you nomore need to use move_uploaded_file.</div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=41</guid>
		</item>
		<item>
			<title>Super Fast Form Processing Via PHP</title>
			<link>http://www.poudo.com/blog.php?b=40</link>
			<pubDate>Thu, 25 Oct 2007 22:33:30 GMT</pubDate>
			<description>This system is very easy. All it requires is 2 files, an html, and a php file.

1. Create a html file named *contact_us.html*
2. Insert the following...</description>
			<content:encoded><![CDATA[<div>This system is very easy. All it requires is 2 files, an html, and a php file.<br />
<br />
1. Create a html file named <b>contact_us.html</b><br />
2. Insert the following code<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">HTML Code:</div>
	<pre class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 162px;
		text-align: left;
		overflow: auto"><span style="color:#000080">&lt;title&gt;</span>NeoGT Mail Form<span style="color:#000080">&lt;/title&gt;</span><span style="color:#000080">&lt;body&gt;</span>
<span style="color:#FF8000">&lt;form action=<span style="color:#0000FF">&quot;mail.php&quot;</span> method=<span style="color:#0000FF">&quot;POST&quot;</span>&gt;</span>
Your Name: <span style="color:#FF8000">&lt;input type=<span style="color:#0000FF">&quot;text&quot;</span> name=<span style="color:#0000FF">&quot;name&quot;</span> size=<span style="color:#0000FF">&quot;20&quot;</span> /&gt;</span><span style="color:#000080">&lt;br /&gt;</span>
Your Email: <span style="color:#FF8000">&lt;input type=<span style="color:#0000FF">&quot;text&quot;</span> name=<span style="color:#0000FF">&quot;email&quot;</span> size=<span style="color:#0000FF">&quot;20&quot;</span>/&gt;</span><span style="color:#000080">&lt;br /&gt;</span>
Subject: <span style="color:#FF8000">&lt;input type=<span style="color:#0000FF">&quot;text&quot;</span> name=<span style="color:#0000FF">&quot;subject&quot;</span> size=<span style="color:#0000FF">&quot;20&quot;</span>/&gt;</span><span style="color:#000080">&lt;br /&gt;</span>
Comments:<span style="color:#FF8000">&lt;textarea name=<span style="color:#0000FF">&quot;text&quot;</span> name=<span style="color:#0000FF">&quot;text&quot;</span> cols=<span style="color:#0000FF">&quot;50&quot;</span> rows=<span style="color:#0000FF">&quot;10&quot;</span>&gt;</span><span style="color:#FF8000">&lt;/textarea&gt;</span><span style="color:#000080">&lt;br /&gt;</span>
<span style="color:#FF8000">&lt;input type=<span style="color:#0000FF">&quot;submit&quot;</span> name=<span style="color:#0000FF">&quot;submit&quot;</span> value=<span style="color:#0000FF">&quot;Send&quot;</span> /&gt;</span>
<span style="color:#FF8000">&lt;/form&gt;</span>
<span style="color:#000080">&lt;/body&gt;</span></pre>
</div>3. Create a php file named <b>mail.php</b><br />
4. Insert the following code<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 162px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">@</font><font color="#0000BB">extract</font><font color="#007700">(</font><font color="#0000BB">$_POST</font><font color="#007700">);<br /></font><font color="#0000BB">$name&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">stripslashes</font><font color="#007700">(</font><font color="#0000BB">$name</font><font color="#007700">);<br /></font><font color="#0000BB">$email&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">stripslashes</font><font color="#007700">(</font><font color="#0000BB">$email</font><font color="#007700">);<br /></font><font color="#0000BB">$subject&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">stripslashes</font><font color="#007700">(</font><font color="#0000BB">$subject</font><font color="#007700">);<br /></font><font color="#0000BB">$text&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">stripslashes</font><font color="#007700">(</font><font color="#0000BB">$text</font><font color="#007700">);<br /></font><font color="#0000BB">mail</font><font color="#007700">(</font><font color="#DD0000">'email@address.com'</font><font color="#007700">,</font><font color="#0000BB">$subject</font><font color="#007700">,</font><font color="#0000BB">$text</font><font color="#007700">,</font><font color="#DD0000">"From:&nbsp;$name&nbsp;&lt;$email&gt;"</font><font color="#007700">);<br />echo(</font><font color="#DD0000">"Your&nbsp;email&nbsp;was&nbsp;sent,&nbsp;thank&nbsp;you!"</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>Notes:<br />
@extract will attempt to collect the post data<br />
Field names with the '$' symbol provide variables, hence;[*]$name[*]email[*]$subject[*]$text<br />
Echo command displays any desired text</div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=40</guid>
		</item>
		<item>
			<title>PHP: PHPBB2 integration with your site</title>
			<link>http://www.poudo.com/blog.php?b=39</link>
			<pubDate>Sun, 21 Oct 2007 12:32:05 GMT</pubDate>
			<description>In this tutorial I will teach you how to integrate PHPBB2 into your main site. This includes a login form, showing user info, and more.

PHPBB2 keeps...</description>
			<content:encoded><![CDATA[<div>In this tutorial I will teach you how to integrate PHPBB2 into your main site. This includes a login form, showing user info, and more.<br />
<br />
PHPBB2 keeps sessions using cookies. Making the cookies extend to your main site is a fairly simple task.<br />
<br />
There is a small complication with keeping the PHPBB2 sessions active when linking from your integrated main site to your forum. You have to use the <b>append_sid()</b> function on all the links to your forum. It is also recommended to do this with all links that point to the mainsite, but it is not required.<br />
<br />
Lets start with a simple file that we will include in all our main site pages. This file will take care of the cookies PHPPBB2 uses and allow us to use PHPBB2 defined functions.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 146px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />define</font><font color="#007700">(</font><font color="#DD0000">'IN_PHPBB'</font><font color="#007700">,&nbsp;</font><font color="#0000BB">true</font><font color="#007700">);<br /></font><font color="#0000BB">$phpbb_root_path&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">'forums/'</font><font color="#007700">;&nbsp;</font><font color="#FF9900">//Relative&nbsp;path&nbsp;to&nbsp;your&nbsp;PHPBB2&nbsp;installation<br /></font><font color="#007700">include(</font><font color="#0000BB">$phpbb_root_path&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#DD0000">'extension.inc'</font><font color="#007700">);<br />include(</font><font color="#0000BB">$phpbb_root_path&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#DD0000">'common.'</font><font color="#007700">.</font><font color="#0000BB">$phpEx</font><font color="#007700">);<br /></font><font color="#0000BB">$userdata&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">session_pagestart</font><font color="#007700">(</font><font color="#0000BB">$user_ip</font><font color="#007700">,&nbsp;</font><font color="#0000BB">PAGE_INDEX</font><font color="#007700">);<br /></font><font color="#0000BB">init_userprefs</font><font color="#007700">(</font><font color="#0000BB">$userdata</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>Make sure that the variable with the path to your forum is correct, otherwise the sessions will not work.<br />
<br />
Now lets make an example page witch includes the above file and checks if a user is logged in and if the user is a guest displays a login form.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 258px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">include(</font><font color="#DD0000">'include.php'</font><font color="#007700">);&nbsp;</font><font color="#FF9900">//include&nbsp;our&nbsp;session&nbsp;handling&nbsp;file,&nbsp;make&nbsp;sure&nbsp;you&nbsp;have&nbsp;the&nbsp;right&nbsp;file&nbsp;name<br /><br /></font><font color="#007700">if(&nbsp;!</font><font color="#0000BB">$userdata</font><font color="#007700">&#91;</font><font color="#DD0000">'session_logged_in'</font><font color="#007700">&#93;&nbsp;)&nbsp;</font><font color="#FF9900">//&nbsp;Is&nbsp;the&nbsp;user&nbsp;NOT&nbsp;logged&nbsp;in?<br />&nbsp;&nbsp;&nbsp;</font><font color="#007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">?&gt;<br /></font>&lt;form&nbsp;action="forums/login.php"&nbsp;method="post"&nbsp;name="login"&gt;&nbsp;&lt;!--&nbsp;Show&nbsp;a&nbsp;simple&nbsp;login&nbsp;form&nbsp;--&gt;<br />&lt;input&nbsp;type="text"&nbsp;name="username"&gt;&lt;br&nbsp;/&gt;<br />&lt;input&nbsp;type="password"&nbsp;name="password"&gt;&lt;br&nbsp;/&gt;<br />&lt;input&nbsp;type="hidden"&nbsp;name="redirect"&nbsp;value="../index.php"&gt;&nbsp;&lt;!--&nbsp;Redirect&nbsp;the&nbsp;user&nbsp;to&nbsp;a&nbsp;page&nbsp;different&nbsp;than&nbsp;the&nbsp;PHPBB2&nbsp;index&nbsp;page.&nbsp;You&nbsp;can&nbsp;delete&nbsp;this&nbsp;if&nbsp;you&nbsp;want.&nbsp;The&nbsp;path&nbsp;must&nbsp;be&nbsp;relative&nbsp;from&nbsp;the&nbsp;PHPBB2&nbsp;login&nbsp;file.&nbsp;--&gt;<br />&lt;input&nbsp;type="submit"&nbsp;value="login"&nbsp;name="login"&gt;<br />&lt;/form&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;</font><font color="#007700">}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>Make sure that the action attribute of the form tag points to your forums login page.<br />
<br />
Now for the <b>append_sid()</b> function, here is an example of how the function can be use on your URLs.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 146px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$phpbb_links&nbsp;</font><font color="#007700">=&nbsp;array&nbsp;(&nbsp;</font><font color="#FF9900">//start&nbsp;our&nbsp;array<br /></font><font color="#DD0000">'home'&nbsp;</font><font color="#007700">=&gt;&nbsp;</font><font color="#0000BB">append_sid</font><font color="#007700">(</font><font color="#DD0000">"index.$phpEx"</font><font color="#007700">),&nbsp;</font><font color="#FF9900">//&nbsp;.$phpEx&nbsp;is&nbsp;the&nbsp;way&nbsp;PHPBB2&nbsp;writes&nbsp;the&nbsp;.php&nbsp;file&nbsp;extension,&nbsp;change&nbsp;this&nbsp;to&nbsp;just&nbsp;.html&nbsp;if&nbsp;you&nbsp;use&nbsp;.html&nbsp;files&nbsp;or&nbsp;other&nbsp;file&nbsp;extensions.<br /></font><font color="#DD0000">'forums_home'&nbsp;</font><font color="#007700">=&gt;&nbsp;</font><font color="#0000BB">append_sid</font><font color="#007700">(</font><font color="#DD0000">"forums/index.$phpEx"</font><font color="#007700">),<br /></font><font color="#DD0000">'tolist'&nbsp;</font><font color="#007700">=&gt;&nbsp;</font><font color="#0000BB">append_sid</font><font color="#007700">(</font><font color="#DD0000">"toplist.$phpEx"</font><font color="#007700">),&nbsp;</font><font color="#FF9900">//&nbsp;notice&nbsp;the&nbsp;comma&nbsp;after&nbsp;each&nbsp;line<br /></font><font color="#DD0000">'downloads'&nbsp;</font><font color="#007700">=&gt;&nbsp;</font><font color="#0000BB">append_sid</font><font color="#007700">(</font><font color="#DD0000">"downloads.$phpEx"</font><font color="#007700">)&nbsp;</font><font color="#FF9900">//&nbsp;there&nbsp;is&nbsp;no&nbsp;comma&nbsp;on&nbsp;the&nbsp;last&nbsp;line<br /></font><font color="#007700">);&nbsp;</font><font color="#FF9900">//&nbsp;end&nbsp;our&nbsp;array<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>You can simply put this code at the top of your page or even better put it in the sessions file that you include on each page.<br />
<br />
Then you simply call the variable when you want the link.<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 34px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
&lt;a&nbsp;href="<font color="#0000BB">&lt;?php&nbsp;</font><font color="#007700">echo&nbsp;</font><font color="#0000BB">$phpbb_links</font><font color="#007700">&#91;</font><font color="#DD0000">'home'</font><font color="#007700">&#93;;&nbsp;</font><font color="#0000BB">?&gt;</font>"&gt;Site&nbsp;Home&lt;/a&gt;</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>It's as simple as that. The last thing I will show you how to do is to display some information about a user when he or she is logged in.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 194px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">include(</font><font color="#DD0000">'include.php'</font><font color="#007700">);&nbsp;</font><font color="#FF9900">//include&nbsp;our&nbsp;session&nbsp;handling&nbsp;file<br /></font><font color="#007700">if(&nbsp;</font><font color="#0000BB">$userdata</font><font color="#007700">&#91;</font><font color="#DD0000">'session_logged_in'</font><font color="#007700">&#93;&nbsp;)&nbsp;</font><font color="#FF9900">//&nbsp;Is&nbsp;the&nbsp;user&nbsp;logged&nbsp;in?<br />&nbsp;&nbsp;&nbsp;</font><font color="#007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$appendLogout&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$u_login_logout&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$phpbb_root_path</font><font color="#007700">.</font><font color="#DD0000">'login.'</font><font color="#007700">.</font><font color="#0000BB">$phpEx</font><font color="#007700">.</font><font color="#DD0000">'?logout=true&amp;amp;sid='&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#0000BB">$userdata</font><font color="#007700">&#91;</font><font color="#DD0000">'session_id'</font><font color="#007700">&#93;;&nbsp;</font><font color="#FF9900">//&nbsp;Add&nbsp;the&nbsp;session&nbsp;ID&nbsp;to&nbsp;the&nbsp;logout&nbsp;link<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">echo&nbsp;</font><font color="#DD0000">"Welcome&nbsp;back,&nbsp;&lt;a&nbsp;href=\"forums/profile.php?mode=viewprofile&amp;u="</font><font color="#007700">.</font><font color="#0000BB">$userdata</font><font color="#007700">&#91;</font><font color="#DD0000">'user_id'</font><font color="#007700">&#93;.</font><font color="#DD0000">"\"&nbsp;title=\""</font><font color="#007700">.</font><font color="#0000BB">$userdata</font><font color="#007700">&#91;</font><font color="#DD0000">'username'</font><font color="#007700">&#93;.</font><font color="#DD0000">"\"&gt;"</font><font color="#007700">.</font><font color="#0000BB">$userdata</font><font color="#007700">&#91;</font><font color="#DD0000">'username'</font><font color="#007700">&#93;.</font><font color="#DD0000">"&lt;/a&gt;!&lt;br&nbsp;/&gt;"</font><font color="#007700">;&nbsp;</font><font color="#FF9900">//&nbsp;Show&nbsp;a&nbsp;welcome&nbsp;message<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">echo&nbsp;</font><font color="#DD0000">"&lt;a&nbsp;href=\"forums/privmsg.php?folder=inbox\"&nbsp;title=\"You&nbsp;have&nbsp;"</font><font color="#007700">.</font><font color="#0000BB">$userdata</font><font color="#007700">&#91;</font><font color="#DD0000">'user_unread_privmsg'</font><font color="#007700">&#93;.</font><font color="#DD0000">"&nbsp;new&nbsp;messages\"&gt;("</font><font color="#007700">.</font><font color="#0000BB">$userdata</font><font color="#007700">&#91;</font><font color="#DD0000">'user_unread_privmsg'</font><font color="#007700">&#93;.</font><font color="#DD0000">")&nbsp;New&nbsp;Messages&lt;/a&gt;&lt;br&nbsp;/&gt;"</font><font color="#007700">;&nbsp;</font><font color="#FF9900">//&nbsp;Any&nbsp;new&nbsp;PMs?<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">echo&nbsp;</font><font color="#DD0000">"&lt;a&nbsp;href=\"forums/profile.php?mode=editprofile\"&nbsp;title=\"My&nbsp;Profile\"&gt;My&nbsp;Profile&lt;/a&gt;&lt;br&nbsp;/&gt;"</font><font color="#007700">;&nbsp;</font><font color="#FF9900">//&nbsp;Edit&nbsp;your&nbsp;profile&nbsp;link<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">echo&nbsp;</font><font color="#DD0000">"&lt;a&nbsp;href=\""</font><font color="#007700">.</font><font color="#0000BB">$appendLogout</font><font color="#007700">.</font><font color="#DD0000">"\"&nbsp;title=\"Logout\"&gt;Logout&lt;/a&gt;&lt;br&nbsp;/&gt;"</font><font color="#007700">;&nbsp;</font><font color="#FF9900">//&nbsp;Logout&nbsp;link<br />&nbsp;&nbsp;&nbsp;</font><font color="#007700">}&nbsp;</font><font color="#FF9900">//&nbsp;end&nbsp;if,&nbsp;if&nbsp;you&nbsp;want&nbsp;you&nbsp;could&nbsp;add&nbsp;a&nbsp;login&nbsp;form&nbsp;in&nbsp;an&nbsp;else&nbsp;statement&nbsp;below<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>Make sure you make the links point to your forums, if you want you can change all the links to use the $phpbb_root_path set in the included file as I have done in the logout link. Also notice that i didn't use append_sid() on the logout link, it is required to add the session id manually on a logout link otherwise you will get an error from the logout page.<br />
<br />
You can download the entire script in .zip format from:<br />
<a href="http://www.marek.litomisky.com/tutorials/PHPBB2-integration/PHPBB2-integration.zip" target="_blank">http://www.marek.litomisky.com/tutor...ntegration.zip</a><br />
Just make sure you change the forum path to the correct one.<br />
<br />
That's about all there is to site integration with PHPBB2! If you have any questions or comments leave them using the form below and if you liked this tutorial, please think about registering at Design Avarice.</div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=39</guid>
		</item>
		<item>
			<title>Creating a count down system</title>
			<link>http://www.poudo.com/blog.php?b=38</link>
			<pubDate>Sun, 21 Oct 2007 12:26:40 GMT</pubDate>
			<description><![CDATA[In this tutorial I will show you how to create a simple count down system.

*Step 1.*
First of all let's collect what we need to make our idea to a...]]></description>
			<content:encoded><![CDATA[<div>In this tutorial I will show you how to create a simple count down system.<br />
<br />
<b>Step 1.</b><br />
First of all let's collect what we need to make our idea to a working code. We want to calculate how many day, hours, minutes and seconds are until a given date is coming. To do this we need the date and time in the future (let's call it to target date) and the actual date and time informations. In this tutorial we will use a hard coded target date. To make our calculation more easy and to avoid any date/time string format problem just define each date component separate like this:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 178px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF9900">//&nbsp;Define&nbsp;your&nbsp;target&nbsp;date&nbsp;here<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$targetYear&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">2007</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$targetMonth&nbsp;&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">9</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$targetDay&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">10</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$targetHour&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">12</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$targetMinute&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">00</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$targetSecond&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">00</font><font color="#007700">;<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div><b>Step 2.</b><br />
As next step we have to calculate the difference between the actual date and the target date. To do this we will convert/get both date values to a UNIX timestamp in a long integer format which containing the number of seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time specified. To convert the target date use the built in PHP function mktime()<br />
<br />
<b>Synatx:</b><br />
int mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]] )<br />
<br />
As you can see we can use here the date components defined in Step 1.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 66px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$targetDate&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mktime</font><font color="#007700">(</font><font color="#0000BB">$targetHour</font><font color="#007700">,</font><font color="#0000BB">$targetMinute</font><font color="#007700">,</font><font color="#0000BB">$targetSecond</font><font color="#007700">,</font><font color="#0000BB">$targetMonth</font><font color="#007700">,</font><font color="#0000BB">$targetDay</font><font color="#007700">,</font><font color="#0000BB">$targetYear</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>To get the actual date we can simply use an oyher built in PHP function time() which function returns the actual date in UNIXtimestamp format as the mktime function.<br />
<br />
<b>Syntax:</b><br />
int time ( void )<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 66px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$actualDate&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">time</font><font color="#007700">();<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div><b>Step 3.</b><br />
Now we have both the dates so we can calculate the difference quite easy: target date - actual date. Let's make some calculation how many full days, hours, minutes is it. As the difference is in seconds we will use the following approach. A day is 24 hours, each hours has 60 minutes and each minute has 60 seconds so at the end a full day is 60*60*24 seconds. We want to get only the full days so during our calculation we will use the floor() function which returns the next lowest integer value by rounding down value if necessary. So the complete calculation process looks like this:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 178px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$secondsDiff&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$targetDate&nbsp;</font><font color="#007700">-&nbsp;</font><font color="#0000BB">$actualDate</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$remainingDay&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">floor</font><font color="#007700">(</font><font color="#0000BB">$secondsDiff</font><font color="#007700">/</font><font color="#0000BB">60</font><font color="#007700">/</font><font color="#0000BB">60</font><font color="#007700">/</font><font color="#0000BB">24</font><font color="#007700">);<br /></font><font color="#0000BB">$remainingHour&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">floor</font><font color="#007700">((</font><font color="#0000BB">$secondsDiff</font><font color="#007700">-(</font><font color="#0000BB">$remainingDay</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">24</font><font color="#007700">))/</font><font color="#0000BB">60</font><font color="#007700">/</font><font color="#0000BB">60</font><font color="#007700">);<br /></font><font color="#0000BB">$remainingMinutes&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">floor</font><font color="#007700">((</font><font color="#0000BB">$secondsDiff</font><font color="#007700">-(</font><font color="#0000BB">$remainingDay</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">24</font><font color="#007700">)-(</font><font color="#0000BB">$remainingHour</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">))/</font><font color="#0000BB">60</font><font color="#007700">);<br /></font><font color="#0000BB">$remainingSeconds&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">floor</font><font color="#007700">((</font><font color="#0000BB">$secondsDiff</font><font color="#007700">-(</font><font color="#0000BB">$remainingDay</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">24</font><font color="#007700">)-(</font><font color="#0000BB">$remainingHour</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">))-(</font><font color="#0000BB">$remainingMinutes</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">));<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div><b>Step 4.</b><br />
As last step we makes some formatting. In this case I will display the target date, the actual date and the remaining time. To make a nice formatting let's define a fomatting string for the date() function.<br />
<br />
<b>Synatx:</b><br />
string date ( string format [, int timestamp] )<br />
<br />
So the code which formats the output is the following:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 130px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF9900">//&nbsp;Define&nbsp;date&nbsp;format<br /></font><font color="#0000BB">$dateFormat&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">"Y-m-d&nbsp;H:i:s"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$targetDateDisplay&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">date</font><font color="#007700">(</font><font color="#0000BB">$dateFormat</font><font color="#007700">,</font><font color="#0000BB">$targetDate</font><font color="#007700">);<br /></font><font color="#0000BB">$actualDateDisplay&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">date</font><font color="#007700">(</font><font color="#0000BB">$dateFormat</font><font color="#007700">,</font><font color="#0000BB">$actualDate</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>And as result here is the complete PHP code:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 450px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF9900">//&nbsp;Define&nbsp;your&nbsp;target&nbsp;date&nbsp;here<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$targetYear&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">2007</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$targetMonth&nbsp;&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">9</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$targetDay&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">10</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$targetHour&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">12</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$targetMinute&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">00</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$targetSecond&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">00</font><font color="#007700">;<br /></font><font color="#FF9900">//&nbsp;End&nbsp;target&nbsp;date&nbsp;definition<br /><br /></font><font color="#0000BB">$targetDate&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mktime</font><font color="#007700">(</font><font color="#0000BB">$targetHour</font><font color="#007700">,</font><font color="#0000BB">$targetMinute</font><font color="#007700">,</font><font color="#0000BB">$targetSecond</font><font color="#007700">,</font><font color="#0000BB">$targetMonth</font><font color="#007700">,</font><font color="#0000BB">$targetDay</font><font color="#007700">,</font><font color="#0000BB">$targetYear</font><font color="#007700">);<br /></font><font color="#0000BB">$actualDate&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">time</font><font color="#007700">();<br /><br /></font><font color="#0000BB">$secondsDiff&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$targetDate&nbsp;</font><font color="#007700">-&nbsp;</font><font color="#0000BB">$actualDate</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$remainingDay&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">floor</font><font color="#007700">(</font><font color="#0000BB">$secondsDiff</font><font color="#007700">/</font><font color="#0000BB">60</font><font color="#007700">/</font><font color="#0000BB">60</font><font color="#007700">/</font><font color="#0000BB">24</font><font color="#007700">);<br /></font><font color="#0000BB">$remainingHour&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">floor</font><font color="#007700">((</font><font color="#0000BB">$secondsDiff</font><font color="#007700">-(</font><font color="#0000BB">$remainingDay</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">24</font><font color="#007700">))/</font><font color="#0000BB">60</font><font color="#007700">/</font><font color="#0000BB">60</font><font color="#007700">);<br /></font><font color="#0000BB">$remainingMinutes&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">floor</font><font color="#007700">((</font><font color="#0000BB">$secondsDiff</font><font color="#007700">-(</font><font color="#0000BB">$remainingDay</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">24</font><font color="#007700">)-(</font><font color="#0000BB">$remainingHour</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">))/</font><font color="#0000BB">60</font><font color="#007700">);<br /></font><font color="#0000BB">$remainingSeconds&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">floor</font><font color="#007700">((</font><font color="#0000BB">$secondsDiff</font><font color="#007700">-(</font><font color="#0000BB">$remainingDay</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">24</font><font color="#007700">)-(</font><font color="#0000BB">$remainingHour</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">))-(</font><font color="#0000BB">$remainingMinutes</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">));<br /><br /></font><font color="#FF9900">//&nbsp;Define&nbsp;date&nbsp;format<br /></font><font color="#0000BB">$dateFormat&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">"Y-m-d&nbsp;H:i:s"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$targetDateDisplay&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">date</font><font color="#007700">(</font><font color="#0000BB">$dateFormat</font><font color="#007700">,</font><font color="#0000BB">$targetDate</font><font color="#007700">);<br /></font><font color="#0000BB">$actualDateDisplay&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">date</font><font color="#007700">(</font><font color="#0000BB">$dateFormat</font><font color="#007700">,</font><font color="#0000BB">$actualDate</font><font color="#007700">);<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div><div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">HTML Code:</div>
	<pre class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 130px;
		text-align: left;
		overflow: auto"><span style="color:#000080">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color:#000080">&lt;html&gt;</span>
<span style="color:#000080">&lt;body&gt;</span>
 TARGET DATE : <span style="color:#000080">&lt;?php echo $targetDateDisplay; ?&gt;</span><span style="color:#000080">&lt;br/&gt;</span><span style="color:#000080">&lt;br/&gt;</span>
 ACTUAL DATE : <span style="color:#000080">&lt;?php echo $actualDateDisplay; ?&gt;</span><span style="color:#000080">&lt;br/&gt;</span><span style="color:#000080">&lt;br/&gt;</span>
 REMAINING   : <span style="color:#000080">&lt;?php echo &quot;$remainingDay days, $remainingHour hours, $remainingMinutes minutes, $remainingSeconds seconds&quot;;?&gt;</span>
<span style="color:#000080">&lt;/body&gt;</span></pre>
</div></div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=38</guid>
		</item>
		<item>
			<title>Image upload with MYSQL database</title>
			<link>http://www.poudo.com/blog.php?b=37</link>
			<pubDate>Sun, 21 Oct 2007 12:24:44 GMT</pubDate>
			<description>In this tutorial is presented a simple code with informations about programing a script that uses MYSQL database to upload images. Very simple to...</description>
			<content:encoded><![CDATA[<div>In this tutorial is presented a simple code with informations about programing a script that uses MYSQL database to upload images. Very simple to interpretate, to code and to test, its a simple way to learn how to program a upload script that select images from the MYSQL database using php programing. Image upload with MYSQL databaseThere will be 3 PHP files in this tutorial: readdir.php - this puts all the images in a folder into the database image.php - the actual image script that displays the imag view.php - an example file that shows you how to call the imageCreating the Image DatabaseFirst, create a mysql database called base64imgdb (this is the name that will be used throughout the tutorial)Second, create a table called images with two rows. Name the first one imgid, and give it the parameters TYPE: INT EXTRA: auto_increment, and check the circle under Primary. Name the second sixfourdata, and make it TYPE: LONGTEXT. Here is the sql code:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<pre class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 98px;
		text-align: left;
		overflow: auto">CREATE TABLE `images` (
`imgid` INT NOT NULL AUTO_INCREMENT ,
`sixfourdata` LONGTEXT NOT NULL ,
PRIMARY KEY ( `imgid` )
);</pre>
</div>The READDIR.PHP script<br />
This script reads a directory within the server, selects all the jpg and gif images, encodes them into base64, and uploads them to the database, except in a different order. This is because the script reads each image in a loop, and we would like to keep a constant connection to the mysql database instead of creating multiple ones. Here is the database connection where: username and password<br />
<br />
is the directory the readdir.php file is located:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 50px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$path&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">"./"</font><font color="#007700">;<br /></font><font color="#0000BB">$dir_handle&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">opendir</font><font color="#007700">(</font><font color="#0000BB">$path</font><font color="#007700">)&nbsp;or&nbsp;die(</font><font color="#DD0000">"Unable&nbsp;to&nbsp;open&nbsp;directory&nbsp;$path"</font><font color="#007700">);&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div><div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 226px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?<br /></font><font color="#007700">while&nbsp;(</font><font color="#0000BB">$file&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">readdir</font><font color="#007700">(</font><font color="#0000BB">$dir_handle</font><font color="#007700">))&nbsp;{<br /></font><font color="#0000BB">$filetyp&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">substr</font><font color="#007700">(</font><font color="#0000BB">$file</font><font color="#007700">,&nbsp;-</font><font color="#0000BB">3</font><font color="#007700">);<br />if&nbsp;(</font><font color="#0000BB">$filetyp&nbsp;</font><font color="#007700">==&nbsp;</font><font color="#DD0000">'gif'&nbsp;</font><font color="#007700">OR&nbsp;</font><font color="#0000BB">$filetyp&nbsp;</font><font color="#007700">==&nbsp;</font><font color="#DD0000">'jpg'</font><font color="#007700">)&nbsp;{<br /></font><font color="#0000BB">$handle&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#0000BB">$path&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#DD0000">"/"&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#0000BB">$file</font><font color="#007700">,</font><font color="#DD0000">'r'</font><font color="#007700">);<br /></font><font color="#0000BB">$file_content&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fread</font><font color="#007700">(</font><font color="#0000BB">$handle</font><font color="#007700">,</font><font color="#0000BB">filesize</font><font color="#007700">(</font><font color="#0000BB">$path&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#DD0000">"/"&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#0000BB">$file</font><font color="#007700">));<br /></font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$handle</font><font color="#007700">);<br /></font><font color="#0000BB">$encoded&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">chunk_split</font><font color="#007700">(</font><font color="#0000BB">base64_encode</font><font color="#007700">(</font><font color="#0000BB">$file_content</font><font color="#007700">));<br /></font><font color="#0000BB">$sql&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">"INSERT&nbsp;INTO&nbsp;images&nbsp;SET&nbsp;sixfourdata='$encoded'"</font><font color="#007700">;<br /></font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#0000BB">$sql</font><font color="#007700">);<br />}<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>This is the last and final part of the readdir.php: closing the directory and stating the proccess is complete:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 98px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?<br />closedir</font><font color="#007700">(</font><font color="#0000BB">$dir_handle</font><font color="#007700">);<br />echo(</font><font color="#DD0000">"complete"</font><font color="#007700">);<br /></font><font color="#0000BB">mysql_close</font><font color="#007700">(</font><font color="#0000BB">$dbcnx</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div><b>The Image Reader IMAGE.PHP<br />
This file may be the hardest file to understand whenever you see how simple view.php is, but bear with me, your patience will pay off. This file takes a request, requests the row in the table, decodes the data, and presents itself as an image. First, we have to connect to the database again:</b><br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 50px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">$dbcnx&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_connect</font><font color="#007700">(</font><font color="#DD0000">"localhost"</font><font color="#007700">,&nbsp;</font><font color="#DD0000">"username"</font><font color="#007700">,&nbsp;</font><font color="#DD0000">"password"</font><font color="#007700">);<br /></font><font color="#0000BB">mysql_select_db</font><font color="#007700">(</font><font color="#DD0000">"base64imgdb"</font><font color="#007700">);&nbsp;<br /></font><font color="#0000BB"></font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div><b><br />
After this, we need to connect to the table, get the data, and set it into variables:</b><br />
<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 210px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?<br />&nbsp;&nbsp;&nbsp;&nbsp;$result&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#DD0000">"SELECT&nbsp;*&nbsp;FROM&nbsp;images&nbsp;WHERE&nbsp;imgid="&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#0000BB">$img&nbsp;</font><font color="#007700">.<br /></font><font color="#DD0000">""</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</font><font color="#0000BB">$result</font><font color="#007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo(</font><font color="#DD0000">"&lt;b&gt;Error&nbsp;performing&nbsp;query:&nbsp;"&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#0000BB">mysql_error</font><font color="#007700">()&nbsp;.&nbsp;</font><font color="#DD0000">"&lt;/b&gt;"</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(</font><font color="#0000BB">$row&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_fetch_array</font><font color="#007700">(</font><font color="#0000BB">$result</font><font color="#007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$imgid&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$row</font><font color="#007700">&#91;</font><font color="#DD0000">"imgid"</font><font color="#007700">&#93;;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$encodeddata&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$row</font><font color="#007700">&#91;</font><font color="#DD0000">"sixfourdata"</font><font color="#007700">&#93;;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>Now here is the last and most confusing part of the file:<br />
[/php]<br />
mysql_close($dbcnx);<br />
echo base64_decode($encodeddata);<br />
?&gt;<br />
<br />
The files:<br />
readdir.php:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 402px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?<br /></font><font color="#FF9900">###############################<br />#&nbsp;DB&nbsp;CONNECTION<br />#&nbsp;CHANGE&nbsp;THESE&nbsp;VALUES<br />###############################<br /></font><font color="#0000BB">$dbcnx&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_connect</font><font color="#007700">(</font><font color="#DD0000">"localhost"</font><font color="#007700">,&nbsp;</font><font color="#DD0000">"username"</font><font color="#007700">,&nbsp;</font><font color="#DD0000">"password"</font><font color="#007700">);<br /></font><font color="#0000BB">mysql_select_db</font><font color="#007700">(</font><font color="#DD0000">"base64imgdb"</font><font color="#007700">);<br /></font><font color="#0000BB">$path&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">"./"</font><font color="#007700">;<br /></font><font color="#0000BB">$dir_handle&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">opendir</font><font color="#007700">(</font><font color="#0000BB">$path</font><font color="#007700">)&nbsp;or&nbsp;die(</font><font color="#DD0000">"Unable&nbsp;to&nbsp;open&nbsp;directory&nbsp;$path"</font><font color="#007700">);<br />while&nbsp;(</font><font color="#0000BB">$file&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">readdir</font><font color="#007700">(</font><font color="#0000BB">$dir_handle</font><font color="#007700">))&nbsp;{<br /></font><font color="#0000BB">$filetyp&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">substr</font><font color="#007700">(</font><font color="#0000BB">$file</font><font color="#007700">,&nbsp;-</font><font color="#0000BB">3</font><font color="#007700">);<br />if&nbsp;(</font><font color="#0000BB">$filetyp&nbsp;</font><font color="#007700">==&nbsp;</font><font color="#DD0000">'gif'&nbsp;</font><font color="#007700">OR&nbsp;</font><font color="#0000BB">$filetyp&nbsp;</font><font color="#007700">==&nbsp;</font><font color="#DD0000">'jpg'</font><font color="#007700">)&nbsp;{<br /></font><font color="#0000BB">$handle&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#0000BB">$file</font><font color="#007700">,</font><font color="#DD0000">'r'</font><font color="#007700">);<br /></font><font color="#0000BB">$file_content&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">fread</font><font color="#007700">(</font><font color="#0000BB">$handle</font><font color="#007700">,</font><font color="#0000BB">filesize</font><font color="#007700">(</font><font color="#0000BB">$file</font><font color="#007700">));<br /></font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$handle</font><font color="#007700">);<br /></font><font color="#0000BB">$encoded&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">chunk_split</font><font color="#007700">(</font><font color="#0000BB">base64_encode</font><font color="#007700">(</font><font color="#0000BB">$file_content</font><font color="#007700">));<br /></font><font color="#0000BB">$sql&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">"INSERT&nbsp;INTO&nbsp;images&nbsp;SET&nbsp;sixfourdata='$encoded'"</font><font color="#007700">;<br /></font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#0000BB">$sql</font><font color="#007700">);<br />}<br />}<br /></font><font color="#0000BB">closedir</font><font color="#007700">(</font><font color="#0000BB">$dir_handle</font><font color="#007700">);<br />echo(</font><font color="#DD0000">"complete"</font><font color="#007700">);<br /></font><font color="#0000BB">mysql_close</font><font color="#007700">(</font><font color="#0000BB">$dbcnx</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div>image.php:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
	<div class="alt2" dir="ltr" style="
		margin: 0px;
		padding: 6px;
		border: 1px inset;
		width: 640px;
		height: 498px;
		text-align: left;
		overflow: auto">
		<code style="white-space:nowrap">
			<!-- php buffer start --><code><font color="#000000">
<font color="#0000BB">&lt;?<br />$dbcnx&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_connect</font><font color="#007700">(</font><font color="#DD0000">"localhost"</font><font color="#007700">,&nbsp;</font><font color="#DD0000">"username"</font><font color="#007700">,&nbsp;</font><font color="#DD0000">"password"</font><font color="#007700">);&nbsp;<br /></font><font color="#0000BB">mysql_select_db</font><font color="#007700">(</font><font color="#DD0000">"base64imgdb"</font><font color="#007700">);<br /></font><font color="#0000BB">$img&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$_REQUEST</font><font color="#007700">&#91;</font><font color="#DD0000">"img"</font><font color="#007700">&#93;;<br /></font><font color="#0000BB">$result&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#DD0000">"SELECT&nbsp;*&nbsp;FROM&nbsp;images&nbsp;WHERE&nbsp;imgid="&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#0000BB">$img&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#DD0000">""</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</font><font color="#0000BB">$result</font><font color="#007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo(</font><font color="#DD0000">"&lt;b&gt;Error&nbsp;performing&nbsp;query:&nbsp;"&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#0000BB">mysql_error</font><font color="#007700">()&nbsp;.&nbsp;</font><font color="#DD0000">"&lt;/b&gt;"</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(</font><font color="#0000BB">$row&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_fetch_array</font><font color="#007700">(</font><font color="#0000BB">$result</font><font color="#007700">)&nbsp;)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$imgid&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$row</font><font color="#007700">&#91;</font><font color="#DD0000">"imgid"</font><font color="#007700">&#93;;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$encodeddata&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$row</font><font color="#007700">&#91;</font><font color="#DD0000">"sixfourdata"</font><font color="#007700">&#93;;&lt;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></font><font color="#0000BB">mysql_close</font><font color="#007700">(</font><font color="#0000BB">$dbcnx</font><font color="#007700">);<br />echo&nbsp;</font><font color="#0000BB">base64_decode</font><font color="#007700">(</font><font color="#0000BB">$encodeddata</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;<br />&lt;?<br />$dbcnx&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_connect</font><font color="#007700">(</font><font color="#DD0000">"localhost"</font><font color="#007700">,&nbsp;</font><font color="#DD0000">"username"</font><font color="#007700">,&nbsp;</font><font color="#DD0000">"password"</font><font color="#007700">);&nbsp;<br /></font><font color="#0000BB">mysql_select_db</font><font color="#007700">(</font><font color="#DD0000">"base64imgdb"</font><font color="#007700">);<br /></font><font color="#0000BB">$img&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$_REQUEST</font><font color="#007700">&#91;</font><font color="#DD0000">"img"</font><font color="#007700">&#93;;<br /></font><font color="#0000BB">$result&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#DD0000">"SELECT&nbsp;*&nbsp;FROM&nbsp;images&nbsp;WHERE&nbsp;imgid="&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#0000BB">$img&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#DD0000">""</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</font><font color="#0000BB">$result</font><font color="#007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo(</font><font color="#DD0000">"&lt;b&gt;Error&nbsp;performing&nbsp;query:&nbsp;"&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#0000BB">mysql_error</font><font color="#007700">()&nbsp;.&nbsp;</font><font color="#DD0000">"&lt;/b&gt;"</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(</font><font color="#0000BB">$row&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_fetch_array</font><font color="#007700">(</font><font color="#0000BB">$result</font><font color="#007700">)&nbsp;)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$imgid&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$row</font><font color="#007700">&#91;</font><font color="#DD0000">"imgid"</font><font color="#007700">&#93;;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$encodeddata&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$row</font><font color="#007700">&#91;</font><font color="#DD0000">"sixfourdata"</font><font color="#007700">&#93;;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></font><font color="#0000BB">mysql_close</font><font color="#007700">(</font><font color="#0000BB">$dbcnx</font><font color="#007700">);<br />echo&nbsp;</font><font color="#0000BB">base64_decode</font><font color="#007700">(</font><font color="#0000BB">$encodeddata</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code><!-- php buffer end -->
		</code>
	</div>
</div></div>

]]></content:encoded>
			<dc:creator>escapeboy</dc:creator>
			<guid isPermaLink="true">http://www.poudo.com/blog.php?b=37</guid>
		</item>
	</channel>
</rss>
