<?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/" version="2.0">

<channel>
	<title>valadiléne</title>
	
	<link>http://valadilene.org</link>
	<description>web development, programming and music</description>
	<lastBuildDate>Sun, 25 Jul 2010 13:38:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/valadilene" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="valadilene" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>WordBB 0.3 Released</title>
		<link>http://valadilene.org/2010/06/27/wordbb-0-3-released/</link>
		<comments>http://valadilene.org/2010/06/27/wordbb-0-3-released/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 21:14:16 +0000</pubDate>
		<dc:creator>Hangman</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[WordBB]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://valadilene.org/?p=776</guid>
		<description><![CDATA[WordPress 3.0 has been around for a few days now, and yesterday I noticed that WordBB has some broken features. So I fixed them, added a couple things some folks asked for, and uploaded WordBB 0.3. Here&#8217;s the new stuff: Fixed some WP 3.0 compatibility bugs (posts and categories sections) Improved performance on some SQL [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress 3.0 has been around for a few days now, and yesterday I noticed that WordBB has some broken features. So I fixed them, added a couple things some folks asked for, and uploaded <strong>WordBB 0.3</strong>. </p>
<p>Here&#8217;s the new stuff:</p>
<ul>
<li>Fixed some WP 3.0 compatibility bugs (posts and categories sections)</li>
<li>Improved performance on some SQL queries</li>
<li>It&#8217;s now possible to add a link to the original WP post before or after the thread&#8217;s post content</li>
<li>Latest threads widget now checks user and forum permissions (e.g. protected forums won&#8217;t be visible to guests)</li>
<li>Fixed bug on the post excerpt function (now it checks if there&#8217;s an excerpt, otherwise it just uses the content before the &#8220;more&#8221; tag)</li>
<li>wordbb_get_userinfo() renamed to wordbb_get_logged_user_info()</li>
</ul>
<p>As usual, post your bug reports and/or comments here (please try not to use forums or PMs on the MyBB forums, as I can&#8217;t keep track of everything). Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://valadilene.org/2010/06/27/wordbb-0-3-released/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Four Tracks From New Flying Lotus Album</title>
		<link>http://valadilene.org/2010/02/19/four-tracks-from-new-flying-lotus-album/</link>
		<comments>http://valadilene.org/2010/02/19/four-tracks-from-new-flying-lotus-album/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 09:28:17 +0000</pubDate>
		<dc:creator>Hangman</dc:creator>
				<category><![CDATA[Music]]></category>
		<category><![CDATA[cosmogramma]]></category>
		<category><![CDATA[flying lotus]]></category>

		<guid isPermaLink="false">http://valadilene.org/?p=737</guid>
		<description><![CDATA[Flying Lotus&#8216; third album, Cosmogramma, will be released on May 3rd, 2010 in the UK and May 4th in the US on Warp Records. Cosmogramma will feature collaborations with Thom Yorke, Laura Darrington (who appeared on previous albums as well) and Outkast string arranger Miguel Atwood-Ferguson. If you are an hardcore fan (like me), good [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://valadilene.org/wp-content/uploads/2010/02/cosmogramma.jpg"><img src="http://valadilene.org/wp-content/uploads/2010/02/cosmogramma-150x150.jpg" alt="" title="flying lotus cosmogramma" width="150" height="150" class="alignright wp-caption size-thumbnail wp-image-739" /></a><a href="http://www.last.fm/music/Flying+Lotus">Flying Lotus</a>&#8216; third album, Cosmogramma, will be released on May 3rd, 2010 in the UK and May 4th in the US on Warp Records.</p>
<p>Cosmogramma will feature collaborations with Thom Yorke, Laura Darrington (who appeared on previous albums as well) and Outkast string arranger Miguel Atwood-Ferguson.</p>
<p>If you are an hardcore fan (like me), good news: while you wait for it, you can listen to these new four tracks extracted from the album.</p>
<p><a href="http://www.mediafire.com/?nbaieltmojv">Computer Face</a> / <a href="http://www.mediafire.com/?wyujjjytvvl">Dance Of The Pseudo Nymph</a> / <a href="http://www.mediafire.com/?zimjyqeglmc">Nose Art</a> / <a href="http://www.mediafire.com/?zhwmxydmydu">Satelllliiiiiteee</a></p>
]]></content:encoded>
			<wfw:commentRss>http://valadilene.org/2010/02/19/four-tracks-from-new-flying-lotus-album/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Tweet Calendar Events on MyBB</title>
		<link>http://valadilene.org/2010/02/09/how-to-tweet-calendar-events-on-mybb/</link>
		<comments>http://valadilene.org/2010/02/09/how-to-tweet-calendar-events-on-mybb/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:17:32 +0000</pubDate>
		<dc:creator>Hangman</dc:creator>
				<category><![CDATA[MyBB]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[bit.ly]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://valadilene.org/?p=687</guid>
		<description><![CDATA[Recently I had to make a plugin for one of my message boards which would send an update to Twitter whenever an user posted a new calendar event. In this tutorial I&#8217;ll explain how I&#8217;ve done it. We will see how to shorten the event URL through bit.ly and post a new status on a [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had to make a plugin for <a target="_blank" href="http://www.idmitalia.com">one of my message boards</a> which would send an update to Twitter whenever an user posted a new calendar event. In this tutorial I&#8217;ll explain how I&#8217;ve done it.<br />
We will see how to shorten the event URL through <a target="_blank" href="http://bit.ly">bit.ly</a> and post a new status on a <a target="_blank" href="http://twitter.com">Twitter</a> account with PHP. Of course the same code can be applied to threads or posts.</p>
<p><span id="more-687"></span></p>
<h3>Requirements</h3>
<ul>
<li>MyBB message board</li>
<li>Twitter account</li>
<li>bit.ly account</li>
</ul>
<p>The first step is registering on <a target="_blank" href="http://twitter.com">Twitter</a> and <a target="_blank" href="http://bit.ly">bit.ly</a>. After you&#8217;re done with those, take note of your Twitter username and password, and, most importantly, your bit.ly API key, which can be found in your <a target="_blank" href="http://bit.ly/account/">Account page</a>.</p>
<h3>Setting Up the Plugin</h3>
<p>At this point, we are ready to start with some code. First of all, let&#8217;s create a new empty file called mybbtwitter.php or whatever you like. Then insert this code, which is the basic stuff for any MyBB plugin.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw2">function</span> valadilene_info<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;name&quot;</span> <span class="sy0">=&gt;</span> <span class="st0">&quot;TwitterCalendar&quot;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;description&quot;</span> <span class="sy0">=&gt;</span> <span class="st0">&quot;Tweets calendar events&quot;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;website&quot;</span> <span class="sy0">=&gt;</span> <span class="st0">&quot;http://valadilene.org&quot;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;author&quot;</span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">=&gt;</span> <span class="st0">&quot;valadilene&quot;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;authorsite&quot;</span> <span class="sy0">=&gt;</span> <span class="st0">&quot;http://valadilene.org&quot;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;version&quot;</span> <span class="sy0">=&gt;</span> <span class="st0">&quot;1.0&quot;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;guid&quot;</span> <span class="sy0">=&gt;</span> <span class="st0">&quot;&quot;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;compatibility&quot;</span> <span class="sy0">=&gt;</span> <span class="st0">&quot;*&quot;</span><br />
<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">function</span> valadilene_activate<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span></p>
<p><span class="br0">&#125;</span></p>
<p><span class="kw2">function</span> valadilene_deactivate<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span></p>
<p><span class="br0">&#125;</span></div>
</div>
<h3>Shortening URLs</h3>
<p>As you may already know, <a target="_blank" href="http://bit.ly">bit.ly</a> is an URL shortening service. Since Twitter only allows 140 characters long statuses, we need to make our URLs short. Example:</p>
<blockquote><p>
<strong>before:</strong> <a href="http://www.example.com/forum/showthread.php?tid=614" title="http://www.example.com/forum/showthread.php?tid=614" class="autohyperlink" target="_blank">http://www.example.com/forum/showthread.php?tid=614</a><br />
<strong>after:</strong> <a href="http://bit.ly/somecode" title="http://bit.ly/somecode" class="autohyperlink" target="_blank">http://bit.ly/somecode</a>
</p></blockquote>
<p>Here&#8217;s a sweet PHP function that does the job (<a target="_blank" href="http://davidwalsh.name/bitly-php">source</a>). Add this at the end of your plugin file.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw2">function</span> make_bitly_url<span class="br0">&#40;</span><span class="re0">$url</span><span class="sy0">,</span><span class="re0">$login</span><span class="sy0">,</span><span class="re0">$appkey</span><span class="sy0">,</span><span class="re0">$format</span> <span class="sy0">=</span> <span class="st_h">&#8216;xml&#8217;</span><span class="sy0">,</span><span class="re0">$version</span> <span class="sy0">=</span> <span class="st_h">&#8217;2.0.1&#8242;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//create the URL</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$bitly</span> <span class="sy0">=</span> <span class="st_h">&#8216;http://api.bit.ly/shorten?version=&#8217;</span><span class="sy0">.</span><span class="re0">$version</span><span class="sy0">.</span><span class="st_h">&#8216;&amp;longUrl=&#8217;</span><span class="sy0">.</span><a href="http://www.php.net/urlencode"><span class="kw3">urlencode</span></a><span class="br0">&#40;</span><span class="re0">$url</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="st_h">&#8216;&amp;login=&#8217;</span><span class="sy0">.</span><span class="re0">$login</span><span class="sy0">.</span><span class="st_h">&#8216;&amp;apiKey=&#8217;</span><span class="sy0">.</span><span class="re0">$appkey</span><span class="sy0">.</span><span class="st_h">&#8216;&amp;format=&#8217;</span><span class="sy0">.</span><span class="re0">$format</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//get the url</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//could also use cURL here</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$response</span> <span class="sy0">=</span> <a href="http://www.php.net/file_get_contents"><span class="kw3">file_get_contents</span></a><span class="br0">&#40;</span><span class="re0">$bitly</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//parse depending on desired format</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/strtolower"><span class="kw3">strtolower</span></a><span class="br0">&#40;</span><span class="re0">$format</span><span class="br0">&#41;</span> <span class="sy0">==</span> <span class="st_h">&#8216;json&#8217;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$json</span> <span class="sy0">=</span> <span class="sy0">@</span><a href="http://www.php.net/json_decode"><span class="kw3">json_decode</span></a><span class="br0">&#40;</span><span class="re0">$response</span><span class="sy0">,</span><span class="kw4">true</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$json</span><span class="br0">&#91;</span><span class="st_h">&#8216;results&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="re0">$url</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;shortUrl&#8217;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span> <span class="co1">//xml</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$xml</span> <span class="sy0">=</span> <a href="http://www.php.net/simplexml_load_string"><span class="kw3">simplexml_load_string</span></a><span class="br0">&#40;</span><span class="re0">$response</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="st_h">&#8216;http://bit.ly/&#8217;</span><span class="sy0">.</span><span class="re0">$xml</span><span class="sy0">-&gt;</span><span class="me1">results</span><span class="sy0">-&gt;</span><span class="me1">nodeKeyVal</span><span class="sy0">-&gt;</span><span class="me1">hash</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>Now it&#8217;s time to get our hands on a PHP Twitter class, so that our forums can communicate with Twitter. This is <a target="_blank" href="http://code.google.com/p/php-twitter/">the one I&#8217;m using</a> in my plugin.</p>
<h3>Calendar Event Hook</h3>
<p>The hook we need to handle is called <strong>calendar_do_addevent_end</strong>. Let&#8217;s add this code to the plugin file.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="re0">$plugins</span><span class="sy0">-&gt;</span><span class="me1">add_hook</span><span class="br0">&#40;</span><span class="st_h">&#8216;calendar_do_addevent_end&#8217;</span><span class="sy0">,</span> <span class="st_h">&#8216;valadilene_addevent&#8217;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>So, <strong>valadilene_addevent</strong> is the handler function. Here&#8217;s the implementation, which uses the Twitter class we have downloaded earlier.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw2">function</span> valadilene_addevent<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">global</span> <span class="re0">$details</span><span class="sy0">,</span> <span class="re0">$mybb</span><span class="sy0">,</span> <span class="re0">$db</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// gets event data from the db</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$q</span><span class="sy0">=</span><span class="re0">$db</span><span class="sy0">-&gt;</span><span class="me1">simple_select</span><span class="br0">&#40;</span><span class="st_h">&#8216;events&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;name, description, uid, starttime&#8217;</span><span class="sy0">,</span><span class="st0">&quot;eid=<span class="es4">{$details['eid']}</span>&quot;</span><span class="sy0">,</span><a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">&#8216;limit&#8217;</span><span class="sy0">=&gt;</span>1<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$event</span><span class="sy0">=</span><span class="re0">$db</span><span class="sy0">-&gt;</span><span class="me1">fetch_array</span><span class="br0">&#40;</span><span class="re0">$q</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// include twitter class</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">require_once</span><span class="br0">&#40;</span><span class="st_h">&#8216;class.twitter.php&#8217;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// get bit.ly URL</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$short</span><span class="sy0">=</span>make_bitly_url<span class="br0">&#40;</span><span class="re0">$mybb</span><span class="sy0">-&gt;</span><span class="me1">settings</span><span class="br0">&#91;</span><span class="st_h">&#8216;bburl&#8217;</span><span class="br0">&#93;</span><span class="sy0">.</span><span class="st0">&quot;/calendar.php?action=event&amp;eid=<span class="es4">{$event['eid']}</span>&quot;</span><span class="sy0">,</span>BITLY_USERNAME<span class="sy0">,</span>BITLY_API_KEY<span class="sy0">,</span><span class="st_h">&#8216;json&#8217;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// send twitter status</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$tw</span><span class="sy0">=</span><span class="kw2">new</span> twitter<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$tw</span><span class="sy0">-&gt;</span><span class="me1">username</span><span class="sy0">=</span>TWITTER_USERNAME<span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$tw</span><span class="sy0">-&gt;</span><span class="me1">password</span><span class="sy0">=</span>TWITTER_PASSWORD<span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$tw</span><span class="sy0">-&gt;</span><span class="me1">update</span><span class="br0">&#40;</span><span class="st0">&quot;[&quot;</span><span class="sy0">.</span>my_date<span class="br0">&#40;</span><span class="st_h">'d M'</span><span class="sy0">,</span><span class="re0">$event</span><span class="br0">&#91;</span><span class="st_h">'starttime'</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="st0">&quot;] <span class="es4">{$event['name']}</span> <span class="es4">{$short}</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>Of course you need to replace <strong>BITLY_USERNAME</strong>, <strong>BITLY_API_KEY</strong>, <strong>TWITTER_USERNAME</strong> and <strong>TWITTER_PASSWORD</strong> with your bit.ly username, the API key you&#8217;ve obtained earlier, and your Twitter username and password respectively (or, better, just define those costants at the beginning of the file).</p>
<p>Whenever an user on your message board will post an event in the calendar, your Twitter account will be updated with a new status like the following.</p>
<blockquote><p>[09 Feb] Event name <a target="_blank" href="http://bit.ly/code">http://bit.ly/code</a><br />
&nbsp;
</p></blockquote>
<p>You can change this by editing the argument passed to the <strong>my_date()</strong> function call. Look at <a target="_blank" href="http://php.net/date">this page</a> about <strong>date()</strong> from the PHP documentation for more information.</p>
<p><strong>NOTE:</strong> <strong>my_date()</strong> is a MyBB function similar to PHP&#8217;s <a target="_blank" href="http://php.net/date">date()</a>. It does extra handling such as timezone and language based on your board&#8217;s settings.</p>
<h3>Conclusion</h3>
<p>And that&#8217;s it. Of course you can modify the code to do anything you like. For example you could have a look at this list of <a target="_blank" href="http://wiki.mybboard.net/index.php/MyBB_Plugin_Hooks">MyBB hooks</a> and extend tweeting even for threads or posts. Have fun!</p>
<p><strong>Sources</strong>:<br />
<em>php-twitter library</em>: <a href="http://code.google.com/p/php-twitter/" target="_blank">http://code.google.com/p/php-twitter/</a><br />
<em>bit.ly short URLs with PHP</em>: <a href="http://davidwalsh.name/bitly-php" target="_blank">http://davidwalsh.name/bitly-php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://valadilene.org/2010/02/09/how-to-tweet-calendar-events-on-mybb/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to Show Last.fm Tracks In Your Blog</title>
		<link>http://valadilene.org/2010/01/09/how-to-show-last-fm-tracks-in-your-wordpress-blog/</link>
		<comments>http://valadilene.org/2010/01/09/how-to-show-last-fm-tracks-in-your-wordpress-blog/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 17:57:11 +0000</pubDate>
		<dc:creator>Hangman</dc:creator>
				<category><![CDATA[Stuff I use]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[last.fm]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://valadilene.org/?p=649</guid>
		<description><![CDATA[So you have a WordPress blog and you want to show your latest tracks from Last.fm in your sidebar? Then Last.wp is the plugin for you. It works through JavaScript (no server overhead each time you load a page) and it displays song names, artist names, album names and even album artwork. This is by [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://valadilene.org/wp-content/uploads/2010/01/lastwp1.png" alt="" title="lastwp1" width="195" height="227" class="alignright size-full wp-image-660" />So you have a WordPress blog and you want to show your latest tracks from <a href="http://last.fm">Last.fm</a> in your sidebar? Then <a href="http://wordpress.org/extend/plugins/lastwp/">Last.wp</a> is the plugin for you. It works through JavaScript (no server overhead each time you load a page) and it displays song names, artist names, album names and even album artwork.<br />
This is by far the best Last.fm plugin for WordPress I&#8217;ve ever tried.</p>
<p><span id="more-649"></span></p>
<h3>What Do You Need to Run It</h3>
<p>There are some requirements for this plugin to work correctly.<br />
First of all, of course you must have a WordPress blog running with a widget-enabled theme. Then you need a Last.fm profile, preferably with some good charts (you don&#8217;t want to get your users horrified at your musical taste).<br />
Last but not least, you need a Last.fm API key associated to your account. In order to get one, just log into Last.fm and visit this address: <a href="http://www.last.fm/api/account" title="http://www.last.fm/api/account" class="autohyperlink" target="_blank">http://www.last.fm/api/account</a>. Once you have obtained your key, copy and paste it somewhere for later, when you&#8217;ll have to enter it in the plugin&#8217;s settings.</p>
<h3>Widget Setup and Settings</h3>
<p>Upload the <strong>lastwp</strong> directory into /wp-content/plugins/, then activate the plugin in the <strong>Plugins</strong> section in your wp-admin. Now that Last.wp is active, go to the <strong>Widgets</strong> section under <strong>Appearance</strong>. Drag and drop the Last.wp widget in your preferred sidebar on the right, then expand it to show the plugin&#8217;s settings. </p>
<p><img src="http://valadilene.org/wp-content/uploads/2010/01/lastwp.png" alt="" title="lastwp" width="252" height="340" class="alignright size-full wp-image-650" />Here you have to enter the widget&#8217;s title, your Last.fm username and, most importantly, you have to paste the key you have obtained earlier in the <strong>Last.fm API key</strong> field. Then you can choose how many songs you want to show in your sidebar through the dropdown menu.<br />
Once you&#8217;re done tweaking the settings, click <strong>Save</strong>.</p>
<p>That&#8217;s it. You should now see your latest tracks from your Last.fm account in your blog&#8217;s sidebar. Enjoy a cup of coffee or tea while scrobbling some of your favourite tracks.</p>
<h3>Last.fm Widget Customization</h3>
<p>You can customize how your Last.fm widget looks by editing the <strong>lastwp.css</strong> stylesheet, under the &#8220;css&#8221; directory in the plugin&#8217;s folder. If you are familiar with CSS, this should be quite a straightforward task.<br />
The <strong>lfm_overlay.png</strong> image is shown at the bottom right corner of the album artwork, and by default it&#8217;s a tiny green music note. If you want to customize it, you can either replace the existing image or edit the path in the CSS file, in the <strong>.widget_lastWP div.lfm_art a</strong> block.<br />
Another thing you could change is how the fonts for song name, artist name and album name look. These are defined respectively by the <strong>div.lfm_song</strong>, <strong>div.lfm_artist</strong> and <strong>div.lfm_album</strong> classes.</p>
<p><em>Visit the <a href="http://kylehotchkiss.com/">plugin&#8217;s author website</a> and the <a href="http://kylehotchkiss.com/productions/last.wp/">plugin&#8217;s page</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://valadilene.org/2010/01/09/how-to-show-last-fm-tracks-in-your-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Some Reasons Why Last.fm Sucks</title>
		<link>http://valadilene.org/2010/01/07/some-reasons-why-last-fm-sucks/</link>
		<comments>http://valadilene.org/2010/01/07/some-reasons-why-last-fm-sucks/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 19:07:42 +0000</pubDate>
		<dc:creator>Hangman</dc:creator>
				<category><![CDATA[Stuff I use]]></category>
		<category><![CDATA[Sucks-Rant]]></category>
		<category><![CDATA[last.fm]]></category>
		<category><![CDATA[sucks]]></category>

		<guid isPermaLink="false">http://valadilene.org/?p=631</guid>
		<description><![CDATA[No, don&#8217;t get me wrong, I love Last.fm. I&#8217;ve been a subscriber for years and I&#8217;m really happy with it &#8212; my profile reflects my music taste just fine and I always discover new stuff through the recommendation system. It has clean interface (unlike some other social sites out there), okay people (haven&#8217;t seen much [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://valadilene.org/wp-content/uploads/2010/01/lastfmlogo.png" alt="" title="lastfmlogo" width="154" height="66" class="alignright size-full wp-image-642" />No, don&#8217;t get me wrong, I love <a href="http://last.fm">Last.fm</a>.<br />
I&#8217;ve been <a href="http://www.last.fm/user/MonochromeNight">a subscriber for years</a> and I&#8217;m really happy with it &mdash; my profile reflects my music taste just fine and I always discover new stuff through the recommendation system. It has clean interface (unlike some other social sites out there), okay people (haven&#8217;t seen much trolls there) and the whole idea of scrobbling music building my profile is very appealing.<br />
I really shouldn&#8217;t complain about it, but&#8230; okay, here&#8217;s my list of reasons why Last.fm sucks, at least a little bit.<br />
<span id="more-631"></span></p>
<ul>
<a href="http://valadilene.org/wp-content/uploads/2010/01/oldlastfm.jpg"><img src="http://valadilene.org/wp-content/uploads/2010/01/oldlastfm-300x262.jpg" alt="" title="The old Last.fm design was much better than the one you see today, no doubt about it." width="300" height="262" class="alignright size-medium wp-image-632" /></a></p>
<li><strong>New design:</strong> In July 2008, the folks at Last.fm decided they absolutely had to rebuild the site&#8217;s design from scratch. This apparently seemed like an okay idea &mdash; too bad they fucked it up. Bugs everywhere, slowness, and overall it&#8217;s just plain ugly when compared to the old good design. At the time several <a href="http://www.last.fm/group/Bring+back+the+old+Last.fm">groups</a> and <a href="http://www.last.fm/group/Petition+against+Last.fm's+recent+relaunch!">petitions</a> <a href="http://www.last.fm/forum/21713/_/433131/1">were opened</a> against the site change, and someone even made a <a href="http://www.lastfm.com.br/group/Bring+back+the+old+Last.fm/forum/103555/_/506991">Greasemonkey script</a> to bring back the old look &#038; feel (although it needs a lot of imagination and some template features are just impossible to reproduce). At first, even some website features were missing &#8211; some of them have been fixed (Paint it Black, Reply Tracker, Neighbours, gif support), some of them still aren&#8217;t there (list is too long, view &#8220;Things we would like to have back&#8221; in the <strong><a href="http://www.last.fm/group/Bring+back+the+old+Last.fm">Bring back the old Last.fm</a></strong> group).
</li>
<li><strong>Support is incredibly slow:</strong> People at Last.fm are obviously working hard to fix stuff, but there are some things I just can&#8217;t explain. Some major bugs, like the <a href="http://www.last.fm/forum/6666/_/580294/1">track upload issue</a> which occurred in November 2009, or less important but still incredibly annoying bugs like the <a href="http://www.last.fm/forum/21713/_/590628">image charts server not working</a> (December 2009 &#8211; still not fixed) are just a few examples of problems that take a shit-load of time to get fixed without any apparent reason.
</li>
<li><strong>Free radio for US, German and English users; paid for anyone else:</strong> Since April 2009, Last.fm changed their policy regarding free radio listening. That&#8217;s what the <a href="http://blog.last.fm/2009/03/24/lastfm-radio-announcement">blog post</a> said: ] &#8220;[...] In the United States, United Kingdom and Germany, nothing will change. In all other countries, listening to Last.fm Radio will soon require a subscription of €3.00 per month.&#8221; When this happened, just like for the design problem, thousands of users complained on <a href="http://www.last.fm/group/Bring+back+the+free+last.fm">groups</a> and <a href="http://www.last.fm/group/Last.fm+Web+Services/forum/21604/_/517212">forums</a> and a lot of them stopped submitting data or even cancelled their accounts.</li>
<li><strong>Artists with the same name:</strong> Did you know that there are <strong>ten</strong> bands in the world all named <strong>Atrox</strong>? They make completely different genres from progressive metal to industrial, from punk rock to black metal. Well, believe it or not, on Last.fm all these bands <a href="http://www.last.fm/music/Atrox">share the same page</a>. They share the same photo gallery, the same tag cloud, the same shoutbox, the same events box and, of course, <strong>the same listeners</strong>. What were they thinking when they designed this? I don&#8217;t know. Anyway, if you are curious about other bands sharing the same page, <a href="http://www.last.fm/group/Multiple+Artists+of+the+Same+Name">check out this group</a>.</li>
</ul>
<p>Okay, other than all this, Last.fm is cool. I&#8217;ve always been using it since the Audioscrobbler days, and even if I was kind of desperate when the new shitty design went live (just like anybody else), today I&#8217;m still a paying subscriber anyway &#8211; so I can say I am definitely addicted to it. If you don&#8217;t know about it, you should definitely <a href="http://last.fm">check it out</a>. And as for the radio thing, there&#8217;s a 30 days trial period so you can try it for free before subscribing. <strong>Happy listening!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://valadilene.org/2010/01/07/some-reasons-why-last-fm-sucks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordBB 0.2 Beta Released</title>
		<link>http://valadilene.org/2009/10/29/wordbb-0-2-beta-released/</link>
		<comments>http://valadilene.org/2009/10/29/wordbb-0-2-beta-released/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 01:54:33 +0000</pubDate>
		<dc:creator>Hangman</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[WordBB]]></category>
		<category><![CDATA[MyBB]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://valadilene.org/?p=589</guid>
		<description><![CDATA[A new WordBB version has just been released. You can get it on the official WordPress.org WordBB page. Here&#8217;s the changelog: Now it&#8217;s possible to post a comment on the forums through WP&#8217;s form Added &#8220;Redirect to MyBB thread when using WP&#8217;s comment form&#8221; setting Fixed bug in Sync function Fixed bug in get_comment_link() hook [...]]]></description>
			<content:encoded><![CDATA[<p>A new WordBB version has just been released. You can get it on the official <a href="http://wordpress.org/extend/plugins/wordbb/">WordPress.org</a> WordBB page. Here&#8217;s the changelog:</p>
<p><img src="http://valadilene.org/wp-content/uploads/2009/08/wordbb1.png" alt="wordbb" title="wordbb" width="236" height="58" class="alignright size-full wp-image-374" /></p>
<ul>
<li>Now it&#8217;s possible to post a comment on the forums through WP&#8217;s form</li>
<li>Added &#8220;Redirect to MyBB thread when using WP&#8217;s comment form&#8221; setting</li>
<li>Fixed bug in Sync function</li>
<li>Fixed bug in get_comment_link() hook</li>
<li>Now you can leave &#8220;Default Post Forum&#8221; empty in order to avoid syncing by default (and maybe enable it only for specific categories in &#8220;WordBB Categories&#8221; section)</li>
<li>Fixed createPost function bug</li>
<li>Fixed bug in get_comments_number() hook</li>
</ul>
<p>The most important feature is that you don&#8217;t need to hide your WP form anymore: you can just use it and it will post comments on MyBB directly from your WordPress blog without forcing your users to go on the forums (of course the user must be logged in). Some template tweaking is still required, as you may want to show the username of the currently logged in MyBB user near the comment form.</p>
<p>As usual, you can report bugs and glitches on this blog post. <strong>Happy merging!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://valadilene.org/2009/10/29/wordbb-0-2-beta-released/feed/</wfw:commentRss>
		<slash:comments>65</slash:comments>
		</item>
		<item>
		<title>Interview with vgmTorrents Creator (mirror)</title>
		<link>http://valadilene.org/2009/10/18/interview-with-vgmtorrents-creator-mirror/</link>
		<comments>http://valadilene.org/2009/10/18/interview-with-vgmtorrents-creator-mirror/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 02:01:43 +0000</pubDate>
		<dc:creator>Hangman</dc:creator>
				<category><![CDATA[Interviews]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[techloid]]></category>
		<category><![CDATA[vgmtorrents]]></category>

		<guid isPermaLink="false">http://valadilene.org/?p=573</guid>
		<description><![CDATA[Unfortunately Techloid.com has recently closed, so I&#8217;m mirroring their interview with vgmTorrents creator (i.e. me) here. Interview with vgmTorrents creator Ahh, Italy. Home to Ferrari, Valentino, the Renaissance, The Mafia, Pizza, Leonardo da Vinci, Enrico Fermi and many beautiful women! But that&#8217;s not all. Italy is also home to Rosario, a game developer who lives [...]]]></description>
			<content:encoded><![CDATA[<p>Unfortunately <a href="http://Techloid.com" title="http://Techloid.com" class="autohyperlink" target="_blank">Techloid.com</a> has recently closed, so I&#8217;m mirroring their interview with vgmTorrents creator (i.e. me) here.</p>
<h2>Interview with vgmTorrents creator</h2>
<p>Ahh, Italy. Home to <a href="http://www.ferrari.com/English/Pages/Home.aspx">Ferrari</a>, <a href="http://www.valentino.com/">Valentino</a>, <a href="http://history-world.org/renaissance.htm">the Renaissance</a>, <a href="http://en.wikipedia.org/wiki/Mafia">The Mafia</a>, <a href="http://en.wikipedia.org/wiki/History_of_pizza">Pizza</a>, <a href="http://www.mos.org/leonardo/">Leonardo da Vinci</a>, <a href="http://nobelprize.org/nobel_prizes/physics/laureates/1938/fermi-bio.html">Enrico Fermi</a> and many <a href="http://www.italylogue.com/about-italy/italian-women-13-hottest-soccer-wags.html">beautiful women</a>!</p>
<p>But that&#8217;s not all. Italy is also home to Rosario, a game developer who lives and works there. Rosario is the creator of <a href="http://www.vgmtorrents.com/">vgmTorrents</a>, a private video game music tracker. After discovering his <a href="http://valadilene.org/2009/07/15/how-to-create-a-torrent-tracker-part-2-upload-form/">how-to on building a torrent tracker</a>, we exchanged emails and sent him a bunch of questions on vgmTorrents, video game music, The Pirate Bay and the future of torrents and file-sharing:</p>
<p><span id="more-573"></span></p>
<p><strong>TECHLOID</strong>: Howdy, can you tell us a little bit about yourself, where you&#8217;re from, what you do, some of the basics?</p>
<p><strong>vgmTorrents</strong>: I&#8217;m Rosario and I live and work in Italy as a game developer. I&#8217;ve always been interested in computers and programming since I was a kid, and eventually this has become a job. Now I&#8217;m currently working as a freelancer with a friend of mine on our own indie game. I&#8217;ve always loved music and videogames, although only in relatively recent times I&#8217;ve discovered my passion for video game music. </p>
<p>I&#8217;m into web development (and recently blogging) as well, I love the idea behind BitTorrent and private trackers and I&#8217;ve always liked building communities, so I thought it would&#8217;ve been cool to mix all those things into a personal project.</p>
<p><strong>TL</strong>: How long have you been messing about with BitTorrent, what go you interested in BT?</p>
<p><strong>VGMT</strong>: I think the first time I ever tried to download a torrent was something like five or six years ago, when I still used a dial-up connection. I&#8217;ve always shared files since I had a modem, but being really young at that time, I wasn&#8217;t really aware of what was going on, you know, technically speaking.</p>
<p>Even now, when ideas about vgmTorrents started popping out in my mind, I didn&#8217;t know that much about BitTorrent, I was just an avid downloader but nothing more. </p>
<p>What really motivated me, on top of my passion for video game music, was the fact that I actually started discovering VGM and listening to it regularly thanks to file sharing. If it wasn&#8217;t for P2P, I would never have known about game composers and soundtracks at all. So that&#8217;s the main reason that inspired me in building my own tracker. The work on it took more than a month, in which I searched for information on the protocol, how things worked in terms of programming and so on. Also, in the meantime I became interested in the P2P scene reading news and watching stuff like <a href="http://www.stealthisfilm.com/Part2/">Steal This Film</a>.</p>
<p><strong>TL</strong>: Okay, vgmTorrents, what is it and why?</p>
<p><strong>VGMT</strong>: vgmTorrents is a private BitTorrent tracker which tries to collect any kind of content related to video game music. Soundtracks, rearrangements, remixes, fan made tribute albums, videos, documentaries, interviews, all of these can be uploaded on the site. I don&#8217;t exactly know if anyone except for me ever felt the need for this, I personally don&#8217;t know not even one VGM fan in real life, so it *must* be a niche, that&#8217;s for sure. </p>
<p>Anyway, the idea was to have a single place where anyone could upload not only the classic and well known soundtracks, but especially the rare stuff, such as rips of old games, western soundtracks which are often hard to find, high quality FLAC releases and so on. But, on top of that, what I really felt the site needed was a strong community built around it. In fact another reason why I decided to create vgmTorrents was that I wanted to meet people with my same interest in this kind of music. This is reflected by the structure of the site, for example the homepage is a blog with news from the VGM industry and P2P scene, which I don&#8217;t think is something you usually see on a torrent tracker. We also have a Features section with user-written articles and, of course, the forums, where you can introduce yourself, meet other VGM fans, or request a particular release.</p>
<p><strong>TL</strong>: What&#8217;s your experience, thus far, running your own tracker, how do you feel about the legal issues and what are you doing to cover your ass (if anything?) Is it expensive, complicated? Do you use a third-party to host the setup?</p>
<p><strong>VGMT</strong>: Actually, I never really thought about legal issues that much. I did a bit of research before I started working on the project, and I saw there are already some VGM sites around, but it looks like none of them have ever received not even a cease and desist letter or something. Also, have a quick look on eBay for soundtrack titles and you&#8217;ll find that 99% of them are pirated bootlegs, and you know, no one does anything for that, and I consider it to be the *real* piracy &#8212; so why should they even bother about a small torrent community? </p>
<p>On top of that, I don&#8217;t think this kind of activity would kill the industry at all, instead it can only help in spreading this kind of music even more. I don&#8217;t think a lot of people would buy a 30 USD worth soundtrack they have never heard before, coming from a store on the other side of the world, so, just like it happens for a lot of other stuff, file sharing actually helps artists in having their works heard by everyone. I&#8217;m sure that people who really like this music will eventually buy the real thing, and that&#8217;s why you can find a &#8220;Buy original CD&#8221; on each torrent page on the site. We also try to constantly talk and inform people about bootlegs, which, as I already said, are the real problem the industry should fight against, from my point of view. Nobody wins from that, except for -obviously- the bootleggers: the buyer gets a crappy and pirated copy of the CD thinking he has bought the real thing for a cheaper price, the companies lose all the money, and what&#8217;s worse is that you can&#8217;t do much to get your money back once you&#8217;ve been cheated.</p>
<p><strong>TL</strong>: What about the vgm community on your site, is it mostly leechers or does everyone play their part? vgmTorrents is still young, what&#8217;s your growth looking like? What sort of stats can you provide?</p>
<p><strong>VGMT</strong>: Of course most of the users come on the site searching for torrents on search engines, and a lot of them won&#8217;t seed after downloading (they will lose the ability to leech after they&#8217;ve reached a particular amount of downloaded data, though). But that&#8217;s obvious; I mean, I can&#8217;t pretend anyone to be interested in VGM and in regularly sharing it: the occasional leecher is okay as long as the ratio system detects it and kicks his/her ass! *laughs* Seriously speaking, of course I understand that not everybody out there is a VGM fanatic willing to share any single soundtrack, although it&#8217;s evident that seeding is important on small niche trackers like vgmTorrents. </p>
<p>Anyway, on the other side, I&#8217;ve been surprised seeing how many people have uploaded even rare stuff on the site. I uploadeded and seeded most of the torrents there, but we wouldn&#8217;t have 260+ torrents now if it wasn&#8217;t for those guys and gals, who of course are the same people posting on the forums and talking about their favourite composers and soundtracks.</p>
<p><strong>TL</strong>: Are you aware of any other trackers or indexers that are focusing on video game music? Where do you want the site to be in less than a year from now?</p>
<p><strong>VGMT</strong>: Actually at first I was like &#8220;hey, I&#8217;m sure there&#8217;s a VGM torrent community out there, I&#8217;m going to find it and register so I can meet some VGM people&#8221;. So I went on Google and tried a search, but I was surprised I couldn&#8217;t find anything similar to what I had in my mind&#8230; so in the end I just did it on my own. </p>
<p>Of course there are a few VGM sites I know, such as <a href="http://gh.ffshrine.org/">Galbadia Hotel</a> and <a href="http://www.gamemp3s.net/">gamemp3s</a>, the latter actually being a public tracker, but there isn&#8217;t a community there, and you can&#8217;t upload your stuff &#8212; it&#8217;s all managed by the sysops, so that&#8217;s obviously a completely different kind of website. As for GH, they&#8217;ve always had huge problems in terms of management and server bandwidth (they host plain HTTP downloads), also there have been a lot of cases of files containing viruses and malware, so you know, it just looks like people are not really happy with it.</p>
<p>As for my own tracker, I&#8217;d really like it if more people posted on <a href="http://vgmtorrents.net/forums/">the forums</a>, I really love that aspect of the site and I&#8217;d be glad to see it growing in that direction. Also, it would be awesome to spread the word about unknown remixers and musicians rearranging game soundtracks, just like we already did recently for a Doom 2 music remake project. So if someone reading this is remixing or playing some VGM tune, we would be more than happy to feature their stuff and give them more visibility to video game music fans. </p>
<p>Finally, of course the main goal is to be the best place on the net where to find the newest and rarest VGM releases, and to be a cool way to meet new people with the same taste and interest in this genre.</p>
<p><strong>TL</strong>: I&#8217;m not an avid gamer, or big into vgm (but I did like the music from <a href="http://en.wikipedia.org/wiki/Airwolf_(video_game)">Air Wolf for NES</a>, as well as <a href="http://en.wikipedia.org/wiki/Super_Mario_Bros.">Mario Bros 1</a>, it was cheesy and cheerful), is video game music really that hip that it deserves a dedicated tracker?</p>
<p><strong>VGMT</strong>: I have to admit that when I was an avid gamer (now I spend most of my time working on games rather than playing them), starting with the PlayStation, I was already hooked on the celtic and folky tracks of games such as <a href="http://en.wikipedia.org/wiki/Chrono_Cross">Chrono Cross</a>, the creepy ambient stuff of <a href="http://en.wikipedia.org/wiki/Silent_Hill">Silent Hill</a> and <a href="http://en.wikipedia.org/wiki/Parasite_Eve_(video_game)">Parasite Eve</a>, the inspired melody crafting in games such as <a href="http://en.wikipedia.org/wiki/Spyro_(series)">Spyro the Dragon</a>&#8230; and after all I realized I felt much more comfortable when playing something with music I liked as a background. It was an huge part of the gaming experience for me, and it became so important that at one point I started looking for game music MP3s on the Internet. It soon became an huge passion and I spent a lot of time listening to both soundtracks of old games I played when I was a kid and new releases, even from games I didn&#8217;t even know.</p>
<p>What&#8217;s cool about VGM is that it&#8217;s not only a part of those great experiences we all have when playing good games, but on top of that, out of the game it can still be great music, even as stand-alone. Also it&#8217;s not limited to a single genre, but instead it covers any kind of music, spanning from orchestral music to ambient, from jazz to metal, including most kinds of electronic genres and so on. </p>
<p>Video game music has become much more important than ever in the last decade &#8212; most composers, especially Japanese ones, are popular among videogamers and some of them have even successfully performed live in various parts of the world. So, after all, I think there really was a need for one dedicated place featuring this kind of stuff, as I&#8217;m sure there are a lot of fans out there that are willing to collect their favourite music and support the project.</p>
<p><strong>TL</strong>: The selling of The Pirate Bay. Alot of their users had a cow and freaked out, especially because of the trust and belief in TPB and what they were doing (i.e., sticking it to The Man). At the same time, others were decent enough about it and understood their position. What are your thoughts?</p>
<p><strong>VGMT</strong>: I was very surprised to see them selling out, but after all it was clear they didn&#8217;t have any other choice. As for the site, I always laughed thinking about how a legal file sharing site could be named &#8220;The Pirate Bay&#8221;! Seriously speaking, I just think we&#8217;re going to see it become yet another Napster and fading out into obscurity.</p>
<p><strong>TL</strong>: Folks say that The Pirate Bay was responsible for a lot of the overall BitTorrent traffic. Assuming that the new TPB sinks, what&#8217;s the future of BitTorrent? Other trackers have stepped up like <a href="http://openbittorrent.com/">OpenBitTorrent</a> and PublicBit Torrent. Is order returning to the BT universe? What about other p2p technologies?How do you feel about streaming music and movies? What would you like to see in the BT protocol?</p>
<p><strong>VGMT</strong>: I think that the future of BitTorrent is pretty clear: for each tracker that gets closed, plenty of new ones pop up the day after. I guess it&#8217;s near to impossible for RIAA or whatever to shut down all of them. Nothing will stop people to do what they want, i.e. share stuff. As for OpenBitTorrent and similar projects, I think that it&#8217;s just what the scene needed, i.e. a public tracker not directly linked to an indexing site which is what causes most of legal issues, I guess. I&#8217;m not sure about video streaming sites such as <a href="http://www.megavideo.com/">MegaVideo</a> or similar, I guess that from a legal point of view they&#8217;re easier to shut down because they&#8217;re actually hosting copyrighted data.</p>
<p>On the other side, as for the legal way of streaming, I think that web radios such as <a href="http://www.pandora.com/">Pandora</a> and <a href="http://www.last.fm/">Last.fm</a> were pretty cool before they decided to restrict the services to certain areas and/or to let users pay. Are we supposed to pay monthly for a service that doesn&#8217;t play exactly what we really want to hear? The random radio thing was funny to discover new stuff, sometimes annoying because it randomly played unrelated tracks, mostly useless when looking for less known kinds of music (e.g. VGM!)&#8230; but now I think that paying for that is non-sense, and fortunately there&#8217;s been an huge reaction from the users against that. Of course my feeling is even worse towards all kinds of sites trying to sell <a href="http://en.wikipedia.org/wiki/Digital_rights_management">DRM</a> bloated crap.</p>
<p><strong>TL</strong>: Finally, is there anything you&#8217;d like to say to the users of the internets?</p>
<p><strong>VGMT</strong>: Maybe it&#8217;s trivial and it&#8217;s been said a lot yet, but I&#8217;d like to add that even if file sharing is really important and cool, I feel like people should care more about artists and support them if possible. Buy the CDs you actually like, go to live gigs and&#8230; please seed! *laughs*</p>
<p><strong>TL</strong>: Thank you very much, Rosario and <a href="http://starwars.wikia.com/wiki/May_the_Force_be_with_you">may the Force be with you</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://valadilene.org/2009/10/18/interview-with-vgmtorrents-creator-mirror/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordBB Research and Feature Suggestions</title>
		<link>http://valadilene.org/2009/10/12/wordbb-research-and-feature-suggestions/</link>
		<comments>http://valadilene.org/2009/10/12/wordbb-research-and-feature-suggestions/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 01:45:07 +0000</pubDate>
		<dc:creator>Hangman</dc:creator>
				<category><![CDATA[WordBB]]></category>

		<guid isPermaLink="false">http://valadilene.org/?p=562</guid>
		<description><![CDATA[I&#8217;m just wondering how many people out there are actually using WordBB on live websites and enjoying it. If you are one of those, please comment this post. I noticed most of you have some problems with theme editing, which is okay since it requires some PHP/HTML skills. If this is your case, please give [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m just wondering how many people out there are actually using <a href="http://valadilene.org/wordbb">WordBB</a> on live websites and enjoying it. If you are one of those, please comment this post.<br />
I noticed most of you have some problems with theme editing, which is okay since it requires some PHP/HTML skills. If this is your case, please give a look at the <a href="http://valadilene.org/wordbb-documentation">documentation</a> and let me know if there&#8217;s something you still don&#8217;t get or are in trouble with. I can&#8217;t offer much support (too busy with work and other stuff) but I&#8217;d be glad to improve documentation and tutorials if there&#8217;s the need.</p>
<p>Also, if you&#8217;re looking for new features on WordBB, now it&#8217;s a good time to ask.</p>
]]></content:encoded>
			<wfw:commentRss>http://valadilene.org/2009/10/12/wordbb-research-and-feature-suggestions/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>YouTube’s Comment System Sucks</title>
		<link>http://valadilene.org/2009/09/29/youtubes-comment-system-sucks/</link>
		<comments>http://valadilene.org/2009/09/29/youtubes-comment-system-sucks/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 18:59:34 +0000</pubDate>
		<dc:creator>Hangman</dc:creator>
				<category><![CDATA[Sucks-Rant]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[sucks]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://valadilene.org/?p=540</guid>
		<description><![CDATA[We&#8217;re almost at the end of year 2009, and the commenting system on YouTube still sucks like horseshit. I followed its evolution throughout the years, but nothing has really improved. The worst thing of all this is that people don&#8217;t seem to realize it, and a lot of them use YouTube comments to make incredibly [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://valadilene.org/wp-content/uploads/2009/09/youtube.PNG"><img src="http://valadilene.org/wp-content/uploads/2009/09/youtube.PNG" alt="youtube" title="youtube" width="116" height="63" class="alignright size-full wp-image-542" /></a>We&#8217;re almost at the end of year 2009, and the commenting system on YouTube still sucks like horseshit.<br />
I followed its evolution throughout the years, but nothing has really improved. The worst thing of all this is that people don&#8217;t seem to realize it, and a lot of them use YouTube comments to make incredibly elaborated conversations (mostly flames) that go on even for days.<br />
Anyway, here&#8217;s my list of reasons why <strong>commenting on YouTube sucks</strong>.</p>
<p><span id="more-540"></span></p>
<ul>
<li><strong>Disorganization:</strong> any video on YouTube, even the most obscure one, has an incredible amount of comments. From one of the most visited websites on the Internet, one would expect at least features such as threaded comments and paging. Forget about them on YouTube. Welcome to a world of madness, where your messages will be buried within minutes after posting and replies are just orphan pieces of text lying around in the mess.</li>
<li><strong>Poor use of AJAX:</strong> since the boom of Web 2.0, I&#8217;ve never seen a comment system not using AJAX technlogies. A proper use of AJAX would be, for example, allowing the user to see the comment he/she has just posted without reloading the page. Guess what? YouTube is not able to do this (and we&#8217;re talking about a video streaming website, where you would expect to be able to use controls in the page while still playing your video).</li>
<p><a href="http://valadilene.org/wp-content/uploads/2009/09/youtube-comments.PNG"><img src="http://valadilene.org/wp-content/uploads/2009/09/youtube-comments-300x174.PNG" alt="youtube-comments" title="youtube-comments" width="300" height="174" class="alignright size-medium wp-image-541" /></a></p>
<li><strong>Even more disorganization:</strong> suppose you want to read all the comments posted for a specific video: easy, there&#8217;s the &#8220;View all comments&#8221; link at the bottom. Now suppose that specific video is about a farting baby. YouTube will show the whole pack of a thousand comments <strong>in a single page</strong>! This is not only impracticable for reading, but it also forces you to download an huge amount of data at once.</li>
<li><strong>No basic features:</strong> as an effect of all the previous reasons, there&#8217;s no way to collapse threads (that would make it a bit less messy), no custom sorting (oldest or newest first) and no way to choose how many comments to show per page.</li>
</ul>
<p>Well, I guess this is enough to say without any doubt that the comment system on YouTube is a <strong>total fail</strong>. Not to count that the actual content of the comments is pure garbage and there&#8217;s a flame even on the most insignificant video out there, but that&#8217;s another story.</p>
]]></content:encoded>
			<wfw:commentRss>http://valadilene.org/2009/09/29/youtubes-comment-system-sucks/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How to Create a Torrent Tracker: Part 4 – Search Engine</title>
		<link>http://valadilene.org/2009/09/07/how-to-create-a-torrent-tracker-part-4-%e2%80%93-search-engine/</link>
		<comments>http://valadilene.org/2009/09/07/how-to-create-a-torrent-tracker-part-4-%e2%80%93-search-engine/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 15:59:36 +0000</pubDate>
		<dc:creator>Hangman</dc:creator>
				<category><![CDATA[BitTorrent]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[search engine]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://valadilene.org/?p=462</guid>
		<description><![CDATA[One of the most important parts of a torrent site is definitely the search engine. It is probably the first thing people are going to use, and a bug free search form will greatly improve user experience. In this tutorial, we are going to implement a Browse section including torrent details columns, paging, and a [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most important parts of a torrent site is definitely the search engine. It is probably the first thing people are going to use, and a bug free search form will greatly improve user experience.<br />
In this tutorial, we are going to implement a Browse section including torrent details columns, paging, and a form which will be used to filter results based on search queries.</p>
<p><span id="more-462"></span></p>
<h3>Torrents table</h3>
<p>As a first step, we build an HTML table containing all of our torrents. I assume you have added the <strong>name</strong> and <strong>size</strong> fields in your <strong>xbt_files</strong> table.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;">&lt;table&gt;<br />
&lt;tr&gt;&lt;th&gt;Date&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Size&lt;/th&gt;&lt;th&gt;Seeds&lt;/th&gt;&lt;th&gt;Leechers&lt;/th&gt;&lt;/tr&gt;</p>
<p><span class="kw2">&lt;?php</span><br />
<span class="re0">$q</span><span class="sy0">=</span><a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="st0">&quot;SELECT name,size,seeders,leechers,ctime FROM xbt_files&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw1">while</span><span class="br0">&#40;</span><span class="re0">$t</span><span class="sy0">=</span><a href="http://www.php.net/mysql_fetch_row"><span class="kw3">mysql_fetch_row</span></a><span class="br0">&#40;</span><span class="re0">$q</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="sy1">?&gt;</span><br />
&lt;tr&gt;&lt;td&gt;<span class="kw2">&lt;?php</span> <span class="kw1">echo</span> <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="st0">&quot;j M y&quot;</span><span class="sy0">,</span><span class="re0">$t</span><span class="sy0">-&gt;</span><span class="me1">ctime</span><span class="br0">&#41;</span> <span class="sy1">?&gt;</span>&lt;/td&gt;&lt;td&gt;<span class="kw2">&lt;?php</span> <span class="kw1">echo</span> <span class="re0">$t</span><span class="sy0">-&gt;</span><span class="me1">name</span> <span class="sy1">?&gt;</span>&lt;/td&gt;&lt;td&gt;<span class="kw2">&lt;?php</span> <span class="kw1">echo</span> <span class="re0">$t</span><span class="sy0">-&gt;</span><span class="me1">size</span> <span class="sy1">?&gt;</span>&lt;/td&gt;&lt;td&gt;<span class="kw2">&lt;?php</span> <span class="kw1">echo</span> <span class="re0">$t</span><span class="sy0">-&gt;</span><span class="me1">seeds</span> <span class="sy1">?&gt;</span>&lt;/td&gt;&lt;td&gt;<span class="kw2">&lt;?php</span> <span class="kw1">echo</span> <span class="re0">$t</span><span class="sy0">-&gt;</span><span class="me1">leechers</span> <span class="sy1">?&gt;</span>&lt;/td&gt;&lt;/tr&gt;<br />
<span class="kw2">&lt;?php</span><br />
<span class="br0">&#125;</span><br />
<span class="sy1">?&gt;</span></p>
<p>&lt;/table&gt;</p></div>
</div>
<p>This code will show a table listing all the torrent records contained in our database. It will seem good as long as we don&#8217;t have more than 25 torrents on our tracker. Otherwise, we are definitely going to need to split our table in different pages. We are going to edit our SQL query using the <strong>LIMIT</strong> clause and show a navigation bar below the table containing links to pages.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw2">&lt;?php</span><br />
<a href="http://www.php.net/define"><span class="kw3">define</span></a><span class="br0">&#40;</span><span class="st_h">&#8216;ROWS_PER_PAGE&#8217;</span><span class="sy0">,</span>25<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="re0">$page</span><span class="sy0">=</span><a href="http://www.php.net/intval"><span class="kw3">intval</span></a><span class="br0">&#40;</span><span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st_h">&#8216;p&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$page</span><span class="sy0">&lt;</span>1<span class="br0">&#41;</span> <span class="re0">$page</span><span class="sy0">=</span><span class="nu0">1</span><span class="sy0">;</span><br />
<span class="re0">$offset</span><span class="sy0">=</span><span class="br0">&#40;</span><span class="re0">$page</span><span class="sy0">-</span>1<span class="br0">&#41;</span><span class="sy0">*</span>ROWS_PER_PAGE<span class="sy0">;</span></p>
<p><span class="co1">// main query</span><br />
<span class="re0">$q</span><span class="sy0">=</span><a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="st0">&quot;SELECT SQL_CALC_FOUND_ROWS name,size,seeders,leechers,ctime FROM xbt_files LIMIT <span class="es4">$offset</span>,&quot;</span><span class="sy0">.</span>ROWS_PER_PAGE<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="re0">$num_rows</span><span class="sy0">=</span><a href="http://www.php.net/mysql_fetch_row"><span class="kw3">mysql_fetch_row</span></a><span class="br0">&#40;</span><a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="st0">&quot;SELECT FOUND_ROWS()&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="re0">$max_page</span><span class="sy0">=</span><a href="http://www.php.net/ceil"><span class="kw3">ceil</span></a><span class="br0">&#40;</span><span class="re0">$num_rows</span><span class="sy0">/</span>ROWS_PER_PAGE<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$max_page</span> <span class="sy0">&gt;</span> 0 <span class="sy0">&amp;&amp;</span> <span class="re0">$page</span><span class="sy0">&gt;</span><span class="re0">$max_page</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$page</span><span class="sy0">=</span><span class="nu0">1</span><span class="sy0">;</span></p>
<p><span class="co1">//</span><br />
<span class="co1">// &#8230; table code&#8230;</span><br />
<span class="co1">//</span></p>
<p><span class="co1">// build navigation bar code</span><br />
<span class="re0">$nav</span><span class="sy0">=</span><span class="st_h">&#8221;</span><span class="sy0">;</span><br />
<span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$p</span><span class="sy0">=</span><span class="nu0">1</span><span class="sy0">;</span> <span class="re0">$p</span><span class="sy0">&lt;=</span><span class="re0">$max_page</span><span class="sy0">;</span> <span class="re0">$p</span><span class="sy0">++</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$start</span><span class="sy0">=</span><span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$p</span><span class="sy0">-</span>1<span class="br0">&#41;</span><span class="sy0">*</span>ROWS_PER_PAGE<span class="br0">&#41;</span><span class="sy0">+</span><span class="nu0">1</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$end</span><span class="sy0">=</span><span class="re0">$p</span><span class="sy0">*</span>ROWS_PER_PAGE<span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$end</span><span class="sy0">&gt;</span><span class="re0">$num_rows</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$end</span><span class="sy0">=</span><span class="re0">$num_rows</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$p</span> <span class="sy0">==</span> <span class="re0">$page</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$nav</span> <span class="sy0">.=</span> <span class="st0">&quot;<span class="es4">{$start}</span> &#8211; <span class="es4">{$end}</span> | &quot;</span><span class="sy0">;</span> <span class="co1">// no need to create a link to current page</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$page_url</span><span class="sy0">=</span><span class="st_h">&#8216;browse.php?p=&#8217;</span><span class="sy0">.</span><span class="re0">$p</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$nav</span> <span class="sy0">.=</span> <span class="st_h">&#8216;&lt;a href=&quot;&#8217;</span><span class="sy0">.</span><span class="re0">$page_url</span><span class="sy0">.</span><span class="st_h">&#8216;&quot;&gt;&#8217;</span><span class="sy0">.</span><span class="st0">&quot;<span class="es4">{$start}</span> &#8211; <span class="es4">{$end}</span>&quot;</span><span class="sy0">.</span><span class="st_h">&#8216;&lt;/a&gt; | &#8216;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="re0">$nav</span><span class="sy0">=</span><a href="http://www.php.net/rtrim"><span class="kw3">rtrim</span></a><span class="br0">&#40;</span><span class="re0">$nav</span><span class="sy0">,</span><span class="st_h">&#8216; | &#8216;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="sy1">?&gt;</span></p>
<p><span class="kw2">&lt;?php</span> <span class="kw1">if</span><span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/empty"><span class="kw3">empty</span></a><span class="br0">&#40;</span><span class="re0">$nav</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">:</span> <span class="sy1">?&gt;</span></p>
<p>&lt;div id=&quot;page-navigation&quot;&gt;<br />
<span class="kw2">&lt;?php</span> <span class="kw1">echo</span> <span class="re0">$nav</span> <span class="sy1">?&gt;</span><br />
&lt;/div&gt;</p>
<p><span class="kw2">&lt;?php</span> <span class="kw1">endif</span> <span class="sy1">?&gt;</span></div>
</div>
<p>Note that, after the <strong>SELECT</strong> query with the <strong>LIMIT</strong> clause, we make another query using the <strong>FOUND_ROWS()</strong> function in order to get the number of rows found with the previous query. Then we divide that value by the maximum number of rows per page we want to show, which gives us the number of total pages for this query; using this data, we are able to build a navigation bar.<br />
As an exercise, you could add a <strong>sort</strong> parameter which will control the order of the results by using the <strong>ORDER BY</strong> clause.</p>
<h3>Simple search form</h3>
<p>Now that we have built a table capable of showing torrents, we are ready to implement a way to filter our entries. Here&#8217;s the code for our bare bones search form.</p>
<div class="codesnip-container" >
<div class="html4strict codesnip" style="font-family:monospace;"><span class="sc2">&lt;<a href="http://december.com/html/4/element/form.html"><span class="kw2">form</span></a> <span class="kw3">action</span><span class="sy0">=</span><span class="st0">&quot;browse.php&quot;</span> <span class="kw3">method</span><span class="sy0">=</span><span class="st0">&quot;get&quot;</span>&gt;</span><br />
<span class="sc2">&lt;<a href="http://december.com/html/4/element/input.html"><span class="kw2">input</span></a> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text&quot;</span> <span class="kw3">name</span><span class="sy0">=</span><span class="st0">&quot;q&quot;</span> <span class="sy0">/</span>&gt;</span><br />
<span class="sc2">&lt;<a href="http://december.com/html/4/element/input.html"><span class="kw2">input</span></a> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;submit&quot;</span> <span class="kw3">value</span><span class="sy0">=</span><span class="st0">&quot;Search&quot;</span> <span class="sy0">/</span>&gt;</span><br />
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/form.html"><span class="kw2">form</span></a>&gt;</span></div>
</div>
<p>In our PHP script we are going to handle the <strong>q</strong> parameter. As a first example, we are going to try the simplest way to filter rows with MySQL, which is using the <strong>LIKE</strong> clause on the torrent&#8217;s <strong>name</strong> field. Let&#8217;s add this code at the beginning of our script:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw2">&lt;?php</span><br />
<span class="re0">$search</span><span class="sy0">=</span><span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st_h">&#8216;q&#8217;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
<span class="re0">$search</span><span class="sy0">=</span><a href="http://www.php.net/mysql_real_escape_string"><span class="kw3">mysql_real_escape_string</span></a><span class="br0">&#40;</span><span class="re0">$search</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="sy1">?&gt;</span></div>
</div>
<p>And then we edit our main query:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw2">&lt;?php</span><br />
<span class="re0">$q</span><span class="sy0">=</span><a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="st0">&quot;SELECT SQL_CALC_FOUND_ROWS name,size,seeders,leechers,ctime FROM xbt_files WHERE name LIKE &#8216;%&quot;</span><span class="sy0">.</span><span class="re0">$search</span><span class="sy0">.</span><span class="st0">&quot;%&#8217; LIMIT <span class="es4">$offset</span>,&quot;</span><span class="sy0">.</span>ROWS_PER_PAGE<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="sy1">?&gt;</span></div>
</div>
<p>With this code, searching for &#8220;pear&#8221; will show only torrents that contain the word &#8220;pear&#8221; in their names. But what if we have a torrent containing &#8220;appearance&#8221;? It will be shown as well. This is because we put the &#8220;%&#8221; symbol before and after the search term. If we didn&#8217;t do so, our query would have returned only torrents named exactly &#8220;pear&#8221;, which is definitely something we don&#8217;t want.<br />
As we have seen, the <strong>LIKE</strong> clause is very limited and is not suitable for a real world search engine. So we are going to explore a different way to search in strings: <strong>regular expressions</strong>.</p>
<h3>A step further: RegEx</h3>
<p>Regular expressions are a way of identifying strings of text through search patterns written in a formal language. Think of them as a much more advanced version of wildcards. MySQL has a built-in RegEx processor which can be used through the <strong>REGEXP</strong> function.<br />
In the following snippet we are going to modify our query in order to use regexes for searching. We will also look for spaces in our search keyword and split the words into an array.<br />
Additionally, since our query is getting long, it will be split into multiple parts which we&#8217;ll eventually concatenate into a new string, so that our code will be a bit easier to read.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw2">&lt;?php</span></p>
<p><span class="re0">$search</span><span class="sy0">=</span><span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st_h">&#8216;q&#8217;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
<span class="re0">$search</span><span class="sy0">=</span><a href="http://www.php.net/mysql_real_escape_string"><span class="kw3">mysql_real_escape_string</span></a><span class="br0">&#40;</span><span class="re0">$search</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="co1">// split query string into an array of words</span><br />
<span class="re0">$search</span><span class="sy0">=</span><a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st_h">&#8216; &#8216;</span><span class="sy0">,</span><span class="re0">$search</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="re0">$sql</span><span class="sy0">=</span><span class="st0">&quot;SELECT SQL_CALC_FOUND_ROWS name,size,seeders,leechers,ctime FROM xbt_files &quot;</span><span class="sy0">;</span></p>
<p><span class="co1">// where clause</span><br />
<span class="re0">$sql</span><span class="sy0">.=</span><span class="st0">&quot;WHERE name LIKE &#8216;%&quot;</span><span class="sy0">.</span><span class="re0">$search</span><span class="sy0">.</span><span class="st0">&quot;%&#8217; &quot;</span><span class="sy0">;</span></p>
<p><span class="co1">// regexp</span></p>
<p><span class="kw1">if</span><span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/empty"><span class="kw3">empty</span></a><span class="br0">&#40;</span><span class="re0">$search</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sql</span><span class="sy0">.=</span><span class="st_h">&#8216;(&#8216;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$search</span> <span class="kw1">as</span> <span class="re0">$word</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$word</span><span class="sy0">=</span><a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span><span class="re0">$word</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sql</span><span class="sy0">.=</span> <span class="st0">&quot;(`name` REGEXP &#8216;[[:&lt;:]]&quot;</span><span class="sy0">.</span><span class="re0">$word</span><span class="sy0">.</span><span class="st0">&quot;[[:&gt;:]]&#8217; OR `description` REGEXP &#8216;[[:&lt;:]]&quot;</span><span class="sy0">.</span><span class="re0">$word</span><span class="sy0">.</span><span class="st0">&quot;[[:&gt;:]]&#8217;) AND &quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sql</span><span class="sy0">=</span><a href="http://www.php.net/rtrim"><span class="kw3">rtrim</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="sy0">,</span><span class="st_h">&#8216; AND &#8216;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sql</span><span class="sy0">.=</span><span class="st_h">&#8216;)&#8217;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">// limit</span><br />
<span class="re0">$sql</span><span class="sy0">.=</span><span class="st0">&quot;LIMIT <span class="es4">$offset</span>,&quot;</span><span class="sy0">.</span>ROWS_PER_PAGE<span class="sy0">;</span></p>
<p><span class="re0">$q</span><span class="sy0">=</span><a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="co1">// &#8230; rest of code &#8230;</span></p>
<p><span class="sy1">?&gt;</span></div>
</div>
<p>This code will basically search for the specified keyword in the torrent&#8217;s name and description through MySQL&#8217;s regex engine. &#8220;<strong>[[:<:]]</strong>&#8221; and &#8220;<strong>[[:>:]]</strong>&#8221; are used for word boundaries, so that if you are looking for &#8220;lane&#8221; it won&#8217;t match &#8220;miscellaneous&#8221;. </p>
<h3>Word stemming</h3>
<p>There&#8217;s a new problem. What if our torrent contains the word &#8220;domain&#8221; and we are searching for &#8220;domains&#8221;? In order for this case to work, we need to use the <strong>stem</strong> of the keyword. Fortunately, this is exactly what the <a href="http://www.chuggnutt.com/stemmer.php">Porter Stemmer</a> algorithm does. </p>
<blockquote><p>The Porter Stemming Algorithm was developed by Martin Porter for reducing English words to their word stems. For example, the word &#8220;connections&#8221; would be reduced to its stem form &#8220;connect.&#8221;</p></blockquote>
<p>In order to use it, first of all we have to include the library in our PHP file; then it&#8217;s simply a matter of adding this code before the call to the <strong>explode</strong> function.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw2">&lt;?php</span></p>
<p><span class="kw1">require_once</span> <span class="st_h">&#8216;class.stemmer.inc&#8217;</span><span class="sy0">;</span></p>
<p><span class="co1">// &#8230;</span></p>
<p><span class="re0">$stemmer</span><span class="sy0">=</span><span class="kw2">new</span> Stemmer<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="re0">$search</span><span class="sy0">=</span><span class="re0">$stemmer</span><span class="sy0">-&gt;</span><span class="me1">stem_list</span><span class="br0">&#40;</span><span class="re0">$search</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="sy1">?&gt;</span></div>
</div>
<h3>Filtering useless stuff</h3>
<p>In a real world search engine, we may want to filter things such as symbols and short words.<br />
So, right after the <strong>explode</strong> call, let&#8217;s add this if statement which will exclude words shorter than 3 characters:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw2">&lt;?php</span></p>
<p><span class="re0">$words</span><span class="sy0">=</span><a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$search</span> <span class="kw1">as</span> <span class="re0">$word</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/strlen"><span class="kw3">strlen</span></a><span class="br0">&#40;</span><span class="re0">$word</span><span class="br0">&#41;</span><span class="sy0">&gt;=</span>3<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$words</span><span class="br0">&#91;</span><span class="br0">&#93;</span><span class="sy0">=</span><span class="re0">$word</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="re0">$search</span><span class="sy0">=</span><span class="re0">$words</span><span class="sy0">;</span></p>
<p><span class="sy1">?&gt;</span></div>
</div>
<p>Then we are ready to deal with useless symbols and punctuation. Let&#8217;s add this code right after the <strong>mysql_real_escape_string</strong> call:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw2">&lt;?php</span></p>
<p><span class="kw2">var</span> <span class="re0">$symbols</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">&#8216;/&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;\&#8217;,&#8217;</span>\<span class="st_h">&#8221;</span><span class="sy0">,</span><span class="st_h">&#8216;&quot;&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;,&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;.&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;&lt;&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;&gt;&#8217;</span><span class="sy0">,</span><br />
<span class="st_h">&#8216;?&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;;&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;:&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;['</span><span class="sy0">,</span><span class="st_h">']&#8216;</span><span class="sy0">,</span><span class="st_h">&#8216;{&#8216;</span><span class="sy0">,</span><span class="st_h">&#8216;}&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;|&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;=&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;+&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;-&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;_&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;)&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;(&#8216;</span><span class="sy0">,</span><span class="st_h">&#8216;*&#8217;</span><span class="sy0">,</span><br />
<span class="st_h">&#8216;&amp;&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;^&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;%&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;$&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;#&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;@&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;!&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;~&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;`&#8217;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$i</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$i</span> <span class="sy0">&lt;</span> <a href="http://www.php.net/sizeof"><span class="kw3">sizeof</span></a><span class="br0">&#40;</span><span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">symbols</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$i</span><span class="sy0">++</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$search</span><span class="sy0">=</span><a href="http://www.php.net/str_replace"><span class="kw3">str_replace</span></a><span class="br0">&#40;</span><span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">symbols</span><span class="br0">&#91;</span><span class="re0">$i</span><span class="br0">&#93;</span><span class="sy0">,</span><span class="st_h">&#8216; &#8216;</span><span class="sy0">,</span><span class="re0">$search</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy1">?&gt;</span></div>
</div>
<h3>Conclusion</h3>
<p>And that&#8217;s it &#8212; we are done with our simple and bare bones search engine. In a real world scenario, you will want to add your own custom things; for example in some cases you may want to extend acronyms (&#8220;ff&#8221; to &#8220;final fantasy&#8221; and so on), filter a list of custom words and stuff like that. This is all up to you and it depends on what you need for your specific website. </p>
<p>See you in the next tutorial and happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://valadilene.org/2009/09/07/how-to-create-a-torrent-tracker-part-4-%e2%80%93-search-engine/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
