PluginProbe ʕ •ᴥ•ʔ
Anti-Malware Security and Brute-Force Firewall / 4.23.73
Anti-Malware Security and Brute-Force Firewall v4.23.73
4.23.90 trunk 1.2.03.23 1.3.02.15 3.07.06 4.14.47 4.15.16 4.16.17 4.17.28 4.17.29 4.17.44 4.17.57 4.17.58 4.17.68 4.17.69 4.18.52 4.18.62 4.18.63 4.18.69 4.18.71 4.18.74 4.18.76 4.19.44 4.19.50 4.19.68 4.19.69 4.20.59 4.20.72 4.20.92 4.20.93 4.20.94 4.20.95 4.20.96 4.21.74 4.21.83 4.21.84 4.21.85 4.21.86 4.21.87 4.21.88 4.21.89 4.21.90 4.21.91 4.21.92 4.21.93 4.21.94 4.21.95 4.21.96 4.23.56 4.23.57 4.23.67 4.23.68 4.23.69 4.23.71 4.23.73 4.23.77 4.23.81 4.23.83 4.23.85 4.23.87 4.23.88 4.23.89
gotmls / images / index.php
gotmls / images Last commit date
.htaccess 11 years ago ELI-16x16.gif 14 years ago GOTMLS-16x16.gif 12 years ago GOTMLS-Loading.gif 1 year ago blocked.gif 14 years ago btn_donateCC_WIDE.gif 13 years ago checked.gif 14 years ago index.php 1 year ago question.gif 13 years ago threat.gif 13 years ago wait.gif 14 years ago
index.php
1997 lines
1 <?php
2 /**
3 * GOTMLS Plugin Global Variables and Functions
4 * @package GOTMLS
5 * @since 4.23.73
6 */
7
8 define("GOTMLS_plugin_path", dirname(dirname(__FILE__))."/");
9
10 if (!function_exists("__")) {
11 function __($text, $domain = "gotmls") {
12 return $text;
13 }}
14
15 require_once(GOTMLS_plugin_path."safe-load/trace.php");
16
17 GOTMLS_define("GOTMLS_local_images_path", substr(__FILE__, 0, strlen(__FILE__) - strlen(basename(__FILE__))));
18 GOTMLS_define("GOTMLS_Failed_to_list_LANGUAGE", __("Failed to list files in directory!",'gotmls'));
19 GOTMLS_define("GOTMLS_Run_Quick_Scan_LANGUAGE", __("Quick Scan",'gotmls'));
20 GOTMLS_define("GOTMLS_View_Quarantine_LANGUAGE", __("View Quarantine",'gotmls'));
21 GOTMLS_define("GOTMLS_View_Scan_Log_LANGUAGE", __("View Scan History",'gotmls'));
22 GOTMLS_define("GOTMLS_require_version_LANGUAGE", sprintf(__("This Plugin requires WordPress version %s or higher",'gotmls'), GOTMLS_require_version));
23 GOTMLS_define("GOTMLS_Scan_Settings_LANGUAGE", __("Scan Settings",'gotmls'));
24 GOTMLS_define("GOTMLS_Loading_LANGUAGE", __("Loading, Please Wait ...",'gotmls'));
25 GOTMLS_define("GOTMLS_Automatically_Fix_LANGUAGE", __("Automatically Fix SELECTED Files Now",'gotmls'));
26 GOTMLS_define("GOTMLS_position_msg", __("Default position",'gotmls'));
27
28 if (!defined("ABSPATH")) {
29 define("ABSPATH", dirname(dirname(__FILE__)).'/safe-load/');
30 $root_path = dirname(ABSPATH);
31 while (strlen($root_path) > 1 && !is_file($root_path."/wp-config.php"))
32 $root_path = dirname($root_path);
33 if (is_file($root_path."/wp-config.php"))
34 include_once($root_path."/wp-config.php");
35 else
36 die("No wp-config!");
37 }
38
39 $bad = array("eval", "preg_replace", "auth_pass");
40 $GLOBALS["GOTMLS"] = array(
41 "MT" => microtime(true),
42 "tmp"=>array("debug_fix"=>"", "HeadersError"=>"", "onLoad"=>"", "file_contents"=>"", "new_contents"=>"", "threats_found"=>array(),
43 "base_page" => "GOTMLS-settings",
44 "pluginTitle" => "Anti-Malware",
45 "default_encodings" => array('UTF-8', 'ISO-8859-1', 'windows-1252'),
46 "skip_dirs" => array(".", ".."), "scanfiles" => array(), "nonce"=>array(),
47 "mt" => ((isset($_REQUEST["mt"])&&strlen($_REQUEST["mt"])==32)?$_REQUEST["mt"]:md5(microtime(true))),
48 "threat_files" => array("htaccess"=>".htaccess","timthumb"=>"thumb.php"),
49 "threat_levels" => array(__("Database Injections",'gotmls')=>"db_scan",__("htaccess Threats",'gotmls')=>"htaccess",__("TimThumb Exploits",'gotmls')=>"timthumb",__("Known Threats",'gotmls')=>"known",__("Core File Changes",'gotmls')=>"wp_core",__("Potential Threats",'gotmls')=>"potential"),
50 "apache" => array(),
51 "skip_ext"=>array("png", "jpg", "jpeg", "gif", "bmp", "tif", "tiff", "psd", "svg", "webp", "doc", "docx", "otf", "ttf", "fla", "flv", "mov", "mp3", "pdf", "css", "pot", "po", "mo", "so", "exe", "zip", "7z", "gz", "rar"),
52 "execution_time" => 60,
53 "default" => array("msg_position" => array("80px", "40px", "400px", "600px")),
54 "Definition" => array("Default" => "CCIGG"),
55 "definitions_array" => array(
56 "potential" => array(
57 $bad[0] => array("CCIGG", "/[^a-z_\\/'\"]".$bad[0]."\\(.+\\)+\\s*;/i"),
58 $bad[1]." /e" => array("CCIGG", "/".$bad[1]."[\\s*\\(]+(['\"])([\\!\\/\\#\\|\\@\\%\\^\\*\\~]).+?\\2[imsx]*e[imsx]*\\1\\s*,[^,]+,[^\\)]+[\\);\\s]+/i"),
59 $bad[2] => array("CCIGG", "/\\\$".$bad[2]."\\s*=.+;/i"),
60 "function add_action wp_enqueue_script json2" => array("CCIGG", "/json2\\.min\\.js/i"),
61 "Tagged Code" => array("CCIGG", "/\\#(\\w+)\\#.+?\\#\\/\\1\\#/is"),
62 "protected by copyright" => array("CCIGG", "/\\/\\* This file is protected by copyright law and provided under license. Reverse engineering of this file is strictly prohibited. \\*\\//i")
63 )
64 )
65 )
66 );
67 if (isset($_SERVER["HTTP_HOST"]))
68 $SERVER_HTTP = 'HOST://'.GOTMLS_safe_domain($_SERVER["HTTP_HOST"]);
69 elseif (isset($_SERVER["SERVER_NAME"]))
70 $SERVER_HTTP = 'NAME://'.GOTMLS_safe_domain($_SERVER["SERVER_NAME"]);
71 elseif (isset($_SERVER["SERVER_ADDR"]))
72 $SERVER_HTTP = 'ADDR://'.GOTMLS_safe_ip($_SERVER["SERVER_ADDR"]);
73 else
74 $SERVER_HTTP = "NULL://not.anything.com";
75 if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"])
76 $SERVER_HTTP .= ":".GOTMLS_safe_ip($_SERVER["SERVER_PORT"]);
77 $SERVER_parts = explode(":", $SERVER_HTTP.":");
78 if ((isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on" || $_SERVER["HTTPS"] == 1)) || (count($SERVER_parts) > 2 && $SERVER_parts[2] == "443"))
79 $GLOBALS["GOTMLS"]["tmp"]["protocol"] = "https:";
80 else
81 $GLOBALS["GOTMLS"]["tmp"]["protocol"] = "http:";
82 GOTMLS_define("GOTMLS_script_URI", preg_replace('/\&(last_)?mt=[0-9\.a-f]+/i', '', str_replace('&amp;', '&', GOTMLS_htmlspecialchars($_SERVER["REQUEST_URI"], ENT_QUOTES))).'&mt='.$GLOBALS["GOTMLS"]["tmp"]["mt"]);
83 GOTMLS_define("GOTMLS_plugin_home", "https://gotmls.net/");
84 if (function_exists("plugins_url"))
85 GOTMLS_define("GOTMLS_images_path", plugins_url('/', __FILE__));
86 elseif (function_exists("plugin_dir_url"))
87 GOTMLS_define("GOTMLS_images_path", plugin_dir_url(__FILE__));
88 elseif (isset($_SERVER["DOCUMENT_ROOT"]) && ($_SERVER["DOCUMENT_ROOT"]) && strlen($_SERVER["DOCUMENT_ROOT"]) < __FILE__ && substr(__FILE__, 0, strlen($_SERVER["DOCUMENT_ROOT"])) == $_SERVER["DOCUMENT_ROOT"])
89 GOTMLS_define("GOTMLS_images_path", substr(dirname(__FILE__), strlen($_SERVER["DOCUMENT_ROOT"])).'/');
90 elseif (isset($_SERVER["SCRIPT_FILENAME"]) && isset($_SERVER["DOCUMENT_ROOT"]) && ($_SERVER["DOCUMENT_ROOT"]) && strlen($_SERVER["DOCUMENT_ROOT"]) < strlen($_SERVER["SCRIPT_FILENAME"]) && substr($_SERVER["SCRIPT_FILENAME"], 0, strlen($_SERVER["DOCUMENT_ROOT"])) == $_SERVER["DOCUMENT_ROOT"])
91 GOTMLS_define("GOTMLS_images_path", substr(GOTMLS_safe_url(dirname($_SERVER["SCRIPT_FILENAME"])), strlen($_SERVER["DOCUMENT_ROOT"])).'/');
92 else
93 GOTMLS_define("GOTMLS_images_path", "/wp-content/plugins/gotmls/images/");
94
95 function GOTMLS_user_can() {
96 if (is_multisite())
97 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"] = "manage_network";
98 elseif (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"]) || $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"] == "manage_network")
99 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"] = "activate_plugins";
100 if (current_user_can($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"]))
101 return true;
102 else
103 return false;
104 }
105
106 function GOTMLS_update_option($index, $value = array(), $auto = true) {
107 return update_option('GOTMLS_'.$index.'_blob', GOTMLS_encode(serialize($value)), $auto);
108 }
109
110 function GOTMLS_get_option($index, $value = array()) {
111 if (is_array($tmp = get_option('GOTMLS_'.$index.'_array', array())) && count($tmp)) {
112 GOTMLS_update_option($index, $tmp);
113 delete_option('GOTMLS_'.$index.'_array');
114 } else
115 $tmp = $value;
116 return GOTMLS_uckserialize(GOTMLS_decode(get_option('GOTMLS_'.$index.'_blob', GOTMLS_encode(serialize($tmp)))));
117 }
118
119 $GLOBALS["GOTMLS"]["tmp"]["nonce"] = GOTMLS_get_option('nonce', array());
120 $GLOBALS["GOTMLS"]["tmp"]["settings_array"] = get_option('GOTMLS_settings_array', array());
121 $GLOBALS["GOTMLS"]["tmp"]["definitions_array"] = GOTMLS_get_option('definitions', $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]);
122 GOTMLS_define("GOTMLS_siteurl", rtrim(get_option("siteurl", $GLOBALS["GOTMLS"]["tmp"]["protocol"].$SERVER_parts[1].((count($SERVER_parts) > 2 && ($SERVER_parts[2] == '80' || $SERVER_parts[2] == '443'))?"":":".$SERVER_parts[2])."/"), '\\/'));
123 GOTMLS_load_scanlog($GLOBALS["GOTMLS"]["tmp"]["mt"]);
124 if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"]))
125 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"] = $GLOBALS["GOTMLS"]["tmp"]["threat_levels"];
126 if (!(isset($GLOBALS["GOTMLS"]["scan"]["log"]["settings"]) && is_array($GLOBALS["GOTMLS"]["scan"]["log"]["settings"])))
127 $GLOBALS["GOTMLS"]["scan"]["log"]["settings"] = $GLOBALS["GOTMLS"]["tmp"]["settings_array"];
128 GOTMLS_define("GOTMLS_installation_key", md5(GOTMLS_siteurl));
129 GOTMLS_define("GOTMLS_update_home", "//updates.gotmls.net/".GOTMLS_installation_key."/");
130
131 function GOTMLS_get_corefile_URL($path, $hash) {
132 if (strpos($URL = GOTMLS_get_version("URL"), '&cp='))
133 //$hash != md5($contents)."O".strlen($contents)
134 return 'http:'.GOTMLS_update_home.'cp_core.php?'.$URL.'&f='.GOTMLS_encode($path)."&h=$hash&ts=".gmdate("YmdHis").'&d='.rawurlencode(GOTMLS_siteurl);
135 else
136 return "http://core.svn.wordpress.org/tags/".GOTMLS_wp_version."$path";
137 }
138
139 function GOTMLS_Invalid_Nonce($pre = "//Error: ") {
140 return sprintf(__("%s Invalid or expired Nonce Token! %s Refresh and try again?",'gotmls'), $pre, (isset($_REQUEST["GOTMLS_mt"])?(" (".GOTMLS_htmlspecialchars($_REQUEST["GOTMLS_mt"]).((strlen($_REQUEST["GOTMLS_mt"]) == 32)?(isset($GLOBALS["GOTMLS"]["tmp"]["nonce"][$_REQUEST["GOTMLS_mt"]]["hour"])&&isset($GLOBALS["GOTMLS"]["tmp"]["nonce"][$_REQUEST["GOTMLS_mt"]]["user"])?(substr($pre, 0, 7)=="//DEBUG"?GOTMLS_htmlspecialchars(", U:".$GLOBALS["GOTMLS"]["tmp"]["nonce"][$_REQUEST["GOTMLS_mt"]]["user"].", H:".$GLOBALS["GOTMLS"]["tmp"]["nonce"][$_REQUEST["GOTMLS_mt"]]["hour"]."!) "):" !UH!) "):" !found!) "):" !len[".strlen($_REQUEST["GOTMLS_mt"])."]!) ")):" (GOTMLS_mt !set!) "));
141 }
142
143 function GOTMLS_set_nonce($context = "NULL", $uid = 0) {
144 $hour = (int) round(round($GLOBALS["GOTMLS"]["MT"]/60)/60);
145 if (!$uid)
146 $uid = GOTMLS_get_current_user_id(GOTMLS_REMOTEADDR);
147 $transient_name = md5(substr(number_format(microtime(true), 9, '-', '/'), 6).GOTMLS_installation_key.GOTMLS_plugin_path.$context.$uid);
148 if (isset($GLOBALS["GOTMLS"]["tmp"]["nonce"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["nonce"])) {
149 foreach ($GLOBALS["GOTMLS"]["tmp"]["nonce"] as $nonce_key => $token) {
150 if ((!(is_array($token) && isset($token["hour"]) && is_numeric($token["hour"]))) || (($token["hour"] > $hour) || (($token["hour"] + 24) < $hour)))
151 unset($GLOBALS["GOTMLS"]["tmp"]["nonce"][$nonce_key]);
152 elseif (is_array($token) && isset($token["hour"]) && isset($token["user"]) && isset($token["context"]) && ($token["hour"] == $hour) && ($token["user"] == $uid) && ($token["context"] == $context))
153 $transient_name = $nonce_key;
154 }
155 }
156 if (!isset($GLOBALS["GOTMLS"]["tmp"]["nonce"][$transient_name])) {
157 $GLOBALS["GOTMLS"]["tmp"]["nonce"][$transient_name] = array("hour" => $hour, "user" => $uid, "context" => $context);
158 if (!GOTMLS_update_option('nonce', $GLOBALS["GOTMLS"]["tmp"]["nonce"], false))
159 return (GOTMLS_sanitize($context)."=DB-err:".rawurlencode(preg_replace('/[\r\n]+/', " ", print_r($GLOBALS["GOTMLS"]["tmp"]["nonce"],1).$wpdb->last_error)));
160 }
161 return 'GOTMLS_mt='.rawurlencode($transient_name);
162 }
163
164 function GOTMLS_get_nonce($context = "", $uid = 0) {
165 $return = false;
166 if (isset($_REQUEST["GOTMLS_mt"])) {
167 if (!$uid)
168 $uid = GOTMLS_get_current_user_id(GOTMLS_REMOTEADDR);
169 if (isset($_POST["GOTMLS_mt"]) && (strlen($_POST["GOTMLS_mt"]) == 32) && isset($GLOBALS["GOTMLS"]["tmp"]["nonce"][$_POST["GOTMLS_mt"]]))
170 $token = $GLOBALS["GOTMLS"]["tmp"]["nonce"][$_POST["GOTMLS_mt"]];
171 elseif (isset($_GET["GOTMLS_mt"]) && (strlen($_GET["GOTMLS_mt"]) == 32) && isset($GLOBALS["GOTMLS"]["tmp"]["nonce"][$_GET["GOTMLS_mt"]]))
172 $token = $GLOBALS["GOTMLS"]["tmp"]["nonce"][$_GET["GOTMLS_mt"]];
173 if (isset($token) && is_array($token) && isset($token["hour"]) && isset($token["user"]) && isset($token["context"])) {
174 if (strlen($context) && ($context != $token["context"]))
175 $return = null;
176 elseif ($uid == $token["user"] || (is_numeric($uid) && !is_numeric(GOTMLS_REMOTEADDR) && (GOTMLS_REMOTEADDR == $token["user"])))
177 $return = (INT) $token["hour"];
178 else
179 $return = 0;
180 } else
181 $return = "";
182 }
183 return $return;
184 }
185
186 function GOTMLS_fileperms($file) {
187 if ($prm = @fileperms($file)) {
188 if (($prm & 0xC000) == 0xC000)
189 $ret = "s";
190 elseif (($prm & 0xA000) == 0xA000)
191 $ret = "l";
192 elseif (($prm & 0x8000) == 0x8000)
193 $ret = "-";
194 elseif (($prm & 0x6000) == 0x6000)
195 $ret = "b";
196 elseif (($prm & 0x4000) == 0x4000)
197 $ret = "d";
198 elseif (($prm & 0x2000) == 0x2000)
199 $ret = "c";
200 elseif (($prm & 0x1000) == 0x1000)
201 $ret = "p";
202 else
203 $ret = "u";
204 $ret .= (($prm & 0x0100)?"r":"-").(($prm & 0x0080)?"w":"-");
205 $ret .= (($prm & 0x0040)?(($prm & 0x0800)?"s":"x" ):(($prm & 0x0800)?"S":"-"));
206 $ret .= (($prm & 0x0020)?"r":"-").(($prm & 0x0010)?"w":"-");
207 $ret .= (($prm & 0x0008)?(($prm & 0x0400)?"s":"x" ):(($prm & 0x0400)?"S":"-"));
208 $ret .= (($prm & 0x0004)?"r":"-").(($prm & 0x0002)?"w":"-");
209 $ret .= (($prm & 0x0001)?(($prm & 0x0200)?"t":"x" ):(($prm & 0x0200)?"T":"-"));
210 return $ret;
211 } else
212 return "stat failed!";
213 }
214
215 function GOTMLS_file_details($file) {
216 return '<div id="file_details_'.md5($file).'" class="shadowed-box rounded-corners" style="display: none; position: absolute; left: 8px; top: 29px; background-color: #ccc; border: medium solid #C00; box-shadow: -3px 3px 3px #666; border-radius: 10px; padding: 10px;"><b>File Details: '.GOTMLS_htmlspecialchars(basename($file)).'</b><br />in: '.dirname(realpath($file)).'<br />size: '.filesize(realpath($file)).' ( '.ceil(strlen(GOTMLS_htmlspecialchars($GLOBALS["GOTMLS"]["tmp"]["file_contents"]))/1024).' KB )<br />encoding: '.(isset($GLOBALS["GOTMLS"]["tmp"]["encoding"])?$GLOBALS["GOTMLS"]["tmp"]["encoding"]:(function_exists("mb_detect_encoding")?mb_detect_encoding($GLOBALS["GOTMLS"]["tmp"]["file_contents"]):"Unknown")).'<br />permissions: '.GOTMLS_fileperms(realpath($file)).'<br />Owner/Group: '.fileowner(realpath($file)).'/'.filegroup(realpath($file)).(function_exists("getmyuid")&&function_exists("getmygid")?' (you are: '.getmyuid().'/'.getmygid():'(getmyuid does not exist').')<br />modified:'.gmdate(" Y-m-d H:i:s ", filemtime(realpath($file))).'<br />changed:'.gmdate(" Y-m-d H:i:s ", filectime(realpath($file))).'</div>';
217 }
218
219 function GOTMLS_esc_url($url) {
220 if ("" === trim($url))
221 return "";
222 $original_url = $url;
223 $url = str_replace(' ', '%20', ltrim($url));
224 $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url);
225 $url = wp_kses_normalize_entities($url);
226 $url = str_replace('&amp;', '&#038;', $url);
227 $url = str_replace("'", '&#039;', $url);
228 if ((false !== strpos($url, '[')) || (false !== strpos($url, ']'))) {
229 $end_dirty = preg_replace('/^([fhtps]+\:)?\/\/([^\@]+\@)*[^\/]++/i', '', $url);
230 $end_clean = str_replace(array('[', ']'), array('%5B', '%5D'), $end_dirty);
231 $url = str_replace($end_dirty, $end_clean, $url);
232 }
233 return $url;
234 }
235
236 function GOTMLS_admin_url($action, $url = '') {
237 $return = admin_url("admin-ajax.php?action=$action");
238 foreach (array('eli', 'oversize', 'GOTMLS_debug') as $pass_on)
239 if (isset($_GET["$pass_on"]))
240 $return .= "&$pass_on=".GOTMLS_esc_url($_GET["$pass_on"]);
241 return ("$return&$url");
242 }
243
244 function GOTMLS_dashicon_button($title, $dashicon = "editor-help", $style = 'text-decoration: none;', $contents = "", $href = "javascript:void(0);") {
245 $gt = ">"; // This local variable never changes
246 $lt = "<"; // This local variable never changes
247 return $lt.'a href="'.$href.'" title="'.$title.'" style="'.$style.'"'.$gt.$lt."span class='dashicons dashicons-$dashicon'$gt$lt/span$gt $contents$lt/a$gt\n";
248 }
249
250 function GOTMLS_close_button($box_id, $margin = '6px', $title = "Close") {
251 return GOTMLS_dashicon_button($title, 'dismiss', "float: right; color: #F00; overflow: hidden; width: 20px; height: 20px; text-decoration: none; margin: $margin", "X", 'javascript:void(0);" onclick="showhide(\''.$box_id.'\');');
252 }
253
254 function GOTMLS_get_styles($pre_style = "") {
255 $head_nonce = GOTMLS_set_nonce(__FUNCTION__."255");
256 $gt = ">"; // This local variable never changes
257 $lt = "<"; // This local variable never changes
258 if (!strlen(trim("$pre_style")))
259 $pre_style = $lt."style$gt";
260 return $pre_style.'
261 span.GOTMLS_date {float: right; width: 130px; white-space: nowrap;}
262 .GOTMLS_page {float: left; border-radius: 10px; padding: 0 5px;}
263 .GOTMLS_quarantine_item {margin: 4px 12px;}
264 .rounded-corners {margin: 10px; border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border: 1px solid #000;}
265 .shadowed-box {box-shadow: -3px 3px 3px #666; -moz-box-shadow: -3px 3px 3px #666; -webkit-box-shadow: -3px 3px 3px #666;}
266 .sidebar-box {background-color: #CCC;}
267 iframe {border: 0;}
268 .GOTMLS-scanlog li a {display: none;}
269 .GOTMLS-scanlog li:hover a {display: block;}
270 .GOTMLS-sidebar-links {list-style: none;}
271 .GOTMLS-sidebar-links li img {margin: 3px; height: 16px; vertical-align: middle;}
272 .GOTMLS-sidebar-links li {margin-bottom: 0 !important;}
273 .popup-box {background-color: #FFC; display: none; position: absolute; left: 0px; z-index: 10;}
274 .shadowed-text {text-shadow: #00F -1px 1px 1px;}
275 .sub-option {float: left; margin: 3px 5px;}
276 .inside {margin: 10px; position: relative;}
277 .GOTMLS_li, .GOTMLS_plugin li {list-style: none;}
278 .GOTMLS_plugin {margin: 5px; background: #cfc; border: 1px solid #0C0; padding: 0 5px; border-radius: 3px;}
279 .GOTMLS_plugin.known, .GOTMLS_plugin.db_scan, .GOTMLS_plugin.htaccess, .GOTMLS_plugin.timthumb, .GOTMLS_plugin.errors {background: #f99; border: 1px solid #f00;}
280 .GOTMLS_plugin.potential, .GOTMLS_plugin.wp_core, .GOTMLS_plugin.skipdirs, .GOTMLS_plugin.skipped {background: #ffc; border: 1px solid #fc6;}
281 .GOTMLS ul li {margin-left: 12px;}
282 .GOTMLS h2 {margin: 0 0 10px;}
283 .postbox {margin-right: 10px; line-height: 1.4; font-size: 13px;}
284 #pastDonations li {list-style: none;}
285 #quarantine_buttons {margin: 0px; padding: 0px;}
286 #quarantine_buttons input.button-primary {margin-right: 20px;}
287 #reclean_buttons {
288 color: #a00;
289 min-height: 32px;
290 border-top: solid 2px black;
291 padding-top: 10px;
292 }
293 #reclean_buttons input.button-primary {float: right;}
294 #delete_button {
295 background-color: #C33;
296 color: #FFF;
297 background-image: linear-gradient(to bottom, #C22, #933);
298 border-color: #933 #933 #900;
299 box-shadow: 0 1px 0 rgba(230, 120, 120, 0.5) inset;
300 text-decoration: none; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
301 margin-top: 10px;
302 }
303 #main-page-title {
304 background: url("https://secure.gravatar.com/avatar/5feb789dd3a292d563fea3b885f786d6?s=64") no-repeat scroll 0 0 transparent;
305 height: 64px;
306 line-height: 58px;
307 margin: 10px 0 0 0;
308 max-width: 600px;
309 padding: 0 110px 0 84px;
310 }
311 #main-page-title h1 {
312 background: url("https://secure.gravatar.com/avatar/8151cac22b3fc543d099241fd573d176?s=64") no-repeat scroll top right transparent;
313 height: 64px;
314 line-height: 32px;
315 margin: 0;
316 padding: 0 84px 0 0;
317 display: table-cell;
318 text-align: center;
319 vertical-align: middle;
320 }
321 '."$lt/style$gt\n$lt".'div id="div_file" class="shadowed-box rounded-corners sidebar-box" style="padding: 0; display: none; position: fixed; top: '.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][1].'; left: '.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][0].'; width: '.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][3].'; height: '.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][2].'; border: solid #c00; z-index: 112358;"'.$gt.$lt.'table style="width: 100%; height: 100%;" cellspacing="0" cellpadding="0"'.$gt.$lt.'tr'.$gt.$lt.'td style="border-bottom: 1px solid #EEE; height: 32px;" colspan="2"'.$gt.GOTMLS_close_button("div_file").$lt.'h3 onmousedown="grabDiv();" onmouseup="releaseDiv();" id="windowTitle" style="cursor: move; border-bottom: 0px none; z-index: 2345677; position: absolute; left: 0px; top: 0px; margin: 0px; padding: 6px; width: 90%; height: 20px;"'.$gt.GOTMLS_Loading_LANGUAGE."$lt/h3$gt$lt/td$gt$lt/tr$gt$lt".'tr'.$gt.$lt.'td colspan="2" style="height: 100%"'.$gt.$lt.'div style="width: 100%; height: 100%; position: relative; padding: 0; margin: 0; background-color: #fff;" class="inside"'.$gt.$lt.'center'.$gt.$lt.'img src="'.GOTMLS_images_path.'GOTMLS-Loading.gif" id="got-loading-gif" style="max-height: 280px;" alt="..."'.$gt.$lt.'br /'.$gt.GOTMLS_Loading_LANGUAGE.$lt.'br /'.$gt.$lt.'div id="gotmls_too_long" style="display: none;"'.$gt.__("If this is taking too long:",'gotmls').$lt.'br /'.$gt.$lt.'input type="button" onclick="showhide(\'div_file\');if (formx = document.getElementById(\'GOTMLS_Form_clean\')) formx.method = \'get\';" value="'.__("Go Back and Try Again",'gotmls').'" style="margin: 0 5px;" class="button-primary" /'.$gt.'or'.$lt.'input type="button" onclick="showhide(\'GOTMLS_iFrame\', true);" value="'.__("Show the Unloaded Page",'gotmls').'" style="margin: 0 5px;" class="button-primary" /'."$gt$lt/div$gt$lt/center$gt$lt".'iframe id="GOTMLS_iFrame" name="GOTMLS_iFrame" style="top: 0px; left: 0px; position: absolute; width: 100%; height: 100%; background-color: #CCC;"'."$gt$lt/iframe$gt$lt/td$gt$lt/tr$gt$lt".'tr'.$gt.$lt.'td style="height: 20px;"'.$gt.$lt.'iframe id="GOTMLS_statusFrame" name="GOTMLS_statusFrame" style="width: 100%; height: 20px; background-color: #CCC;"'."$gt$lt/iframe$gt$lt/div$gt$lt/td$gt$lt".'td style="height: 20px; width: 20px;"'.$gt.$lt.'h3 id="cornerGrab" onmousedown="grabCorner();" onmouseup="releaseCorner();" style="cursor: move; height: 24px; width: 24px; margin: 0; padding: 0; z-index: 2345678; overflow: hidden; position: absolute; right: 0px; bottom: 0px;"'.$gt.$lt.'span class="dashicons dashicons-editor-expand"'."$gt$lt/span$gt&#8690;$lt/h3$gt$lt/td$gt$lt/tr$gt$lt/table$gt$lt/div$gt\n$lt".'script type="text/javascript"'.$gt.'
322 function showhide(id) {
323 divx = document.getElementById(id);
324 if (divx) {
325 if (divx.style.display == "none" || arguments[1]) {
326 divx.style.display = "block";
327 divx.parentNode.className = (divx.parentNode.className+"close").replace(/close/gi,"");
328 return true;
329 } else {
330 divx.style.display = "none";
331 return false;
332 }
333 }
334 }
335 function checkAllFiles(check) {
336 var checkboxes = new Array();
337 checkboxes = document["GOTMLS_Form_clean"].getElementsByTagName("input");
338 for (var i=0; i<checkboxes.length; i++)
339 if (checkboxes[i].type == "checkbox" && (checkboxes[i].id.substring(0, 6) == "check_" || checkboxes[i].id.substring(0, 24) == "GOTMLS_quarantine_check_"))
340 checkboxes[i].checked = check;
341 }
342 function setvalAllFiles(val) {
343 var checkboxes = document.getElementById("GOTMLS_fixing");
344 if (checkboxes)
345 checkboxes.value = val;
346 }
347 function getWindowWidth(min) {
348 if (typeof window.innerWidth != "undefined" && window.innerWidth > min)
349 min = window.innerWidth;
350 else if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != "undefined" && document.documentElement.clientWidth > min)
351 min = document.documentElement.clientWidth;
352 else if (typeof document.getElementsByTagName("body")[0].clientWidth != "undefined" && document.getElementsByTagName("body")[0].clientWidth > min)
353 min = document.getElementsByTagName("body")[0].clientWidth;
354 return min;
355 }
356 function getWindowHeight(min) {
357 if (typeof window.innerHeight != "undefined" && window.innerHeight > min)
358 min = window.innerHeight;
359 else if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientHeight != "undefined" && document.documentElement.clientHeight > min)
360 min = document.documentElement.clientHeight;
361 else if (typeof document.getElementsByTagName("body")[0].clientHeight != "undefined" && document.getElementsByTagName("body")[0].clientHeight > min)
362 min = document.getElementsByTagName("body")[0].clientHeight;
363 return min;
364 }
365 function loadIframe(title) {
366 showhide("gotmls_too_long", true);
367 showhide("gotmls_too_long");
368 showhide("GOTMLS_iFrame", true);
369 showhide("GOTMLS_iFrame");
370 document.getElementById("windowTitle").innerHTML = title;
371 if (curDiv) {
372 windowW = getWindowWidth(200);
373 windowH = getWindowHeight(200);
374 if (windowW > 200)
375 windowW -= 30;
376 if (windowH > 200)
377 windowH -= 20;
378 if (px2num(curDiv.style.width) > windowW) {
379 curDiv.style.width = windowW + "px";
380 curDiv.style.left = "0px";
381 } else if ((px2num(curDiv.style.left) + px2num(curDiv.style.width)) > windowW) {
382 curDiv.style.left = (windowW - px2num(curDiv.style.width)) + "px";
383 }
384 if (px2num(curDiv.style.height) > windowH) {
385 curDiv.style.height = windowH + "px";
386 curDiv.style.top = "0px";
387 } else if ((px2num(curDiv.style.top) + px2num(curDiv.style.height)) > windowH) {
388 curDiv.style.top = (windowH - px2num(curDiv.style.height)) + "px";
389 }
390 if (px2num(curDiv.style.left) < 0)
391 curDiv.style.left = "0px";
392 if (px2num(curDiv.style.top)< 0)
393 curDiv.style.top = "0px";
394 }
395 showhide("div_file", true);
396 if (IE)
397 curDiv.scrollIntoView(true);
398 setTimeout(function (){ showhide(\'gotmls_too_long\', true); }, 15000);
399 }
400 function cancelserver(divid) {
401 document.getElementById(divid).innerHTML = "'.$lt."div class='error'$gt".GOTMLS_strip4java(__("No response from server!",'gotmls'))."$lt/div$gt".'";
402 }
403 var stopCheckingDefinitions = 0;
404 function checkPrimaryUpdateServer() {
405 var updatescript = document.createElement("script");
406 if (arguments[0])
407 updatescript.setAttribute("src", pri_addr+arguments[0]);
408 else
409 updatescript.setAttribute("src", pri_addr);
410 if (divx = document.getElementById("Definition_Updates"))
411 divx.appendChild(updatescript);
412 return setTimeout(function() {stopCheckingDefinitions = checkAlternateUpdateServer();}, 15000);
413 }
414 function checkAlternateUpdateServer() {
415 var updatescript = document.createElement("script");
416 if (arguments[0])
417 updatescript.setAttribute("src", alt_addr+arguments[0]);
418 else
419 updatescript.setAttribute("src", alt_addr);
420 if (divx = document.getElementById("Definition_Updates"))
421 divx.appendChild(updatescript);
422 return setTimeout(function() {stopCheckingDefinitions = cancelserver("Definition_Updates");}, 15000);
423 }
424 function checkupdateserver(server) {
425 var updatescript = document.createElement("script");
426 updatescript.setAttribute("src", server);
427 if (divx = document.getElementById("GOTMLS_patch_searching"))
428 divx.appendChild(updatescript);
429 return setTimeout(function() {cancelserver("GOTMLS_patch_searching");}, '.(((INT) $GLOBALS["GOTMLS"]["tmp"]['execution_time'])+1).'000+3000);
430 }
431 var IE = document.all?true:false;
432 //if (!IE) document.addEventListener("mousemove", getMouseXY);
433 document.onmousemove = getMouseXY;
434 var offsetX = 0;
435 var offsetY = 0;
436 var offsetW = 0;
437 var offsetH = 0;
438 var curX = 0;
439 var curY = 0;
440 var curDiv, loadingGif;
441 function getMouseXY(e) {
442 if (IE) { // grab the mouse pos if browser is IE
443 curX = event.clientX + document.body.scrollLeft;
444 curY = event.clientY + document.body.scrollTop;
445 } else { // grab the mouse pos if browser is Not IE
446 curX = e.pageX - document.body.scrollLeft;
447 curY = e.pageY - document.body.scrollTop;
448 }
449 if (curX < 0) {curX = 0;}
450 if (curY < 0) {curY = 0;}
451 if (offsetX && curX > 10) {curDiv.style.left = (curX - offsetX)+"px";}
452 if (offsetY && (curY - offsetY) > 0) {curDiv.style.top = (curY - offsetY)+"px";}
453 if (offsetW && (curX - offsetW) > 360) {curDiv.style.width = (curX - offsetW)+"px";}
454 if (offsetH && (curY - offsetH) > 200) {
455 curDiv.style.height = (curY - offsetH)+"px";
456 loadingGif.style.height = (curY - offsetH - 130)+"px";
457 }
458 return true;
459 }
460 function px2num(px) {
461 return parseInt(px.substring(0, px.length - 2), 10);
462 }
463 function setDiv(DivID) {
464 if (curDiv = document.getElementById(DivID)) {
465 if (IE)
466 curDiv.style.position = "absolute";
467 curDiv.style.left = "'.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][0].'";
468 curDiv.style.top = "'.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][1].'";
469 curDiv.style.height = "'.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][2].'";
470 curDiv.style.width = "'.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][3].'";
471 }
472 if (loadingGif = document.getElementById("got-loading-gif"))
473 loadingGif.style.height = "'.(substr($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][2], 0, -2) - 130).'px";
474 }
475 function grabDiv() {
476 corner = document.getElementById("windowTitle");
477 if (corner) {
478 corner.style.width="100%";
479 corner.style.height="100%";
480 }
481 offsetX=curX-px2num(curDiv.style.left);
482 offsetY=curY-px2num(curDiv.style.top);
483 }
484 function releaseDiv() {
485 corner = document.getElementById("windowTitle");
486 if (corner) {
487 corner.style.width="90%";
488 corner.style.height="20px";
489 }
490 document.getElementById("GOTMLS_statusFrame").src = "'.GOTMLS_admin_url('GOTMLS_position', ($GOTMLS_position_nonce = GOTMLS_set_nonce(GOTMLS_position_msg)).'&GOTMLS_x=').'"+curDiv.style.left+"&GOTMLS_y="+curDiv.style.top;
491 offsetX=0;
492 offsetY=0;
493 }
494 function grabCorner() {
495 corner = document.getElementById("cornerGrab");
496 if (corner) {
497 corner.style.width="100%";
498 corner.style.height="100%";
499 }
500 offsetW=curX-px2num(curDiv.style.width);
501 offsetH=curY-px2num(curDiv.style.height);
502 }
503 function releaseCorner() {
504 corner = document.getElementById("cornerGrab");
505 if (corner) {
506 corner.style.width="20px";
507 corner.style.height="20px";
508 }
509 document.getElementById("GOTMLS_statusFrame").src = "'.GOTMLS_admin_url('GOTMLS_position', $GOTMLS_position_nonce.'&GOTMLS_w=').'"+curDiv.style.width+"&GOTMLS_h="+curDiv.style.height;
510 offsetW=0;
511 offsetH=0;
512 }
513 function check_for_donation(chk) {
514 if ((audl = document.getElementById("autoUpdateDownload")) && audl.src.replace(/^.+\?/,"")=="0")
515 if (chk.substr(0, 8) != "Changed " || chk.substr(8, 1) != "0")
516 chk += "\\n\\n'.__("Please make a donation for the use of this wonderful feature!",'gotmls').'";
517 alert(chk);
518 }
519 setDiv("div_file");'."\n$lt/script$gt\n";
520 }
521
522 function GOTMLS_get_header($optional_box = "") {
523 $gt = ">"; // This local variable never changes
524 $lt = "<"; // This local variable never changes
525 if (isset($_GET["check_site"]) && $_GET["check_site"])
526 $pre_style = $lt.'div id="check_site" style="z-index: 1234567;"'.$gt.$lt.'img src="'.GOTMLS_images_path.'checked.gif" height=16 width=16 alt="&#x2714;"'.$gt.__("Tested your site. It appears we didn't break anything",'gotmls')." ;-)$lt/div$gt$lt".'script type="text/javascript"'.$gt.'if (csw = window.parent.document.getElementById("check_site_warning")) csw.style.backgroundColor=\'#0C0\';window.addEventListener(\'load\', (event) => {showhide(\'inside_ddd6dbd641b9a5909fe4d44da2017cc7\');});'."$lt/script$gt{$lt}li$gt Please $lt".'a target="_blank" href="https://wordpress.org/support/plugin/gotmls/reviews/#wporg-footer"'.$gt.'write a "Five-Star" Review'."$lt/a$gt".' on WordPress.org if you like this plugin.'."$lt/li$gt$lt".'style'.$gt.'#footer, #GOTMLS-metabox-container, #GOTMLS-right-sidebar, #admin-page-container, #wpadminbar, #adminmenuback, #adminmenuwrap, #adminmenu, .error, .updated, .notice, .update-nag {display: none !important;} #wpbody-content {padding-bottom: 0;} #wpbody, html.wp-toolbar {padding-top: 0 !important;} #wpcontent, #footer {margin-left: 5px !important;}';
527 else
528 $pre_style = $lt.'style'.$gt.'#GOTMLS-right-sidebar {float: right; margin-right: 0px;}';
529 return GOTMLS_get_styles($pre_style).$lt.'div id="main-page-title"'.$gt.$lt.'h1 style="vertical-align: middle;"'.$gt.'Anti-Malware from&nbsp;GOTMLS.NET'."$lt/h1$gt$lt/div$gt";
530 }
531
532 function GOTMLS_object_to_array($obj) {
533 if (is_object($obj))
534 $obj = (array) $obj;
535 $new = array();
536 if (is_array($obj)) {
537 foreach ($obj as $key => $val)
538 $new[$key] = GOTMLS_object_to_array($val);
539 } else
540 $new = $obj;
541 return $new;
542 }
543
544 function GOTMLS_get_pagination($count, $wrap = "") {
545 $Q_Paged = "";
546 if (isset($_REQUEST["paged"]) && is_numeric($_REQUEST["paged"])) {
547 if ((INT) $count < (INT) $_REQUEST["paged"])
548 $GLOBALS["GOTMLS"]["Quarantine"]["paged"] = (INT) $count;
549 else
550 $GLOBALS["GOTMLS"]["Quarantine"]["paged"] = (INT) $_REQUEST["paged"];
551 } else
552 $GLOBALS["GOTMLS"]["Quarantine"]["paged"] = 1;
553 for ($p = 1; $p <= $count; $p++) {
554 $Q_Paged .= '<input class="GOTMLS_page" type="submit" value="'.$p.'"'.((isset($GLOBALS["GOTMLS"]["Quarantine"]["paged"]) && $GLOBALS["GOTMLS"]["Quarantine"]["paged"] == $p) || (!isset($GLOBALS["GOTMLS"]["Quarantine"]["paged"]) && 1 == $p)?" DISABLED":"").' name="paged">';
555 }
556 if ($Q_Paged) {
557 foreach ($_GET as $name => $value) {
558 if (substr($name, 0, 10) != 'paged') {
559 if (is_array($value)) {
560 foreach ($value as $val)
561 $Q_Paged .= '<input type="hidden" name="'.GOTMLS_htmlspecialchars($name).'[]" value="'.GOTMLS_htmlspecialchars($val).'">';
562 } else
563 $Q_Paged .= '<input type="hidden" name="'.GOTMLS_htmlspecialchars($name).'" value="'.GOTMLS_htmlspecialchars($value).'">';
564 }
565 }
566 $Q_Paged = '<form method="GET" name="GOTMLS_Form_page"><div style="float: left;">Page:</div>'."$Q_Paged\n</form><br style=\"clear: left;\" />\n";
567 }
568 if ($wrap)
569 return "$Q_Paged<!-- p = $p , count = $count -->$wrap$Q_Paged";
570 else
571 return $Q_Paged;
572 }
573
574 function GOTMLS_get_quarantine($only = false) {
575 global $wpdb, $post;
576 if (is_numeric($only))
577 return get_post($only, ARRAY_A);
578 elseif ($only === true)
579 return $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->posts` WHERE `post_type` = 'GOTMLS_quarantine' AND `post_status` = 'private'");
580 else
581 $args = array("orderby" => 'date', "post_type" => 'GOTMLS_quarantine', "post_status" => array('private'));
582 if (isset($_REQUEST["post_status"]))
583 $args["post_status"] = $_REQUEST["post_status"];
584 if (isset($_REQUEST["paged"]) && is_numeric($_REQUEST["paged"]))
585 $args["paged"] = (INT) $_REQUEST["paged"];
586 if (isset($_REQUEST["posts_per_page"]) && is_numeric($_REQUEST["posts_per_page"]) && ($_REQUEST["posts_per_page"]))
587 $args["posts_per_page"] = (INT) $_REQUEST["posts_per_page"];
588 else
589 $args["posts_per_page"] = 200;
590 $my_query = new WP_Query($args);
591 if ($my_query->have_posts()) {
592 $Q_Page = '<form method="POST" action="'.admin_url('admin-ajax.php').'" target="GOTMLS_iFrame" id="GOTMLS_Form_clean" name="GOTMLS_Form_clean"><input type="hidden" id="GOTMLS_fixing" name="GOTMLS_fixing" value="1"><input type="hidden" name="'.str_replace('=', '" value="', GOTMLS_set_nonce(__FUNCTION__."581")).'"><input type="hidden" name="action" value="GOTMLS_fix"><p id="quarantine_buttons" style="display: none;"><input id="repair_button" type="submit" value="'.__("Restore selected files from quarantine records",'gotmls').'" class="button-primary" onclick="if (confirm(\''.__("Are you sure you want to overwrite the previously cleaned files with the selected files in the Quarantine?",'gotmls').'\')) { setvalAllFiles(1); loadIframe(\'File Restoration Results\'); } else return false;" /><input id="delete_button" type="submit" class="button-primary" value="'.__("Delete selected quarantine records",'gotmls').'" onclick="if (confirm(\''.__("Are you sure you want to permanently delete the selected files in the Quarantine?",'gotmls').'\')) { setvalAllFiles(2); loadIframe(\'File Deletion Results\'); } else return false;" /></p><p><b>'.__("The following items highlighted in yellow had been found to contain malicious code, they have been cleaned and the malicious contents have been removed. A record of the infection has been saved here in the Quarantine for your review and could help with any future investigations. The code is safe here and you do not need to do anything further with these files.",'gotmls').'</b></p>
593 <p id="reclean_buttons" style="display: none;"><input id="reclean_button" type="submit" value="'.__("Re-clean re-infected files",'gotmls').'" class="button-primary" onclick="checkAllFiles(false); setvalAllFiles(1); loadIframe(\'Reinfected File Recleaning Results\');" /><b>'.__("The items highlighted in red have been found to be re-infected. The malicious code has returned and needs to be cleaned again.",'gotmls').'</b></p>
594 <ul name="found_Quarantine" id="found_Quarantine" class="GOTMLS_plugin known" style="background-color: #ccc; padding: 0;"><h3 style="margin: 8px 12px;">'.($my_query->post_count>1?'<input type="checkbox" onchange="checkAllFiles(this.checked); document.getElementById(\'quarantine_buttons\').style.display = \'block\';"> '.sprintf(__("Check all %d",'gotmls'),$my_query->post_count):"").__(" Items in Quarantine",'gotmls').'<span class="GOTMLS_date">'.__("Quarantined",'gotmls').'</span><span class="GOTMLS_date">'.__("Date Infected",'gotmls').((isset($_REQUEST["GOTMLS_debug"]))?'</span><span class="GOTMLS_date">'.__("Date Modified",'gotmls').'</span><span class="GOTMLS_date">'.__("Date Changed",'gotmls').'</span><span class="GOTMLS_date">'.__("File Size",'gotmls').'</span><span class="GOTMLS_date">'.__("Threat Found",'gotmls'):"").'</span></h3>';
595 $root_path = implode(GOTMLS_slash(), array_slice(GOTMLS_explode_dir(__FILE__), 0, (2 + intval($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_level"])) * -1));
596 while ($my_query->have_posts()) {
597 $my_query->the_post();
598 $gif = 'blocked.gif';
599 $threat = 'potential';
600 $action = $post->ID.'" id="check_'.$post->ID.'" onchange="document.getElementById(\'quarantine_buttons\').style.display = \'block\';';
601 $link = GOTMLS_error_link(__("The current/live file is missing or deleted",'gotmls'), $post->ID, $threat);
602 $fa = GOTMLS_threats_found_meta(GOTMLS_object_to_array($post));
603 if (is_file($post->post_title)) {
604 GOTMLS_scanfile($post->post_title);
605 if (count($GLOBALS["GOTMLS"]["tmp"]["threats_found"])) {
606 $gif = 'threat.gif" onload="document.getElementById(\'reclean_buttons\').style.display = \'block\';';
607 $threat = 'known';
608 $action = GOTMLS_encode(realpath($post->post_title)).'" id="ilist_'.$post->ID.'" checked="true';
609 }
610 $link = GOTMLS_error_link(__("View current/live version",'gotmls'), $post->post_title, $threat);
611 } elseif (is_array($postdb = explode(":", $post->post_title.":")) && count($postdb) > 3 && is_numeric($postdb[1])) {
612 if ("options" == substr($postdb[0], -7)) {
613 if ($opt_row = $wpdb->get_row($wpdb->prepare("SELECT * FROM `$wpdb->options` WHERE `option_id` = %s",(INT) $postdb[1]), ARRAY_A))
614 $link = GOTMLS_error_link(__("View Option Record: ",'gotmls').((INT) $postdb[1]), ((INT) $postdb[1]).'.1', $threat);
615 elseif ($opt_row = $wpdb->get_row($SQL = $wpdb->prepare("SELECT * FROM `$wpdb->options` WHERE `option_name` LIKE %s", trim($postdb[2], '"')), ARRAY_A))
616 $link = GOTMLS_error_link(__("View Option Record: ",'gotmls').htmlspecialchars($postdb[2]), $opt_row["option_id"].'.1', $threat);
617 else
618 $link = GOTMLS_error_link(__("View Quarantine Record",'gotmls'), $post->ID, $threat);
619 } else {
620 $link = '<a target="_blank" href="';
621 if ("revision" == $postdb[0])
622 $link .= admin_url('revision.php?revision='.rawurlencode($postdb[1]))."\" title=\"View this revision";
623 else
624 $link .= admin_url('post.php?action=edit&post='.rawurlencode((INT) $postdb[1]))."\" title=\"View current ".GOTMLS_htmlspecialchars($postdb[0]);
625 $link .= "\" id=\"list_edit_".((INT) $postdb[1])."\" class=\"GOTMLS_plugin $threat\">";
626 }
627 }
628 $Q_Page .= '
629 <li id="GOTMLS_quarantine_'.((INT) $post->ID).'" class="GOTMLS_quarantine_item" onmouseover="this.style.fontWeight=\'bold\';" onmouseout="this.style.fontWeight=\'normal\';"><span class="GOTMLS_date">'.GOTMLS_error_link(__("View Quarantine Record",'gotmls'), $post->ID, $threat).$post->post_date.'</a></span><span title="modified: '.GOTMLS_htmlspecialchars($post->post_modified).'" class="GOTMLS_date">'.GOTMLS_htmlspecialchars($post->post_modified_gmt).((isset($_REQUEST["GOTMLS_debug"]) && is_file($post->post_title))?'</span><span class="GOTMLS_date">'.gmdate("Y-m-d H:i:s", filemtime($post->post_title)).'</span><span class="GOTMLS_date">'.gmdate("Y-m-d H:i:s", filectime($post->post_title)).'</span><span class="GOTMLS_date">('.filesize($post->post_title).' bytes)</span><span class="GOTMLS_date">( '.$fa.')':"").'</span><input type="checkbox" name="GOTMLS_fix[]" value="'.$action.'" /><img src="'.GOTMLS_images_path.$gif.'" height=16 width=16 alt="Q">'.$link.GOTMLS_htmlspecialchars(str_replace($root_path, "...", $post->post_title))."</a></li>\n";
630 }
631 $Q_Page = GOTMLS_get_pagination($my_query->max_num_pages, "$Q_Page\n</ul>\n</form>");
632 } else
633 $Q_Page = '<h3>'.__("No Items in Quarantine",'gotmls').'</h3>';
634 wp_reset_query();
635 return $Q_Page;
636 }
637
638 function GOTMLS_box($bTitle, $bContents, $bType = "postbox") {
639 $md5 = md5($bTitle);
640 if (isset($GLOBALS["GOTMLS"]["tmp"]["$bType"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["$bType"]))
641 $GLOBALS["GOTMLS"]["tmp"]["$bType"]["$md5"] = "$bTitle";
642 else
643 $GLOBALS["GOTMLS"]["tmp"]["$bType"] = array("$md5"=>"$bTitle");
644 return '
645 <div id="box_'.$md5.'" class="'.$bType.'"><h3 title="Click to toggle" onclick="if (typeof '.$bType.'_showhide == \'function\'){'.$bType.'_showhide(\'inside_'.$md5.'\');}else{showhide(\'inside_'.$md5.'\');}" style="cursor: pointer;" class="hndle"><span id="title_'.$md5.'">'.$bTitle.'</span></h3>
646 <div id="inside_'.$md5.'" class="inside">
647 '.$bContents.'
648 </div>
649 </div>';
650 }
651
652 function GOTMLS_threats_ver($threats_name) {
653 foreach ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"] as $threat_level => $Threats)
654 if (is_array($Threats) && isset($Threats["$threats_name"][0]) && strlen($Threats["$threats_name"][0]) == 5)
655 return $Threats["$threats_name"][0];
656 return $threats_name;
657 }
658
659 function GOTMLS_threats_found_meta($Q_post = array()) {
660 global $wpdb, $table_prefix;
661 $gt = ">"; // This local variable never changes
662 $lt = "<"; // This local variable never changes
663 $SQL = "SELECT `meta_value` AS `Threat`, COUNT(*) AS `Found` FROM `{$wpdb->prefix}postmeta` WHERE `meta_key` = 'GOTMLS_threats_found'";
664 if (isset($Q_post["ID"]) && is_numeric($pID = $Q_post["ID"]) && ($pID > 0))
665 $SQL = $wpdb->prepare("$SQL AND post_id = %s", (INT) $pID);
666 else
667 $pID = 0;
668 $my_query = $wpdb->get_results("$SQL GROUP BY `meta_value`", ARRAY_A);
669 $fa = "";
670 if (is_array($my_query) && count($my_query)) {
671 $f = 1;
672 foreach ($my_query as $rec) {
673 if (isset($rec["Threat"]) && is_string($rec["Threat"]) && is_array($Threat = @GOTMLS_uckserialize($rec["Threat"])) && isset($Threat["DefVer"]) && isset($Threat["SubPos"])) {
674 $ends = explode("-", $Threat["SubPos"]."--", 3);
675 if (strlen($ends[0]) > 0 && strlen($ends[1]) > 0 && is_numeric($ends[1]) && is_numeric($ends[0])) {
676 if ($ends[1] < $ends[0])
677 $ends = array_reverse($ends);
678 $fa .= $lt.'a title="'.GOTMLS_htmlspecialchars($Threat["DefVer"]).'" href="javascript:select_text_range(\'ta_file\', '.$ends[0].', '.$ends[1].');"'.$gt.'['.$f++."]$lt/a$gt ";
679 }
680 }
681 }
682 } else {
683 if (isset($Q_post["post_excerpt"]) && strlen($Q_post["post_excerpt"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["threats_found"] = @GOTMLS_uckserialize(GOTMLS_decode($Q_post["post_excerpt"])))) {
684 $f = 1;
685 foreach ($GLOBALS["GOTMLS"]["tmp"]["threats_found"] as $threats_found => $threats_name) {
686 $ends = explode("-", "$threats_found--", 3);
687 if (strlen($ends[0]) > 0 && strlen($ends[1]) > 0 && is_numeric($ends[1]) && is_numeric($ends[0])) {
688 if ($ends[1] < $ends[0])
689 $ends = array_reverse($ends);
690 $fa .= $lt.'a title="'.GOTMLS_htmlspecialchars($threats_name).'" href="javascript:select_text_range(\'ta_file\', '.$ends[0].', '.$ends[1].');"'.$gt.'['.$f++."]$lt/a$gt ";
691 if (function_exists("add_post_meta"))
692 add_post_meta($pID, 'GOTMLS_threats_found', array("SubPos" => $ends[0]."-".$ends[1], "DefVer" => GOTMLS_threats_ver($threats_name)));
693 } else {
694 if (is_numeric($threats_found)) {
695 $threats_found = $threats_name;
696 $threats_name = $f;
697 }
698 $fpos = 0;
699 $flen = 0;
700 $potential_threat = GOTMLS_convert_r($threats_found);
701 while (($fpos = strpos($GLOBALS["GOTMLS"]["tmp"]["file_contents"], ($potential_threat), $flen + $fpos)) !== false) {
702 $flen = strlen($potential_threat);
703 $fa .= $lt.'a title="'.GOTMLS_htmlspecialchars($threats_name).'" href="javascript:select_text_range(\'ta_file\', '.($fpos).', '.($fpos + $flen).');"'.$gt.'['.$f++."]$lt/a$gt ";
704 if (function_exists("add_post_meta"))
705 add_post_meta($pID, 'GOTMLS_threats_found', serialize(array("SubPos" => $fpos."-".($fpos + $flen), "DefVer" => GOTMLS_threats_ver($threats_name))));
706 }
707 }
708 }
709 } else
710 $fa = strlen($Q_post["post_excerpt"])."No Threats Found ";
711 }
712 return $fa;
713 }
714
715 function GOTMLS_view_details($Q_post, $pretext = "") {
716 $title = __("View Details:",'gotmls');
717 $clean_file = GOTMLS_htmlentities($Q_post["post_title"]);
718 $encoded_file_contents = GOTMLS_convert_r($GLOBALS["GOTMLS"]["tmp"]["file_contents"]);
719 if (isset($GLOBALS["GOTMLS"]["tmp"]["encoding"])) {
720 $en = $GLOBALS["GOTMLS"]["tmp"]["encoding"];
721 @header("Content-type: text/html; charset=$en");
722 } else
723 $en = "Unknown";
724 $fa = GOTMLS_threats_found_meta($Q_post);
725 die(GOTMLS_html_tags(array(
726 "html" => array(
727 "head" => array(
728 "title" => "$title $clean_file",
729 "script" => GOTMLS_js_text_range()
730 ),
731 "body" => array(
732 "table" => array(
733 "tr" => array(
734 "td" => "$pretext".
735 GOTMLS_html_tags(array(
736 "div" => array(
737 "b" => "$title",
738 "br id='encoding' /" => "encoding: $en",
739 "br id='size' /" => "size: ".strlen("$encoded_file_contents")." Bytes",
740 "br id='modified' /" => 'modified:'.$Q_post["post_modified"],
741 "br id='changed' /" => 'changed:'.$Q_post["post_modified_gmt"],
742 "br id='quarantined' /" => 'quarantined:'.$Q_post["post_date"]
743 )
744 ), array(
745 'div' => 'id="fileperms" class="shadowed-box rounded-corners" style="display: none; position: absolute; left: 8px; top: 29px; background-color: #ccc; border: medium solid #C00; box-shadow: -3px 3px 3px #666; border-radius: 10px; padding: 10px;"'
746 )
747 ).
748 GOTMLS_html_tags(array(
749 "div" => GOTMLS_html_tags(array('span' => $title), array('span' => 'onmouseover="document.getElementById(\'fileperms\').style.display=\'block\';" onmouseout="document.getElementById(\'fileperms\').style.display=\'none\';"'))."( $fa)"
750 ), array(
751 'div' => 'style="overflow: auto;"'
752 )
753 )
754 ),
755 GOTMLS_html_tags(array(
756 "tr" => array(
757 "td" => array(
758 "textarea" => GOTMLS_htmlentities("$encoded_file_contents")
759 )
760 )
761 ), array(
762 'td' => 'style="height: 100%; padding: 5px 5px 0 0;"',
763 'textarea' => 'id="ta_file" style="width: 100%; height: 100%"'
764 )
765 )
766 )
767 )
768 )
769 ), array(
770 'script' => 'type="text/javascript"',
771 'table' => 'style="top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;"',
772 'td' => 'style="width: 100%"'
773 )
774 ));
775 }
776
777 function GOTMLS_js_text_range($posttext = "") {
778 return '
779 function select_text_range(ta_id, start, end) {
780 var textBox = document.getElementById(ta_id);
781 var scrolledText = "";
782 scrolledText = textBox.value.substring(0, end);
783 textBox.focus();
784 if (textBox.setSelectionRange) {
785 scrolledText = textBox.value.substring(end);
786 textBox.value = textBox.value.substring(0, end);
787 textBox.scrollTop = textBox.scrollHeight;
788 textBox.value = textBox.value + scrolledText;
789 textBox.setSelectionRange(start, end);
790 } else if (textBox.createTextRange) {
791 var range = textBox.createTextRange();
792 range.collapse(true);
793 range.moveStart("character", start);
794 range.moveEnd("character", end);
795 range.select();
796 } else
797 alert("The highlighting function does not work in your browser");
798 }
799 if (typeof window.parent.showhide === "function")
800 window.parent.showhide("GOTMLS_iFrame", true);
801 '.$posttext;
802 }
803
804 if ((isset($_SERVER["DOCUMENT_ROOT"]) && ($SCRIPT_FILE = str_replace($_SERVER["DOCUMENT_ROOT"], "", (isset($_SERVER["SCRIPT_FILENAME"])?$_SERVER["SCRIPT_FILENAME"]:(isset($_SERVER["SCRIPT_NAME"])?$_SERVER["SCRIPT_NAME"]:"")))) && strlen($SCRIPT_FILE) > strlen("/".basename(__FILE__)) && substr(__FILE__, -1 * strlen($SCRIPT_FILE)) == substr($SCRIPT_FILE, -1 * strlen(__FILE__)))) {
805 if (isset($_REQUEST["page"]) && str_replace('-', '_', $_REQUEST["page"]) == "GOTMLS_View_Quarantine" && isset($_REQUEST["GOTMLS_mt"]) && strlen($GOTMLS_nonce = $_REQUEST["GOTMLS_mt"]) == 32 && isset($GLOBALS["GOTMLS"]["tmp"]["nonce"][$_REQUEST["GOTMLS_mt"]]["context"]) && ($GLOBALS["GOTMLS"]["tmp"]["nonce"][$_REQUEST["GOTMLS_mt"]]["context"] == GOTMLS_update_home)) {
806 try {
807 $wpdb->prefix = $table_prefix;
808 if (isset($_REQUEST["id"]) && is_numeric($_REQUEST["id"])) {
809 $my_query = $wpdb->get_results($wpdb->prepare("SELECT * FROM `{$wpdb->prefix}posts` WHERE `post_type` = 'GOTMLS_quarantine' AND `ID` = %s", (INT) $_REQUEST["id"]), ARRAY_A);
810 if (is_array($my_query) && isset($my_query[0]["post_type"]) && strtolower($my_query[0]["post_type"]) == "gotmls_quarantine") {
811 GOTMLS_load_contents(GOTMLS_decode($my_query[0]["post_content"]));
812 GOTMLS_view_details($my_query[0], '<form style="margin: 0;" method="post" action="?GOTMLS_mt='.$GOTMLS_nonce.'&page=GOTMLS_View_Quarantine" onsubmit="return confirm(\''.GOTMLS_strip4java(__("Are you sure you want to restore this record from the quarantine?",'gotmls')).'\');"><input type="hidden" name="id[]" value="'.$my_query[0]["ID"].'"><input type="submit" value="Restore from Quarantine" style="display: none; background-color: #0C0; float: right;"></form>');
813 } else
814 die('<h3>Item NOT Found in Quarantine</h3>');
815 } else {
816 if (!isset($_REQUEST["not_in"]))
817 $_REQUEST["not_in"] = "trash";
818 $GLOBALS["GOTMLS"]["Quarantine"]["SQL"] = $wpdb->prepare("FROM `{$wpdb->prefix}posts` WHERE `post_type` = 'GOTMLS_quarantine' AND `post_status` != %s ORDER BY `post_date_gmt` DESC", $_REQUEST["not_in"]);
819 $GLOBALS["GOTMLS"]["Quarantine"]["Count"] = $wpdb->get_var("SELECT COUNT(*) ".$GLOBALS["GOTMLS"]["Quarantine"]["SQL"]);
820 if (isset($_REQUEST["posts_per_page"]) && is_numeric($_REQUEST["posts_per_page"]) && ($_REQUEST["posts_per_page"]))
821 $GLOBALS["GOTMLS"]["Quarantine"]["posts_per_page"] = (INT) $_REQUEST["posts_per_page"];
822 else
823 $GLOBALS["GOTMLS"]["Quarantine"]["posts_per_page"] = 200;
824 $paged = GOTMLS_get_pagination(ceil($GLOBALS["GOTMLS"]["Quarantine"]["Count"] / $GLOBALS["GOTMLS"]["Quarantine"]["posts_per_page"]));
825 $GLOBALS["GOTMLS"]["Quarantine"]["SQL"] .= $wpdb->prepare(" LIMIT %d,%d", (INT) (($GLOBALS["GOTMLS"]["Quarantine"]["paged"] - 1) * $GLOBALS["GOTMLS"]["Quarantine"]["posts_per_page"]), (INT) $GLOBALS["GOTMLS"]["Quarantine"]["posts_per_page"]);
826 $my_query = $wpdb->get_results("SELECT * ".$GLOBALS["GOTMLS"]["Quarantine"]["SQL"], ARRAY_A);
827 if (is_array($my_query) && count($my_query)) {
828 $Q_Page = $paged.'<form method="POST" action="?page=GOTMLS_View_Quarantine" id="GOTMLS_Form_clean" name="GOTMLS_Form_clean"><input type="hidden" name="GOTMLS_mt" value="'.$GOTMLS_nonce.'"><p id="quarantine_buttons" style="display: none;"><input id="repair_button" type="submit" value="Restore selected files" class="button-primary" style="background-color: #0C0;" onclick="return confirm(\'Are you sure you want to overwrite the previously cleaned files with the selected files in the Quarantine?\');" /></p><p><b>The following items have been found to contain malicious code, they have been cleaned, and the original infected file contents have been saved here in the Quarantine. The code is safe here and you do not need to do anything further with these files.</b></p>
829 <ul name="found_Quarantine" id="found_Quarantine" class="GOTMLS_plugin known" style="background-color: #ccc; padding: 0;"><h3 style="margin: 8px 12px;">'.(count($my_query)>1?'<input type="checkbox" onchange="checkAllFiles(this.checked); document.getElementById(\'quarantine_buttons\').style.display = \'block\';"> '.sprintf(__("Check all %d",'gotmls'),count($my_query)):"").__(" Items in Quarantine",'gotmls').'<span class="GOTMLS_date">'.__("Quarantined",'gotmls').'</span><span class="GOTMLS_date">'.__("Date Infected",'gotmls').'</span></h3>';
830 $root_path = implode(GOTMLS_slash(), array_slice(GOTMLS_explode_dir(__FILE__), 0, (2 + intval($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_level"])) * -1));
831 foreach ($my_query as $post_a) {
832 $restored = "";
833 $image = "threat";
834 $extra = "";
835 if (isset($_REQUEST["id"]) && is_array($_REQUEST["id"]) && in_array($post_a["ID"], $_REQUEST["id"])) {
836 if (GOTMLS_save_contents($post_a["post_title"], $apost_content = GOTMLS_decode($post_a["post_content"]))) {
837 $post_a["post_date_gmt"] = gmdate("Y-m-d H:i:s");
838 if ($wpdb->query($wpdb->prepare("UPDATE `{$wpdb->prefix}posts` SET `post_status` = 'pending', `post_name` = 'whitelist', `post_date_gmt` = '".$post_a["post_date_gmt"]."' WHERE `post_type` = 'GOTMLS_quarantine' AND `ID` = %s", (INT) $post_a["ID"])))
839 $post_a["post_status"] = 'pending';
840 }
841 }
842 if ($post_a["post_status"] == 'pending') {
843 $restored = " read-only disabled";
844 $image = "checked";
845 $extra = " Whitelisted ".$post_a["post_date_gmt"];
846 }
847 if ($post_a["post_status"] == 'trash') {
848 $restored = " read-only disabled";
849 $image = "blocked";
850 $extra = " Deleted ".$post_a["post_date_gmt"];
851 }
852 $Q_Page .= '
853 <li id="GOTMLS_quarantine_'.$post_a["ID"].'" class="GOTMLS_quarantine_item"><span class="GOTMLS_date">'.$post_a["post_date"].'</span><span class="GOTMLS_date" title="modified: '.$post_a["post_modified"].'">'.$post_a["post_modified_gmt"].'</span><input'.$restored.' type="checkbox" name="id[]" value="'.$post_a["ID"].'" id="GOTMLS_quarantine_check_'.$post_a["ID"].'" onchange="document.getElementById(\'quarantine_buttons\').style.display = \'block\';" /><img src="'.$image.'.gif" height=16 width=16 alt="Q"><a class="GOTMLS_plugin '.$restored.($post_a["post_status"]=='pending'?'" title="View Whitelisted File':($post_a["post_status"]=='trash'?' potential" title="View Deleted File':' known" title="View Quarantined File')).'" target="_blank" href="?page=GOTMLS_View_Quarantine&id='.$post_a["ID"].'&GOTMLS_mt='.$GOTMLS_nonce.'">'.str_replace($root_path, "...", $post_a["post_title"])."$extra</a></li>\n";
854 }
855 $Q_Page .= "\n</ul>\n</form>$paged";
856 } else
857 $Q_Page = '<h3>'.__("No Items in Quarantine",'gotmls').'</h3>';
858 die(GOTMLS_html_tags(array("html" => array("body" => GOTMLS_get_header().GOTMLS_box(__("View Quarantine",'gotmls'), $Q_Page)))));
859 }
860 } catch (Exception $e) {
861 die('Caught exception: '.GOTMLS_htmlspecialchars($e->getMessage())."\n");
862 }
863 } else {
864 header("Content-type: image/gif");
865 die(GOTMLS_decode('R=lGODlhEAAQAIQYAAAAAAIAAAMAAAgAAAkAAAsAAAwAAHcAAHgAAKYAAK4AAK8AALUAALYAAMcAAMgAAM=AANkAANoAANwAAN=AAP4AAP8AANTU1P_______________________________yH5BAEKAB8ALAAAAAAQABAAAAWB4HddwGia5SWSAVBZMAwIKQkg7xtXCJAKCEukURgRIJbKQWCrSGw-QAJWiS4sjFHUAYNUFD7LpKilvC6DiaVUqZxipuQIFpfXSWLC5UWpFdQ-V=gWD1EjDBYLUToJUT4XEVUlAQddAyMGDRIWS1o3SW=6PI9aNKJJMykrNSckIx8hADs2'));
866
867 }
868 }
869 $GOTMLS_image_alt = array("wait"=>"...", "checked"=>"&#x2714;", "blocked"=>"X", "question"=>"?", "threat"=>"!");
870 $GOTMLS_dir_at_depth = array();
871 $GOTMLS_dirs_at_depth = array();
872 $GLOBAL_STRING = array("REQUEST" => "&","SERVER" => "&","FILES" => "&");
873 if (isset($_GET) && is_array($_GET))
874 foreach ($_GET as $req => $val)
875 $GLOBAL_STRING["REQUEST"] .= "$req=".(is_array($val)?print_r($val,1):$val)."&";
876 if (isset($_POST) && is_array($_POST))
877 foreach ($_POST as $req => $val)
878 $GLOBAL_STRING["REQUEST"] .= "$req=".(is_array($val)?print_r($val,1):$val)."&";
879 if (isset($_SERVER) && is_array($_SERVER))
880 foreach ($_SERVER as $req => $val)
881 $GLOBAL_STRING["SERVER"] .= "$req=".(is_array($val)?print_r($val,1):$val)."&";
882 if (isset($_FILES) && is_array($_FILES))
883 foreach ($_FILES as $req => $fila)
884 foreach (array("tmp_name","name") as $val)
885 if (isset($fila["$val"]))
886 $GLOBAL_STRING["FILES"] .= "$req.$val=".(is_array($fila["$val"])?print_r($fila["$val"],1):$fila["$val"])."&";
887 if (!(isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["firewall"]) && array($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["firewall"])))
888 $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["firewall"] = array(
889 "RevSlider"=>array("CCIGG", "Revolution Slider Exploit Protection", "This protection is automatically activated because of the widespread attacks on WordPress that have affected so many sites. It is still recommended that you make sure to upgrade any older versions of the Revolution Slider plugin, especially those included in themes that will not update automatically. Even if you don't think you have Revolution Slider on your site it doen't hurt to have this protection enabled.", "SERVER", '/\/admin-ajax\.php/i', "REQUEST", '/\&img=[^\&]*(?<!\.'.implode(')(?<!\.', array_slice($GLOBALS["GOTMLS"]["tmp"]["skip_ext"], 0, 10)).')\&/i'),
890 "Traversal"=>array("CCIGG", "Directory Traversal Protection", "This protection is automatically activated because this type of attack is quite common. This protection can prevent hackers from accessing secure files in parent directories (or user's folders outside the site_root).", "REQUEST", '/[\=\/](\.\.|etc)\//'),
891 "UploadPHP"=>array("CCIGG", "Upload PHP File Protection", "This protection is automatically activated because this type of attack is extremely dangerous. This protection can prevent hackers from uploading malicious code via web scripts.", "FILES", '/name=[^\&]*\.php\&/'));
892 foreach ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["firewall"] as $TP => $VA) {
893 $V = 3;
894 if (is_array($VA) && count($VA) > $V && is_array($VA[$V])) {
895 foreach ($VA[$V] as $reg => $arr) {
896 $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["firewall"]["$TP"][$V++] = $arr;
897 $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["firewall"]["$TP"][$V++] = $reg;
898 }
899 }
900 if (!(isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["firewall"]["$TP"]) && $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["firewall"]["$TP"])) {
901 $GLOBALS["GOTMLS"]["detected_attacks"] = "&attack[]=FW_$TP";
902 for ($V = 4; isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["firewall"]["$TP"][$V]); $V+=2)
903 if (!isset($GLOBAL_STRING[$GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["firewall"]["$TP"][$V-1]]))
904 die($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["firewall"]["$TP"][$V-1]." [$V] not in ".GOTMLS_html_tags(array('pre' => GOTMLS_htmlspecialchars(print_r($GLOBAL_STRING,1)))));
905 elseif (!preg_match($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["firewall"]["$TP"][$V], $GLOBAL_STRING[$GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["firewall"]["$TP"][$V-1]], $matches))
906 $GLOBALS["GOTMLS"]["detected_attacks"] = "";
907 if ($GLOBALS["GOTMLS"]["detected_attacks"])
908 include(dirname(dirname(__FILE__))."/safe-load/index.php");
909 }
910 }
911 $GLOBALS["GOTMLS"]["detected_attacks"] = "";
912 if (!(isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"]) && count($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"]) == 4))
913 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"] = $GLOBALS["GOTMLS"]["tmp"]["default"]["msg_position"];
914 if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_what"]))
915 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_what"] = 2;
916 if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_depth"]))
917 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_depth"] = -1;
918 if (!(isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_ext"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_ext"])))
919 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_ext"] = $GLOBALS["GOTMLS"]["tmp"]["skip_ext"];
920 if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check_custom"]))
921 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check_custom"] = "";
922 if (!(isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_dir"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_dir"])))
923 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_dir"] = array();
924 $GOTMLS_total_percent = 0;
925
926 function GOTMLS_admin_notices() {
927 if (!is_admin())
928 return;
929 if (is_file(dirname(dirname(dirname(__FILE__)))."/yuzo-related-post/yuzo_related_post.php"))
930 echo GOTMLS_error_div('It looks like you have <b>"Related Post" plugin By <i>Lenin Zapata</i></b> installed on your site.<br />This plugin was removed from the WordPress Plugin Repository because it contained a major vulnerability that was responsible for a fairly widespread breach to many WordPress sites that had it installed.<br />It is recommended that it be deactivated and deleted until a fix is released that solves this problem.');
931 if (!function_exists("mb_detect_encoding"))
932 echo GOTMLS_error_div('It looks like you don\'t have <b>"mbstring" functions</b> enabled on your server.<br />This Anti-Malware plugin requires Multibyte String compatibility for best results. Please make sure that php-mbstring is installed and configured for the version of PHP running on your server.');
933 if ($GLOBALS["GOTMLS"]["tmp"]["HeadersError"])
934 echo $GLOBALS["GOTMLS"]["tmp"]["HeadersError"];
935 }
936 add_action("admin_notices", "GOTMLS_admin_notices");
937
938 function GOTMLS_array_recurse($array1, $array2) {
939 foreach ($array2 as $key => $value) {
940 if (!isset($array1[$key]) || (isset($array1[$key]) && !is_array($array1[$key])))
941 $array1[$key] = array();
942 if (is_array($value))
943 $value = GOTMLS_array_recurse($array1[$key], $value);
944 $array1[$key] = $value;
945 }
946 return $array1;
947 }
948
949 function GOTMLS_array_replace($array1, $array2) {
950 foreach ($array2 as $key => $value)
951 $array1[$key] = $value;
952 return $array1;
953 }
954
955 function GOTMLS_array_replace_recursive($array1 = array()) {
956 $args = func_get_args();
957 $array1 = $args[0];
958 if (!is_array($array1))
959 $array1 = array();
960 for ($i = 1; $i < count($args); $i++)
961 if (is_array($args[$i]))
962 $array1 = GOTMLS_array_recurse($array1, $args[$i]);
963 return $array1;
964 }
965
966 function GOTMLS_scanlog_title() {
967 $units = array("seconds"=>60,"minutes"=>60,"hours"=>24,"days"=>365,"years"=>10);
968 if (isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["type"]) && strlen($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["type"]))
969 $GLOBALS["GOTMLS"]["scan"]["title"] = GOTMLS_sanitize($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["type"]);
970 else
971 $GLOBALS["GOTMLS"]["scan"]["title"] = "Unknown scan type";
972 $scan_only = "";
973 if (isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["scan_only"])) {
974 if (is_array($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["scan_only"])) {
975 if (count($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["scan_only"]) == 1 && isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["scan_only"][0]))
976 $scan_only = "/".$GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["scan_only"][0];
977 } else
978 $scan_only = "/".$GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["scan_only"];
979 }
980 if (isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["dir"]) && @is_dir($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["dir"]))
981 $GLOBALS["GOTMLS"]["scan"]["title"] .= " of ".basename($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["dir"].$scan_only);
982 elseif ($scan_only)
983 $GLOBALS["GOTMLS"]["scan"]["title"] .= " of ".basename($scan_only);
984 if (isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"]) && is_numeric($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"])) {
985 $ukeys = array_keys($units);
986 $GLOBALS["GOTMLS"]["scan"]["title"] .= " on ".date("Y-m-d", $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"]);
987 if (isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["finish"]) && is_numeric($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["finish"]) && ($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["finish"] >= $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"])) {
988 $time = ($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["finish"] - $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"]);
989 for ($unit = $ukeys[0], $key=0; (isset($units[$ukeys[$key]]) && $key < (count($ukeys) - 1) && $time >= $units[$ukeys[$key]]); $unit = $ukeys[++$key])
990 $time = floor($time/$units[$ukeys[$key]]);
991 if (1 == $time)
992 $unit = substr($unit, 0, -1);
993 if ($time)
994 $GLOBALS["GOTMLS"]["scan"]["title"] .= " ran for $time $unit";
995 } else
996 $GLOBALS["GOTMLS"]["scan"]["title"] .= " was not finished!";
997 } else
998 $GLOBALS["GOTMLS"]["scan"]["title"] .= " failed to started!";
999 return $GLOBALS["GOTMLS"]["scan"]["title"];
1000 }
1001
1002 function GOTMLS_load_scanlog($scanlog_key) {
1003 global $wpdb;
1004 if (strlen($scanlog_key = preg_replace('/[^0-9a-f]++]i/', "", $scanlog_key)) != 32)
1005 $scanlog_key = preg_replace('/[^0-9a-f]++]i/', "", $GLOBALS["GOTMLS"]["tmp"]["mt"]);
1006 if ((strlen($scanlog_key) == 32) && ($prs = $wpdb->get_results($wpdb->prepare("SELECT * FROM `{$wpdb->prefix}posts` WHERE post_type = %s AND post_name = %s", 'gotmls_results', $scanlog_key), ARRAY_A))) {
1007 $GLOBALS["GOTMLS"]["scan"]["key"] = $scanlog_key;
1008 if (!(isset($prs[0]["post_content"]) && (strlen($prs[0]["post_content"])) && is_array($GLOBALS["GOTMLS"]["scan"]["log"] = json_decode($prs[0]["post_content"], true))))
1009 $GLOBALS["GOTMLS"]["scan"]["log"] = array();
1010 if (!isset($GLOBALS["GOTMLS"]["scan"]["title"]) && !(isset($prs[0]["post_title"]) && (strlen($GLOBALS["GOTMLS"]["scan"]["title"] = $prs[0]["post_title"])))) {
1011 GOTMLS_scanlog_title();
1012 }
1013 return $scanlog_key;
1014 }
1015 return false;
1016 }
1017
1018 function GOTMLS_update_scanlog($scan_log, $status = "") {
1019 global $wpdb;
1020 if (is_array($scan_log)) {
1021 if (isset($GLOBALS["GOTMLS"]["scan"]["key"]) && strlen($scanlog_key = preg_replace('/[^0-9a-f]++]i/', "", $GLOBALS["GOTMLS"]["scan"]["key"])) == 32) {
1022 $GLOBALS["GOTMLS"]["scan"]["log"] = GOTMLS_array_replace_recursive($GLOBALS["GOTMLS"]["scan"]["log"], $scan_log);
1023 $values = array("post_modified" => date("Y-m-d H:i:s", (int) $GLOBALS["GOTMLS"]["MT"]));
1024 $where = array("post_type" => 'gotmls_results', "post_name" => $scanlog_key);
1025 } else {
1026 $where = false;
1027 $values = array("post_modified" => date("Y-m-d H:i:s", (int) $GLOBALS["GOTMLS"]["MT"]), "post_date_gmt" => date("Y-m-d H:i:s", (int) $GLOBALS["GOTMLS"]["MT"]), "post_type" => 'gotmls_results', "post_parent" => 0);
1028 if (($prs = $wpdb->get_results($wpdb->prepare("SELECT ID FROM `{$wpdb->prefix}posts` WHERE post_type = %s ORDER BY post_date DESC LIMIT 1", 'gotmls_results'), ARRAY_A)) && isset($prs[0]["ID"]))
1029 $values["post_parent"] = $prs[0]["ID"];
1030 $GLOBALS["GOTMLS"]["scan"]["log"] = $scan_log;
1031 }
1032 if (isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["percent"]) && is_numeric($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["percent"]) && ($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["percent"] >= 100))
1033 $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["finish"] = time();
1034 if (isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["finish"]) && is_numeric($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["finish"])) {
1035 $values["post_modified_gmt"] = date("Y-m-d H:i:s", (int) $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["finish"]);
1036 if (!isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"]))
1037 $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"] = $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["finish"];
1038 }
1039 if (isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["type"]) && !isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"]))
1040 $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"] = (int) $GLOBALS["GOTMLS"]["MT"];
1041 $values["post_content"] = json_encode($GLOBALS["GOTMLS"]["scan"]["log"]);
1042 $values["post_author"] = GOTMLS_get_current_user_id(0);
1043 $values["post_modified"] = date("Y-m-d H:i:s", (int) microtime(true));
1044 if (!(isset($GLOBALS["GOTMLS"]["scan"]["log"]["settings"]) && is_array($GLOBALS["GOTMLS"]["scan"]["log"]["settings"])) && isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]))
1045 $GLOBALS["GOTMLS"]["scan"]["log"]["settings"] = $GLOBALS["GOTMLS"]["tmp"]["settings_array"];
1046 if (isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"]) && is_numeric($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"]) && ($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"] > 0)) {
1047 $values["post_date"] = date("Y-m-d H:i:s", (int) $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"]);
1048 $values["post_title"] = GOTMLS_scanlog_title();
1049 if ($where)
1050 $scan_log["updated" . $wpdb->update($wpdb->posts, $values, $where)] = $where;
1051 else {
1052 if (strlen($GLOBALS["GOTMLS"]["scan"]["key"] = preg_replace('/[^0-9a-f]++]i/', "", $GLOBALS["GOTMLS"]["tmp"]["mt"])) != 32)
1053 $GLOBALS["GOTMLS"]["scan"]["key"] = md5($GLOBALS["GOTMLS"]["MT"]);
1054 $values["post_name"] = $GLOBALS["GOTMLS"]["scan"]["key"];
1055 $scan_log["inserted"] = $wpdb->insert($wpdb->posts, $values);
1056 }
1057 }
1058 }
1059 }
1060
1061 function GOTMLS_loaded() {
1062 if (headers_sent($filename, $linenum)) {
1063 if (!$filename)
1064 $filename = __("an unknown file",'gotmls');
1065 if (!is_numeric($linenum))
1066 $linenum = __("unknown",'gotmls');
1067 $GLOBALS["GOTMLS"]["tmp"]["HeadersError"] = GOTMLS_error_div(sprintf(__('<b>Headers already sent</b> in %1$s on line %2$s.<br />This is not a good sign, it may just be a poorly written plugin but Headers should not have been sent at this point.<br />Check the code in the above mentioned file to fix this problem.','gotmls'), $filename, $linenum));
1068 } elseif (isset($_GET["SESSION"]) && !session_id()) {
1069 @session_start();
1070 }
1071 if (session_id() && isset($_GET["SESSION"]) && $_GET["SESSION"] == "GOTMLS_debug" && ((isset($_GET["GOTMLS_debug"]) && "SESSION" == $_GET["GOTMLS_debug"]) || !isset($_SESSION["GOTMLS_debug"])))
1072 $_SESSION["GOTMLS_debug"] = array("GOTMLS_loaded" => microtime(true));
1073 }
1074 add_action("plugins_loaded", "GOTMLS_loaded");
1075
1076 if (!function_exists("add_action")) {
1077 GOTMLS_loaded();
1078 // GOTMLS_admin_notices();
1079 }
1080
1081 function GOTMLS_get_ext($filename) {
1082 $nameparts = explode(".", ".$filename");
1083 return strtolower($nameparts[(count($nameparts)-1)]);
1084 }
1085
1086 function GOTMLS_preg_match_all($threat_definition, $threat_name, $not_serialized = true) {
1087 if ($match = @preg_match_all($threat_definition, $GLOBALS["GOTMLS"]["tmp"]["file_contents"], $threats_found)) {
1088 $start = -1;
1089 if (!@preg_match_all($threat_definition, $GLOBALS["GOTMLS"]["tmp"]["new_contents"], $threat_found)) {
1090 $new_contents = $GLOBALS["GOTMLS"]["tmp"]["new_contents"];
1091 $GLOBALS["GOTMLS"]["tmp"]["new_contents"] = $GLOBALS["GOTMLS"]["tmp"]["file_contents"];
1092 } else
1093 $new_contents = false;
1094 foreach ($threats_found[0] as $find) {
1095 $potential_threat = GOTMLS_convert_r($find);
1096 $flen = strlen($potential_threat);
1097 while (($start = strpos(GOTMLS_convert_r($GLOBALS["GOTMLS"]["tmp"]["file_contents"]), $potential_threat, $start+1)) !== false) {
1098 $GLOBALS["GOTMLS"]["tmp"]["threats_found"]["$start-".($flen+$start)] = "$threat_name";
1099 if ($not_serialized)
1100 $GLOBALS["GOTMLS"]["tmp"]["new_contents"] = str_replace($find, "", $GLOBALS["GOTMLS"]["tmp"]["new_contents"]);
1101 else
1102 $GLOBALS["GOTMLS"]["tmp"]["new_contents"] = substr($GLOBALS["GOTMLS"]["tmp"]["new_contents"], 0, $start).str_repeat(" ", $flen).substr($GLOBALS["GOTMLS"]["tmp"]["new_contents"], $start + $flen);
1103 }
1104 }
1105 if ($not_serialized && ($new_contents !== false) && strlen($new_contents) < strlen($GLOBALS["GOTMLS"]["tmp"]["new_contents"]))
1106 $GLOBALS["GOTMLS"]["tmp"]["new_contents"] = $new_contents;
1107 return count($GLOBALS["GOTMLS"]["tmp"]["threats_found"]);
1108 } else
1109 return $match;
1110 }
1111
1112 function GOTMLS_preg_last_pcre_error() {
1113 $DC = array('PREG_NO_ERROR', 'PREG_INTERNAL_ERROR', 'PREG_BACKTRACK_LIMIT_ERROR', 'PREG_RECURSION_LIMIT_ERROR', 'PREG_BAD_UTF8_ERROR', 'PREG_BAD_UTF8_OFFSET_ERROR');
1114 if (function_exists("preg_last_error") && ($key = (INT) preg_last_error()) && isset($DC[$key]))
1115 return $DC[$key];
1116 else
1117 return "";
1118 }
1119
1120 function GOTMLS_check_threat($check_threats, $file='UNKNOWN') {
1121 $GLOBALS["GOTMLS"]["tmp"]["threats_found"] = array();
1122 $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["last_threat"] = microtime(true);
1123 $filekey = md5($GLOBALS["GOTMLS"]["tmp"]["file_contents"])."O".strlen($GLOBALS["GOTMLS"]["tmp"]["file_contents"]);
1124 if (is_array($check_threats)) {
1125 $path = str_replace("//", "/", "/".str_replace("\\", "/", substr($file, strlen(ABSPATH))));
1126 if (substr($file, 0, strlen(ABSPATH)) == ABSPATH && isset($check_threats[GOTMLS_wp_version]["$path"])) {
1127 if (($check_threats[GOTMLS_wp_version]["$path"] != $filekey) && ($source = GOTMLS_get_URL(GOTMLS_get_corefile_URL("$path", $check_threats[GOTMLS_wp_version]["$path"]))) && ($check_threats[GOTMLS_wp_version]["$path"] == md5($source)."O".strlen($source))) {
1128 $GLOBALS["GOTMLS"]["tmp"]["new_contents"] = $source;
1129 $len = strlen($GLOBALS["GOTMLS"]["tmp"]["file_contents"]);
1130 if (strlen($source) < $len)
1131 $len = strlen($source);
1132 for ($start = 0, $end = 0; ($start == 0 || $end == 0) && $len > 0; $len--){
1133 if ($start == 0 && substr($source, 0, $len) == substr($GLOBALS["GOTMLS"]["tmp"]["file_contents"], 0, $len))
1134 $start = $len;
1135 if ($end == 0 && substr($source, -1 * $len) == substr($GLOBALS["GOTMLS"]["tmp"]["file_contents"], -1 * $len))
1136 $end = $len;
1137 }
1138 $GLOBALS["GOTMLS"]["tmp"]["threats_found"]["$start-".(strlen($GLOBALS["GOTMLS"]["tmp"]["file_contents"])-$end)] = "Core File Modified";
1139 }
1140 } else {
1141 foreach ($check_threats as $threat_name=>$threat_definitions) {
1142 $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["last_threat"] = microtime(true);
1143 if (is_array($threat_definitions) && count($threat_definitions) > 1 && strlen($def_ver = array_shift($threat_definitions)) == 5 && (!(isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"]) && in_array($threat_name, $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"])))) {
1144 while ($threat_definition = array_shift($threat_definitions)) {
1145 $found = GOTMLS_preg_match_all($threat_definition, $threat_name);
1146 if ($found===false && ($err = GOTMLS_preg_last_pcre_error()))
1147 $GLOBALS["GOTMLS"]["tmp"]["errors"]["$def_ver"]["$filekey"] = $err;
1148 }
1149 if (isset($_SESSION["GOTMLS_debug"])) {
1150 $_SESSION["GOTMLS_debug"]["threat_name"] = "$threat_name";// ($def_ver)";
1151 $file_time = sprintf('%f', (microtime(true) - $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["last_threat"]));
1152 if (isset($_GET["GOTMLS_debug"]) && is_numeric($_GET["GOTMLS_debug"]) && $file_time > $_GET["GOTMLS_debug"])
1153 echo GOTMLS_htmlspecialchars("\n//GOTMLS_debug $file_time $threat_name $file\n");
1154 if (isset($GLOBALS["GOTMLS"]["tmp"]["errors"]["$def_ver"]["$filekey"]))
1155 $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_name"]]["errors"]["$filekey"] = $GLOBALS["GOTMLS"]["tmp"]["errors"]["$def_ver"]["$filekey"];
1156 if (isset($_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_name"]]["total"]))
1157 $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_name"]]["total"] = sprintf('%f', $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_name"]]["total"] + $file_time);
1158 else
1159 $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_name"]]["total"] = $file_time;
1160 if (isset($_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_name"]]["count"]))
1161 $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_name"]]["count"]++;
1162 else
1163 $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_name"]]["count"] = 1;
1164 if (!isset($_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_name"]]["least"]) || $file_time < $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_name"]]["least"])
1165 $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_name"]]["least"] = $file_time;
1166 if (!isset($_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_name"]]["most"]) || $file_time > $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_name"]]["most"])
1167 $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_name"]]["most"] = $file_time;
1168 }
1169 }
1170 }
1171 }
1172 } elseif (strlen($check_threats) && isset($_GET['eli']) && GOTMLS_verify_regex($check_threats)) {
1173 $found = GOTMLS_preg_match_all($check_threats, $check_threats);
1174 if ($found===false && ($err = GOTMLS_preg_last_pcre_error()))
1175 $GLOBALS["GOTMLS"]["tmp"]["errors"]["$check_threats"]["$filekey"] = $err;
1176 }
1177 if (isset($_SESSION["GOTMLS_debug"])) {
1178 $file_time = sprintf('%f', (microtime(true) - $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["last_threat"]));
1179 if (isset($_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_level"]]["total"]))
1180 $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_level"]]["total"] = sprintf('%f', $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_level"]]["total"] + $file_time);
1181 else
1182 $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_level"]]["total"] = $file_time;
1183 if (isset($_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_level"]]["count"]))
1184 $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_level"]]["count"]++;
1185 else
1186 $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_level"]]["count"] = 1;
1187 if (!isset($_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_level"]]["least"]) || $file_time < $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_level"]]["least"])
1188 $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_level"]]["least"] = $file_time;
1189 if (!isset($_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_level"]]["most"]) || $file_time > $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_level"]]["most"])
1190 $_SESSION["GOTMLS_debug"][$_SESSION["GOTMLS_debug"]["threat_level"]]["most"] = $file_time;
1191 }
1192 return count($GLOBALS["GOTMLS"]["tmp"]["threats_found"]);
1193 }
1194
1195 function GOTMLS_verify_regex($RegExp) {
1196 if (preg_match('/^(\/|\#|\|).+\1[is]*$/', $RegExp))
1197 return $RegExp;
1198 else
1199 return "";
1200 }
1201
1202 function GOTMLS_is_whitelisted($MD5Ofile, $file = "") {
1203 if (!(isset($GLOBALS["GOTMLS"]["tmp"]["whitelist"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["whitelist"]))) {
1204 if (isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["wp_core"][GOTMLS_wp_version]) && is_array($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["wp_core"][GOTMLS_wp_version]))
1205 $GLOBALS["GOTMLS"]["tmp"]["whitelist"] = array_flip($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["wp_core"][GOTMLS_wp_version]);
1206 else
1207 $GLOBALS["GOTMLS"]["tmp"]["whitelist"] = array();
1208 if (isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"])) {
1209 foreach ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"] as $whitelist_file=>$non_threats) {
1210 if (is_array($non_threats) && count($non_threats) > 1) {
1211 if (isset($non_threats[0]))
1212 unset($non_threats[0]);
1213 $GLOBALS["GOTMLS"]["tmp"]["whitelist"] = array_merge($GLOBALS["GOTMLS"]["tmp"]["whitelist"], $non_threats);
1214 }
1215 }
1216 }
1217 }
1218 if (isset($GLOBALS["GOTMLS"]["tmp"]["whitelist"][$MD5Ofile]))
1219 return true;
1220 else
1221 return false;
1222 }
1223
1224 function GOTMLS_scanfile($file) {
1225 global $wpdb;
1226 $gt = ">"; // This local variable never changes
1227 $lt = "<"; // This local variable never changes
1228 $GLOBALS["GOTMLS"]["tmp"]["debug_fix"] = "Scanning...";
1229 $GLOBALS["GOTMLS"]["tmp"]["threats_found"] = array();
1230 $found = false;
1231 $threat_link = "";
1232 $className = "scanned";
1233 $real_file = realpath($file);
1234 $clean_file = GOTMLS_encode($real_file);
1235 $MD5O = md5($GLOBALS["GOTMLS"]["tmp"]["file_contents"]).'O';
1236 if (is_file($real_file) && ($filesize = filesize($real_file)) && GOTMLS_load_contents(@file_get_contents($real_file))) {
1237 if (GOTMLS_is_whitelisted($MD5O.$filesize))
1238 return GOTMLS_return_threat($className, "checked.gif?$className", $file, $threat_link);
1239 $GLOBALS["GOTMLS"]["tmp"]["new_contents"] = $GLOBALS["GOTMLS"]["tmp"]["file_contents"];
1240 if (isset($GLOBALS["GOTMLS"]["scan"]["log"]["settings"]["check_custom"]) && strlen($GLOBALS["GOTMLS"]["scan"]["log"]["settings"]["check_custom"]) && isset($_GET['eli']) && GOTMLS_verify_regex($GLOBALS["GOTMLS"]["scan"]["log"]["settings"]["check_custom"]) && ($found = GOTMLS_check_threat($GLOBALS["GOTMLS"]["scan"]["log"]["settings"]["check_custom"])))
1241 $className = "known";
1242 else {
1243 $path = str_replace("//", "/", "/".str_replace("\\", "/", substr($file, strlen(ABSPATH))));
1244 if (isset($_SESSION["GOTMLS_debug"])) {
1245 $_SESSION["GOTMLS_debug"]["file"] = $file;
1246 $_SESSION["GOTMLS_debug"]["last"]["total"] = microtime(true);
1247 }
1248 if (isset($GLOBALS["GOTMLS"]["tmp"]["threat_levels"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["threat_levels"])) {
1249 foreach ($GLOBALS["GOTMLS"]["tmp"]["threat_levels"] as $threat_level) {
1250 if ("db_scan" != $threat_level) {
1251 if (isset($_SESSION["GOTMLS_debug"])) {
1252 $_SESSION["GOTMLS_debug"]["threat_level"] = $threat_level;
1253 $_SESSION["GOTMLS_debug"]["last"]["threat_level"] = microtime(true);
1254 }
1255 if (in_array($threat_level, $GLOBALS["GOTMLS"]["scan"]["log"]["settings"]["check"]) && !$found && isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"][$threat_level]) && ($threat_level != "wp_core" || (substr($file, 0, strlen(ABSPATH)) == ABSPATH && isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["wp_core"][GOTMLS_wp_version]["$path"]))) && (!isset($GLOBALS["GOTMLS"]["tmp"]["threat_files"]["$threat_level"]) || (substr($file."e", (-1 * strlen($GLOBALS["GOTMLS"]["tmp"]["threat_files"][$threat_level]."e"))) == $GLOBALS["GOTMLS"]["tmp"]["threat_files"][$threat_level]."e")) && ($found = GOTMLS_check_threat($GLOBALS["GOTMLS"]["tmp"]["definitions_array"][$threat_level],$file)))
1256 $className = $threat_level;
1257 }
1258 }
1259 }
1260 if (isset($_SESSION["GOTMLS_debug"])) {
1261 $file_time = round(microtime(true) - $_SESSION["GOTMLS_debug"]["last"]["total"], 5);
1262 if (isset($_SESSION["GOTMLS_debug"]["total"]["total"]))
1263 $_SESSION["GOTMLS_debug"]["total"]["total"] += $file_time;
1264 else
1265 $_SESSION["GOTMLS_debug"]["total"]["total"] = $file_time;
1266 if (isset($_SESSION["GOTMLS_debug"]["total"]["count"]))
1267 $_SESSION["GOTMLS_debug"]["total"]["count"] ++;
1268 else
1269 $_SESSION["GOTMLS_debug"]["total"]["count"] = 1;
1270 if (!isset($_SESSION["GOTMLS_debug"]["total"]["least"]) || $file_time < $_SESSION["GOTMLS_debug"]["total"]["least"])
1271 $_SESSION["GOTMLS_debug"]["total"]["least"] = $file_time;
1272 if (!isset($_SESSION["GOTMLS_debug"]["total"]["most"]) || $file_time > $_SESSION["GOTMLS_debug"]["total"]["most"])
1273 $_SESSION["GOTMLS_debug"]["total"]["most"] = $file_time;
1274 }
1275 }
1276 } else {
1277 GOTMLS_load_contents((is_file($real_file)?(is_readable($real_file)?(filesize($real_file)?__("Failed to read file contents!",'gotmls'):__("Empty file!",'gotmls')):(isset($_GET["eli"])?(@chmod($real_file, GOTMLS_CHMOD_FILE)?__("Fixed file permissions! (try again)",'gotmls'):__("File permissions read-only!",'gotmls')):__("File not readable!",'gotmls'))):__("File does not exist!",'gotmls')));
1278 $className = "errors";
1279 }
1280 if (count($GLOBALS["GOTMLS"]["tmp"]["threats_found"])) {
1281 $threat_link = $lt.'a target="GOTMLS_iFrame" href="'.GOTMLS_admin_url('GOTMLS_scan', GOTMLS_set_nonce(__FUNCTION__."1275").'&mt='.$GLOBALS["GOTMLS"]["tmp"]["mt"].'&GOTMLS_scan='.$clean_file).'" id="list_'.$clean_file.'" onclick="loadIframe(\''.str_replace("\"", "&quot;", $lt.'div style="float: left; white-space: nowrap;"'.$gt.GOTMLS_strip4java(__("Examine File",'gotmls')).' ... '.$lt.'/div'.$gt.$lt.'div style="overflow: hidden; position: relative; height: 20px;"'.$gt.$lt.'div style="position: absolute; right: 0px; text-align: right; width: 9000px;"'.$gt.GOTMLS_htmlspecialchars(GOTMLS_strip4java($file), ENT_NOQUOTES))."$lt/div$gt$lt/div$gt');\" class=\"GOTMLS_plugin\"$gt";
1282 if ($className == "errors") {
1283 $GLOBALS["GOTMLS"]["tmp"]["debug_fix"]="errors";
1284 $threat_link = GOTMLS_error_link($GLOBALS["GOTMLS"]["tmp"]["file_contents"], $file);
1285 $imageFile = "/blocked";
1286 } elseif ($className != "potential") {
1287 if (isset($_REQUEST["GOTMLS_fix"]) && is_array($_REQUEST["GOTMLS_fix"]) && in_array($clean_file, $_REQUEST["GOTMLS_fix"])) {
1288 $GLOBALS["GOTMLS"]["tmp"]["debug_fix"]="GOTMLS_fix";
1289 if (GOTMLS_get_nonce()) {
1290 if ($className == "timthumb") {
1291 if (($source = GOTMLS_get_URL("https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/timthumb/timthumb.php")) && strlen($source) > 500)
1292 $GLOBALS["GOTMLS"]["tmp"]["new_contents"] = $source;
1293 else
1294 $GLOBALS["GOTMLS"]["tmp"]["file_contents"] = "";
1295 } elseif ($className == 'wp_core') {
1296 $path = str_replace("//", "/", "/".str_replace("\\", "/", substr($file, strlen(ABSPATH))));
1297 if (substr($file, 0, strlen(ABSPATH)) == ABSPATH && isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["wp_core"][GOTMLS_wp_version]["$path"]) && ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["wp_core"][GOTMLS_wp_version]["$path"] != $MD5O.strlen($GLOBALS["GOTMLS"]["tmp"]["file_contents"])) && ($source = GOTMLS_get_URL(GOTMLS_get_corefile_URL("$path", $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["wp_core"][GOTMLS_wp_version]["$path"]))) && ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["wp_core"][GOTMLS_wp_version]["$path"] == md5($source)."O".strlen($source)))
1298 $GLOBALS["GOTMLS"]["tmp"]["new_contents"] = $source;
1299 else
1300 $GLOBALS["GOTMLS"]["tmp"]["file_contents"] = "";
1301 } else {
1302 $GOTMLS_no_contents = trim(preg_replace('/\/\*.*?\*\/\s*/s', "", $GLOBALS["GOTMLS"]["tmp"]["new_contents"]));
1303 $GOTMLS_no_contents = trim(preg_replace('/\n\s*\/\/.*/', "", $GOTMLS_no_contents));
1304 $GOTMLS_no_contents = trim(preg_replace('/'.$lt.'\?(php)?\s*(\?'.$gt.'|$)/is', "", $GOTMLS_no_contents));
1305 if (strlen($GOTMLS_no_contents))
1306 $GLOBALS["GOTMLS"]["tmp"]["new_contents"] = trim(preg_replace('/'.$lt.'\?(php)?\s*(\?'.$gt.'|$)/is', "", $GLOBALS["GOTMLS"]["tmp"]["new_contents"]));
1307 else
1308 $GLOBALS["GOTMLS"]["tmp"]["new_contents"] = "";
1309 }
1310 if (strlen($GLOBALS["GOTMLS"]["tmp"]["file_contents"]) > 0 && (($Q_post = GOTMLS_write_quarantine($file, $className)) !== false) && ((strlen($GLOBALS["GOTMLS"]["tmp"]["new_contents"])==0 && isset($_GET["eli"]) && ($_GET["eli"] == "delete") && @unlink($file)) || (($Write_File = GOTMLS_save_contents($file, $GLOBALS["GOTMLS"]["tmp"]["new_contents"])) !== false))) {
1311 echo __("Success!",'gotmls');
1312 return "/*--{$gt}*"."/\nfixedFile('$clean_file');\n/*{$lt}!--*"."/";
1313 } else {
1314 echo __("Failed:",'gotmls').' '.(strlen($GLOBALS["GOTMLS"]["tmp"]["file_contents"])?((is_writable(dirname($file)) && is_writable($file))?(($Q_post===false)?__("failed to quarantine!",'gotmls')." (".GOTMLS_htmlspecialchars($wpdb->last_error).")":((isset($Write_File)&&$Write_File)?"Q=$Q_post: ".__("reason unknown!",'gotmls'):"Q=$Q_post: ".__("failed to write!",'gotmls'))):__("file not writable!",'gotmls')):__("no file contents!",'gotmls'));
1315 if (isset($_GET["eli"]))
1316 echo get_current_user().$lt."br$gt{$lt}pre$gt file_stat".print_r(stat($file), true);
1317 return "/*--{$gt}*"."/\nfailedFile('$clean_file');\n/*{$lt}!--*"."/";
1318 }
1319 } else {
1320 echo GOTMLS_Invalid_Nonce(__("Failed: ",'gotmls'));
1321 return "/*--{$gt}*"."/\nfailedFile('$clean_file');\n/*{$lt}!--*"."/";
1322 }
1323 }
1324 $GLOBALS["GOTMLS"]["tmp"]["debug_fix"]=isset($_POST["GOTMLS_fix"])?"GOTMLS_fix=".GOTMLS_htmlspecialchars(preg_replace('/[\r\n]+/', ' ', print_r($_POST["GOTMLS_fix"],1))):"!potential";
1325 $threat_link = $lt.'input type="checkbox" name="GOTMLS_fix[]" value="'.$clean_file.'" id="check_'.$clean_file.(($className != "wp_core||ifitis")?'" checked="'.$className:'').'" /'.$gt.$threat_link;
1326 $imageFile = "threat";
1327 } elseif (isset($_POST["GOTMLS_fix"]) && is_array($_POST["GOTMLS_fix"]) && in_array($clean_file, $_POST["GOTMLS_fix"])) {
1328 echo __("Already Fixed!",'gotmls');
1329 return "/*-->*"."/\nfixedFile('$clean_file');\n/*<!--*"."/";
1330 } else
1331 $imageFile = "question";
1332 return GOTMLS_return_threat($className, $imageFile, $file, str_replace("GOTMLS_plugin", "GOTMLS_plugin $className", $threat_link));
1333 } elseif (isset($_POST["GOTMLS_fix"]) && is_array($_POST["GOTMLS_fix"]) && in_array($clean_file, $_POST["GOTMLS_fix"])) {
1334 $GLOBALS["GOTMLS"]["tmp"]["debug_fix"]="Already Fixed";
1335 echo __("Already Fixed!",'gotmls');
1336 return "/*--{$gt}*"."/\nfixedFile('$clean_file');\n/*{$lt}!--*"."/";
1337 } else {
1338 $GLOBALS["GOTMLS"]["tmp"]["debug_fix"]="no threat";
1339 return GOTMLS_return_threat($className, ($className=="scanned"?"checked":"blocked").".gif?$className", $file, $threat_link);
1340 }
1341 }
1342
1343 function GOTMLS_db_scan($id = 0) {
1344 global $wpdb;
1345 $li_js = "";
1346 if (isset($GLOBALS["GOTMLS"]["scan"]["log"]["settings"]["check"]) && is_array($GLOBALS["GOTMLS"]["scan"]["log"]["settings"]["check"]) && in_array("db_scan", $GLOBALS["GOTMLS"]["scan"]["log"]["settings"]["check"]) && isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["db_scan"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["db_scan"]) && count($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["db_scan"])) {
1347 if ($id) {
1348 $encoded_id = GOTMLS_encode($id);
1349 $ids = explode(".", $id.'.');
1350 if (count($ids) > 2 && 'tbl'.$ids[1] == 'tbl1' && is_numeric($ids[0]) && ($Q_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM `$wpdb->options` WHERE `option_id` = %s", (INT) $ids[0]), ARRAY_A))) {
1351 $path = 'Option ID: '.$Q_post["option_id"];
1352 $clean_file = $Q_post["option_name"];
1353 $fa = "";
1354 GOTMLS_load_contents($Q_post["option_value"]);
1355 $not_serialized = !(is_array(GOTMLS_uckserialize($GLOBALS["GOTMLS"]["tmp"]["new_contents"] = $Q_post["option_value"])));
1356 $found = 0;
1357 $GLOBALS["GOTMLS"]["tmp"]["threats_found"] = array();
1358 foreach ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["db_scan"] as $scan_sql => $scan_regex) {
1359 $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["last_threat"] = microtime(true);
1360 $threat_name = array_shift($scan_regex);
1361 while ($threat_definition = array_shift($scan_regex))
1362 $found += GOTMLS_preg_match_all($threat_definition, $threat_name, $not_serialized);
1363 }
1364 if (isset($GLOBALS["GOTMLS"]["tmp"]["threats_found"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["threats_found"]) && count($GLOBALS["GOTMLS"]["tmp"]["threats_found"])) {
1365 $f = 1;
1366 foreach ($GLOBALS["GOTMLS"]["tmp"]["threats_found"] as $threats_found => $threats_name) {
1367 list($start, $end, $junk) = explode("-", "$threats_found--", 3);
1368 if ($start > $end)
1369 $fa .= 'ERROR['.($f++).']: Threat_size{'.$threats_found.'} Content_size{'.strlen($GLOBALS["GOTMLS"]["tmp"]["file_contents"]).'}';
1370 else
1371 $fa .= ' <a title="'.GOTMLS_htmlspecialchars($threats_name).'" href="javascript:select_text_range(\'ta_file\', '.$start.', '.$end.');">['.$f++.']</a>';
1372 }
1373 } else
1374 $fa = " No Threats Found";
1375 if (isset($_REQUEST["GOTMLS_fix"]) && is_array($_REQUEST["GOTMLS_fix"]) && in_array($encoded_id, $_REQUEST["GOTMLS_fix"]) && isset($_REQUEST["GOTMLS_fixing"]) && $_REQUEST["GOTMLS_fixing"] > 0) {
1376 GOTMLS_write_quarantine($Q_post, "db_scan");
1377 if ($_REQUEST["GOTMLS_fixing"] > 1) {
1378 echo "<li>Removing $path ... ";
1379 if ($wpdb->query($wpdb->prepare("DELETE FROM `$wpdb->options` WHERE `option_id` = %s", (INT) $Q_post["option_id"]))) {
1380 echo __("Done!",'gotmls');
1381 $li_js .= "/*-->*"."/\nDeletedFile('$encoded_id');\n/*<!--*"."/";
1382 } else {
1383 echo __("Failed to delete!",'gotmls');
1384 $li_js .= "/*-->*"."/\nfailedFile('$encoded_id');\n/*<!--*"."/";
1385 }
1386 GOTMLS_update_scanlog(array("scan" => array("finish" => time(), "type" => "Removal of Option")));
1387 } else {
1388 echo "<li>Fixing $path ... ";
1389 if ($wpdb->update($wpdb->options, array("option_value" => $GLOBALS["GOTMLS"]["tmp"]["new_contents"]), array('option_id' => $Q_post["option_id"]))) {
1390 echo __("Success!",'gotmls');
1391 $li_js .= "/*-->*"."/\nfixedFile('$encoded_id');\n/*<!--*"."/";
1392 } else {
1393 echo __("Update Failed!",'gotmls');
1394 $li_js .= "/*-->*"."/\nfailedFile('$encoded_id');\n/*<!--*"."/";
1395 }
1396 GOTMLS_update_scanlog(array("scan" => array("finish" => time(), "type" => "Removal from Option")));
1397 }
1398 return $li_js;
1399 } else {
1400 return '<form style="margin: 0;" method="post" action="'.admin_url('admin-ajax.php?'.GOTMLS_set_nonce(__FUNCTION__."1394")).'" onsubmit="return confirm(\''.__("Are you sure you want to delete this option?",'gotmls').'\');"><input type="hidden" name="GOTMLS_fixing" value="2"><input type="hidden" name="action" value="GOTMLS_fix"><input type="submit" value="Delete this Option" style="float: right;"><input type="hidden" name="GOTMLS_fix[]" value="'.$encoded_id.'"></form><div id="fileperms" class="shadowed-box rounded-corners" style="display: none; position: absolute; left: 8px; top: 29px; background-color: #ccc; border: medium solid #C00; box-shadow: -3px 3px 3px #666; border-radius: 10px; padding: 10px;"><b>Record Details</b><br />encoding: '.(isset($GLOBALS["GOTMLS"]["tmp"]["encoding"])?$GLOBALS["GOTMLS"]["tmp"]["encoding"]:"Unknown").'<br />size: '.strlen(GOTMLS_convert_r($GLOBALS["GOTMLS"]["tmp"]["file_contents"])).' bytes</div><div style="overflow: auto;"><span onmouseover="document.getElementById(\'fileperms\').style.display=\'block\';" onmouseout="document.getElementById(\'fileperms\').style.display=\'none\';">'.__("Record Details:",'gotmls').'</span> ('.$fa.' )</div></td></tr><tr><td style="height: 100%"><textarea id="ta_file" style="width: 100%; height: 100%">'.GOTMLS_htmlentities(GOTMLS_convert_r($GLOBALS["GOTMLS"]["tmp"]["file_contents"])).'</textarea></td></tr></table>';
1401 }
1402 } elseif (($Q_post = GOTMLS_get_quarantine($ids[0])) && isset($Q_post["post_content"])) {
1403 $path = $Q_post["post_type"].' ID: '.$Q_post["ID"];
1404 $clean_file = $Q_post["post_title"];
1405 $fa = "";
1406 GOTMLS_load_contents($Q_post["post_content"]);
1407 $not_serialized = !(is_array(GOTMLS_uckserialize($GLOBALS["GOTMLS"]["tmp"]["new_contents"] = $Q_post["post_content"])));
1408 $found = 0;
1409 $GLOBALS["GOTMLS"]["tmp"]["threats_found"] = array();
1410 foreach ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["db_scan"] as $scan_sql => $scan_regex) {
1411 $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["last_threat"] = microtime(true);
1412 $threat_name = array_shift($scan_regex);
1413 while ($threat_definition = array_shift($scan_regex))
1414 $found += GOTMLS_preg_match_all($threat_definition, $threat_name, $not_serialized);
1415 }
1416 if (isset($GLOBALS["GOTMLS"]["tmp"]["threats_found"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["threats_found"]) && count($GLOBALS["GOTMLS"]["tmp"]["threats_found"])) {
1417 $f = 1;
1418 foreach ($GLOBALS["GOTMLS"]["tmp"]["threats_found"] as $threats_found => $threats_name) {
1419 list($start, $end, $junk) = explode("-", "$threats_found--", 3);
1420 if ($start > $end)
1421 $fa .= 'ERROR['.($f++).']: Threat_size{'.$threats_found.'} Content_size{'.strlen($GLOBALS["GOTMLS"]["tmp"]["file_contents"]).'}';
1422 else
1423 $fa .= ' <a title="'.GOTMLS_htmlspecialchars($threats_name).'" href="javascript:select_text_range(\'ta_file\', '.$start.', '.$end.');">['.$f++.']</a>';
1424 }
1425 } else
1426 $fa = " No Threats Found";
1427 if (isset($_REQUEST["GOTMLS_fix"]) && is_array($_REQUEST["GOTMLS_fix"]) && in_array($encoded_id, $_REQUEST["GOTMLS_fix"]) && isset($_REQUEST["GOTMLS_fixing"]) && $_REQUEST["GOTMLS_fixing"] > 0) {
1428 if ($_REQUEST["GOTMLS_fixing"] > 1) {
1429 echo "<li>Removing $path ... ";
1430 $Q_post["post_status"] = "trash";
1431 if (wp_update_post($Q_post)) {
1432 echo __("Done!",'gotmls');
1433 $li_js .= "/*-->*"."/\nDeletedFile('$encoded_id');\n/*<!--*"."/";
1434 } else {
1435 echo __("Failed to delete!",'gotmls');
1436 $li_js .= "/*-->*"."/\nfailedFile('$encoded_id');\n/*<!--*"."/";
1437 }
1438 GOTMLS_update_scanlog(array("scan" => array("finish" => time(), "type" => "Removal of Revision")));
1439 } else {
1440 echo "<li>Fixing $path ... ";
1441 GOTMLS_write_quarantine($Q_post, "db_scan");
1442 $Q_post["post_content"] = $GLOBALS["GOTMLS"]["tmp"]["new_contents"];
1443 if (wp_update_post($Q_post)) {
1444 echo __("Success!",'gotmls');
1445 $li_js .= "/*-->*"."/\nfixedFile('$encoded_id');\n/*<!--*"."/";
1446 } else {
1447 echo __("Update Failed!",'gotmls');
1448 $li_js .= "/*-->*"."/\nfailedFile('$encoded_id');\n/*<!--*"."/";
1449 }
1450 GOTMLS_update_scanlog(array("scan" => array("finish" => time(), "type" => "Removal from Content")));
1451 }
1452 return $li_js;
1453 } else {
1454 return '<form style="margin: 0;" method="post" action="'.admin_url('admin-ajax.php?'.GOTMLS_set_nonce(__FUNCTION__."1448")).($Q_post["post_type"]=="revision"?'" onsubmit="return confirm(\''.__("Are you sure you want to delete this revision?",'gotmls').'\');"><input type="hidden" name="GOTMLS_fixing" value="2"><input type="hidden" name="action" value="GOTMLS_fix"><input type="submit" value="Delete this revision" style="float: right;"><input type="hidden" name="GOTMLS_fix[]" value="'.$encoded_id:"").'"></form><div id="fileperms" class="shadowed-box rounded-corners" style="display: none; position: absolute; left: 8px; top: 29px; background-color: #ccc; border: medium solid #C00; box-shadow: -3px 3px 3px #666; border-radius: 10px; padding: 10px;"><b>Record Details</b><br />encoding: '.(isset($GLOBALS["GOTMLS"]["tmp"]["encoding"])?$GLOBALS["GOTMLS"]["tmp"]["encoding"]:"Unknown").'<br />size: '.strlen(GOTMLS_convert_r($GLOBALS["GOTMLS"]["tmp"]["file_contents"])).' bytes<br />last_modified:'.$Q_post["post_modified_gmt"].'<br />post_type:'.$Q_post["post_type"].'<br />author:'.$Q_post["post_author"].'<br />status:'.$Q_post["post_status"].'</div><div style="overflow: auto;"><span onmouseover="document.getElementById(\'fileperms\').style.display=\'block\';" onmouseout="document.getElementById(\'fileperms\').style.display=\'none\';">'.__("Record Details:",'gotmls').'</span> ('.$fa.' )</div></td></tr><tr><td style="height: 100%"><textarea id="ta_file" style="width: 100%; height: 100%">'.GOTMLS_htmlentities(GOTMLS_convert_r($GLOBALS["GOTMLS"]["tmp"]["file_contents"])).'</textarea></td></tr></table>';
1455 }
1456 } else
1457 die(GOTMLS_html_tags(array("html" => array("body" => __("This record no longer exists.",'gotmls')."<br />\n<script type=\"text/javascript\">\nwindow.parent.showhide('GOTMLS_iFrame', true);\n</script>"))));
1458 } else {
1459 $threats_found = array();
1460 $and = "";
1461 if (!isset($_REQUEST["eli"]))
1462 $and .= " AND `post_status` != 'trash'";
1463 if (isset($_REQUEST["limit"]) && is_numeric($_REQUEST["limit"]))
1464 $and .= " LIMIT ".((INT) $_REQUEST["limit"]);
1465 if (isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["db_scan"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["db_scan"])) {
1466 if (isset($_GET["GOTMLS_scan"]) && strlen($_GET["GOTMLS_scan"]) > 8 && isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["db_scan"][substr($_GET["GOTMLS_scan"], 8)])) {
1467 $scan_replace = str_replace("db_scan", "Database for ", GOTMLS_htmlspecialchars($_GET["GOTMLS_scan"]));
1468 $db_scan_a = array(GOTMLS_sanitize(substr($_GET["GOTMLS_scan"], 8)) => $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["db_scan"][substr($_GET["GOTMLS_scan"], 8)]);
1469 } elseif (isset($_GET["GOTMLS_only_file"]) && strlen($_GET["GOTMLS_only_file"]) && isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["db_scan"][GOTMLS_decode($_GET["GOTMLS_only_file"])])) {
1470 $scan_replace = str_replace("db_scan", ("Database only $and for "), GOTMLS_htmlspecialchars("db_scan=".htmlspecialchars_decode(GOTMLS_decode($_GET["GOTMLS_only_file"]))));
1471 $_GET["GOTMLS_scan"] = "db_scan=".GOTMLS_decode($_GET["GOTMLS_only_file"]);
1472 $db_scan_a = array(GOTMLS_decode($_GET["GOTMLS_only_file"]) => $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["db_scan"][GOTMLS_decode($_GET["GOTMLS_only_file"])]);
1473 } else {
1474 $scan_replace = str_replace("db_scan", "Database", GOTMLS_htmlspecialchars($_GET["GOTMLS_scan"]));
1475 $db_scan_a = $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["db_scan"];
1476 }
1477 echo "/*<!--*"."/".GOTMLS_update_status(sprintf(__("Scanning %s",'gotmls'), $scan_replace));
1478 GOTMLS_flush();
1479 $li_js .= "/*<!--*"."/".GOTMLS_return_threat("dir", "checked", GOTMLS_htmlspecialchars($_GET["GOTMLS_scan"])).GOTMLS_update_status(sprintf(__("Scanned %s",'gotmls'), $scan_replace));
1480 } else {
1481 echo "/*<!--*"."/".GOTMLS_update_status(sprintf(__("No Definitions for DB Injections!",'gotmls')));
1482 GOTMLS_flush();
1483 $li_js .= GOTMLS_return_threat("error", "question", GOTMLS_htmlspecialchars($_GET["GOTMLS_scan"]));
1484 $db_scan_a = GOTMLS_sanitize($_GET["GOTMLS_scan"]);
1485 }
1486 if (isset($db_scan_a) && is_array($db_scan_a)) {
1487 echo "\n//memory_limit=".@ini_get("memory_limit")."\n";
1488 foreach ($db_scan_a as $scan_sql => $scan_regex) {
1489 if (!in_array(GOTMLS_sanitize($scan_sql), $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"])) {
1490 $SQL = preg_replace('/\{[a-f0-9]{64}\}/', '%', $wpdb->prepare("SELECT * FROM `$wpdb->posts` WHERE `post_content` LIKE %s $and", $scan_sql));
1491 $threat_name = array_shift($scan_regex);
1492 if (($found_row = $wpdb->get_results($SQL, ARRAY_A)) && is_array($found_row) && count($found_row)) {
1493 $val = count($found_row);
1494 if (isset($_REQUEST["eli"]) && ($_REQUEST["eli"] == "debug"))
1495 echo GOTMLS_return_threat("db_scan", "question", (print_r(array("scan_regex:"=>$scan_regex,"SQL:"=>$SQL),1)), GOTMLS_error_link("$val Rows", 0));//debug
1496 foreach ($found_row as $frow) {
1497 $encoded_id = GOTMLS_encode($frow["ID"].'.0');
1498 $found = 0;
1499 if ($frow["post_type"] != "revision" || isset($_REQUEST["eli"])) {
1500 GOTMLS_load_contents($frow["post_content"]);
1501 $not_serialized = !(is_array(GOTMLS_uckserialize($frow["post_content"])));
1502 $GLOBALS["GOTMLS"]["tmp"]["threats_found"] = array();
1503 $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["last_threat"] = microtime(true);
1504 foreach ($scan_regex as $threat_definition)
1505 $found += GOTMLS_preg_match_all($threat_definition, $threat_name, $not_serialized);
1506 if ($found && !isset($threats_found['row_id_'.$encoded_id])) {
1507 echo str_replace($frow["ID"].'</a>', '</a><a target="_blank" title="Open '.$frow["post_type"].'" href="'.admin_url(($frow["post_type"]=="revision")?'revision.php?revision='.$frow["ID"].'">View Revision: ':'post.php?action=edit&post='.$frow["ID"].'">Edit '.$frow["post_type"].': ').$frow["ID"].'</a>', GOTMLS_return_threat("db_scan", "threat", "$found $threat_name \"".str_replace('%', '*', trim($scan_sql, "%")).'" in '.$frow["post_type"]."(".(($frow["post_status"]=='inherit')?$frow["post_parent"]:$frow["post_status"]).'):"'.GOTMLS_htmlspecialchars($frow["post_title"]).'":'.$frow["ID"], '<input type="checkbox" name="GOTMLS_fix[]" id="check_'.$encoded_id.'" value="'.$encoded_id.'" checked="true">'.GOTMLS_error_link(__("View DB Injection",'gotmls'), $frow["ID"].'.0', "db_scan")));
1508 $threats_found['row_id_'.$encoded_id] = $threat_name;
1509 } elseif (isset($_REQUEST["eli"]) && ($_REQUEST["eli"] == "debug"))
1510 echo GOTMLS_return_threat("db_scan", "question", (print_r(array("post_id"=>$frow["ID"], "scan_regex:"=>$scan_regex,"SQL:"=>$SQL),1)), GOTMLS_error_link("No preg_match", 0));//debug
1511 }
1512 }
1513 }
1514 if (($found_row = $wpdb->get_results(preg_replace('/\{[a-f0-9]{64}\}/', '%', $wpdb->prepare("SELECT * FROM `$wpdb->options` WHERE `option_value` LIKE %s", $scan_sql)), ARRAY_A)) && is_array($found_row) && count($found_row)) {
1515 $val = count($found_row);
1516 if (isset($_REQUEST["eli"]) && ($_REQUEST["eli"] == "debug"))
1517 echo GOTMLS_return_threat("db_scan", "question", (print_r(array("scan_regex:"=>$scan_regex,"SQL:"=>$SQL),1)), GOTMLS_error_link("$val Rows", 0));//debug
1518 foreach ($found_row as $frow) {
1519 $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["last_threat"] = microtime(true);
1520 $GLOBALS["GOTMLS"]["tmp"]["threats_found"] = array();
1521 $encoded_id = GOTMLS_encode($frow["option_id"].'.1');
1522 $found = 0;
1523 GOTMLS_load_contents($frow["option_value"]);
1524 $not_serialized = !(is_array(GOTMLS_uckserialize($frow["option_value"])));
1525 foreach ($scan_regex as $threat_definition)
1526 $found += GOTMLS_preg_match_all($threat_definition, $threat_name, $not_serialized);
1527 if ($found && !isset($threats_found['row_id_'.$encoded_id])) {
1528 echo GOTMLS_return_threat("db_scan", "threat", "$found $threat_name \"".str_replace('%', '*', trim($scan_sql, "%")).'" in '."$wpdb->options:".GOTMLS_htmlspecialchars($frow["option_name"]).'":'.$frow["option_id"].'.1', '<input type="checkbox" name="GOTMLS_fix[]" id="check_'.$encoded_id.'" value="'.$encoded_id.'" checked="true">'.GOTMLS_error_link(__("View DB Injection",'gotmls'), $frow["option_id"].'.1', "db_scan"));
1529 $threats_found['row_id_'.$encoded_id] = $threat_name;
1530 } elseif (isset($_REQUEST["eli"]) && ($_REQUEST["eli"] == "debug"))
1531 echo GOTMLS_return_threat("db_scan", "question", (print_r(array("post_id"=>$frow["ID"], "scan_regex:"=>$scan_regex,"SQL:"=>$SQL),1)), GOTMLS_error_link("No preg_match", 0));//debug
1532 }
1533 }
1534 }
1535 }
1536 }
1537 //
1538 }
1539 } else {
1540 $li_js .= "/*<!--*"."/".GOTMLS_return_threat("skipdirs", "blocked", "db_scan").GOTMLS_update_status(__("Skipped DB Scan",'gotmls'));
1541 }
1542 GOTMLS_update_scanlog(array("scan" => array("finish" => time())));
1543 return "$li_js/*-->*"."/\nscanNextDir(-1);\n/*<!--*"."/";
1544 }
1545
1546 function GOTMLS_remove_dots($dir) {
1547 if ($dir != "." && $dir != "..")
1548 return $dir;
1549 }
1550
1551 function GOTMLS_getfiles($dir) {
1552 $files = false;
1553 if (is_dir($dir)) {
1554 if (function_exists("scandir"))
1555 $files = @scandir($dir);
1556 if (is_array($files))
1557 $files = array_filter($files, "GOTMLS_remove_dots");
1558 elseif ($handle = @opendir($dir)) {
1559 $files = array();
1560 while (false !== ($entry = readdir($handle)))
1561 if ($entry != "." && $entry != "..")
1562 $files[] = "$entry";
1563 closedir($handle);
1564 } else
1565 $files = GOTMLS_read_error($dir);
1566 }
1567 return $files;
1568 }
1569
1570 function GOTMLS_return_threat($className, $imageFile, $fileName, $link = "") {
1571 global $GOTMLS_image_alt;
1572 $fileNameJS = GOTMLS_strip4java(str_replace("db_scan", "Database", str_replace("db_scan=", "Database Query ", GOTMLS_replace_dirname(htmlspecialchars_decode($fileName)))));
1573 $fileName64 = GOTMLS_encode(htmlspecialchars_decode($fileName));
1574 $li_js = "/*-->*"."/";
1575 $imageF = explode(".", $imageFile.".");
1576 if ($className != "scanned")
1577 $li_js .= "\n$className++;\ndivx=document.getElementById('found_$className');\nif (divx) {\n\tvar newli = document.createElement('li');\n\tnewli.innerHTML='<img src=\"".GOTMLS_strip4java(GOTMLS_images_path.$imageFile).'.gif" height=16 width=16 alt="'.$GOTMLS_image_alt[$imageF[0]].'" style="float: left;" id="'.$imageFile."_$fileName64\">".GOTMLS_strip4java($link, true).$fileNameJS.($link?"</a>';\n\tdivx.display='block":"")."';\n\tdivx.appendChild(newli);\n}";
1578 if ($className == "errors")
1579 $li_js .= "\ndivx=document.getElementById('wait_$fileName64');\nif (divx) {\n\tdivx.src='".GOTMLS_images_path."blocked.gif';\n\tdirerrors++;\n}";
1580 elseif (is_file($fileName))
1581 $li_js .= "\nscanned++;\n";
1582 if ($className == "dir")
1583 $li_js .= "\ndivx=document.getElementById('wait_$fileName64');\nif (divx)\n\tdivx.src='".GOTMLS_images_path."checked.gif';";
1584 return $li_js."\n/*<!--*"."/";
1585 }
1586
1587 function GOTMLS_slash($dir = __FILE__) {
1588 if (substr($dir.' ', 1, 1) == ':' || substr($dir.' ', 0, 1) == "\\")
1589 return "\\";
1590 else
1591 return '/';
1592 }
1593
1594 function GOTMLS_trailingslashit($dir = "") {
1595 if (substr(' '.$dir, -1) != GOTMLS_slash($dir))
1596 $dir .= GOTMLS_slash($dir);
1597 return $dir;
1598 }
1599
1600 function GOTMLS_explode_dir($dir, $pre = '') {
1601 if (strlen($pre))
1602 $dir = GOTMLS_slash($dir).$pre.$dir;
1603 return explode(GOTMLS_slash($dir), $dir);
1604 }
1605
1606 function GOTMLS_html_tags($tags, $inner = array()) {
1607 $html = "";
1608 $gt = ">"; // This local variable never changes
1609 if (!is_array($tags))
1610 $tags = array($tags => (is_array($inner)?(isset($inner["contents"])?$inner["contents"]:""):$inner));
1611 foreach ($tags as $tag => $contents) {
1612 if (!is_numeric($tag))
1613 $html .= ($tag=="html"?"<!DOCTYPE html$gt":"")."<$tag".(isset($inner[$tag])?" ".$inner[$tag]:"").$gt;
1614 if (is_array($contents))
1615 $html .= GOTMLS_html_tags($contents, $inner);
1616 else
1617 $html .= $contents;
1618 if ((!is_numeric($tag)) && substr($tag, -1) != '/')
1619 $html .= "</$tag$gt";
1620 }
1621 return $html;
1622 }
1623
1624 function GOTMLS_write_quarantine($file, $className, $post_status = "private") {
1625 global $wpdb;
1626 $insert = array("post_author"=>GOTMLS_get_current_user_id(), "post_content"=>GOTMLS_encode($GLOBALS["GOTMLS"]["tmp"]["file_contents"]), "post_mime_type"=>md5($GLOBALS["GOTMLS"]["tmp"]["file_contents"]), "post_name"=>$className, "post_status"=>$post_status, "post_type"=>"GOTMLS_quarantine", "post_content_filtered"=>GOTMLS_encode($GLOBALS["GOTMLS"]["tmp"]["new_contents"]), "guid"=>GOTMLS_Version);
1627 if (isset($file["ID"]) && is_numeric($file["ID"])) {
1628 $insert["post_modified"] = $file["post_modified"];
1629 $insert["post_modified_gmt"] = $file["post_modified_gmt"];
1630 $file = $file["post_type"].':'.$file["ID"].':"'.$file["post_title"].'"';
1631 } elseif (isset($file["option_id"]) && is_numeric($file["option_id"])) {
1632 $insert["post_modified"] = gmdate("Y-m-d H:i:s");
1633 $insert["post_modified_gmt"] = gmdate("Y-m-d H:i:s");
1634 $file = $wpdb->options.':'.$file["option_id"].':"'.$file["option_name"].'"';
1635 }
1636 $insert["comment_count"] = strlen($GLOBALS["GOTMLS"]["tmp"]["file_contents"]);
1637 $insert["post_title"] = $file;
1638 $insert["post_date"] = gmdate("Y-m-d H:i:s");
1639 $insert["post_date_gmt"] = $insert["post_date"];
1640 if (is_file($file)) {
1641 if (@filemtime($file))
1642 $insert["post_modified"] = gmdate("Y-m-d H:i:s", filemtime($file));
1643 else
1644 $insert["post_modified"] = $insert["post_date"];
1645 if (@filectime($file))
1646 $insert["post_modified_gmt"] = gmdate("Y-m-d H:i:s", filectime($file));
1647 else
1648 $insert["post_modified_gmt"] = $insert["post_date"];
1649 if (!($insert["comment_count"] = @filesize($file)))
1650 $insert["comment_count"] = strlen($GLOBALS["GOTMLS"]["tmp"]["file_contents"]);
1651 }
1652 if (isset($GLOBALS["GOTMLS"]["tmp"]["threats_found"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["threats_found"])) {
1653 $insert["post_excerpt"] = GOTMLS_encode(@serialize($GLOBALS["GOTMLS"]["tmp"]["threats_found"]));
1654 $pinged = array();
1655 foreach ($GLOBALS["GOTMLS"]["tmp"]["threats_found"] as $loc => $threat_name) {
1656 if (isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["$className"]["$threat_name"][0]) && isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["$className"]["$threat_name"][1]) && strlen($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["$className"]["$threat_name"][0]) == 5 && strlen($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["$className"]["$threat_name"][1]))
1657 $ping = $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["$className"]["$threat_name"][1];
1658 else
1659 $ping = $threat_name;
1660 if (isset($pinged[$ping]))
1661 $pinged[$ping]++;
1662 else
1663 $pinged[$ping] = 1;
1664 }
1665 $insert["pinged"] = GOTMLS_encode(@serialize($pinged));
1666 }
1667 if ($return = $wpdb->insert($wpdb->posts, $insert))
1668 return $return;
1669 else
1670 die(print_r(array('return'=>($return===false)?"FALSE":$return, 'last_error'=>$wpdb->last_error, 'insert'=>$insert),1));
1671 }
1672
1673 function GOTMLS_update_status($status, $percent = -1) {
1674 if (!(isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"]) && is_numeric($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"])))
1675 $GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"] = time();
1676 $microtime = ceil(time()-$GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["start"]);
1677 if (($percent > 0) || isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["finish"]))
1678 GOTMLS_update_scanlog(array("scan" => array("microtime" => $microtime, "percent" => $percent)), $status);
1679 return "/*-->*"."/\nupdate_status('".GOTMLS_strip4java($status)."', $microtime, $percent);\n/*<!--*"."/";
1680 }
1681
1682 function GOTMLS_flush($tag = "") {
1683 $output = "";
1684 if (($output = @ob_get_contents()) && strlen(trim($output)) > 18) {
1685 @ob_clean();
1686 if (!(isset($_GET["eli"]) && $_GET["eli"] == "debug"))
1687 $output = preg_replace('/\/\*<\!--\*\/.*?\/\*-->\*\//s', "", "$output/*-->*"."/");
1688 echo "$output\n//flushed(".strlen(trim($output)).")\n";
1689 if ($tag)
1690 echo "\n</$tag>\n";
1691 if (@ob_get_length())
1692 @ob_flush();
1693 if ($tag)
1694 echo "<$tag>\n";
1695 echo "/*<!--*"."/";
1696 }
1697 }
1698
1699 function GOTMLS_replace_dirname($dir, $replace_with = "...") {
1700 return (isset($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["dir"]) ? str_replace(dirname($GLOBALS["GOTMLS"]["scan"]["log"]["scan"]["dir"]), "...", $dir) : $dir);
1701 }
1702
1703 function GOTMLS_readdir($dir, $current_depth = 1) {
1704 global $GOTMLS_dirs_at_depth, $GOTMLS_dir_at_depth, $GOTMLS_total_percent;
1705 if ($current_depth) {
1706 @set_time_limit($GLOBALS["GOTMLS"]["tmp"]['execution_time']);
1707 $entries = GOTMLS_getfiles($dir);
1708 if (is_array($entries)) {
1709 echo GOTMLS_return_threat("dirs", "wait", $dir).GOTMLS_update_status(sprintf(__("Preparing %s",'gotmls'), GOTMLS_replace_dirname($dir)), $GOTMLS_total_percent);
1710 $files = array();
1711 $directories = array();
1712 foreach ($entries as $entry) {
1713 if (is_dir(GOTMLS_trailingslashit($dir).$entry))
1714 $directories[] = $entry;
1715 else
1716 $files[] = $entry;
1717 }
1718 if ($_REQUEST["scan_type"] == "Quick Scan") {
1719 $GOTMLS_dirs_at_depth[$current_depth] = count($directories);
1720 $GOTMLS_dir_at_depth[$current_depth] = 0;
1721 } else
1722 $GLOBALS["GOTMLS"]["tmp"]["scanfiles"][GOTMLS_encode($dir)] = GOTMLS_strip4java(GOTMLS_replace_dirname($dir));
1723 foreach ($directories as $directory) {
1724 $path = GOTMLS_trailingslashit($dir).$directory;
1725 if (isset($_REQUEST["scan_depth"]) && is_numeric($_REQUEST["scan_depth"]) && ($_REQUEST["scan_depth"] != $current_depth) && (!((($Recusive = strpos(GOTMLS_trailingslashit($dir), '/'.$directory.'/')) !== FALSE) && is_dir($dir.substr($dir, $Recusive).substr($dir, $Recusive).substr($dir, $Recusive)))) && !in_array($directory, $GLOBALS["GOTMLS"]["tmp"]["skip_dirs"]) && !in_array($path, $GLOBALS["GOTMLS"]["tmp"]["skip_dirs"])) {
1726 $current_depth++;
1727 $current_depth = GOTMLS_readdir($path, $current_depth);
1728 } else {
1729 if (!(isset($_REQUEST["scan_only"]) && is_array($_REQUEST["scan_only"])&& in_array($directory, $_REQUEST["scan_only"])))
1730 echo GOTMLS_return_threat("skipdirs", "blocked", $path, '<a title="'.(in_array($directory, $GLOBALS["GOTMLS"]["tmp"]["skip_dirs"])||in_array($path, $GLOBALS["GOTMLS"]["tmp"]["skip_dirs"])?"Directory is on Skip List":"Directory is below Scan Depth").'">');
1731 $GOTMLS_dir_at_depth[$current_depth] = (isset($GOTMLS_dir_at_depth[$current_depth])?$GOTMLS_dir_at_depth[$current_depth]:0) + 1;
1732 }
1733 }
1734 if ($_REQUEST["scan_type"] == "Quick Scan") {
1735 $echo = "";
1736 echo GOTMLS_update_status(sprintf(__("Scanning %s",'gotmls'), GOTMLS_replace_dirname($dir)), $GOTMLS_total_percent);
1737 GOTMLS_flush("script");
1738 foreach ($files as $file)
1739 echo GOTMLS_check_file(GOTMLS_trailingslashit($dir).$file);
1740 echo GOTMLS_return_threat("dir", "checked", $dir);
1741 }
1742 } else
1743 echo GOTMLS_return_threat("errors", "blocked", $dir, GOTMLS_error_link(GOTMLS_Failed_to_list_LANGUAGE.' readdir:'.($entries===false?'('.GOTMLS_fileperms($dir).')':$entries)));
1744 @set_time_limit($GLOBALS["GOTMLS"]["tmp"]['execution_time']);
1745 if ($current_depth-- && $_REQUEST["scan_type"] == "Quick Scan") {
1746 $GOTMLS_dir_at_depth[$current_depth] = (isset($GOTMLS_dir_at_depth[$current_depth])?$GOTMLS_dir_at_depth[$current_depth]:0) + 1;
1747 for ($GOTMLS_total_percent = 0, $depth = $current_depth; $depth >= 0; $depth--) {
1748 if (!isset($GOTMLS_dir_at_depth[$depth]))
1749 $GOTMLS_dir_at_depth[$depth] = 0;
1750 echo "\n//(($GOTMLS_total_percent / $GOTMLS_dirs_at_depth[$depth]) + ($GOTMLS_dir_at_depth[$depth] / $GOTMLS_dirs_at_depth[$depth])) = ";
1751 $GOTMLS_total_percent = (($GOTMLS_dirs_at_depth[$depth]?($GOTMLS_total_percent / $GOTMLS_dirs_at_depth[$depth]):0) + ($GOTMLS_dir_at_depth[$depth] / ($GOTMLS_dirs_at_depth[$depth]+1)));
1752 echo "$GOTMLS_total_percent\n";
1753 }
1754 $GOTMLS_total_percent = floor($GOTMLS_total_percent * 100);
1755 echo GOTMLS_update_status(sprintf(__("Scanned %s",'gotmls'), GOTMLS_replace_dirname($dir)), $GOTMLS_total_percent);
1756 }
1757 GOTMLS_flush("script");
1758 }
1759 return $current_depth;
1760 }
1761
1762 function GOTMLS_sexagesimal($timestamp = 0) {
1763 if (!is_numeric($timestamp) && strlen($timestamp) == 5) {
1764 $delim = array("=", "-", "-", " ", ":");
1765 foreach (str_split($timestamp) as $bit)
1766 $timestamp .= array_shift($delim).substr("00".(ord($bit)>96?ord($bit)-61:(ord($bit)>64?ord($bit)-55:ord($bit)-48)), -2);
1767 return "20".substr($timestamp, -14);
1768 } else {
1769 $match = '/^(20)?([0-5][0-9])[\-: \/]*(0*[1-9]|1[0-2])[\-: \/]*(0*[1-9]|[12][0-9]|3[01])[\-: \/]*([0-5][0-9])[\-: \/]*([0-5][0-9])$/';
1770 if (preg_match($match, $timestamp))
1771 $date = preg_replace($match, "\\2-\\3-\\4-\\5-\\6", $timestamp);
1772 elseif ($timestamp && strtotime($timestamp))
1773 $date = date("y-m-d-H-i", strtotime($timestamp));
1774 else
1775 $date = gmdate("y-m-d-H-i", time());
1776 foreach (explode("-", $date) as $bit)
1777 $date .= (intval($bit)>35?chr(ord("a")+intval($bit)-36):(intval($bit)>9?chr(ord("A")+intval($bit)-10):substr('0'.$bit, -1)));
1778 return substr($date, -5);
1779 }
1780 }
1781
1782 if (!function_exists('ur1encode')) { function ur1encode($url) {
1783 $return = "";
1784 foreach (str_split($url) as $char)
1785 $return .= '%'.substr('00'.strtoupper(dechex(ord($char))),-2);
1786 return $return;
1787 }}
1788
1789 function GOTMLS_strip4java($item, $htmlentities = false) {
1790 return preg_replace("/\\\\/", "\\\\\\\\", str_replace("'", "'+\"'\"+'", preg_replace('/\\+n|\\+r|\n|\r|\0/', "", ($htmlentities?$item:GOTMLS_htmlentities($item)))));
1791 }
1792
1793 function GOTMLS_error_link($errorTXT, $file = "", $class = "errors") {
1794 global $post, $wpdb;
1795 $encoded_file = GOTMLS_encode($file);
1796 $ids = explode(".", $file.'.');
1797 if (isset($post->post_title))
1798 $js_file = GOTMLS_strip4java(GOTMLS_htmlspecialchars($post->post_title, ENT_NOQUOTES));
1799 elseif (count($ids) > 2 && 'tbl'.$ids[1] == 'tbl1' && is_numeric($ids[0]))
1800 $js_file = GOTMLS_strip4java(GOTMLS_htmlspecialchars($wpdb->get_var($wpdb->prepare("SELECT CONCAT('option', `option_id`, ': ', `option_name`) FROM `$wpdb->options` WHERE `option_id` = %s", (INT) $ids[0])), ENT_NOQUOTES));
1801 elseif (count($ids) > 2 && 'tbl'.$ids[1] == 'tbl0' && is_numeric($ids[0]))
1802 $js_file = GOTMLS_strip4java(GOTMLS_htmlspecialchars($wpdb->get_var($wpdb->prepare("SELECT CONCAT(`post_type`, `ID`, ': ', `post_title`) FROM `$wpdb->posts` WHERE `ID` = %s", (INT) $ids[0])), ENT_NOQUOTES));
1803 else
1804 $js_file = GOTMLS_strip4java(GOTMLS_htmlspecialchars($file, ENT_NOQUOTES));
1805 $nonce_url = GOTMLS_set_nonce(__FUNCTION__."1823");
1806 if (count($ids) == 2 && is_numeric($ids[0])) {
1807 $encoded_file = (INT) $file;
1808 $onclick = 'loadIframe(\''.str_replace("\"", "&quot;", '<div style="float: left; white-space: nowrap;">'.GOTMLS_strip4java(__("Examine Quarantined Content",'gotmls')).' ... </div><div style="overflow: hidden; position: relative; height: 20px;"><div style="position: absolute; right: 0px; text-align: right; width: 9000px;">'.$js_file).'</div></div>\');" href="'.GOTMLS_admin_url('GOTMLS_scan', $nonce_url.'&mt='.$GLOBALS["GOTMLS"]["tmp"]["mt"].'&GOTMLS_scan='.$encoded_file);
1809 } elseif ($file)
1810 $onclick = 'loadIframe(\''.str_replace("\"", "&quot;", '<div style="float: left; white-space: nowrap;">'.GOTMLS_strip4java(__("Examine Current Content",'gotmls')).' ... </div><div style="overflow: hidden; position: relative; height: 20px;"><div style="position: absolute; right: 0px; text-align: right; width: 9000px;">'.$js_file).'</div></div>\');" href="'.GOTMLS_admin_url('GOTMLS_scan', $nonce_url.'&mt='.$GLOBALS["GOTMLS"]["tmp"]["mt"].'&GOTMLS_scan='.$encoded_file);
1811 else
1812 $onclick = 'return false;';
1813 return "<a id=\"list_$encoded_file\" title=\"$errorTXT\" target=\"GOTMLS_iFrame\" onclick=\"$onclick\" class=\"GOTMLS_plugin $class\">";
1814 }
1815
1816 function GOTMLS_check_file($file) {
1817 $filesize = @filesize($file);
1818 $MD5O = @md5_file($file)."O";
1819 echo "/*-->*"."/\ndocument.getElementById('status_text').innerHTML='Checking ".GOTMLS_strip4java($file)." ($filesize bytes)';\n/*<!--*"."/";
1820 if ($filesize===false)
1821 echo GOTMLS_return_threat("errors", "blocked", $file, GOTMLS_error_link(__("Failed to determine file size!",'gotmls'), $file));
1822 elseif (GOTMLS_is_whitelisted($MD5O.$filesize, $file))
1823 echo GOTMLS_return_threat("scanned", "checked", $file, GOTMLS_error_link(__("CORE file was not modified!",'gotmls'), $file, ""));
1824 elseif (($filesize==0) || ($filesize>((isset($_REQUEST["oversize"])&&is_numeric($_REQUEST["oversize"]))?$_REQUEST["oversize"]:2934567)))
1825 echo GOTMLS_return_threat("skipped", "blocked", $file, GOTMLS_error_link(__("Skipped because of file size!",'gotmls')." ($filesize bytes)", $file, "potential"));
1826 elseif (in_array(GOTMLS_get_ext($file), $GLOBALS["GOTMLS"]["tmp"]["skip_ext"]) && !(preg_match('/(?:(?:shim|social\d*+)\.png|\/\.[^\/]++)$/i', $file)))
1827 echo GOTMLS_return_threat("skipped", "blocked", $file, GOTMLS_error_link(__("Skipped because of file extention!",'gotmls'), $file, "potential"));
1828 elseif (isset($GLOBALS["GOTMLS"]["tmp"]["custom_whitelist"]) && isset($GLOBALS["GOTMLS"]["tmp"]["custom_whitelist"]["$MD5O$filesize"]))
1829 echo GOTMLS_return_threat("skipped", "blocked", $file, GOTMLS_error_link(__("Skipped because file was Whitelisted!",'gotmls'), $file, "potential"));
1830 else {
1831 try {
1832 echo @GOTMLS_scanfile($file);
1833 echo "/*-->*"."/\n//debug_fix:".$GLOBALS["GOTMLS"]["tmp"]["debug_fix"]."\n/*<!--*"."/";
1834 } catch (Exception $e) {
1835 die("//Exception:".GOTMLS_strip4java($e));
1836 }
1837 }
1838 echo "/*-->*"."/\ndocument.getElementById('status_text').innerHTML='Checked ".GOTMLS_strip4java($file)."';\n/*<!--*"."/";
1839 }
1840
1841 function GOTMLS_read_error($path) {
1842 $error = error_get_last();
1843 if (!file_exists($path))
1844 return " (Path not found)";
1845 if (!is_readable($path) && isset($_GET["eli"]))
1846 $return = (@chmod($path, (is_dir($path)?GOTMLS_CHMOD_DIR:GOTMLS_CHMOD_FILE))?"Fixed permissions":"error: ".preg_replace('/[\r\n]/', ' ', print_r($error,1)));
1847 else
1848 $return = (is_array($error) && isset($error["message"])?preg_replace('/[\r\n]/', ' ', print_r($error["message"],1)):"readable?");
1849 return " [".GOTMLS_fileperms($path)."] ( ".filesize($path)." $return)";
1850 }
1851
1852 function GOTMLS_scandir($dir) {
1853 echo "/*<!--*"."/".GOTMLS_update_status(sprintf(__("Scanning %s",'gotmls'), GOTMLS_replace_dirname(GOTMLS_htmlspecialchars($dir))));
1854 GOTMLS_flush();
1855 $li_js = "/*-->*"."/\nscanNextDir(-1);\n/*<!--*"."/";
1856 if (!(isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_depth"]) && $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_depth"]))
1857 echo GOTMLS_return_threat("errors", "blocked", $dir, GOTMLS_error_link("Directory Scan Depth set to 0, no files will be scanned!"));
1858 elseif (isset($_GET["GOTMLS_skip_dir"]) && $dir == GOTMLS_decode($_GET["GOTMLS_skip_dir"])) {
1859 if (isset($_GET["GOTMLS_only_file"]) && strlen($_GET["GOTMLS_only_file"]))
1860 echo GOTMLS_return_threat("errors", "blocked", GOTMLS_trailingslashit($dir).GOTMLS_decode($_GET["GOTMLS_only_file"]), GOTMLS_error_link("Failed to read this file!".GOTMLS_read_error(GOTMLS_trailingslashit($dir).GOTMLS_decode($_GET["GOTMLS_only_file"])), GOTMLS_trailingslashit($dir).GOTMLS_decode($_GET["GOTMLS_only_file"])));
1861 else
1862 echo GOTMLS_return_threat("errors", "blocked", $dir, GOTMLS_error_link(__("Failed to read directory!",'gotmls')).GOTMLS_read_error($dir));
1863 } else {
1864 if (is_dir($dir) && is_array($files = GOTMLS_getfiles($dir))) {
1865 if (isset($_GET["GOTMLS_only_file"])) {
1866 if (strlen($_GET["GOTMLS_only_file"])) {
1867 $path = GOTMLS_trailingslashit($dir).GOTMLS_decode($_GET["GOTMLS_only_file"]);
1868 if (is_file($path)) {
1869 GOTMLS_check_file($path);
1870 echo GOTMLS_return_threat("dir", "checked", $path);
1871 }
1872 } else {
1873 foreach ($files as $file) {
1874 $path = GOTMLS_trailingslashit($dir).$file;
1875 if (is_file($path)) {
1876 $file_ext = GOTMLS_get_ext($file);
1877 $filesize = @filesize($path);
1878 if ((in_array($file_ext, $GLOBALS["GOTMLS"]["tmp"]["skip_ext"]) && !(preg_match('/(?:(?:shim|social\d*+)\.png|\/\.[^\/]++)$/i', $file))) || ($filesize==0) || ($filesize>((isset($_REQUEST["oversize"])&&is_numeric($_REQUEST["oversize"]))?$_REQUEST["oversize"]:2934567)))
1879 echo GOTMLS_return_threat("skipped", "blocked", $path, GOTMLS_error_link(sprintf(__('Skipped because of file size (%1$s bytes) or file extention (%2$s)!','gotmls'), $filesize, $file_ext), $file, "potential"));
1880 else
1881 echo "/*-->*"."/\nscanfilesArKeys.push('".GOTMLS_encode($dir)."&GOTMLS_only_file=".GOTMLS_encode($file, "D")."');\nscanfilesArNames.push('Re-Checking ".GOTMLS_strip4java($path)."');\n/*<!--*"."/".GOTMLS_return_threat("dirs", "wait", $path);
1882 } elseif (is_dir($path)) {
1883 echo "/*-->*"."/\n//sub-directory $path;\n/*<!--*"."/";
1884 }
1885 }
1886 echo GOTMLS_return_threat("dir", "question", $dir);
1887 }
1888 } else {
1889 foreach ($files as $file) {
1890 $path = GOTMLS_trailingslashit($dir).$file;
1891 if (is_file($path)) {
1892 if (isset($_GET["GOTMLS_skip_file"]) && is_array($_GET["GOTMLS_skip_file"]) && in_array($path, $_GET["GOTMLS_skip_file"])) {
1893 $li_js .= "/*-->*"."/\n//skipped $path;\n/*<!--*"."/";
1894 if ($_GET["GOTMLS_skip_file"][count($_GET["GOTMLS_skip_file"])-1] == $path)
1895 echo GOTMLS_return_threat("errors", "blocked", $path, GOTMLS_error_link(__("Failed to read file!",'gotmls'), $path));
1896 } else {
1897 GOTMLS_check_file($path);
1898 }
1899 } elseif (is_dir($path)) {
1900 $li_js .= "/*-->*"."/\n//sub-directory $path;\n/*<!--*"."/";
1901 }
1902 }
1903 echo GOTMLS_return_threat("dir", "checked", $dir);
1904 }
1905 } else
1906 echo GOTMLS_return_threat("errors", "blocked", $dir, GOTMLS_error_link(GOTMLS_Failed_to_list_LANGUAGE.' scandir:'.($files===false?' (FALSE)':$files)));
1907 }
1908 echo GOTMLS_update_status(sprintf(__("Scanned %s",'gotmls'), GOTMLS_replace_dirname($dir)));
1909 return $li_js;
1910 }
1911
1912 function GOTMLS_safe_domain($domain) {
1913 return preg_replace('/[^a-z_0-9\-\~\+\.\?\#\/\:\@]/i', "", $domain);
1914 }
1915
1916 function GOTMLS_safe_url($url, $allow = array(' ', '%20')) {
1917 $all = implode("", array_keys($allow));
1918 $url = preg_replace('/[^a-z_0-9\-\~\+\.\?\#\/\:\@\%\$\|\*\(\)\[\]\=\!\&\;'.$all.']/i', "", $url);
1919 foreach ($allow as $al => $low)
1920 $url = str_replace($al, $low, ltrim($url));
1921 return $url;
1922 }
1923
1924 function GOTMLS_reset_settings($item, $key) {
1925 $key_parts = explode("_", $key."_");
1926 if (strlen($key_parts[0]) != 4 && $key_parts[0] != "exclude")
1927 unset($GLOBALS["GOTMLS"]["tmp"]["settings_array"][$key]);
1928 }
1929
1930 function GOTMLS_sanitize($unsanitized, $allow = 'a-zA-Z0-9\|\[\]\{\}<>\s\?\*\%\#\&\/=_\~\:;\.,\+-') {
1931 if (is_array($unsanitized)) {
1932 $sanitized = array();
1933 foreach ($unsanitized as $key => $val)
1934 $sanitized[preg_replace('/[^'.$allow.']/', '', $key)] = preg_replace('/[^'.$allow.']/', '', $val);
1935 } else
1936 $sanitized = preg_replace('/[^'.$allow.']/', '', $unsanitized);
1937 return $sanitized;
1938 }
1939
1940 function GOTMLS_get_URL($URL) {
1941 $response = "";
1942 $GLOBALS["GOTMLS"]["get_URL"] = GOTMLS_get_option('get_URL', array());
1943 $min = round($GLOBALS["GOTMLS"]["MT"]/60);
1944 if (is_array($GLOBALS["GOTMLS"]["get_URL"]) && !preg_match('/\&dt=\d++/', $URL)) {
1945 foreach ($GLOBALS["GOTMLS"]["get_URL"] as $URI => $property)
1946 if (!(isset($property["time"]) && is_numeric($property["time"]) && ($property["time"] + 30) > $min))
1947 unset($GLOBALS["GOTMLS"]["get_URL"]["$URI"]);
1948 } else
1949 $GLOBALS["GOTMLS"]["get_URL"] = array();
1950 $URI = md5(preg_replace('/GOTMLS_mt[\[\]]*=[0-9a-f]*/i', "", $URL));
1951 if (isset($GLOBALS["GOTMLS"]["get_URL"]["$URI"]["response"]) && strlen($response = GOTMLS_decode($GLOBALS["GOTMLS"]["get_URL"]["$URI"]["response"])))
1952 $method = "cached";
1953 else {
1954 $GLOBALS["GOTMLS"]["get_URL"]["$URI"] = array("time" => $min);
1955 if (function_exists($method = "wp_remote_get")) {
1956 $GLOBALS["GOTMLS"]["get_URL"]["$URI"][$method] = wp_remote_get($URL, array("sslverify" => false));
1957 if (200 == wp_remote_retrieve_response_code($GLOBALS["GOTMLS"]["get_URL"]["$URI"][$method]))
1958 $response = wp_remote_retrieve_body($GLOBALS["GOTMLS"]["get_URL"]["$URI"][$method]);
1959 }
1960 if (strlen($response) == 0 && function_exists($method = "curl_exec")) {
1961 $curl_hndl = curl_init();
1962 curl_setopt($curl_hndl, CURLOPT_URL, $URL);
1963 curl_setopt($curl_hndl, CURLOPT_TIMEOUT, 30);
1964 if (isset($_SERVER['HTTP_REFERER']))
1965 $SERVER_HTTP_REFERER = GOTMLS_safe_url($_SERVER['HTTP_REFERER']);
1966 elseif (isset($_SERVER['HTTP_HOST']))
1967 $SERVER_HTTP_REFERER = 'HOST://'.GOTMLS_safe_domain($_SERVER['HTTP_HOST']);
1968 elseif (isset($_SERVER['SERVER_NAME']))
1969 $SERVER_HTTP_REFERER = 'NAME://'.GOTMLS_safe_domain($_SERVER['SERVER_NAME']);
1970 elseif (isset($_SERVER['SERVER_ADDR']))
1971 $SERVER_HTTP_REFERER = 'ADDR://'.GOTMLS_safe_ip($_SERVER['SERVER_ADDR']);
1972 else
1973 $SERVER_HTTP_REFERER = 'NULL://not.anything.com';
1974 curl_setopt($curl_hndl, CURLOPT_REFERER, $SERVER_HTTP_REFERER);
1975 if (isset($_SERVER['HTTP_USER_AGENT']))
1976 curl_setopt($curl_hndl, CURLOPT_USERAGENT, GOTMLS_safe_url($_SERVER['HTTP_USER_AGENT'], array(' ', ' ')));
1977 curl_setopt($curl_hndl, CURLOPT_HEADER, 0);
1978 curl_setopt($curl_hndl, CURLOPT_RETURNTRANSFER, TRUE);
1979 if (!($response = curl_exec($curl_hndl)))
1980 $GLOBALS["GOTMLS"]["get_URL"]["$URI"][$method] = curl_error($curl_hndl);
1981 curl_close($curl_hndl);
1982 }
1983 if (strlen($response) == 0 && function_exists($method = "file_get_contents")) {
1984 try {
1985 $response = @file_get_contents($URL).'';
1986 } catch(Exception $e) {
1987 $GLOBALS["GOTMLS"]["get_URL"]["$URI"][$method] = $e->getTrace();
1988 }
1989 }
1990 $GLOBALS["GOTMLS"]["get_URL"]["$URI"]["response"] = GOTMLS_encode($response);
1991 }
1992 GOTMLS_update_option('get_URL', $GLOBALS["GOTMLS"]["get_URL"], false);
1993 if (isset($_GET["GOTMLS_debug"]) && (strlen($response) == 0 || $_GET["GOTMLS_debug"] == "GOTMLS_get_URL"))
1994 print_r(array("$method $URI:".strlen($response)=>htmlspecialchars($GLOBALS["GOTMLS"]["get_URL"]["$URI"]["time"]." ~ $min: ".count($GLOBALS["GOTMLS"]["get_URL"]))));
1995 return $response;
1996 }
1997