| 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. | <?php
//If open basedir is on, search the closest directory possible, otherwise search "/"
//this will take a very long time to complete
//define('path', ini_get('open_basedir') ? ini_get('open_basedir') : DIRECTORY_SEPARATOR);
//One directory before the current directory:
define('path', '..');
//Maximum number of directories to find (to save time)
//define('maxdirs', 10);
set_time_limit(0);
$writable = array();
function finddir($d = path){
global $writable;
if(defined('maxdirs')){
if(count(array_unique($writable)) >= maxdirs){
printout();
}
}
$tmp = array();
if($x = scandir($d)){
foreach($x as $y){
if(@is_dir($d . DIRECTORY_SEPARATOR . $y)){
if($y != ".." && $y != "."){
array_push($tmp, $y);
$real = $d . DIRECTORY_SEPARATOR . $y;
}
}
foreach($tmp as $t){
if(@is_writable($d . DIRECTORY_SEPARATOR . $t)){
array_push($writable, $d . DIRECTORY_SEPARATOR . $t);
}
finddir($real);
}
}
}
}
function printout(){
global $writable;
?><p><b>Writable directories:</b></p>
<textarea rows=<?php echo(count(array_unique($writable))); ?> cols=50><?php
echo(($writable ? implode("\n", array_unique($writable)) : "No writable directories found.") . "\n</textarea>");
die();
}
finddir();
printout();
?> |