<?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>That Matt &#187; Programming</title>
	<atom:link href="http://that-matt.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://that-matt.com</link>
	<description>That one, not this one!</description>
	<lastBuildDate>Tue, 25 Oct 2011 00:57:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>OSCommerce / Paypoint redirects to payment information after paying</title>
		<link>http://that-matt.com/2010/06/oscommerce-paypoint-redirects-to-payment-information-after-paying/</link>
		<comments>http://that-matt.com/2010/06/oscommerce-paypoint-redirects-to-payment-information-after-paying/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 19:52:05 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[oscommerce]]></category>
		<category><![CDATA[paypoint]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[secpay]]></category>

		<guid isPermaLink="false">http://sigswitch.com/?p=140</guid>
		<description><![CDATA[I was asked to do some work on an oscommerce site which was accepting payments from paypoint (formally secpay) yet instead of redirecting the user to the &#8220;Thank you for your order&#8221; page it was sending them to the payment &#8230; <a href="http://that-matt.com/2010/06/oscommerce-paypoint-redirects-to-payment-information-after-paying/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was asked to do some work on an oscommerce site which was accepting payments from <a href="http://paypoint.net">paypoint</a> (formally secpay) yet instead of redirecting the user to the &#8220;Thank you for your order&#8221; page it was sending them to the payment information page, and wasn&#8217;t classing the order as being paid for.</p>
<p>After a bit of debugging it turns out the problem stems from the paypoint-secpay merger and the fact that OSCommerce is a poorly supported hunk of junk.</p>
<p><span id="more-140"></span></p>
<p>During a typical transaction paypoint will ask the user for their card details, and if the details check out it sends a request back to OSCommerce telling it that the transaction was a success.  It will then display to the user whatever your server outputs.  Thus your customers should see the &#8220;Thank you for your order&#8221; page appear under a url of &#8220;https://www.secpay.com/java-bin/ValCard&#8221;.</p>
<p>When oscommerce receives the &#8220;the transaction succeeded&#8221; message from secpay it looks at the ip address the message came from, and tries to resolve it to a hostname to see if it came from secpay.com.</p>
<p>Since the merger the ip address that paypoint are using ﻿(in this case it was 81.93.226.30) doesn&#8217;t resolve to secpay.com, in fact <a href="http://whois.domaintools.com/reverse-ip/?hostname=81.93.226.30">it doesn&#8217;t resolve to anything</a>.  If php can&#8217;t resolve an ip address to a hostname then it gives up and returns the ip, thus oscommerce was trying to check that &#8216;secpay.com&#8217; was the same as &#8217;81.93.226.30&#8242;, which it isn&#8217;t.</p>
<p>To fix this I changed the before_process() method in the secpay payment module to look like so:</p>
<pre class="brush:php">function before_process() {

      if ($_POST['valid'] == 'true') {
          if ($remote_addr = $_SERVER['REMOTE_ADDR']) {
	      // Check that the request came from one of the secpay / paypoint servers
    	      if (strpos($remote_addr, '81.93.226') !== 0) {
        	    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, tep_session_name() . '=' . $HTTP_POST_VARS[tep_session_name()] . '&amp;payment_error=' . $this-&gt;code, 'SSL', false, false));
          }
        } else {
          tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, tep_session_name() . '=' . $HTTP_POST_VARS[tep_session_name()] . '&amp;payment_error=' . $this-&gt;code, 'SSL', false, false));
        }
      }
    }</pre>
<p>Ignoring for a second the horrible use of php3/php4 conventions, the method now checks to see if the sender&#8217;s ip address begins with 81.93.226, as <a href="http://whois.domaintools.com/81.93.226.30">paypoint seem to own</a> that range.</p>
<p>Hopefully this will save someone else the headache</p>
]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2010/06/oscommerce-paypoint-redirects-to-payment-information-after-paying/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updated textarea maxlength with Jquery plugin</title>
		<link>http://that-matt.com/2010/04/updated-textarea-maxlength-with-jquery-plugin/</link>
		<comments>http://that-matt.com/2010/04/updated-textarea-maxlength-with-jquery-plugin/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 15:08:19 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Html]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://sigswitch.com/?p=127</guid>
		<description><![CDATA[When I first wrote the &#8220;Textarea maxlength with jQuery&#8221; plugin last year I had no idea how popular it would be &#8211; over 70% of the visits to my site since then have been people reading that one post. The &#8230; <a href="http://that-matt.com/2010/04/updated-textarea-maxlength-with-jquery-plugin/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I first wrote the &#8220;Textarea maxlength with jQuery&#8221; plugin last year I had no idea how popular it would be &#8211; over 70% of the visits to my site since then have been people reading that one post.  The problem is, the code there is basically an ugly hack &#8211; you copy and paste and you&#8217;re done.  But if you need to implement the same functionality across a site with slight differences to the functionality, you&#8217;d end up with a lot of copy and paste garbage.  <span id="more-127"></span> So what with it being time for some spring cleaning I thought I&#8217;d begin by refactoring the original code into a jquery plugin:</p>
<pre class="brush:js">jQuery.fn.limitMaxlength = function(options){

	var settings = jQuery.extend({
		attribute: "maxlength",
		onLimit: function(){},
		onEdit: function(){}
	}, options);

	// Event handler to limit the textarea
	var onEdit = function(){
		var textarea = jQuery(this);
		var maxlength = parseInt(textarea.attr(settings.attribute));

		if(textarea.val().length &gt; maxlength){
			textarea.val(textarea.val().substr(0, maxlength));

			// Call the onlimit handler within the scope of the textarea
			jQuery.proxy(settings.onLimit, this)();
		}

		// Call the onEdit handler within the scope of the textarea
		jQuery.proxy(settings.onEdit, this)(maxlength - textarea.val().length);
	}

	this.each(onEdit);

	return this.keyup(onEdit)
				.keydown(onEdit)
				.focus(onEdit)
				.live('input paste', onEdit);
}</pre>
<p>And here&#8217;s an example of it in use, limiting all textareas in the document and updating a p element with the id of charsRemaining with&#8230; the number of characters remaining.  It also sets the textarea bg color to red when the user tries to exceed the maxlength.</p>
<pre class="brush:js">$(document).ready(function(){

	var onEditCallback = function(remaining){
		$(this).siblings('.charsRemaining').text("Characters remaining: " + remaining);

		if(remaining &gt; 0){
			$(this).css('background-color', 'white');
		}
	}

	var onLimitCallback = function(){
		$(this).css('background-color', 'red');
	}

	$('textarea[maxlength]').limitMaxlength({
		onEdit: onEditCallback,
		onLimit: onLimitCallback
	});
});</pre>
<p>And here&#8217;s a <a href="http://jsbin.com/ufuji3/9">jsbin paste with a quick demo</a>.  Although there is a lot more code in this version it&#8217;s a lot more flexible as it allows you to decide how to inform the user of how many characters there&#8217;re remaining.  It also means that it&#8217;ll take any characters already in the textbox into account when the document loads.</p>
<p><strong>Update 2010/04/09:</strong> Fixed a few bugs &amp; typos<br />
<strong>Update 2010/08/01:</strong> Removed problematic comma &amp; added live(&#8216;input paste&#8217;) &#8211; thanks Surya and Len!</p>
]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2010/04/updated-textarea-maxlength-with-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>Testing Kohana3 with PHPUnit</title>
		<link>http://that-matt.com/2009/12/testing-kohana3-with-phpunit/</link>
		<comments>http://that-matt.com/2009/12/testing-kohana3-with-phpunit/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 21:39:51 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[Kohana]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPUnit]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://sigswitch.com/?p=113</guid>
		<description><![CDATA[Unit testing is great, period. It allows you to test different parts of your application independently of the rest of the system.  Any changes that will cause problems elsewhere can be identified almost instantly (if you&#8217;re doing it right!). Up &#8230; <a href="http://that-matt.com/2009/12/testing-kohana3-with-phpunit/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Unit_testing">Unit testing</a> is great, period. It allows you to test different parts of your application independently of the rest of the system.  Any changes that will cause problems elsewhere can be identified almost instantly (if you&#8217;re doing it right!).</p>
<p>Up until recently <a href="http://github.com/kohana/kohana">Kohana3</a> was using a home-grown module for unit testing &#8211; It was ok, but lacked some of the more advanced features of independent testing suites &#8211; however now the project has now adopted PHPUnit as its <a href="http://github.com/kohana/unittest">official test framework</a>!  PHPUnit is one of the more popular testing suites for PHP, it has full support for <a href="http://www.phpunit.de/manual/3.1/en/fixtures.html">Fixtures</a>, <a href="http://www.phpunit.de/manual/3.1/en/mock-objects.html">Mock Objects</a>, <a href="http://www.phpunit.de/manual/3.1/en/code-coverage-analysis.html">Code Coverage</a> and a lot of other <a href="http://seleniumhq.org/">cool stuff</a>.</p>
<p>The module only requires a few changes to the bootstrap in order to integrate Kohana with PHPUnit, and afterwards you can run tests from the cli, IDE or our custom web runner.  All available tests are loaded from Kohana&#8217;s cascading filesystem and can be filtered using PHPUnit&#8217;s &#8211;group switch.</p>
<p>Go and <a href="http://github.com/kohana/unittest">git it</a> while it&#8217;s hot!</p>
]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2009/12/testing-kohana3-with-phpunit/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Kohana &#8211; the php framework</title>
		<link>http://that-matt.com/2008/10/kohana-the-php-framework/</link>
		<comments>http://that-matt.com/2008/10/kohana-the-php-framework/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 18:58:22 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Kohana]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://sigswitch.com/?p=7</guid>
		<description><![CDATA[I know I haven&#8217;t written anything here for quite a while, but I just wanted to make a quick post about this totally amazing awesome MVC php framework called kohana. It was originally a fork of codeigniter (Another good php &#8230; <a href="http://that-matt.com/2008/10/kohana-the-php-framework/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I know I haven&#8217;t written anything here for quite a while, but I just wanted to make a quick post about this totally <span style="text-decoration: line-through;">amazing</span> awesome MVC php framework called <a title="Kohana PHP Framework" href="http://kohanaphp.com">kohana</a>.  It was originally a fork of <a href="http://www.codeigniter.com">codeigniter</a> (Another good php framework, albeit php4 grounded at the moment), although it&#8217;s come a long way since then.<br />
<span id="more-7"></span><br />
It&#8217;s main feature (in my opinion) is it&#8217;s extensibility &#8211; You can override any file in the framework (bar some of the ones included by the bootstrap) simply by creating a file with the same name + the MY_ prefix in the application directory.</p>
<p><strong>For example</strong> &#8211; Say I want to change the Controller class so that it initiates the session in the constructor (It might be better to initiate the session in a hook of some kind, but it serves as a decent example here).</p>
<p>The default controller class is stored in</p>
<p><span style="font-family: -webkit-monospace;">system/libraries/Controller.php</span></p>
<p>To extend it I simply create the following file:</p>
<p><code>application/libraries/MY_Controller.php</code></p>
<p>And then I can simply create a class like so:</p>
<p>[sourcecode language="php"]<br />
<?php defined('SYSPATH') or die('No direct script access.');</p>
<p>Class Controller extends Controller_Core<br />
{<br />
	function __construct()<br />
	{<br />
		parent::__construct();</p>
<p>		//Init Session<br />
		Session::instance();<br />
	}<br />
}<br />
[/sourcecode]</p>
<p>And the class is extended!</p>
<p>Best of all, because Kohana allows you to transparently extend files all of your controllers which extend Controller will automatically use your modifications as well as the system's version of Controller.</p>
<p><em>note &#8211; you can only really extend a library once.  There are ways to get around this restriction, but it&#8217;s not really worth it.</em></p>
<p>You could also totally override the class by making a file called</p>
<p><code>application/libraries/Controller.php</code></p>
<p>In which you&#8217;d place<br />
[sourcecode language="php"]<br />
<?php defined('SYSPATH') or die('No direct script access.');</p>
<p>Class Controller_Core<br />
{<br />
	function __construct()<br />
	{<br />
		parent::__construct();</p>
<p>		//Init Session<br />
		Session::instance();<br />
	}<br />
}<br />
[/sourcecode]</p>
<p>If you do replace a core library, then make sure that you either remove all references to parts of the controller which are no longer available, or that you copy across the changes. </p>
<p>There are lots more tutorials available at <a href="http://learn.kohanaphp.com">http://learn.kohanaphp.com</a></p>
<p>Anyway, there&#8217;s much more cool stuff that <a href="http://kohanaphp.com">kohana</a> can do, so I&#8217;d deffinitely reccomend you give it a try <img src='http://that-matt.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Alex</p>
<p>P.S. Did I mention it&#8217;s free?</p>
]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2008/10/kohana-the-php-framework/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Textarea maxlength with Jquery</title>
		<link>http://that-matt.com/2008/07/textarea-maxlength-with-jquery/</link>
		<comments>http://that-matt.com/2008/07/textarea-maxlength-with-jquery/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 14:45:25 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Html]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://sigswitch.com/?p=6</guid>
		<description><![CDATA[The other day I was trying to find a way to limit the amount of characters that a user could enter into a textbox. For some reason you can&#8217;t set the maxlength attribute on textareas, so I decided to make &#8230; <a href="http://that-matt.com/2008/07/textarea-maxlength-with-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The other day I was trying to find a way to limit the amount of characters that a user could enter into a textbox.  For some reason you can&#8217;t set the maxlength attribute on textareas, so I decided to make this little jquery snippet that truncates a user&#8217;s input once they go past a certain limit.</p>
<p><span id="more-6"></span><br />
<strong>There&#8217;s an updated version of this script <a href="http://sigswitch.com/2010/04/updated-textarea-maxlength-with-jquery-plugin/">here</a></strong></p>
<p>Save this snippet in a js file:</p>
<pre class="brush:jscript">$(document).ready(function(){
	$('textarea[maxlength]').keyup(function(){
		var max = parseInt($(this).attr(’maxlength’));
		if($(this).val().length &gt; max){
			$(this).val($(this).val().substr(0, $(this).attr('maxlength')));
		}

		$(this).parent().find('.charsRemaining').html('You have ' + (max - $(this).val().length) + ' characters remaining');
	});
});</pre>
<p>Just download and include <a title="Jquery" href="http://www.jquery.com">jquery</a> like so:</p>
<pre class="brush:html"><script src="jquery.js " type="text/javascript"><!--mce:0--></script></pre>
<p>And then include the js file containing the above snippet</p>
<p>Then, to limit a textarea do this:</p>
<pre class="brush:html">
<textarea></textarea></pre>
<p>If you want to show the user the &#8216;You have x characters remaining&#8217; message, then append an element with the &#8216;charsRemaining&#8217; class, like so:</p>
<pre class="brush:html">
<textarea></textarea>

You have 255 characters remaining
</pre>
<p>You have to make sure that the p and textarea elements share the same parent, else the message won&#8217;t be updated.</p>
<p>Alex</p>
<p><strong>UPDATE:</strong> Thanks for the parseInt() tip <a href="http://jasonseney.tumblr.com/">Jason</a><br />
<strong>There&#8217;s an updated version of this script <a href="http://sigswitch.com/2010/04/updated-textarea-maxlength-with-jquery-plugin/">here</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2008/07/textarea-maxlength-with-jquery/feed/</wfw:commentRss>
		<slash:comments>55</slash:comments>
		</item>
	</channel>
</rss>

