Archive for September, 2005

Weekends just aren’t long enough!

Well the weekend is over yet again, and in under 9 hours I’ll be (or rather, should be) back at my desk for the start of another week.

Weekends just aren’t long enough. I’ve been arguing for a four day working week for some time, but alas I can’t see this happening any time soon. I’ve hardly made any inroads into my mass of work, and I just feel a bit swamped by it all.

I need a holiday.

On the plus side I got quite a novel web site finished yesterday, and made a few finishing touches to it today. It all seems to be running quite happily, but I’ll have to keep an eye on it over this next week.

There’s still loads to do on BritBlog too. There are loads of blogs to review (nearly 200), and I really just want to get on and fix some bugs and add some new features. The XML-RPC ping service is nearly ready to be tested too (or part of it is at least — the easy bit that is!), so I’ll be looking for some volunteers to be beta testers shortly.

I managed to break the comments system on this blog yesterday too. I’ve been get shed loads of comment spam, so at least it put a stop to that for a bit. I was trying to get Gudlyf’s Authimage thing working, but there seems to be a problem with it. No time to find out what the issue was though. Maybe I’ll have a chance this week.

I’ve got loads of photos to tweak from some weddings I went to this summer too. (Odd that the Autumn seems to be here already.) I take RAW photos with my camera (not JPEGs of TIFFs), and this means they all have to be processed to get the best from them. This is great when you only have a few to get through, but when there are hundreds it’s quite a daunting task! Maybe I’ll take my laptop in to work so I can get on with them at lunch time… We’ll see.

Right, must get some sleep now. TTFN.

XML-RPC autodiscovery

You probably know by know that I’ve been playing with PEAR and XML-RPC a lot lately. Well when reading an excellent book called Advanced PHP Programming I came across a small section on XML-RPC autodiscovery. This seemed like an interesting thing to me (no, really it did), so I decided to have a play.

Now my only problem with this book is that most of the stuff is written for PHP5. This wouldn’t be so bad (PHP 5 looks to have to great improvements), except for the fact that most of the web servers I have to work on all run PHP 4.

So, for the benefit of the human race, I’ve re-written the script so that it will work in PHP4:

require_once('XML/RPC.php');

$url = parse_url('http://www.oreillynet.com/meerkat/xml-rpc/server.php');
//$url = parse_url('http://www.syndic8.com/xmlrpc.php');
//$url = parse_url('http://www.newsisfree.com/RPC');
//$url = parse_url('http://localhost/index.php');

$cli   = new XML_RPC_Client($url['path'], $url['host']);
$msg   = new XML_RPC_Message('system.listMethods');
$resp = $cli->send($msg);

if($resp->faultCode())
{
   echo "** ERROR **n";
   echo 'Fault Code: ' . $result->faultCode() . "n";
   echo 'Fault Reason: ' . $result->faultString() . "n";
   exit;
}

// get list of methods returned
$methods = XML_RPC_decode($resp->value());

foreach($methods as $method)
{
   print "Method $method:n";

   // get the documentation for this method
   $oDoc = $cli->send(
                      new XML_RPC_Message('system.methodHelp',
                      array( new XML_RPC_Value($method) ))
                      );

   $doc = XML_RPC_decode( $oDoc->value() );

   if($doc)
   {
      print "$docn";
   }
   else
   {
      print "No Docstringn";
   }

   // get the method signatures (if there are any)
   $msg = new XML_RPC_Message('system.methodSignature',
                              array(new XML_RPC_Value($method)));
   $oResp = $cli->send($msg);
   $resp = $oResp->value();

   if($resp->kindOf() == 'array')
   {
      $sigs = XML_RPC_decode($resp);
      for($i = 0; $i < count($sigs); $i++)
      {
         $return = array_shift($sigs[$i]);
         $params = implode(", ", $sigs[$i]);
         print "Signature #$i: $return $method($params)n";
      }
   }
   else
   {
      print "No Signaturen";
   }
   print "n";
}

Save this file as something like rpc-test.php and you can run this from the command line like this:

php -f rpc-test.php

Depending on the server you point it at, you will get output like the following (in this case from Meerkat, O’Reilly Network’s Open Wire Service):

Method meerkat.getChannels:
Returns an array of structs of available RSS channels each with its associated channel Id.
Signature #0: array meerkat.getChannels()

Method meerkat.getCategories:
Returns an array of structs of available Meerkat categories each with its associated category Id.
Signature #0: array meerkat.getCategories()

Method meerkat.getCategoriesBySubstring:
Returns an array of structs of available Meerkat categories each with its associated category Id given a substring to match (case-insensitively).
Signature #0: array meerkat.getCategoriesBySubstring(string)

Method meerkat.getChannelsByCategory:
Returns an array of structs of RSS channels in a particular category (specified by integer category id) each with its associated channel Id.
Signature #0: array meerkat.getChannelsByCategory(int)

Method meerkat.getChannelsBySubstring:
Returns an array of structs of RSS channels in a particular category each with its associated channel Id givena substring to match (case-insensitively).
Signature #0: array meerkat.getChannelsBySubstring(string)

Method meerkat.getItems:
Returns an array of structs of RSS items given a recipe struct.

Search Criteria:
  channel (int) - a channel's numeric id
  category (int) - a category's numeric id
  item (int) - a particular item's numeric id
  search (string) - /a MySQL regular expression/
	time_period (string) - travel back in time; format: #(MINUTE|HOUR|DAY)
  profile (int) - a particular profile's numeric id
  mob (int) - a particular mob's numeric id
  url (string) - a particular url

Display Recipes:
  ids (int) - Return story ids (0=off, 1=on)
  descriptions (int) - Return item descriptions (0=off, 1=full, >1=length)
  categories (int) - Return categories with which items are associated (0=off, 1=on)
  channels (int) - Return channels in which items appeared (0=off, 1=on)
  dates (int) - Return the dates items were picked up by Meerkat (0=off, 1=on)
  num_items (int) - The number of items to be returned (0 < n <=50)

Example:
  $ f = new xmlrpcmsg("meerkat.getItems",
    array(
      new xmlrpcval(
        array(
          "channel" => new xmlrpcval(724, "int"),
          "search" => new xmlrpcval("/xml|[Jj]ava/", "string"),
          "time_period" => new xmlrpcval("3DAY", "string"),
          "ids" => new xmlrpcval(0, "int"),
          "descriptions" => new xmlrpcval(200, "int"),
          "categories" => new xmlrpcval(0, "int"),
          "channels" => new xmlrpcval(0, "int"),
          "dates" => new xmlrpcval(0, "int"),
          "num_items" => new xmlrpcval(5, "int"),
      	),
        "struct"
      )
    )
  );

Signature #0: array meerkat.getItems(struct)

Method system.listMethods:
This method lists all the methods that the XML-RPC server knows how to dispatch
Signature #0: array system.listMethods(string)
Signature #1: array system.listMethods()

Method system.methodHelp:
Returns help text if defined for the method passed, otherwise returns an empty string
Signature #0: string system.methodHelp(string)

Method system.methodSignature:
Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)
Signature #0: array system.methodSignature(string)

Caveat

You may run into some problems when running this script: not all servers make the system methods available to them (like system.listMethods, system.methodHelp, and system.methodSignature

Anyway, I hope someone finds this useful/interesting…

BritBlog news

Two things to mention:

1) BritBlog now has a blog, so you should read it/subscribe to it/leave a comment! It will cary on in the same vein as the old news system: announcing new features, newsworthy things, and bringing up questions for general discussion. You not there yet? Go and read it!

2) I’d like to introduce our latest BritBlog editor: Merialc. Welcome to the team Merialc!

Texas hold ‘em - what the hell is it?

Texas hold ‘em is one of those things that’s been on my mind a lot lately. I, probably like lots of you, have been getting loads of spam comments and emails over the last few months on various online gambling topics. One of the most memorable of these is Texas hold ‘em. On the radio this morning the news was talking about how well (but at the same time how badly) the UK’s largest online gambling site, Partygaming, has been doing. It seems that although their revenue has risen 80% in the last six months, their share prices have fallen more than 30% after it warned future market growth could slow.

Hmm. I’m no business anylist, so I can’t give any incitful comment to this news. But it got me thinking. What is the thing with all this online betting, and what is this Texas hold ‘em thing I keep getting spammed about?

Texas hold ‘em (or simply hold ‘em or holdem) is the most popular of the community card poker games. It is the most popular poker variant played in casinos in the western United States, and its no-limit form is used in the main event of the World Series of Poker (abbreviated WSOP), widely recognized as the world championship of the game.

Source: WikiPedia

So in other words, it’s poker. All that for poker. It’s amazing that this industry has grown such a lot over the last year, and that a company like Partygaming can make £237.7m from it! All you seem to see plastered everywhere over the internet is online gambling, offshore gambling, gambling boats and casinos (!!!), and we mustn’t forget our old favorites viagra and cialis! (Cialis I think will have to be the topic of another post - this is another one of those things I get spammed about and have absolutely no idea what it is!)

So is there a conclusion to this post? If there is, it’s not made itself known yet. I’m just left thinking if I’m in the wrong business…

PHPHighlight - MediaWiki Extension

Introducing my second MediaWiki extension: PHPHighlight!

This is actually quite a straight forward extension as it’s just really a wrapper around the PHP highlight_string() function. Still, it’s quite useful if you need to stick PHP snippets in your Wiki articles as it makes the code nicer to read :-)