<?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>Marcus Povey &#187; Software</title>
	<atom:link href="http://www.marcus-povey.co.uk/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.marcus-povey.co.uk</link>
	<description>Making the world a better place, one byte at a time...</description>
	<lastBuildDate>Fri, 16 Jul 2010 09:00:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<atom:link rel='hub' href='http://www.marcus-povey.co.uk/?pushpress=hub'/>
		<item>
		<title>How to set up ProFTP, MySQL and Virtual Users</title>
		<link>http://www.marcus-povey.co.uk/2010/06/15/proftp-mysql-virtual-users-howto/</link>
		<comments>http://www.marcus-povey.co.uk/2010/06/15/proftp-mysql-virtual-users-howto/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 10:59:45 +0000</pubDate>
		<dc:creator>Marcus Povey</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[proftp]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[virtual users]]></category>

		<guid isPermaLink="false">http://www.marcus-povey.co.uk/?p=551</guid>
		<description><![CDATA[ProFTP is a configurable FTP server available on most *nix platforms. I recently had the need to get this working and authenticating off a PHP maintained MySQL backend, and this post is primarily to aid my own memory should I ever have to do it again. Installing ProFTP In order to use MySQL as a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.proftp.org"><img src="http://www.marcus-povey.co.uk/wp-content/proftpd.png" alt="" width="150" align="right" />ProFTP</a> is a configurable FTP server available on most *nix platforms.</p>
<p>I recently had the need to get this working and authenticating off a PHP maintained MySQL backend, and this post is primarily to aid my own memory should I ever have to do it again.</p>
<p><strong>Installing ProFTP</strong></p>
<p>In order to use MySQL as a back end you need to install some packages. If you&#8217;re using a <a href="http://www.debian.org">Debian</a> based distro like <a href="http://www.ubuntu.com">Ubuntu</a>, this is easy:</p>
<blockquote><p><code>apt-get install mysql-server proftpd proftpd-mod-mysql</code></p></blockquote>
<p><strong>The database schema</strong></p>
<p>Next, you need to install the database schema to store your users and passwords.</p>
<blockquote><p><code>CREATE TABLE IF NOT EXISTS users (<br />
userid varchar(30) NOT NULL default '',<br />
passwd <strong>varchar(128)</strong> NOT NULL default '',<br />
uid int(11) default NULL,<br />
gid int(11) default NULL,<br />
homedir varchar(255) default NULL,<br />
shell varchar(255) default NULL,<br />
UNIQUE KEY uid (uid),<br />
UNIQUE KEY userid (userid)<br />
) TYPE=MyISAM;</code></p>
<p><code>CREATE TABLE IF NOT EXISTS groups (<br />
groupname varchar(30) NOT NULL default '',<br />
gid int(11) NOT NULL default '0',<br />
members varchar(255) default NULL<br />
) TYPE=MyISAM;</code></p></blockquote>
<p>One important thing to note here &#8211; that caused me a fair amount of hair pulling when I tried to use encrypted passwords &#8211; is that the password field shown in many howtos on the internet is much too short. This causes the hashed password to be quietly truncated by MySQL when saved.</p>
<p>This results in a somewhat misleading &#8220;<strong>No such user found</strong>&#8221; error to appear in the logs when using encrypted passwords.</p>
<p>To end all argument I&#8217;ve allowed passwords up to 128 chars, but this field could probably be a good deal shorter.</p>
<p>The user table looks much like /etc/passwd and is largely self explanatory. The <strong>uid</strong> &amp; <strong>gid</strong> fields correspond to a system user in most cases, but since we&#8217;re using virtual users they can largely be ignored. <strong>Homedir </strong>points to a location which will serve as the user&#8217;s default directory. <strong>Shell</strong> is largely unused and can be set to <strong>/bin/false</strong> or similar.</p>
<p><strong>Configuring ProFTP</strong></p>
<p>Next, you need to make some changes to the ProFTP configuration files stored in /etc/proftpd. While doing this it is handy to run proftp in debug mode from the console:</p>
<blockquote><p><code>proftpd -nd6</code></p></blockquote>
<p><strong><em>proftpd.conf</em></strong></p>
<ol>
<li>Make sure the AuthOrder line looks like:<br />
<blockquote><p><code>AuthOrder mod_sql.c</code></p></blockquote>
</li>
<li>Ensure that the following line is uncommented:<br />
<blockquote><p><code>Include /etc/proftpd/sql.conf</code></p></blockquote>
</li>
<li>For belts and braces I&#8217;ve included the following at the end, although I&#8217;m not entirely sure it&#8217;s strictly required:<br />
<blockquote><p><code>&lt;IfModule mod_auth_pam.c&gt;<br />
AuthPAM off<br />
&lt;/IfModule&gt;<br />
</code></p></blockquote>
</li>
<li>Our users don&#8217;t need a valid shell, so:<br />
<blockquote><p><code>RequireValidShell off</code></p></blockquote>
</li>
</ol>
<p><em><strong>modules.conf</strong></em></p>
<ol>
<li>Make sure the following lines are uncommented:<br />
<blockquote><p><code>LoadModule mod_sql.c<br />
LoadModule mod_sql_mysql.c</code></p></blockquote>
</li>
</ol>
<p><strong><em>sql.conf</em></strong></p>
<ol>
<li>Set your SQL backend and ensure that authentication is turned on:<br />
<blockquote><p><code>SQLBackend mysql<br />
SQLEngine on<br />
SQLAuthenticate on</code></p></blockquote>
</li>
<li>Tell proftp how passwords are stored. You have a number of options here, but since I was using mysql&#8217;s PASSWORD function, I&#8217;ll defer to the backend.<br />
<blockquote><p><code>SQLAuthTypes backend</code></p></blockquote>
</li>
<li>Tell proftp how to connect to your database by providing the required connection details, ensure that the user has full access to these tables.<br />
<blockquote><p><code>SQLConnectInfo <em>database</em>@<em>host</em> <em>user</em> <em>password</em></code></p></blockquote>
</li>
<li>Define your table structure in the format <em>tablename</em> <em>fields&#8230;.</em><br />
<blockquote><p><code>SQLUserInfo users userid passwd uid gid homedir shell<br />
SQLGroupInfo groups groupname gid members</code></p></blockquote>
</li>
</ol>
<p><strong>Adding users</strong></p>
<p>I manage users from within a <a href="http://php.net">PHP</a> web application that I&#8217;m developing, but in a nutshell adding FTP users from this point is a simple insert statement looking something like:</p>
<blockquote><p><code>mysql_query("REPLACE INTO users<br />
(userid, passwd, uid, gid, homedir, shell)<br />
VALUES<br />
('$userid', PASSWORD('$password'), $uid, $gid, '$homedir', '$shell')");</code></p></blockquote>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcus-povey.co.uk/2010/06/15/proftp-mysql-virtual-users-howto/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Multiple site support with MP&#8217;s Multisite Elgg</title>
		<link>http://www.marcus-povey.co.uk/2010/04/19/multiple-site-support-elgg/</link>
		<comments>http://www.marcus-povey.co.uk/2010/04/19/multiple-site-support-elgg/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 08:04:38 +0000</pubDate>
		<dc:creator>Marcus Povey</dc:creator>
				<category><![CDATA[elgg]]></category>
		<category><![CDATA[#ue]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[elgg-multisite]]></category>
		<category><![CDATA[elggmulti]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[mp-multisite-elgg]]></category>
		<category><![CDATA[multisite]]></category>
		<category><![CDATA[ning]]></category>

		<guid isPermaLink="false">http://www.marcus-povey.co.uk/?p=508</guid>
		<description><![CDATA[I have just Open Sourced an &#8220;itch scratching&#8221; project I&#8217;ve been hacking on for a little while. So, without much further ado, I&#8217;d like to introduce you to Marcus Povey&#8217;s Multisite Elgg! It is currently in Beta and the code could do with a bit of a tidy, but this is Open Source so roll [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.marcus-povey.co.uk/wp-content/elgg-com-logo.gif" alt="" width="150" align="right" />I have just <a href="http://en.wikipedia.org/wiki/Open_source">Open Sourced</a> an &#8220;itch scratching&#8221; project I&#8217;ve been hacking on for a little while. So, without much further ado, I&#8217;d like to introduce you to <a href="http://code.google.com/p/mp-multisite-elgg">Marcus Povey&#8217;s Multisite Elgg</a>!</p>
<p>It is currently in Beta and the code could do with a bit of a tidy, but this is <a href="http://en.wikipedia.org/wiki/Open_source">Open Source</a> so roll up your sleeves and get involved.</p>
<p><strong>What is it?</strong><br />
<a href="http://code.google.com/p/mp-multisite-elgg">Multisite Elgg</a> allows you to run multiple separate <a href="http://www.elgg.org">Elgg</a> sites off of the same install of the codebase, saving disk space and making administration a whole bunch easier.</p>
<p>Currently based around the latest Elgg 1.7 release, once installed adding new <a href="http://www.elgg.org">Elgg</a> sites is a matter of clicking on a button and entering in some details.</p>
<p><strong>What can I do with it?</strong><br />
You can do everything that you can do with Elgg, but with the ability to create new networks on demand. This will for example let you:</p>
<ul>
<li>Set up your own version of <a href="http://www.ning.com/">Ning</a>! What with <a href="http://tech.blorge.com/Structure:%20/2010/04/16/ning-cuts-free-accounts-and-40-percent-of-staff/">Ning phasing out free accounts</a>, it is my hope that <a href="http://code.google.com/p/mp-multisite-elgg">Multisite Elgg</a> will let a thousand more Nings bloom!</li>
<li>In your organisation or institution, easily set up Elgg sites for each department.</li>
<li>If your one of the Elgg hosting companies out there, you may want to look at multisite in order to simplify your work flow.</li>
<li>&#8230; etc&#8230;</li>
</ul>
<p><strong>Installation</strong><br />
Once you have downloaded the installation package you will need to do a few things in order to get up and running. <a href="http://code.google.com/p/mp-multisite-elgg">Multisite Elgg</a> assumes that you have some knowledge of how to set up and run a server &#8211; there is no wizard just yet!</p>
<ol>
<li>﻿﻿﻿<strong>Unzip the package on your web server.</strong></li>
<li><strong>Point your master domain at the contents of the install location on your web server</strong>. This is your master control domain, go here to configure your sites. Because of this you might want to consider putting this behind some further access restrictions.</li>
<li><strong>Point any sub domains to the contents of the docroot folder</strong>, eg (/var/multisite/docroot). This directory forms the base of all your Elgg installs. To make things even more automated you may want to consider making this an <a href="http://ma.tt/2003/10/wildcard-dns-and-sub-domains/">Apache wildcard domain</a>, if your DNS provider supports it.</li>
<li><strong>Chmod 777 docroot/data:</strong> This is the default location for multisite domains.</li>
<li><strong>Install schema/multisite_mysql.sql: </strong><a href="http://www.ntchosting.com/mysql/create-database.html">Create a new database on your Mysql server</a> and install the <a href="http://code.google.com/p/mp-multisite-elgg">Multisite</a> schema &#8211; this is your master control database.</li>
<li><strong>Rename settings.example.php in docroot/elgg/engine/ to settings.php and configure:</strong><br />
<blockquote><p>$CONFIG-&gt;multisite-&gt;dbuser = &#8216;your username&#8217;;<br />
$CONFIG-&gt;multisite-&gt;dbpass = &#8216;password&#8217;;<br />
$CONFIG-&gt;multisite-&gt;dbhost = &#8216;host&#8217;;</p></blockquote>
<p>Make sure this user has sufficient privileges to create and grant access to databases and tables on your server. This will allow the admin tool to create the databases for your hosted sites automatically.</li>
<li><strong>Visit your master domain and configure your admin user</strong></li>
<li><strong>Begin configuring your sites!</strong></li>
</ol>
<p><strong>Creating sites</strong><br />
Once you have created an admin user, adding sites is easy. Currently you can only create one type of site, but in the future <a href="http://code.google.com/p/mp-multisite-elgg">Multisite Elgg</a> will let you create sites which have quotas and other access restrictions.</p>
<p>You have a box to enter database details, or you can leave them blank to use <a href="http://code.google.com/p/mp-multisite-elgg">Multisite Elgg</a> user defined above (which you may not want to do for security reasons).</p>
<p>You can also select which of the installed plugins you want to allow, this lets have different sites have different plugins available while still installing them on the same codebase.</p>
<p><strong>Contributing</strong><br />
So, that was a brief introduction to <a href="http://code.google.com/p/mp-multisite-elgg">Multisite Elgg</a>. I hope that at least some of you out there find it useful!</p>
<p>As I said before, it&#8217;s <a href="http://en.wikipedia.org/wiki/Open_source">Open Source</a>, so if you want to get involved here are the important details:</p>
<ul>
<li><strong>Project homepage: </strong><a href="http://code.google.com/p/mp-multisite-elgg">http://code.google.com/p/mp-multisite-elgg</a></li>
<li><strong>Bug Tracker: </strong><a href="http://code.google.com/p/mp-multisite-elgg/issues/list">http://code.google.com/p/mp-multisite-elgg/issues/list</a></li>
<li><strong>Code Repository: </strong>svn checkout http://mp-multisite-elgg.googlecode.com/svn/trunk/ mp-multisite-elgg-read-only</li>
<li><strong>Discussion forum:</strong> <a href="http://groups.google.com/group/mp-multisite-elgg">http://groups.google.com/group/mp-multisite-elgg</a></li>
<li><strong><a href="http://mp-multisite-elgg.googlecode.com/files/multisiteelgg-1.7beta.zip">Direct download!</a></strong></li>
</ul>
<p>If you want to contribute patches, feel free to use the bug tracker or discussion forum!</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcus-povey.co.uk/2010/04/19/multiple-site-support-elgg/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>[audioblog] Google buzz and privacy</title>
		<link>http://www.marcus-povey.co.uk/2010/02/12/google-buzz-and-privacy/</link>
		<comments>http://www.marcus-povey.co.uk/2010/02/12/google-buzz-and-privacy/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 18:18:10 +0000</pubDate>
		<dc:creator>Marcus Povey</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[audioblog]]></category>
		<category><![CDATA[bct]]></category>
		<category><![CDATA[buzz]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[privacy]]></category>

		<guid isPermaLink="false">http://www.marcus-povey.co.uk/?p=432</guid>
		<description><![CDATA[Unless you have been living under a rock the last few days you will be aware of Google&#8217;s new social networking product &#8211; Google Buzz. Unfortunately it would seem that some assumptions made by the designers and the automatic opt-in nature of the service has lead to some serious issues. For me it underlines some [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://audioboo.fm/boos/97642-the-buzz-around-buzz"><img src="http://audioboo.fm/files/images/0038/9564/5529E887-46D6-4B2E-96B1-F2DB073B9B34-2299-0000018B7460E38D.jpg?1265995901" alt="" width="150" align="right" /></a>Unless you have been living under a rock the last few days you will be aware of <a href="http://www.google.com">Google&#8217;s</a> new social networking product &#8211; <a href="http://buzz.google.com">Google Buzz</a>.</p>
<p>Unfortunately it would seem that some assumptions made by the designers and the automatic opt-in nature of the service has lead to some <a href="http://fugitivus.wordpress.com/2010/02/11/fuck-you-google/">serious</a> <a href="http://lbc.co.uk/googles-buzz-has-serious-privacy-flaws-20201">issues</a>.</p>
<p>For me it underlines some of the problems with entrusting your personal data to the cloud. That is not to say of course that it is a user&#8217;s fault that their data gets shared in such a way &#8211; everything in the day to day usage of these tools gives the user a reasonable expectation of privacy.</p>
<p>The trouble is, that this expectation is largely an illusion. When using cloud services, you are entrusting them and you hope that they will exercise the same care when dealing with your data as you would &#8211; but unfortunately this is rarely the case.</p>
<p>Whether through carelessness or malicious action information has a tendency to leak. Assumptions made by the design team can be proved poor. So in short, never put anything on the internet that you wouldn&#8217;t be happy to see on a billboard.</p>
<p><a href="http://audioboo.fm/boos/97642-the-buzz-around-buzz.mp3">Download audio file (97642-the-buzz-around-buzz.mp3)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcus-povey.co.uk/2010/02/12/google-buzz-and-privacy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://audioboo.fm/boos/97642-the-buzz-around-buzz.mp3" length="142" type="audio/mpeg3;" />
		</item>
		<item>
		<title>Akismet plugin for Elgg</title>
		<link>http://www.marcus-povey.co.uk/2010/01/18/akismet-plugin-for-elgg/</link>
		<comments>http://www.marcus-povey.co.uk/2010/01/18/akismet-plugin-for-elgg/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 09:59:36 +0000</pubDate>
		<dc:creator>Marcus Povey</dc:creator>
				<category><![CDATA[elgg]]></category>
		<category><![CDATA[#ue]]></category>
		<category><![CDATA[akismet]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://www.marcus-povey.co.uk/?p=387</guid>
		<description><![CDATA[I have just written a very small Akismet plugin for Elgg. When enabled and configured, this plugin will scan newly submitted comments of the &#8216;generic_comment&#8217; annotation class. While spam comments are rarer on Elgg due to the fact that most sites don&#8217;t allow anonymous comments, this could be useful for people who are getting spam [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/david-trattnig/262091025/"><img src="http://farm1.static.flickr.com/82/262091025_9825a64b68_m.jpg" alt="" width="150" align="right" /></a></p>
<p>I have just written a very small <a href="http://community.elgg.org/pg/plugins/marcus/read/385700/akismet">Akismet plugin</a> for <a href="http://elgg.org">Elgg</a>.</p>
<p>When enabled and configured, this plugin will scan newly submitted comments of the &#8216;generic_comment&#8217; annotation class.</p>
<p>While spam comments are rarer on Elgg due to the fact that most sites don&#8217;t allow anonymous comments, this could be useful for people who are getting spam comments from people who have signed up.</p>
<p>This plugin comes into its own when you allow anonymous comments, such as on a site I recently built for a client.</p>
<p>Extending this plugin to scan other content should be fairly straight forward for even a novice coder, but if I have time I&#8217;ll provide an interface to do so.</p>
<p>Anyway, go <a href="http://community.elgg.org/pg/plugins/marcus/read/385700/akismet">get it here</a>, or check out the <a href="https://code.google.com/p/elgg-akismet/">project page</a> on google code!</p>
<p><small><strong><em>Image &#8220;<a href="http://www.flickr.com/photos/david-trattnig/262091025/">Spam! [don't buy]</a>&#8221; by <a href="http://www.flickr.com/photos/david-trattnig/">David Trattnig</a></em></strong></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcus-povey.co.uk/2010/01/18/akismet-plugin-for-elgg/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using an XBOX 360 wireless controller with XBMC on Ubuntu</title>
		<link>http://www.marcus-povey.co.uk/2009/12/29/using-an-xbox-360-wireless-controller-with-xbmc-on-ubuntu/</link>
		<comments>http://www.marcus-povey.co.uk/2009/12/29/using-an-xbox-360-wireless-controller-with-xbmc-on-ubuntu/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 17:48:30 +0000</pubDate>
		<dc:creator>Marcus Povey</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[360]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[wireless]]></category>
		<category><![CDATA[xbmc]]></category>
		<category><![CDATA[xbox]]></category>
		<category><![CDATA[xbox 360]]></category>

		<guid isPermaLink="false">http://www.marcus-povey.co.uk/?p=357</guid>
		<description><![CDATA[This Christmas I finally bit the bullet and treated myself to a shiny XBox 360. Ostensibly this was so that I could experiment with console development, but mostly I have used it to play Gears of War. In a slight departure from what I usually talk about, I thought I&#8217;d quickly jot down how I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/miskan/25241898/"><img src="http://farm1.static.flickr.com/22/25241898_aa45084bd8_m.jpg" border="0" alt="" align="right" /></a>This Christmas I finally bit the bullet and treated myself to a shiny XBox 360. Ostensibly this was so that I could experiment with console development, but mostly I have used it to play <a href="http://en.wikipedia.org/wiki/Gears_of_War">Gears of War</a>.</p>
<p>In a slight departure from what I usually talk about, I thought I&#8217;d quickly jot down how I got the wireless controller to work with my Ubuntu <a href="http://xbmc.org/">XBMC</a> media PC.</p>
<p>The wireless controller provides a slightly more usable remote than my <a href="http://remote.collect3.com.au/">iPhone</a> (which must first be unlocked making quick pauses impossible) or rather flaky wireless keyboard, so hopefully this will be useful to someone.</p>
<p><strong>Getting started<br />
</strong></p>
<p>My media PC currently runs Ubuntu Karmic with XBMC. To begin with you will need to install the XBox kernel driver (already installed on Karmic).</p>
<p>Most importantly however, you will need to get yourself a <a href="http://support.microsoft.com/kb/933711?sd=xbox">XBox wireless gaming receiver for Windows</a> &#8211; which I got included with my second controller. Xbox controllers do not use standard bluetooth, so you can&#8217;t just pair in the normal way using your existing hardware.</p>
<p>This <a href="https://help.ubuntu.com/community/Xbox360Controller">howto has some more info</a>&#8230;</p>
<p><strong>Configuring XBMC</strong></p>
<p>Assuming you have your module installed and controller paired you will need to tell XBMC about it by configuring a keyfile:</p>
<ol>
<li>I used <a href="https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk/system/keymaps/joystick.Microsoft.Xbox.Controller.S.xml">this keyfile as a starting point</a>. Download and save it as <code>~/.xbmc/userdata/keymaps/Keymap.xml</code> (note case).</li>
<li>Find out what your computer thinks the controller is by looking at the output from: <code>cat /proc/bus/input/devices</code> &#8211; you want a <code>"Name"</code> that says something like <code>"Xbox 360 Wireless Receiver"</code></li>
<li>Replace all occurrences of <code>"Microsoft Xbox Controller S"</code> with this value.</li>
</ol>
<p>At this point if you start XBMC it should respond to the controller. If you are lucky this is all you will have to do, however for me I had to mess around with the key bindings a bit since the example keymap file didn&#8217;t match my controller exactly.</p>
<p>If this happens to you there&#8217;s not much I can suggest other than to bind one key at a time, restart XBMC and see what button that maps to then repeat until all your keys are mapped. I&#8217;m sure there must be an easier way that I&#8217;ve overlooked, feel free to comment below!</p>
<p>For what it&#8217;s worth, here is my modified (but somewhat incomplete) key file which has largely sensible bindings. Hack away to get it working how you like.</p>
<p>» <a href="http://www.marcus-povey.co.uk/wp-content/Keymap.zip">Modified Keymap</a></p>
<p><small><em>Image &#8220;<a href="http://www.flickr.com/photos/miskan/25241898/">XBMC</a>&#8221; by <a href="http://www.flickr.com/photos/miskan/">Miskan</a></em></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcus-povey.co.uk/2009/12/29/using-an-xbox-360-wireless-controller-with-xbmc-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Running Elgg on a MySQL cluster</title>
		<link>http://www.marcus-povey.co.uk/2009/09/21/running-elgg-on-a-mysql-cluster/</link>
		<comments>http://www.marcus-povey.co.uk/2009/09/21/running-elgg-on-a-mysql-cluster/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 19:01:49 +0000</pubDate>
		<dc:creator>Marcus Povey</dc:creator>
				<category><![CDATA[elgg]]></category>
		<category><![CDATA[#ue]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[clustering]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql-proxy]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.marcus-povey.co.uk/?p=308</guid>
		<description><![CDATA[I have recently been exploring some aspects of the Elgg scalability question by exploring how easy it would be to get the latest version of Elgg (1.6) running on a MySQL cluster. In this article I will document the process, but first I should point out: This is highly experimental and not endorsed in any [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/File:Us-nasa-columbia.jpg"><img src="http://upload.wikimedia.org/wikipedia/commons/3/3d/Us-nasa-columbia.jpg" alt="" width="200" align="right" /></a>I have recently been exploring some aspects of the <a href="http://www.marcus-povey.co.uk/2009/01/04/elgg-scalability/">Elgg scalability</a> question by exploring how easy it would be to get the latest version of <a href="http://elgg.org/getelgg.php?forward=elgg1.6.1.zip">Elgg (1.6)</a> running on a <a href="http://en.wikipedia.org/wiki/MySQL_Cluster">MySQL cluster</a>.</p>
<p>In this article I will document the process, but first I should point out:</p>
<ul>
<li>This is highly experimental and not endorsed in any way.</li>
<li>It is built against <a href="http://elgg.org/getelgg.php?forward=elgg1.6.1.zip">Elgg 1.6.1</a></li>
<li>This is not canonical and doesn&#8217;t reflect anything to do with the roadmap</li>
<li>This has not been extensively tested so <em>caveat emptor.</em></li>
</ul>
<h2>Setting up the cluster</h2>
<p>The first step is to set up the cluster on your equipment.</p>
<p>A MySQL cluster consists of a management node and several data nodes connected together by a network. Because I was running rather low on hardware, I cheated here and created each node as a <a href="http://www.virtualbox.org/">Virtual Box</a> image on my laptop &#8211; but the principle is the same.</p>
<p>Each node is an <a href="http://www.ubuntu.com/">Ubuntu</a> install (although you can use pretty much any OS) with two (virtual) network cards, one connected to the wider network (to install packages) and another on an internal network. If you do this for real you should consider removing the internet facing card once you&#8217;ve set everything up since a cluster isn&#8217;t secure enough to be run on the wider internet.</p>
<p>In my test configuration I had three nodes with name/internal IP as follows:</p>
<ul>
<li>HHCluster1/192.168.2.1 &#8211; Management node &amp; web server</li>
<li>HHCluster2/192.168.2.2 &#8211; First data node</li>
<li>HHCluster3/192.168.2.3 &#8211; Second data node</li>
</ul>
<p><strong>HHCluster1 &#8211; The management node</strong></p>
<p>Install mysql, apache etc. This should be a simple matter of apt-getting the relevant packages. Clustering (ndb) support is built into the version of mysql bundled with Ubuntu, but this may not be the case universally so check!</p>
<p>You need to create a file in /etc/mysql/ called <code>ndb_mgmd.cnf</code>, this should contain the following:</p>
<blockquote><p><code><br />
[NDBD DEFAULT]<br />
NoOfReplicas=2 # How many nodes you have<br />
DataMemory=80M    # How much memory to allocate for data storage (change for larger clusters)<br />
IndexMemory=18M   # How much memory to allocate for index storage (change for larger clusters)<br />
[MYSQLD DEFAULT]<br />
[NDB_MGMD DEFAULT]<br />
[TCP DEFAULT]</code></p>
<p><code>[NDB_MGMD]<br />
HostName=192.168.2.1 # IP address of this system</code></p>
<p><code># Now we describe each node on the system</code></p>
<p><code># First data node<br />
HostName=192.168.2.2<br />
DataDir=/var/lib/mysql-cluster<br />
BackupDataDir=/var/lib/mysql-cluster/backup<br />
DataMemory=512M<br />
[NDBD]<br />
# Second data node node<br />
HostName=192.168.2.3<br />
DataDir=/var/lib/mysql-cluster<br />
BackupDataDir=/var/lib/mysql-cluster/backup<br />
DataMemory=512M<br />
</code></p>
<p><code>#one [MYSQLD] per data storage node<br />
[MYSQLD]<br />
[MYSQLD]</code></p></blockquote>
<p><strong>Data nodes (HHCluster2 &amp; 3)</strong><br />
You must now configure your data nodes:</p>
<ol>
<li>Create the data directories, as root type:<br />
<blockquote><p><code>mkdir -p /var/lib/mysql-cluster/backup<br />
chown -R mysql:mysql /var/lib/mysql-cluster</code></p></blockquote>
</li>
<li>Edit your /etc/mysql/my.cnf and add the following to the [mysqld] section:<br />
<blockquote><p><code>ndbcluster<br />
# Replace the following with the IP address of your management server<br />
ndb-connectstring=192.168.2.1</code></p></blockquote>
</li>
<li>Again in /etc/mysql/my.cnf uncomment and edit the [MYSQL_CLUSTER] section so it contains the location of your management server:<br />
<blockquote><p><code>[MYSQL_CLUSTER]<br />
ndb-connectstring=192.168.2.1</code></p></blockquote>
</li>
<li>You need to create your database on each node (this is because clustering operates on a table level rather than a database level):<br />
<blockquote><p><code>CREATE DATABASE elggcluster;</code></p></blockquote>
</li>
</ol>
<p><strong>Starting the cluster</strong></p>
<ol>
<li>Start the management node:<br />
<blockquote><p><code>/etc/init.d/mysql-ndb-mgm start</code></p></blockquote>
</li>
<li>Start your data nodes:<br />
<blockquote><p><code>/etc/init.d/mysql restart<br />
/etc/init.d/mysql-ndb restart</code></p></blockquote>
</li>
</ol>
<p><strong>Verifying the cluster</strong><br />
You should now have the cluster up and running, you can verify this by logging into your management node and typing <code>show</code> in <code>ndb_mgm</code>.</p>
<p style="text-align: center;"><a href="http://www.marcus-povey.co.uk/wp-content/screenshot.png"><img class="aligncenter" src="http://www.marcus-povey.co.uk/wp-content/screenshot.png" border="0" alt="" width="400" /></a></p>
<p style="text-align: left;"><strong>A word on access&#8230;<br />
</strong></p>
<p style="text-align: left;">The cluster is now set up and will replicate tables (created with the ndbcluster engine &#8211; more on that later), but that is only useful to a point. Right now we don&#8217;t have a single endpoint to direct queries to, so this direction needs to be done at the application level.</p>
<p style="text-align: left;">We could take advantage of Elgg&#8217;s built in split read and writes, but this would only allow us to use a maximum of two nodes. A better solution would be to use a load balancer here such as <a href="http://www.ultramonkey.org/">Ultramonkey</a> to direct the query to the appropriate server allowing us to scale much further.</p>
<p style="text-align: left;">I didn&#8217;t really have time to get into this, so I am using the somewhat simpler <a href="http://forge.mysql.com/wiki/MySQL_Proxy">mysql-proxy</a>.</p>
<ol>
<li>On HHCluster1 install and run mysql-proxy:<br />
<blockquote><p><code>apt-get install mysql-proxy<br />
mysql-proxy --proxy-backend-addresses=192.168.2.2:3306 --proxy-backend-addresses=192.168.2.2:3306</code></p></blockquote>
</li>
<li>On your data nodes edit your /etc/mysql/my.cnf file. Find <code>bind-address</code> and change it&#8217;s IP to the node&#8217;s IP address. Also ensure that you have commented out any occurrence of <code>skip-networking.</code></li>
<li>Again on your client nodes, log in to mysql and grant access to your cluster table to a user on HHCluster1 &#8211; for example:<br />
<blockquote><p><code>GRANT ALL ON elggcluster.* TO `root`@`HHCluster1.local` IDENTIFIED BY '[some password]'</code></p></blockquote>
</li>
</ol>
<h2>Installing elgg</h2>
<p>Unfortunately as it stands, you need to make some code changes to the vanilla version of Elgg in order for it to work in a clustered environment. These changes are necessary because of the restrictions placed on us by the ndbcluster engine.</p>
<p>Two things in particular cause us problems &#8211; ndbcluster doesn&#8217;t support FULLTEXT indexes, and it also doesn&#8217;t support indexes over TEXT or BLOB fields.</p>
<p>FULLTEXT is for searching and is largely not used in the vanilla install of elgg, so I removed them. Equally, most indexes blobs one can live without, the exception being on the metastrings table.</p>
<p>Metastrings is accessed a lot, so the index is critical. Therefore I added an extra varchar field which we&#8217;ll modify the code to include the first 50 characters of the indexed text &#8211; this is equivalent to the existing index:</p>
<blockquote><p><code>CREATE TABLE `prefix_metastrings` (<br />
`id` int(11) NOT NULL auto_increment,<br />
`string` TEXT NOT NULL,<br />
<strong>`string_index` varchar(50) NOT NULL,</strong><br />
PRIMARY KEY (`id`),<br />
<strong>KEY `string_index` (`string_index`)</strong><br />
) ENGINE=ndbcluster DEFAULT CHARSET=utf8;</code></p></blockquote>
<p>And the modified query:</p>
<blockquote><p><code>$row = get_data_row("SELECT * from {$CONFIG-&gt;dbprefix}metastrings where string=$cs'$string' and string_index='$string_index' limit 1");</code></p></blockquote>
<p>Mysql&#8217;s optimiser checks the index first so this doesn&#8217;t lose a significant amount of efficiency (at least according to the explain command).</p>
<p>» <a href="http://www.marcus-povey.co.uk/wp-content/elgg-mysql-cluster.sql">Modified schema</a></p>
<p>The next problem is that the system log currently uses INSERT DELAYED to insert the log data. This is also not supported under the clustered engine.</p>
<p>There are a number of approaches we could take including using <a href="http://reference.elgg.org/database_8php.html#d03f827016fde8428fb40f3ee87aa887">Elgg&#8217;s delayed write functionality</a> or writing a plugin which replaces and logs to a different location.</p>
<p>For the purposes of this test I decided to just comment out the code in <a href="http://reference.elgg.org/system__log_8php.html#3ef1dd1a4a83c58012ad92ef2841b356">system_log()</a>.</p>
<p><strong>What won&#8217;t work</strong><br />
Currently there are a couple of core things that won&#8217;t work under these changes, here is a by no means complete summary:</p>
<ul>
<li>The system log (as previously described). This isn&#8217;t too much of a show stopper as the river code introduced in Elgg 1.5 no longer uses this.</li>
<li>The log rotate plugin as this attempts to copy the table into the archive engine type and we can&#8217;t guarantee which node it will be executed on in this scenario.</li>
<li>Any third party plugins which attempt to access the metastrings table directly (of which there should be none as direct table access is a big no no!)</li>
</ul>
<p>Anyway, here is a patch I made against the released version of 1.6.1 with all the code changes I made. Once you have applied this patch to your Elgg install you should be able to proceed with the normal Elgg install.</p>
<p>Let me know any feedback you may have!</p>
<p>» <a href="http://www.marcus-povey.co.uk/wp-content/ElggCluster1.6.1.patch">Elgg Clustering patch for Elgg 1.6.1</a></p>
<p><small><em>Top image &#8220;Birds-eye view of the 10,240-processor SGI Altix supercomputer housed at the NASA Advanced Supercomputing facility.&#8221;</em></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcus-povey.co.uk/2009/09/21/running-elgg-on-a-mysql-cluster/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Pastures new</title>
		<link>http://www.marcus-povey.co.uk/2009/09/15/pastures-new/</link>
		<comments>http://www.marcus-povey.co.uk/2009/09/15/pastures-new/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 14:13:25 +0000</pubDate>
		<dc:creator>Marcus Povey</dc:creator>
				<category><![CDATA[elgg]]></category>
		<category><![CDATA[consultancy]]></category>
		<category><![CDATA[curverider]]></category>
		<category><![CDATA[expert]]></category>
		<category><![CDATA[marcus povey]]></category>
		<category><![CDATA[new]]></category>
		<category><![CDATA[pastures new]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://www.marcus-povey.co.uk/?p=290</guid>
		<description><![CDATA[I would like to interrupt your usual reading in order to make a brief announcement: I joined the Elgg team full time back in 2008 (after having worked for them as a technology consultant). I was there at the birth of the Elgg 1.0 codebase (which I helped design) and was delighted to see Elgg [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.elgg.org/"><img src="http://www.marcus-povey.co.uk/wp-content/elgg-com-logo.gif" alt="" width="250" align="right" /></a>I would like to interrupt your usual reading in order to make a brief announcement:</p>
<p>I joined the <a href="http://www.elgg.com">Elgg</a> team full time back in 2008 (after having worked for them as a technology consultant). I was there at the birth of the Elgg 1.0 codebase (which I helped design) and was delighted to see Elgg grow from strength to strength.</p>
<p>By the time of the Elgg 1.5 release earlier in the year, Elgg had achieved widespread support and adoption and had cemented itself as the leading open source social networking framework. Now with the Elgg 1.6 release out of the door and the continued growth of the vibrant <a href="http://community.elgg.org">Elgg community</a>, I have no doubt that Elgg&#8217;s success will continue into the future.</p>
<p>However, I have decided that it is time to move on and explore other projects.</p>
<p>So, as of the 27th October I will no longer be part of <a href="http://www.curverider.co.uk">Curverider</a> or Elgg&#8217;s core development team (although I dare say I will still end up doing a bit of Elgg coding here and there).</p>
<p>I really enjoyed helping build Elgg and being part of the <a href="http://community.elgg.org">Elgg community</a>, and I am excited to see where the community takes the platform next.</p>
<p>As for me, I will be busily working on my next project (more on that to come) as well as continuing to provide <a href="http://www.marcus-povey.co.uk/consultancy/">expert consultancy services</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcus-povey.co.uk/2009/09/15/pastures-new/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Geocoding Elgg entities</title>
		<link>http://www.marcus-povey.co.uk/2009/08/28/geocoding-elgg-entities/</link>
		<comments>http://www.marcus-povey.co.uk/2009/08/28/geocoding-elgg-entities/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 14:23:24 +0000</pubDate>
		<dc:creator>Marcus Povey</dc:creator>
				<category><![CDATA[elgg]]></category>
		<category><![CDATA[#ue]]></category>
		<category><![CDATA[geo]]></category>
		<category><![CDATA[geocoding]]></category>
		<category><![CDATA[georss]]></category>
		<category><![CDATA[objects]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://www.marcus-povey.co.uk/?p=280</guid>
		<description><![CDATA[Geotagging and GeoRSS support has been available in Elgg for a little while now, but like so many cool features of the platform, I haven&#8217;t really had the time to draw people&#8217;s attention to it. Although I am drawing your attention to it now, it should be noted that this is still somewhat under development! [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://georss.org/Main_Page"><img src="http://www.marcus-povey.co.uk/wp-content/georss_logo.png" alt="" align="right" /></a>Geotagging and <a href="http://georss.org/Main_Page">GeoRSS</a> support has been available in Elgg for a little while now, but like so many cool features of the platform, I haven&#8217;t really had the time to draw people&#8217;s attention to it.</p>
<p>Although I am drawing your attention to it now, it should be noted that this is still somewhat under development!</p>
<h2>Anatomy of a geocoder</h2>
<p>To begin geocoding your data you will need a geocoder. This is not something that Elgg comes installed with by default, <a href="http://community.elgg.org/pg/plugins/marcus/read/107702/google-maps-geocoder">although here&#8217;s one I coded earlier</a>.</p>
<p>This geocoder users the <a href="http://code.google.com/apis/maps/">Google maps API</a> to do the actual encoding, and provides two primary features.</p>
<ul>
<li>It handles the plugin hook &#8220;geocode&#8221;,&#8221;location&#8221;</li>
<li>It listens to all create events and attempts to tag it with the latitude and longitude &#8211; either from a -&gt;location metadata on the object itself, or from the user&#8217;s current -&gt;location &#8211; you could get more creative, this is a simple example.</li>
</ul>
<p>When you attempt to geocode a location you call the function <a href="http://reference.elgg.org/location_8php.html#3dfde0e2643efcff5feee626e098a368">elgg_geocode_location()</a>. This in turn triggers the above plugin hook and attempts to encode the data.</p>
<p>For efficiency once a location has been geocoded the result is cached. Future attempts to code the same location will return the result from the cache.</p>
<p>Once installed and configured, new content (wire posts etc) will be tagged with a latitude and longitude. Fill in your profile location field and try it out for yourself!</p>
<h2>Location based searches</h2>
<p>Once things are tagged with a location, you can start to use location as a starting point for searching by using some of the <a href="http://reference.elgg.org/location_8php-source.html">location aware search functions in location.php</a>.</p>
<p>This hasn&#8217;t currently been hooked up to the Elgg interface in any way, but that doesn&#8217;t stop you making use of it in your plugins.</p>
<h2>GeoRSS</h2>
<p>This is something you&#8217;ll be pleased to know that you get for free!</p>
<p>As you list your entities using the <a href="http://docs.elgg.org/wiki/Views#Listing_entities">Elgg listing tools</a> using the RSS view, if an entity has a position defined it will be included using standard geoRSS simple notation, i.e:</p>
<blockquote><p><code>&lt;georss:point&gt; 45.256 -71.92 &lt;/georss:point&gt;</code></p></blockquote>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcus-povey.co.uk/2009/08/28/geocoding-elgg-entities/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using Elgg&#8217;s REST-like API</title>
		<link>http://www.marcus-povey.co.uk/2009/08/25/using-elggs-rest-like-api/</link>
		<comments>http://www.marcus-povey.co.uk/2009/08/25/using-elggs-rest-like-api/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 14:20:04 +0000</pubDate>
		<dc:creator>Marcus Povey</dc:creator>
				<category><![CDATA[elgg]]></category>
		<category><![CDATA[#ue]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[endpoint]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[handler]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[token]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.marcus-povey.co.uk/?p=272</guid>
		<description><![CDATA[Another one of Elgg&#8216;s less documented but very powerful features is the ability to expose functionality from the core and user modules in a standard way via a REST like API. This gives you the opportunity to develop interoperable web services and provide them to the users of your site, all in a standardised way. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://xkcd.com/262/"><img title="in_ur_reality" src="http://www.marcus-povey.co.uk/wp-content/in_ur_reality.png" alt="in_ur_reality" width="200" align="right" /></a>Another one of <a href="http://www.elgg.org">Elgg</a>&#8216;s less documented but very powerful features is the ability to expose functionality from the core and user modules in a standard way via a REST like API.</p>
<p>This gives you the opportunity to develop interoperable web services and provide them to the users of your site, all in a standardised way.</p>
<h2>The endpoint</h2>
<p>To make an API call you must direct your query at a special URL. This query will be either a GET or a POST query (depending on the command you are executing), the specific endpoint you use depends on the format you want the return value returned in.</p>
<p>The endpoint:</p>
<blockquote><p><code>http://yoursite.com/pg/api/<strong>[protocol]</strong>/<strong>[return format]</strong>/</code></p></blockquote>
<p>Where:</p>
<ul>
<li><strong>[protocol]</strong> is the protocol being used, in this case and for the moment only &#8220;rest&#8221; is supported.</li>
<li><strong>[return format]</strong> is the format you want your information returned in, either &#8220;php&#8221;, &#8220;json&#8221; or &#8220;xml&#8221;.</li>
</ul>
<p>This endpoint should then be passed the method and any parameters as GET variables, so for example:</p>
<blockquote><p><code>http://yoursite.com/pg/api/rest/xml/?method=test.test&amp;myparam=foo&amp;anotherparam=bar</code></p></blockquote>
<p>Would pass &#8220;foo&#8221; and &#8220;bar&#8221; as the given named parameters to the function &#8220;test.test&#8221; and return the result in XML format.</p>
<p>Notice here also that the API uses the &#8220;PG&#8221; page handler extension, this means that it would be a relatively simple matter to add a new API protocol or replace the entire API subsystem in a module &#8211; should you be so inclined.</p>
<p><strong>Return result</strong></p>
<p>The result of the api call will be an entity encoded in your chosen format.</p>
<p>This entity will have a &#8220;status&#8221; parameter &#8211; zero for success, non-zero denotes an error. Result data will be in the &#8220;result&#8221; parameter. You may also receive some messages and debug information.</p>
<h2>Exporting a function</h2>
<p>Any Elgg function &#8211; core or module &#8211; can be exposed via the API, all you have to do is declare it using <code><a href="http://reference.elgg.org/api_8php.html#3ee7de907c28ff90ec8b7ffc52254484">expose_function()</a></code> from within your code, passing the method name, handler and any parameters (note that these parameters must be declared in the same order as they appear in your function).</p>
<p><strong>Listing functions</strong></p>
<p>You can see a list of all registered functions using the built in api command &#8220;system.api.list&#8221;, this is also a useful test to see if your client is configured correctly.</p>
<p>E.g.</p>
<blockquote><p><code>http://yoursite.com/pg/api/rest/xml/?method=system.api.list</code></p></blockquote>
<h2>Authorising and authenticating</h2>
<p>Most commands will require some form of authorisation in order to function. There are two main types of authorisation &#8211; protocol level which determines whether a given client is permitted to connect, and user level where a command whereby a user requires a special token in lieu of a username and password.</p>
<p><strong>Protocol level authentication</strong><br />
Protocol level authentication is a way to ensure that commands only come from approved clients for which you have previously given keys. This is in keeping with many web based API systems and permits you to disconnect clients who abuse your system, or track usage for accountancy purposes.</p>
<p>The client must send a <a href="http://en.wikipedia.org/wiki/HMAC">HMAC</a> signature together with a set of special HTTP headers when making a call. This ensures that the API call is being made from the stated client and that the data has not been tampered with.</p>
<p>Eagle-eyed readers with long memories will see a lot of similarity with the <a href="http://www.marcus-povey.co.uk/2008/02/21/getting-started-with-the-elggvoices-api-part-1-api-basics/">ElggVoices API</a> I wrote about previously.</p>
<p>The HMAC must be constructed over the following data:</p>
<ul>
<li>The Secret Key provided by the target Elgg install (as provided easily by the APIAdmin plugin).</li>
<li>The current unix time in microseconds as a floating point decimal, produced my microtime(true).</li>
<li>Your API key identifying you to the Elgg api server (companion to your secret key).</li>
<li>URLEncoded string representation of any GET variable parameters, eg &#8220;method=test.test&amp;foo=bar&#8221;</li>
<li>If you are sending post data, the hash of this data.</li>
</ul>
<p>Some extra information must be added to the HTTP header in order for this data to be correctly processed:</p>
<ul>
<li><strong>X-Elgg-apikey</strong> &#8211; The API key (not the secret key!)</li>
<li><strong>X-Elgg-time</strong> &#8211; Microtime used in the HMAC calculation</li>
<li><strong>X-Elgg-hmac</strong> &#8211; The HMAC as hex characters.</li>
<li><strong>X-Elgg-hmac-algo</strong> &#8211; The algorithm used in the HMAC calculation &#8211; eg, sha1, md5 etc</li>
</ul>
<p>If you are sending POST data you must also send:</p>
<ul>
<li><strong>X-Elgg-posthash</strong> &#8211; The hash of the POST data.</li>
<li><strong>X-Elgg-posthash-algo</strong> &#8211; The algorithm used to produce the POST data hash &#8211; eg, md5.</li>
<li><strong>Content-type</strong> &#8211; The content type of the data you are sending (if in doubt use <code>application/octet-stream</code>).</li>
<li><strong>Content-Length</strong> &#8211; The length in bytes of your POST data.</li>
</ul>
<p>Much of this will be handled for you if you use the <a href="http://reference.elgg.org/api_8php.html#8b98a982e4462bfa0c752e124bb98c0c">built in Elgg API Client</a>.</p>
<p><strong>User level tokens</strong></p>
<p>User level tokens are used to identify a specific user on the target system, in much the same way as if they were to log in with their user name and password, but without the need to send this for every API call.</p>
<p>Tokens are time limited, and so it will be necessary for your client to periodically refresh the token they use to identify the user.</p>
<p>Tokens are generated by using the API command &#8220;auth.gettoken&#8221; and passing the username and password as parameters, eg:</p>
<blockquote><p><code>http://yoursite.com/pg/api/rest/xml/?method=auth.gettoken&amp;username=foo&amp;password=bar</code></p></blockquote>
<p><strong>Anonymous methods</strong><br />
Anonymous methods (such as &#8220;system.api.list&#8221;) can be executed without any form of authentication, thus accepting connections from any client and regardless of whether they provide a user token. This is useful in certain situations and it goes without saying that you don&#8217;t expose sensitive functionality this way.</p>
<p>To do so set $anonymous=true in your call to expose_function().</p>
<p><small>Image “<a href="http://xkcd.com/262/">In UR Reality</a>” by <a href="http://www.xkcd.com">XKCD</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcus-povey.co.uk/2009/08/25/using-elggs-rest-like-api/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The Export Interface</title>
		<link>http://www.marcus-povey.co.uk/2009/08/24/the-export-interface/</link>
		<comments>http://www.marcus-povey.co.uk/2009/08/24/the-export-interface/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 16:42:21 +0000</pubDate>
		<dc:creator>Marcus Povey</dc:creator>
				<category><![CDATA[elgg]]></category>
		<category><![CDATA[#ue]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[interface]]></category>

		<guid isPermaLink="false">http://www.marcus-povey.co.uk/?p=263</guid>
		<description><![CDATA[One of the more hidden features of Elgg is the Export interface. In a nutshell this interface provides an export view for Entities, Metadata, Annotations and relationships which can provide a convenient way of accessing data objects in a machine readable form. Endpoints The export url is constructed in different ways for entities, relationships and [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.marcus-povey.co.uk/wp-content/elgg-com-logo.gif" alt="" width="180" align="right" />One of the more hidden features of Elgg is the Export interface.</p>
<p>In a nutshell this interface provides an export view for Entities, Metadata, Annotations and relationships which can provide a convenient way of accessing data objects in a machine readable form.</p>
<h2>Endpoints</h2>
<p>The export url is constructed in different ways for entities, relationships and metadata.</p>
<p>All endpoints begin with:</p>
<blockquote><p><code>http://yoursite.com/export/<strong>[VIEW]</strong>/</code></p></blockquote>
<p>Where [VIEW] is the format you want the data exported in &#8211; e.g. json, opendd, php or default.</p>
<p><strong>Entities</strong><br />
To export a GUID simply add it to the end:</p>
<blockquote><p><code>http://yoursite.com/export/<strong>[VIEW]</strong>/<strong>[GUID]</strong>/</code></p></blockquote>
<p><strong>Annotations &amp; Metadata</strong></p>
<p>Metadata and annotation can be exported by providing the type (&#8216;annotation&#8217; or &#8216;metadata&#8217;) and the appropriate ID.</p>
<blockquote><p><code>http://yoursite.com/export/<strong>[VIEW]</strong>/<strong>[GUID]</strong>/<strong>[annotation|metadata]</strong>/<strong>[annotation_id|metadata_id]</strong>/</code></p></blockquote>
<p><strong>Relationships</strong><br />
Follows the same format as above, but with <strong>[GUID]</strong> being the first guid in the relationship &#8211; in essence the entity to which the relationship &#8220;belongs&#8221;.</p>
<blockquote><p><code>http://yoursite.com/export/<strong>[VIEW]</strong>/<strong>[GUID]</strong>/relationship/<strong>[relationship_id]</strong>/</code></p></blockquote>
<h2>Security</h2>
<p>Some items of data (for example user passwords) are restricted from this export view. Exactly what is output by an output view is governed by <code>$object-&gt;getExportableValues();</code> which returns a list of exportable fields in the entity.</p>
<p>In addition, access permissions on the object are respected &#8211; meaning that if you can&#8217;t see an item in Elgg, you will not be able to see it in the export view either.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcus-povey.co.uk/2009/08/24/the-export-interface/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
