<?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>Ten Fingers And A Brain &#187; OOP</title>
	<atom:link href="http://ten-fingers-and-a-brain.com/category/oop/feed/" rel="self" type="application/rss+xml" />
	<link>http://ten-fingers-and-a-brain.com</link>
	<description>Martin Lormes on Wordpress, PHP, Nagios, XML, FileMaker, BlackBerry, Arduino</description>
	<lastBuildDate>Tue, 27 Mar 2012 10:06:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Keeping your debug output out of the way</title>
		<link>http://ten-fingers-and-a-brain.com/2011/06/keeping-your-debug-output-out-of-the-way/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=keeping-your-debug-output-out-of-the-way</link>
		<comments>http://ten-fingers-and-a-brain.com/2011/06/keeping-your-debug-output-out-of-the-way/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 20:24:09 +0000</pubDate>
		<dc:creator>Martin Lormes</dc:creator>
				<category><![CDATA[OOP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[debug-bar]]></category>

		<guid isPermaLink="false">http://ten-fingers-and-a-brain.com/?p=222</guid>
		<description><![CDATA[Peter Westwood and some other WordPress core developers have written a great plugin for WordPress plugin and theme developers: the Debug Bar. It plugs into the Admin Bar that was introduced with WordPress 3.1 and outputs various details about the current page, but to (super) admins only. Thanks to the consequent usage of WordPress Plugin [...]]]></description>
			<content:encoded><![CDATA[<div><div style="float: left; margin: 0 0px 5px 0;"><g:plusone size="medium" href="http://ten-fingers-and-a-brain.com/2011/06/keeping-your-debug-output-out-of-the-way/"></g:plusone></div><div style="float: left; margin: 0 30px 5px 0;"><a class="FlattrButton" style="display:none;" title="Keeping your debug output out of the way" rev="flattr;uid:tfnab;category:text;language:en_GB;button:compact;" href="http://ten-fingers-and-a-brain.com/2011/06/keeping-your-debug-output-out-of-the-way/">Peter Westwood and some other WordPress core developers have written a great plugin for WordPress plugin and theme developers: the Debug Bar. It plugs into the Admin Bar that was introduced with WordPress 3.1 and outputs various details about the current page, but to (super) admins only. Thanks to the consequent usage of WordPress Plugin API functions there is a fairly easy and straightforward way of outputting your own debug information into the Debug Bar. You should create a separate file for your Debug Bar tab, let's call it my-debug-bar-panel.php, and place it in the same directory as your plugin file or your theme's functions.php file. In this file you create a child class of Debug_Bar_Panel, e.g. my_Debug_Bar_Panel, with at least one method render() in which you can output everything that should be on your tab. 1 &lt;?php class my_Debug_Bar_Panel extends Debug_Bar_Panel { function render() { echo '&lt;div id=&quot;my-debug-par-panel&quot;&gt;'; echo '&lt;h3&gt;...</a></div><div style="float: left; margin: 0 15px 5px 0;"><a style="display:none;" href="http://twitter.com/share?url=http%3A%2F%2Ften-fingers-and-a-brain.com%2F2011%2F06%2Fkeeping-your-debug-output-out-of-the-way%2F&amp;via=10fnab&amp;text=Keeping%20your%20debug%20output%20out%20of%20the%20way&amp;count=horizontal" class="twitter-share-button">Tweet</a></div><div style="float: left; margin: 0 0px 5px 0;"><fb:like href="http://ten-fingers-and-a-brain.com/2011/06/keeping-your-debug-output-out-of-the-way/" layout="button_count"></fb:like></div></div><div style="clear: both;"></div><p><a href="http://westi.wordpress.com/2011/01/05/introducing-debug-bar/">Peter Westwood and some other WordPress core developers have written a great plugin</a> for WordPress plugin and theme developers: <a href="http://wordpress.org/extend/plugins/debug-bar/">the Debug Bar</a>. It plugs into the Admin Bar that was introduced with WordPress 3.1 and outputs various details about the current page, but to (super) admins only.</p>
<p>Thanks to the consequent usage of <a href="http://codex.wordpress.org/Plugin_API">WordPress Plugin API</a> functions there is a fairly easy and straightforward way of outputting your own debug information into the Debug Bar.</p>
<p><img src="http://ten-fingers-and-a-brain.com/wp-content/uploads/2011/06/debug-bar-panel.jpg" alt="Your own Debug Bar Panel" title="Your own Debug Bar Panel" width="500" height="172" class="alignnone size-full wp-image-227" /></p>
<p>You should create a separate file for your Debug Bar tab, let&#8217;s call it <code>my-debug-bar-panel.php</code>, and place it in the same directory as your plugin file or your theme&#8217;s <code>functions.php</code> file. In this file you create a child class of <code>Debug_Bar_Panel</code>, e.g. <code>my_Debug_Bar_Panel</code>, with at least one method <code>render()</code> in which you can output everything that should be on your tab.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
class my_Debug_Bar_Panel extends Debug_Bar_Panel
{
  function render()
  {
    echo '&lt;div id=&quot;my-debug-par-panel&quot;&gt;';
    echo '&lt;h3&gt;Some header&lt;/h3&gt;';
    echo '&lt;p&gt;Some debug output&lt;/p&gt;';
    echo '&lt;/div&gt;';
  }
}
</pre>
<p>Now back to your main plugin file or <code>functions.php</code>: You need a function that hooks into <code>debug_bar_panels</code>. I put a double check in my example to make sure the base class <code>Debug_Bar_Panel</code> exists (since you never know whether they drop this in a future release which would cause fatal runtime errors). Then you create a new instance of <code>my_Debug_Bar_Panel</code> with the title, which you would like to see on your tab, passed to the constructor:</p>
<pre class="brush: php; title: ; notranslate">
function my_debug_bar_panels($a)
{
  if (class_exists('Debug_Bar_Panel'))
  {
    require_once dirname(__FILE__).'/my-debug-bar-panel.php';
    $a[]=new my_Debug_Bar_Panel('My tab title');
  }
  return $a;
}
add_filter('debug_bar_panels', 'my_debug_bar_panels');
</pre>
<p>Believe it or not, you&#8217;re done!</p>
]]></content:encoded>
			<wfw:commentRss>http://ten-fingers-and-a-brain.com/2011/06/keeping-your-debug-output-out-of-the-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>{SSHA} Salted SHA1 with PHP</title>
		<link>http://ten-fingers-and-a-brain.com/2009/08/ssha-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ssha-php</link>
		<comments>http://ten-fingers-and-a-brain.com/2009/08/ssha-php/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 19:36:25 +0000</pubDate>
		<dc:creator>Martin Lormes</dc:creator>
				<category><![CDATA[encryption]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[openLDAP]]></category>
		<category><![CDATA[passwd]]></category>
		<category><![CDATA[sha1]]></category>
		<category><![CDATA[ssha]]></category>

		<guid isPermaLink="false">http://ten-fingers-and-a-brain.com/2009/08/ssha-php/</guid>
		<description><![CDATA[I was in need of a PHP class to encrypt hash and verify passwords using salted sha1 hashes. Here it is, quick but not too dirty: 1TweetI was in need of a PHP class to encrypt hash and verify passwords using salted sha1 hashes. Here it is, quick but not too dirty:]]></description>
			<content:encoded><![CDATA[<div><div style="float: left; margin: 0 0px 5px 0;"><g:plusone size="medium" href="http://ten-fingers-and-a-brain.com/2009/08/ssha-php/"></g:plusone></div><div style="float: left; margin: 0 30px 5px 0;"><a class="FlattrButton" style="display:none;" title="{SSHA} Salted SHA1 with PHP" rev="flattr;uid:tfnab;category:text;language:en_GB;button:compact;" href="http://ten-fingers-and-a-brain.com/2009/08/ssha-php/">I was in need of a PHP class to encrypt hash and verify passwords using salted sha1 hashes. Here it is, quick but not too dirty: 1</a></div><div style="float: left; margin: 0 15px 5px 0;"><a style="display:none;" href="http://twitter.com/share?url=http%3A%2F%2Ften-fingers-and-a-brain.com%2F2009%2F08%2Fssha-php%2F&amp;via=10fnab&amp;text=%7BSSHA%7D%20Salted%20SHA1%20with%20PHP&amp;count=horizontal" class="twitter-share-button">Tweet</a></div><div style="float: left; margin: 0 0px 5px 0;"><fb:like href="http://ten-fingers-and-a-brain.com/2009/08/ssha-php/" layout="button_count"></fb:like></div></div><div style="clear: both;"></div><p>I was in need of a PHP class to <del datetime="2009-08-02T23:39:58+00:00">encrypt</del> hash and verify passwords using salted sha1 hashes. Here it is, quick but not too dirty:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php

class SSHA
{

  public static function newSalt()
  {
    return chr(rand(0,255)).chr(rand(0,255)).chr(rand(0,255)).chr(rand(0,255));
  }

  public static function hash($pass,$salt)
  {
    return '{SSHA}'.base64_encode(sha1($pass.$salt,true).$salt);
  }

  public static function getSalt($hash)
  {
    return substr(base64_decode(substr($hash,-32)),-4);
  }

  public static function newHash($pass)
  {
    return self::hash($pass,self::newSalt());
  }

  public static function verifyPassword($pass,$hash)
  {
    return $hash == self::hash($pass,self::getSalt($hash));
  }

}</pre>
]]></content:encoded>
			<wfw:commentRss>http://ten-fingers-and-a-brain.com/2009/08/ssha-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design Patterns.</title>
		<link>http://ten-fingers-and-a-brain.com/2009/07/design-patterns/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=design-patterns</link>
		<comments>http://ten-fingers-and-a-brain.com/2009/07/design-patterns/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 21:23:10 +0000</pubDate>
		<dc:creator>Martin Lormes</dc:creator>
				<category><![CDATA[blurts]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://ten-fingers-and-a-brain.com/2009/07/design-patterns/</guid>
		<description><![CDATA[(Almost) Everybody should read this book: Design Patterns. Elements of Reusable Object-Oriented Software.]]></description>
			<content:encoded><![CDATA[<p>(Almost) Everybody should read this book: <a href="http://www.amazon.de/gp/product/0201633612?ie=UTF8&#038;tag=tfnab-21&#038;linkCode=as2&#038;camp=1638&#038;creative=19454&#038;creativeASIN=0201633612">Design Patterns. Elements of Reusable Object-Oriented Software.</a><img src="http://www.assoc-amazon.de/e/ir?t=tfnab-21&#038;l=as2&#038;o=3&#038;a=0201633612" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>
]]></content:encoded>
			<wfw:commentRss>http://ten-fingers-and-a-brain.com/2009/07/design-patterns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

