Using mysql_grep.php to grep tables

I’ve created a new piece of code that allows people to grep through their database tables and fields. I regularily work on databases with more than 50 tables in the database. Each table has anywhere from two to twenty fields in them. To make things even more of a pain in the ass sometimes the fields are mispelled or do not match up.

As a result I created mysql_grep.php. You can download it from my newly created source directory. Check back often for more code/utilities created by me. Below is an example use of mysql_grep.php

jstump@zebulon:~$ php -q bin/mysql_grep.php -d joestump_net -e photo

The following fields match "photo"
  +-> photos_favorites
      +-> photoID
  +-> photos_images
      +-> photoID

The following tables match "photo"
  +-> photos_albums
  +-> photos_favorites
  +-> photos_images

The code does not support connecting to hosts other than localhost nor does it support changing sockets/ports. Furthermore, the code requires PEAR’s DB. And, finally, the expressions are passed directly to PHP’s ereg(). This means you should be able to pass "^[A-Z]" as an expression (remember to quote your complex expressions).

Checking Server Status – Easily

I’m currently working on a simple backup script and I wanted to make sure my backup server was up before I sent stuff from my laptop over to the backup server (which is housed here locally on a nice software RAID setup). It’s nothing ground breaking, but I couldn’t find a simple utility to simply ping a server, timeout gracefully and return a valid exit code. So, being the geek I am I made one.


  $timeout = 5;
  if (!isset($argv[1])) {
      die("Usage: php -q server_status ipaddress:port [timeout]n");
  } else {
      list($server,$port) = explode(':',$argv[1]);
      if (isset($argv[2]) && is_numeric($argv[2])) {
          $timeout = $argv[2];

  $fp = @fsockopen($server,$port,$errno,$errstr,$timeout);
  if (!$fp) {
  } else {


Introducing PublishTron3000

When I worked at we had a really cool web frontend to RCS that the developers and designers used instead of FTP for file management. It was cool for a number of reasons.

  • RCS – It used RCS for version control of all files uploaded through the interface. A must have when you fsck up a file and need to revert to an older version.
  • File locking – PublishTron300 (PT3K) allows users to lock files while they are aditing them. Only the user who owns the lock can work on that file while it is locked.
  • Publishing – PT3K allows users to publish their files to a “live” site after they have verified the file is working on the developmental site.

Those are the main features of PT3K. It has quite a few others that makes managing websites with multiple developers a lot easier. The site isn’t up yet, but you will be able to download the source and learn more about it at

A little history. PT3K was originally developed in house at, where I worked from May of 2000 until September of 2002. released the source GPL sometime in the summer of 2001. It was at this time I started using PT3K privately and at places I consulted. Now that I started Jerum it seemed like a good idea to use PT3K for file management, thus version 2.0.0 was born.

PHPTalk 0.9 Released!

It took me a while, but I finally got off my ass and worked on PHPTalk. There are some major updates/upgrades in this version. I have ported PHPTalk to PEAR, included better support for i18n, fixed many minor bugs, and cleaned up a lot of the code. You can find out more about PHPTalk here.