<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Moggylaceous</title>
	
	<link>http://moggy.laceous.com</link>
	<description>If nothing we do matters, then all that matters is what we do.</description>
	<lastBuildDate>Sat, 06 Feb 2010 08:58:58 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Moggylaceous" /><feedburner:info uri="moggylaceous" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>Moggylaceous</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2FMoggylaceous" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FMoggylaceous" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2FMoggylaceous" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/Moggylaceous" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FMoggylaceous" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FMoggylaceous" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FMoggylaceous" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><item>
		<title>Semisecure Integration</title>
		<link>http://feedproxy.google.com/~r/Moggylaceous/~3/aoLI6dpOMkw/</link>
		<comments>http://moggy.laceous.com/2009/11/25/semisecure-integration/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 13:58:39 +0000</pubDate>
		<dc:creator>moggy</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://moggy.laceous.com/?p=227</guid>
		<description><![CDATA[Semisecure Login Reimagined supports 3rd-party integration. This might be useful if you have a custom plugin/widget that allows you to submit a password to login (or for registration). Information on how the integration works can be found on the plugin&#8217;s settings page. Up until now I haven&#8217;t seen any complete examples. To fill the gap, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://moggy.laceous.com/2009/09/05/semisecure-login-reimagined-v3/">Semisecure Login Reimagined</a> supports 3rd-party integration. This might be useful if you have a custom plugin/widget that allows you to submit a password to login (or for registration). Information on how the integration works can be found on the plugin&#8217;s settings page. Up until now I haven&#8217;t seen any complete examples. To fill the gap, here&#8217;s a complete example using the <a href="http://wordpress.org/extend/plugins/register-plus/">Register Plus</a> plugin (which allows you to enter your own password when registering):</p>
<p>(This should only be considered a reference; I&#8217;m not supporting the following plugin)</p>
<pre>
&lt;?php
/*
Plugin Name: SemisecureLoginReimagined-RegisterPlus-Bridge
Plugin URI: http://moggy.laceous.com
Description: Integrate SemisecureLoginReimagined with RegisterPlus (reference implementation; tested with: PHP 5.2.9, WP 2.8.6, SLR 3.0.8.3, RP 3.5.1)
Author: moggy
Author URI: http://moggy.laceous.com
Version: 1.0
*/

// hook into the registration form (wp-login.php?action=register)
// make sure this function runs before RegisterPlus
add_action('register_form', 'slr_rp_b_register_form', -1000);
function slr_rp_b_register_form() {
  // if both plugins are activated (and configured)
  if (slr_rp_b_plugins_activated()) {
    // if there are any errors, RegisterPlus will pass the unencrypted password from the server to the browser
    // this stops the password from being sent in the clear
    if (isset($_POST['pass1']))
      unset($_POST['pass1']);
    if (isset($_POST['pass2']))
      unset($_POST['pass2']);
  }
}

// hook into the head section of the registration page (wp-login.php?action=register)
add_action('login_head', 'slr_rp_b_login_head');
function slr_rp_b_login_head() {
  // if this is the registration page and both plugins are activated (and configured)
  if ($_GET['action'] == 'register' &amp;&amp; slr_rp_b_plugins_activated()) {
    // Make sure that all the external JavaScript is available (including jQuery)
    SemisecureLoginReimagined::enqueue_js(true);
    // insert our custom JavaScript
    ?&gt;
    &lt;script type="text/javascript"&gt;
    //&lt;![CDATA[
      jQuery(document).ready(function($) {
        // display a default message
        $('#pass2').after('&lt;span id="semisecure-message"&gt;Semisecure Login is enabled.&lt;/span&gt;');

        // Bind to the form's submit event
        $('form#registerform').submit(function() {
          // update the message when the form is submitted
          $('#semisecure-message').text('Encrypting password &amp; submitting...');

          // Collect the password(s)...
          var pass1 = $('#pass1').val();
          var pass2 = $('#pass2').val();
          var passwords = [];
          passwords[0] = pass1;
          passwords[1] = pass2;

          // ...and form name(s)
          var names = [];
          names[0] = $('#pass1').attr('name');
          names[1] = $('#pass2').attr('name');

          // Pass the needed PHP values over to the JavaScript side
          var public_n = '&lt;?php echo SemisecureLoginReimagined::public_n(); ?&gt;';
          var public_e = '&lt;?php echo SemisecureLoginReimagined::public_e(); ?&gt;';
          var uuid = '&lt;?php echo SemisecureLoginReimagined::uuid(); ?&gt;';
          var nonce_js = '&lt;?php echo SemisecureLoginReimagined::nonce_js(); ?&gt;';
          var max_rand_chars = '&lt;?php echo SemisecureLoginReimagined::max_rand_chars(); ?&gt;';
          var rand_chars = '&lt;?php echo addslashes(SemisecureLoginReimagined::rand_chars()); ?&gt;';
          var secret_key_algo = '&lt;?php echo SemisecureLoginReimagined::secret_key_algo(); ?&gt;';

          // Encrypt the password(s)
          var arr = SemisecureLoginReimagined.encrypt(passwords, names, nonce_js, public_n, public_e, uuid, secret_key_algo, rand_chars, max_rand_chars);

          if (arr) {
            // Loop through the array and append the controls to the form
            for (var i = 0; i &lt; arr.length; i++) {
              $('form#registerform').append(arr[i]);
            }

            // Finally, don't submit the plain-text password(s)
            // One option is to submit asterisks in place of the actual password
            var temp1 = '';
            var temp2 = '';
            for (var i = 0; i &lt; pass1.length; i++) { temp1 += '*'; }
            for (var i = 0; i &lt; pass2.length; i++) { temp2 += '*'; }
            $('#pass1').val(temp1);
            $('#pass2').val(temp2);
            // Another option is to disable the control(s) with the plain-text password(s) altogether
            $('#pass1').attr('disabled', 'true');
            $('#pass2').attr('disabled', 'true');
            return true;
          }
          else {
            $('#semisecure-message').text('Problem encrypting password! Please disable JavaScript to submit without encryption.');
            return false;
          }
        });
      })
    //]]&gt;
    &lt;/script&gt;
    &lt;?php
  }
}

function slr_rp_b_plugins_activated() {
  // if SemisecureLoginReimagined v3 is activated (tested w/ v3.0.8.3)
  // Note: v3.0.5 fixed a bug with the version method in this context
  if (method_exists('SemisecureLoginReimagined', 'version') &amp;&amp; version_compare(SemisecureLoginReimagined::version(), '3.0', '&gt;=')) {
    // if the RSA keypair has been generated and openssl is available
    if (SemisecureLoginReimagined::is_rsa_key_ok() &amp;&amp; SemisecureLoginReimagined::is_openssl_avail()) {
      // if RegisterPlus is activated (tested w/ v3.5.1)
      if (class_exists('RegisterPlusPlugin')) {
        // if registrants can enter their own password
        $regplus = get_option( 'register_plus' );
        if (is_array($regplus) &amp;&amp; $regplus['password']) {
          return true;
        }
      }
    }
  }
  return false;
}

?&gt;
</pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=aoLI6dpOMkw:hY3Z1W2WqFE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=aoLI6dpOMkw:hY3Z1W2WqFE:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?i=aoLI6dpOMkw:hY3Z1W2WqFE:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Moggylaceous/~4/aoLI6dpOMkw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://moggy.laceous.com/2009/11/25/semisecure-integration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://moggy.laceous.com/2009/11/25/semisecure-integration/</feedburner:origLink></item>
		<item>
		<title>Cast of Characters</title>
		<link>http://feedproxy.google.com/~r/Moggylaceous/~3/cHT7YaTTqBI/</link>
		<comments>http://moggy.laceous.com/2009/09/28/cast-of-characters/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 00:54:19 +0000</pubDate>
		<dc:creator>moggy</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[ascii]]></category>
		<category><![CDATA[unicode]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://moggy.laceous.com/?p=225</guid>
		<description><![CDATA[Learn about character encoding (ASCII, ANSI, UTF-8, etc.)
]]></description>
			<content:encoded><![CDATA[<p><a href="http://vlaurie.com/computers2/Articles/characters.htm">Learn</a> about character encoding (ASCII, ANSI, UTF-8, etc.)</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=cHT7YaTTqBI:x-fV-e8v-vI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=cHT7YaTTqBI:x-fV-e8v-vI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?i=cHT7YaTTqBI:x-fV-e8v-vI:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Moggylaceous/~4/cHT7YaTTqBI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://moggy.laceous.com/2009/09/28/cast-of-characters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://moggy.laceous.com/2009/09/28/cast-of-characters/</feedburner:origLink></item>
		<item>
		<title>Semisecure Login Reimagined v3</title>
		<link>http://feedproxy.google.com/~r/Moggylaceous/~3/SJZbSJJm8qw/</link>
		<comments>http://moggy.laceous.com/2009/09/05/semisecure-login-reimagined-v3/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 15:54:02 +0000</pubDate>
		<dc:creator>moggy</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://moggy.laceous.com/?p=223</guid>
		<description><![CDATA[Semisecure Login Reimagined v3 is now available. This release includes a number of changes from previous versions.
For starters, past versions relied on RSA public-key encryption alone. Version 3 now uses a combination of public and secret-key encryption. This means that there is no longer a limit on the length of passwords that can be encrypted. [...]]]></description>
			<content:encoded><![CDATA[<p>Semisecure Login Reimagined v3 is now available. This release includes a number of changes from previous versions.</p>
<p>For starters, past versions relied on <a href="http://en.wikipedia.org/wiki/RSA">RSA</a> public-key encryption alone. Version 3 now uses a combination of public and secret-key encryption. This means that there is no longer a limit on the length of passwords that can be encrypted. The limit in earlier versions was large enough that I doubt it affected anyone, however.</p>
<p>Initially, two secret-key algorithms are provided: <a href="http://en.wikipedia.org/wiki/RC4">RC4</a>  (a stream cipher) and <a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard">AES</a> (a block cipher). On the JavaScript side I chose to go with the <a href="http://code.google.com/p/crypto-js/">crypto-js</a> library. Unfortunately, there wasn&#8217;t a complimentary PHP library so I ended up converting the majority of crypto-js to PHP.</p>
<p>Past versions of this plugin didn&#8217;t behave themselves very well when stepping outside of the <a href="http://en.wikipedia.org/wiki/ASCII">ASCII</a> character bounds. (Western <a href="http://en.wikipedia.org/wiki/ISO/IEC_8859-1">ISO-8859-1</a> might be more technically correct.) Version 3 now has support for <a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a> passwords. Only UTF-8 is supported. If your blog is using another character encoding then your mileage may vary.</p>
<p>The settings page was starting to get long and unwieldy. This has been corrected by splitting each section into sub-pages.</p>
<p>If you&#8217;re having trouble generating an RSA keypair then you can now (optionally) display some debugging information to get you pointed in the right direction.</p>
<p>The main reason that the version has been bumped up to version 3 (rather than&#8230; say&#8230; 2.5) is because the integration API has changed. This change was necessary because of the secret-key addition. Hopefully now, the integration has also been simplified a bit.</p>
<p>Finally, support for older versions of WordPress has been dropped. Semisecure Login Reimagined v3 requires WP 2.7 (or higher) and PHP 4.3 (or higher). Seriously, if you&#8217;re running an older version of WordPress you&#8217;re just asking to be hacked! <a href="http://www.php.net/manual/en/book.openssl.php">OpenSSL</a> is still required, but no other PHP extensions are required (including mcrypt, etc).</p>
<p><span style="text-decoration: underline;">Download</span><br />
The download location hasn&#8217;t changed :) You can still download <a href="http://wordpress.org/extend/plugins/semisecure-login-reimagined/">Semisecure Login Reimagined</a> at its official WordPress page.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=SJZbSJJm8qw:EW3-LoBoIRc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=SJZbSJJm8qw:EW3-LoBoIRc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?i=SJZbSJJm8qw:EW3-LoBoIRc:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Moggylaceous/~4/SJZbSJJm8qw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://moggy.laceous.com/2009/09/05/semisecure-login-reimagined-v3/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		<feedburner:origLink>http://moggy.laceous.com/2009/09/05/semisecure-login-reimagined-v3/</feedburner:origLink></item>
		<item>
		<title>JavaScript classes</title>
		<link>http://feedproxy.google.com/~r/Moggylaceous/~3/Vio5W8OuWnQ/</link>
		<comments>http://moggy.laceous.com/2009/08/31/javascript-classes/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 09:49:36 +0000</pubDate>
		<dc:creator>moggy</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://moggy.laceous.com/?p=221</guid>
		<description><![CDATA[3 ways to  define a JavaScript class
]]></description>
			<content:encoded><![CDATA[<p>3 ways to  <a href="http://www.phpied.com/3-ways-to-define-a-javascript-class/">define</a> a JavaScript class</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=Vio5W8OuWnQ:_VUVPCX3zB0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=Vio5W8OuWnQ:_VUVPCX3zB0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?i=Vio5W8OuWnQ:_VUVPCX3zB0:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Moggylaceous/~4/Vio5W8OuWnQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://moggy.laceous.com/2009/08/31/javascript-classes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://moggy.laceous.com/2009/08/31/javascript-classes/</feedburner:origLink></item>
		<item>
		<title>Semisecure Login Reimagined v2</title>
		<link>http://feedproxy.google.com/~r/Moggylaceous/~3/ahRW_zl3Onk/</link>
		<comments>http://moggy.laceous.com/2009/06/11/semisecure-login-reimagined-v2/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 09:43:18 +0000</pubDate>
		<dc:creator>moggy</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://moggy.laceous.com/?p=64</guid>
		<description><![CDATA[With the release of WordPress 2.8, I&#8217;m releasing Semisecure Login Reimagined v2.  This new version now requires WordPress 2.2 or higher (v1 required WP 2.1 or higher).
Programming note: while v1 of this plugin supported WP 2.1, it also required PHP 4.3.  Techincally, WP 2.1.x, 2.2.x, and 2.3.x only required PHP 4.2.  Semisecure [...]]]></description>
			<content:encoded><![CDATA[<p>With the release of WordPress 2.8, I&#8217;m releasing Semisecure Login Reimagined v2.  This new version now requires WordPress 2.2 or higher (<a href="http://moggy.laceous.com/2008/05/30/semisecure-login-reimagined/">v1</a> required WP 2.1 or higher).</p>
<p>Programming note: while v1 of this plugin supported WP 2.1, it also required PHP 4.3.  Techincally, WP 2.1.x, 2.2.x, and 2.3.x only required PHP 4.2.  Semisecure Login Reimagined v2 should now work properly with PHP 4.2.  (Hopefully most people have upgraded to a recent version of PHP 5)</p>
<p>This new version is now using a new internal API to decrypt passwords on the server side.  Previously, it had been using the <em>wp_authenticate</em> hook, but <a href="http://willnorris.com/2009/03/authentication-in-wordpress-28">this</a> post indicates that it might be removed at some point in the near future.  The new API is much more generic and isn&#8217;t limited to just logging in.</p>
<p><span style="text-decoration: underline;">What&#8217;s New</span></p>
<ul>
<li>jQuery is now being used on the client side</li>
<li>If you&#8217;re not able to generate a keypair with the standard or alternative methods, then you can now generate a keypair via JavaScript (you&#8217;ll have to manually insert the data in your DB though)</li>
<li>If you&#8217;re using WP 2.7 or higher then you can now encrypt the password on the user administration pages (editing or adding a new user)</li>
<li>3rd-party integration support for other plugin authors (see the included help link on the plugin&#8217;s settings page)</li>
<li>You can decide which parts of this plugin to enable: activating the plugin enables the API, while the settings page lets you decide if you want to encrypt the password on the login page (enabled by default so there&#8217;s no surprises for anyone upgrading from v1) and if you want to encrypt the password on the user administration pages (disabled by default)</li>
</ul>
<p><span style="text-decoration: underline;">Download</span><br />
You can still download <a href="http://wordpress.org/extend/plugins/semisecure-login-reimagined/">Semisecure Login Reimagined</a> at its official WordPress page.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=ahRW_zl3Onk:UwC4s76SJJk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=ahRW_zl3Onk:UwC4s76SJJk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?i=ahRW_zl3Onk:UwC4s76SJJk:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Moggylaceous/~4/ahRW_zl3Onk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://moggy.laceous.com/2009/06/11/semisecure-login-reimagined-v2/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://moggy.laceous.com/2009/06/11/semisecure-login-reimagined-v2/</feedburner:origLink></item>
		<item>
		<title>Paging Hemingway Part Deux</title>
		<link>http://feedproxy.google.com/~r/Moggylaceous/~3/63eVWoP8i98/</link>
		<comments>http://moggy.laceous.com/2008/08/15/paging-hemingway-part-deux/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 20:52:14 +0000</pubDate>
		<dc:creator>moggy</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[hemingway]]></category>
		<category><![CDATA[paging]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://moggy.laceous.com/?p=61</guid>
		<description><![CDATA[A little over a year ago, I wrote a plugin that let you page the HemingwayEx home-page.  Unfortunately it doesn&#8217;t work out-of-the-box with HemingwayEx 1.1 (it also wouldn&#8217;t work with vanilla Hemingway).  The original version made a few assumptions that are no longer true.  So here&#8217;s a new version that still works [...]]]></description>
			<content:encoded><![CDATA[<p>A little over a year ago, I wrote a <a href="http://moggy.laceous.com/2007/07/29/paging-the-hemingwayex-home-page/">plugin</a> that let you page the <a href="http://www.nalinmakar.com/hemingwayex/">HemingwayEx</a> home-page.  Unfortunately it doesn&#8217;t work out-of-the-box with HemingwayEx 1.1 (it also wouldn&#8217;t work with vanilla <a href="http://warpspire.com/hemingway/">Hemingway</a>).  The original version made a few assumptions that are no longer true.  So here&#8217;s a new version that still works with older versions of HemingwayEx (that had a built-in asides feature) as well as working with the latest version (1.1) of HemingwayEx (where the asides feature has been removed).  It will also work with the original Hemingway theme.</p>
<p>The best hook to use is still the <em>query_string</em> filter.  Unfortunately, this specific filter is technically deprecated (and may be removed at some point).  You&#8217;re supposed to use the <em>request</em> filter now.  However, the request filter doesn&#8217;t seem to provide quite as much functionality as the query_string filter.  Namely, there doesn&#8217;t appear to be a good way to check for <em>is_home</em> (which is important for our purposes).</p>
<pre>
&lt;?php

/*
 * Plugin Name: Custom Hemingway Home Query
 * Plugin URI: http://moggy.laceous.com/2008/08/15/paging-hemingway-part-deux/
 * Description: Gives you the ability to use the paging links on your homepage (works with Hemingway and HemingwayEx)
 * Version: 0.2a
 * Author: moggy
 * Author URI: http://moggy.laceous.com
 */

add_filter('query_string', 'custom_hem_home_query');
function custom_hem_home_query($query_string) {
	global $wp_query;
	$wp_query-&gt;parse_query($query_string); //required in order to check is_home
	if ($wp_query-&gt;is_home) {
		if (strlen($query_string) &gt; 0) {
			$query_string .= '&#038;';
		}
		$query_string .= 'posts_per_page=2';
		global $hemingwayEx;
		if (isset($hemingwayEx)) {
			if (method_exists($hemingwayEx, 'get_asides_category_id')) {
				$category_id = $hemingwayEx-&gt;get_asides_category_id();
				if (!is_null($category_id) &#038;&#038; !empty($category_id) &#038;&#038; is_numeric($category_id)) {
					$query_string .= '&#038;cat=-' . $category_id;
				}
			}
		}
	}
	return $query_string;
}

?&gt;
</pre>
<p>An alternate way to do this would be to hook into the <em>pre_get_posts</em> action.  Unfortunately, there&#8217;s a down-side here as well.  Namely, if you create a new <strong>WP_Query</strong> object then this method might interfere with your new WP_Query instance (rather than just affecting the main <a href="http://codex.wordpress.org/The_Loop">loop</a>).  I ran into this very problem with my asides widget, and had to throw in a category check in the code below.</p>
<pre>
&lt;?php

/*
 * Plugin Name: Custom Hemingway Home Query
 * Plugin URI: http://moggy.laceous.com/2008/08/15/paging-hemingway-part-deux/
 * Description: Gives you the ability to use the paging links on your homepage (works with Hemingway and HemingwayEx)
 * Version: 0.2b
 * Author: moggy
 * Author URI: http://moggy.laceous.com
 */

add_action('pre_get_posts', 'custom_hem_home_query', 1, 1);
function custom_hem_home_query($wp_query) {
	if (is_home()) { //at this point is_home is already set
		$wp_query-&gt;query_vars['posts_per_page'] = 2;
		//$wp_query-&gt;query['posts_per_page'] = 2; //only setting query_vars seems to matter
		if (isset($GLOBALS['hemingwayEx'])) {
			if (method_exists($GLOBALS['hemingwayEx'], 'get_asides_category_id')) {
				$category_id = $GLOBALS['hemingwayEx']-&gt;get_asides_category_id();
				if (!is_null($category_id) &#038;&#038; !empty($category_id) &#038;&#038; is_numeric($category_id)) {
					//check if the category has already been set
					//if I don't check this then it breaks my asides widget
					if (strlen($wp_query-&gt;query_vars['cat']) &lt;= 0) {
						$wp_query-&gt;query_vars['cat'] = '-' . $category_id;
					}
				}
			}
		}
	}
}

?&gt;
</pre>
<p>To get this to work you&#8217;ll still need to follow the 3 steps from my <a href="http://moggy.laceous.com/2007/07/29/paging-the-hemingwayex-home-page/">original post</a>. Namely (that&#8217;s número tres for those of you counting along at home *wink wink*), copying the PHP code into a file (i.e. <strong>custom_hem_home_query.php</strong>) and uploading to your plugins folder (don&#8217;t forget to activate the plugin when you&#8217;re ready), commenting out the custom query in your theme&#8217;s index.php file (the <em>query_posts</em> line towards the top), and adding the paging links to your home page (also in your theme&#8217;s index.php file).</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=63eVWoP8i98:cxMgeruVgEQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=63eVWoP8i98:cxMgeruVgEQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?i=63eVWoP8i98:cxMgeruVgEQ:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Moggylaceous/~4/63eVWoP8i98" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://moggy.laceous.com/2008/08/15/paging-hemingway-part-deux/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://moggy.laceous.com/2008/08/15/paging-hemingway-part-deux/</feedburner:origLink></item>
		<item>
		<title>Fluency Admin</title>
		<link>http://feedproxy.google.com/~r/Moggylaceous/~3/m-HC3TTkOH0/</link>
		<comments>http://moggy.laceous.com/2008/08/06/fluency-admin/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 11:05:42 +0000</pubDate>
		<dc:creator>moggy</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://moggy.laceous.com/?p=60</guid>
		<description><![CDATA[Re-skin the WordPress admin area with this cool theme
]]></description>
			<content:encoded><![CDATA[<p>Re-skin the <a href="http://en.wikipedia.org/wiki/WordPress">WordPress</a> admin area with this cool <a href="http://deanjrobinson.com/projects/fluency-admin/">theme</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=m-HC3TTkOH0:khAVW4XrTnc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=m-HC3TTkOH0:khAVW4XrTnc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?i=m-HC3TTkOH0:khAVW4XrTnc:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Moggylaceous/~4/m-HC3TTkOH0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://moggy.laceous.com/2008/08/06/fluency-admin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://moggy.laceous.com/2008/08/06/fluency-admin/</feedburner:origLink></item>
		<item>
		<title>Custom Request Methods And PHP</title>
		<link>http://feedproxy.google.com/~r/Moggylaceous/~3/DYxH-fVmoVM/</link>
		<comments>http://moggy.laceous.com/2008/08/01/custom-request-methods-and-php/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 14:41:29 +0000</pubDate>
		<dc:creator>moggy</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://moggy.laceous.com/?p=59</guid>
		<description><![CDATA[By default, PHP (along with web browsers and HTML in general) uses two of the eight defined HTTP request methods.  The eight methods are: HEAD, GET, POST, PUT, DELETE, TRACE, OPTIONS, and CONNECT.  GET is the most widely used, followed by POST.  Whenever you type a URL into your browser&#8217;s address bar, [...]]]></description>
			<content:encoded><![CDATA[<p>By default, <a href="http://en.wikipedia.org/wiki/PHP">PHP</a> (along with <a href="http://en.wikipedia.org/wiki/Web_browser">web browsers</a> and <a href="http://en.wikipedia.org/wiki/HTML">HTML</a> in general) uses two of the eight defined HTTP <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods">request methods</a>.  The eight methods are: HEAD, GET, POST, PUT, DELETE, TRACE, OPTIONS, and CONNECT.  <strong>GET</strong> is the most widely used, followed by <strong>POST</strong>.  Whenever you type a <a href="http://en.wikipedia.org/wiki/Uniform_Resource_Locator">URL</a> into your browser&#8217;s address bar, select a bookmark, or click a link you&#8217;re doing a GET.  When you submit a form on a web page the method will be either GET or POST.</p>
<p><a href="http://en.wikipedia.org/wiki/Representational_State_Transfer#RESTful_example:_the_World_Wide_Web">RESTfully</a> designed web-services use POST, GET, PUT, and DELETE.</p>
<p>Behind the scenes a basic GET request looks like this:</p>
<pre>
GET /path/to/file.php HTTP/1.1
Host: www.domain.com
</pre>
<p>If you were to type this URL into your browser it would look like http://www.domain.com/path/to/file.php</p>
<p>Similarly, a POST to the same URL would look like this:</p>
<pre>
POST /path/to/file.php HTTP/1.1
Host: www.domain.com
</pre>
<p>(Note: For the purpose of these examples I&#8217;m leaving out other request headers such as User-Agent, Keep-Alive, Connection, etc. that you might normally see when using a web browser)</p>
<p>When you do a GET or POST you can also pass in variables.  Consider a web page with a form that asks you to submit your first and last name.</p>
<p>The GET request might look like this:</p>
<pre>
GET /path/to/file.php?FirstName=John&#038;LastName=Doe HTTP/1.1
Host: www.domain.com
</pre>
<p>As you can see, the variables are attached to the URL.  In your browser this would look like http://www.domain.com/path/to/file.php?FirstName=John&#038;LastName=Doe.  These type of request variables are sometimes known as GET variables.</p>
<p>The POST version of this request would look like this:</p>
<pre>
POST /path/to/file.php HTTP/1.1
Host: www.domain.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 27

FirstName=John&#038;LastName=Doe
</pre>
<p>As you can see, the variables aren&#8217;t appended to the URL in a POST, but instead submitted following the request headers.  Variables submitted in this way are sometimes known as POST variables.  In this example I also set the Content-Length and Content-Type headers indicating that this POST was submitting name/value pairs.  You can also submit other data via POST such as uploading a file (and you would want to set the Content-Type appropriately).</p>
<p>PHP has two <a href="http://php.net/manual/en/language.variables.superglobals.php">superglobals</a> called <strong>$_GET</strong> and <strong>$_POST</strong>.  These arrays are automatically populated by PHP based on the request.</p>
<p>It should be noted that it&#8217;s technically possible to submit a POST request with both GET and POST-type variables.</p>
<pre>
POST /path/to/file.php?variable1=value1&#038;variable2=value2 HTTP/1.1
Host: www.domain.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 27

FirstName=John&#038;LastName=Doe
</pre>
<p>In this case, $_GET would be populated with:</p>
<pre>
Array
(
    [variable1] => value1
    [variable2] => value2
)
</pre>
<p>And $_POST would be populated with:</p>
<pre>
Array
(
    [FirstName] => John
    [LastName] => Doe
)
</pre>
<p><span style="text-decoration: underline;"><strong>Using A Custom Request Method</strong></span><br />
What happens if you want to create a RESTful web-service and submit a PUT request to a PHP page?  What if you want to make up your own request method; how do you handle that with PHP?</p>
<p>Consider the following request:</p>
<pre>
MYMETHOD /path/to/file.php HTTP/1.1
Host: www.domain.com
Content-Length: 27

FirstName=John&#038;LastName=Doe
</pre>
<p>In this example I&#8217;m submitting POST-style variables with my own made-up request method called <strong>MYMETHOD</strong>.  I could just as easily substitute <strong>MYMETHOD</strong> with <strong>PUT</strong>.  You can easily submit this type of request with a <a href="http://en.wikipedia.org/wiki/Mozilla_Firefox">Firefox</a> extension called <a href="http://www.xucia.com/#RestTest">RestTest</a>.  You can verify what is actually being sent with another extension called <a href="http://livehttpheaders.mozdev.org/">Live HTTP Headers</a>.</p>
<p>(Note: Some servers may be locked down to only allow certain request methods. If you make a request with a method that&#8217;s not allowed then the server will respond back with a 405 Method Not Allowed error.  A 405 response will include a response header letting you know which methods are allowed.)</p>
<p>If you don&#8217;t want to rely on the convenience of $_GET and $_POST then you can always parse out the raw data yourself.</p>
<ul>
<li><strong>$_SERVER['QUERY_STRING']</strong> is the raw version of <strong>$_GET</strong></li>
<li><strong>php://input</strong> is the raw version of <strong>$_POST</strong></li>
</ul>
<p>You should never have to parse out the query string manually, but $_POST is only populated if the request method is POST and an appropriate Content-Type is set.</p>
<p>To get our raw MYMETHOD data we could do something like this:</p>
<pre>
if ($_SERVER['REQUEST_METHOD'] == 'MYMETHOD')
{
  $raw_data = file_get_contents('php://input');
}
</pre>
<p>We could then parse out the raw data into a $_MYMETHOD variable (to mimic $_GET and $_POST).</p>
<pre>
$array = explode('&#038;', $raw_data);
foreach($array as $item)
{
  list($key, $value) = explode('=', $item);
  $_MYMETHOD[$key] = $value;
}
</pre>
<p><span style="text-decoration: underline;"><strong>Putting It All Together</strong></span><br />
Besides using a tool like RestTest, we can also create a web page that submits a MYMETHOD request.  We&#8217;ll do this by using some JavaScript and making an <a href="http://en.wikipedia.org/wiki/Ajax_(programming)">Ajax</a> request with the <a href="http://en.wikipedia.org/wiki/XMLHttpRequest">XMLHttpRequest</a> object.</p>
<pre>
&lt;?php
if ($_SERVER['REQUEST_METHOD'] == 'MYMETHOD' &#038;&#038; strpos($_SERVER['CONTENT_TYPE'], 'application/x-javascript') !== FALSE):
  $raw_data = file_get_contents('php://input');
  $array = explode('&#038;', $raw_data);
  foreach($array as $item)
  {
    list($key, $value) = explode('=', $item);
    $_MYMETHOD[$key] = $value;
  }
  print_r($_MYMETHOD);

else:
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript"&gt;
/**
 * Bridge XMLHTTP to XMLHttpRequest in pre-7.0 Internet Explorers
 */
if( typeof XMLHttpRequest == "undefined" )
  XMLHttpRequest = function() {
    try { return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP") }     catch(e) {}
    try { return new ActiveXObject("Microsoft.XMLHTTP") }  catch(e) {}
    throw new Error( "This browser does not support XMLHttpRequest or XMLHTTP." )
  };

function ajax(url, vars) {
  var request = new XMLHttpRequest();
  request.open("MYMETHOD", url, true);
  request.setRequestHeader("Content-Type", "application/x-javascript;");

  request.onreadystatechange = function() {
    if (request.readyState == 4 &#038;&#038; request.status == 200) {
      if (request.responseText) {
        alert(request.responseText);
      }
    }
  };

  request.send(vars);
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;input type="button" value="click for ajax" onclick="javascript:ajax('&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;', 'FirstName=John&amp;amp;LastName=Doe');" /&gt;

&lt;/body&gt;
&lt;/html&gt;
&lt;?php endif; ?&gt;
</pre>
<p>If you copy this into a PHP file (i.e. mymethod.php), upload it to a PHP-enabled web server, and navigate to it with your web browser you&#8217;ll see a button that says <strong>click for ajax</strong>.  If you click the button, an asynchronous MYMETHOD request will be sent, the server will parse out the sent name/value pairs and send the processed data back to the browser.  The user will then be presented with an alert popup containing the following text:</p>
<pre>
Array
(
    [FirstName] => John
    [LastName] => Doe
)
</pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=DYxH-fVmoVM:IGcJ8E1oEBM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=DYxH-fVmoVM:IGcJ8E1oEBM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?i=DYxH-fVmoVM:IGcJ8E1oEBM:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Moggylaceous/~4/DYxH-fVmoVM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://moggy.laceous.com/2008/08/01/custom-request-methods-and-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://moggy.laceous.com/2008/08/01/custom-request-methods-and-php/</feedburner:origLink></item>
		<item>
		<title>Criticizing OpenID</title>
		<link>http://feedproxy.google.com/~r/Moggylaceous/~3/nFoxQNaEee4/</link>
		<comments>http://moggy.laceous.com/2008/07/26/criticizing-openid/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 14:57:13 +0000</pubDate>
		<dc:creator>moggy</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[openid]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://moggy.laceous.com/?p=55</guid>
		<description><![CDATA[Problems with OpenID
]]></description>
			<content:encoded><![CDATA[<p><a href="http://idcorner.org/2007/08/22/the-problems-with-openid/">Problems</a> with <a href="http://en.wikipedia.org/wiki/OpenID">OpenID</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=nFoxQNaEee4:P2c4LRRmhaY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=nFoxQNaEee4:P2c4LRRmhaY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?i=nFoxQNaEee4:P2c4LRRmhaY:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Moggylaceous/~4/nFoxQNaEee4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://moggy.laceous.com/2008/07/26/criticizing-openid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://moggy.laceous.com/2008/07/26/criticizing-openid/</feedburner:origLink></item>
		<item>
		<title>Firefox &amp; KDE</title>
		<link>http://feedproxy.google.com/~r/Moggylaceous/~3/4rkv3ZrDNn4/</link>
		<comments>http://moggy.laceous.com/2008/06/21/firefox-kde/#comments</comments>
		<pubDate>Sat, 21 Jun 2008 21:50:51 +0000</pubDate>
		<dc:creator>moggy</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[KDE]]></category>

		<guid isPermaLink="false">http://moggy.laceous.com/?p=54</guid>
		<description><![CDATA[Integrating Firefox with KDE
]]></description>
			<content:encoded><![CDATA[<p><a href="http://gentoo-wiki.com/HOWTO_Integrate_Firefox_with_KDE">Integrating</a> <a href="http://en.wikipedia.org/wiki/Mozilla_Firefox">Firefox</a> with <a href="http://en.wikipedia.org/wiki/KDE">KDE</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=4rkv3ZrDNn4:GXr0T_X468Y:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Moggylaceous?a=4rkv3ZrDNn4:GXr0T_X468Y:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Moggylaceous?i=4rkv3ZrDNn4:GXr0T_X468Y:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Moggylaceous/~4/4rkv3ZrDNn4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://moggy.laceous.com/2008/06/21/firefox-kde/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://moggy.laceous.com/2008/06/21/firefox-kde/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.383 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-02-24 08:57:44 -->
