<?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>The Webmaster's Café &#187; Web Development</title>
	<atom:link href="http://www.thewebmasterscafe.net/category/development/feed" rel="self" type="application/rss+xml" />
	<link>http://www.thewebmasterscafe.net</link>
	<description>Resources For Webmasters, Web Developers and Web Designers</description>
	<lastBuildDate>Wed, 20 Aug 2008 00:02:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How To Prevent Your Email Address From Being Picked Up By Spammers</title>
		<link>http://www.thewebmasterscafe.net/development/mailto-javascript.html</link>
		<comments>http://www.thewebmasterscafe.net/development/mailto-javascript.html#comments</comments>
		<pubDate>Wed, 19 Mar 2008 18:35:02 +0000</pubDate>
		<dc:creator>Stephane</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.thewebmasterscafe.net/development/mailto-javascript.html</guid>
		<description><![CDATA[When I click on a &#8220;contact&#8221; link, I rather be taken to a page where I can click a link to email somebody rather than filling a contact form. I guess either I&#8217;m too lazy or I prefer using my email client. If you&#8217;ve published your email address on your website, you know it can [...]]]></description>
			<content:encoded><![CDATA[<p>When I click on a &#8220;contact&#8221; link, I rather be taken to a page where I can click a link to email somebody rather than filling a contact form. I guess either I&#8217;m too lazy or I prefer using my email client.</p>
<p>If you&#8217;ve published your email address on your website, you know it can be caught by automated scripts that crawl the web to find potential mailboxes to spam.</p>
<p>So how can you publish your email while hidding it from spammers? The answer is easy: simply use some Javascript to break your email address into multiple lines of code so it won&#8217;t be caught by those malicious scripts.</p>
<p>Here&#8217;s an example:</p>
<blockquote><p><span style="font-family: courier new,courier">&lt;script type=&#8221;text/javascript&#8221; language=&#8221;javascript&#8221;&gt;<br />
document.write(&#8216;&lt;a href=&#8221;mailto:johndoe&#8217;);<br />
document.write(&#8216;@nowhere.com&#8221;&gt;Send me an email&lt;/a&gt;&#8217;);<br />
&lt;/script&gt;</span></p></blockquote>
<p>Inserting this code in your web page would display an email link that is invisible to search engines since they do not support client-side scripting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebmasterscafe.net/development/mailto-javascript.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding A Search Engine To Your Site With Sphider</title>
		<link>http://www.thewebmasterscafe.net/development/sphider-php-search-engine.html</link>
		<comments>http://www.thewebmasterscafe.net/development/sphider-php-search-engine.html#comments</comments>
		<pubDate>Sat, 01 Mar 2008 17:43:34 +0000</pubDate>
		<dc:creator>Stephane</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[free php search engine]]></category>
		<category><![CDATA[phpdig]]></category>
		<category><![CDATA[sphider]]></category>

		<guid isPermaLink="false">http://www.thewebmasterscafe.net/development/sphider-php-search-engine.html</guid>
		<description><![CDATA[Adding a local search engine to your website not only serves your visitors: it will provide you with a tremendous amount of precious data. You will learn about what your visitors are looking for, how do they search for it, the most popular searches, etc. You can then put this data to your service by [...]]]></description>
			<content:encoded><![CDATA[<p>Adding a local search engine to your website not only serves your visitors: it will provide you with a tremendous amount of precious data. You will learn about what your visitors are looking for, how do they search for it, the most popular searches, etc. You can then put this data to your service by optimizing your pages, writing new content, etc.</p>
<p>I used to use <a target="_blank" href="http://www.phpdig.net">phpDig</a> a lot but since it hasn&#8217;t been updated since 2005, so I need to find an alternative. I&#8217;ve found out about Sphider, a free PHP crawler, so we&#8217;re going to try it out today.</p>
<h2>Installing Sphider</h2>
<p>This is a quick and dirty guide to installing Sphider.</p>
<ol>
<li>Grab yourself a <a target="_blank" href="http://www.sphider.eu/download.php">copy of Sphider</a>.</li>
<li>Extract the content from the archive and upload it to your web server. For my part, I&#8217;ve uploaded it into http://www.mydomain.com/search</li>
<li>Unless you want to use an existing MySQL database, create a new one.</li>
<li>From your Sphider directory, edit settings/database.php and set the connexion parameters for your database. Save the file and exit the editor. Upload the file to your web server.</li>
<li>Again from the Sphider directory, edit <em>admin/auth.php</em> and set the username and password you want to access the administration interface. Save the file and exit the file editor.</li>
<li>Open your browser and point it to <em>http://www.yourdomain/search/admin/install.php</em> (or whatever directory you installed Sphider into).</li>
<li>The database tables should&#8217;ve been created successfully at this point. If not, verify your connexion settings in <em>settings/database.php</em></li>
<li>Click on the <strong>admin.php</strong> link, it will take you to the administration interface.</li>
<li>Under the <strong>Site</strong> tab, click on <strong>Add Site</strong> and enter the information for the web site you wish to index.</li>
<li>Click on the <strong>Reindex All</strong> link. This may consume a lot o resource though, make sure you don&#8217;t get your hosting account suspended.</li>
<li>Once the indexing process is completed, open your browser at http://www.yourdomain.com/search/search.php and try searching your website. I was impressed, Sphider seems pretty fast considering I had over 1000 pages to index.</li>
</ol>
<p>So that&#8217;s pretty much it, you now got a local search engine on your website. Here are a few tips to make it better:</p>
<p><strong>Disallow Indexing Of Unwanted Directories</strong></p>
<p>Create a robots.txt file a the root of your website and include the following content to disallow spidering of unecessary folders:</p>
<blockquote><p><span style="font-family: courier new,courier">User-agent: *<br />
Disallow: /admin<br />
Disallow: /go<br />
Disallow: /oa<br />
Disallow: /search<br />
Disallow: /visit<br />
Disallow: /feed</span></p></blockquote>
<p><strong>Setup A Scheduled Task To Reindex Your Website Automatically</strong></p>
<p>Use CRON (on Linux-based servers) to schedule a reindexing task. If you&#8217;re running a dedicated server and that your control panel does not allow you to manage cron tasks, create a file named <strong>sphider.sh</strong> in <strong>/etc/cron.daily</strong> and insert the following content:</p>
<blockquote><p><span style="font-family: courier new,courier">#!/bin/sh<br />
/path/to/php /path/to/sphider/admin/spider.php -all &gt;&gt; /dev/null</span></p></blockquote>
<p>This will reindex all websites everyday. Of course you could set a different indexing cycle and set <a target="_blank" href="http://www.sphider.eu/docs.php#commandline">different spidering options</a>.</p>
<p>If you are using cPanel, here&#8217;s how to setup a cron job to execute spider.php once a day at 1am:</p>
<p style="text-align: center"><img src="http://www.thewebmasterscafe.net/wp-content/uploads/2008/03/sphider-cron-cpanel.jpg" alt="sphider-cron-cpanel.jpg" /></p>
<p><strong>Change the default search page</strong></p>
<p>Instead of using http://www.yourdomain.com/search/search.php, you can make the search page the default page. Simply rename <strong>/search/search.php</strong> to <strong>/search/index.php</strong> and replace all occurences of <strong>search.php</strong> by <strong>index.php</strong> in <strong>/search/templates/search_form.php</strong>.</p>
<p>Of course if you use another template than the standard one, you&#8217;ll have to modify it too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebmasterscafe.net/development/sphider-php-search-engine.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Dynamically Add Pages To Your WordPress Sitemap</title>
		<link>http://www.thewebmasterscafe.net/seo/add-dynamic-entries-to-wordpress-sitemap.html</link>
		<comments>http://www.thewebmasterscafe.net/seo/add-dynamic-entries-to-wordpress-sitemap.html#comments</comments>
		<pubDate>Sun, 17 Feb 2008 01:41:30 +0000</pubDate>
		<dc:creator>Stephane</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.thewebmasterscafe.net/seo/add-dynamic-entries-to-wordpress-sitemap.html</guid>
		<description><![CDATA[If you are using the sitemap plugin for WordPress from Arne Brachhold, you may have the need to add additional pages which are not generated by your blog. If you&#8217;ve got a handful of pages, the sitemap plugin gives your the possibility to add them manually through the option page. There is also an option [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using the sitemap plugin for WordPress from <a href="http://www.arnebrachhold.de/" title="Visit author homepage">Arne Brachhold</a>, you may have the need to add additional pages which are not generated by your blog. If you&#8217;ve got a handful of pages, the sitemap plugin gives your the possibility to add them manually through the option page. There is also an option that allows the plugin to build the sitemap based on requests sent to your web server.</p>
<p>This may be useful but if you need a little more control, here&#8217;s how to dynamically add pages to your WordPress sitemap:</p>
<p>1. Edit /wp-content/plugins/google-sitemap-generator/sitemap.php</p>
<p>2. Find the line that reads:</p>
<blockquote><p><span style="font-family: courier new,courier"><span style="font-family: courier new,courier">$this-&gt;AddElement(new GoogleSitemapGeneratorXmlEntry(&#8220;&lt;/urlset&gt;&#8221;));</span></span></p></blockquote>
<p>3. Just before this line, insert:</p>
<blockquote><p><span style="font-family: courier new,courier"><span style="font-family: courier new,courier">include(&#8220;mysitemap.php&#8221;);</span></span></p></blockquote>
<p>4. Create a new empty file into <strong>/wp-content/plugins/google-sitemap-generator/</strong> and save it as <strong>mysitemap.php</strong>.</p>
<p>5. Insert the following content into your newly created file:</p>
<p class="divSourceCode"><span style="font-family: courier new,courier">&lt;?php</span></p>
<p class="divSourceCode"><span style="font-family: courier new,courier">$this-&gt;AddElement(new GoogleSitemapGeneratorXmlEntry(&#8221; &lt;url&gt;&#8221;));</span></p>
<p><span style="color: #ff0000; font-family: courier new,courier">$this-&gt;AddElement(new GoogleSitemapGeneratorXmlEntry(&#8220;\n &lt;loc&gt;http://www.yourdomain.com/document.html&lt;/loc&gt;&#8221;));</span></p>
<p><span style="color: #ff0000; font-family: courier new,courier">$this-&gt;AddElement(new GoogleSitemapGeneratorXmlEntry(&#8220;\n &lt;changefreq&gt;weekly&lt;/changefreq&gt;&#8221;));</span></p>
<p><span style="color: #ff0000; font-family: courier new,courier">$this-&gt;AddElement(new GoogleSitemapGeneratorXmlEntry(&#8220;\n &lt;priority&gt;0.5&lt;/priority&gt;&#8221;));</span></p>
<p><span style="font-family: courier new,courier">$this-&gt;AddElement(new GoogleSitemapGeneratorXmlEntry(&#8220;\n &lt;/url&gt;\n&#8221;));</span></p>
<p><span style="font-family: courier new,courier">?&gt;</span></p>
<p>6. Once your done, upload sitemap.php and mysitemap.php to your web server.</p>
<p>Of course the iteration process has to occur between the &lt;url&gt; and &lt;/url&gt; entries (<em>the part identified in red</em>). You can dynamically add pages using an SQL query for example.</p>
<p>The <em>sitemap.xml</em> and <em>sitemap.xml.gz</em> files will automatically be updated with your dynamic entries next time your rebuild your sitemap.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebmasterscafe.net/seo/add-dynamic-entries-to-wordpress-sitemap.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Change &#8220;View Source&#8221; Program In Internet Explorer</title>
		<link>http://www.thewebmasterscafe.net/development/change-internet-explorer-view-source.html</link>
		<comments>http://www.thewebmasterscafe.net/development/change-internet-explorer-view-source.html#comments</comments>
		<pubDate>Thu, 24 Jan 2008 14:38:36 +0000</pubDate>
		<dc:creator>Stephane</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.thewebmasterscafe.net/development/change-internet-explorer-view-source.html</guid>
		<description><![CDATA[Since I often have to look at the source code of a web page, I thought it would be useful to have another editor / viewer than Microsoft&#8217;s powerful Notepad application. For my part, I like to use Notepad++, an open-source editor way more powerful than Notepad. Here&#8217;s how to change the default source code [...]]]></description>
			<content:encoded><![CDATA[<p>Since I often have to look at the source code of a web page, I thought it would be useful to have another editor / viewer than Microsoft&#8217;s powerful Notepad application.</p>
<p>For my part, I like to use <a href="http://notepad-plus.sourceforge.net/" target="_blank">Notepad++</a>, an open-source editor way more powerful than Notepad.</p>
<p>Here&#8217;s how to change the default source code viewer for Internet Explorer in Windows XP (it might work for 2000 and Vista as well):</p>
<ol>
<li>Download and run <a href="http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx" target="_blank">TweakUI from Microsoft&#8217;s PowerToys</a>.</li>
<li>Expand the &#8220;Internet Explorer&#8221; section and click on &#8220;View Source&#8221;
<p><img src="http://www.thewebmasterscafe.net/wp-content/uploads/2008/01/tweakui.jpg" alt="tweakui.jpg" /></li>
<li>Hit the &#8220;Change Program&#8221; button and select the desired viewer.</li>
<li>Click on OK and relaunch Internet Explorer.</li>
</ol>
<p>That&#8217;s it! No more Notepad to view the source code of a web page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebmasterscafe.net/development/change-internet-explorer-view-source.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Developing Dynamic Websites At Lightning Speed With CodeCharge Studio</title>
		<link>http://www.thewebmasterscafe.net/development/codecharge.html</link>
		<comments>http://www.thewebmasterscafe.net/development/codecharge.html#comments</comments>
		<pubDate>Wed, 05 Dec 2007 04:00:34 +0000</pubDate>
		<dc:creator>Stephane</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.thewebmasterscafe.net/development/codecharge.html</guid>
		<description><![CDATA[If you are regularly developing dynamic websites, you probably have the need for a fast and powerful development environment. Notepad may do the job for short scripts but when it comes to creating more complex applications, it&#8217;s your salary that goes down the drain if you&#8217;re wasting too much time on coding. Personnally I&#8217;ve been [...]]]></description>
			<content:encoded><![CDATA[<p>If you are regularly developing dynamic websites, you probably have the need for a fast and powerful development environment. Notepad may do the job for short scripts but when it comes to creating more complex applications, it&#8217;s your salary that goes down the drain if you&#8217;re wasting too much time on coding.</p>
<p>Personnally I&#8217;ve been using <a target="_blank" href="/go/codecharge.php">CodeCharge Studio from YesSoftware</a> for about four years (since version 2) to develop PHP websites. While I haven&#8217;t used any other programming languages it offers, here are its possibilities:</p>
<ul>
<li>PHP 4/5</li>
<li>ASP 3.0</li>
<li>ASP.NET C#</li>
<li>ASP.NET VB</li>
<li>CFML 4.01/MX</li>
<li>JSP 1.1 JDK 1.3</li>
<li>Perl 5.0</li>
<li>Servlets 2.2 JDK 1.3</li>
</ul>
<p>CodeCharge Studio allows you to create multilingual applications by storing text content in a language file. This way you can even have contributors translating your application in various languages. CodeCharge supports most open source and commercial database formats.</p>
<p>Enough talk, let me show how you fast it can create a record form to manage data from a MySQL table. For this video, I&#8217;ve used the database from <a href="http://www.thewebmasterscafe.net/development/basic-php-data-browser-pt1.html">this post</a>. The only thing I&#8217;ve created in advance is the ODBC link and the folder on my webserver.</p>
<p><a target="_blank" href="/videos/codecharge"><strong>Watch CodeCharge Studio demo here</strong></a> (can take a while to load)</p>
<p><em>This is not a tutorial, it just goes to show you how much time you can save with CodeCharge Studio.</em></p>
<p><strong>Time spent developing: 7:25 minutes.</strong> </p>
<p>I also love the fact that I can learn to use a single development environment for multiple programming languages.</p>
<p><a target="_blank" href="/go/codecharge.php"><img border="0" vspace="8" align="right" width="55" src="http://www.thewebmasterscafe.net/wp-content/uploads/2007/12/icon_logo_ccs.jpg" hspace="8" alt="Order CodeCharge Studio Now!" height="80" /></a>So suppose usually that you would have charged $70 for this two-hour project, you would have made $35 an hour for coding this from scratch. Using CodeCharge, you could&#8217;ve done it in half an hour, charged your client $60 (to be slightly cheaper than your competitors) and you would have made $120 an hour.</p>
<p><strong>That&#8217;s a 343% increase in profitability.</strong></p>
<p>If you&#8217;re not a programmer and you&#8217;re hiring someone to do that, maybe you want to see how they&#8217;re coding and where goes your money.</p>
<p><a target="_blank" href="/go/codecharge.php"><strong>Click here to visit CodeCharge website.</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebmasterscafe.net/development/codecharge.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is Your Webserver Secure? Find Out With nUbuntu</title>
		<link>http://www.thewebmasterscafe.net/webhosting/nubuntu-network-security.html</link>
		<comments>http://www.thewebmasterscafe.net/webhosting/nubuntu-network-security.html#comments</comments>
		<pubDate>Wed, 07 Nov 2007 11:00:28 +0000</pubDate>
		<dc:creator>Stephane</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Web Hosting]]></category>

		<guid isPermaLink="false">http://www.thewebmasterscafe.net/webhosting/nubuntu-network-security.html</guid>
		<description><![CDATA[nUbuntu (network Ubuntu) is a Linux security distro based on Ubuntu(!). According to the nUbuntu website, the goal of the project is to create a distribution that is derived from the Ubuntu distribution, add packages related to security testing, and remove unneeded packages such as Gnome, OpenOffice.org, and Evolution. At the time of this writing, the current [...]]]></description>
			<content:encoded><![CDATA[<p>nUbuntu (network Ubuntu) is a Linux security distro based on <a target="_blank" href="http://www.ubuntu.com/">Ubuntu</a>(!). According to the <a target="_blank" href="http://www.nubuntu.org">nUbuntu website</a>, the goal of the project is <em>to create a distribution that is derived from the Ubuntu distribution, add packages related to security testing, and remove unneeded packages such as Gnome, OpenOffice.org, and Evolution.</em></p>
<p>At the time of this writing, the current version of nUbuntu is based on Ubuntu 6.10 - <em>Edgy Eft</em>. Some of the better known tools are:</p>
<ul>
<li><a target="_blank" href="http://insecure.org/nmap/"><strong>Nmap</strong></a> &#8211; A network exploration and security auditing tool.</li>
<li><a target="_blank" href="http://www.yersinia.net/"><strong>Yersinia</strong></a> &#8211; Network tool designed to take advantage of some weakeness in different network protocols.</li>
<li><strong><a target="_blank" href="http://ettercap.sourceforge.net/">Ettercap</a></strong> &#8211; A sniffer for switched LANs.</li>
<li><a target="_blank" href="http://www.kismetwireless.net/"><strong>Kismet</strong></a> - A 802.11 layer2 wireless network detector, sniffer, and intrusion detection system</li>
<li><strong><a target="_blank" href="http://monkey.org/~dugsong/dsniff/">Dsniff</a></strong> &#8211; Collection of tools for network auditing.</li>
<li><strong><a target="_blank" href="http://www.wireshark.org/">Wireshark</a></strong> &#8211; Network protocol analyzer examination of data from a live network, or from a capture file on disk.</li>
</ul>
<p>Listing the <em>/tools</em> directory shows us available tool categories: bluetooth, cisco, database, enum, exploit, forensics, fuzzers, passwords, and scanners.</p>
<h2>Test Your Webserver&#8217;s Vulnerability With BED v0.5</h2>
<p>Some of the included need to be executed as root. In this case, use <em>sudo [command]</em>. Change directory to <em>/tools/fuzzers/bed</em> and run <em>sudo ./bed.pl</em> to see its usage feedback. Suppose you&#8217;d like to test for buffer overflow on a particular host, use:</p>
<blockquote class="SourceCode"><p># sudo ./bed.pl -s HTTP -t 192.168.0.1</p></blockquote>
<p>Of course, change the IP to the one of the server you want to test.</p>
<p>There is also the DNS Enum tool you might want to check out for testing your name resolution system. A well-managed domain won&#8217;t give up too much information or a zone transfer. To launch DNS Enum, change directory to <em>/tools/enum/dnsenum</em> and enter:</p>
<blockquote>
<p class="SourceCode"># ./dnsenum.pl [domain] [dns.txt]</p>
</blockquote>
<p>If you&#8217;d like to know more about nUbuntu, visit <a href="http://www.nubuntu.org/">http://www.nubuntu.org</a>. Other security distros can be found through <a href="http://www.securitydistro.com/">http://www.securitydistro.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebmasterscafe.net/webhosting/nubuntu-network-security.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Protecting Sensitive Information In PHP Files</title>
		<link>http://www.thewebmasterscafe.net/development/php-file-encryption.html</link>
		<comments>http://www.thewebmasterscafe.net/development/php-file-encryption.html#comments</comments>
		<pubDate>Mon, 05 Nov 2007 05:00:45 +0000</pubDate>
		<dc:creator>Stephane</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.thewebmasterscafe.net/development/php-file-encryption.html</guid>
		<description><![CDATA[Lately as my previous webserver has been hacked and I&#8217;ve been faced with the reality that my PHP scripts weren&#8217;t secure. This led me to change all my account passwords including SSH, MySQL, POP3 and lots of others. Fortunately I&#8217;ve always been using a different set of passwords for my other accounts like forums, online communities [...]]]></description>
			<content:encoded><![CDATA[<p>Lately as my previous webserver has been hacked and I&#8217;ve been faced with the reality that my PHP scripts weren&#8217;t secure. This led me to change all my account passwords including SSH, MySQL, POP3 and lots of others. Fortunately I&#8217;ve always been using a different set of passwords for my other accounts like forums, online communities and banking so I didn&#8217;t have to change those.</p>
<p>How many of you have stored their database password into an includable PHP configuration file? And how many of you are using the same password for more than one database? Well let me tell you, chances are, if you are running a WordPress blog, you&#8217;ve already got a password stored into <em>wp-config.php</em>. Now what if your webserver&#8217;s configuration got messed up and started serving PHP files as plain text instead of parsing them?</p>
<p><em>And believe me it can happen, I once moved a website to somebody else&#8217;s server which wasn&#8217;t configured properly and it showed the content of PHP scripts!</em></p>
<h2>Encrypting Your PHP Scripts</h2>
<p>Encrypting PHP files does not only protect your passwords, it also protects your intellectual property. Sure, open-source is a beautiful thing but let&#8217;s say you&#8217;ve develop this awesome PHP application and you distribute it for free. What&#8217;s the best way to find it&#8217;s vulnerability? Just go through the source code and find out!</p>
<p>There are a bunch of commercial softwares that allow you to encrypt your PHP files:</p>
<ul>
<li><a target="_blank" href="http://www.zend.com/products/zend_guard"><strong>Zend Guard</strong></a> : Previously known as <em>Zend Encoder</em>, Zend Guard protects your commercial PHP 4 and PHP 5 applications from reverse engineering, unauthorized customization, unlicensed use and redistribution. Encrypted files require Zend Optimizer (free) to be installed on the webserver. Yearly license: $995 USD.</li>
<li><a target="_blank" href="http://www.thewebmasterscafe.net/go/sourceguardian.php"><strong>SourceGuardian For PHP : PHP Encoder</strong></a> : Best know as <em>PHP Encoder</em> SourceGuardian is an advanced package with a long list of features for making the resulting code as hard to read as possible. There are no requirements as to running encrypted PHP scripts on a webserver. Full license: $250 USD.</li>
<li><a target="_blank" href="http://www.ioncube.com/"><strong>ionCube PHP Encoder</strong></a><strong> </strong>: ionCube provides PHP file encryption through a software or online on a pay-per-download basis. This entry-level encryption application is more affordable than its two competitors. Pricing : $199 USD.</li>
</ul>
<p>There are also some open-source encryption softwares available for free but they haven&#8217;t been updated in awhile (over 3 to 4 years ago!) so I don&#8217;t recommend them. However you can try them out if you really want to:</p>
<ul>
<li><a target="_blank" href="http://turck-mmcache.sourceforge.net/"><strong>Turck MMCache for PHP</strong></a> : While it requires to install additional software on the server, it is also compatible with Zend Optimizer.</li>
<li><a target="_blank" href="http://pobs.mywalhalla.net/"><strong>PHP Obfuscator (POBS)</strong></a><strong> </strong>: POBS is written in PHP and is to be used online from your webserver.</li>
</ul>
<p>If you know of any other method of protecting / encrypting PHP scripts, let us know!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebmasterscafe.net/development/php-file-encryption.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Prevent Email Form Injection With PHP</title>
		<link>http://www.thewebmasterscafe.net/development/prevent-email-form-injection.html</link>
		<comments>http://www.thewebmasterscafe.net/development/prevent-email-form-injection.html#comments</comments>
		<pubDate>Sun, 21 Oct 2007 20:31:16 +0000</pubDate>
		<dc:creator>Stephane</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.thewebmasterscafe.net/development/prevent-email-form-injection.html</guid>
		<description><![CDATA[Form injection is one of the most common security issue on the web. Bots or scripts are continuously crawling the web in search of entry forms. When they find one, they try to submit it while injecting malicious instructions into some of the form&#8217;s fields. These instructions may go from SQL queries to SMTP commands. Email form [...]]]></description>
			<content:encoded><![CDATA[<p>Form injection is one of the most common security issue on the web. Bots or scripts are continuously crawling the web in search of entry forms. When they find one, they try to submit it while injecting malicious instructions into some of the form&#8217;s fields. These instructions may go from SQL queries to SMTP commands.</p>
<p>Email form injection is what we&#8217;ll be discussing about today. This form of attack is mainly used to send spam mail through the exploited server. We&#8217;ll see what precaution we can take by validating the input before it is sent to server and after it is being sent but just before processing it.</p>
<p>Let&#8217;s say we want to secure this simple email form:</p>
<p style="text-align: center"><img src="http://www.thewebmasterscafe.net/wp-content/uploads/2007/10/email-form.jpg" alt="Preventing Email Form Injection" /></p>
<h2>Client-Side Protection</h2>
<p>There are a some precautions you can take on the client-side (before the form is submitted) in order to avoid email form injection:</p>
<ul>
<li>Limit the maximum length of each field so that it may be harder to inject malicious instructions (while still not totally impossible);</li>
<li>Add an additional field to require an anti-spam question (like 2+3=?) to ensure it&#8217;s being accessed by a human and not a script;</li>
<li>Replace text fields by dropdown menus or checkboxes where possible (does not apply for the above form example);</li>
</ul>
<h2>Server-Side Protection And Validation</h2>
<p>In order to prevent form injection, let&#8217;s start by validating the sender&#8217;s email address using the <em>preg_match</em> function. The following would prevent an email to be sent if the sender&#8217;s email address format is incorrect:</p>
<blockquote class="SourceCode"><p>&lt;?<br />
$email_pattern = &#8216;/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i&#8217;;</p>
<p>if (!preg_match($email_pattern, $sender_email)){<br />
  die(&#8220;Your email address is incorrect&#8221;);<br />
}<br />
?&gt;</p></blockquote>
<p>Next we could filter out carriage returns from text fields (but not text areas of course):</p>
<blockquote class="SourceCode"><p>&lt;?<br />
if (eregi(&#8220;(\r|\n)&#8221;, $subject))<br />
     die(&#8220;Form injection detected&#8221;);<br />
?&gt;</p></blockquote>
<p>Making sure that the validation script is being sent data from a browser will also rule out some bots:</p>
<blockquote class="SourceCode"><p>&lt;?<br />
if(!isset($_SERVER['HTTP_USER_AGENT'])){<br />
   die(&#8220;Forbidden &#8211; You are not authorized to view this page&#8221;);<br />
   exit;<br />
}<br />
?&gt;</p></blockquote>
<p>There are also a few strings you may want to make sure they aren&#8217;t passed to your script:</p>
<blockquote class="SourceCode"><p>$badstrings = array(&#8220;Content-Type:&#8221;,<br />
                     &#8220;MIME-Version:&#8221;,<br />
                     &#8220;Content-Transfer-Encoding:&#8221;,<br />
                     &#8220;bcc:&#8221;,<br />
                     &#8220;cc:&#8221;);</p>
<p>foreach($_POST as $key =&gt; $value){<br />
   foreach($badstrings as $badstring){<br />
       if(strpos($value, $badstring) !== false){<br />
          die(&#8220;Forbidden &#8211; You are not authorized to view this page&#8221;);<br />
          exit;<br />
       }<br />
   }<br />
}</p></blockquote>
<p>I&#8217;ve got another post where you can learn more on <a href="http://www.thewebmasterscafe.net/development/how-to-send-emails-with-php.html">how to send emails with PHP</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebmasterscafe.net/development/prevent-email-form-injection.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Send Emails With PHP</title>
		<link>http://www.thewebmasterscafe.net/development/how-to-send-emails-with-php.html</link>
		<comments>http://www.thewebmasterscafe.net/development/how-to-send-emails-with-php.html#comments</comments>
		<pubDate>Fri, 12 Oct 2007 19:00:16 +0000</pubDate>
		<dc:creator>Stephane</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.thewebmasterscafe.net/web-development/how-to-send-emails-with-php.html</guid>
		<description><![CDATA[Web developers often face the need of automating the sending of emails through their scripts. Of course, there is the possibility of using the PHP mail() function. While using this function for sending a basic email (i.e. one recipient, a subject and a message) is pretty easy, pushing the envelope (i.e. multiple recipients, attachments, etc.) [...]]]></description>
			<content:encoded><![CDATA[<p>Web developers often face the need of automating the sending of emails through their scripts. Of course, there is the possibility of using the <a target="_blank" href="http://www.php.net/manual/en/function.mail.php">PHP mail() function</a>. While using this function for sending a basic email (i.e. one recipient, a subject and a message) is pretty easy, pushing the envelope (i.e. multiple recipients, attachments, etc.) may require a lot more coding.</p>
<p>Here&#8217;s the basic mail() function syntax:</p>
<blockquote class="SourceCode"><p>mail ( string $to, string $subject, string $message [, string $additional_headers [, string $additional_parameters]] )</p></blockquote>
<p>A good knowledge of mail headers is required in order to achieve advanced results. Fortunately there are easier ways of sending emails with PHP.</p>
<h2>Introducing The PHPMailer Class</h2>
<p><a target="_blank" href="http://phpmailer.sourceforge.net/">PHPMailer</a> is a full featured email transfer class for PHP. Here are a few features:</p>
<ul>
<li>Can send emails with multiple TOs, CCs, BCCs and REPLY-TOs</li>
<li>Redundant SMTP servers</li>
<li>Multipart/alternative emails for mail clients that do not read HTML email</li>
<li>Support for 8bit, base64, binary, and quoted-printable encoding</li>
<li>Uses the same methods as the very popular AspEmail active server (COM) component</li>
<li>SMTP authentication</li>
<li>Word wrap</li>
<li>Address reset functions</li>
<li>HTML email</li>
<li>Tested on multiple SMTP servers: Sendmail, qmail, Postfix, Imail, Exchange, etc</li>
<li>Works on any platform</li>
<li>Flexible debugging</li>
<li>Custom mail headers</li>
<li>Multiple fs, string, and binary attachments (those from database, string, etc)</li>
<li>Embedded image support</li>
</ul>
<h2>How To Use PHPMailer</h2>
<p>First <a target="_blank" href="http://sourceforge.net/project/showfiles.php?group_id=26031">get your copy of PHPMailer from SourceForge</a> or you can <a href="http://www.thewebmasterscafe.net/wp-content/uploads/2007/10/phpmailer-173.zip" title="phpmailer-173.zip">get it here too</a>. Extract the <em>phpmailer</em> folder from the archive and upload it to the root of your website. You can delete the following files / folders:</p>
<ul>
<li>/phpmailer/test</li>
<li>/phpmailer/ChangeLog.txt</li>
<li>/phpmailer/docs</li>
<li>/phpmailer/phpdoc</li>
<li>/phpmailer/LICENCE</li>
<li>/phpmailer/README</li>
</ul>
<p>Now let&#8217;s create a php file named <em>sendemail.php</em> at the root of your website. At this point you should have a file / folder structure like this:</p>
<ul>
<li>http://www.yourwebsite.com/phpmailer</li>
<li>http://www.yourwebsite.com/sendemail.php</li>
</ul>
<p>Here&#8217;s the content of <em>sendemail.php</em>:</p>
<blockquote class="SourceCode"><p>&lt;?<br />
error_reporting(E_ALL);</p>
<p>require(&#8216;phpmailer/class.phpmailer.php&#8217;);</p>
<p>$mail = new PHPMailer();</p>
<p>$mail-&gt;Host = &#8220;localhost&#8221;;<br />
$mail-&gt;Mailer = &#8220;smtp&#8221;;</p>
<p>$mail-&gt;From = &#8220;my@email.com&#8221;;<br />
$mail-&gt;FromName = &#8220;Bill Gate&#8221;;<br />
$mail-&gt;Subject = &#8220;How are you?&#8221;;</p>
<p>$htmlmsg = &#8220;Hey there,&lt;br&gt;&lt;br&gt;What have you been up to lately?&lt;br&gt;Waiting for your news!&lt;br&gt;&lt;br&gt;&#8221; .<br />
  &#8221;See you soon,&lt;br&gt;Your friend&#8221;;<br />
$txtmsg = str_replace(&#8220;&lt;br&gt;&#8221;, &#8220;\n&#8221;, $htmlmsg);</p>
<p>$mail-&gt;Body = $htmlmsg;<br />
$mail-&gt;AltBody = $txtmsg;</p>
<p>$mail-&gt;AddAddress(myfriend@hotmail.com, &#8220;Joe&#8221;);<br />
$mail-&gt;AddAddress(&#8220;myotherfriend@gmail.com&#8221;, &#8220;Jack&#8221;);</p>
<p>if($mail-&gt;Send())<br />
 echo &#8220;Email sent successfully&#8221;;<br />
else<br />
 echo &#8220;Email has not been sent&#8221;;<br />
?&gt;</p></blockquote>
<p>Of course, there is a lot more you can do with PHPMailer like embedding images, sending attachments, etc. Have a look at &#8220;docs\extending.html&#8221; from the PHPMailer archive.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebmasterscafe.net/development/how-to-send-emails-with-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The End Of PHP4</title>
		<link>http://www.thewebmasterscafe.net/news/php4-end-of-life.html</link>
		<comments>http://www.thewebmasterscafe.net/news/php4-end-of-life.html#comments</comments>
		<pubDate>Mon, 08 Oct 2007 17:04:46 +0000</pubDate>
		<dc:creator>Stephane</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.thewebmasterscafe.net/news/php4-end-of-life.html</guid>
		<description><![CDATA[PHP 5 has already been out for more than three years now and version 6 is on it&#8217;s way. PHP developers recently announced on php.net that there will be no further releases of PHP version 4 although security fixes will continue on a case-by-case basis until August 8th 2008. PHP 4 scripts should be converted [...]]]></description>
			<content:encoded><![CDATA[<p>PHP 5 has already been out for more than three years now and version 6 is on it&#8217;s way. PHP developers recently announced on <a target="_blank" href="http://www.php.net/">php.net</a> that there will be no further releases of PHP version 4 although security fixes will continue on a case-by-case basis until August 8th 2008. PHP 4 scripts should be converted to version 5 by the end of 2007.</p>
<p>Conversion to PHP 5 has been really slow. According to <a target="_blank" href="http://www.nexen.net">Nexen.net</a> for August 2007, 78% of websites are still using PHP 4. PHP 4.4.7 is still the popular choice while PHP 5.2.3 is good second.</p>
<p style="text-align: center"><img src="http://www.thewebmasterscafe.net/wp-content/uploads/2007/10/php-major-version-repartition.jpg" alt="PHP Major Version Repartition" /></p>
<p>PHP.net has a <a target="_blank" href="http://docs.php.net/manual/en/migration5.php">migration guide for PHP4 to PHP5</a> as well as guides for <a target="_blank" href="http://docs.php.net/manual/en/migration51.php">PHP 5.0 to 5.1</a> and <a target="_blank" href="http://docs.php.net/manual/en/migration52.php">PHP 5.1 to 5.2</a>.</p>
<p><a href="http://www.thewebmasterscafe.net/webhosting/centos4-upgrade-php4-to-php5.html">If you are using CentOS 4, I&#8217;ve written an article about migrating from PHP 4.3.9 to 5.1.6.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebmasterscafe.net/news/php4-end-of-life.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

