As discussed somewhat at length in a rapidly-devolving thread on the PHP General mailing list, I am in favor of a function that, when called, will initiate on the host system a self-destruct sequence. Well, being a nice, sunny, spring Friday morning, I decided to offer just that:
Introducing the first public release of the System Detonation Library for PHP.
This useless extension provides one function with one purpose: to cause your server to explode. Due to the obvious hazards involved, including (but not limited to) loss of hardware, limbs, and potentially life and liberty, this has only been tested on one single occasion, using a PC with Ubuntu 10.10 and a heavily-modified SVN version of PHP 5.3.6. Thankfully, as the test was successful, there were no serious injuries.
Firstly, you may download the package here.
Second, as a very basic course on the compilation and installation of this unofficial PHP extension, here are some simple instructions for Linux users. All others are on their own, and this may (read: probably) will not work anyway…. which is a shame, because I know plenty of Windows boxes that should have the right to self-destruct as well.
- Download the package above.
- Extract it: tar -zxf detonate-0.2.tar.gz
- Change to the newly-created directory where the files are located: cd detonate-0.2/
- Build the wrappers for your version of the Zend/PHP API: phpize (NOTE: on Ubuntu-built packages, this command may be: phpize5)
- Build the necessary makefiles for your system: ./configure –with-detonate
- Compile the code: make
- Install the binary (as root, or using sudo): make install
- Edit your php.ini to load the newly-installed extension by adding this line: extension=detonate.so
- If you plan to use it via the CLI, you’re done. For use on the web, remember to reload/restart your web server.
- Create a basic PHP script with the following: <?php detonate(); ?>
- Check your insurance coverage.
- Run the script created in Step #10.
And that’s all there is to it. Feel free to install this on all of your systems and use it as a replacement for exit or die() in your scripts. Because, unlike die(), this function will absolutely get the point across, once and for all.