返回列表 回复 发帖

删除文件或文件夹的程序

  1. <style>
  2. input,body{font-family:verdana; font-size:12px; background-color:&#35;fcfcfc}
  3. </style>
  4. <?php
  5. function CleanDir(&#36;dir)
  6. {
  7.     &#36;handle=opendir(&#36;dir);
  8.     while ( &#36;file=readdir(&#36;handle) )
  9.     {
  10.         if ( (&#36;file==".") || (&#36;file=="..") ) continue;
  11.         if ( is_dir("&#36;dir/&#36;file") )
  12.         {
  13.             CleanDir("&#36;dir/&#36;file");
  14.             if ( rmdir("&#36;dir/&#36;file") )    echo "Remove dir "&#36;dir/&#36;file" successfully!<p>";
  15. else                echo "<FONT COLOR=RED>Fail to Remove dir "&#36;dir/&#36;file"!</FONT><P>";
  16.         }
  17.         else
  18.         {
  19.             if ( unlink("&#36;dir/&#36;file") ) echo "Del file "&#36;dir/&#36;file" successfully!<p>";
  20.             else         echo "<FONT COLOR=RED>Fail to del file "&#36;dir/&#36;file"!</FONT><P>";
  21.         }
  22.     }
  23.     closedir(&#36;handle);
  24. }
  25. if ( !IsSet(&#36;dirname) )
  26. {
  27.     echo "<form action=&#36;PHP_SELF method=post name=delform><center><font color=red>Folder or File</font> to be deled: <input name=dirname style="color:red"> password: <input type=password name=pass size=6> <input type=submit></center></form>";
  28.     echo " <SCRIPT> document.delform.dirname.focus() </SCRIPT> ";
  29. }
  30. else
  31. {
  32.     if (&#36;pass!="hg")        die("wrong password");
  33.     if ( is_file( &#36;dirname ) )
  34.     {
  35.     if ( unlink(&#36;dirname) )        echo "Del file "&#36;dirname" successfully!<p>";
  36. else                echo "<FONT COLOR=RED>Fail to del file "&#36;dirname"!</FONT><P>";
  37.     }
  38.     else
  39.     {
  40.     CleanDir(&#36;dirname);
  41.     if ( rmdir(&#36;dirname) )        echo "Remove dir "&#36;dirname" successfully!<p>";
  42.     else         echo "<FONT COLOR=RED>Fail to Remove dir "&#36;dirname"!</FONT><P>";
  43.     }
  44. }
  45. ?>
复制代码
哈哈哈!!!!你的IP是不是?我都知道了!!!
返回列表