<?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>David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞. &#187; Security</title> <atom:link href="http://davidwalsh.name/tutorials/security/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Thu, 02 Sep 2010 03:13:15 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>AJAX For Evil:  Spyjax with&#160;jQuery</title><link>http://davidwalsh.name/jquery-spyjax</link> <comments>http://davidwalsh.name/jquery-spyjax#comments</comments> <pubDate>Wed, 18 Nov 2009 13:38:23 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Markup]]></category> <category><![CDATA[Security]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4223</guid> <description><![CDATA[Last year I wrote a popular post titled AJAX For Evil: Spyjax when I described a technique called &#8220;Spyjax&#8221;: Spyjax, as I know it, is taking information from the user’s computer for your own use — specifically their browsing habits. By using CSS and JavaScript, I can inject anchor links into the page and tell [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/jquery-spyjax">AJAX For Evil:  Spyjax with&nbsp;jQuery</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/ajax-evil-spyjax' rel='bookmark' title='Permanent Link: AJAX For Evil:&nbsp;Spyjax'>AJAX For Evil:&nbsp;Spyjax</a></li><li><a
href='http://davidwalsh.name/spyjax-dojo' rel='bookmark' title='Permanent Link: Spyjax:  Ajax For Evil Using&nbsp;Dojo'>Spyjax:  Ajax For Evil Using&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/animated-ajax-jquery' rel='bookmark' title='Permanent Link: Animated AJAX Record Deletion Using&nbsp;jQuery'>Animated AJAX Record Deletion Using&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/ajax-spinner-jquery' rel='bookmark' title='Permanent Link: Form Element AJAX Spinner Attachment Using&nbsp;jQuery'>Form Element AJAX Spinner Attachment Using&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/broken-images-jquery-ajax' rel='bookmark' title='Permanent Link: Send Email Notifications for Broken Images Using jQuery&nbsp;AJAX'>Send Email Notifications for Broken Images Using jQuery&nbsp;AJAX</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Last year I wrote a popular post titled AJAX For Evil:  Spyjax when I described a technique called &#8220;Spyjax&#8221;:</p><blockquote>Spyjax, as I know it, is taking information from the user’s computer for your own use — specifically their browsing habits. By using CSS and JavaScript, I can inject anchor links into the page and tell whether you’ve been to the link’s URL. How? Quite easy actually.</blockquote><p>I&#8217;ve taken the time to demonstrate this technique using jQuery.</p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/jquery-spyjax.php" class="demo">View Basic Demo</a> <a
href="http://davidwalsh.name/dw-content/jquery-spyjax-advanced.php" class="demo">View Advanced Demo</a><div
class="clear"></div></div><h2>The&nbsp;CSS</h2><pre class="css">
a.checkme			{ color:#00ff00; }
a.checkme:visited	{ color:#ff0000; }
</pre><p>The most important part of the CSS is the difference in &#8220;:link&#8221; and &#8220;:visited&#8221; color;  the method by which we can tell if a site has been visited is by its link color being the &#8220;:visited&#8221; color.</p><h2>The jQuery&nbsp;JavaScript</h2><pre class="js">
//when the page is ready
$(document).ready(function() {
	//the list of domains to check and an array which will store hits
	var domains = ['davidwalsh.name','css-tricks.com','scriptandstyle.com','cnn.com','digg.com'];
	var visited = [];
	//for every domain...
	$.each(domains,function() {
		//inject a link into page
		var a = $('<a></a>').attr({
			href: 'http://' + this,
			'class': 'checkme'
		}).appendTo(document.body);
		//check the color of the link
		if($(a).css('color') == '#ff0000' || $(a).css('color') == 'rgb(255, 0, 0)') { //either format of color
			$(a).addClass('highlight');
			visited.push(this);
		}
		//remove from the page -- no longer need the links
		a.remove();
	});
	if(visited.length) {
		//save via ajax!  shady!
		//display items on the page based on "hits"
	}
});
</pre><p>We start by injecting a bunch of hidden links into the page (unbeknownst to the user).  For each link we&#8217;ve injected into the page, our jQuery JavaScript grabs the link color &#8212; if the link&#8217;s color matches the designated &#8220;:visited&#8221; link color we set via CSS, we&#8217;ve found a site the user&#8217;s been to.  Of course we can do anything we want with that information, including saving it via AJAX.  Why?  Well, if we know a user has been to Digg.com, maybe we show the Digg &#8220;share&#8221; icon instead of the Reddit icon.</p><h2>The MooTools&nbsp;JavaScript</h2><pre class="js">
var domains = ['davidwalsh.name','css-tricks.com','scriptandstyle.com','cnn.com','digg.com'];
var visited = [];
domains.each(function(url) {
	var anchor = new Element('a', {
		href: 'http://' + url,
		'class': 'checkme',
		html: url
	}).inject(document.body);
	if(anchor.getStyle('color') == '#ff0000') {
		visited.push(url);
	}
	anchor.dispose();
});
</pre><p>The above code accomplishes the same task using MooTools as outlined in my <a
href="http://davidwalsh.name/ajax-evil-spyjax">previous Spyjax post</a>.</p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/jquery-spyjax.php" class="demo">View Basic Demo</a> <a
href="http://davidwalsh.name/dw-content/jquery-spyjax-advanced.php" class="demo">View Advanced Demo</a><div
class="clear"></div></div><p>What are your thoughts on Spyjax?  Harmless?  Major privacy violation?  You tell me!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/jquery-spyjax">AJAX For Evil:  Spyjax with&nbsp;jQuery</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/ajax-evil-spyjax' rel='bookmark' title='Permanent Link: AJAX For Evil:&nbsp;Spyjax'>AJAX For Evil:&nbsp;Spyjax</a></li><li><a
href='http://davidwalsh.name/spyjax-dojo' rel='bookmark' title='Permanent Link: Spyjax:  Ajax For Evil Using&nbsp;Dojo'>Spyjax:  Ajax For Evil Using&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/animated-ajax-jquery' rel='bookmark' title='Permanent Link: Animated AJAX Record Deletion Using&nbsp;jQuery'>Animated AJAX Record Deletion Using&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/ajax-spinner-jquery' rel='bookmark' title='Permanent Link: Form Element AJAX Spinner Attachment Using&nbsp;jQuery'>Form Element AJAX Spinner Attachment Using&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/broken-images-jquery-ajax' rel='bookmark' title='Permanent Link: Send Email Notifications for Broken Images Using jQuery&nbsp;AJAX'>Send Email Notifications for Broken Images Using jQuery&nbsp;AJAX</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/jquery-spyjax/feed</wfw:commentRss> <slash:comments>52</slash:comments> </item> <item><title>Disallow Robots Using&#160;Robots.txt</title><link>http://davidwalsh.name/robots-txt</link> <comments>http://davidwalsh.name/robots-txt#comments</comments> <pubDate>Fri, 03 Jul 2009 11:10:47 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Google]]></category> <category><![CDATA[Security]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=3028</guid> <description><![CDATA[I develop customer websites on a publicly accessible web server so that my customers may check the progress of their website at any given time. I could use .htaccess to require username and password for the site but then I&#8217;m constantly needing to remind customers what their password is. My big concern is preventing search [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/robots-txt">Disallow Robots Using&nbsp;Robots.txt</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/google-password-protected-areas' rel='bookmark' title='Permanent Link: Allow Google Into Password Protected&nbsp;Areas'>Allow Google Into Password Protected&nbsp;Areas</a></li><li><a
href='http://davidwalsh.name/set-user-agent-php-curl-spoof' rel='bookmark' title='Permanent Link: Set the User Agent With PHP&nbsp;cURL'>Set the User Agent With PHP&nbsp;cURL</a></li><li><a
href='http://davidwalsh.name/htaccess-security-include-files' rel='bookmark' title='Permanent Link: Advanced .htaccess Security &#8211; Block Access to Include Files Using&nbsp;.htaccess'>Advanced .htaccess Security &#8211; Block Access to Include Files Using&nbsp;.htaccess</a></li><li><a
href='http://davidwalsh.name/htaccess-security-allow-block-ips' rel='bookmark' title='Permanent Link: Advanced .htaccess Security &#8211; Allow or Block Specific IPs From Your&nbsp;Website'>Advanced .htaccess Security &#8211; Allow or Block Specific IPs From Your&nbsp;Website</a></li><li><a
href='http://davidwalsh.name/knowing-website-state-php' rel='bookmark' title='Permanent Link: Knowing Website State Using&nbsp;PHP'>Knowing Website State Using&nbsp;PHP</a></li></ol>]]></description> <content:encoded><![CDATA[<p>I develop customer websites on a publicly accessible web server so that my customers may check the progress of their website at any given time.  I could use <a
href="http://davidwalsh.name/password-protect-directory-using-htaccess">.htaccess to require username and password</a> for the site but then I&#8217;m constantly needing to remind customers what their password is.  My big concern is preventing search engines from finding their way to my development server.  Luckily I can add a <span
class="file">robots.txt</span> file to my development server websites that will prevent search engines from indexing them.</p><h2>The&nbsp;Robots.txt</h2><pre class="text">
User-agent: *
Disallow: /
</pre><p>The above directive prevents the search engines from indexing any pages or files on the website.  Say, however, that you simply want to keep search engines out of the folder that contains your administrative control panel.  You&#8217;d code:</p><pre class="text">
User-agent: *
Disallow: /administration/
</pre><p>Or if you wanted to allow in all spiders except Google&#8217;s GoogleBot, you&#8217;d code:</p><pre class="text">
User-Agent: googelbot
Disallow: /
</pre><p>What would you prevent the search engines from seeing?</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/robots-txt">Disallow Robots Using&nbsp;Robots.txt</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/google-password-protected-areas' rel='bookmark' title='Permanent Link: Allow Google Into Password Protected&nbsp;Areas'>Allow Google Into Password Protected&nbsp;Areas</a></li><li><a
href='http://davidwalsh.name/set-user-agent-php-curl-spoof' rel='bookmark' title='Permanent Link: Set the User Agent With PHP&nbsp;cURL'>Set the User Agent With PHP&nbsp;cURL</a></li><li><a
href='http://davidwalsh.name/htaccess-security-include-files' rel='bookmark' title='Permanent Link: Advanced .htaccess Security &#8211; Block Access to Include Files Using&nbsp;.htaccess'>Advanced .htaccess Security &#8211; Block Access to Include Files Using&nbsp;.htaccess</a></li><li><a
href='http://davidwalsh.name/htaccess-security-allow-block-ips' rel='bookmark' title='Permanent Link: Advanced .htaccess Security &#8211; Allow or Block Specific IPs From Your&nbsp;Website'>Advanced .htaccess Security &#8211; Allow or Block Specific IPs From Your&nbsp;Website</a></li><li><a
href='http://davidwalsh.name/knowing-website-state-php' rel='bookmark' title='Permanent Link: Knowing Website State Using&nbsp;PHP'>Knowing Website State Using&nbsp;PHP</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/robots-txt/feed</wfw:commentRss> <slash:comments>15</slash:comments> </item> <item><title>PHP, SSL, and cURL SSL3_GET_SERVER_CERTIFICATE&#160;Errors</title><link>http://davidwalsh.name/php-ssl-curl-error</link> <comments>http://davidwalsh.name/php-ssl-curl-error#comments</comments> <pubDate>Wed, 10 Jun 2009 03:00:10 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[Security]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=2818</guid> <description><![CDATA[I recently developed a complex system for a customer that involved PHP, cURL, and a SSL connection to a third party vendor. The third party vendor would validate the security certificate of the source (the system I created) and either allow or reject access. My code looked like this: $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,'https://thirdparty.com/token.php'); //not the [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/php-ssl-curl-error">PHP, SSL, and cURL SSL3_GET_SERVER_CERTIFICATE&nbsp;Errors</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/godaddy-curl-http-403-errors' rel='bookmark' title='Permanent Link: GoDaddy, cURL, HTTP, and 403&nbsp;Errors'>GoDaddy, cURL, HTTP, and 403&nbsp;Errors</a></li><li><a
href='http://davidwalsh.name/godaddy-hosting-curl' rel='bookmark' title='Permanent Link: GoDaddy Hosting Tip &#8211; Using CURL On GoDaddy Shared&nbsp;Hosting'>GoDaddy Hosting Tip &#8211; Using CURL On GoDaddy Shared&nbsp;Hosting</a></li><li><a
href='http://davidwalsh.name/download-urls-content-php-curl' rel='bookmark' title='Permanent Link: Download a URL&#8217;s Content Using PHP&nbsp;cURL'>Download a URL&#8217;s Content Using PHP&nbsp;cURL</a></li><li><a
href='http://davidwalsh.name/feedburner-reader-statistic-php-curl-feedburner-api' rel='bookmark' title='Permanent Link: Get Your FeedBurner Reader Statistic Using PHP cURL and the FeedBurner&nbsp;API'>Get Your FeedBurner Reader Statistic Using PHP cURL and the FeedBurner&nbsp;API</a></li><li><a
href='http://davidwalsh.name/execute-http-post-php-curl' rel='bookmark' title='Permanent Link: Execute a HTTP POST Using PHP&nbsp;CURL'>Execute a HTTP POST Using PHP&nbsp;CURL</a></li></ol>]]></description> <content:encoded><![CDATA[<p>I recently developed a complex system for a customer that involved PHP, cURL, and a SSL connection to a third party vendor.  The third party vendor would validate the security certificate of the source (the system I created) and either allow or reject access.  My code looked like this:</p><pre class="php">
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'https://thirdparty.com/token.php'); //not the actual site
curl_setopt($ch,CURLOPT_TIMEOUT,60);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,'customer_id='.$cid.'&#038;password='.$pass);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,true); 
curl_setopt($ch,CURLOPT_CAINFO,'ca-bundle.crt'); /* problem here! */
$result = curl_exec($ch);
if(empty($result)) { /* error: nothing returned */ } else { /* success! */ }
curl_close($ch);
</pre><p>Unfortunately I was persistently receiving the following error message:</p><blockquote>error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed</blockquote><p> It turns out that the SSL bundle file I was using was old, as was the default bundle that came with the old version of cURL the shared hosting server.
Essentially the third party didn&#8217;t trust that the system&#8217;s SSL certificate was valid.
I downloaded <a
href="http://curl.haxx.se/docs/caextract.html">Mozilla&#8217;s bundle file</a>, named it <span
class="file">mozilla.pem</span> and changed my PHP code to:</p><pre class="php">
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'https://thirdparty.com/token.php'); //not the actual site
curl_setopt($ch,CURLOPT_TIMEOUT,60);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,'customer_id='.$cid.'&#038;password='.$pass);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,true); 
curl_setopt($ch,CURLOPT_CAINFO,'mozilla.pem'); /* fixed! */
$result = curl_exec($ch);
if(empty($result)) { /* error: nothing returned */ } else { /* success! */ }
curl_close($ch);
</pre><p>I share this with you because it cost me over three hours.  Hopefully this will save someone time and frustration in the future.</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/php-ssl-curl-error">PHP, SSL, and cURL SSL3_GET_SERVER_CERTIFICATE&nbsp;Errors</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/godaddy-curl-http-403-errors' rel='bookmark' title='Permanent Link: GoDaddy, cURL, HTTP, and 403&nbsp;Errors'>GoDaddy, cURL, HTTP, and 403&nbsp;Errors</a></li><li><a
href='http://davidwalsh.name/godaddy-hosting-curl' rel='bookmark' title='Permanent Link: GoDaddy Hosting Tip &#8211; Using CURL On GoDaddy Shared&nbsp;Hosting'>GoDaddy Hosting Tip &#8211; Using CURL On GoDaddy Shared&nbsp;Hosting</a></li><li><a
href='http://davidwalsh.name/download-urls-content-php-curl' rel='bookmark' title='Permanent Link: Download a URL&#8217;s Content Using PHP&nbsp;cURL'>Download a URL&#8217;s Content Using PHP&nbsp;cURL</a></li><li><a
href='http://davidwalsh.name/feedburner-reader-statistic-php-curl-feedburner-api' rel='bookmark' title='Permanent Link: Get Your FeedBurner Reader Statistic Using PHP cURL and the FeedBurner&nbsp;API'>Get Your FeedBurner Reader Statistic Using PHP cURL and the FeedBurner&nbsp;API</a></li><li><a
href='http://davidwalsh.name/execute-http-post-php-curl' rel='bookmark' title='Permanent Link: Execute a HTTP POST Using PHP&nbsp;CURL'>Execute a HTTP POST Using PHP&nbsp;CURL</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/php-ssl-curl-error/feed</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>SSLmatic: Quality, Cheap SSL Certificates and&#160;Giveaway!</title><link>http://davidwalsh.name/sslmatic-ssl-certificates</link> <comments>http://davidwalsh.name/sslmatic-ssl-certificates#comments</comments> <pubDate>Tue, 28 Apr 2009 11:45:04 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Security]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=2158</guid> <description><![CDATA[If you develop eCommerce websites or create applications that request sensitive user information, you&#8217;re probably well aware of the advantages of using SSL certificates. For those that haven&#8217;t, SSL certificates: Encrypt data between the user&#8217;s browser and the web server. Provide peace of mind to users giving their information. Are required by credit card companies [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/sslmatic-ssl-certificates">SSLmatic: Quality, Cheap SSL Certificates and&nbsp;Giveaway!</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/sslmatic-ssl-certificate-winners' rel='bookmark' title='Permanent Link: SSLmatic SSL Certificate Giveaway&nbsp;Winners'>SSLmatic SSL Certificate Giveaway&nbsp;Winners</a></li><li><a
href='http://davidwalsh.name/web-service-php-mysql-xml-json' rel='bookmark' title='Permanent Link: Create a Basic Web Service Using PHP, MySQL, XML, and&nbsp;JSON'>Create a Basic Web Service Using PHP, MySQL, XML, and&nbsp;JSON</a></li><li><a
href='http://davidwalsh.name/force-secure-page-php' rel='bookmark' title='Permanent Link: Force A Secure Page Using&nbsp;PHP'>Force A Secure Page Using&nbsp;PHP</a></li><li><a
href='http://davidwalsh.name/google-wave-invites' rel='bookmark' title='Permanent Link: Google Wave Invites&nbsp;Giveaway'>Google Wave Invites&nbsp;Giveaway</a></li><li><a
href='http://davidwalsh.name/php-ssl-curl-error' rel='bookmark' title='Permanent Link: PHP, SSL, and cURL SSL3_GET_SERVER_CERTIFICATE&nbsp;Errors'>PHP, SSL, and cURL SSL3_GET_SERVER_CERTIFICATE&nbsp;Errors</a></li></ol>]]></description> <content:encoded><![CDATA[<a
href="http://www.sslmatic.com"><img
src="http://davidwalsh.name/dw-content/sslmatic.jpg" alt="The SSLmatic process" class="image" /></a><p>If you develop  eCommerce websites or create applications that request sensitive user information, you&#8217;re probably well aware of the advantages of using SSL certificates. For those that haven&#8217;t, SSL certificates:</p><ul><li>Encrypt data between the user&#8217;s browser and the web server.</li><li>Provide peace of mind to users giving their information.</li><li>Are required by credit card companies for vendors accepting credit card payment (even for vendors that have a website WITHOUT eCommerce.</li></ul><p>Purchasing a SSL certificate can be quite an investment.  Many vendors charge up to $400 per certificate.  That&#8217;s right: <strong>$400</strong>!  Peace of mind and security are important but that doesn&#8217;t mean that SSL certificates should put a dent in your budget.  Enter a great SSL certificate vendor called <a
href="http://www.sslmatic.com/">SSLmatic</a>.</p><p>SSLmatic provides <a
href="http://www.sslmatic.com">cheap SSL certificates</a> for as low as $20/year.  You&#8217;d think that for that cost you&#8217;d get a no-name, generic certificate but that&#8217;s not the case.  SSLmatic provides SSL certificates for some of the web&#8217;s largest SSL vendors:</p><table
cellpadding="0" cellspacing="0" class="poll-results"><tr><th>Provider</th><th>Regular Price/Year</th><th>SSLmatic Price</th></tr><tr><td>RapidSSL</td><td>$80</td><td>$19.99</td></tr><tr><td>GeoTrust</td><td>$299</td><td>$99.99</td></tr><tr><td>Verisign</td><td>$399</td><td>$349.99</td></tr></table><p>SSLmatic also simplifies the SSL certificate request process.  Here&#8217;s how it works:</p><p><a
href="http://www.sslmatic.com"><img
src="http://davidwalsh.name/dw-content/sslmatic-process.jpg" alt="The SSLmatic process" /></a></p><p>Already have a security certificate?  No problem!  SSLmatic also offers renewal certificates.  As always SSLmatic allows you to lock in your SSL certificate for just one year or up to five years.  For more information on specific policies, <a
href="http://www.sslmatic.com/">check out the SSLmatic website</a>.</p><p>SSLmatic asked me to try their service and it was by far the easiest non-hosting-provider-forces-you-to-use-them-so-they-hold-you-hostage SSL certificate process I&#8217;ve ever completed.  I answered a couple quick questions, provided SSLmatic a CSR, and in no-time I had my SSL certificate waiting for me in my inbox.  From there I was able to navigate to my Plesk administrative panel, plug in my SSL certificate, and I was done.  No hassle &#8212; just plug and play.  Sweet!</p><h2>SSLmatic SSL Certificate Giveaway!  Yep &#8212; Free RapidSSL&nbsp;Certificates!</h2><p>SSLmatic would like five David Walsh Blog readers to give their service a shot.  Want to be one of the chosen five?  Easy and fun.  In a comment below, post your favorite actor/actress&#8217; name with &#8220;FTW&#8221; after it.  For example:</p><blockquote>Christina Ricci FTW!</blockquote><p>Winners will be chosen at random and posted Friday.  Thank you to <a
href="http://www.sslmatic.com/">SSLmatic</a> for this opportunity and good luck to everyone that comments!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/sslmatic-ssl-certificates">SSLmatic: Quality, Cheap SSL Certificates and&nbsp;Giveaway!</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/sslmatic-ssl-certificate-winners' rel='bookmark' title='Permanent Link: SSLmatic SSL Certificate Giveaway&nbsp;Winners'>SSLmatic SSL Certificate Giveaway&nbsp;Winners</a></li><li><a
href='http://davidwalsh.name/web-service-php-mysql-xml-json' rel='bookmark' title='Permanent Link: Create a Basic Web Service Using PHP, MySQL, XML, and&nbsp;JSON'>Create a Basic Web Service Using PHP, MySQL, XML, and&nbsp;JSON</a></li><li><a
href='http://davidwalsh.name/force-secure-page-php' rel='bookmark' title='Permanent Link: Force A Secure Page Using&nbsp;PHP'>Force A Secure Page Using&nbsp;PHP</a></li><li><a
href='http://davidwalsh.name/google-wave-invites' rel='bookmark' title='Permanent Link: Google Wave Invites&nbsp;Giveaway'>Google Wave Invites&nbsp;Giveaway</a></li><li><a
href='http://davidwalsh.name/php-ssl-curl-error' rel='bookmark' title='Permanent Link: PHP, SSL, and cURL SSL3_GET_SERVER_CERTIFICATE&nbsp;Errors'>PHP, SSL, and cURL SSL3_GET_SERVER_CERTIFICATE&nbsp;Errors</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/sslmatic-ssl-certificates/feed</wfw:commentRss> <slash:comments>109</slash:comments> </item> <item><title>Email Protection with MooTools&#160;JavaScript</title><link>http://davidwalsh.name/email-protection-mootools-javascript</link> <comments>http://davidwalsh.name/email-protection-mootools-javascript#comments</comments> <pubDate>Wed, 10 Sep 2008 12:46:30 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[MooTools]]></category> <category><![CDATA[Security]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=371</guid> <description><![CDATA[Important Note: This article has been updated here. We all know how spammers write scripts to slurp pages and collect as many emails as they possibly can, right? Well, I&#8217;ve created a really easy way to avoid this problem using MooTools JavaScript. Let me show you the process. The&#160;XHTML &#60;a href="/david&#124;davidwalsh.name" class="email" title="Email me."&#62;David Walsh&#60;/a&#62; [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/email-protection-mootools-javascript">Email Protection with MooTools&nbsp;JavaScript</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/email-protection-mootools-javascript-v2' rel='bookmark' title='Permanent Link: Email Protection with MooTools JavaScript&nbsp;v2'>Email Protection with MooTools JavaScript&nbsp;v2</a></li><li><a
href='http://davidwalsh.name/creating-advanced-xhtml-email-links-include-subject-cc-bcc-email-body' rel='bookmark' title='Permanent Link: Creating Advanced XHTML Email Links:  Include Subject, CC, BCC, and Email&nbsp;Body'>Creating Advanced XHTML Email Links:  Include Subject, CC, BCC, and Email&nbsp;Body</a></li><li><a
href='http://davidwalsh.name/php-email-encode-prevent-spam' rel='bookmark' title='Permanent Link: PHP Email Encoder &#8211; Prevent Spam Bots From Collecting Email&nbsp;Addresses'>PHP Email Encoder &#8211; Prevent Spam Bots From Collecting Email&nbsp;Addresses</a></li><li><a
href='http://davidwalsh.name/php-email-validator-mx-dns-record-check' rel='bookmark' title='Permanent Link: PHP Email Validator &#8211; Email MX DNS Record&nbsp;Check'>PHP Email Validator &#8211; Email MX DNS Record&nbsp;Check</a></li><li><a
href='http://davidwalsh.name/read-email' rel='bookmark' title='Permanent Link: You Know How I Know You Read My&nbsp;Email?'>You Know How I Know You Read My&nbsp;Email?</a></li></ol>]]></description> <content:encoded><![CDATA[<div
class="guest-blogger-top"><p><b>Important Note:</b> This article has been updated <a
href="http://davidwalsh.name/email-protection-mootools-javascript-v2">here</a>.</p></div><p>We all know how spammers write scripts to slurp pages and collect as many emails as they possibly can, right?  Well, I&#8217;ve created a really easy way to avoid this problem using MooTools JavaScript.  Let me show you the process.</p><h2>The&nbsp;XHTML</h2><pre  class="html">
	&lt;a href="/david|davidwalsh.name" class="email" title="Email me."&gt;David Walsh&lt;/a&gt;
</pre><p>We create a link with the CSS class &#8220;email&#8221;.  The email address is inside the href attribute, but the &#8220;@&#8221; is replaced with &#8220;|&#8221;.  Worthless to a spammer&#8217;s slurp script.  The href&#8217;s beginning &#8220;/&#8221; is an IE workaround.</p><h2>The MooTools&nbsp;JavaScript</h2><pre  class="js">
$$('.email').each(function(el) { 
	el.set('href','mailto:' + el.get('href').replace('|','@').replace('/','')); 
});
</pre><p> Once the DOM is ready (as always), we grab each link with the <span
class="param">email</span> class.
We take each link&#8217;s <span
class="param">href</span> (the modified email address) and reformat the address
so that it acts as a normal email link.</p><p> Have a better solution?  Share it!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/email-protection-mootools-javascript">Email Protection with MooTools&nbsp;JavaScript</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/email-protection-mootools-javascript-v2' rel='bookmark' title='Permanent Link: Email Protection with MooTools JavaScript&nbsp;v2'>Email Protection with MooTools JavaScript&nbsp;v2</a></li><li><a
href='http://davidwalsh.name/creating-advanced-xhtml-email-links-include-subject-cc-bcc-email-body' rel='bookmark' title='Permanent Link: Creating Advanced XHTML Email Links:  Include Subject, CC, BCC, and Email&nbsp;Body'>Creating Advanced XHTML Email Links:  Include Subject, CC, BCC, and Email&nbsp;Body</a></li><li><a
href='http://davidwalsh.name/php-email-encode-prevent-spam' rel='bookmark' title='Permanent Link: PHP Email Encoder &#8211; Prevent Spam Bots From Collecting Email&nbsp;Addresses'>PHP Email Encoder &#8211; Prevent Spam Bots From Collecting Email&nbsp;Addresses</a></li><li><a
href='http://davidwalsh.name/php-email-validator-mx-dns-record-check' rel='bookmark' title='Permanent Link: PHP Email Validator &#8211; Email MX DNS Record&nbsp;Check'>PHP Email Validator &#8211; Email MX DNS Record&nbsp;Check</a></li><li><a
href='http://davidwalsh.name/read-email' rel='bookmark' title='Permanent Link: You Know How I Know You Read My&nbsp;Email?'>You Know How I Know You Read My&nbsp;Email?</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/email-protection-mootools-javascript/feed</wfw:commentRss> <slash:comments>30</slash:comments> </item> <item><title>Whitelisting:  You Set The Rules For&#160;Security</title><link>http://davidwalsh.name/whitelisting-set-rules-security</link> <comments>http://davidwalsh.name/whitelisting-set-rules-security#comments</comments> <pubDate>Tue, 17 Jun 2008 12:20:16 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[Security]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=287</guid> <description><![CDATA[We all know what blacklisting is when it comes to strings: removing specified &#8220;bad&#8221; characters. While this helps to secure user input, it isn&#8217;t as secure as whitelisting. Whitelisting is the process of saying &#8220;Let me tell you what you can give me&#8221; whereas blacklisting says &#8220;If I find this, I&#8217;ll remove it.&#8221; A customer [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/whitelisting-set-rules-security">Whitelisting:  You Set The Rules For&nbsp;Security</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/username-validation-php' rel='bookmark' title='Permanent Link: Simple Username Creation Validation with&nbsp;PHP'>Simple Username Creation Validation with&nbsp;PHP</a></li><li><a
href='http://davidwalsh.name/htaccess-security-include-files' rel='bookmark' title='Permanent Link: Advanced .htaccess Security &#8211; Block Access to Include Files Using&nbsp;.htaccess'>Advanced .htaccess Security &#8211; Block Access to Include Files Using&nbsp;.htaccess</a></li><li><a
href='http://davidwalsh.name/generate-search-engine-friendly-urls-php-function' rel='bookmark' title='Permanent Link: Generate Search Engine Friendly URLs with PHP&nbsp;Functions'>Generate Search Engine Friendly URLs with PHP&nbsp;Functions</a></li><li><a
href='http://davidwalsh.name/htaccess-security-allow-block-ips' rel='bookmark' title='Permanent Link: Advanced .htaccess Security &#8211; Allow or Block Specific IPs From Your&nbsp;Website'>Advanced .htaccess Security &#8211; Allow or Block Specific IPs From Your&nbsp;Website</a></li><li><a
href='http://davidwalsh.name/javascript-unique-letters-string' rel='bookmark' title='Permanent Link: JavaScript Exercise: Find the Number of Unique Letters in a&nbsp;String'>JavaScript Exercise: Find the Number of Unique Letters in a&nbsp;String</a></li></ol>]]></description> <content:encoded><![CDATA[<p>We all know what blacklisting is when it comes to strings:  removing specified &#8220;bad&#8221; characters. While this helps to secure user input, it isn&#8217;t as secure as whitelisting.  Whitelisting is the process of saying &#8220;Let me tell you what you can give me&#8221; whereas blacklisting says &#8220;If I find this, I&#8217;ll remove it.&#8221;</p><p>A customer recently asked that I create a whitelisting function that allowed letters, digits, whitespace characters, periods, commas, and dashes.  Any other characters were to be replaced with spaces.</p><h2>The&nbsp;PHP</h2><pre  class="php">
function make_valid($input) 
{ 
	return preg_replace('/[^A-Za-z0-9.,\(\)\s-]/',' ',$input); 
}
</pre><p>The above function uses preg_match() and a small regular expression to remove the rubbish characters.</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/whitelisting-set-rules-security">Whitelisting:  You Set The Rules For&nbsp;Security</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/username-validation-php' rel='bookmark' title='Permanent Link: Simple Username Creation Validation with&nbsp;PHP'>Simple Username Creation Validation with&nbsp;PHP</a></li><li><a
href='http://davidwalsh.name/htaccess-security-include-files' rel='bookmark' title='Permanent Link: Advanced .htaccess Security &#8211; Block Access to Include Files Using&nbsp;.htaccess'>Advanced .htaccess Security &#8211; Block Access to Include Files Using&nbsp;.htaccess</a></li><li><a
href='http://davidwalsh.name/generate-search-engine-friendly-urls-php-function' rel='bookmark' title='Permanent Link: Generate Search Engine Friendly URLs with PHP&nbsp;Functions'>Generate Search Engine Friendly URLs with PHP&nbsp;Functions</a></li><li><a
href='http://davidwalsh.name/htaccess-security-allow-block-ips' rel='bookmark' title='Permanent Link: Advanced .htaccess Security &#8211; Allow or Block Specific IPs From Your&nbsp;Website'>Advanced .htaccess Security &#8211; Allow or Block Specific IPs From Your&nbsp;Website</a></li><li><a
href='http://davidwalsh.name/javascript-unique-letters-string' rel='bookmark' title='Permanent Link: JavaScript Exercise: Find the Number of Unique Letters in a&nbsp;String'>JavaScript Exercise: Find the Number of Unique Letters in a&nbsp;String</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/whitelisting-set-rules-security/feed</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>AJAX For Evil:&#160;Spyjax</title><link>http://davidwalsh.name/ajax-evil-spyjax</link> <comments>http://davidwalsh.name/ajax-evil-spyjax#comments</comments> <pubDate>Wed, 04 Jun 2008 12:47:07 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[Security]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=277</guid> <description><![CDATA[With great power comes great responsibility. With every advancement in technology we face the threat of it being used for evil purposes. This is the case with AJAX. AJAX has a ton of great uses but one form of negative AJAX has taken life: Spyjax. Spyjax, as I know it, is taking information from the [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/ajax-evil-spyjax">AJAX For Evil:&nbsp;Spyjax</a></p>No related posts.]]></description> <content:encoded><![CDATA[<p>With great power comes great responsibility.  With every advancement in technology we face the threat of it being used for evil purposes.  This is the case with AJAX.  AJAX has a ton of great uses but one form of negative AJAX has taken life:  Spyjax.</p><p>Spyjax, as I know it, is taking information from the user&#8217;s computer for your own use &#8212; specifically their browsing habits.  By using CSS and JavaScript, I can inject anchor links into the page and tell whether you&#8217;ve been to the link&#8217;s URL.  How?  Quite easy actually.</p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/spyjax.php" class="demo">Basic Demo</a> <a
href="http://davidwalsh.name/dw-content/spyjax-advanced.php" class="demo">Advanced Demo</a><div
class="clear"></div></div><h2>The&nbsp;CSS</h2><pre class="css" >a.checkme			{ color:#0ff0; }
a.checkme:visited	{ color:#f00; }
.highlight			{ background:#fffea1; }</pre><p>The most important part is making sure the <span
class="param">:visited</span> link color is different than the standard link color.  In this case, I&#8217;m using red.</p><h2>The&nbsp;JavaScript</h2><pre class="js" >&lt;?php 
	$sites = array(
							'davidwalsh.name',
							'css-tricks.com',
							'snook.ca',
							'cnn.com',
							'digg.com',
							'flickr.com',
							'php.net',
							'reddit.com',
							'yahoo.com',
							'google.com',
							'msn.com',
							'gmail.com',
							'ajaxian.com',
							'imdb.com',
							'mootools.net',
							'jquery.com',
							'wordpress.org',
							'dlisted.com',
							'foxnews.com',
							'dzone.com',
							'nettuts.com',
							'youtube.com',
							'diggnation.com',
							'collegehumor.com',
							'facebook.com',
							'myspace.com'
						);
	$site_string = implode('\',\'',$sites);
	
?&gt;
//inject!
$('tell-me').addEvent('click', function() {
	
	var urls = ['&lt;?php echo $site_string; ?&gt;'];
	var known = [];
	urls.each(function(url) {
		var anchor = new Element('a', {
			'href': 'http://' + url,
			'class':'checkme',
			'html':url,
			'styles' : {
				'display': 'none'
			}
		}).inject($('body'));
		if(anchor.getStyle('color') == '#ff0000') {
			known.include(anchor.get('text'));
		}
	});
	
	alert(known.length ? 'Found ' + known.length + ': ' + known.join(', ') + '.  Time to record this using AJAX.'  : 'Lucky you, I didn\'t find any!');
});
});</pre><p>The JavaScript is really done into parts.  The first part is injecting the links into the page, the second part is pulling the link&#8217;s text color from our injected elements.  You&#8217;d think it would be harder, huh?  Nope!</p><p>Spyjax isn&#8217;t as evil as stealing credit card information or social security numbers but it can be an invasion of privacy.  One use I&#8217;ve seen for Spyjax has been checking to see if a user&#8217;s been to Digg.  If so, show the &#8220;Digg This&#8221; button.  If not, check for Reddit, DZone, and so on.</p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/spyjax.php" class="demo">Basic Demo</a> <a
href="http://davidwalsh.name/dw-content/spyjax-advanced.php" class="demo">Advanced Demo</a><div
class="clear"></div></div><p>What are your thoughts on this practice?</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/ajax-evil-spyjax">AJAX For Evil:&nbsp;Spyjax</a></p><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/ajax-evil-spyjax/feed</wfw:commentRss> <slash:comments>54</slash:comments> </item> <item><title>Tips for Protecting Querystring Keys &amp; Values in&#160;PHP</title><link>http://davidwalsh.name/tips-protecting-querystring-keys-values-php</link> <comments>http://davidwalsh.name/tips-protecting-querystring-keys-values-php#comments</comments> <pubDate>Tue, 27 May 2008 12:58:05 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[Security]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=271</guid> <description><![CDATA[The easiest way to pass information to a page is by placing information in the URL. This, of course, is referred to as the querystring and the information in the querystring can be accessed by using $_GET['varname']. Simple, yes. Insecure, possibly. Here are some guidelines for managing querystring information. Typecast Value when Expecting&#160;Numbers When you&#8217;re [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/tips-protecting-querystring-keys-values-php">Tips for Protecting Querystring Keys &#038; Values in&nbsp;PHP</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/php-validatie-numeric-digits' rel='bookmark' title='Permanent Link: PHP:  Validating Numeric Values and&nbsp;Digits'>PHP:  Validating Numeric Values and&nbsp;Digits</a></li><li><a
href='http://davidwalsh.name/return-multiple-values-from-ajax-using-mootools' rel='bookmark' title='Permanent Link: Return Multiple Values From AJAX Using MooTools and&nbsp;PHP'>Return Multiple Values From AJAX Using MooTools and&nbsp;PHP</a></li><li><a
href='http://davidwalsh.name/css-variables-php-dynamic' rel='bookmark' title='Permanent Link: CSS Variables Using&nbsp;PHP'>CSS Variables Using&nbsp;PHP</a></li><li><a
href='http://davidwalsh.name/web-service-php-mysql-xml-json' rel='bookmark' title='Permanent Link: Create a Basic Web Service Using PHP, MySQL, XML, and&nbsp;JSON'>Create a Basic Web Service Using PHP, MySQL, XML, and&nbsp;JSON</a></li><li><a
href='http://davidwalsh.name/mootools-onload-smoothscroll' rel='bookmark' title='Permanent Link: MooTools onLoad&nbsp;SmoothScrolling'>MooTools onLoad&nbsp;SmoothScrolling</a></li></ol>]]></description> <content:encoded><![CDATA[<p>The easiest way to pass information to a page is by placing information in the URL.  This, of course, is referred to as the querystring and the information in the querystring can be accessed by using <span
class="var">$_GET['varname']</span>.  Simple, yes.  Insecure, possibly.  Here are some guidelines for managing querystring information.</p><h2>Typecast Value when Expecting&nbsp;Numbers</h2><p>When you&#8217;re expecting an integer in the querystring, typecast the value before using it.  This prevents string values from causing you problems.</p><pre  class="php">
$id = (int) $_GET['i'];
</pre><h2>Sanitize&nbsp;Input</h2><p>Build a basic function for each type of variable you are passing that you can use throughout your website.  That ensures consistency and security.</p><h2>Make Sure REGISTER_GLOBALS is&nbsp;Off</h2><p>Stating the obvious of course, but having REGISTER_GLOBALS on is a major problem.  Make sure it&#8217;s turned off.</p><h2>Don&#8217;t Make Variable Names&nbsp;Meaningful</h2><p>Lets just say that having a <span
class="var">$_GET</span> variable with the name of &#8216;user_id&#8217; isn&#8217;t a good thing.  Change it to &#8216;u&#8217; or something different.</p><pre  class="html">
&lt;!-- no! --&gt;
&lt;a href="/profile.php?user_id=&lt;?php echo $user_id; ?&gt;"&gt;Your Profile&lt;/a&gt;
&lt;!-- yes! --&gt;
&lt;a href="/profile.php?q=&lt;?php echo $user_id; ?&gt;"&gt;Your Profile&lt;/a&gt;
</pre><h2>Encrypt Querystring&nbsp;Values</h2><p>If you need to pass sensitive information from page to page, use at least a basic encryption algorythym or an md5.</p><pre  class="php">
&lt;a href="/profile.php?i=&lt;?php echo dw_encrypt($user_id); ?&gt;"&gt;Click here&lt;/a&gt;
</pre><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/tips-protecting-querystring-keys-values-php">Tips for Protecting Querystring Keys &#038; Values in&nbsp;PHP</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/php-validatie-numeric-digits' rel='bookmark' title='Permanent Link: PHP:  Validating Numeric Values and&nbsp;Digits'>PHP:  Validating Numeric Values and&nbsp;Digits</a></li><li><a
href='http://davidwalsh.name/return-multiple-values-from-ajax-using-mootools' rel='bookmark' title='Permanent Link: Return Multiple Values From AJAX Using MooTools and&nbsp;PHP'>Return Multiple Values From AJAX Using MooTools and&nbsp;PHP</a></li><li><a
href='http://davidwalsh.name/css-variables-php-dynamic' rel='bookmark' title='Permanent Link: CSS Variables Using&nbsp;PHP'>CSS Variables Using&nbsp;PHP</a></li><li><a
href='http://davidwalsh.name/web-service-php-mysql-xml-json' rel='bookmark' title='Permanent Link: Create a Basic Web Service Using PHP, MySQL, XML, and&nbsp;JSON'>Create a Basic Web Service Using PHP, MySQL, XML, and&nbsp;JSON</a></li><li><a
href='http://davidwalsh.name/mootools-onload-smoothscroll' rel='bookmark' title='Permanent Link: MooTools onLoad&nbsp;SmoothScrolling'>MooTools onLoad&nbsp;SmoothScrolling</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/tips-protecting-querystring-keys-values-php/feed</wfw:commentRss> <slash:comments>12</slash:comments> </item> <item><title>.htaccess &#8220;Down For Maintenance&#8221; Page&#160;Redirect</title><link>http://davidwalsh.name/htaccess-maintenance-page-redirect</link> <comments>http://davidwalsh.name/htaccess-maintenance-page-redirect#comments</comments> <pubDate>Thu, 22 May 2008 12:59:17 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[.htaccess]]></category> <category><![CDATA[Security]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=245</guid> <description><![CDATA[I recently needed to move one website from a shared web host to our internal server. After some discussion, we decided to simply add a &#8220;Site Down For Maintenance&#8221; page to the site to prevent users from submitting orders during the hosting change. Using the following .htaccess code snippet, we were able to send all [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/htaccess-maintenance-page-redirect">.htaccess &#8220;Down For Maintenance&#8221; Page&nbsp;Redirect</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/no-www-using-htaccess-file' rel='bookmark' title='Permanent Link: No WWW Using&nbsp;.htaccess'>No WWW Using&nbsp;.htaccess</a></li><li><a
href='http://davidwalsh.name/force-secure-ssl-htaccess' rel='bookmark' title='Permanent Link: Force Secure (SSL) Pages With&nbsp;.htaccess'>Force Secure (SSL) Pages With&nbsp;.htaccess</a></li><li><a
href='http://davidwalsh.name/mod_rewrite-htaccess-godaddy' rel='bookmark' title='Permanent Link: Fixing mod_rewrite and .htaccess on GoDaddy&nbsp;Hosting'>Fixing mod_rewrite and .htaccess on GoDaddy&nbsp;Hosting</a></li><li><a
href='http://davidwalsh.name/prevent-image-hotlinking' rel='bookmark' title='Permanent Link: Prevent Image Hotlinking With .htaccess and&nbsp;mod_rewrite'>Prevent Image Hotlinking With .htaccess and&nbsp;mod_rewrite</a></li><li><a
href='http://davidwalsh.name/advanced-htaccess-security-block-unwanted-referrers' rel='bookmark' title='Permanent Link: Advanced .htaccess Security &#8211; Block Unwanted&nbsp;Referrers'>Advanced .htaccess Security &#8211; Block Unwanted&nbsp;Referrers</a></li></ol>]]></description> <content:encoded><![CDATA[<p>I recently needed to move one website from a shared web host to our internal server.  After some discussion, we decided to simply add a &#8220;Site Down For Maintenance&#8221; page to the site to prevent users from submitting orders during the hosting change.  Using the following <span
class="file">.htaccess</span> code snippet, we were able to send all users to a <span
class="file">maintenance.html</span> page no matter which page they requested:</p><pre  class="js">
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://domain.com/maintenance.html [R=307,L]
</pre><p>Once we posted the <span
class="file">maintenance.html</span> page and <span
class="file">.htaccess</span> code on both the old hosting environment AND new hosting environment, we switched the DNS settings.  Before making the switch, we had ported the website&#8217;s code to a &#8220;utility&#8221; domain and made adjustments so that the website would function well in the new hosting environment.  Now that the DNS had been changed, we wanted to make sure that the website would function well on the new domain within the new hosting environment.  Unfortunately the code above blocks EVERYONE from accessing any file besides the <span
class="file">maintenance.html</span> file.  Fortunately my gifted IT team had the answer:</p><pre  class="js">
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^11\.111\.111\.111
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://domain.com/maintenance.html [R=307,L]
</pre><p>The above code sends all users to <span
class="file">maintenance.html</span> EXCEPT those with the specified IP, which just so happened to be us.  We got to test the website while others were locked out. When we were satisfied with the website, we removed the <span
class="file">.htaccess</span> code and the site was back up immediately!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/htaccess-maintenance-page-redirect">.htaccess &#8220;Down For Maintenance&#8221; Page&nbsp;Redirect</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/no-www-using-htaccess-file' rel='bookmark' title='Permanent Link: No WWW Using&nbsp;.htaccess'>No WWW Using&nbsp;.htaccess</a></li><li><a
href='http://davidwalsh.name/force-secure-ssl-htaccess' rel='bookmark' title='Permanent Link: Force Secure (SSL) Pages With&nbsp;.htaccess'>Force Secure (SSL) Pages With&nbsp;.htaccess</a></li><li><a
href='http://davidwalsh.name/mod_rewrite-htaccess-godaddy' rel='bookmark' title='Permanent Link: Fixing mod_rewrite and .htaccess on GoDaddy&nbsp;Hosting'>Fixing mod_rewrite and .htaccess on GoDaddy&nbsp;Hosting</a></li><li><a
href='http://davidwalsh.name/prevent-image-hotlinking' rel='bookmark' title='Permanent Link: Prevent Image Hotlinking With .htaccess and&nbsp;mod_rewrite'>Prevent Image Hotlinking With .htaccess and&nbsp;mod_rewrite</a></li><li><a
href='http://davidwalsh.name/advanced-htaccess-security-block-unwanted-referrers' rel='bookmark' title='Permanent Link: Advanced .htaccess Security &#8211; Block Unwanted&nbsp;Referrers'>Advanced .htaccess Security &#8211; Block Unwanted&nbsp;Referrers</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/htaccess-maintenance-page-redirect/feed</wfw:commentRss> <slash:comments>23</slash:comments> </item> <item><title>Force Secure (SSL) Pages With&#160;.htaccess</title><link>http://davidwalsh.name/force-secure-ssl-htaccess</link> <comments>http://davidwalsh.name/force-secure-ssl-htaccess#comments</comments> <pubDate>Fri, 09 May 2008 12:55:05 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[.htaccess]]></category> <category><![CDATA[Security]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=248</guid> <description><![CDATA[A while back, I shared a method for forcing a secure page using PHP. What if you want to force SSL (https://) on an entire website though? You don&#8217;t want to have to put force-SSL PHP code on every page, right? Well, the website&#8217;s .htaccess file comes to the rescue. The .htaccess&#160;Code RewriteEngine On RewriteCond [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/force-secure-ssl-htaccess">Force Secure (SSL) Pages With&nbsp;.htaccess</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/force-secure-page-php' rel='bookmark' title='Permanent Link: Force A Secure Page Using&nbsp;PHP'>Force A Secure Page Using&nbsp;PHP</a></li><li><a
href='http://davidwalsh.name/secure-ssl-google-analytics' rel='bookmark' title='Permanent Link: Secure (SSL) Google&nbsp;Analytics'>Secure (SSL) Google&nbsp;Analytics</a></li><li><a
href='http://davidwalsh.name/htaccess-maintenance-page-redirect' rel='bookmark' title='Permanent Link: .htaccess &#8220;Down For Maintenance&#8221; Page&nbsp;Redirect'>.htaccess &#8220;Down For Maintenance&#8221; Page&nbsp;Redirect</a></li><li><a
href='http://davidwalsh.name/htaccess-security-include-files' rel='bookmark' title='Permanent Link: Advanced .htaccess Security &#8211; Block Access to Include Files Using&nbsp;.htaccess'>Advanced .htaccess Security &#8211; Block Access to Include Files Using&nbsp;.htaccess</a></li><li><a
href='http://davidwalsh.name/no-www-using-htaccess-file' rel='bookmark' title='Permanent Link: No WWW Using&nbsp;.htaccess'>No WWW Using&nbsp;.htaccess</a></li></ol>]]></description> <content:encoded><![CDATA[<p>A while back, I shared a method for <a
href="http://davidwalsh.name/force-secure-page-php">forcing a secure page using PHP</a>.  What if you want to force SSL <em>(https://)</em> on an entire website though?  You don&#8217;t want to have to put force-SSL PHP code on every page, right?  Well, the website&#8217;s <span
class="file">.htaccess</span> file comes to the rescue.</p><h2>The .htaccess&nbsp;Code</h2><pre  class="js">
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://domain.com/$1 [R,L]</pre><p> Obviously, you&#8217;ll want to change &#8220;domain.com&#8221; to your domain.  Another short snippet of code that has a big impact on your website!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/force-secure-ssl-htaccess">Force Secure (SSL) Pages With&nbsp;.htaccess</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/force-secure-page-php' rel='bookmark' title='Permanent Link: Force A Secure Page Using&nbsp;PHP'>Force A Secure Page Using&nbsp;PHP</a></li><li><a
href='http://davidwalsh.name/secure-ssl-google-analytics' rel='bookmark' title='Permanent Link: Secure (SSL) Google&nbsp;Analytics'>Secure (SSL) Google&nbsp;Analytics</a></li><li><a
href='http://davidwalsh.name/htaccess-maintenance-page-redirect' rel='bookmark' title='Permanent Link: .htaccess &#8220;Down For Maintenance&#8221; Page&nbsp;Redirect'>.htaccess &#8220;Down For Maintenance&#8221; Page&nbsp;Redirect</a></li><li><a
href='http://davidwalsh.name/htaccess-security-include-files' rel='bookmark' title='Permanent Link: Advanced .htaccess Security &#8211; Block Access to Include Files Using&nbsp;.htaccess'>Advanced .htaccess Security &#8211; Block Access to Include Files Using&nbsp;.htaccess</a></li><li><a
href='http://davidwalsh.name/no-www-using-htaccess-file' rel='bookmark' title='Permanent Link: No WWW Using&nbsp;.htaccess'>No WWW Using&nbsp;.htaccess</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/force-secure-ssl-htaccess/feed</wfw:commentRss> <slash:comments>7</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 107/302 queries in 2.485 seconds using disk

Served from: davidwalsh.name @ 2010-09-02 23:27:39 -->