error_reporting E_ALL dir files_in_dir array function openfilesdir dir

 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
52
53
54
55
error_reporting (E_ALL);
$dir= '.';
$files_in_dir=array();
function openfilesdir($dir='.'){
global $files_in_dir;
$scandir=scandir($dir);
foreach ($scandir as $num_file => $name_file)
{
if($name_file=='.' or $name_file=='..') continue;
if($dir=='.') $add_name=""; else $add_name="$dir/";
if(is_file($add_name.$name_file)){
$ext=explode('.',$add_name.$name_file); $ext=$ext[count($ext)-1];
$scriptFileName=explode('/', $_SERVER['PHP_SELF']); $scriptFileName=$scriptFileName[count($scriptFileName)-1];
if($ext=='gif' or $ext=='zip' or $ext=='rar' or $ext=='jpg' or $ext=='jpeg' or $ext=='png' or $name_file==$scriptFileName) continue;
$files_in_dir[]=$add_name.$name_file;
}
elseif(is_dir($add_name.$name_file)) filesdir($add_name.$name_file);
}
}
openfilesdir($dir);
foreach ($files_in_dir as $num_file => $name_file)
{
$file=file($name_file);
$found=false;
foreach ($file as $line_num => $line_text)
{
$keyword = array('.$_', '. $_', ', $_', '"$_', "'\$_", ',$_', 'eval(', 'exec(', 'proc_open(', 'system(');
foreach ($keyword as $key){
if (strpos($line_text, $key) !== false) {
$found=true;
$num_line[]=$line_num+1;
$text_num_line[]=trim($line_text);}
}
}
if($found==true)
{
echo '<div class="copyright"><b>Файл => /'.$name_file.'</b>:</div>';
$count=count($num_line);
for($i=0;$i<=$count-1;$i++)
{
echo '<div class="content">Строка '.$num_line[$i].': '.highlight_string('<? '.$text_num_line[$i].' ?>', 1).'</div>';
}
$num_line='';
}
}