PHP ini issues for scripts running in CLI or executing shell_exec() in *nix

Did you try to run php from command line and faced with php exception like safe mood is on, memory limit exceeded, maximum execution time exceeded etc. A general solution is to edit the php.ini and made those changes and restart apache server. At least i found these solutions online 🙂

But that is not gonna solve your problem. when you are running CLI or shell_exec in *nix environment, php uses a different php.ini file located inside CLI folder. until you edit that the problem wont be solved. So if you are constantly getting errors after altering your php.ini file used by your web server then you should try your CLIs’ php.ini file for any issues regarding cron/CLI.

Running CodeIgniter from Cron/CLI

Many of us faced the problem of running CodeIgniter controllers from Cron or from Command Line. usually we write the following codes to run a php file from cron/CLI.

php /var/www/path/to/your/script

but if we give CodeIgniter Controller path here it will not work since CodeIgniter will fail to initialize its core classes. A work around of this is running the script using CURL

curl http://yourwebsite/controllername

the problem with the above command is that it takes too much CPU resources .

Today my collegue Hasan showed me a nice way of doing it, just write the following codes in a php file in your root folder. here is the way to go

$_GET[“/external/do_cron”] = null;
require “index.php”;

note: here “external” is the controller name and “do_cron” is the function name that you want to execute.

now save this file to any name you want (eg. mycron.php) and run the script using

php /var/www/path/to/script

[here it is php /var/www/mywebsite/mycron.php]

if the above code does not work, you can try the following one. (thanks to sucio)

$_SERVER[“REQUEST_URI”] =”external/do_cron”;
require “index.php”;

Mediawiki Image Gallery Extension – WikiGallery

I was working with MediaWiki Gallery extension named “Smooth Gallery” which is based on JonDesign’s SmoothGallery . It was almost the thing i was looking for but not the exact one for my purpose. As a result I had to hack the code and modify it to fit my needs. You can download the extension and install it for your purpose. I have named it as WikiGallery as lots of things has been changed in this extension. This extension supports external images as well and hence give you more options to create a nice gallery.

A very special thanks to Ryan Lane & Jon

Details of the extension is given below:






Requirements: Mediawiki 1.9.0  and above [ I have not tested with earlier versions. ]


  1. Download the wikigallery files from here.
  2. unzip it to your extensions directory
  3. download wikigallery extension file from here
  4. unzip it and drop it into your extensions directory
  5. make sure $wgUseImageResize is enabled in your LocalSettings.php file
  6. add the following lines to your LocalSettings.php file and save

$wgWikiGalleryExtensionPath = “/mediawiki/extensions/wikigallery”;
$wgWikiGalleryDelimiter = “n”;

Now the extension is ready and we can use it to our wiki pages. Edit a wiki page and add the following tag with image names delimited by the wikigallery delimiter as mentioned on LocalSettings.php file (in this case its n , but it can be , # etc). For local files (uploaded in the wiki), we do not have to put anything. but for external images the http:// must be there.


Now save and check your page , you will see the gallery is there.


  •     I will try to keep the code updated with smooth gallery. But can not promise that.
  •     If you have any download issue, please inform me with your email address. I will send you the scripts in email.

Why to use Stored Procedure or Prepared Statement?

In web development, we do face the issue of running a query few thousands to million times everyday. If your website traffic is small then the impact of such queries is not noticed. but if your site attracts lots of users and the query requires to run a good number of time, it might hurt your database performance. every query we run goes through a rigorous cycle to produce the desire result. it goes from parsing, optimizing, executing and returning the result. once a query is written and ran correctly for the first time then the steps of parsing and optimization is not necessarily requires as it is already been parsed and optimized. for the same query it is kind of redundant efforts going on. but what if we can just execute the query and get the result and bypass few of the early steps? well it’s possible and that is where the concept of Stored Procedure and Prepared statements come from. now let’s look at the detail of it

 Prepared statement:

Prepared statements are the ability to set up a statement once, and then execute it many times with different parameters. They are designed to replace building ad hoc query strings, and do so in a more secure and efficient manner. A typical prepared statement would look something like:

The ? is what is a called a placeholder. When you execute the above query, you would need to supply the value for it, which would replace the ? in the query above.


as from Harrison Fisk article on prepared statement

Prepared statements can help increase security by separating SQL logic from the data being supplied. This separation of logic and data can help prevent a very common type of vulnerability called an SQL injection attack. Normally when you are dealing with an ad hoc query, you need to be very careful when handling the data that you received from the user. This entails using functions that escape all of the necessary trouble characters, such as the single quote, double quote, and backslash characters. This is unnecessary when dealing with prepared statements. The separation of the data allows MySQL to automatically take into account these characters and they do not need to be escaped using any special function.

The increase in performance in prepared statements can come from a few different features. First is the need to only parse the query a single time. When you initially prepare the statement, MySQL will parse the statement to check the syntax and set up the query to be run. Then if you execute the query many times, it will no longer have that overhead. This pre-parsing can lead to a speed increase if you need to run the same query many times, such as when doing many INSERT statements.

following image will illustrate the fact


Stored procedure:
A stored procedure is a precompiled executable object that contains one or more SQL statements. Hence you can replace your complex SQL statements with a single stored procedure. Since, stored procedures are precompiled objects they execute faster at the database server. For the consecutive run it will run from the compiled stage and hence boost performance.

Note: You have to choose the when to use to use what. certainly not every query should be transformed to prepared statement  or stored procedures.  🙂

New initiatives for Bangla Language on Web

I am thinking of introducing new Bangla based services for the web. here are few of my ideas which will go development phase very soon

1. bangla spell checker

2. bangla wysiwyg editor (probably tinymce)

3. bangla translation

4. bangla unicode pdf

5. bangla universal writing panel with keyboard support (from somewhereinblog write panel)

if you have some cool idea, you can share with me and also you can participate in any of the projects above if you want to.

WordPress Plugins Development

I had started writing my new book for Packt Publishing titled “WordPress Plugins Development”. But I decided to take the back step as I was very busy with my projects at office and couldn’t manage good amount of time for the book. I believe in quality rather than quantity. So, as i am getting bit free time now, I want to finish the book with a modified outline and publish it online. So that people can review and give me necessary feedback to make it a good one. May be later I will try to publish it but i want to focus on the writings for right now.

Every 2/3 weeks a new chapter will be uploaded online with all the codes and graphics so that user can read and apply the things they will learn. I hope to upload the first chapter in the first week of April.

Certified Scrum Master

Recently I have completed my Certified Scrum Master training from Pete Deemer of Good Agile ( I have attended the 14 hour training program along with my colleague N.H.M Tanveer Hossain Khan on 5th March, 2008 in New Delhi, India. It’s been a nice experience for us and we believe it will be very helpful for us to implement a good scrum oriented development all over the organization. Thanks to Arild for this opportunity and We hope to deliver the expected result to him.

Me and Hasan is also trying to organize a Scrum Master Training in Bangladesh for the first time in this year. So anybody interested to attend the course can drop me a line.


Mediawiki tutorials coming soon…

Currently I am working with Mediawiki version 1.11 and lots of things have changed and new things emerged during last 1 year. So i feel that my book “Mediawiki administrator’s tutorial guide” requires some additional writings as well. From April 2008, i will be writing new tutorials every week on Mediawiki including some hacks, extensions and template design.

I hope it will be helpful for all Mediawiki users and administrators 🙂