Skip to content

My PHP , Wordpress and Linux Lab

Archive

December, 2007Archive for

PHP Code Cleaner and Indenter

Dec 19
Posted by : Sabeen Malik in PHP

Online Code Cleaner Demo

With six years of experience with PHP , I have been ‘blessed’ with working with code written by really lazy people , who just didn’t think it was important at all to indent their code or comment it or make the opening and ending curly braces align.

And sometimes our favorite FTP clients would add God knows why those silly annoying empty lines and the code would keep getting bigger and bigger.

And I am sure that I am not alone in my frustrations.

That is why is am writing this script which will try to take care of all that.

Basically it will try to achieve the following goals:

  • Indent your code with tabs.
  • Put a comment block at the start of class definitions or functions.
  • Provide you with the facility to align curly brackets.
  • Remove unwanted lines from the code.
  • Put some spacing in blocks for improved readability.
  • Replaces short open tags with proper <?php tags
  • If a PHP block contains only one line , it will put the whole block in one line to improve readability.

Please provide your valuable feedback to improve this script. I will be soon releasing a full script which will clean the code in all PHP files in a directory. Stay tuned!

Online Code Cleaner Demo

Web based FTP Sync Tool written in PHP

Dec 4
Posted by : Sabeen Malik in Linux, Misc, MySQL, PHP

FTP Sync Jobs ScreenFTP Sync 0.9

PURPOSE:
To upload files which have changed to your production server , automating the task of comparing which files have changed. You simply create a FTP job
in the script , run the job and it will upload the changed files for you.

REQUIREMENTS:
FTP functions are required for this script to work.
PHP 4 Or 5
MySQL 4+

INSTALL:
Open dbinc.php and put in the database connection variables in there. Once done run installer.php from your browser and you are all set to go.
Its advised to remove installer.php once you have finished installation.

SECURITY:
It if advised that the admin creates users and allocates jobs to them. Also the admin should block access to the database and script files
from general staff.

INFO:
We made this script for our internal use , thought it might be useful for some of you out there. It was a tiring job to find which files needed to be uploaded
to the main server after development on local server. Thus i created this script , where you can create jobs and upload folders and files which were changed.

The decision to upload happens on 3 rules:

1 : you can provide time and date in the job page , files which were created after that time will be uploaded.

2 : you can ask the script to match the time against the server file , the script would calculate the time offset and calculate if the file has
changed since last upload.

3 : The script also keeps a log , if the file changed after last upload , it will upload the file.

You can exclude the files you dont want to upload, for instance you wont want to upload and overwrite config.php or something like that. So you
can create the skip list. The skip list is the path of the file from the source directory you have provided.

For instance if you have a source directory called “/www/something/upload/” , and you dont want to upload the file “/www/something/upload/config.php”
or the folder “/www/something/upload/users/images” then you would put in something like this:

config.php
users/images

Remember no trailing slash for folders.

You need to have writable permissions for the logs folder , also if you want to utlize the copy permissions feature you will need the BcMath library
compiled with PHP.

The admin can run any job , but if you want to have users which can run specific jobs only please utilize the users section , in which a user can
run all jobs or only specific jobs.

Same goes for the jobs , you can set an attribute to allow all users to run the job.

This code has been tested on PHP 5 and PHP 4.4.

You are free to modify the code as you please. The code is released in the public domain under the GPL license.

Enjoy!

WP Admin Switcher Plugin Updated

Dec 4
Posted by : Sabeen Malik in Wordpress

WP Admin Switcher has been updated , please download the latest zip from the link on the right. This version has been tested on WP 2.3.1 If you are getting a file not found error , than it means you dont have the .htaccess rules set for mod_rewrite. WP Admin Switcher wont work without this.

Thanks to all the users sending in feedback to make this plugin better.

Soon i will be updating the plugin to handle blogs with no mod_rewrite (permalinks) .

Keep checking!