libcurlemu – a pure PHP curl implementation (libcurl emulator)

Have you came across a situation where you need to use php libcurl extension and it was not enabled on your webserver? Then, try libcurlemu, apure-PHP implementation to PHP cURL. It emulates all of the curl_* functions normally provided by the native cURL extension itself.

libcurlemu works transparently regardless of the availability of PHP cURL extensions, thus making your script even more portable across web server that does not have PHP cURL extensions.

What is libcurl / cURL?

cURL is a command-line tool that supports transfering files with URL syntax. It supports many protocols like FTP, FTPS, TFTP, HTTP, HTTPS, TELNET, DICT, FILE and LDAP.

libcurl is a library based on cURL that helps you to connect and communicate with different type of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, and ldap protocols.

For HTTP/HTTPS protocol, libcurl supports POST, PUT, GET and DELETE method, making it suitable for writing web services, particularly REST-like services.

Stay tune for code examples on how to use libcurl to emulate a browser submitting POST request to a server.

libcurlemu is written by Steve Blinch, and can be downloaded at his website :

php, libcurl, curl, rest, opensource

sphpblog – php blog scripts with text storage

blog, blogging, sphpblog, php, open source, free software, gnu/gpl

One of my friends is using sphpblog as his blogging platform which makes me curious to try it out myself.

Simple PHP Blog script is a simple blog application which only uses text files as its data storage. This in turn makes it one of the simplest php blog script to install, you just need to unpack it and you’re done (well you need to change some write permission).

sphpblog packs the most features for its size. It has (among others) :

  • Comments
  • Trackbacks
  • Post Category
  • Syndication feed (RSS 2.0, RSS 1.0, ATOM 0.3
  • Search feature
  • Article Rating
  • Article views counter
  • Contact Me page
  • Build in blog stats
  • Archives Calendar
  • and many more…!

sphpblog certainly has more than I could expect from a blogging platform, it’s simple requirements of using PHP version > 4.3.x (it supports PHP5 too) and a couple of write permissions makes it easy to install.

Finally, sphpblog is available for download here, under the terms of GNU General Public License version 2.0


Using Feedcreator to generate ATOM 1.0 feeds

I’m going give out a tip on using feedcreator class library to ease up generating syndication feeds for your web project. As you might know, there are different kind of syndication format out there such as RSS 2.0, RSS 1.0, RSS0.91, ATOM0.3 and ATOM1.0. Each of the syndication format has its own markup (though RSS 0.91 and 2.0 are closely related), making generating feeds from scratch can be quite a chore for your project.

Feedcreator provides an easy way to create RSS and ATOM feeds from within PHP using ease to use classes. However, feedcreator has a couple of drawback :

  1. It does not support ATOM 1.0
  2. Doesn’t support Enclosure
  3. Can’t generate feeds on the fly

Though these drawbacks might not be as serious as I put in here, it is nice to have this features implemented on feedcreator. ATOM 1.0 is a new syndication format issued by IETF as a standard way to produce feeds, ATOM 1.0 has a nice features and more structured layout than the ever-inconsistent RSS feeds.

Though Enclosure tag is optional in RSS 2.0, the tag is significant for those who are into podcasting or photoblogging. Enclosure feature allows for the syndicated feed to not just serve text content, but also to package an enclosure (call it an attachment of some sort), as well. IIn the podcasting model, the RSS enclosure contains an audio file, which subscribers can listen to on their devices.

Generating feeds on the fly is one of the most requested feature of feedcreator. This allows feeds to be generated dynamically upon request as opposed to generating feed on certain event (such as posting new articles). Mambo and PhpGedView project uses modified Feedcreator to generate feeds on-the-fly.

I’ve published a modified version of Feedcreator (namely Feedcreator 1.7.2-ppt) that contains all of these enhancements (or hacks). Here’s a snippets on how to use the additional features :


This demo is to illustrate how to use feedcreator
using outputFeed function, ATOM1.0 and enclosure

Enclosure support is useful if you are into
podcasting or publishing photoblog.

the required parameter for enclosure is url, length
and type (as in MIME-type)


< ? php include ("include/feedcreator.class.php"); //define channel $rss = new UniversalFeedCreator(); $rss->useCached();
$rss->title="Personal News Site";
$rss->description="daily news from me";

//channel items/entries
$item = new FeedItem();
$item->title = "test berita pertama";
$item->link = "";
$item->description = "hahaha aku berjaya!";
$item->source = "";
$item->author = "";

//optional enclosure support
$item->enclosure = new EnclosureItem();


//Valid parameters are RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated),

//$rss->saveFeed("ATOM1.0", "news/feed.xml");


You can download the modified version of Feedcreator 1.7.2 from my server, the zip package contains the modified class library, GNU/LGPL license, some demo php file and a diff file against the plain vanilla Feedcreator 1.7.2 for curious people.

p/s : all of the modifications are written by me except outputFeed function which is written by Fabian Wolf.

Download :
Feedcreator 1.7.2-ppt (zip)

Feedcreator website :

PHP – Generate PDF on-the-fly with FPDF

Do you want to create PDF documents online for your commercial software? Now you can do it with FPDF class library. FPDF is a PHP class which allows to generate PDF files with pure PHP without depending on external library such as PDFlib.

What’s wrong with PDFlib? well for starters, PDFlib support need to be compiled in the php to make it work, secondly PDFlib isn’t free software meaning that you need to buy a separate license if you with to use PDFlib to generate pdf docs for your commercial apps and business. On the other hand, though not stated in a formal form, FPDF is freely distributable with or without modification and there are no restriction on the use of FPDF class library.

Of course being a pure PHP implementation, FPDF suffers from the lack speed of PDFlib, but the performance degradation won’t be noticeable unless you are planning to generate a large pdf files. FPDF library has been ported to other languages like Ruby, PHP and and C++ as there’s no restriction imposed on it.

Here’s a link to those who are interested to use FPDF in their projects :

Simple Affiliate software script

The past few days i’ve been searching for a simple and free affiliate script to integrate into my personal project.

The reason why i chose free (as in free beer) is because I dont have the budget to spend on expensive affiliate tracking software such as iDevAffiliate, ClixGalore and TradeDoubler.

The quest brought me to PostAffiliate, which is released as GNU/GPL and it was based on PHP-Affiliate v1.2. The PostAffiliate website claim that they fixed vulnerability in PHP-Affiliate, but upon using the software, i felt that PostAffiliate 1.3 has serious flaw in which the user password is stored as a plain-text in the database!

So i’ve taken my time to touch up PostAffiliate 1.3, mainly to fix the plaintext password storing method in PostAffiliate. The password is now hashed in SHA-1 before stored in the database. I’ve also fix some potential security vulnerability point and updated the login page (I plan to clean the code as it’s too messy).

Here’s my half-assed (actually 1 hour) modifications on PostAffiliate : PostAffiliate fix

Stay tune as i’m planning to rewrite most of the postaffiliate part and release the modification under GNU/GPL.

keyword : free affiliate php software script

SSH with PHP 4

Tengah merayau dengan surf internet lepas tu tetiba pulak terjumpa dengan web nie : Introduction to SSH through PHP. Apa yang disampaikan oleh web nie adalah, bagaimana untuk menghasilkan web application yang menggabungkan kefungsian SSH dan PHP4 (PHP 4.3.x)

OpenSSH Logo
PHP Logo

Artikel ini turut juga memberikan contoh-contoh aplikasi yang boleh dibangunkan dengan menggabungkan PHP dan SSH, sedikit aspek-aspek sekuriti (pembaca digalakkan buat homework) dan contoh implementasi script PHP untuk menggunakan SSH.

Di bahagian tengah artikel ini membincangkan cara-cara penyediaan sistem anda termasuk keperluan untuk menggunakan PHP dan SSH. Perbincangan turut meliputi ciri-ciri keselamatan minima SSH termasuk langkah-langkah untuk menghasilkan public-key authentication.

Bahagian akhir artikel ini membincangkan implementasi kelas PHP (PHP Class) untuk memudahkan pengaturcaraan web dilakukan dengan menggunakan SSH. Turut ditegaskan disini, penggunaan PHP Class akan meningkatkan tahap reusability pengaturcaraan web. Contoh yang dibincangkan di bahagian akhir artikel ini, memberikan sebuah skrip PHP mudah untuk mendapatkan proses-proses dalam GNU/Linux untuk dipaparkan di antaramuka web.

Kesimpulannya artikel ini telah sebuah idea inovatif penggunaan SSH dalam pengaturcaraan PHP dan secara tidak langsung membuka pintu untuk menghasilkan aplikasi web yang lebih kreatif pada masa hadapan.

Rujukan :
1. SSH with PHP 4
2. OpenSSH Project
3. PHP: Hypertext Preprocessor