A PHP wrapper for the unix at command

A project I am working on at the moment requires time delayed job queues and having found nothing yet that can manage it properly so I decided to wrap up `at` into a PHP class. This gives you simple methods to add, list and remove jobs from the `at` queue using object oriented code.

The code is very simple and I have documented it reasonably well so along with the examples you should get on your way quickly. The class can, of course, be used from the command line as well so if you want to write batch scripts in PHP to handle adding a collection of predefined `at` jobs for example - it can make it easier.

I feel the important features of `at` have been added into the code, but if you want to wrap any of the other functions then please do fork my code and make a patch or post a pull request. For more information on what `at` can do please either run `man at` in your console or visit the Edinburgh University’s man at page.

You can get the code from my repository on GitHub: PHP-at-Job-Queue-Wrapper.

If you do have any trouble getting the `at` daemon (atd) going then my previous post may help you debug it - please see If you are having problems getting Ubuntu atd running for more on that.

Getting gearman to install on Ubuntu

External Link: Getting gearman to install on Ubuntu

Getting the gearman PHP PECL package to build on Ubuntu is problematic with many unaccounted for dependency issues.

I only made a couple changes when following the instructions from JSJoy as I am running Karmic rather than Lucid I changed the apt-get sources to:

deb http://ppa.launchpad.net/gearman-developers/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/gearman-developers/ppa/ubuntu karmic main

My sources file was also located at /etc/apt/sources.list and not /etc/sources.list as stated in the original post from JSJoy.

Drop Cap with PHP Regular Expression

This is a simple regular expression I wrote to convert the first letter of an article into a drop cap. It will surround the first letter with a span tag containing the class drop-cap. You can then apply any styling you like to the span with CSS. It will skip over any HTML encoded characters or tags at the beginning of the article as well so it always highlights the first letter of the content and not any HTML formatting.

http://gist.github.com/469749

Updated: Back up Tumblr Blog and/or Disqus Comments

External Link: Updated: Back up Tumblr Blog and/or Disqus Comments

A simple and somewhat dirty script for backing up Tumblr and/or Disqus via its API to an SQLite DB. It now handles backing up Disqus comments to SQLite as well.

Backing up Tumblr blogs with PHP and SQLite

External Link: Backing up Tumblr blogs with PHP and SQLite

I have knocked together a very simple and somewhat dirty PHP CLI script to download copies of an entire Tumblr blog through their API. I have imaginatively called it Tumblr Backup PHP. I will be adding extra features as and when I can. The first new feature on the list will be ability backup the associated Disqus comments at the same time.

This script was developed on Windows so you will need to update the PHP binary location in the top of the run.php file. More installation information is available in the readme file on GitHub.

Essentially the script uses php-rest-api by Jason Tan to download all your blog posts in 50 post chunks from the Tumblr API and Idiorm by Jamie Matthews to then save all the posts into an SQLite database.

All you need to do is update the configuration file with your blogs details and then execute run.php in your console/command prompt. You will need SQLite, cURL and PHP5 to run the script. You do not need a web server you can just install PHP on your machine and run the script from the command line just like you would with a Python or Ruby script.

There is currently no allowances for time outs when accessing the API and there is also no restore script at the moment.

Agavi: Agavi on the Azure Platform

External Link: Agavi: Agavi on the Azure Platform

The next release of Agavi will have initial support for running applications on the Microsoft Windows Azure platform, as well as a database adapter for the new ext/sqlsrv driver to communicate with Microsoft SQL Server and support for the IIS7 web server, which now finally has a very nice

ADODB

During a recent project I ended up using ADODB and found it very effective. Especially the wrapper it places around PHPs sessions, it stores them in the DB instead of in the temp directory, which can be less secure. It also handles encryption of the session variables contents, but only using MD5 originally and I prefer to use SHA1. So I hacked the following to allow me to do so and I contributed it to ADODB.

adodb-encrypt-sha1.php (new file):

http://gist.github.com/294724

Add to crypt.inc.php:

http://gist.github.com/294725

This code has now been added to the stable release of ADODB.

An interesting PHP site

Some hints and tips for producing secure PHP code. Some tips are gems others are less so.

http://securephp.damonkohler.com/

Developing with CamTech

For a project I am working on at the moment we are using the CamTech Merchant Gateway. A handy note to all is that it will not function on anything but Java 1.4.x. Java 5 does not work.