Categories
PHP

Changing Font Style in PHP Generated Image

To change the font style, you need to use different fonts. You can use the imagettftext() function to draw text on a php generated image using GD. Here’s a code snippet:

Have a look at the function’s doc on php.net to learn more. http://www.php.net/imagettftext 🙂

It’s not that hard! Put the file in the www directory of a ubuntu LAMP server and visit the url on a web browser 🙂

Categories
Python

My First Gedit Plugin

I am now using Ubuntu 10.04. In an older post of mine, I described how you can use the PHP_Beautifier tool with Gedit to code php in a fashion. But the major drawback was that a shell output used to popup every time you used the external tool. I was looking for a solution and even after a while I could not find one.

I knew Gedit supports plugins and you could write plugins in C & Python. Blessed that I know some Python, I went through the plugin API and soon realized that gedit plugin development was not much hard. I took a sample snippet, scratched and played around and finally achieved what I wanted.

I named it “Shell Hider”. All it does is to disable the entire bottom panel so that the shell output don’t stay long. In fact, the shell window will popup for a second and then hide itself. On a fast machine, you probably won’t see the popup at all!

Download it from here: http://bit.ly/cQeTMx

Enjoy!

Categories
PHP

Text based Captcha with PHP

I needed text based captcha for my mobile web application to stop automated registrations. The mobile application was developed targeting the WAP devices without any fancy JS or iFrame support. So, I was forced to put some text based captcha. I set one up earlier which didn’t require any database but it was just an eye wash. If anyone examined the HTML source, s/he would know how to break it through.

This time I have come up with something better, something more effective. It is quite simple. Have a look at the source code and you’ll understand yourself.

The SQL for the Table:

The TextCaptcha Class :

You might notice that I haven’t used the “time” field. It will be used to delete unused captcha via cron or in some other way. Didn’t get the time to code that.

And how to use it:

Have fun! If you don’t get anything, please place a question below.