<?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>GS Design &#187; php&amp;mysql 101</title>
	<atom:link href="http://www.gsdesign.ro/blog/category/programing/phpmysql-101/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gsdesign.ro/blog</link>
	<description>Just another developer blog</description>
	<lastBuildDate>Fri, 23 Jul 2010 07:33:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>determining the application root path and url in php</title>
		<link>http://www.gsdesign.ro/blog/determining-the-application-root-path-and-url-in-php/</link>
		<comments>http://www.gsdesign.ro/blog/determining-the-application-root-path-and-url-in-php/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 08:47:13 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Programing]]></category>
		<category><![CDATA[php&mysql 101]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[path]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=283</guid>
		<description><![CDATA[If you buid any web application you will eventually need to find a way to specify the application root path and URL. This is inevitable if you don't build your links in a relative way ( by unsing ./ and ../ combinations ), and also if you want to have a way of keeping things [...]]]></description>
			<content:encoded><![CDATA[<p>If you buid any web application you will eventually need to find a way to specify the application root path and URL. This is inevitable if you don't build your links in a relative way ( by unsing ./ and ../ combinations ), and also if you want to have a way of keeping things organized and working even if you move script to a new server or in a folder.</p>
<p>Well there are several ways you can do this. The first one would be to write them in a config file by hand, and edit them as you move the project.</p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showCodeTxt('php-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/define"><span style="color:#000066;">define</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'ROOT_PATH'</span>, <span style="color:#FF0000;">'/home/user/public_html/folder/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/define"><span style="color:#000066;">define</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'PROJECT_DIR'</span>, <span style="color:#FF0000;">'/folder/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/define"><span style="color:#000066;">define</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'BASE_URL'</span>, <span style="color:#FF0000;">'http://'</span> . <span style="color:#0000FF;">$_SERVER</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'HTTP_HOST'</span><span style="color:#006600; font-weight:bold;">&#93;</span> . PROJECT_DIR<span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>But even if that works well, it will give a bit of work when you move the application since you have to edit them by hand.<br />
So the next method would be to have them be generated automatically. The ROOT_PATH is relatively easy to determine . What i do is have a directory called config in wich i place my config files, in it i have one called main_config.php which includes the rest of the config files. One of them is called paths.php.<br />
Now to determine the root_path i use a function called <a href="http://php.net/dirname">dirname()</a> and the __FILE__ constant.</p>
<div class="igBar"><span id="lphp-5"><a href="#" onclick="javascript:showCodeTxt('php-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-5">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/define"><span style="color:#000066;">define</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'ROOT_PATH'</span>, <a href="http://www.php.net/dirname"><span style="color:#000066;">dirname</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/dirname"><span style="color:#000066;">dirname</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/define"><span style="color:#000066;">define</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'PROJECT_DIR'</span>, <span style="color:#FF0000;">'/folder/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/define"><span style="color:#000066;">define</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'BASE_URL'</span>, <span style="color:#FF0000;">'http://'</span> . <span style="color:#0000FF;">$_SERVER</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'HTTP_HOST'</span><span style="color:#006600; font-weight:bold;">&#93;</span> . PROJECT_DIR<span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now we have the root_path solved and base_url to some extend, but need to specify the project directory.<br />
We can solve that too automatically.</p>
<div class="igBar"><span id="lphp-6"><a href="#" onclick="javascript:showCodeTxt('php-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-6">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/define"><span style="color:#000066;">define</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'ROOT_PATH'</span>, <span style="color:#FF0000;">'/home/user/public_html/folder/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$projectDir</span> = <a href="http://www.php.net/implode"><span style="color:#000066;">implode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/'</span>, <a href="http://www.php.net/array_intersect"><span style="color:#000066;">array_intersect</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/explode"><span style="color:#000066;">explode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/'</span>, <span style="color:#0000FF;">$_SERVER</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"REQUEST_URI"</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <a href="http://www.php.net/explode"><span style="color:#000066;">explode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/'</span>, <a href="http://www.php.net/str_replace"><span style="color:#000066;">str_replace</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'<span style="color:#000099; font-weight:bold;">\\</span>'</span>, <span style="color:#FF0000;">'/'</span>, ROOT_PATH<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$projectDir</span><span style="color:#006600; font-weight:bold;">&#91;</span><a href="http://www.php.net/strlen"><span style="color:#000066;">strlen</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$projectDir</span><span style="color:#006600; font-weight:bold;">&#41;</span>-<span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span> != <span style="color:#FF0000;">'/'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$projectDir</span> .= <span style="color:#FF0000;">'/'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/define"><span style="color:#000066;">define</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'PROJECT_DIR'</span>, <span style="color:#0000FF;">$projectDir</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/define"><span style="color:#000066;">define</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'BASE_URL'</span>, <span style="color:#FF0000;">'http://'</span> . <span style="color:#0000FF;">$_SERVER</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'HTTP_HOST'</span><span style="color:#006600; font-weight:bold;">&#93;</span> . PROJECT_DIR<span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>What that code does is take the ROOT_PATH that we defined and the REQUEST_URI from the server global variable and do an intersection of them to determine the project dir.</p>
<p>Hope this small snippet helped you.<br />
Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/determining-the-application-root-path-and-url-in-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Connection Interrupted</title>
		<link>http://www.gsdesign.ro/blog/connection-interrupted/</link>
		<comments>http://www.gsdesign.ro/blog/connection-interrupted/#comments</comments>
		<pubDate>Sat, 15 Nov 2008 21:29:00 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Programing]]></category>
		<category><![CDATA[php&mysql 101]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[error]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=224</guid>
		<description><![CDATA[A few weeks ago as i was working on a project i got a message in firefox that said : Connection Interrupted The connection to the server was reset while the page was loading. The network link was interrupted while negotiating a connection. Please try again. I was a little puzzled since i never saw [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago as i was working on a project i got a message in firefox that said : </p>
<blockquote><p>
<strong>Connection Interrupted</strong><br />
The connection to the server was reset while the page was loading.<br />
The network link was interrupted while negotiating a connection. Please try again.
</p></blockquote>
<p>I was a little puzzled since i never saw this one before. So i did a little googling search and debugging i find out the cause <img src='http://www.gsdesign.ro/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>There was a <strong>infinite loop in my code.</strong> </p>
<p>I know silly me, but hope you manage to stumble upon this when you get in the same situation.<br />
cheers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/connection-interrupted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; convert Microsoft word doc to pdf</title>
		<link>http://www.gsdesign.ro/blog/php-convert-microsoft-word-doc-to-pdf/</link>
		<comments>http://www.gsdesign.ro/blog/php-convert-microsoft-word-doc-to-pdf/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 13:53:08 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Programing]]></category>
		<category><![CDATA[php&mysql 101]]></category>
		<category><![CDATA[conververt]]></category>
		<category><![CDATA[doc]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=188</guid>
		<description><![CDATA[A lot of people are searching for solution to do this conversion on the fly. I dont know any other programing languages except PHP so i will write only about how you can do this in PHP. Now to do this there is 2 major situations: 1. Doing it on a windows Server 2. Doing [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of people are searching for solution to do this conversion on the fly. I dont know any other programing languages except PHP so i will write only about how you can do this in PHP.</p>
<p>Now to do this there is 2 major situations:<br />
1. Doing it on a windows Server<br />
2. Doing it on a linux Server</p>
<p>In both cases the chanses are that you need to have root access to the server in order to do all the settings required for this conversion. </p>
<p>In case of windows you can use COM objects to acces either Word or OpenOffice and do the conversion. Here peek of a code to access OpenOffice API to do the conversion:</p>
<div class="igBar"><span id="lphp-8"><a href="#" onclick="javascript:showCodeTxt('php-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-8">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/set_time_limit"><span style="color:#000066;">set_time_limit</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> MakePropertyValue<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$name</span>,<span style="color:#0000FF;">$value</span>,<span style="color:#0000FF;">$osm</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$oStruct</span> = <span style="color:#0000FF;">$osm</span>-&gt;<span style="color:#006600;">Bridge_GetStruct</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"com.sun.star.beans.PropertyValue"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$oStruct</span>-&gt;<span style="color:#006600;">Name</span> = <span style="color:#0000FF;">$name</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$oStruct</span>-&gt;<span style="color:#006600;">Value</span> = <span style="color:#0000FF;">$value</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">return</span> <span style="color:#0000FF;">$oStruct</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> word2pdf<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$doc_url</span>, <span style="color:#0000FF;">$output_url</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Invoke the OpenOffice.org service manager</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$osm</span> = <span style="color:#000000; font-weight:bold;">new</span> COM<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"com.sun.star.ServiceManager"</span><span style="color:#006600; font-weight:bold;">&#41;</span> or <a href="http://www.php.net/die"><span style="color:#000066;">die</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Please be sure that OpenOffice.org is installed.<span style="color:#000099; font-weight:bold;">\n</span>"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Set the application to remain hidden to avoid flashing the document onscreen</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$args</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span>MakePropertyValue<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Hidden"</span>,<span style="color:#000000; font-weight:bold;">true</span>,<span style="color:#0000FF;">$osm</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Launch the desktop</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$oDesktop</span> = <span style="color:#0000FF;">$osm</span>-&gt;<span style="color:#006600;">createInstance</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"com.sun.star.frame.Desktop"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Load the .doc file, and pass in the &quot;Hidden&quot; property from above</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$oWriterDoc</span> = <span style="color:#0000FF;">$oDesktop</span>-&gt;<span style="color:#006600;">loadComponentFromURL</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$doc_url</span>,<span style="color:#FF0000;">"_blank"</span>, <span style="color:#CC66CC;color:#800000;">0</span>, <span style="color:#0000FF;">$args</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Set up the arguments for the PDF output</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$export_args</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span>MakePropertyValue<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"FilterName"</span>,<span style="color:#FF0000;">"writer_pdf_Export"</span>,<span style="color:#0000FF;">$osm</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Write out the PDF</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$oWriterDoc</span>-&gt;<span style="color:#006600;">storeToURL</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$output_url</span>,<span style="color:#0000FF;">$export_args</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$oWriterDoc</span>-&gt;<span style="color:#006600;">close</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$output_dir</span> = <span style="color:#FF0000;">"C:/dev/openofficeintegration/docconverter/"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$doc_file</span> = <span style="color:#FF0000;">"C:/dev/openofficeintegration/docconverter/DpmR5Reqv1.20.doc"</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$pdf_file</span> = <span style="color:#FF0000;">"DpmR5Reqv1.20.pdf"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$output_file</span> = <span style="color:#0000FF;">$output_dir</span> . <span style="color:#0000FF;">$pdf_file</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$doc_file</span> = <span style="color:#FF0000;">"file:///"</span> . <span style="color:#0000FF;">$doc_file</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$output_file</span> = <span style="color:#FF0000;">"file:///"</span> . <span style="color:#0000FF;">$output_file</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">word2pdf<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$doc_file</span>,<span style="color:#0000FF;">$output_file</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now in case of linux things get a little more tricky, not by much but they do. You cant user COM objects any more but you can still install OpenOffice and its API in extension with a <a href="http://www.artofsolving.com/opensource/pyodconverter">python script</a>. </p>
<blockquote><p>
PyODConverter, for Python OpenDocument Converter, is a Python script that automates office document conversions from the command line using OpenOffice.org.</p>
<p>The script does basically the same thing as the command line tool that comes with JODConverter but is much simpler. In fact the Python script was released for the people who use JODConverter only from the command line (not as a Java library or web service) and would like a simpler alternative.
</p></blockquote>
<p>To check out the full documentation and download the script go <a href="http://www.artofsolving.com/opensource/pyodconverter">here</a>.</p>
<h3>Covertor for php5</h3>
<p>As i was doing research to do this post i found out of yet another solution, but this is only available for php5, but it works for both lynux and windows. Its a php module written in C++ called <a href="http://www.wstech2.net/index.php?do=puno">Punno</a>.</p>
<blockquote><p>
 This project is a PHP5 module written in C++ that brings the OpenOffice.org UNO Programming API to the PHP userspace.</p>
<p>You can use it to write scripts that create, modify, read and save OpenOffice.org documents (Writer, Spreadsheet, Drawing). Also, you can export these documents in various formats, like PDF or HTML for example.</p>
<p>It can be installed on any Linux/Unix or Windows platform where PHP5 and OpenOffice.org are also available.</p>
<p>It is released under PHP License 3.01.
</p></blockquote>
<p>That is it.</p>
<p>Do you know of any other solutions to do a <strong>doc to pdf conversion using php</strong> ?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/php-convert-microsoft-word-doc-to-pdf/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to protect your php applications for free ?</title>
		<link>http://www.gsdesign.ro/blog/how-to-protect-your-php-applications-for-free/</link>
		<comments>http://www.gsdesign.ro/blog/how-to-protect-your-php-applications-for-free/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 09:31:24 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Programing]]></category>
		<category><![CDATA[php&mysql 101]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[PADL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[protect]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=167</guid>
		<description><![CDATA[Did you developed a very cool application, and maybe thought about selling it ? If you did you might have thought: How will i protect my code ? Because the php code is visible and can be distributed really easy, once it has been downloaded once. Well there are solutions to do this, but most [...]]]></description>
			<content:encoded><![CDATA[<p>Did you developed a very cool application, and maybe thought about selling it ?<br />
If you did you might have thought: How will i protect my code ?<br />
Because the php code is visible and can be distributed really easy, once it has been downloaded once.</p>
<p>Well there are solutions to do this, but most of them are not free, and if your application is not a really expensive one it doesn't make sense to pay more on the software to protect the code then the actual selling price.</p>
<p>Well you are in luck, because there is a <a href="http://solomongaby.users.phpclasses.org/">php class</a> called <a href="http://solomongaby.users.phpclasses.org/browse/package/2298.html"><strong>PADL (PHP Application Distribution License System)</strong></a> that generates PHP application license keys.</p>
<blockquote><p>
This class can used to generate license style keys to control the distribution and functionality of PHP applications.</p>
<p>It generates license strings that can bind PHP applications to specific domains, specific servers, can only be executed during limited time period, or to restrictions placed on a home server within the license key.</p>
<p>The binding to server process attempts to use the server network card MAC address. This feature was tested on servers are Mac OS X (Darwin), Linux, Windows XP, although it may also work for FreeBSD, NetBSD, Solaris.</p>
<p>PADL also attempts to use information from $_SERVER variable to encode that server name, server IP, server application path and server application url to the license key. Part of the process also binds the IP Address from the $_SERVER variable if found, but it also attempts to parse the server config file (the same used to get the MAC address) for any more IPs.</p>
<p>The server binding can be disabled if required, and it also possible to block the key being generated for the localhost address (127.0.0.1).</p>
<p>The time limiting of the license uses a start period (and a given start offset to allow for time discrepancies) and an expiry date if required.</p>
<p>If required when validating a key it is also possible to dial home to check the license key on your own PADL License Server, examples are given.</p>
<p>The PHP_OS and PHP_VERSION of the php that the key was generated for is also encrypted into the key.</p>
<p>It is also possible to encrypt additional information into the license key to enable you to place restrictive features in your application to allow the creation of trialware or demoware.</p>
<p>This class is still in development however it is stable. A GUI is to follow.
</p></blockquote>
<p>This class received the Php Classes Innovation Award, and is ranked 98 in the same website, so this is why i highly recommend this class to protect your code.</p>
<p>Hope like this class as well,<br />
Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/how-to-protect-your-php-applications-for-free/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQL Query : Copy one Column to another column in MySQL</title>
		<link>http://www.gsdesign.ro/blog/sql-query-copy-one-column-to-another-column-in-mysql/</link>
		<comments>http://www.gsdesign.ro/blog/sql-query-copy-one-column-to-another-column-in-mysql/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 23:00:46 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Programing]]></category>
		<category><![CDATA[php&mysql 101]]></category>
		<category><![CDATA[column]]></category>
		<category><![CDATA[Copy]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=152</guid>
		<description><![CDATA[I wanted to do add a new column to a table and to copy the values from that a diferent to column ( from the same table ) to the new column. And even though i thought of very integrates query's at first, the solution was quite simple ( as always ). PLAIN TEXT SQL: [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to do add a new column to a table and to copy the values from that a diferent to column ( from the same table ) to the new column. And even though i thought of very integrates query's at first, the solution was quite simple <img src='http://www.gsdesign.ro/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  ( as always ).</p>
<div class="igBar"><span id="lsql-10"><a href="#" onclick="javascript:showCodeTxt('sql-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-10">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`table_name`</span> <span style="color: #993333; font-weight: bold;">ADD</span> <span style="color: #ff0000;">`new_column`</span> TEXT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #ff0000;">`table_name`</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #ff0000;">`new_column`</span> = <span style="color: #ff0000;">`old_column`</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Nice and simple.<br />
Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/sql-query-copy-one-column-to-another-column-in-mysql/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>how to: Generating XML from PHP</title>
		<link>http://www.gsdesign.ro/blog/how-to-generating-xml-from-php/</link>
		<comments>http://www.gsdesign.ro/blog/how-to-generating-xml-from-php/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 10:30:05 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Programing]]></category>
		<category><![CDATA[php&mysql 101]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[genarate]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=149</guid>
		<description><![CDATA[I had to do a small REST application on a project recently and i wanted to find a small easy way of returning the response in XML. After a little searching find this rather old post ( but just what i was looking for ) on Simon Willison’s Weblog. It featured a small php class [...]]]></description>
			<content:encoded><![CDATA[<p>I had to do a small REST application on a project recently and i wanted to find a small easy way of returning the response in XML.</p>
<p>After a little searching find this rather old post ( but just what i was looking for ) on Simon Willison’s Weblog. It featured a small php <a href="http://simonwillison.net/2003/Apr/29/xmlWriter/">class to generate XML</a>.</p>
<h3>Example Code</h3>
<div class="igBar"><span id="lphp-13"><a href="#" onclick="javascript:showCodeTxt('php-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-13">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$array</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'monkey'</span>, <span style="color:#FF0000;">'banana'</span>, <span style="color:#FF0000;">'Jim'</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'hamster'</span>, <span style="color:#FF0000;">'apples'</span>, <span style="color:#FF0000;">'Kola'</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'turtle'</span>, <span style="color:#FF0000;">'beans'</span>, <span style="color:#FF0000;">'Berty'</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$xml</span> = <span style="color:#000000; font-weight:bold;">new</span> XmlWriter<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$xml</span>-&gt;<span style="color:#006600;">push</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'zoo'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">foreach</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$array</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$animal</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$xml</span>-&gt;<span style="color:#006600;">push</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'animal'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'species'</span> =&gt; <span style="color:#0000FF;">$animal</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$xml</span>-&gt;<span style="color:#006600;">element</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'name'</span>, <span style="color:#0000FF;">$animal</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$xml</span>-&gt;<span style="color:#006600;">element</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'food'</span>, <span style="color:#0000FF;">$animal</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$xml</span>-&gt;<span style="color:#006600;">pop</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$xml</span>-&gt;<span style="color:#006600;">pop</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/print"><span style="color:#000066;">print</span></a> <span style="color:#0000FF;">$xml</span>-&gt;<span style="color:#006600;">getXml</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h3>XML returned</h3>
<div class="igBar"><span id="lxml-14"><a href="#" onclick="javascript:showCodeTxt('xml-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-14">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;</span>?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"1.0"</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">"utf-8"</span>?<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;zoo<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;animal</span> <span style="color: #000066;">species</span>=<span style="color: #ff0000;">"monkey"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;name<span style="font-weight: bold; color: black;">&gt;</span></span></span>Jim<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/name<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;food<span style="font-weight: bold; color: black;">&gt;</span></span></span>banana<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/food<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/animal<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;animal</span> <span style="color: #000066;">species</span>=<span style="color: #ff0000;">"hamster"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;name<span style="font-weight: bold; color: black;">&gt;</span></span></span>Kola<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/name<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;food<span style="font-weight: bold; color: black;">&gt;</span></span></span>apples<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/food<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/animal<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;animal</span> <span style="color: #000066;">species</span>=<span style="color: #ff0000;">"turtle"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;name<span style="font-weight: bold; color: black;">&gt;</span></span></span>Berty<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/name<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;food<span style="font-weight: bold; color: black;">&gt;</span></span></span>beans<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/food<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/animal<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/zoo<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h3>Attention</h3>
<p>A little heads up, if your running php you might encounter this error:</p>
<blockquote><p>
Fatal error: Cannot redeclare class xmlwriter in /var/www/web4/cgi-bin/includes/XmlWriter.class.inc on line 6
</p></blockquote>
<p>Thats because php already has a built in php class called xmlwriter, to fix it all you need to do is rename it.</p>
<p>hope this helps somebody.<br />
Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/how-to-generating-xml-from-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Find and Replace Text in MySQL Table using SQL</title>
		<link>http://www.gsdesign.ro/blog/find-and-replace-text-in-mysql/</link>
		<comments>http://www.gsdesign.ro/blog/find-and-replace-text-in-mysql/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 06:14:46 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Programing]]></category>
		<category><![CDATA[php&mysql 101]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=126</guid>
		<description><![CDATA[The database engine MySQL has a string function called REPLACE that performes similar to the php function str_replace(). This really comes in handy when you want a certain text replaced in a table data, either being a name or a certain uinique number or maybe some speling mistake. Syntax MySQL reference : REPLACE(str,from_str,to_str) Returns the [...]]]></description>
			<content:encoded><![CDATA[<p>The database engine MySQL has a string function called REPLACE that performes similar to the php function str_replace(). This really comes in handy when you want a certain text replaced in a table data, either being a name or a certain uinique number or maybe some speling mistake.</p>
<h3>Syntax</h3>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace">MySQL reference</a> :</p>
<blockquote><p>REPLACE(str,from_str,to_str)</p>
<p>Returns the string str with all occurrences of the string from_str replaced by the string to_str. REPLACE() performs a case-sensitive match when searching for from_str.</p>
<p>This function is multi-byte safe.</p></blockquote>
<h3>Examples:</h3>
<p>update `orders_table` set `traking_id` = replace(`traking_id`, ‘1111111’, ‘999999999’);<br />
// this will replace all the 1111111 with 999999999 in the table orders_table for the column traking_id</p>
<p>SELECT REPLACE(’www.mysql.com’, ‘w’, ‘Ww’);<br />
Above statement will return ‘WwWwWw.mysql.com’ as result.</p>
<p>It is easy to work around a <a href="http://www.1-hit.com/web-development.htm">web development software</a>, all you need to know is the basis of <a href="http://www.1-hit.com/website-design.htm">website design</a>. Hire a <a href="http://maine.gov/informe/state/design/index.htm">web design manager</a> if you cannot figure that out and proceed with <a href="http://www.1-hit.com/web-hosting.htm">website hosting</a>. Once done with that, you can move on with <a href="http://www.1-hit.com">internet marketing</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/find-and-replace-text-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Create a zip file with php on the fly</title>
		<link>http://www.gsdesign.ro/blog/how-to-create-a-zip-file-with-php-on-the-fly/</link>
		<comments>http://www.gsdesign.ro/blog/how-to-create-a-zip-file-with-php-on-the-fly/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 20:55:29 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Programing]]></category>
		<category><![CDATA[php&mysql 101]]></category>
		<category><![CDATA[generate]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zip]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=102</guid>
		<description><![CDATA[For a future project I needed these days some easy to use zip or gzip class to create a zip file from files / folders inside a specified directory. A short search on Google has lead me to the Create ZIP File PHP class from Rochak Chauhan. This class can create ZIP archives from lists [...]]]></description>
			<content:encoded><![CDATA[<p>For a future project I needed these days some easy to use <strong>zip</strong> or <strong>gzip class</strong> to create a zip file from files / folders inside a specified directory. A short search on Google has lead me to the <a href="http://solomongaby.users.phpclasses.org/browse/package/2322.html">Create ZIP File</a> PHP class from <a href="http://www.rochakchauhan.com/blog/">Rochak Chauhan</a>. </p>
<blockquote><p>
This class can create ZIP archives from lists of files.</p>
<p>The class provides means to add individual files or whole directories to the list of files packed into a ZIP archive.</p>
<p>The class can generate the packed archive as a string value.</p>
<p>The class can also output the necessary request response headers to serve the generated ZIP archive for download.</p>
<p>The supplied example demonstrates how to use the class to store the ZIP archive in a file, serve it for download and delete the file after it is served.
</p></blockquote>
<h3>Example of usage</h3>
<div class="igBar"><span id="lphp-16"><a href="#" onclick="javascript:showCodeTxt('php-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-16">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">include_once</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"createZip.inc.php"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$createZip</span> = <span style="color:#000000; font-weight:bold;">new</span> createZip;&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$createZip</span> -&gt; <span style="color:#006600;">addDirectory</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"dir/"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$fileContents</span> = <a href="http://www.php.net/file_get_contents"><span style="color:#000066;">file_get_contents</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"img.jpg"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$createZip</span> -&gt; <span style="color:#006600;">addFile</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$fileContents</span>, <span style="color:#FF0000;">"dir/img.jpg"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$fileName</span> = <span style="color:#FF0000;">"archive.zip"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$fd</span> = <a href="http://www.php.net/fopen"><span style="color:#000066;">fopen</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$fileName</span>, <span style="color:#FF0000;">"wb"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$out</span> = <a href="http://www.php.net/fwrite"><span style="color:#000066;">fwrite</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$fd</span>, <span style="color:#0000FF;">$createZip</span> -&gt; <span style="color:#006600;">getZippedfile</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/fclose"><span style="color:#000066;">fclose</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$fd</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$createZip</span> -&gt; <span style="color:#006600;">forceDownload</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$fileName</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@<a href="http://www.php.net/unlink"><span style="color:#000066;">unlink</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$fileName</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/how-to-create-a-zip-file-with-php-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>List Files In A Directory Using PHP</title>
		<link>http://www.gsdesign.ro/blog/list-files-in-a-directory-using-php/</link>
		<comments>http://www.gsdesign.ro/blog/list-files-in-a-directory-using-php/#comments</comments>
		<pubDate>Thu, 29 May 2008 16:41:31 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Programing]]></category>
		<category><![CDATA[php&mysql 101]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=63</guid>
		<description><![CDATA[Usually Apache will list all the files in a directory that doesnt have an index, unless the -indexes option is activated. Never the less sometimes in your programing you will need to list the files that are in a directory, not on the screen necessarily but at least save those files in a variable. But [...]]]></description>
			<content:encoded><![CDATA[<p>Usually Apache will list all the files in a directory that doesnt have an index, unless the -indexes option is activated. Never the less sometimes in your programing you will need to list the files that are in a directory, not on the screen necessarily but at least save those files in a variable. </p>
<p>But enough small talk lets gets on with the actual code :</p>
<div class="igBar"><span id="lphp-18"><a href="#" onclick="javascript:showCodeTxt('php-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-18">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$fileList</span>=<a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$dirPath</span>=<span style="color:#FF0000;">'/path/to/your/dir/'</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$handle</span> = <a href="http://www.php.net/opendir"><span style="color:#000066;">opendir</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$dirPath</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color:#616100;">while</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">false</span> !== <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$file</span> = <a href="http://www.php.net/readdir"><span style="color:#000066;">readdir</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$handle</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$file</span> != <span style="color:#FF0000;">"."</span> &amp;&amp; <span style="color:#0000FF;">$file</span> != <span style="color:#FF0000;">".."</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$fileList</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$file</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <a href="http://www.php.net/closedir"><span style="color:#000066;">closedir</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$handle</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;h3&gt;List of files:&lt;/h3&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <span style="color:#616100;">foreach</span> <span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$fileList</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$f</span> <span style="color:#006600; font-weight:bold;">&#41;</span> : <span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;P&gt;&lt;?=<span style="color:#0000FF;">$f</span>?&gt;&lt;/p&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> endforeach; <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Is that simple. </p>
<p>Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/list-files-in-a-directory-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Error Documents with .htacces</title>
		<link>http://www.gsdesign.ro/blog/custom-error-documents-with-htacces/</link>
		<comments>http://www.gsdesign.ro/blog/custom-error-documents-with-htacces/#comments</comments>
		<pubDate>Sat, 24 May 2008 11:18:16 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Aplications]]></category>
		<category><![CDATA[php&mysql 101]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[documents]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[htaccess]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=33</guid>
		<description><![CDATA[Some people only know about .htaccess utility in apache rewrite, but it can do more than that. For example it can help you specify your own Error Documents. When ever a browser makes a request for a web document ( webpage, files, images, css files etc) the server returns a header that contains an error [...]]]></description>
			<content:encoded><![CDATA[<p>Some people only know about .htaccess utility in apache rewrite, but it can do more than that. For example it can help you specify your own Error Documents. When ever a browser makes a request for a web document ( webpage, files, images, css files etc) the server returns a header that contains an error code that tells the browser details about the requests. I will list this codes below:</p>
<p><strong>Successful Client Requests</strong><br />
200    OK<br />
201    Created<br />
202    Accepted<br />
203    Non-Authorative Information<br />
204    No Content<br />
205    Reset Content<br />
206    Partial Content<br />
Client Request Redirected<br />
300    Multiple Choices<br />
301    Moved Permanently<br />
302    Moved Temporarily<br />
303    See Other<br />
304    Not Modified<br />
305    Use Proxy</p>
<p><strong>Client Request Errors</strong><br />
400    Bad Request<br />
401    Authorization Required<br />
402    Payment Required (not used yet)<br />
403    Forbidden<br />
404    Not Found<br />
405    Method Not Allowed<br />
406    Not Acceptable (encoding)<br />
407    Proxy Authentication Required<br />
408    Request Timed Out<br />
409    Conflicting Request<br />
410    Gone<br />
411    Content Length Required<br />
412    Precondition Failed<br />
413    Request Entity Too Long<br />
414    Request URI Too Long<br />
415    Unsupported Media Type</p>
<p><strong>Server Errors</strong><br />
500    Internal Server Error<br />
501    Not Implemented<br />
502    Bad Gateway<br />
503    Service Unavailable<br />
504    Gateway Timeout<br />
505    HTTP Version Not Supported</p>
<p>In order to In order to specify your own ErrorDocuments, you need to know these error codes, since you will need to specify for wich error code you want to assign a page.</p>
<p>But you wont need to specify an error page for all those codes, You only might want to do a custom error page for the most common of them like 404 and 500. Also most people do a custom Error Document for<br />
<strong>401 - Authorization Required</strong> ( for sections of the site that are protected by a folder password and somebody tries to enter a protected area without corect login details ),<br />
<strong>403 - Forbidden</strong> ( for example when someone is trying to access a folder withough an index option )<br />
<strong>400 - Bad Request</strong>, which is one of those generic kind of errors that people get to by doing some weird stuff with your URL or scripts.</p>
<p>The advantage of having custom error documents is that you can display to the user a custom page with the site layout ( instead of the simple default one ) and you can even build a script to make custom logs of this errors.</p>
<p>You shouldn't make custom pages for all error codes, for example an ErrorDocument for code 200 would cause an infinite loop, whenever a page was found...this would not be good.</p>
<p>To specify your custom error documents, you will add a special command for this in the htaccess file:<br />
ErrorDocument [code] /directory/errorDocument.html</p>
<p>For example an error document for 404 would be:<br />
ErrorDocument 404 /errors/404.html</p>
<p>Now you told the server that when it has an error code of 404 to return the page http://yoursite.com/errors/notfound.html. The same principle apply's to all the codes.</p>
<p>As a small advice i would recommend you make a special folder for your error documents and also name them something that will show theyr error code and purpose. I put 404.html but you can do notFound.html for example. Also the error documents do not need to be html they can also be php,asp or other types of files.</p>
<p>If you dont want to make a special file you can add the html directly in .htaccess file<br />
ErrorDocument 401 "&lt;body&gt; You have to to be a member to view this page.</p>
<p>To do this you need to keep in mind :<br />
the ErrorDocument starts with a " but does not end with one ... that was not a typo <img src='http://www.gsdesign.ro/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
the command should be on one line, including the HTML</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/custom-error-documents-with-htacces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
