<?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>XprsYrslf &#187; Coding &#38; Web Design &#187; Javascript</title>
	<atom:link href="http://xprsyrslf.be/category/web-technology/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://xprsyrslf.be</link>
	<description>by Jeroen Op &#039;t Eynde</description>
	<lastBuildDate>Fri, 09 Apr 2010 03:42:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Contactform Plugin for WordPress</title>
		<link>http://xprsyrslf.be/2009/08/22/contactform-plugin-for-wordpress/</link>
		<comments>http://xprsyrslf.be/2009/08/22/contactform-plugin-for-wordpress/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 19:31:06 +0000</pubDate>
		<dc:creator>Jeroen</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://xprsyrslf.be/?p=423</guid>
		<description><![CDATA[I've worked on a plugin for WordPress, actually I have been rewriting the Contact Form Captcha plugin. I've tackled out the javascript bit for generating the captcha and added a few features to the email itself.]]></description>
			<content:encoded><![CDATA[<p><a href="http://xprsyrslf.be/wordpress/wp-content/uploads/2009/08/secure_email.png"><img class="alignright size-thumbnail wp-image-448" title="Secure Email" src="http://xprsyrslf.be/wordpress/wp-content/uploads/2009/08/secure_email-150x150.png" alt="Secure Email" width="150" height="150" /></a> I&#8217;ve worked on a plugin for WordPress, actually I have been rewriting the <a href="http://eazeenet.in/contact-form-with-captcha-plugin-for-wordpress/">Contact Form Captcha</a> plugin (also <a href="http://wordpress.org/extend/plugins/contact-form-captcha/">here</a> on WP Extend). I&#8217;ve tackled out the javascript bit for generating the captcha and added a few features to the email itself.</p>
<p>You can download it from <a href="http://xprsyrslf.be/wordpress/wp-content/uploads/2009/08/contactform.1.0.tar.gz">here</a>.</p>
<p>The code generated in the captcha will only contain alphabetic capitals between A &amp; Z, which is stronger, I&#8217;m not a security expert but 26<sup>6</sup> is a higher number than 10<sup>6</sup>. Instead of the javascript validation, it only uses server side validation. The boxes will get a red border to indicate if there was something wrong in there. This indication can be easily expanded in the source, maybe I&#8217;ll add that later. The code comparison will happen in a session, so no client side hacking possible.</p>
<p>Next big thing I did was the email validation check with regular expressions, I&#8217;ll talk more about that later. This validation should be foolproof and even checks if the domain has <a onclick="this.target='_blank'" href="http://en.wikipedia.org/wiki/MX_record">MX records</a>. Check out the function, it should be reusable in any project using PHP 4 or newer, please include credits. Code released under <a onclick="this.target='_blank'" href="http://creativecommons.org/licenses/by-sa/2.0/be/">Creative Commons Attribution-Share Alike 2.0 Belgium License</a></p>
<pre>function check_email($email) {
	//Function written by Jeroen Op 't Eynde - XprsYrslf.be
	//Creative Commons Attribution-Share Alike 2.0 Belgium License
	//Pattern from: http://fightingforalostcause.net/misc/2006/compare-email-regex.php
	$pattern = "/^[-a-z0-9~!$%^&amp;*_=+}{\'?]+(\.[-a-z0-9~!$%^&amp;*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|asia|cat|jobs|tel|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i";
	if (function_exists('checkdnsrr')){
		list($user,$domain) = split('@',$email);
		if(preg_match($pattern,$email) &amp;&amp; checkdnsrr($domain,"MX")) return $email; //Linux: PHP 4.3.0 &amp; Windows: PHP 5.3.0
		else return false;
	} else {
		if(preg_match($pattern,$email)) return $email; //PHP 4 or 5
		else return false;
	}
}</pre>
<p>I thank <a href="http://blog.tuxz.net/archives/2009/03/27/email_validation_using_regular_expression/">Alexandre De Dommelin</a> &amp; <a href="http://fightingforalostcause.net/misc/2006/compare-email-regex.php">Ian Dunn</a> for the regex research.</p>
<p>As I said, I&#8217;ve added a few features to the email that makes it more usable for different website&#8217;s. List of features:</p>
<ul>
<li>Date of Submission</li>
<li>Server&#8217;s Name (or Website&#8217;s Name)</li>
<li>IP address of person using the form</li>
<li>URL of page containing the form</li>
</ul>
<p>Like in the original plugin by Eazeenet, you can add &lt;!&#8211;contact form&#8211;&gt; anywhere you want to put it. But now it puts it exactly where you put the tag and not only below the text of that page.</p>
<p>That&#8217;s it. You can see an example of the contact form <a href="http://xprsyrslf.be/contact/">here</a>. You are free to test it with any hate mail you want. Any bugs and/or features can be reported as a reply to this post or via the contact form, of course.</p>
]]></content:encoded>
			<wfw:commentRss>http://xprsyrslf.be/2009/08/22/contactform-plugin-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable Input Box</title>
		<link>http://xprsyrslf.be/2008/11/22/javascript-disable-input-box/</link>
		<comments>http://xprsyrslf.be/2008/11/22/javascript-disable-input-box/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 19:35:17 +0000</pubDate>
		<dc:creator>Jeroen</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://localhost/~jeroen/wordpress/?p=109</guid>
		<description><![CDATA[Disable a html Input box without losing successful-controls with javascript:

&#60;form action="" method="post"&#62;
&#60;input type="text" readonly="readonly" onselect="this.blur()"
onfocus="this.blur()" name="SomeTextBox" value=""
style="background-color:lightgrey;cursor:default;"&#62;
&#60;input type="submit"&#62;
&#60;/form&#62;

]]></description>
			<content:encoded><![CDATA[<p>Disable a html Input box without losing <a href="http://www.w3.org/TR/html4/interact/forms.html#successful-controls" target="_blank">successful-controls</a> with javascript:<br />
<code><br />
&lt;form action="" method="post"&gt;<br />
&lt;input type="text" readonly="readonly" onselect="this.blur()"<br />
onfocus="this.blur()" name="SomeTextBox" value=""<br />
style="background-color:lightgrey;cursor:default;"&gt;<br />
&lt;input type="submit"&gt;<br />
&lt;/form&gt;</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://xprsyrslf.be/2008/11/22/javascript-disable-input-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>URL Parameters</title>
		<link>http://xprsyrslf.be/2008/11/02/javascript-url-parameters/</link>
		<comments>http://xprsyrslf.be/2008/11/02/javascript-url-parameters/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 23:10:52 +0000</pubDate>
		<dc:creator>Jeroen</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://localhost/~jeroen/wordpress/?p=116</guid>
		<description><![CDATA[Getting URL Parameters (original source):

function gup( name )
{
&#160;&#160;name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
&#160;&#160;var regexS = "[\\?&#038;]"+name+"=([^&#]*)";
&#160;&#160;var regex = new RegExp( regexS );
&#160;&#160;var results = regex.exec( window.location.href );
&#160;&#160;if( results == null )
&#160;&#160;&#160;&#160;return "";
&#160;&#160;else
&#160;&#160;&#160;&#160;return results[1];
}

Getting URL Hash Parameters (modified from original source):

function ghp( name )
{
&#160;&#160;name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
&#160;&#160;var regexS = "[\\#&#038;]"+name+"=([^&#]*)";
&#160;&#160;var regex = new RegExp( regexS );
&#160;&#160;var results = regex.exec( window.location.hash [...]]]></description>
			<content:encoded><![CDATA[<p>Getting URL Parameters <span class="small">(<a target="_blank" href="http://www.netlobo.com/url_query_string_javascript.html">original source</a>)</span>:<br />
<code><br />
function gup( name )<br />
{<br />
&nbsp;&nbsp;name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");<br />
&nbsp;&nbsp;var regexS = "[\\?&#038;]"+name+"=([^&#]*)";<br />
&nbsp;&nbsp;var regex = new RegExp( regexS );<br />
&nbsp;&nbsp;var results = regex.exec( window.location.href );<br />
&nbsp;&nbsp;if( results == null )<br />
&nbsp;&nbsp;&nbsp;&nbsp;return "";<br />
&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;return results[1];<br />
}<br />
</code><br />
Getting URL Hash Parameters <span class="small">(modified from <a target="_blank" href="http://www.netlobo.com/url_query_string_javascript.html">original source</a>)</span>:<br />
<code><br />
function ghp( name )<br />
{<br />
&nbsp;&nbsp;name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");<br />
&nbsp;&nbsp;var regexS = "[\\#&#038;]"+name+"=([^&#]*)";<br />
&nbsp;&nbsp;var regex = new RegExp( regexS );<br />
&nbsp;&nbsp;var results = regex.exec( window.location.hash );<br />
&nbsp;&nbsp;if( results == null )<br />
&nbsp;&nbsp;&nbsp;&nbsp;return "";<br />
&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;return results[1];<br />
}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://xprsyrslf.be/2008/11/02/javascript-url-parameters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
