Enabling PHP error reporting on Dhiraagu hosting

Here's a quick tip for anyone stumped by the issue.

I have not dealt with the web hosting services from Dhiraagu for a long time but had a brief encounter earlier this week when I was attempting to setup the custom CMS we use at Semicolon for a client project. It turns out Dhiraagu has error reporting disabled for their PHP setup as well as disabled the phpinfo() function, which by themselves really are decent security measures. But as a developer, error reporting is essential when setting up a new application or testing out code and debugging.

You can get back error reporting on Dhiraagu hosting services by overriding their error reporting setting through a .htaccess or by adding a PHP statement at the start of the PHP files.

.htaccess:
php_value display_errors on
php_value display_startup_errors on


PHP:
ini_set('display_errors',1);
error_reporting(E_ALL); // Or whatever level of error reporting you would like


Unfortunately, short of asking Dhiraagu, there is no way (atleast, that I am aware of) to activate the phpinfo function if it has been disabled by adding it to the "disable_functions" list in php.ini. However, it is possible to cull all (if not most) the data available via the phpinfo() function using other functions available within PHP.

Blogger to Serendipity importer script v2

I had occasion last night to revisit the Blogger to Serendipity importer script I wrote a few years ago, while helping someone move from Blogger to something that packs a bit more punch.

Serendipity has been carrying the script I wrote bundled as part of the importers available in its core package, thanks to Garvin Hicking (lead developer at the Serendipity project) who had done the dirty work of integrating my code into the project. Anyway, last night when I got about to importing the blog on Blogger into a fresh install of Serendipity, I found myself annoyed by the tediousness of the process required by the very importer I'd authored. Blogger didn't have any export feature back then nor did it provide API access. As a result, the (popular) method for exporting a blog from Blogger had involved setting a special template as the blog's layout and tweaking around a few other settings, after which the blog is published and the output parsed to extract what is needed.

Things have, of course, changed dramatically and for the good in the years since, as Google has continued to open up its services for developers via public APIs. Encouraged by the simplicity of the API, I ended up spending a little bit of time to rewrite the importer almost from scratch. The highly desirable "export blog" feature in the Blogger Data API allows obtaining an XML based dump of the entire blog, which can then be moulded however to fit ones needs.

Download

- Download s9y-bloggerimporter-v0.2.zip (3.3Kb)

Requirements

- PHP 5

Installation

- Extract the contents of the Zip file.
- Upload (or copy) the file "blogger.inc.php" to the folder "include/admin/importers" under the main Serendipity installation path. Make sure the old file is replaced with the new.

Usage

The new importer script can transfer posts (both published and drafts), comments (including comment moderation settings) and authors, without breaking sweat. The process for importing a blog is simple:
1. Login to Blogger/Google and login to Serendipity Administration Suite.
2. Navigate to "Import data" using the menu and select Blogger.com as the type of import.
3. Click the "Go to Google" link to jump to a special authorization request page that allows the importer to access the blogs. [Image 1]
4. Click the "Grant access" button and wait to be taken back to Serendipity. [Image 2]
5. Select the blog to import from the list. [Image 3]
6. Optionally, select the category for the imported posts, set desired trackback behavior, select a charset. [Image 3]
7. Click "Import now!". (see Image 3]
8. Posts (and its comments) are processed and import results displayed.


Image 1


Image 2


Image 3


Enjoy!

Update (17-Feb-2009): This has been adopted into the Serendipity code base and would be available bundled-in with future releases from the project.

Thaana date formatting for PHP 5

Here is a PHP 5 class that provides a drop-in function replacement/equivalent for the built-in PHP date() function to output formatted dates in Thaana/Dhivehi. It follows the standard method of writing Gregorian dates in Thaana by using transliterations of the English month names and using the native Dhivehi names for the week days. It accepts all the usual formatting arguments permitted by the original date() function thus allowing the same degree of formatting freedom as the original. The output returned from the function uses ASCII Thaana and, if needed, can then be converted to Unicode/UTF-8 by using the Thaana Conversions class. This class does not support Hijri dates (yet).

The class is being released under the Open Source MIT License.

Functions exposed

format()
Returns a Dhivehi date string formatted according to the given format string using the given integer timestamp

Usage

<?php
// Load class include
require 'thaana_date.obj.php';

// Format date
$thaanatoday = Thaana_Date::format('j M Y', time());
?>

Download

- Thaana_Date.zip (v0.2, 1.4KB)

Drop me a line if you have comments/queries. Enjoy :-)

Thaana Unicode<->Ascii conversions PHP class

Here is something that would probably be very handy to Maldivian web developers dabbling with Dhivehi sites. This PHP class addresses the need for converting text to and from Thaana in Ascii and Thaana in Unicode.

The class makes it easy to standardize text into one format irrespective of how it was/is written. This means that you can take text written in Accent, MS Word 97 (and prior) or written using Unicode as featured on recent MS Word editions and use the class to present output in the format of your choice without the need for imposing restrictions on the people who write the text. The class comes in even more handy when you have a form submission that takes input in Unicode but needs to be stored in the database or presented later as Ascii, or vice versa.

The class was something I originally wrote around 2001 and was used in the free Online Document Converter that featured on maldivianunderground.net. I rewrote it for PHP 5 recently for use in a project I am working on. The original class had support for Letin dhivehi -> Unicode/Ascii conversions as well which I haven't included in this release but will add it a future update.

Usage should be pretty straightforward but here is an example just to illustrate:

Example:
<?php
require 'thaana_conversions.obj.php';
$thaana = new Thaana_Conversions();

echo $thaana->convertUnicodeToAscii('&#1931;&#1960;&#1928;&#1964;&#1920;&#1960;');
echo $thaana->convertAsciiToUnicode('rWacje');
?>

Download:
- Thaana_Conversions.zip (v0.1, 2KB)

Enjoy :-)

Update (7-May-2008): This version is now superseded by v0.2.

Updated: PHP script for Hulhule flight info

I'm releasing an update to the Hulhule FlightInfo PHP class I released late last year as a response to a feature request I received recently. The update adds support for flight information for all the days as available on the Flight Information Services site rather than the current-day-only mode that the original script supported. A small demo script is packaged in the download to highlight the usage details.

The Hulhule Flight Info class simplifies access to the flight information by doing the dirty work of grabbing the HTML page from the FIS site, parsing it, extracting the required information and making it accessible as a multidimensional array. It supports grabbing both the arrival and departure information and is easy to use. It has since been integrated into a few sites by different people.

- Download the flightinfo class v0.2

Enjoy :-)

PHP script for live Hulhule flight info

The Maldives Airports Company has rolled out a website (http://www.fis.com.mv/) where real-time flight arrival/departure information is available. It's about time they did that and I am sure many people will find it very useful.

I wrote some code yesterday for Nattu, who is currently developing a new website for Haveeru News, to get the data from the Flight Information Services (FIS) website and display it on the Haveeru website. Haveeru has access to an XML feed of the data with more fields available than that shown at the FIS site. The script I wrote implements a class that parses the XML file and provides easy access to the flight information via the class properties.

Sadly, the XML feed is not (yet) available to the public and so today I modified the code so that it works by scraping the publicly available data on the FIS website. The code implements an object called "flightinfo" that can be used in any of your PHP applications and the data displayed as you please. I've included a demo sample file as well.

- Download the flightinfo script

WebSMS for blogs, websites and Google personalised home

Here is something I conjured up in the minutes of freedom after "work" last night. It is what I would call a widget - a WebSMS widget. The idea for the application came after a blog reader by the handle Vayfarer emailed me asking for advice on implementing a "Gadget" for Google personalised home. Anyway, two and a half hours later, I had this baby all wrapped up just as I wanted it.

This "widget" can be added to your blog or website. You will be able to host this widget on your own server when I release the source code, until then you are welcome to use the service based at the Technova server. The widget supports skinning the widget with your own CSS files and so can be made to fit the look of your blog and/or website. I will be releasing the source code for the project soon - right after I flush any major bugs that crops up the coming few days.

widget_websms


I've also made available a "gadget" package for adding the WebSMS widget to the Google "personalised home".

websms widget at google homepage


Here is live demo:


Interested in getting one for your blog/website or adding it to your Google homepage? Click here to go to the widget's homepage at Technova.

Have fun.

PS: Other SMS related stuff that I've released previously include, a SMS Sender program which you can run on your Windows/Mac/Linux computer and a WebSMS tool for phpBB forums.