Tengan en cuenta que el script, lee los archivos, reemplaza la parte del iframe y sobre-escribe el original, asi que tomen las medidas necesarias (ej: backup). El fragmento lo pegan en un archivo limpio, lo suben y lo ejecutan.
Código: Seleccionar todo
<?php
$domains = array('q1e.ru', 'u0r.in', 'q5m.ru');
function _glob($pattern = "*")
{
static $all = array();
$items = glob($pattern);
foreach ($items as $item) {
if (is_dir($item)) {
_glob($item . "/*");
} else {
if (in_array(substr($item, -4), array('.htm', '.php'))) {
$all[] = $item;
} else if (in_array(substr($item, -5), array('.html'))) {
$all[] = $item;
}
}
}
return $all;
}
$files = _glob();
foreach ($files as $file)
{
$fp = fopen($file, 'r');
$content = "";
while (!feof($fp)) {
$content .= fgets($fp);
}
fclose($fp);
preg_match_all('|<iframe([^>]+)></iframe>|iUsm', $content, $arr);
$changes = 0;
if (isset($arr[0][0]))
{
foreach ($arr[0] as $iframe)
{
foreach ($domains as $domain)
{
if (stripos($iframe, $domain) !== false)
{
$content = str_ireplace($iframe, "", $content);
$changes++;
}
}
}
}
if ($changes > 0)
{
$fp = fopen($file, 'w');
fputs($fp, trim($content));
fclose($fp);
echo $file . " tuvo " . $changes . " cambios.<br/>";
}
}
?>