New here? Then you may want to subscribe to my rss feed. :)

Site Launch - ASHT.INFO

July 8th, 2008 | Posted in Codeigniter, Development, Freelancing, My Work News, PHP | 

After many months of development, I am glad to say that www.asht.info has finally launched.

Who are ASHT?

The Anglo Sikh Heritage Trail is a project of the Maharajah Duleep Singh Centenary Trust. The Trust was first established in 1993, the centenary year of the death of Maharajah Duleep Singh, with the primary objective of highlighting and promoting Anglo Sikh heritage. Since then it has engaged in a series of initiatives, including the Arts of the Sikh Kingdoms exhibition in collaboration with the V&A, the annual Portrait of Courage lecture at the Imperial War Museum and the Jawans to Generals exhibition in collaboration with English Heritage. Other projects have included the commissioning of a bronze statue of Maharajah Duleep Singh at Thetford; the first major piece of Sikh art outside India, as well as two highly successful festivals of Anglo Sikh heritage.

The site has a user friendly CMS, newsletter system as well as various ways for the community to contribute. The site was built using PHP/Codeigniter framework with a MySQL database. Client side development resulted in clean CSS/HTML markup as well as the creation of database driven flash elements. Site wide search makes use of Google’s Custom Search.

Visit ASHT

Discuss this article »

Eclipse, just when I thought we were getting on…

October 1st, 2007 | Posted in Development, PHP | 6 Comments

In an earlier post I talked about how great Eclipse was as an all purpose IDE. Then it decides to let me down in the most spectacular way possible.

I was working on a project for a client, deadline was 2pm. Managed to get the last bit done at 2.05pm. Excellent I thought, all I need to do is upload and we’re done. In Eclipse I had two files open. One of which needed uploading which took me several hours to code and test. I switched to my FTP client to upload, surprisingly, I couldn’t find the file in the file explorer part of the FTP client. Strange… So I switched back to Eclipse, the file had disappeared from the list of open files. Several panicky searches later and the worst possible thing had happened. The file had simply “disappeared”. WTF?!?! As you can imagine, I wasn’t best pleased. Many many many four letter words later I decided to re-code the page. By the time I was finished it was 5pm. OK, only a few hours late.

Searching forums I discovered that this had happened to other Eclipse users. This to me seems like a MAJOR issue which needs addressing.

Discuss this article »

Wordtube and protected wordpress posts

August 19th, 2007 | Posted in Development, PHP | 3 Comments

I rarely password protect posts. Never have anything I wouldn’t want prying eyes to see. Occasionally though, I do have to place content behind a password entry form.

Using Wordtube, I uploaded an .flv file and password protected the page. I noticed that the RSS feed had a link to the .flv file in its “enclosure” tag. This revealed the path to the video file I was intending to hide.

Digging through Wordpress RSS feed generating scripts, I saw that this had been taken into account and couldn’t work out how this particular one was getting through. Well, would you Adam and Eve it, Wordtube also has its own RSS feed generator.

By adding a check to the RSS generating code prevented it from revealing .flv, .mp3, .swf and .jpg files.

In wordtube.php, at line 233…ish:

  1. // Add single media file to RSS feed
  2. function add_wpTube_rss2_file()
  3. {
  4.         GLOBAL $wpdb, $post;
  5.  
  6.         // CHECK FOR PASSWORD PROTECTED POST
  7.         // RETURN IF POST IS PROTECTED
  8.         if ( !empty($post->post_password))
  9.                 return;
  10.  
  11.         $search = "/\[MEDIA=(\d+)\]/";   //search for ‘media’ entry
  12.         preg_match_all($search, $post->post_content, $matches);

Any problems then let me know.

Discuss this article »

SimplePie RSS class and CodeIgniter

June 18th, 2007 | Posted in Codeigniter, Development, PHP | 18 Comments

Users of the latest version of Simplepie (Version 1.0.1) have been getting errors when passing in the feed url. The error refers to a missing method “feed_url()”. This is due to a change in Simplepie, to set the feed url you must now use “set_feed_url(your rss url)”.

A pet project of mine which I will unleash upon you all soon required the home page to read in an RSS feed. Since I am a CodeIgniter whore I soon learnt that amongst its many libraries and helpers that there wasn’t an RSS reader.

This was easily solved using an open source PHP RSS class called SimplePie. Simply, I can’t imagine ever needing anything else. Not to mention the ease of getting it to work within CodeIgniter. By placing simplepie.inc in the libraries directory and renaming it to simplepie.php, I could now use its methods to parse and display my RSS feed.

Within your controller:

  1. function index() {
  2.         $this->load->library(’simplepie’);
  3.         //$this->simplepie->feed_url(’http://www.digg.com/rss/indexdig.xml’);
  4.         // You may have encountered an error where it couldn’t find feed_url. This is due
  5.         // to a change in the latest version of simplepie. Simply, feed_url is now set_feed_url
  6.         $this->simplepie->set_feed_url(‘http://www.digg.com/rss/indexdig.xml’);
  7.         $this->simplepie->init();
  8.         $data[‘dig_feed’] = $this->simplepie;
  9. }

Passing the $data array holding the parsed feed data to the view template made displaying the data a breeze. get_items() returns all feed data as an array. Optionally, if you wish to only display the first 5 items, get_items takes 2 parameters, the starting position and quantity to return. Passing in 0,5 as arguments returns the first 5 items.

  1. echo "<ol>";
  2. foreach($dig_feed->get_items() as $item) {
  3.         echo "<li><a href=’" .$item->get_link() . "’>" . $item->get_title() . "</a></li>";
  4. }
  5. echo "</ol>";

Any problems then let me know.

Discuss this article »

Play a random mp3 file from a specific directory

June 4th, 2007 | Posted in Development, PHP, Wordpress | 13 Comments

In this post i discussed how to play random media files using wordtube by passing a comma delimited list of media ids.

Josh asked if there was a way of playing files from a specific directory rather than having to upload through wordtube and listing all media file ids.

Having helped Josh I thought it would be of use to others if I posted a little how to.

Firstly, you will need to download, install and activate coffee2code Random File plugin. This will randomly select a file from the specified directory and return it as a url ready to pass into the flash player.

Next, you need to download Flash Mediaplayer and upload mediaplayer.swf. For the sake of this how-to, I have uploaded it to the web root.

You will need to create the code to embed the flash player. Fortunately there is a wizard available here which will create all the code for you.

Copy paste the generated embed code and replace the file parameter value with a call to the random file plugin like so:

  1. <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  2. codebase= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8"
  3. width="320" height="20"
  4. id="randomplayer">
  5.  
  6.         <param name=movie value="mediaplayer.swf">
  7.         <param name=quality value="high">
  8.         <param name=bgcolor value="#FFFFFF">
  9.         <param name=allowFullScreen value="false">
  10.         <param name=swLiveConnect value="true">
  11.         <param name=allowScriptAccess value="sameDomain">
  12.         <param name="FlashVars" value="file=<?php echo c2c_random_file(’/path_to_music_folder_relative_from_webroot’, ‘mp3′, ‘url’); ?>& width=320&height=20&displaywidth=320&displayheight=0
  13. &autostart=true&backcolor=0xFFFFFF">
  14.  
  15.         <embed type="application/x-shockwave-flash"
  16.         pluginspage="http://www.macromedia.com/go/getflashplayer"
  17.         width="320" height="20" bgcolor="#FFFFFF"
  18.         name="randomplayer"
  19.         src="mediaplayer.swf"
  20.         flashvars="file=<?php echo c2c_random_file(’/path_to_music_folder_relative_from_webroot’, ‘mp3′, ‘url’); ?>&width=320&height=20&displaywidth=320&displayheight=0 &autostart=true&backcolor=0xFFFFFF">
  21.         </embed>
  22.  
  23. </object>

Taken from plugin authors page:

The directory of random files must exist at the directory structure level of your WordPress installation or below. (i.e., if your site is installed on your server at /usr/local/htdocs/yoursite/www/journal/, then the directory of random files you specified will assume that as its base… so $dir=’randomfiles’ would be assumed to actually be: /usr/local/htdocs/yoursite/www/journal/randomfiles/)
Leading and trailing ‘/’ are unnecessary… ‘/randomfiles/’ == ‘/randomfiles’ == ‘randomfiles/’ == ‘randomfiles’

Finally, you need to place the code in one of your theme templates. Hopefully, you will have the player stream a random mp3 from a specified directory on every page load. If you encounter any problems then ask.

Discuss this article »