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

<channel>
	<title>Jotlab &#187; PHP</title>
	<atom:link href="http://www.jotlab.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jotlab.com</link>
	<description>Jotlab</description>
	<lastBuildDate>Tue, 24 Aug 2010 00:37:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Protecting Files Against Hotlinking with PHP, Lighttpd, Apache &amp; X-Sendfile</title>
		<link>http://www.jotlab.com/2010/08/11/protecting-files-against-hotlinking-with-php-lighttpd-apache-x-sendfile/</link>
		<comments>http://www.jotlab.com/2010/08/11/protecting-files-against-hotlinking-with-php-lighttpd-apache-x-sendfile/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 01:53:33 +0000</pubDate>
		<dc:creator>VoiDeT</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[hot]]></category>
		<category><![CDATA[hotlinking]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[linking]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://www.jotlab.com/?p=4528</guid>
		<description><![CDATA[I recently had to lock down some important files that first required some level of authentication. The problem was the only way to guard against hotlinking or direct access to these files was to pipe the data through php after an Auth check. Using fread,... <span><a href="http://www.jotlab.com/2010/08/11/protecting-files-against-hotlinking-with-php-lighttpd-apache-x-sendfile/" title="Protecting Files Against Hotlinking with PHP, Lighttpd, Apache &#038; X-Sendfile" rel="bookmark">[+]</a></span>]]></description>
			<content:encoded><![CDATA[<p>I recently had to lock down some important files that first required some level of authentication. The problem was the only way to guard against hotlinking or direct access to these files was to pipe the data through php after an Auth check. Using fread, readfile or file_get_contents produced extreme CPU usage, not really to my surprise. Usually I wouldn&#8217;t care about high CPU usage on smaller projects, however this was causing the webserver to become unresponsive as it had to fully parse the files.</p>
<p>I went searching and eventually came across a module for both Apache and Lighttpd called X-Sendfile. The module works by sending headers out to the webserver to simply output a static file, without touching PHP&#8217;s file handling functions. First we need to install the module before we can start sending headers out to the webserver.</p>
<h3>Apache:</h3>
<ol>
<li>Login as root or your administrator account</li>
<li>Download the following code to your server <a href="http://tn123.ath.cx/mod_xsendfile/mod_xsendfile.c">mod_xsendfile.c</a></li>
<li>Installing is simple with: sudo apxs -cia mod_xsendfile.c</li>
<li>You will now notice the messages on the screen stating it has been added to your Apache config file and copied to the apache modules directory</li>
<li>Restart Apache. Done <img src='http://www.jotlab.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<h3>Lighttpd</h3>
<p>Setting up X-Sendfile on Lighttpd is much simpler as the module is shipped with Lighttpd 1.4+. All we will need to do is add in the &#8220;allow-x-send-file&#8221; => &#8220;enable&#8221; setting to our fastcgi.server array:</p>
<pre class="brush: php; ">
fastcgi.server = ( &quot;.php&quot; =&gt;
  ( &quot;localhost&quot; =&gt;
    (&quot;socket&quot; =&gt; &quot;/opt/local/var/run/lighttpd/php-fastcgi.socket&quot;,
     &quot;allow-x-send-file&quot; =&gt; &quot;enable&quot;,
     .......etc
    )
  )
)
</pre>
<h3>PHP &#038; Lighttpd</h3>
<p>Next up we will handle some basic user authentication with PHP to show how you can protect your files with PHP:</p>
<pre class="brush: php; ">
&lt;?php

if (!empty($_SESSION[&#039;logged_in&#039;])) {
  header( &quot;Content-Disposition: attachment; filename=\&quot;The Name You Want Your Users To See.mp3\&quot;&quot;);
  header( &quot;X-LIGHTTPD-send-file: /full/path/to/your/file.mp3&quot;);
} else {
  echo &quot;Sorry, You&#039;re not on the list, You&#039;re not coming in!&quot;;
}

?&gt;
</pre>
<p>If you&#8217;re using Lighttpd version 1.5 then you can replace &#8220;X-LIGHTTPD-send-file&#8221; with &#8220;X-Sendfile&#8221;.</p>
<h3>PHP &#038; Apache</h3>
<p>Using X-Sendfile with Apache is very similar, however we need to turn X-Sendfile on. Either put &#8220;XSendFile On&#8221; in a .htaccess files where your script resides, or put this in your Apache config file. The php configuration is pretty much exactly like Lighttpd 1.5 handling:</p>
<pre class="brush: php; ">
&lt;?php

if (!empty($_SESSION[&#039;logged_in&#039;])) {
  header( &quot;Content-Disposition: attachment; filename=\&quot;The Name You Want Your Users To See.mp3\&quot;&quot;);
  header( &quot;X-Sendfile: /full/path/to/your/file.mp3&quot;);
} else {
  echo &quot;Sorry, You&#039;re not on the list, You&#039;re not coming in!&quot;;
}

?&gt;
</pre>
<p>Feel free to move your files outside of the root path of the webserver which will prevent hotlinking, or as always, &#8220;deny from all&#8221; will do the trick in a .htaccess file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jotlab.com/2010/08/11/protecting-files-against-hotlinking-with-php-lighttpd-apache-x-sendfile/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Picking up where strtotime() left off</title>
		<link>http://www.jotlab.com/2010/05/06/picking-up-where-strtotime-left-off/</link>
		<comments>http://www.jotlab.com/2010/05/06/picking-up-where-strtotime-left-off/#comments</comments>
		<pubDate>Thu, 06 May 2010 06:00:18 +0000</pubDate>
		<dc:creator>VoiDeT</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[dates]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[formatting]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[strtotime]]></category>

		<guid isPermaLink="false">http://www.jotlab.com/?p=4371</guid>
		<description><![CDATA[I was working on a project where dates were being calculated (sort of) based on user input. For example the user was able to type in &#8220;Next Saturday&#8221; or the &#8220;Second Sunday of the Month&#8221;. This wouldn&#8217;t really be sortable, as strtotime doesn&#8217;t exactly allow... <span><a href="http://www.jotlab.com/2010/05/06/picking-up-where-strtotime-left-off/" title="Picking up where strtotime() left off" rel="bookmark">[+]</a></span>]]></description>
			<content:encoded><![CDATA[<p>I was working on a project where dates were being calculated (sort of) based on user input. For example the user was able to type in &#8220;Next Saturday&#8221; or the &#8220;Second Sunday of the Month&#8221;. This wouldn&#8217;t really be sortable, as strtotime doesn&#8217;t exactly allow all of these inputs, and so the saga of extending the functionality to accomodate almost any user input (well what i found common use for this client anyway) began.</p>
<p>This function will spit out timestamps of the following dates for example:</p>
<p>Sat 5 &#8211; Sun 27 Jun 10<br />
Sun 6 Jun 2010<br />
Tue 29 Jun &#8211; Sat 3 Jul + Tue 6 Jul &#8211; Sat 10 Jul 2010<br />
Thu 29 Jul &#8211; Sat 31 Jul + Wed 4 Aug &#8211; Sat 7 Aug 2010<br />
Every Fri<br />
1st Sat of Every Month<br />
3rd Wed of Every Month</p>
<p>This was developed for a particular use case, so please, if you would like some other terms thrown in let me know and I might go ahead and build them in for future use.</p>
<pre class="brush: php; ">
function calculateStartDates($data) {
	foreach ($data as &amp;$event) {
		if (!empty($event[&#039;Event&#039;][&#039;time_period&#039;])) {
			$event[&#039;Event&#039;][&#039;start_timestamp&#039;] = $event[&#039;Event&#039;][&#039;time_period&#039;];
			preg_match(&#039;/(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i&#039;, $event[&#039;Event&#039;][&#039;start_timestamp&#039;], $months);
			preg_match(&#039;/(.*)every\s*(\w+)/i&#039;, $event[&#039;Event&#039;][&#039;start_timestamp&#039;], $every);
			$datePlurals = array(&#039;first&#039;, &#039;second&#039;, &#039;third&#039;, &#039;fourth&#039;, &#039;fifth&#039;, &#039;sixth&#039;, &#039;seventh&#039;, &#039;eigth&#039;, &#039;nineth&#039;);
			$fullDays = array(&#039;sat&#039; =&gt; &#039;Saturday&#039;, &#039;sun&#039; =&gt; &#039;Sunday&#039;, &#039;mon&#039; =&gt; &#039;Monday&#039;, &#039;tue&#039; =&gt; &#039;Tuesday&#039;, &#039;wed&#039; =&gt; &#039;Wednesday&#039;, &#039;thu&#039; =&gt; &#039;Thursday&#039;, &#039;fri&#039; =&gt; &#039;Friday&#039;);

			if (!empty($every[2])) {
				if (stristr($every[2], &#039;month&#039;)) {
					preg_match(&#039;/(mon|tue|wed|thur|fri|sat|sun)/i&#039;, $event[&#039;Event&#039;][&#039;start_timestamp&#039;], $day);
					preg_match_all(&#039;/(\d)(nd|st|th|rd)/i&#039;, $every[1], $times);
					if (!empty($times[1][0])) {
						$event[&#039;Event&#039;][&#039;start_timestamp&#039;] = date(&#039;d-m-Y&#039;, strtotime($datePlurals[$times[1][0]-1].&#039; &#039;.$fullDays[strtolower($day[1])]));
					}
				} else {
					$event[&#039;Event&#039;][&#039;start_timestamp&#039;] = date(&#039;d-m-Y&#039;, strtotime(&#039;next &#039;.$every[2]));
				}
			} else {
				$dashMatch = split(&#039;[-\+]&#039;, $event[&#039;Event&#039;][&#039;start_timestamp&#039;]);

				foreach ($dashMatch as $timeFrame) {
					preg_match(&#039;/(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i&#039;, $timeFrame, $thisMonth);

					if (!empty($months[1]) &amp;&amp; empty($thisMonth[1])) {
						if (!stristr($timeFrame, $months[1])) {
							$timeFrame = $timeFrame.&#039; &#039;.$months[1];
						}
					}
					$tempTime[] = strtotime($timeFrame);
				}

				sort($tempTime);
				unset($setTime, $tempTime);
				if (!empty($tempTime)) {
					foreach ($tempTime as $time) {
						if ($time &gt; mktime()) {
							$setTime = date(&#039;d-m-Y&#039;, $time);
							break;
						}
					}
				}

				if (!empty($timeFrame) &amp;&amp; empty($setTime)) {
					$event[&#039;Event&#039;][&#039;start_timestamp&#039;] = $timeFrame;
				} elseif (!empty($setTime)) {
					$event[&#039;Event&#039;][&#039;start_timestamp&#039;] = $setTime;
				}

			}
			$event[&#039;Event&#039;][&#039;start_timestamp&#039;] = strtotime($event[&#039;Event&#039;][&#039;start_timestamp&#039;]);
		}
	}
	return $data;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.jotlab.com/2010/05/06/picking-up-where-strtotime-left-off/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Downgrade PHP 5.3 Port to 5.2.10</title>
		<link>http://www.jotlab.com/2009/10/07/downgrade-php-5-3-port-to-5-2-10/</link>
		<comments>http://www.jotlab.com/2009/10/07/downgrade-php-5-3-port-to-5-2-10/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 04:11:32 +0000</pubDate>
		<dc:creator>VoiDeT</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jotlab.com/?p=4204</guid>
		<description><![CDATA[It&#8217;s pretty simple! Just make sure subversion client is installed and then checkout the php port file with the revision number of 53555 which is the latest for the 5.2.10: svn co -r 53555 http://svn.macports.org/repository/macports/trunk/dports/lang/php5 cd php5 sudo port install +fastcgi+mysql5+pear Or you can simply... <span><a href="http://www.jotlab.com/2009/10/07/downgrade-php-5-3-port-to-5-2-10/" title="Downgrade PHP 5.3 Port to 5.2.10" rel="bookmark">[+]</a></span>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s pretty simple!<br />
Just make sure subversion client is installed and then checkout the php port file with the revision number of 53555 which is the latest for the 5.2.10:</p>
<pre class="brush: bash; ">
svn co -r 53555 http://svn.macports.org/repository/macports/trunk/dports/lang/php5
cd php5
sudo port install +fastcgi+mysql5+pear
</pre>
<p>Or you can simply use the branch of PHP 5.2 via:</p>
<pre class="brush: bash; ">
sudo port install php52 +fastcgi+mysql5+pear
</pre>
<p>Happy porting!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jotlab.com/2009/10/07/downgrade-php-5-3-port-to-5-2-10/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ultimate Guestbook Tutorial: How to build a Guestbook with a honeypot, error checking, IP banning, pagination, e-mail notification and smilies with PHP and mySQL</title>
		<link>http://www.jotlab.com/2008/04/26/ultimate-guestbook-tutorial-how-to-build-a-guestbook-with-a-honeypot-error-checking-ip-banning-pagination-e-mail-notification-and-smilies-with-php-and-mysql/</link>
		<comments>http://www.jotlab.com/2008/04/26/ultimate-guestbook-tutorial-how-to-build-a-guestbook-with-a-honeypot-error-checking-ip-banning-pagination-e-mail-notification-and-smilies-with-php-and-mysql/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 11:52:12 +0000</pubDate>
		<dc:creator>VoiDeT</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[guestbook]]></category>
		<category><![CDATA[honey]]></category>
		<category><![CDATA[honeypot]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[pot]]></category>
		<category><![CDATA[smilies]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.jotlab.com/?p=1381</guid>
		<description><![CDATA[In this tutorial i will teach you how to make a guestbook script with PHP and mySQL. Guestbooks are very common today on the internet and are great for getting user feedback or a simple hello from your site fan&#8217;s. This tutorial will feature form... <span><a href="http://www.jotlab.com/2008/04/26/ultimate-guestbook-tutorial-how-to-build-a-guestbook-with-a-honeypot-error-checking-ip-banning-pagination-e-mail-notification-and-smilies-with-php-and-mysql/" title="Ultimate Guestbook Tutorial: How to build a Guestbook with a honeypot, error checking, IP banning, pagination, e-mail notification and smilies with PHP and mySQL" rel="bookmark">[+]</a></span>]]></description>
			<content:encoded><![CDATA[<p>In this tutorial i will teach you how to make a guestbook script with PHP and mySQL. Guestbooks are very common today on the internet and are great for getting user feedback or a simple hello from your site fan&#8217;s. This tutorial will feature form submission techniques, user input error handling, smilies, honeypot traps, and pagination. The final version of this script can be downloaded below, but i recommend that you follow the tutorial in its entirety so that you can program something similar yourself, or modify the script to suit your needs. </p>
<p>But first of all check out my site if you&#8217;re interested in custom decals! Designed by you made by us! <a href="https://www.wedecal.com/step1">www.wedecal.com</a>!</p>
<p>Source: <a href="http://www.jotlab.com/wp-content/uploads/2008/04/guestbook.zip">guestbook.zip</a><br />
Demo: <a href="http://www.jotlab.com/tutorials/guestbook/">http://www.jotlab.com/tutorials/guestbook/</a></p>
<div align="center"><img src="/wp-content/uploads/2008/04/guestbook.jpg" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.jotlab.com/2008/04/26/ultimate-guestbook-tutorial-how-to-build-a-guestbook-with-a-honeypot-error-checking-ip-banning-pagination-e-mail-notification-and-smilies-with-php-and-mysql/feed/</wfw:commentRss>
		<slash:comments>60</slash:comments>
		</item>
		<item>
		<title>Tutorial: How to build a poll system with PHP and mySQL</title>
		<link>http://www.jotlab.com/2008/04/11/tutorial-how-to-build-a-poll-system-in-php-and-mysql/</link>
		<comments>http://www.jotlab.com/2008/04/11/tutorial-how-to-build-a-poll-system-in-php-and-mysql/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 04:03:21 +0000</pubDate>
		<dc:creator>VoiDeT</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[how]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[poll]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[system]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.jotlab.com/?p=1018</guid>
		<description><![CDATA[If you have been doing the other tutorials on this site you will notice that I have been teaching PHP and mySQL through projects. Projects that you can slot into your website, or if you are building a project, code that you can use within... <span><a href="http://www.jotlab.com/2008/04/11/tutorial-how-to-build-a-poll-system-in-php-and-mysql/" title="Tutorial: How to build a poll system with PHP and mySQL" rel="bookmark">[+]</a></span>]]></description>
			<content:encoded><![CDATA[<p>If you have been doing the other tutorials on this site you will notice that I have been teaching PHP and mySQL through projects. Projects that you can slot into your website, or if you are building a project, code that you can use within your project. I start from the ground up, assuming you have no prior knowledge of the topic. So today, we will be building a Poll System using PHP and mySQL. Polls are great for getting user feedback from your site visitors.</p>
<p align="center"><img src="/wp-content/uploads/2008/04/poll2.jpg" alt="" /></p>
<p align="center"><img src="http://www.jotlab.com/wp-content/uploads/2008/04/poll.jpg" alt="" /></p>
<p>The poll system we will be using today will read and store from a mySQL database. mySQL is an extremely fast, efficient and stable database tool. Our poll system will read the questions stored in the database, then display the options to the users, then when a user selects an option and clicks submit, that selection will be stored in the database whereby results will be further calculated from this pool of results. The tutorial today will teach you PHP, not the database construction side of things. If you are interested in the mySQL side of it, just load up phpmyadmin and look at the database design I have made for the tutorial. I will however provide you with the database design which you can just import, which I will describe how to do. Anyway, lets get started.</p>
<p>But first of all check out my site if you&#8217;re interested in custom decals! Designed by you made by us! <a href="https://www.wedecal.com/step1">www.wedecal.com</a>!</p>
<p>Source: <a title="poll.zip" href="http://www.jotlab.com/wp-content/uploads/2008/04/poll.zip">poll.zip</a><br />
Demo: <a href="http://www.jotlab.com/tutorials/poll/index.php">http://www.jotlab.com/tutorials/poll/index.php</a><br />
<span id="more-1018"></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jotlab.com/2008/04/11/tutorial-how-to-build-a-poll-system-in-php-and-mysql/feed/</wfw:commentRss>
		<slash:comments>73</slash:comments>
		</item>
		<item>
		<title>HowTo: Get Cookies Across Subdomains PHP</title>
		<link>http://www.jotlab.com/2008/04/08/howto-get-cookies-across-subdomains-php/</link>
		<comments>http://www.jotlab.com/2008/04/08/howto-get-cookies-across-subdomains-php/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 08:48:07 +0000</pubDate>
		<dc:creator>VoiDeT</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jotlab.com/?p=725</guid>
		<description><![CDATA[So you are using cookies on your website, but when a visitor visits www.yourdomain.com and yourdomain.com the cookie doesn&#8217;t get set across both! That is because in essence, www. is simply a subdomain. The &#8220;www&#8221; component is not a protocol, it is not necessary, instead... <span><a href="http://www.jotlab.com/2008/04/08/howto-get-cookies-across-subdomains-php/" title="HowTo: Get Cookies Across Subdomains PHP" rel="bookmark">[+]</a></span>]]></description>
			<content:encoded><![CDATA[<p>So you are using cookies on your website, but when a visitor visits www.yourdomain.com and yourdomain.com the cookie doesn&#8217;t get set across both! That is because in essence, www. is simply a subdomain. The &#8220;www&#8221; component is not a protocol, it is not necessary, instead all it is, is just a marketing ploy. But anyway. Here is what you would do normally:</p>
<pre lang="php">setcookie('YourCookieName', 'Some Values', time() + 3600, '/', 'mydomain.com');</pre>
<p>Damn! Almost there! The part you are missing to add a cookie irrespective of the subdomain is &#8220;.mydomain.com&#8221;. Yep, just add a . infront of your domain name. So you would have:</p>
<pre lang="php">setcookie('YourCookieName', 'Some Values', time() + 3600, '/', '.mydomain.com');</pre>
<p>All done ^^ Enjoy</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jotlab.com/2008/04/08/howto-get-cookies-across-subdomains-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tutorial: How to make an Image Upload and Thumbnailer Script with cURL</title>
		<link>http://www.jotlab.com/2008/04/08/tutorial-how-to-make-an-image-upload-and-thumbnailer-script-with-curl/</link>
		<comments>http://www.jotlab.com/2008/04/08/tutorial-how-to-make-an-image-upload-and-thumbnailer-script-with-curl/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 07:44:24 +0000</pubDate>
		<dc:creator>VoiDeT</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jotlab.com/?p=724</guid>
		<description><![CDATA[So you have completed the file upload tutorial. The tutorial has taught you how to upload an image using a form, and then it auto makes a thumbnail and shows it to you, nice. Now lets say you are on a public computer, and can&#8217;t... <span><a href="http://www.jotlab.com/2008/04/08/tutorial-how-to-make-an-image-upload-and-thumbnailer-script-with-curl/" title="Tutorial: How to make an Image Upload and Thumbnailer Script with cURL" rel="bookmark">[+]</a></span>]]></description>
			<content:encoded><![CDATA[<p>So you have completed the file upload tutorial. The tutorial has taught you how to upload an image using a form, and then it auto makes a thumbnail and shows it to you, nice. Now lets say you are on a public computer, and can&#8217;t save to the desktop or whatever. So you would like to upload a photo that is already on the internet, but thumbnail it to your webserver. We need to be able to allow our users the ability to submit a link to an image and work from there.</p>
<p>Take a look at the demo before jumping in:<br />
<a href="http://www.jotlab.com/tutorials/thumbtutorial/thumbcurl.php">Demo Here</a></p>
<p>What you will need is a decent webserver, PHP with cURL enabled (check in your phpinfo();) and time. Please note that within php you are unable to test for MIME types unless you brute force them, which is beyond the scope of this tutorial. You can however add extensions to PHP to enable access to the mime types of stored files on the server, please take a look <a href="http://www.jellyandcustard.com/2006/01/19/php-mime-types-and-fileinfo/">here</a> for more information. But for this tutorial we will examine the file extensions in the url and go from there.<br />
<span id="more-724"></span><br />
So you have completed the file upload tutorial. The tutorial has taught you how to upload an image using a form, and then it auto makes a thumbnail and shows it to you, nice. Now lets say you are on a public computer, and can&#8217;t save to the desktop or whatever. So you would like to upload a photo that is already on the internet, but thumbnail it to your webserver. We need to be able to allow our users the ability to submit a link to an image and work from there.</p>
<p>Take a look at the demo before jumping in:<br />
<a href="http://www.jotlab.com/tutorials/thumbtutorial/thumbcurl.php">Demo Here</a></p>
<p>What you will need is a decent webserver, PHP with cURL enabled (check in your phpinfo();) and time. Please note that within php you are unable to test for MIME types unless you brute force them, which is beyond the scope of this tutorial. You can however add extensions to PHP to enable access to the mime types of stored files on the server, please take a look <a href="http://www.jellyandcustard.com/2006/01/19/php-mime-types-and-fileinfo/">here</a> for more information. But for this tutorial we will examine the file extensions in the url and go from there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jotlab.com/2008/04/08/tutorial-how-to-make-an-image-upload-and-thumbnailer-script-with-curl/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Tutorial: How to make an Image Upload and Thumbnailer Script PHP</title>
		<link>http://www.jotlab.com/2008/04/08/tutorial-how-to-make-a-thumbnailer-script/</link>
		<comments>http://www.jotlab.com/2008/04/08/tutorial-how-to-make-a-thumbnailer-script/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 02:23:37 +0000</pubDate>
		<dc:creator>VoiDeT</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jotlab.com/?p=721</guid>
		<description><![CDATA[In this tutorial we will make a thumbnailing script using PHP. The script will allow your users to upload their images using a html form, and then be shown the thumbnail and a link to the file on completion. Also the user will be able... <span><a href="http://www.jotlab.com/2008/04/08/tutorial-how-to-make-a-thumbnailer-script/" title="Tutorial: How to make an Image Upload and Thumbnailer Script PHP" rel="bookmark">[+]</a></span>]]></description>
			<content:encoded><![CDATA[<p>In this tutorial we will make a thumbnailing script using PHP. The script will allow your users to upload their images using a html form, and then be shown the thumbnail and a link to the file on completion. Also the user will be able to specify a max height or width if they want to.</p>
<p>Demo: <a href="http://www.jotlab.com/tutorials/thumbtutorial/thumb.php">http://www.jotlab.com/tutorials/thumbtutorial/thumb.php</a></p>
<p>*Thats right you can host images on my website. But i have edited my code to make the maximum size no greater than 300 pixels*</p>
<p>So start off with. Make a directory on your webserver, call it whatever you want&#8230;.See if i care. Once you have done this make more folders in this folder you made called thumbs and tmp, chmod them both to 777. To chmod you go: right click chmod/properties/get info&#8230;. one of the three. This makes the directories writeable, readable and executable; so you can upload and mangle your files up. Next make a file in this new directory called thumb.php. This will be both our workhorse and our html displayer. So, we have done 3 steps. Congrats!</p>
<p>Now lets open up thumb.php and add in the HTML code. This sets us up with an interface for our users to upload their shiney images.</p>
<pre lang="html">
<form enctype="multipart/form-data" method="post">
	File:
<input name="srcimage" type="file" />
	Max Dimensions:
<input name="maxdimensions" type="text" /> (optional)
<input name="submit" type="submit" value="upload" />
</form>
</pre>
<p>So i will explain. Line one states that this is a form. It gives it a name, says that the data is to be communicated via the POST gateway and that the encoding type allows files. The other fields are the file, which accepts user input of files, max dimensions and a nice button to click to upload the information.</p>
<p>Next lets get onto some PHP stuff.<br />
<span id="more-721"></span><br />
In this tutorial we will make a thumbnailing script using PHP. The script will allow your users to upload their images using a html form, and then be shown the thumbnail and a link to the file on completion. Also the user will be able to specify a max height or width if they want to.</p>
<p>Demo: <a href="http://www.jotlab.com/thumbtutorial">http://www.jotlab.com/thumbtutorial</a></p>
<p>*Thats right you can host images on my website. But i have edited my code to make the maximum size no greater than 300 pixels*</p>
<p>So start off with. Make a directory on your webserver, call it whatever you want&#8230;.See if i care. Once you have done this make more folders in this folder you made called thumbs and tmp, chmod them both to 777. To chmod you go: right click chmod/properties/get info&#8230;. one of the three. This makes the directories writeable, readable and executable; so you can upload and mangle your files up. Next make a file in this new directory called thumb.php. This will be both our workhorse and our html displayer. So, we have done 3 steps. Congrats!</p>
<p>Now lets open up thumb.php and add in the HTML code. This sets us up with an interface for our users to upload their shiney images.</p>
<pre lang="html">
<form enctype="multipart/form-data" method="post">
	File:
<input name="srcimage" type="file" />
	Max Dimensions:
<input name="maxdimensions" type="text" /> (optional)
<input name="submit" type="submit" value="upload" />
</form>
</pre>
<p>So i will explain. Line one states that this is a form. It gives it a name, says that the data is to be communicated via the POST gateway and that the encoding type allows files. The other fields are the file, which accepts user input of files, max dimensions and a nice button to click to upload the information.</p>
<p>Next lets get onto some PHP stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jotlab.com/2008/04/08/tutorial-how-to-make-a-thumbnailer-script/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Howto: Get Number of Rows</title>
		<link>http://www.jotlab.com/2008/04/08/howto-get-number-of-rows/</link>
		<comments>http://www.jotlab.com/2008/04/08/howto-get-number-of-rows/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 02:07:39 +0000</pubDate>
		<dc:creator>VoiDeT</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jotlab.com/?p=720</guid>
		<description><![CDATA[If you have a MySQL table and you want to know how many records there are in this table you can run a query on the entire table for example: This will show you how many rows were supplied in that query. So if you... <span><a href="http://www.jotlab.com/2008/04/08/howto-get-number-of-rows/" title="Howto: Get Number of Rows" rel="bookmark">[+]</a></span>]]></description>
			<content:encoded><![CDATA[<p>If you have a MySQL table and you want to know how many records there are in this table you can run a query on the entire table for example:</p>
<pre lang="php"><?php

	//setup a query to select all items
	$query = mysql_query("SELECT * FROM `tablename`");

	//now use the magic row counter droid
	$rows = mysql_num_rows($query);

	echo $rows;
?></pre>
<p>This will show you how many rows were supplied in that query. So if you want to find out how many people are under 18 in your forums you could do something like this:</p>
<pre lang="php"><?php

	$timegap = time() - (18 * 365 * 24 * 60 * 60);
	$query = mysql_query("SELECT * FROM `tablename` WHERE `dob` < '".$timegap."'");
	$rows = mysql_num_rows($query);
	echo $rows;
?></pre>
<p>The time gap gets the time in seconds of 18 years, then subtracts it from the time now. Yay. so now you can limit access to minors :O</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jotlab.com/2008/04/08/howto-get-number-of-rows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial: Doing basic MySQL database stuff</title>
		<link>http://www.jotlab.com/2008/04/08/tutorial-doing-basic-mysql-database-stuff/</link>
		<comments>http://www.jotlab.com/2008/04/08/tutorial-doing-basic-mysql-database-stuff/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 00:22:13 +0000</pubDate>
		<dc:creator>VoiDeT</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jotlab.com/?p=388</guid>
		<description><![CDATA[This tutorial is quite easy. If you want to connect to a mysql database you can use something like this: $host = 'localhost'; $username = 'yourusername'; $password = 'yourpassword'; $databasename = 'yourdbname'; //don't edit this stuff okay? $connect = mysql_connect($host, $username, $password); $selectdb = mysql_select_db($databasename);... <span><a href="http://www.jotlab.com/2008/04/08/tutorial-doing-basic-mysql-database-stuff/" title="Tutorial: Doing basic MySQL database stuff" rel="bookmark">[+]</a></span>]]></description>
			<content:encoded><![CDATA[<p>This tutorial is quite easy. If you want to connect to a mysql database you can use something like this:</p>
<pre lang="php">$host = 'localhost';
$username = 'yourusername';
$password = 'yourpassword';
$databasename = 'yourdbname';

//don't edit this stuff okay?

$connect = mysql_connect($host, $username, $password);
$selectdb = mysql_select_db($databasename);

if($connect == true){
	echo 'Connected fine!';
} else {
	echo 'Bad Username or Password.....or host dummy!!!!';
}

if($selectdb == true){
	echo 'Connected to DB master <img src='http://www.jotlab.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ';
} else {
	echo 'Cant find that database....did we connect?';
}</pre>
<p>So this code basically connects to the database and says hi!<br />
More to come on DB Functions <img src='http://www.jotlab.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.jotlab.com/2008/04/08/tutorial-doing-basic-mysql-database-stuff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
