Setting session timestamp limited to script scope in PHP

Lets start with analyzing a use case. Well at Saturn we required to run a cron
job which was written in php, with a lot of use for date functions, every day
starting Jan 1 2001 to Dec 31 2012. I did not dig much into override_function
to change the behavior of the date function, instead a small class was written
to handle the ticks, but the loop was run using a history table in mysql.

Continue reading “Setting session timestamp limited to script scope in PHP”

MsSQL Export to CSV

In the near past I got frustrated searching for a tool to export from MsSQL express to proper CSV. As always the frustration lead me to google, and found the post on stackoverflow and to digital point forums and a lot of other places. All these had some or the other issues with us. One being the MsSQL not hosted on our servers and we dont have access to the GUI tools, the second is that I am a bit towards the fag end when Microsoft Technologies are in the anvil. Finally there was no other way and what I did was to migrate our PHP MySQL wrapper to support MsSQL.

Continue reading “MsSQL Export to CSV”

Class DumpIO – Inspired by Apache mod_dumpio but reluctant to restart webserver

Though there are far and wide systems for live debugging, and the sort, for forensic or load analysis, our php-extjs framework did not have anything pre planned, other than some query loggers, and background processing systems to log into db etc. While recently the Master MySQL server started showing variations in the cacti patterns (normal was about 4 to 20 in working window, but was steady between 35 and 40 in the tantrum period), we started to worry and could not identify the situation. Also restarting all application servers and clearing the session store would immediately drop the MySQL fsync graph to a standard pattern. This is the time when I looked for a input logger for Apache, and found about the dumpio, but needed the webserver to be restarted. Actually the time was ripe that the application was in a tantrum, and the MySQL graphs showing about 35 fsyncs average.

Revisiting Importance of event logging in server side scripting and other articles on the net, the out come was a class with a single static method. This was designed to pick and log any input. This was later moved as the lite version, and a full version capable of capturing the output also was built.
Continue reading “Class DumpIO – Inspired by Apache mod_dumpio but reluctant to restart webserver”

PHP Sessions in Memcache – Locking Issues

Actually it is ages since I sat down to scribble something. Well this one could not be avoided. Hence here it is.

In one of our FTE projects, we had faced a complication that Memcached on one node was using 100% cpu and php-cgi was complainging that the same node was not permitting any more memcached connections. The configuration was as what all says, session.save_handler = memcache, session.save_path = “tcp://:11211,tcp://:11211,tcp://:11211″. It was giving jitters to the night support, that this used to happen at the worse time when most of the clients are using the application. And eventually that memcached needed to be restarted, kicking all users out and every one has to login back from the login page. Now during the past weeks it was so horrible that we marked a portion of the ramdisk from one least loaded nodes and used nfs to export this to all the nodes for a file based sessions store.
Continue reading “PHP Sessions in Memcache – Locking Issues”

MariaFramework 0.22 released

The MariaFramework or phpmf has been released with a couple of new enhancements. The MariaFramework portal is updated with some new plugins for phpmf. Will dive into what the details of the plugins are in another post. For the time the enhancements of the all new MariaFramework.
Continue reading “MariaFramework 0.22 released”

php smtp email direct to mail box delivery

For sending status mails, with varying from addresses, for several of our projects at Saturn, we were using the phpmailer which uses our smtp server with authentication. Well our smtp host had a limitation of 250 emails per day. When our requirements grew out of this limit, mails started to pile up. Sure I could install exim4 or sendmail on my boxes, and that is what I did for immediate resolution. But here comes a new requirement, that the mails sent should be marked as such, and those which failed should be marked with the exact response of the receiving end mailserver.

At this point I thought about an SMTP direct to mail box Delivery system. My favorite language being PHP, and primary library being Google, I tried all possible ways, according to me, and they were not the right ones as I came to know later. All these did not get me in the right direction. And finally thought about writing one. Here too, being lazy, wanted to have the code from some ones work to ignite me. Okay I found the phpbb’s smtp.php referred on the net, and the function smtpmail from the same was the right choice.
Continue reading “php smtp email direct to mail box delivery”

A Mathematical Captcha – Reinventing the Wheel

I had seen numeric computational captcha or Mathematical captcha where one has to calculate the answer of an equation with simple arithmetic and supply the result for verification.

For a long time I have been using the image captcha with random characters, and got fed up. I had seen numeric computational captcha or Mathematical captcha where one has to calculate the answer of an equation with simple arithmetic and supply the result for verification. Last night I was pondering over this while watching a movie on the TV. Well the out come is obvious.
Continue reading “A Mathematical Captcha – Reinventing the Wheel”

Getting datetime type into JavaScript as Date object

When selecting datetime to be displayed in a JavaScript ui library, select the unix_timestamp * 1000 from the sql

This is not any new thing and may be discussed at different other places. But just as I came across like any other things, I just wanted to make a record of this.

When selecting datetime to be displayed in a JavaScript ui library, select the unix_timestamp * 1000 from the sql.
Continue reading “Getting datetime type into JavaScript as Date object”