<?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>MaggsWeb:7 &#187; PHP</title>
	<atom:link href="http://www.maggsweb.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maggsweb.com</link>
	<description>www.maggsweb.com</description>
	<lastBuildDate>Sat, 21 Aug 2010 20:50:00 +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>Compressing CSS files &#8211; on the fly</title>
		<link>http://www.maggsweb.com/php/compressing-files-on-the-fly/</link>
		<comments>http://www.maggsweb.com/php/compressing-files-on-the-fly/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 07:30:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[compress]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=978</guid>
		<description><![CDATA[I hate compressing CSS files as they become totally unreadable for editing. I end up keeping 2 versions, compressed and uncompressed, etc.. But how about compressing all your CSS files into one file, &#8216;on-the-fly&#8217;. Now that has solved the problem. ?View Code PHP&#60;?php &#160; header&#40;'Content-type: text/css'&#41;; &#160; ob_start&#40;&#34;compress&#34;&#41;; &#160; function compress&#40;$buffer&#41; &#123; /* remove comments [...]]]></description>
			<content:encoded><![CDATA[<p>I hate compressing CSS files as they become totally unreadable for editing.  I end up keeping 2 versions, compressed and uncompressed, etc..   But how about compressing all your CSS files into one file, &#8216;on-the-fly&#8217;.  Now that has solved the problem.</p>
<p><span id="more-978"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p978code3'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9783"><td class="code" id="p978code3"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<a href="http://www.php.net/header" onclick="pageTracker._trackPageview('/outgoing/www.php.net/header?referer=');"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-type: text/css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<a href="http://www.php.net/ob_start" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ob_start?referer=');"><span style="color: #990000;">ob_start</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;compress&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> compress<span style="color: #009900;">&#40;</span><span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">/* remove comments */</span>
  <span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/preg_replace?referer=');"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!/\*[^*]*\*+([^/][^*]*\*+)*/!'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">/* remove tabs, spaces, newlines, etc. */</span>
  <span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/str_replace?referer=');"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array" onclick="pageTracker._trackPageview('/outgoing/www.php.net/array?referer=');"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'  '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'    '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'    '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$buffer</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* your css files */</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'master.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'typography.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'grid.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'print.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'handheld.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<a href="http://www.php.net/ob_end_flush" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ob_end_flush?referer=');"><span style="color: #990000;">ob_end_flush</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Use it like this :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p978code4'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9784"><td class="code" id="p978code4"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; href=&quot;style.php&quot; type=&quot;text/css&quot; media=&quot;all&quot;&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/compressing-files-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First date of the week</title>
		<link>http://www.maggsweb.com/php/first-date-of-the-week/</link>
		<comments>http://www.maggsweb.com/php/first-date-of-the-week/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 10:06:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=965</guid>
		<description><![CDATA[Just a little script I wrote to work out the date of the first day of the week. ?View Code PHP&#60;?php &#160; $yearNow = date&#40;'Y', $time&#41;; $monthNow = date&#40;'m', $time&#41;; $dayNow = date&#40;'d', $time&#41;; &#160; $first_day_of_week = 'Mon'; // Sat &#124; Sun &#124; Mon &#124; etc.. $day = $dayNow; // dont overwrite $dayNow! &#160; while [...]]]></description>
			<content:encoded><![CDATA[<p>Just a little script I wrote to work out the date of the first day of the week.<br />
<span id="more-965"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p965code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9656"><td class="code" id="p965code6"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$yearNow</span>  <span style="color: #339933;">=</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$monthNow</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dayNow</span>   <span style="color: #339933;">=</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$first_day_of_week</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Mon'</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Sat | Sun | Mon | etc..  </span>
<span style="color: #000088;">$day</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dayNow</span><span style="color: #339933;">;</span>               <span style="color: #666666; font-style: italic;">// dont overwrite $dayNow!</span>
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$weekday</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$first_day_of_week</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$weekday</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'D'</span><span style="color: #339933;">,</span><a href="http://www.php.net/mktime" onclick="pageTracker._trackPageview('/outgoing/www.php.net/mktime?referer=');"><span style="color: #990000;">mktime</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$monthNow</span><span style="color: #339933;">,</span><span style="color: #000088;">$day</span><span style="color: #339933;">,</span><span style="color: #000088;">$yearNow</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$weekday</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$first_day_of_week</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         <span style="color: #000088;">$first_date_of_week</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$day</span><span style="color: #339933;">;</span>
         <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span> 
     <span style="color: #000088;">$day</span><span style="color: #339933;">--;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;h2&gt;First date of week is &quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d'</span><span style="color: #339933;">,</span><a href="http://www.php.net/mktime" onclick="pageTracker._trackPageview('/outgoing/www.php.net/mktime?referer=');"><span style="color: #990000;">mktime</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$monthNow</span><span style="color: #339933;">,</span><span style="color: #000088;">$day</span><span style="color: #339933;">,</span><span style="color: #000088;">$yearNow</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/h2&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><em></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/first-date-of-the-week/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Classes &#8211; quick example</title>
		<link>http://www.maggsweb.com/uncategorized/php-classes-quick-example/</link>
		<comments>http://www.maggsweb.com/uncategorized/php-classes-quick-example/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 13:04:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=938</guid>
		<description><![CDATA[Taken from http://mypaaji.com/Index.php/php-quick-reference/ ?View Code PHP&#60;?php class ClassName&#40;&#41; // class definition &#123; public $var1; // property with public access private $var2; // property with private access &#160; // constructor method public function __construct&#40;&#41; &#123; // code to initialize object goes here &#125; &#160; // public method public function setFoo&#40;$value&#41; &#123; // properties and methods are [...]]]></description>
			<content:encoded><![CDATA[<hr />
Taken from <a href="http://mypaaji.com/Index.php/php-quick-reference/" onclick="pageTracker._trackPageview('/outgoing/mypaaji.com/Index.php/php-quick-reference/?referer=');">http://mypaaji.com/Index.php/php-quick-reference/</a></p>
<hr />
<span id="more-938"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p938code8'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9388"><td class="code" id="p938code8"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> ClassName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// class definition</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$var1</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// property with public access</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$var2</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// property with private access</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// constructor method</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// code to initialize object goes here</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// public method</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setFoo<span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// properties and methods are accessed inside the class</span>
		<span style="color: #666666; font-style: italic;">// using $this-&gt;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span> <span style="color: #004000;">var2</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// private method</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> bar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// more code goes here</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// destructor method</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __destruct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// clean up code goes here</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ClassName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// create a new instance of the object</span>
<span style="color: #000088;">$c</span><span style="color: #339933;">-&gt;</span> <span style="color: #004000;">var1</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">42</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// properties and methods are accessed using - &gt;</span>
<span style="color: #000088;">$c</span><span style="color: #339933;">-&gt;</span> <span style="color: #004000;">setFoo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Hello World'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/uncategorized/php-classes-quick-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Download and Upload Files Over FTP</title>
		<link>http://www.maggsweb.com/uncategorized/how-to-download-and-upload-files-over-ftp/</link>
		<comments>http://www.maggsweb.com/uncategorized/how-to-download-and-upload-files-over-ftp/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 12:55:34 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=934</guid>
		<description><![CDATA[Taken from http://mypaaji.com/Index.php/how-to-download-upload-transfer-files-over-ftp/ The below given listing illustrates the process. First, a connection to the FTP server is initialized with a call to ftp_connect(); this function returns a connection handle that is used in all subsequent calls. The ftp_login() function is then used to log in to the server, while the ftp_close() function is used [...]]]></description>
			<content:encoded><![CDATA[<hr />
Taken from <a href="http://mypaaji.com/Index.php/how-to-download-upload-transfer-files-over-ftp/" onclick="pageTracker._trackPageview('/outgoing/mypaaji.com/Index.php/how-to-download-upload-transfer-files-over-ftp/?referer=');">http://mypaaji.com/Index.php/how-to-download-upload-transfer-files-over-ftp/</a></p>
<hr />
The below given listing illustrates the process. First, a connection to the FTP server is initialized with a call to ftp_connect();  this function returns a connection handle that is used in all subsequent calls. The ftp_login() function is then used to log in to the server, while the ftp_close()  function is used to terminate the connection and end the session. Between the calls to ftp_connect() and ftp_disconnect(), it is possible to perform all the actions commonly associated with an FTP session.</p>
<p>The below given listing illustrates four of the most common: listing files using ftp_nlist(); uploading files with ftp_put(); downloading files with ftp_get(); and deleting files with ftp_delete(). Note that ftp_put() and ftp_get() must be supplied with the remote and local file name, together with the transfer type (binary or ASCII).</p>
<p><span id="more-934"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p934code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p93410"><td class="code" id="p934code10"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// set access parameters</span>
<span style="color: #000088;">$host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ftp.domain.dom&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;user&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/htdocs&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// open connection to FTP server</span>
<span style="color: #000088;">$conn</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ftp_connect" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ftp_connect?referer=');"><span style="color: #990000;">ftp_connect</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$host</span><span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die" onclick="pageTracker._trackPageview('/outgoing/www.php.net/die?referer=');"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ERROR: Cannot connect&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// log in</span>
<a href="http://www.php.net/ftp_login" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ftp_login?referer=');"><span style="color: #990000;">ftp_login</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$conn</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pass</span><span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die" onclick="pageTracker._trackPageview('/outgoing/www.php.net/die?referer=');"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ERROR: Cannot log in&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// get file listing</span>
<span style="color: #000088;">$list</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ftp_nlist" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ftp_nlist?referer=');"><span style="color: #990000;">ftp_nlist</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$conn</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die" onclick="pageTracker._trackPageview('/outgoing/www.php.net/die?referer=');"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ERROR: Cannot list files&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$list</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$file</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Download a file</span>
<span style="color: #000088;">$remote</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;code.zip&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$local</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;code_sny.zip&quot;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/ftp_get" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ftp_get?referer=');"><span style="color: #990000;">ftp_get</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$conn</span><span style="color: #339933;">,</span> <span style="color: #000088;">$local</span><span style="color: #339933;">,</span> <span style="color: #000088;">$remote</span><span style="color: #339933;">,</span> FTP_BINARY<span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die" onclick="pageTracker._trackPageview('/outgoing/www.php.net/die?referer=');"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ERROR: Cannot download file: <span style="color: #006699; font-weight: bold;">$remote</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;File [<span style="color: #006699; font-weight: bold;">$remote</span>] successfully downloaded as [<span style="color: #006699; font-weight: bold;">$local</span>]&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Upload a file</span>
<span style="color: #000088;">$local</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;photoSny.jpg&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$remote</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;photoSny.jpg&quot;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/ftp_put" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ftp_put?referer=');"><span style="color: #990000;">ftp_put</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$conn</span><span style="color: #339933;">,</span> <span style="color: #000088;">$remote</span><span style="color: #339933;">,</span> <span style="color: #000088;">$local</span><span style="color: #339933;">,</span> FTP_BINARY<span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die" onclick="pageTracker._trackPageview('/outgoing/www.php.net/die?referer=');"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ERROR: Cannot upload file: <span style="color: #006699; font-weight: bold;">$local</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;File [<span style="color: #006699; font-weight: bold;">$local</span>] successfully uploaded as [<span style="color: #006699; font-weight: bold;">$remote</span>]&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Delete a file</span>
<span style="color: #000088;">$remote</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;someFile.tmp&quot;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/ftp_delete" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ftp_delete?referer=');"><span style="color: #990000;">ftp_delete</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$conn</span><span style="color: #339933;">,</span> <span style="color: #000088;">$remote</span><span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die" onclick="pageTracker._trackPageview('/outgoing/www.php.net/die?referer=');"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ERROR: Cannot delete file: <span style="color: #006699; font-weight: bold;">$remote</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;File [<span style="color: #006699; font-weight: bold;">$remote</span>] successfully deleted&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Disconnect</span>
<a href="http://www.php.net/ftp_close" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ftp_close?referer=');"><span style="color: #990000;">ftp_close</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/uncategorized/how-to-download-and-upload-files-over-ftp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Sessions&#8230;</title>
		<link>http://www.maggsweb.com/php/php-sessions/</link>
		<comments>http://www.maggsweb.com/php/php-sessions/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 07:38:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=915</guid>
		<description><![CDATA[Using $_SESSIONS&#8230; Forgot the syntax&#8230; Here-ya-go. Initialize Session This must be at the top of every page that will call/use a Session variable. php session_start(); Register (declare) a Session variable To add a Session variable that will be carried till the browser is closed or you kill it yourself. session_register(&#8220;mySessionVariable&#8221;); Assigning value to a Session [...]]]></description>
			<content:encoded><![CDATA[<p>Using $_SESSIONS&#8230;  Forgot the syntax&#8230;   Here-ya-go.<br />
<span id="more-915"></span><br />
<strong>Initialize Session</strong><br />
This must be at the top of every page that will call/use a Session variable.<br />
php session_start();</p>
<p><strong>Register (declare) a Session variable</strong><br />
To add a Session variable that will be carried till the browser is closed or you kill it yourself.<br />
session_register(&#8220;mySessionVariable&#8221;);</p>
<p><strong>Assigning value to a Session variable</strong><br />
Values added to a Session variable can be letters (ABCabc), numbers (1, 200, 999.99, etc.) making them good for usernames/userID&#8217;s when logged into a site.<br />
$_SESSION["mySessionVariable"] = &#8220;MEMBER&#8221;;</p>
<p><strong>Unregister a Session variable</strong><br />
Logging out requires we unregister any and all Session variables used for our application and the users&#8217; account.<br />
session_unregister(&#8220;mySessionVariable&#8221;);</p>
<p><strong>Destroy a Session</strong><br />
We should always destroy a Session to help complete a logout.<br />
session_destroy();</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/php-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a &#8216;slug&#8217;</title>
		<link>http://www.maggsweb.com/php/creating-a-slug/</link>
		<comments>http://www.maggsweb.com/php/creating-a-slug/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 07:34:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[slug]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=917</guid>
		<description><![CDATA[SEO is becoming more and more important, and URL&#8217;s need to be more visible. Here&#8217;s a function for creating a &#8216;slug&#8217; which I used as an add-on to a site, using the page title. ?View Code PHP&#60;?php function slug&#40;$str&#41;&#123; $str = strtolower&#40;trim&#40;$str&#41;&#41;; $str = preg_replace&#40;'/[^a-z0-9-]/', '-', $str&#41;; $str = preg_replace&#40;'/-+/', &#34;-&#34;, $str&#41;; return $str; &#125; [...]]]></description>
			<content:encoded><![CDATA[<p>SEO is becoming more and more important, and URL&#8217;s need to be more visible.  Here&#8217;s a function for creating a &#8216;slug&#8217; which I used as an add-on to a site, using the page title.<br />
<span id="more-917"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p917code12'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p91712"><td class="code" id="p917code12"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> slug<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strtolower" onclick="pageTracker._trackPageview('/outgoing/www.php.net/strtolower?referer=');"><span style="color: #990000;">strtolower</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/trim" onclick="pageTracker._trackPageview('/outgoing/www.php.net/trim?referer=');"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/preg_replace?referer=');"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/[^a-z0-9-]/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/preg_replace?referer=');"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/-+/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$str</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/creating-a-slug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MIME Types</title>
		<link>http://www.maggsweb.com/php/mime-types/</link>
		<comments>http://www.maggsweb.com/php/mime-types/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 13:13:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[mime_type]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=823</guid>
		<description><![CDATA[A full(-ish) list of MIME Types that may come in usefull for upload validatiuon. $mimes = array( &#8216;jpg&#124;jpeg&#124;jpe&#8217; => &#8216;image/jpeg&#8217;, &#8216;gif&#8217; => &#8216;image/gif&#8217;, &#8216;png&#8217; => &#8216;image/png&#8217;, &#8216;bmp&#8217; => &#8216;image/bmp&#8217;, &#8216;tif&#124;tiff&#8217; => &#8216;image/tiff&#8217;, &#8216;ico&#8217; => &#8216;image/x-icon&#8217;, &#8216;asf&#124;asx&#124;wax&#124;wmv&#124;wmx&#8217; => &#8216;video/asf&#8217;, &#8216;avi&#8217; => &#8216;video/avi&#8217;, &#8216;divx&#8217; => &#8216;video/divx&#8217;, &#8216;mov&#124;qt&#8217; => &#8216;video/quicktime&#8217;, &#8216;mpeg&#124;mpg&#124;mpe&#8217; => &#8216;video/mpeg&#8217;, &#8216;txt&#124;c&#124;cc&#124;h&#8217; => &#8216;text/plain&#8217;, &#8216;rtx&#8217; => [...]]]></description>
			<content:encoded><![CDATA[<p>A full(-ish) list of MIME Types that may come in usefull for upload validatiuon.<br />
<span id="more-823"></span><br />
$mimes = array(<br />
		&#8216;jpg|jpeg|jpe&#8217; => &#8216;image/jpeg&#8217;,<br />
		&#8216;gif&#8217; => &#8216;image/gif&#8217;,<br />
		&#8216;png&#8217; => &#8216;image/png&#8217;,<br />
		&#8216;bmp&#8217; => &#8216;image/bmp&#8217;,<br />
		&#8216;tif|tiff&#8217; => &#8216;image/tiff&#8217;,<br />
		&#8216;ico&#8217; => &#8216;image/x-icon&#8217;,<br />
		&#8216;asf|asx|wax|wmv|wmx&#8217; => &#8216;video/asf&#8217;,<br />
		&#8216;avi&#8217; => &#8216;video/avi&#8217;,<br />
		&#8216;divx&#8217; => &#8216;video/divx&#8217;,<br />
		&#8216;mov|qt&#8217; => &#8216;video/quicktime&#8217;,<br />
		&#8216;mpeg|mpg|mpe&#8217; => &#8216;video/mpeg&#8217;,<br />
		&#8216;txt|c|cc|h&#8217; => &#8216;text/plain&#8217;,<br />
		&#8216;rtx&#8217; => &#8216;text/richtext&#8217;,<br />
		&#8216;css&#8217; => &#8216;text/css&#8217;,<br />
		&#8216;htm|html&#8217; => &#8216;text/html&#8217;,<br />
		&#8216;mp3|m4a&#8217; => &#8216;audio/mpeg&#8217;,<br />
		&#8216;mp4|m4v&#8217; => &#8216;video/mp4&#8242;,<br />
		&#8216;ra|ram&#8217; => &#8216;audio/x-realaudio&#8217;,<br />
		&#8216;wav&#8217; => &#8216;audio/wav&#8217;,<br />
		&#8216;ogg&#8217; => &#8216;audio/ogg&#8217;,<br />
		&#8216;mid|midi&#8217; => &#8216;audio/midi&#8217;,<br />
		&#8216;wma&#8217; => &#8216;audio/wma&#8217;,<br />
		&#8216;rtf&#8217; => &#8216;application/rtf&#8217;,<br />
		&#8216;js&#8217; => &#8216;application/javascript&#8217;,<br />
		&#8216;pdf&#8217; => &#8216;application/pdf&#8217;,<br />
		&#8216;doc|docx&#8217; => &#8216;application/msword&#8217;,<br />
		&#8216;pot|pps|ppt|pptx&#8217; => &#8216;application/vnd.ms-powerpoint&#8217;,<br />
		&#8216;wri&#8217; => &#8216;application/vnd.ms-write&#8217;,<br />
		&#8216;xla|xls|xlsx|xlt|xlw&#8217; => &#8216;application/vnd.ms-excel&#8217;,<br />
		&#8216;mdb&#8217; => &#8216;application/vnd.ms-access&#8217;,<br />
		&#8216;mpp&#8217; => &#8216;application/vnd.ms-project&#8217;,<br />
		&#8216;swf&#8217; => &#8216;application/x-shockwave-flash&#8217;,<br />
		&#8216;class&#8217; => &#8216;application/java&#8217;,<br />
		&#8216;tar&#8217; => &#8216;application/x-tar&#8217;,<br />
		&#8216;zip&#8217; => &#8216;application/zip&#8217;,<br />
		&#8216;gz|gzip&#8217; => &#8216;application/x-gzip&#8217;,<br />
		&#8216;exe&#8217; => &#8216;application/x-msdownload&#8217;,<br />
		// openoffice formats<br />
		&#8216;odt&#8217; => &#8216;application/vnd.oasis.opendocument.text&#8217;,<br />
		&#8216;odp&#8217; => &#8216;application/vnd.oasis.opendocument.presentation&#8217;,<br />
		&#8216;ods&#8217; => &#8216;application/vnd.oasis.opendocument.spreadsheet&#8217;,<br />
		&#8216;odg&#8217; => &#8216;application/vnd.oasis.opendocument.graphics&#8217;,<br />
		&#8216;odc&#8217; => &#8216;application/vnd.oasis.opendocument.chart&#8217;,<br />
		&#8216;odb&#8217; => &#8216;application/vnd.oasis.opendocument.database&#8217;,<br />
		&#8216;odf&#8217; => &#8216;application/vnd.oasis.opendocument.formula&#8217;<br />
)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/mime-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manually setting register_globals</title>
		<link>http://www.maggsweb.com/php/manually-register-globals/</link>
		<comments>http://www.maggsweb.com/php/manually-register-globals/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 13:10:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[register_global]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=835</guid>
		<description><![CDATA[This value is generally set in the httpd.conf (server) file, which is generally not accessible to users on shared hosting packages. So, here are a few ways to get around this. In a &#8216;.htaccess&#8217; file, stored in web root: php_value register_globals on or in a &#8216;php.ini&#8217; file, also stored in the web root: register_globals = [...]]]></description>
			<content:encoded><![CDATA[<p>This value is generally set in the httpd.conf (server) file, which is generally not accessible to users on shared hosting packages.  So, here are a few ways to get around this.<br />
<span id="more-835"></span></p>
<p>In a &#8216;.htaccess&#8217; file, stored in web root:<br />
php_value register_globals on</p>
<p>or in a &#8216;php.ini&#8217; file, also stored in the web root:<br />
register_globals = on</p>
<p>More details on this and other override settings can be found in this excellent article: <a href='http://www.sitepoint.com/blogs/2010/03/04/how-to-override-php-configuration-settings/' target='_new' onclick="pageTracker._trackPageview('/outgoing/www.sitepoint.com/blogs/2010/03/04/how-to-override-php-configuration-settings/?referer=');">http://www.sitepoint.com/blogs/2010/03/04/how-to-override-php-configuration-settings/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/manually-register-globals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>English Ordinals for dates in PHP</title>
		<link>http://www.maggsweb.com/php/english_ordinals_for_dates/</link>
		<comments>http://www.maggsweb.com/php/english_ordinals_for_dates/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 08:07:20 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=396</guid>
		<description><![CDATA[Displaying the day-part of the date, followed by the month etc. just looks plain wrong and lazy &#8211; &#8217;20 September 2009&#8242;. &#8217;20th&#8217; would look much nicer and can be achieved without too much hard work. A simple function&#8230; ?View Code PHP&#160; &#60;?php function dispDay&#40;$i&#41; &#123; switch&#40; floor&#40;$i/10&#41; % 10 &#41; &#123; default: switch&#40; $i % [...]]]></description>
			<content:encoded><![CDATA[<p>Displaying the day-part of the date, followed by the month etc. just looks plain wrong and lazy &#8211; &#8217;20 September 2009&#8242;.   &#8217;20th&#8217; would look much nicer and can be achieved without too much hard work.  A simple function&#8230;<br />
<span id="more-396"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p396code14'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p39614"><td class="code" id="p396code14"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #000000; font-weight: bold;">function</span> dispDay<span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span> <a href="http://www.php.net/floor" onclick="pageTracker._trackPageview('/outgoing/www.php.net/floor?referer=');"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
                <span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> <span style="color: #000088;">$ordinal</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'st'</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">:</span> <span style="color: #000088;">$ordinal</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'nd'</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">:</span> <span style="color: #000088;">$ordinal</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'rd'</span><span style="color: #339933;">;</span>   
                <span style="color: #009900;">&#125;</span>
            <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> <span style="color: #000088;">$ordinal</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'th'</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;sup&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$ordinal</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/sup&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/english_ordinals_for_dates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Database backup</title>
		<link>http://www.maggsweb.com/php/mysql-database-backup/</link>
		<comments>http://www.maggsweb.com/php/mysql-database-backup/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 20:44:09 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://tech.maggsweb.co.uk/?p=298</guid>
		<description><![CDATA[Backing up a MySQL database using PHP. ?View Code PHP&#60;?php &#160; // Enter Database access details &#160; $host= 'dbxx.oneandone.co.uk'; $user= 'dbxxxxxx'; $pass= 'xxxxxxxx'; $db= 'dbxxxxxxx'; $filename= getenv&#40;'DOCUMENT_ROOT'&#41;.'/'.date&#40;'Y'&#41;.'-'.date&#40;'M'&#41;.'-'.date&#40;'D'&#41;; &#160; // Instructing the system to zip and store the database &#160; system&#40;sprintf&#40; 'mysqldump --opt -h%s -u%s -p%s %s &#124; gzip &#62; %s.sql.gz', $host, $user, $pass, $db, $filename [...]]]></description>
			<content:encoded><![CDATA[<p>Backing up a MySQL database using PHP.<br />
<span id="more-298"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p298code16'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p29816"><td class="code" id="p298code16"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Enter Database access details</span>
&nbsp;
  <span style="color: #000088;">$host</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">'dbxx.oneandone.co.uk'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$user</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">'dbxxxxxx'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$pass</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">'xxxxxxxx'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$db</span><span style="color: #339933;">=</span>   <span style="color: #0000ff;">'dbxxxxxxx'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$filename</span><span style="color: #339933;">=</span> <a href="http://www.php.net/getenv" onclick="pageTracker._trackPageview('/outgoing/www.php.net/getenv?referer=');"><span style="color: #990000;">getenv</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DOCUMENT_ROOT'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'M'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'D'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Instructing the system to zip and store the database</span>
&nbsp;
  <a href="http://www.php.net/system" onclick="pageTracker._trackPageview('/outgoing/www.php.net/system?referer=');"><span style="color: #990000;">system</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/sprintf" onclick="pageTracker._trackPageview('/outgoing/www.php.net/sprintf?referer=');"><span style="color: #990000;">sprintf</span></a><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'mysqldump --opt -h%s -u%s -p%s %s | gzip &gt; %s.sql.gz'</span><span style="color: #339933;">,</span>
    <span style="color: #000088;">$host</span><span style="color: #339933;">,</span>
    <span style="color: #000088;">$user</span><span style="color: #339933;">,</span>
    <span style="color: #000088;">$pass</span><span style="color: #339933;">,</span>
    <span style="color: #000088;">$db</span><span style="color: #339933;">,</span>
    <span style="color: #000088;">$filename</span>  
  <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'+DONE'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>I haven&#8217;t actually tried this one yet.  The one I use is similar and works with the &#8216;exec&#8217; command &#8211; so this one is a much better function.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/mysql-database-backup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
