<?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>Chris&#039; Blog &#187; tips</title>
	<atom:link href="http://www.cs278.org/blog/tag/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cs278.org/blog</link>
	<description>“A metal loving, web developing, open source contributor.”</description>
	<lastBuildDate>Sun, 03 Apr 2011 14:36:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Another phpBB Hook</title>
		<link>http://www.cs278.org/blog/2009/04/05/another-phpbb-hook/</link>
		<comments>http://www.cs278.org/blog/2009/04/05/another-phpbb-hook/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 14:56:11 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[phpBB]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[modification]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.cs278.org/blog/?p=475</guid>
		<description><![CDATA[Further to my entry last month about a phpBB Hook to disable the post queue for certain users, I&#8217;ve written a really quick one to enable phpBB&#8217;s debugging mode for founder users. Debug mode is usually enabled by using the &#8230; <a href="http://www.cs278.org/blog/2009/04/05/another-phpbb-hook/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Further to my <a href="http://www.cs278.org/blog/2009/03/15/phpbb-post-queue/">entry</a> last month about a phpBB Hook to disable the post queue for certain users, I&#8217;ve written a really quick one to enable phpBB&#8217;s debugging mode for founder users. Debug mode is usually enabled by using the constants <code>DEBUG</code> and <code>DEBUG_EXTRA</code> in the configuration file but these can be defined anywhere. The only downside debugging information will only be available after the hook is included, however this is sufficient to get the page generation time, memory usage etc. in the footer which is what I was after. <span id="more-475"></span></p>
<p><a href="http://gist.github.com/90448" rel="external">includes/hooks/hook_enable-debug-for-founders.php </a></p>
<pre>&lt;?php

/**
 * This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://sam.zoy.org/wtfpl/COPYING for more details.
 */

if (!defined('IN_PHPBB'))
{
	exit;
}

/**
 * This hook enables the debug mode for founders
 */
function hook_enable_debug_for_founders(&#038;$hook)
{
	global $user;

	if ($user-&gt;data['user_type'] == USER_FOUNDER)
	{
		// Be careful when defining the constants

		if (!defined('DEBUG'))
		{
			define('DEBUG', true);
		}

		if (!defined('DEBUG_EXTRA'))
		{
			define('DEBUG_EXTRA', true);
		}
	}
}

$phpbb_hook-&gt;register('phpbb_user_session_handler', 'hook_enable_debug_for_founders');</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cs278.org/blog/2009/04/05/another-phpbb-hook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpBB Post Queue</title>
		<link>http://www.cs278.org/blog/2009/03/15/phpbb-post-queue/</link>
		<comments>http://www.cs278.org/blog/2009/03/15/phpbb-post-queue/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 17:58:06 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[phpBB]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[modification]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[xmedia]]></category>

		<guid isPermaLink="false">http://www.cs278.org/blog/?p=463</guid>
		<description><![CDATA[In phpBB 3.0.3 we added the possibility to queue posts of users who had a post count lower than an administrator defined threshold, this works very well at keeping spam out of the public eye on your board. But on &#8230; <a href="http://www.cs278.org/blog/2009/03/15/phpbb-post-queue/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.phpbb.com/community/viewtopic.php?f=14&#038;t=1292765" rel="external">phpBB 3.0.3</a> we added the possibility to queue posts of users who had a post count lower than an administrator defined threshold, this works very well at keeping spam out of the public eye on your board. But on the <a href="http://xmedia.ex.ac.uk/forums/" rel="external">board</a> I administer which is primarily for <a href="http://www.exeter.ac.uk/" rel="external">university</a> students who all have their own university e-mail address it penalises new users who I as the board administrator trust. To get around this, I will be applying a small modification to our board during the next maintenance period which I thought I will share with you. <span id="more-463"></span></p>
<p>This change exploits phpBB&#8217;s <a href="http://code.phpbb.com/svn/phpbb/branches/phpBB-3_0_0/phpBB/docs/hook_system.html">hook system</a> which allows us to execute custom code in certain phpBB functions/methods without modifying any files. To do this we need to create a new file in our phpBB installation in the <code>includes/hooks/</code> directory, the file name must begin with <code>hook_</code> and end with your PHP extension (usually <code>.php</code>.)</p>
<p><a href="http://gist.github.com/79491">includes/hooks/hook_trusted-users.php</a>:</p>
<pre>&lt;?php

/**
 * This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://sam.zoy.org/wtfpl/COPYING for more details.
 */

if (!defined('IN_PHPBB'))
{
	exit;
}

/**
 * This hook disables the post queue for accounts registered with a trusted
 * e-mail address.
 */
function hook_trusted_users(&#038;$hook)
{
	global $config, $user;

	/**
	 * Skip when the queue is disabled, or this is an administration
	 * session so we don't break the ACP, chances are that administrators
	 * have moderation permissions or more posts than required to post any way.
	 */
	if ($config['enable_queue_trigger'] &#038;&#038; !$user-&gt;data['session_admin'] &#038;&#038; preg_match('#@example\.com$#i', $user-&gt;data['user_email']))
	{
		$config['enable_queue_trigger'] = 0; // Disable the post queue for our trusted users
	}
}

$phpbb_hook-&gt;register('phpbb_user_session_handler', 'hook_trusted_users');</pre>
<p>Once you have dropped the file in place you will need to purge your cache, or just manually delete <code>cache/data_hooks.php</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cs278.org/blog/2009/03/15/phpbb-post-queue/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Firefox 3.0 Address Tweak for SSL/TLS</title>
		<link>http://www.cs278.org/blog/2009/03/11/firefox-30-address-tweak-for-ssltls/</link>
		<comments>http://www.cs278.org/blog/2009/03/11/firefox-30-address-tweak-for-ssltls/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 16:39:46 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[certificates]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.cs278.org/blog/?p=461</guid>
		<description><![CDATA[Since Firefox 3 scrapped the yellow address bar for SSL and TLS secured sites (i.e. https) and displays a nice green box for EV certificates I was hinted at a way to get a similar visual for non-EV certificates. You &#8230; <a href="http://www.cs278.org/blog/2009/03/11/firefox-30-address-tweak-for-ssltls/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Since <a href="http://www.getfirefox.com/" rel="external">Firefox 3</a> scrapped the yellow address bar for SSL and TLS secured sites (i.e. https) and displays a nice green box for <a href="http://en.wikipedia.org/wiki/Extended_Validation_Certificate" rel="external">EV certificates</a> I was hinted at a way to get a similar visual for non-EV certificates. You need to enter the FF configuration editor, pop <code>about:config</code> into your address bar, confirm you know there maybe dragons. Put <code>browser.identity.ssl_domain_display</code> into the filter box, double click on the result and then enter the value <code>2</code>. Bingo! Job done.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cs278.org/blog/2009/03/11/firefox-30-address-tweak-for-ssltls/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress archives</title>
		<link>http://www.cs278.org/blog/2009/03/03/wordpress-archives/</link>
		<comments>http://www.cs278.org/blog/2009/03/03/wordpress-archives/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 05:11:32 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Site]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[mods]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.cs278.org/blog/?p=451</guid>
		<description><![CDATA[I&#8217;ve been running my blog since late 2005 as such my archives had been getting a little bit unwieldy in the sidebar and stretching the page to extraordinary heights. I&#8217;ve reduced this clutter with some very small changes. First I &#8230; <a href="http://www.cs278.org/blog/2009/03/03/wordpress-archives/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been running my blog since <a href="http://www.cs278.org/blog/2005/12/07/welcome/">late 2005</a> as such my archives had been getting a little bit unwieldy in the sidebar and stretching the page to extraordinary heights. I&#8217;ve reduced this clutter with some very small changes. First I dug around only to find out that WordPress doesn&#8217;t support fetching the monthly archives for one year, so I had to apply some filter foomongery. I discovered somebody else has done <a href="http://www.misthaven.org.uk/blog/2009/01/11/filtering-archives/" rel="external">something similar</a>, not quite as nice personally but it works.<br />
<span id="more-451"></span><br />
First I created a filter in my WordPress installation and added it.</p>
<pre>function getarchives_filter($where, $args)
{
	if (isset($args['year']))
	{
		$where .= ' AND YEAR(post_date) = ' . intval($args['year']);
	}
	return $where;
}
add_filter('getarchives_where', 'getarchives_filter', 10, 2);
</pre>
<p>Now the <a href="http://codex.wordpress.org/Template_Tags/wp_get_archives" rel="external"><code>wp_get_archives()</code></a> function supports a year parameter which restricts results to one particular year. Next we modify the sidebar to make use of this additional argument. Here is an example of the correct call to make:</p>
<pre>&lt;?php wp_get_archives('type=monthly&amp;year=' . get_the_time('Y', reset($GLOBALS['posts'])); ?&gt;</pre>
<p>This code also works properly when viewing the archives of a particular year, the months outputted change to the currently viewed year.</p>
<p>I have changed my own sidebar code to use this:</p>
<pre>
&lt;li&gt;&lt;h2&gt;Archives&lt;/h2&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;Months&lt;/strong&gt;
            &lt;ul&gt;
                    &lt;?php
                    // Use the current date when viewing a page, not the pages year
                    $year = (is_page()) ? date('Y') : get_the_time('Y', reset($GLOBALS['posts']));

                    wp_get_archives('type=monthly&amp;limit=12&amp;year[]=' . $year . (!is_archive() ? '&amp;year[]=' . ($year - 1) : ''));
                    ?&gt;
            &lt;/ul&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;Years&lt;/strong&gt;
            &lt;ul&gt;
                    &lt;?php wp_get_archives('type=yearly'); ?&gt;
            &lt;/ul&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
&lt;/li&gt;
</pre>
<p class="note"><strong>Updated 31/01/2010:</strong> Paul spotted a bug, the code used the date of the last post displayed on the page rather than the first.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cs278.org/blog/2009/03/03/wordpress-archives/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

