<?php
/**
*
* DLE Malware Clean Script
* author: Gua
* site: http://guatalk.net/
*
*/
$mysql_host="XXXXX";// MySQL Host
$mysql_user="XXXXX";// MySQL User
$mysql_password="XXXXX"; // MySQL Password
$con = mysql_connect($mysql_host, $mysql_user, $mysql_password);
if (! $con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("XXXXXXXX", $con); // MySQL DB
$codepage ='cp1251'; // SET CODEPAGE
mysql_query('SET NAMES '.$codepage);
mysql_query('SET CHARACTER SET '.$codepage);
$result = mysql_query("SELECT * FROM `dle_post` WHERE (locate(lower('</script>'),lower(`short_story`))>0)")
or die("Could not query: " . mysql_error());
$count=0;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$post_id = $row["id"];
$short_story = $row["short_story"];
$full_story =$row["full_story"];
$short_story = mysql_real_escape_string(preg_replace("~<\s*\bscript\b[^>]*>(.*?)<\s*\/\s*script\s*>~is", "", $short_story));
$full_story = mysql_real_escape_string(preg_replace("~<\s*\bscript\b[^>]*>(.*?)<\s*\/\s*script\s*>~is", "", $full_story));
mysql_query("UPDATE `dle_post` SET `short_story` ='".$short_story."', `full_story` ='".$full_story."' WHERE `id` =".$post_id)
or die("Could not query: " . mysql_error());
$count++;
echo "Fixed id: ".$post_id."<br>";
}
echo 'Fixed <b>'.$count.'</b> posts';
mysql_close($con);
?>