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