Файл: str_scanner.php
Строк: 97
<?php
ob_start();
session_start();
define('PASS', 'rostik12345');
define('DR', $_SERVER['DOCUMENT_ROOT']);
if ($_SESSION['auth_ss'] !== true)
{
if (isset($_POST['ok_pass']))
{
if ($_POST['pass'] == PASS)
{
$_SESSION['auth_ss'] = true;
}
header('location:?');
exit;
}
echo '<form method="post">'."n";
echo '<div><input type="text" name="pass"></div>'."n";
echo '<div><input type="submit" name="ok_pass" value="Вход"></div>'."n";
echo '</form>'."n";
exit;
}
echo '<form method="post">'."n";
echo '<div><input type="text" name="search"></div>'."n";
echo '<div><input type="submit" name="ok" value="Поиск"></div>'."n";
echo '</form>'."n";
function scanFolder($dir)
{
global $Result, $Search;
if ($handle = opendir($dir))
{
while (false !== ($entry = readdir($handle)))
{
if ($entry != '.' && $entry != '..')
{
$Put = $dir.'/'.$entry;
if (is_dir($Put))
{
scanFolder($Put);
}
else
{
$pathinfo = pathinfo($Put);
if ($pathinfo['extension'] == 'php' && $entry != basename($_SERVER['SCRIPT_FILENAME']))
{
$cfa = explode("n", file_get_contents($Put));
foreach ($cfa as $line => $contentFile)
{
$count = substr_count($contentFile, $Search);
if ($count > 0)
{
$Result[$Search][] = array('file' => str_replace(DR, '', $Put), 'line' => ($line + 1), 'text' => $contentFile);
}
}
}
}
}
}
closedir($handle);
}
}
if (isset($_POST['ok']))
{
$Search = $_POST['search'];
scanFolder(DR);
$arD = array(
'<?php </span><span style="color: #007700">(</span><span style="color: #0000BB">axw3</span><span style="color: #007700">) ',
' (</span><span style="color: #0000BB">axw3</span><span style="color: #007700">) </span><span style="color: #0000BB">?></span>',
' </span><span style="color: #007700">(</span><span style="color: #0000BB">axw3</span><span style="color: #007700">) </span><span style="color: #0000BB">?></span>',
' (axw3) </span><span style="color: #0000BB">?></span>',
' (axw3) ?>'
);
if (empty($Result))
{
echo '<div>Вхождений не найдено.</div>'."n";
}
else
{
foreach ($Result as $key => $value)
{
echo '<div><h2>'.$key.'</h2></div>'."n";
foreach ($Result[$key] as $key2 => $value2)
{
echo '<div style="white-space:nowrap;">'.$value2['file'].' <b>'.$value2['line'].'</b> - '.str_replace($arD, '', highlight_string('<?php (axw3) '.trim($value2['text']).' (axw3) ?>', true)).'</div>'."n";
}
}
}
}
?>