In a previous article, I wrote about stripping EXIF meta data from jpeg image files to speed up downloads. We used ExifTool by Phil Harvey which runs from the unix command shell.
Well suppose you have thousands of jpeg files already on a webserver and you would like to strip the meta data from them. If you have a dedicated server, your webhosting provider may give you telnet or more likely ssl access to the server. But on shared servers, they normally won’t give you shell access. So what to do if you don’t have shell access to the server?
Well one possibility is write a PHP program that executes system commands or an external program. PHP has a few different ways to do this: shell_exec(), system(), exec() or putting the command between backticks. Just make sure that your PHP install is does not have safe-mode set to “1″. Also sometimes you webhost may disable some commands. I could get pwd to work on our server, but not ls or whoami. I tried the perl -v command to show the perl version and luckily perl scripts can be executed.
PHP and AJAX to the Rescue
I found a PHP AJAX Shell program called shell.php that provides limited shell access that allowed execution of a perl script. This is a very simple command shell. It can’t even change directories so it has to be in the directory that you execute from. Here is how I used it.
1. I created a bin directory under the home directory and uploaded the EXIFTool directory which is called Image-EXIFTool-7.78 into bin. Then I uploaded shell.php into Image-EXIFTool-7.78.
2. I opened up http://www.yourdomain.com/bin/Image-EXIFTool-7.78/shell.php and the PHP Shell appeared in the browser. I typed perl -v just to see if perl was working. I got back the version number. We’re in business!
3. To install EXIFTool I typed:
%perl Makefile.PL
%make test
4. Then I uploaded a copy of shell.php to the directory above all the image directories and opened a PHP-AJAX-SHELL in the browser. I typed in:
%perl ../../../bin/Image-ExifTool-7.78/exiftool -overwrite_original -all= *01/*.jpg
which stripped the metadata from thousands of files in no time flat. Now our gallery pages will serve faster.
Here is a link to the page with the href=”http://www.askapache.com/tools/php-and-ajax-shell-console.html” target=”_blank”>PHP Ajax Shell Console.










