function cachefile($dir) { global $check, $cklog; $fp = opendir($dir); while ($filename = readdir($fp)) { $path = $dir . $filename; if ($filename != '.' && $filename != '..') { if (is_dir($path)) { cachefile($path . '/'); } elseif (preg_match('/(\\.php|\\.php3|\\.htm)$/i', $filename) && filesize($path) < 1048576) { $a = strtolower(readover($path)); if (strpos($a, 'shell_exec') !== false || strpos($a, 'gzencode') !== false) { $check[$path] = 1; $cklog[1]++; } elseif (strpos($a, 'eval(') !== false || strpos($a, 'move_uploaded_file($') !== false || strpos($a, 'copy($') !== false || strpos($a, 'chr(') !== false || strpos($a, 'fopen(') !== false || strpos($a, 'writeover(') !== false) { $check[$path] = 2; $cklog[2]++; } elseif (preg_match("/\\<iframe(.+?)\\<\\/iframe\\>/is", $a)) { $check[$path] = 3; $cklog[3]++; } } } } closedir($fp); }
// записываем в файл текст fwrite($fp, $text); // закрываем fclose($fp); } //проверяем наличие файла в кеше if (file_exists($file)) { //проверяем дату создания if (filemtime($file) > time() - 3600 * 24 * $cachetime) { //обновлять кэш время не пришло //выводим закэшированный файл redirect(); } else { //если кэш истек //получаем файл $text = file_get_contents($url); if ($text) { //если удалось получить файл, кэшируем и выводим cachefile($text); redirect(); } else { //если не удалось, то выводим кэшированный redirect(); } } } $text = file_get_contents($url); if ($text) { cachefile($text); } redirect();