Archive for October, 2006

Rent A Coder – Resume Page Ratings to RSS

October 30th, 2006 No comments

Myself is more or less active at RAC, and wanted to show off my buyers comments in a page for promoting me. And wrote this script rac2rss. Download from here.

The main script is rac2rss.php, change the line [php] $coder_id = “1242159”; [/php], in rac2rss.php to get your resume. [php] $myFileMgr = new fileMgr(‘./cache’,7 * 24 * 60 * 60); [/php] defines the cache, and the cache folder should be world / webserver writable, and it can be outside web path for security reasons, only that the absolute or relative path should be provided, as well the lifetime is in seconds, actually in the said script I have put it as a week.

As a last note, thanks to all members and maintainers of RAC, for making it a wonderful place for all of us.

Categories: Code Snippets, PHP, Uncategorized Tags:

Moving contents from one folder to another

October 25th, 2006 No comments

We always try to store images in a web path where heavy image linking is needed, and mostly the images will be categorised in some sort of directory tree.. to limit the no of files in a folder.

Once editing, for example, re assinging a set of students from one scientist to another, was needed, and the hell, we had to face.. finally the following piece of code was written, for a future reuse.

function mkdir_r($dirName$rights=0777){
$dirs explode('/'$dirName);
        foreach (
$dirs as $part) {
        if (!
is_dir($dir) && strlen($dir)>0)
xMove($source$target$drop true){
is_dir($source)) return false;
is_dir($target)) mkdir_r($target);
$d dir($source);
        while (
false !== ($entry $d->read())) {
copy($source "/$entry"$target "/$entry");
unlink($source "/$entry");

If any body is wondering (just a thought) how I have managed the colour highlighting, then better take a look at Phpizer Plugin

php wrapper for zapatec tree widget

October 25th, 2006 2 comments

To quote the zapatec site ” The Zapatec DHTML Tree is an easy, attractive, and versatile way to display information. You can use the DHTML tree as a menu, a site map, or a way to display your data. Our DHTML Tree works in many different browsers, but if visitors use older browsers, they will still be able to see and use the underlying HTML code. ”

I did find this very good, and in the sense that it provides a method for the Search Engines to see all the links. Recently in an administrative backend, I needed to provide a method to browse multilevel deep category subcategory, where they add new products, to their existing line, for which I did choose the lite version of zapatec suite.

The generation of nested ul/li tags for the tree was a real pain for me, from the existing database. And I thought about a wrapper which could do the job if provided with an array of data rows. Hence I made the class-tree.php. The included file is having an implementation sample which will need the lite version from zapatec site.

The sample implementation with the help of zapatec could generate a tree as shown from the code attached below.

tree screen shot


The Data

To start with the implementation, we create an instance of the zptree after including the class-tree.php, and passing the path of zapatec js files.

create instance

Then initiate the tree data using $catTree->treeData = array(); Then go along selecting the data from mysql using the select statement select category_id as id,category_name,parent_category_id from category order by parent_category_id, inside a while loop, the tree data is added to the member array, while($rd = $db->fetch_array($rs)) $catTree->treeData[] = $rd;

The attached class-tree.php also has an example implementation at the end, which should be removed before using in production.

Please excuse me about the sloppy documentation, since I am no good at explaining things.