PluginProbe ʕ •ᴥ•ʔ
Anti-Malware Security and Brute-Force Firewall / 4.16.17
Anti-Malware Security and Brute-Force Firewall v4.16.17
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 / index.php
gotmls Last commit date
images 10 years ago languages 10 years ago safe-load 10 years ago index.php 10 years ago readme.txt 10 years ago
index.php
1639 lines
1 <?php
2 /*
3 Plugin Name: Anti-Malware Security and Brute-Force Firewall
4 Plugin URI: http://gotmls.net/
5 Author: Eli Scheetz
6 Text Domain: gotmls
7 Author URI: http://wordpress.ieonly.com/category/my-plugins/anti-malware/
8 Contributors: scheeeli, gotmls
9 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZHD8QHZ2E7PE
10 Description: This Anti-Virus/Anti-Malware plugin searches for Malware and other Virus like threats and vulnerabilities on your server and helps you remove them. It's always growing and changing to adapt to new threats so let me know if it's not working for you.
11 Version: 4.16.17
12 */
13 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__)))
14 include(dirname(__FILE__)."/safe-load/index.php");
15 else
16 require_once(dirname(__FILE__)."/images/index.php");
17 /* ___
18 * / /\ GOTMLS Main Plugin File
19 * / /:/ @package GOTMLS
20 * /__/::\
21 Copyright \__\/\:\__ © 2012-2016 Eli Scheetz (email: eli@gotmls.net)
22 * \ \:\/\
23 * \__\::/ This program is free software; you can redistribute it
24 * ___ /__/:/ and/or modify it under the terms of the GNU General Public
25 * /__/\ _\__\/ License as published by the Free Software Foundation;
26 * \ \:\ / /\ either version 2 of the License, or (at your option) any
27 * ___\ \:\ /:/ later version.
28 * / /\\ \:\/:/
29 / /:/ \ \::/ This program is distributed in the hope that it will be useful,
30 / /:/_ \__\/ but WITHOUT ANY WARRANTY; without even the implied warranty
31 /__/:/ /\__ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
32 \ \:\/:/ /\ See the GNU General Public License for more details.
33 \ \::/ /:/
34 \ \:\/:/ You should have received a copy of the GNU General Public License
35 * \ \::/ with this program; if not, write to the Free Software Foundation,
36 * \__\/ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
37
38 load_plugin_textdomain('gotmls', false, basename(GOTMLS_plugin_path).'/languages');
39 require_once(GOTMLS_plugin_path.'images/index.php');
40
41 function GOTMLS_install() {
42 global $wp_version;
43 if (version_compare($wp_version, GOTMLS_require_version, "<"))
44 die(GOTMLS_require_version_LANGUAGE);
45 }
46 register_activation_hook(__FILE__, "GOTMLS_install");
47
48 function GOTMLS_user_can() {
49 if (is_multisite())
50 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"] = "manage_network";
51 elseif (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"]) || $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"] == "manage_network")
52 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"] = "activate_plugins";
53 if (current_user_can($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"]))
54 return true;
55 else
56 return false;
57 }
58
59 function GOTMLS_menu() {
60 $GOTMLS_Full_plugin_logo_URL = GOTMLS_images_path.'GOTMLS-16x16.gif';
61 $base_page = "GOTMLS-settings";
62 $base_function = "GOTMLS_settings";
63 $pluginTitle = "Anti-Malware";
64 $pageTitle = "$pluginTitle ".GOTMLS_Scan_Settings_LANGUAGE;
65 if (GOTMLS_user_can()) {
66 $my_admin_page = add_menu_page($pageTitle, $pluginTitle, $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"], $base_page, $base_function, $GOTMLS_Full_plugin_logo_URL);
67 add_action('load-'.$my_admin_page, 'GOTMLS_admin_add_help_tab');
68 add_submenu_page($base_page, "$pluginTitle ".GOTMLS_Scan_Settings_LANGUAGE, GOTMLS_Scan_Settings_LANGUAGE, $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"], $base_page, $base_function);
69 add_submenu_page($base_page, "$pluginTitle Firewall Options", "Firewall Options", $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"], "GOTMLS-Firewall-Options", "GOTMLS_Firewall_Options");
70 add_submenu_page($base_page, "$pluginTitle ".GOTMLS_View_Quarantine_LANGUAGE, GOTMLS_View_Quarantine_LANGUAGE.(($Qs = GOTMLS_get_quarantine(true))?' <span class="awaiting-mod count-'.$Qs.'"><span class="awaiting-mod">'.$Qs.'</span></span>':""), $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"], "GOTMLS-View-Quarantine", "GOTMLS_View_Quarantine");
71 }
72 }
73
74 function GOTMLS_admin_add_help_tab() {
75 $screen = get_current_screen();
76 $screen->add_help_tab(array(
77 'id' => "GOTMLS_Getting_Started",
78 'title' => __("Getting Started", 'gotmls'),
79 'content' => '<p>'.__("Make sure the Definition Updates are current and Run a Complete Scan.").'</p><p>'.sprintf(__("If Known Threats are found and displayed in red then there will be a button to '%s'. If only Potentional Threats are found then there is no automatic fix because those are probably not malicious."), GOTMLS_Automatically_Fix_LANGUAGE).'</p><p>'.__("A backup of the original infected files are placed in the Quarantine in case you need to restore them or just want to look at them later. You can delete these files if you don't want to save more.").'</p>'
80 ));
81 $FAQMarker = '== Frequently Asked Questions ==';
82 if (is_file(dirname(__FILE__).'/readme.txt') && ($readme = explode($FAQMarker, @file_get_contents(dirname(__FILE__).'/readme.txt').$FAQMarker)) && strlen($readme[1]) && ($readme = explode("==", $readme[1]."==")) && strlen($readme[0])) {
83 $screen->add_help_tab(array(
84 'id' => "GOTMLS_FAQs",
85 'title' => __("FAQs", 'gotmls'),
86 'content' => '<p>'.preg_replace('/\[(.+?)\]\((.+?)\)/', "<a target=\"_blank\" href=\"\\2\">\\1</a>", preg_replace('/[\r\n]+= /', "</p><b>", preg_replace('/ =[\r\n]+/', "</b><p>", $readme[0]))).'</p>'
87 ));
88 }
89 }
90
91 function GOTMLS_close_button($box_id, $margin = '6px') {
92 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>';
93 }
94
95 function GOTMLS_enqueue_scripts() {
96 wp_enqueue_style('dashicons');
97 }
98 add_action('admin_enqueue_scripts', 'GOTMLS_enqueue_scripts');
99
100 function GOTMLS_display_header($optional_box = "") {
101 global $wp_version, $current_user;
102 get_currentuserinfo();
103 $GOTMLS_url_parts = explode('/', GOTMLS_siteurl);
104 if (isset($_GET["check_site"]) && $_GET["check_site"])
105 echo '<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">window.parent.document.getElementById("check_site_warning").style.backgroundColor=\'#0C0\';</script><li>Please <a target="_blank" href="https://wordpress.org/plugins/gotmls/stats/?compatibility%5Bversion%5D='.$wp_version.'&compatibility%5Btopic_version%5D='.GOTMLS_Version.'&compatibility%5Bcompatible%5D=1#compatibility-works">Vote "Works"</a> or <a target="_blank" href="https://wordpress.org/support/view/plugin-reviews/gotmls#postform">write a "Five-Star" Reviews</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, .update-nag {display: none !important;} #wpbody-content {padding-bottom: 0;} #wpbody, html.wp-toolbar {padding-top: 0 !important;} #wpcontent, #footer {margin-left: 5px !important;}';
106 else
107 echo '<style>#GOTMLS-right-sidebar {float: right; margin-right: 0px;}';
108 $Update_Definitions = GOTMLS_plugin_home.'definitions.js'.$GLOBALS["GOTMLS"]["tmp"]["Definition"]["Updates"].'&js='.GOTMLS_Version.'&p=GOTMLS&wp='.$wp_version.'&ts='.date("YmdHis").'&key='.GOTMLS_installation_key.'&d='.ur1encode(GOTMLS_siteurl);
109 $Update_Link = '<div style="text-align: center;"><a href="';
110 $new_version = "";
111 $file = basename(GOTMLS_plugin_path).'/index.php';
112 $current = get_site_transient("update_plugins");
113 if (isset($current->response[$file]->new_version) && version_compare(GOTMLS_Version, $current->response[$file]->new_version, "<")) {
114 $new_version = sprintf(__("Upgrade to %s now!",'gotmls'), $current->response[$file]->new_version).'<br /><br />';
115 $Update_Link .= wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$file, 'upgrade-plugin_'.$file);
116 }
117 $Update_Link .= "\">$new_version</a></div>";
118 $defLatest = (is_numeric($Latest = preg_replace('/[^0-9]/', "", GOTMLS_sexagesimal($GLOBALS["GOTMLS"]["tmp"]["Definition"]["Latest"]))) && is_numeric($Default = preg_replace('/[^0-9]/', "", GOTMLS_sexagesimal($GLOBALS["GOTMLS"]["tmp"]["Definition"]["Default"]))) && $Latest > $Default)?1:0;
119 if (is_array($keys = maybe_unserialize(get_option('GOTMLS_Installation_Keys', array()))) && array_key_exists(GOTMLS_installation_key, $keys))
120 $isRegistered = $keys[GOTMLS_installation_key];
121 else
122 $isRegistered = "";
123 $Update_Div ='<div id="findUpdates" style="display: none;"><center>'.__("Searching for updates ...",'gotmls').'<br /><img src="'.GOTMLS_images_path.'wait.gif" height=16 width=16 alt="Wait..." /><br /><input type="button" value="Cancel" onclick="cancelserver(\'findUpdates\');" /></center></div>';
124 echo '
125 span.GOTMLS_date {float: right; width: 130px; white-space: nowrap;}
126 .GOTMLS_page {float: left; border-radius: 10px; padding: 0 5px;}
127 .GOTMLS_quarantine_item {margin: 4px 12px;}
128 .rounded-corners {margin: 10px; border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border: 1px solid #000;}
129 .shadowed-box {box-shadow: -3px 3px 3px #666; -moz-box-shadow: -3px 3px 3px #666; -webkit-box-shadow: -3px 3px 3px #666;}
130 .sidebar-box {background-color: #CCC;}
131 .GOTMLS-scanlog li a {display: none;}
132 .GOTMLS-scanlog li:hover a {display: block;}
133 .GOTMLS-sidebar-links {list-style: none;}
134 .GOTMLS-sidebar-links li img {margin: 3px; height: 16px; vertical-align: middle;}
135 .GOTMLS-sidebar-links li {margin-bottom: 0 !important;}
136 .popup-box {background-color: #FFC; display: none; position: absolute; left: 0px; z-index: 10;}
137 .shadowed-text {text-shadow: #00F -1px 1px 1px;}
138 .sub-option {float: left; margin: 3px 5px;}
139 .inside p {margin: 10px;}
140 .GOTMLS_li, .GOTMLS_plugin li {list-style: none;}
141 .GOTMLS_plugin {margin: 5px; background: #cfc; border: 1px solid #0f0; padding: 0 5px; border-radius: 3px;}
142 .GOTMLS_plugin.known, .GOTMLS_plugin.backdoor, .GOTMLS_plugin.htaccess, .GOTMLS_plugin.timthumb, .GOTMLS_plugin.errors {background: #f99; border: 1px solid #f00;}
143 .GOTMLS_plugin.potential, .GOTMLS_plugin.wp_core, .GOTMLS_plugin.skipdirs, .GOTMLS_plugin.skipped {background: #ffc; border: 1px solid #fc6;}
144 .GOTMLS ul li {margin-left: 12px;}
145 .GOTMLS h2 {margin: 0 0 10px;}
146 .postbox {margin-right: 10px;}
147 #pastDonations li {list-style: none;}
148 #quarantine_buttons {position: absolute; right: 0px; top: -54px; margin: 0px; padding: 0px;}
149 #quarantine_buttons input.button-primary {margin-right: 20px;}
150 #delete_button {
151 background-color: #C33;
152 color: #FFF;
153 background-image: linear-gradient(to bottom, #C22, #933);
154 border-color: #933 #933 #900;
155 box-shadow: 0 1px 0 rgba(230, 120, 120, 0.5) inset;
156 text-decoration: none; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
157 margin-top: 10px;
158 }
159 #main-page-title {
160 background: url("'.$GLOBALS["GOTMLS"]["tmp"]["protocol"].'//gravatar.com/avatar/5feb789dd3a292d563fea3b885f786d6?s=64") no-repeat scroll 0 0 transparent;
161 height: 64px;
162 line-height: 58px;
163 margin: 10px 0 0 0;
164 max-width: 600px;
165 padding: 0 110px 0 84px;
166 }
167 #main-page-title h1 {
168 background: url("'.$GLOBALS["GOTMLS"]["tmp"]["protocol"].'//gravatar.com/avatar/8151cac22b3fc543d099241fd573d176?s=64") no-repeat scroll top right transparent;
169 height: 64px;
170 line-height: 32px;
171 margin: 0;
172 padding: 0 84px 0 0;
173 display: table-cell;
174 text-align: center;
175 vertical-align: middle;
176 }
177 </style>
178 <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>
179 <script type="text/javascript">
180 function showhide(id) {
181 divx = document.getElementById(id);
182 if (divx) {
183 if (divx.style.display == "none" || arguments[1]) {
184 divx.style.display = "block";
185 divx.parentNode.className = (divx.parentNode.className+"close").replace(/close/gi,"");
186 return true;
187 } else {
188 divx.style.display = "none";
189 return false;
190 }
191 }
192 }
193 function checkAllFiles(check) {
194 var checkboxes = new Array();
195 checkboxes = document["GOTMLS_Form_clean"].getElementsByTagName("input");
196 for (var i=0; i<checkboxes.length; i++)
197 if (checkboxes[i].type == "checkbox")
198 checkboxes[i].checked = check;
199 }
200 function setvalAllFiles(val) {
201 var checkboxes = document.getElementById("GOTMLS_fixing");
202 if (checkboxes)
203 checkboxes.value = val;
204 }
205 function getWindowWidth(min) {
206 if (typeof window.innerWidth != "undefined" && window.innerWidth > min)
207 min = window.innerWidth;
208 else if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != "undefined" && document.documentElement.clientWidth > min)
209 min = document.documentElement.clientWidth;
210 else if (typeof document.getElementsByTagName("body")[0].clientWidth != "undefined" && document.getElementsByTagName("body")[0].clientWidth > min)
211 min = document.getElementsByTagName("body")[0].clientWidth;
212 return min;
213 }
214 function getWindowHeight(min) {
215 if (typeof window.innerHeight != "undefined" && window.innerHeight > min)
216 min = window.innerHeight;
217 else if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientHeight != "undefined" && document.documentElement.clientHeight > min)
218 min = document.documentElement.clientHeight;
219 else if (typeof document.getElementsByTagName("body")[0].clientHeight != "undefined" && document.getElementsByTagName("body")[0].clientHeight > min)
220 min = document.getElementsByTagName("body")[0].clientHeight;
221 return min;
222 }
223 function loadIframe(title) {
224 showhide("GOTMLS_iFrame", true);
225 showhide("GOTMLS_iFrame");
226 document.getElementById("windowTitle").innerHTML = title;
227 if (curDiv) {
228 windowW = getWindowWidth(200);
229 windowH = getWindowHeight(200);
230 if (windowW > 200)
231 windowW -= 30;
232 if (windowH > 200)
233 windowH -= 20;
234 if (px2num(curDiv.style.width) > windowW) {
235 curDiv.style.width = windowW + "px";
236 curDiv.style.left = "0px";
237 } else if ((px2num(curDiv.style.left) + px2num(curDiv.style.width)) > windowW) {
238 curDiv.style.left = (windowW - px2num(curDiv.style.width)) + "px";
239 }
240 if (px2num(curDiv.style.height) > windowH) {
241 curDiv.style.height = windowH + "px";
242 curDiv.style.top = "0px";
243 } else if ((px2num(curDiv.style.top) + px2num(curDiv.style.height)) > windowH) {
244 curDiv.style.top = (windowH - px2num(curDiv.style.height)) + "px";
245 }
246 if (px2num(curDiv.style.left) < 0)
247 curDiv.style.left = "0px";
248 if (px2num(curDiv.style.top)< 0)
249 curDiv.style.top = "0px";
250 }
251 showhide("div_file", true);
252 if (IE)
253 curDiv.scrollIntoView(true);
254 }
255 function cancelserver(divid) {
256 document.getElementById(divid).innerHTML = "<div class=\'error\'>'. __("No response from server!",'gotmls').'</div>";
257 }
258 function checkupdateserver(server, divid) {
259 var updatescript = document.createElement("script");
260 updatescript.setAttribute("src", server);
261 divx = document.getElementById(divid);
262 if (divx) {
263 divx.appendChild(updatescript);
264 if (arguments[2])
265 return setTimeout("stopCheckingDefinitions = checkupdateserver(\'"+arguments[2]+"\',\'"+divid+"\')",15000);
266 else
267 return setTimeout("cancelserver(\'"+divid+"\')",'.($GLOBALS["GOTMLS"]["tmp"]['execution_time']+1).'000+3000);
268 }
269 }
270 var IE = document.all?true:false;
271 if (!IE) document.captureEvents(Event.MOUSEMOVE)
272 document.onmousemove = getMouseXY;
273 var offsetX = 0;
274 var offsetY = 0;
275 var offsetW = 0;
276 var offsetH = 0;
277 var curX = 0;
278 var curY = 0;
279 var curDiv;
280 function getMouseXY(e) {
281 if (IE) { // grab the mouse pos if browser is IE
282 curX = event.clientX + document.body.scrollLeft;
283 curY = event.clientY + document.body.scrollTop;
284 } else { // grab the mouse pos if browser is Not IE
285 curX = e.pageX - document.body.scrollLeft;
286 curY = e.pageY - document.body.scrollTop;
287 }
288 if (curX < 0) {curX = 0;}
289 if (curY < 0) {curY = 0;}
290 if (offsetX && curX > 10) {curDiv.style.left = (curX - offsetX)+"px";}
291 if (offsetY && (curY - offsetY) > 0) {curDiv.style.top = (curY - offsetY)+"px";}
292 if (offsetW && (curX - offsetW) > 360) {curDiv.style.width = (curX - offsetW)+"px";}
293 if (offsetH && (curY - offsetH) > 200) {curDiv.style.height = (curY - offsetH)+"px";}
294 return true;
295 }
296 function px2num(px) {
297 return parseInt(px.substring(0, px.length - 2), 10);
298 }
299 function setDiv(DivID) {
300 if (curDiv = document.getElementById(DivID)) {
301 if (IE)
302 curDiv.style.position = "absolute";
303 curDiv.style.left = "'.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][0].'";
304 curDiv.style.top = "'.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][1].'";
305 curDiv.style.height = "'.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][2].'";
306 curDiv.style.width = "'.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][3].'";
307 }
308 }
309 function grabDiv() {
310 corner = document.getElementById("windowTitle");
311 if (corner) {
312 corner.style.width="100%";
313 corner.style.height="100%";
314 }
315 offsetX=curX-px2num(curDiv.style.left);
316 offsetY=curY-px2num(curDiv.style.top);
317 }
318 function releaseDiv() {
319 corner = document.getElementById("windowTitle");
320 if (corner) {
321 corner.style.width="90%";
322 corner.style.height="20px";
323 }
324 document.getElementById("GOTMLS_statusFrame").src = "'.admin_url('admin-ajax.php?action=GOTMLS_position&'.GOTMLS_set_nonce(__FUNCTION__."341").'&GOTMLS_x=').'"+curDiv.style.left+"&GOTMLS_y="+curDiv.style.top;
325 offsetX=0;
326 offsetY=0;
327 }
328 function grabCorner() {
329 corner = document.getElementById("cornerGrab");
330 if (corner) {
331 corner.style.width="100%";
332 corner.style.height="100%";
333 }
334 offsetW=curX-px2num(curDiv.style.width);
335 offsetH=curY-px2num(curDiv.style.height);
336 }
337 function releaseCorner() {
338 corner = document.getElementById("cornerGrab");
339 if (corner) {
340 corner.style.width="20px";
341 corner.style.height="20px";
342 }
343 document.getElementById("GOTMLS_statusFrame").src = "'.admin_url('admin-ajax.php?action=GOTMLS_position&'.GOTMLS_set_nonce(__FUNCTION__."360").'&GOTMLS_w=').'"+curDiv.style.width+"&GOTMLS_h="+curDiv.style.height;
344 offsetW=0;
345 offsetH=0;
346 }
347 setDiv("div_file");
348 </script>
349 <div id="main-page-title"><h1 style="vertical-align: middle;">Anti-Malware from&nbsp;GOTMLS.NET</h1></div>
350 <div id="admin-page-container">
351 <div id="GOTMLS-right-sidebar" style="width: 300px;" class="metabox-holder">
352 '.GOTMLS_box(__("Updates & Registration",'gotmls'), '<ul style=""><li>WordPress: <span class="GOTMLS_date">'.$wp_version.'</span></li>
353 <li>Plugin: <span class="GOTMLS_date">'.GOTMLS_Version.'</span></li>
354 <li>Definitions: <span class="GOTMLS_date">'.$GLOBALS["GOTMLS"]["tmp"]["Definition"]["Latest"].'</span></li>
355 <li>'.((!$defLatest && !$isRegistered)?'<form method="POST" action="'.admin_url('admin-ajax.php?'.GOTMLS_set_nonce(__FUNCTION__."349")).'" target="GOTMLS_iFrame" name="GOTMLS_Form_lognewkey"><input type="hidden" name="GOTMLS_installation_key" value="'.GOTMLS_installation_key.'"><input type="hidden" name="action" value="GOTMLS_lognewkey"><span style="color: #F00;" id="GOTMLS_No_Key">No Key! <input type="submit" style="float: right;" value="'.__("Get FREE Key!",'gotmls').'" class="button-primary" onclick="showhide(\'GOTMLS_No_Key\');showhide(\'GOTMLS_Key\', true);check_for_updates(\'Definition_Updates\');" /></span></form><div id="GOTMLS_Key" style="display: none; ':'<div style="').'margin: 0;">Key: <span style="float: right;">'.GOTMLS_installation_key.'</span></div></li></ul>
356 <form id="updateform" method="post" name="updateform" action="'.str_replace("GOTMLS_mt=", "GOTMLS_last_mt=", GOTMLS_script_URI).'&'.GOTMLS_set_nonce(__FUNCTION__."373").'">
357 <img style="display: none; float: right; margin-right: 14px;" src="'.GOTMLS_images_path.'checked.gif" height=16 width=16 alt="definitions file updated" id="autoUpdateDownload" onclick="showhide(\'autoUpdateForm\', true);">
358 '.str_replace('findUpdates', 'Definition_Updates', $Update_Div).'
359 <div id="autoUpdateForm" style="display: none;">
360 <input type="submit" style="width: 100%;" name="auto_update" value="'.__("Download new definitions!",'gotmls').'">
361 </div>
362 </form>
363 <div id="registerKeyForm" style="display: none;"><span style="color: #F00">'.__("<p>Get instant access to definition updates.</p>",'gotmls').'</span><p>
364 '.__("If you have not already registered your Key then register now using the form below.<br />* All registration fields are required<br />** I will NOT share your information.",'gotmls').'</p>
365 <form id="registerform" onsubmit="return sinupFormValidate(this);" action="'.GOTMLS_plugin_home.'wp-login.php?action=register" method="post" name="registerform" target="GOTMLS_iFrame"><input type="hidden" name="redirect_to" id="register_redirect_to" value="/donate/"><input type="hidden" name="user_login" id="register_user_login" value="">
366 <div>'.__("Your Full Name:",'gotmls').'</div>
367 <div style="float: left; width: 50%;"><input style="width: 100%;" id="first_name" type="text" name="first_name" value="'.$current_user->user_firstname.'" /></div>
368 <div style="float: left; width: 50%;"><input style="width: 100%;" id="last_name" type="text" name="last_name" value="'.$current_user->user_lastname.'" /></div>
369 <div style="clear: left; width: 100%;">
370 <div>'.__("A password will be e-mailed to this address:",'gotmls').'</div>
371 <input style="width: 100%;" id="user_email" type="text" name="user_email" value="'.$current_user->user_email.'" /></div>
372 <div>
373 <div>'.__("Your WordPress Site URL:",'gotmls').'</div>
374 <input style="width: 100%;" id="user_url" type="text" name="user_url" value="'.GOTMLS_siteurl.'" readonly /></div>
375 <div>
376 <div>'.__("Plugin Installation Key:",'gotmls').'</div>
377 <input style="width: 100%;" id="installation_key" type="text" name="installation_key" value="'.GOTMLS_installation_key.'" readonly /><input id="old_key" type="hidden" name="old_key" value="'.md5($GOTMLS_url_parts[2]).'" /></div>
378 <input style="width: 100%;" id="wp-submit" type="submit" name="wp-submit" value="Register Now!" /></form></div>'.$Update_Link, "stuffbox").'
379 <script type="text/javascript">
380 function check_for_updates(update_type) {
381 showhide(update_type, true);
382 stopCheckingDefinitions = checkupdateserver("'.$Update_Definitions.'", update_type, "'.str_replace("://", "://www.", $Update_Definitions).'");
383 }
384 function updates_complete(chk) {
385 if (auto_img = document.getElementById("autoUpdateDownload")) {
386 auto_img.style.display="block";
387 check_for_donation(chk);
388 }
389 }
390 function check_for_donation(chk) {
391 if (document.getElementById("autoUpdateDownload").src.replace(/^.+\?/,"")=="0")
392 if (chk.substr(0, 8) != "Changed " || chk.substr(8, 1) != "0")
393 chk += "\\n\\n'.__("Please make a donation for the use of this wonderful feature!",'gotmls').'";
394 alert(chk);
395 }
396 function sinupFormValidate(form) {
397 var error = "";
398 if(form["first_name"].value == "")
399 error += "'.__("First Name is a required field!",'gotmls').'\n";
400 if(form["last_name"].value == "")
401 error += "'.__("Last Name is a required field!",'gotmls').'\n";
402 if(form["user_email"].value == "")
403 error += "'.__("Email Address is a required field!",'gotmls').'\n";
404 else {
405 if (uem = document.getElementById("register_user_login"))
406 uem.value = form["user_email"].value;
407 if (uem = document.getElementById("register_redirect_to"))
408 uem.value = "/donate/?email="+form["user_email"].value.replace("@", "%40");
409 }
410 if(form["user_url"].value == "")
411 error += "'.__("Your WordPress Site URL is a required field!",'gotmls').'\n";
412 if(form["installation_key"].value == "")
413 error += "'.__("Plugin Installation Key is a required field!",'gotmls').'\n";
414 if(error != "") {
415 alert(error);
416 return false;
417 } else {
418 document.getElementById("Definition_Updates").innerHTML = \'<img src="'.GOTMLS_images_path.'wait.gif">'.__("Submitting Registration ...",'gotmls').'\';
419 showhide("Definition_Updates", true);
420 setTimeout(\'stopCheckingDefinitions = checkupdateserver("'.$Update_Definitions.'", "Definition_Updates")\', 3000);
421 showhide("registerKeyForm");
422 return true;
423 }
424 }
425 var divNAtext = false;
426 function loadGOTMLS() {
427 clearTimeout(divNAtext);
428 setDivNAtext();
429 '.$GLOBALS["GOTMLS"]["tmp"]["onLoad"].'
430 }
431 if ('.($defLatest+strlen($isRegistered)).')
432 check_for_updates("Definition_Updates");
433 // else showhide("registerKeyForm", true);
434 if (divNAtext)
435 loadGOTMLS();
436 else
437 divNAtext=true;
438 </script>
439 '.GOTMLS_box(__("Resources & Links",'gotmls'), '
440 <div id="pastDonations"></div>
441 <form name="ppdform" id="ppdform" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
442 <input type="hidden" name="cmd" value="_donations">
443 <input type="hidden" name="business" value="eli@gotmls.net">
444 <input type="hidden" name="no_shipping" value="1">
445 <input type="hidden" name="no_note" value="1">
446 <input type="hidden" name="currency_code" value="USD">
447 <input type="hidden" name="tax" value="0">
448 <input type="hidden" name="lc" value="US">
449 <input type="hidden" name="bn" value="PP-DonationsBF">
450 <input type="radio" name="amount" value="14.89">$14+
451 <input type="radio" id="default_level_donation" name="amount" value="29.29" checked>$29+
452 <input type="radio" id="higher_level_donation" name="amount" value="52.00">$52
453 <input type="radio" name="amount" value="86.00">$86
454 <input type="radio" name="amount" value="133.70">$133.7
455 <input type="hidden" name="item_name" value="Donation to Eli\'s Anti-Malware Plugin">
456 <input type="hidden" name="item_number" value="GOTMLS-key-'.GOTMLS_installation_key.'">
457 <input type="hidden" name="custom" value="key-'.GOTMLS_installation_key.'">
458 <input type="hidden" name="notify_url" value="'.GOTMLS_plugin_home.GOTMLS_installation_key.'/ipn">
459 <input type="hidden" name="page_style" value="GOTMLS">
460 <input type="hidden" name="return" value="'.GOTMLS_plugin_home.'donate/?donation-source=paid">
461 <input type="hidden" name="cancel_return" value="'.GOTMLS_plugin_home.'donate/?donation-source=cancel">
462 <input type="image" id="pp_button" src="'.GOTMLS_images_path.'btn_donateCC_WIDE.gif" border="0" name="submitc" alt="'.__("Make a Donation with PayPal",'gotmls').'">
463 <div>
464 <ul class="GOTMLS-sidebar-links">
465 <li style="float: right;"><b>on <a target="_blank" href="https://profiles.wordpress.org/scheeeli#content-plugins">WordPress.org</a></b><ul class="GOTMLS-sidebar-links">
466 <li><a target="_blank" href="https://wordpress.org/plugins/gotmls/faq/">Plugin FAQs</a></li>
467 <li><a target="_blank" href="https://wordpress.org/support/plugin/gotmls">Forum Posts</a></li>
468 <li><a target="_blank" href="https://wordpress.org/support/view/plugin-reviews/gotmls">Plugin Reviews</a></li>
469 </ul></li>
470 <li><img src="//gravatar.com/avatar/5feb789dd3a292d563fea3b885f786d6?s=16" border="0" alt="Plugin site:"><b><a target="_blank" href="'.GOTMLS_plugin_home.'">GOTMLS.NET</a></b></li>
471 <li><img src="//gravatar.com/avatar/8151cac22b3fc543d099241fd573d176?s=16" border="0" alt="Developer site:"><b><a target="_blank" href="'.GOTMLS_blog_home.'/category/my-plugins/anti-malware/">Eli\'s Blog</a></b></li>
472 <li><img src="https://ssl.gstatic.com/ui/v1/icons/mail/favicon.ico" border="0" alt="mail:"><b><a target="_blank" href="mailto:eli@gotmls.net">Email Eli</a></b></li>
473 <li><iframe allowtransparency="true" frameborder="0" scrolling="no" src="https://platform.twitter.com/widgets/follow_button.html?screen_name=GOTMLS&amp;show_count=false" style="width:125px; height:20px;"></iframe></li>
474 </ul>
475 </div>
476 </form>
477 <a target="_blank" href="https://www.google.com/transparencyreport/safebrowsing/diagnostic/index.html#url='.urlencode(GOTMLS_siteurl).'">Google Safe Browsing Diagnostic</a>', "stuffbox").'
478 '.GOTMLS_box(__("Last Scan Status",'gotmls'), GOTMLS_scan_log(), "stuffbox").'
479 '.$optional_box.'
480 </div>';
481 if (isset($GLOBALS["GOTMLS"]["tmp"]["stuffbox"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["stuffbox"])) {
482 echo '
483 <script type="text/javascript">
484 function stuffbox_showhide(id) {
485 divx = document.getElementById(id);
486 if (divx) {
487 if (divx.style.display == "none" || arguments[1]) {';
488 $else = '
489 if (divx = document.getElementById("GOTMLS-right-sidebar"))
490 divx.style.width = "30px";
491 if (divx = document.getElementById("GOTMLS-main-section"))
492 divx.style.marginRight = "30px";';
493 foreach ($GLOBALS["GOTMLS"]["tmp"]["stuffbox"] as $md5 => $bTitle) {
494 echo "\nif (divx = document.getElementById('inside_$md5'))\n\tdivx.style.display = 'block';\nif (divx = document.getElementById('title_$md5'))\n\tdivx.innerHTML = '".GOTMLS_strip4java($bTitle, true)."';";
495 $else .= "\nif (divx = document.getElementById('inside_$md5'))\n\tdivx.style.display = 'none';\nif (divx = document.getElementById('title_$md5'))\n\tdivx.innerHTML = '".substr($bTitle, 0, 1)."';";
496 }
497 echo '
498 if (divx = document.getElementById("GOTMLS-right-sidebar"))
499 divx.style.width = "300px";
500 if (divx = document.getElementById("GOTMLS-main-section"))
501 divx.style.marginRight = "300px";
502 return true;
503 } else {'.$else.'
504 return false;
505 }
506 }
507 }
508 if (getWindowWidth(780) == 780)
509 setTimeout("stuffbox_showhide(\'inside_'.$md5.'\')", 200);
510 </script>';
511 }
512 echo '
513 <div id="GOTMLS-main-section" style="margin-right: 300px;">
514 <div class="metabox-holder GOTMLS" style="width: 100%;" id="GOTMLS-metabox-container">';
515 }
516
517 function GOTMLS_box($bTitle, $bContents, $bType = "postbox") {
518 $md5 = md5($bTitle);
519 if (isset($GLOBALS["GOTMLS"]["tmp"]["$bType"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["$bType"]))
520 $GLOBALS["GOTMLS"]["tmp"]["$bType"]["$md5"] = "$bTitle";
521 else
522 $GLOBALS["GOTMLS"]["tmp"]["$bType"] = array("$md5"=>"$bTitle");
523 return '
524 <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>
525 <div id="inside_'.$md5.'" class="inside">
526 '.$bContents.'
527 </div>
528 </div>';
529 }
530
531 function GOTMLS_get_scanlog() {
532 global $wpdb;
533 $LastScan = '';
534 if (isset($_GET["GOTMLS_cl"]) && GOTMLS_get_nonce()) {
535 $SQL = $wpdb->prepare("DELETE FROM `$wpdb->options` WHERE option_name LIKE %s AND substring_index(option_name, '/', -1) < %s", 'GOTMLS_scan_log/%', $_GET["GOTMLS_cl"]);
536 if ($cleared = $wpdb->query($SQL))
537 $LastScan .= sprintf(__("Cleared %s records from this log.",'gotmls'), $cleared);
538 // else $LastScan .= $wpdb->last_error."<li>$SQL</li>";
539 }
540 $SQL = "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";
541 if ($rs = $wpdb->get_results($SQL, ARRAY_A)) {
542 $units = array("seconds"=>60,"minutes"=>60,"hours"=>24,"days"=>365,"years"=>10);
543 $LastScan .= '<ul class="GOTMLS-scanlog GOTMLS-sidebar-links">';
544 foreach ($rs as $row) {
545 $LastScan .= "\n<li>";
546 $GOTMLS_scan_log = (isset($row["option_name"])?get_option($row["option_name"], array()):array());
547 if (isset($GOTMLS_scan_log["scan"]["type"]) && strlen($GOTMLS_scan_log["scan"]["type"]))
548 $LastScan .= htmlentities($GOTMLS_scan_log["scan"]["type"]);
549 else
550 $LastScan .= "Unknown scan type";
551 if (isset($GOTMLS_scan_log["scan"]["dir"]) && is_dir($GOTMLS_scan_log["scan"]["dir"]))
552 $LastScan .= " of ".basename($GOTMLS_scan_log["scan"]["dir"]);
553 if (isset($GOTMLS_scan_log["scan"]["start"]) && is_numeric($GOTMLS_scan_log["scan"]["start"])) {
554 $time = (time() - $GOTMLS_scan_log["scan"]["start"]);
555 $ukeys = array_keys($units);
556 for ($unit = $ukeys[0], $key=0; (isset($units[$ukeys[$key]]) && $key < (count($ukeys) - 1) && $time >= $units[$ukeys[$key]]); $unit = $ukeys[++$key])
557 $time = floor($time/$units[$ukeys[$key]]);
558 if (1 == $time)
559 $unit = substr($unit, 0, -1);
560 $LastScan .= " started $time $unit ago";
561 if (isset($GOTMLS_scan_log["scan"]["finish"]) && is_numeric($GOTMLS_scan_log["scan"]["finish"]) && ($GOTMLS_scan_log["scan"]["finish"] >= $GOTMLS_scan_log["scan"]["start"])) {
562 $time = ($GOTMLS_scan_log["scan"]["finish"] - $GOTMLS_scan_log["scan"]["start"]);
563 for ($unit = $ukeys[0], $key=0; (isset($units[$ukeys[$key]]) && $key < (count($ukeys) - 1) && $time >= $units[$ukeys[$key]]); $unit = $ukeys[++$key])
564 $time = floor($time/$units[$ukeys[$key]]);
565 if (1 == $time)
566 $unit = substr($unit, 0, -1);
567 if ($time)
568 $LastScan .= " and ran for $time $unit";
569 else
570 $LastScan = str_replace("started", "ran", $LastScan);
571 } else
572 $LastScan .= " and has not finish";
573 } else
574 $LastScan .= " failed to started";
575 $LastScan .= '<a href="'.GOTMLS_script_URI.'&GOTMLS_cl='.$row["mt"].'&'.GOTMLS_set_nonce(__FUNCTION__."600").'">[clear log below this entry]</a></li>';
576 }
577 $LastScan .= '</ul>';
578 } else
579 $LastScan .= '<h3>'.__("No Scans have been logged",'gotmls').'</h3>';
580 return "$LastScan\n";
581 }
582
583 function GOTMLS_get_whitelists() {
584 $Q_Page = '';
585 if (isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"])) {
586 $Q_Page .= '<ul name="found_Quarantine" id="found_Quarantine" class="GOTMLS_plugin known" style="background-color: #ccc; padding: 0;"><h3>'.__("Globally White-listed files",'gotmls').'<span class="GOTMLS_date">'.__("# of patterns",'gotmls').'</span><span class="GOTMLS_date">'.__("Date Updated",'gotmls').'</span></h3>';
587 foreach ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"] as $file => $non_threats) {
588 if (isset($non_threats[0])) {
589 $updated = GOTMLS_sexagesimal($non_threats[0]);
590 unset($non_threats[0]);
591 } else
592 $updated = "Unknown";
593 $Q_Page .= '<li style="margin: 4px 12px;"><span class="GOTMLS_date">'.count($non_threats).'</span><span class="GOTMLS_date">'.$updated."</span>$file</li>\n";
594 }
595 if (isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["wp_core"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["wp_core"])) {
596 $Q_Page .= '<h3>'.__("WordPress Core files",'gotmls').'<span class="GOTMLS_date">'.__("# of files",'gotmls').'</span></h3>';
597 foreach ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["wp_core"] as $ver => $files) {
598 $Q_Page .= '<li style="margin: 4px 12px;"><span class="GOTMLS_date">'.count($files)."</span>Version $ver</li>\n";
599 }
600 }
601 $Q_Page .= "</ul>";
602 }
603 return "$Q_Page\n";
604 }
605
606 function GOTMLS_get_quarantine($only = false) {
607 global $wpdb, $post;
608 $old_files = 0;
609 if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"]) || $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"]) {
610 if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"])) {
611 if (($upload = wp_upload_dir()) && isset($upload['basedir']))
612 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"] = str_replace("/", GOTMLS_slash(), GOTMLS_trailingslashit($upload['basedir'])).'quarantine';
613 else
614 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"] = false;
615 }
616 if (isset($_GET["page"]) && substr($_GET["page"], 0, 6) == "GOTMLS" && $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"] && is_dir($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"])) {
617 $entries = GOTMLS_getfiles($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"]);
618 if (is_array($entries) && count($entries)) {
619 foreach ($entries as $entry) {
620 if (is_file($file = GOTMLS_trailingslashit($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"]).$entry)) {
621 if (GOTMLS_get_ext($entry) == "gotmls") {
622 $old_files++;
623 if (GOTMLS_get_nonce() && ($GLOBALS["GOTMLS"]["tmp"]["file_contents"] = @file_get_contents($file))) {
624 $insert = array("post_author"=>GOTMLS_get_current_user_id(), "ping_status"=>"imported", "post_status"=>"private", "post_type"=>"GOTMLS_quarantine", "post_content"=>GOTMLS_encode($GLOBALS["GOTMLS"]["tmp"]["file_contents"]), "post_mime_type"=>md5($GLOBALS["GOTMLS"]["tmp"]["file_contents"]), "guid"=>"Unknown");//! comment_status post_password post_name to_ping post_parent menu_order";
625 if (!($insert["comment_count"] = @filesize($file)))
626 $insert["comment_count"] = strlen($GLOBALS["GOTMLS"]["tmp"]["file_contents"]);
627 $file_date = explode(".", $entry);
628 $insert["post_date"] = date("Y-m-d H:i:s", filemtime($file));
629 $insert["post_date_gmt"] = $insert["post_date"];
630 $insert["post_modified"] = $insert["post_date"];
631 $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])$/';
632 if (count($file_date) > 2 && strlen($file_date[0]) == 5 && preg_match($match, GOTMLS_sexagesimal($file_date[0])))
633 $insert["post_modified"] = GOTMLS_sexagesimal($file_date[0]).":00";
634 elseif (count($file_date) > 3 && strlen($file_date[1]) == 5 && preg_match($match, GOTMLS_sexagesimal($file_date[1])))
635 $insert["post_modified"] = GOTMLS_sexagesimal($file_date[1]).":00";
636 $insert["post_modified_gmt"] = $insert["post_modified"];
637 $insert["post_title"] = GOTMLS_decode($file_date[count($file_date)-2]);
638 if (is_file($insert["post_title"]) && ($GLOBALS["GOTMLS"]["tmp"]["new_contents"] = file_get_contents($insert["post_title"])))
639 $insert["post_content_filtered"] = GOTMLS_encode($GLOBALS["GOTMLS"]["tmp"]["new_contents"]);
640 //! pinged post_excerpt
641 if ($wpdb->insert($wpdb->posts, $insert)) {
642 unlink(trailingslashit($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"]).$entry);
643 $old_files--;
644 } else
645 print_r(array($entry=>$insert, "last_error"=>$wpdb->last_error));
646 }
647 } elseif (basename($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"]) == "quarantine")
648 unlink(trailingslashit($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"]).$entry);
649 }
650 }
651 }
652 if ($old_files == 0 && basename($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"]) == "quarantine")
653 rmdir($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"]);
654 }
655 if (!($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"] && is_dir($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"]))) {
656 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["quarantine_dir"] = false;
657 update_option("GOTMLS_settings_array", $GLOBALS["GOTMLS"]["tmp"]["settings_array"]);
658 }
659 }
660 if (is_numeric($only))
661 return get_post($only, ARRAY_A);
662 elseif ($only)
663 return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE `post_type` = 'GOTMLS_quarantine' AND `post_status` = 'private'") + $old_files;
664 else
665 $args = array('posts_per_page' => (isset($_GET['posts_per_page'])&&is_numeric($_GET['posts_per_page'])&&$_GET['posts_per_page']>0?$_GET['posts_per_page']:200), 'orderby' => 'date', 'post_type' => 'GOTMLS_quarantine', "post_status" => "private");
666 if (isset($_POST["paged"]))
667 $args["paged"] = $_POST["paged"];
668 if ($old_files) {
669 $Q_Paged = '<form method="POST" name="GOTMLS_Form_page">';
670 $Q_Page = '<form method="POST" name="GOTMLS_Form_clean"><input type="hidden" name="'.str_replace('=', '" value="', GOTMLS_set_nonce(__FUNCTION__."695")).'">'.__("You have old Quarantined files in the uploads directory on your server. The new quarantine is in your WordPress Database. You need to import these files into your database where they will be safer or just delete the quarantine folder inside /wp-content/uploads/ if you would rather just delete them.",'gotmls').'<br /><input type="submit" value="Import Quarantined Files Now">';
671 } else {
672 $my_query = new WP_Query($args);
673 $Q_Paged = '<form method="POST" name="GOTMLS_Form_page"><input type="hidden" id="GOTMLS_paged" name="paged" value="1"><div style="float: left;">Page:</div>';
674 $Q_Page = '
675 <form method="POST" action="'.admin_url('admin-ajax.php?'.GOTMLS_set_nonce(__FUNCTION__."700")).(isset($_SERVER["QUERY_STRING"])&&strlen($_SERVER["QUERY_STRING"])?"&".$_SERVER["QUERY_STRING"]:"").'" target="GOTMLS_iFrame" name="GOTMLS_Form_clean"><input type="hidden" id="GOTMLS_fixing" name="GOTMLS_fixing" value="1"><input type="hidden" name="action" value="GOTMLS_fix">';
676 if ($my_query->have_posts()) {
677 $Q_Page .= '<p id="quarantine_buttons" style="display: none;"><input id="repair_button" type="submit" value="'.__("Restore selected files",'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 files",'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 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.",'gotmls').'</b></p>
678 <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').'</span></h3>';
679 $root_path = implode(GOTMLS_slash(), array_slice(GOTMLS_explode_dir(__FILE__), 0, (2 + intval($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_level"])) * -1));
680 while ($my_query->have_posts()) {
681 $my_query->the_post();
682 $Q_Page .= '
683 <li id="GOTMLS_quarantine_'.$post->ID.'" class="GOTMLS_quarantine_item"><span class="GOTMLS_date">'.$post->post_date_gmt.'</span><span class="GOTMLS_date">'.$post->post_modified_gmt.'</span><input type="checkbox" name="GOTMLS_fix[]" value="'.$post->ID.'" id="check_'.$post->ID.'" onchange="document.getElementById(\'quarantine_buttons\').style.display = \'block\';" /><img src="'.GOTMLS_images_path.'blocked.gif" height=16 width=16 alt="Q">'.GOTMLS_error_link(__("View Quarantined File",'gotmls'), $post->ID).str_replace($root_path, "...", $post->post_title)."</a></li>\n";
684 }
685 $Q_Page .= "\n</ul>";
686 for ($p = 1; $p <= $my_query->max_num_pages; $p++) {
687 $Q_Paged .= '<input class="GOTMLS_page" type="submit" value="'.$p.'"'.((isset($_POST["paged"]) && $_POST["paged"] == $p) || (!isset($_POST["paged"]) && 1 == $p)?" DISABLED":"").' onclick="document.getElementById(\'GOTMLS_paged\').value = \''.$p.'\';">';
688 }
689 } else
690 $Q_Page .= '<h3>'.__("No Items in Quarantine",'gotmls').'</h3>';
691 wp_reset_query();
692 }
693 $return = "$Q_Paged\n</form><br style=\"clear: left;\" />\n$Q_Page\n</form>\n$Q_Paged\n</form><br style=\"clear: left;\" />\n";
694 if (($trashed = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE `post_type` = 'GOTMLS_quarantine' AND `post_status` != 'private'")) > 1)
695 $return = '<a href="'.admin_url('admin-ajax.php?action=GOTMLS_empty_trash&'.GOTMLS_set_nonce(__FUNCTION__."720")).'" id="empty_trash_link" style="float: right;" target="GOTMLS_statusFrame">['.sprintf(__("Clear %s Deleted Files from the Trash",'gotmls'), $trashed)."]</a>$return";
696 return $return;
697 }
698
699 function GOTMLS_View_Quarantine() {
700 GOTMLS_update_definitions();
701 $echo = GOTMLS_box($Q_Page = __("White-lists",'gotmls'), GOTMLS_get_whitelists());
702 if (!isset($_GET['Whitelists']))
703 $echo .= "\n<script>\nshowhide('inside_".md5($Q_Page)."');\n</script>\n";
704 $echo .= GOTMLS_box($Q_Page = __("Quarantine",'gotmls'), GOTMLS_get_quarantine());
705 if (isset($_GET['Scanlog']))
706 $echo .= "\n<script>\nshowhide('inside_".md5($Q_Page)."');\n</script>\n";
707 GOTMLS_display_header();
708 echo $echo.GOTMLS_box(__("Scan Logs",'gotmls'), GOTMLS_get_scanlog())."\n</div></div></div>";
709 }
710
711 function GOTMLS_Firewall_Options() {
712 global $current_user, $wpdb;
713 GOTMLS_update_definitions();
714 GOTMLS_display_header();
715 $GOTMLS_nonce_found = GOTMLS_get_nonce();
716 $gt = ">";
717 $lt = "<";
718 $patch_attr = array(
719 array(
720 "icon" => "blocked",
721 "language" => __("Your WordPress Login page is susceptible to a brute-force attack (just like any other login page). These types of attacks are becoming more prevalent these days and can sometimes cause your server to become slow or unresponsive, even if the attacks do not succeed in gaining access to your site. Applying this patch will block access to the WordPress Login page whenever this type of attack is detected."),
722 "status" => 'Not Installed',
723 "action" => 'Install Patch'
724 ),
725 array(
726 "language" => __("Your WordPress site has the current version of my brute-force Login protection installed."),
727 "action" => 'Uninstall Patch',
728 "status" => 'Enabled',
729 "icon" => "checked"
730 ),
731 array(
732 "language" => __("Your WordPress Login page has the old version of my brute-force protection installed. Upgrade this patch to improve the protection on the WordPress Login page and preserve the integrity of your WordPress core files."),
733 "action" => 'Upgrade Patch',
734 "status" => 'Out of Date',
735 "icon" => "threat"
736 )
737 );
738 $patch_action = $lt.'form method="POST" name="GOTMLS_Form_XMLRPC_patch"'.$gt.$lt.'input type="hidden" name="'.str_replace('=', '" value="', GOTMLS_set_nonce(__FUNCTION__."1159")).'"'.$gt.$lt.'script'.$gt."\nfunction testComplete() {\nif (autoUpdateDownloadGIF = document.getElementById('autoUpdateDownload'))\n\tdonationAmount = autoUpdateDownloadGIF.src.replace(/^.+\?/,'');\nif ((autoUpdateDownloadGIF.src == donationAmount) || donationAmount=='0') {\n\tif (patch_searching_div = document.getElementById('GOTMLS_XMLRPC_patch_searching')) {\n\t\tif (autoUpdateDownloadGIF.src == donationAmount)\n\t\t\tpatch_searching_div.innerHTML = '<span style=\"color: #F00;\">".__("You must register and donate to use this feature!",'gotmls')."</span>';\n\t\telse\n\t\t\tpatch_searching_div.innerHTML = '<span style=\"color: #F00;\">".__("This feature is available to those who have donated!",'gotmls')."</span>';\n\t}\n} else {\n\tshowhide('GOTMLS_XMLRPC_patch_searching');\n\tshowhide('GOTMLS_XMLRPC_patch_button', true);\n}\n}\nwindow.onload=testComplete;\n$lt/script$gt$lt".'div style="float: right;"'.$gt.$lt.'input type="hidden" name="GOTMLS_XMLRPC_patching" value="';
739 $patch_found = false;
740 $find = '|<Files[^>]+xmlrpc.php>(.+?)</Files>\s*(# END GOTMLS Patch to Block XMLRPC Access\s*)*|is';
741 $head = str_replace(array('|<Files[^>]+', '(.+?)', '\\s*(', '\\s*)*|is'), array("<Files ", "\norder deny,allow\ndeny from all".(isset($_SERVER["REMOTE_ADDR"])?"\nallow from ".$_SERVER["REMOTE_ADDR"]:"").(isset($_SERVER["SERVER_ADDR"])?"\nallow from ".$_SERVER["SERVER_ADDR"]:"")."\n", "\n", "\n"), $find);
742 $htaccess = "";
743 if (is_file(ABSPATH.'.htaccess'))
744 if (($htaccess = @file_get_contents(ABSPATH.'.htaccess')) && strlen($htaccess))
745 $patch_found = preg_match($find, $htaccess);
746 if ($patch_found) {
747 if ($GOTMLS_nonce_found && isset($_POST["GOTMLS_XMLRPC_patching"]) && ($_POST["GOTMLS_XMLRPC_patching"] < 0) && GOTMLS_file_put_contents(ABSPATH.'.htaccess', preg_replace($find, "", $htaccess)))
748 $patch_action .= '1"'.$gt.$lt.'input type="submit" value="Block XMLRPC Access" /'."$gt$lt/div$gt$lt".'div style="padding: 0 30px;"'.$gt.$lt.'p'.$gt.$lt.'b'.$gt.$lt.'img src="'.GOTMLS_images_path.'question.gif"'.$gt.'Block XMLRPC Access (Now Allowing Access';
749 elseif ($GOTMLS_nonce_found && isset($_POST["GOTMLS_XMLRPC_patching"]) && ($_POST["GOTMLS_XMLRPC_patching"] < 0))
750 $patch_action .= '-1"'.$gt.$lt.'input type="submit" value="Unblock XMLRPC Access" /'."$gt$lt/div$gt$lt".'div style="padding: 0 30px;"'.$gt.$lt.'p'.$gt.$lt.'b'.$gt.$lt.'img src="'.GOTMLS_images_path.'threat.gif"'.$gt.'Block XMLRPC Access (Still Blocking: '.sprintf(__("Failed to remove XMLRPC Protection [.htaccess %s]",'gotmls'),(is_readable(ABSPATH.'.htaccess')?'read-'.(is_writable(ABSPATH.'.htaccess')?'write?':'only!'):"unreadable!").": ".strlen($htaccess).GOTMLS_fileperms(ABSPATH.'.htaccess'));
751 else
752 $patch_action .= '-1"'.$gt.$lt.'input type="submit" value="Unblock XMLRPC Access" /'."$gt$lt/div$gt$lt".'div style="padding: 0 30px;"'.$gt.$lt.'p'.$gt.$lt.'b'.$gt.$lt.'img src="'.GOTMLS_images_path.'checked.gif"'.$gt.'Block XMLRPC Access (Currently Blocked';
753 } else {
754 if ($GOTMLS_nonce_found && isset($_POST["GOTMLS_XMLRPC_patching"]) && ($_POST["GOTMLS_XMLRPC_patching"] > 0) && GOTMLS_file_put_contents(ABSPATH.'.htaccess', "$head$htaccess"))
755 $patch_action .= '-1"'.$gt.$lt.'input type="submit" value="Unblock XMLRPC Access" /'."$gt$lt/div$gt$lt".'div style="padding: 0 30px;"'.$gt.$lt.'p'.$gt.$lt.'b'.$gt.$lt.'img src="'.GOTMLS_images_path.'checked.gif"'.$gt.'Block XMLRPC Access (Now Blocked';
756 elseif ($GOTMLS_nonce_found && isset($_POST["GOTMLS_XMLRPC_patching"]) && ($_POST["GOTMLS_XMLRPC_patching"] > 0))
757 $patch_action .= '1"'.$gt.$lt.'input type="submit" value="Block XMLRPC Access" /'."$gt$lt/div$gt$lt".'div style="padding: 0 30px;"'.$gt.$lt.'p'.$gt.$lt.'b'.$gt.$lt.'img src="'.GOTMLS_images_path.'threat.gif"'.$gt.'Block XMLRPC Access (Still Allowing Access: '.sprintf(__("Failed to install XMLRPC Protection [.htaccess %s]",'gotmls'),(is_readable(ABSPATH.'.htaccess')?'read-'.(is_writable(ABSPATH.'.htaccess')?'write?':'only!'):"unreadable!").": ".strlen($htaccess).GOTMLS_fileperms(ABSPATH.'.htaccess'));
758 else
759 $patch_action .= '1"'.$gt.$lt.'input type="submit" value="Block XMLRPC Access" /'."$gt$lt/div$gt$lt".'div style="padding: 0 30px;"'.$gt.$lt.'p'.$gt.$lt.'b'.$gt.$lt.'img src="'.GOTMLS_images_path.'question.gif"'.$gt.'Block XMLRPC Access (Currently Allowing Access';
760 }
761 $patch_action .= ")$lt/b$gt$lt/p$gt".__("Most WordPress site do not use the XMLRPC features and hack attempt on the xmlrpc.php file are more common then ever before. Even if there are no vulnerabilities for hackers to exploit these attempts can cause slowness or downtime similar to a DDoS attack. This patch automatically blocks all external access to the xmlrpc.php file.",'gotmls').$lt.'/div'.$gt.$lt.'/form'.$gt.$lt.'hr /'.$gt;
762 $patch_status = 0;
763 $patch_found = -1;
764 $find = "#if\s*\(([^\&]+\&\&)?\s*file_exists\((.+?)(safe-load|wp-login)\.php'\)\)\s*require(_once)?\((.+?)(safe-load|wp-login)\.php'\);#";
765 $head = str_replace(array('#', '\\(', '\\)', '(_once)?', ')\\.', '\\s*', '(.+?)(', '|', '([^\\&]+\\&\\&)?'), array(' ', '(', ')', '_once', '.', ' ', '\''.dirname(__FILE__).'/', '/', '!in_array($_SERVER["REMOTE_ADDR"], array("'.$_SERVER["REMOTE_ADDR"].'")) &&'), $find);
766 if (is_file(ABSPATH.'../wp-config.php') && !is_file(ABSPATH.'wp-config.php'))
767 $wp_config = '../wp-config.php';
768 else
769 $wp_config = 'wp-config.php';
770 if (is_file(ABSPATH.$wp_config)) {
771 if (($config = @file_get_contents(ABSPATH.$wp_config)) && strlen($config)) {
772 if ($patch_found = preg_match($find, $config)) {
773 if (strpos($config, substr($head, strpos($head, "file_exists")))) {
774 if ($GOTMLS_nonce_found && isset($_POST["GOTMLS_patching"]) && GOTMLS_file_put_contents(ABSPATH.$wp_config, preg_replace('#'.$lt.'\?[ph\s]+(//.*\s*)*\?'.$gt.'#i', "", preg_replace($find, "", $config))))
775 $patch_action .= $lt.'div class="error"'.$gt.__("Removed Brute-Force Protection",'gotmls').$lt.'/div'.$gt;
776 else
777 $patch_status = 1;
778 } else {
779 if ($GOTMLS_nonce_found && isset($_POST["GOTMLS_patching"]) && GOTMLS_file_put_contents(ABSPATH.$wp_config, preg_replace($find, "$head", $config))) {
780 $patch_action .= $lt.'div class="updated"'.$gt.__("Upgraded Brute-Force Protection",'gotmls').$lt.'/div'.$gt;
781 $patch_status = 1;
782 } else
783 $patch_status = 2;
784 }
785 } elseif ($GOTMLS_nonce_found && isset($_POST["GOTMLS_patching"]) && strlen($config) && ($patch_found == 0) && GOTMLS_file_put_contents(ABSPATH.$wp_config, "$lt?php$head// Load Brute-Force Protection by GOTMLS.NET before the WordPress bootstrap. ?$gt$config")) {
786 $patch_action .= $lt.'div class="updated"'.$gt.__("Installed Brute-Force Protection",'gotmls').$lt.'/div'.$gt;
787 $patch_status = 1;
788 } elseif ($GOTMLS_nonce_found && isset($_POST["GOTMLS_patching"]))
789 $patch_action .= $lt.'div class="updated"'.$gt.sprintf(__("Failed to install Brute-Force Protection (wp-config.php %s)",'gotmls'),(is_readable(ABSPATH.$wp_config)?'read-'.(is_writable(ABSPATH.$wp_config)?'write':'only'):"unreadable").": ".strlen($config).GOTMLS_fileperms(ABSPATH.$wp_config)).$lt.'/div'.$gt;
790 } else
791 $patch_action .= $lt.'div class="error"'.$gt.__("wp-config.php Not Readable!",'gotmls').$lt.'/div'.$gt;
792 } else
793 $patch_action .= $lt.'div class="error"'.$gt.__("wp-config.php Not Found!",'gotmls').$lt.'/div'.$gt;
794 if ($GOTMLS_nonce_found && file_exists(ABSPATH.'wp-login.php') && ($login = @file_get_contents(ABSPATH.'wp-login.php')) && strlen($login) && (preg_match($find, $login))) {
795 if (isset($_POST["GOTMLS_patching"]) && ($source = GOTMLS_get_URL("http://core.svn.wordpress.org/tags/".$wp_version.'/wp-login.php')) && (strlen($source) > 500) && GOTMLS_file_put_contents(ABSPATH.'wp-login.php', $source))
796 $patch_action .= $lt.'div class="updated"'.$gt.__("Removed Old Brute-Force Login Patch",'gotmls').$lt.'/div'.$gt;
797 else
798 $patch_status = 2;
799 }
800 $sec_opts = $lt.'div style="padding: 0 30px;"'.$gt.$lt.'p'.$gt.$lt.'img src="'.GOTMLS_images_path.'checked.gif"'.$gt.$lt.'b'.$gt.'Revolution Slider Exploit Protection (Automatically Enabled)'.$lt.'/b'.$gt.$lt.'/p'.$gt.__("This protection is automatically activated with this plugin because of the widespread attack on WordPress that are affecting so many site right now. It is still recommended that you make sure to upgrade and older versions of the Revolution Slider plugin, especially those included in some themes that will not update automatically. Even if you do not have Revolution Slider on your site it still can't hurt to have this protection installed.",'gotmls').$lt.'/div'.$gt.$lt.'hr /'.$gt.'
801 '.$patch_action.'
802 '.$lt.'form method="POST" name="GOTMLS_Form_patch"'.$gt.$lt.'div style="float: right;"'.$gt.$lt.'input type="hidden" name="'.str_replace('=', '" value="', GOTMLS_set_nonce(__FUNCTION__."1223")).'"'.$gt.$lt.'input type="submit" value="'.$patch_attr[$patch_status]["action"].'" style="'.($patch_status?'"'.$gt:' display: none;" id="GOTMLS_patch_button"'.$gt.$lt.'div id="GOTMLS_patch_searching" style="float: right;"'.$gt.__("Checking for session compatibility ...",'gotmls').' '.$lt.'img src="'.GOTMLS_images_path.'wait.gif" height=16 width=16 alt="Wait..." /'.$gt.$lt.'/div'.$gt).$lt.'input type="hidden" name="GOTMLS_patching" value="1"'.$gt.$lt.'/div'.$gt.$lt.'div style="padding: 0 30px;"'.$gt.$lt.'p'.$gt.$lt.'img src="'.GOTMLS_images_path.$patch_attr[$patch_status]["icon"].'.gif"'.$gt.$lt.'b'.$gt.'Brute-force Protection '.$patch_attr[$patch_status]["status"].$lt.'/b'.$gt.$lt.'/p'.$gt.$patch_attr[$patch_status]["language"].__(" For more information on Brute-Force attack prevention and the WordPress wp-login-php file ",'gotmls').' '.$lt.'a target="_blank" href="http://gotmls.net/tag/wp-login-php/"'.$gt.__("read my blog",'gotmls')."$lt/a$gt.$lt/div$gt$lt/form$gt\n{$lt}script type='text/javascript'$gt\nfunction search_patch_onload() {\n\tstopCheckingSession = checkupdateserver('".GOTMLS_images_path."gotmls.js?SESSION=0', 'GOTMLS_patch_searching');\n}\nif (window.addEventListener)\n\twindow.addEventListener('load', search_patch_onload)\nelse\n\tdocument.attachEvent('onload', search_patch_onload);\n$lt/script$gt";
803 $admin_notice = "";
804 if ($current_user->user_login == "admin") {
805 $admin_notice .= $lt.'hr /'.$gt;
806 if ($GOTMLS_nonce_found && isset($_POST["GOTMLS_admin_username"]) && ($current_user->user_login != trim($_POST["GOTMLS_admin_username"])) && strlen(trim($_POST["GOTMLS_admin_username"])) && preg_match('/^\s*[a-z_0-9\@\.\-]{3,}\s*$/i', $_POST["GOTMLS_admin_username"])) {
807 if ($wpdb->update($wpdb->users, array("user_login" => trim($_POST["GOTMLS_admin_username"])), array("user_login" => $current_user->user_login)))
808 $admin_notice .= $lt.'div class="updated"'.$gt.sprintf(__("You username has been change to %s. Don't forget to use your new username when you login again.",'gotmls'), $_POST["GOTMLS_admin_username"]).$lt.'/div'.$gt;
809 else
810 $admin_notice .= $lt.'div class="error"'.$gt.sprintf(__("SQL Error changing username: %s. Please try again later.",'gotmls'), $wpdb->last_error).$lt.'/div'.$gt;
811 } else {
812 if (isset($_POST["GOTMLS_admin_username"]))
813 $admin_notice .= $lt.'div class="updated"'.$gt.sprintf(__("Your new username must be at least 3 characters and can only contain &quot;%s&quot;. Please try again.",'gotmls'), "a-z0-9_.-@").$lt.'/div'.$gt;
814 $admin_notice .= $lt.'form method="POST" name="GOTMLS_Form_admin"'.$gt.$lt.'div style="float: right;"'.$gt.$lt.'div style="float: left;"'.$gt.__("Change your username:",'gotmls').$lt.'/div'.$gt.$lt.'input type="hidden" name="'.str_replace('=', '" value="', GOTMLS_set_nonce(__FUNCTION__."1235")).'"'.$gt.$lt.'input style="float: left;" type="text" id="GOTMLS_admin_username" name="GOTMLS_admin_username" size="6" value="'.$current_user->user_login.'"'.$gt.$lt.'input style="float: left;" type="submit" value="Change"'.$gt.$lt.'/div'.$gt.$lt.'div style="padding: 0 30px;"'.$gt.$lt.'p'.$gt.$lt.'img src="'.GOTMLS_images_path.'threat.gif"'.$gt.$lt.'b'.$gt.'Admin Notice'.$lt.'/b'.$gt.$lt.'/p'.$gt.__("Your username is \"admin\", this is the most commonly guessed username by hackers and brute-force scripts. It is highly recommended that you change your username immediately.",'gotmls').$lt.'/div'.$gt.$lt.'/form'.$gt;
815 }
816 }
817 if ($GOTMLS_nonce_found && isset($_POST["GOTMLS_wpfirewall_action"])) {
818 if ($_POST["GOTMLS_wpfirewall_action"] == "exclude_terms")
819 update_option("WP_firewall_exclude_terms", "");
820 elseif ($_POST["GOTMLS_wpfirewall_action"] == "whitelisted_ip" && isset($_SERVER["REMOTE_ADDR"])) {
821 $ips = maybe_unserialize(get_option("WP_firewall_whitelisted_ip", "not Array!"));
822 if (is_array($ips))
823 $ips = array_merge($ips, array($_SERVER["REMOTE_ADDR"]));
824 else
825 $ips = array($_SERVER["REMOTE_ADDR"]);
826 update_option("WP_firewall_whitelisted_ip", serialize($ips));
827 }
828 }
829 if (get_option("WP_firewall_exclude_terms", "Not Found!") == "allow") {
830 $end = "$lt/div$gt$lt/form$gt\n{$lt}hr /$gt";
831 $img = 'threat.gif"';
832 $button = $lt.'input type="submit" onclick="document.getElementById(\'GOTMLS_wpfirewall_action\').value=\'exclude_terms\';" value="'.__("Disable this Rule",'gotmls').'"'.$gt;
833 $wpfirewall_action = $lt.'form method="POST" name="GOTMLS_Form_wpfirewall2"'.$gt.$lt.'div style="float: right;"'.$gt.$lt.'input type="hidden" name="GOTMLS_wpfirewall_action" id="GOTMLS_wpfirewall_action" value=""'.$gt.$lt.'input type="hidden" name="'.str_replace('=', '" value="', GOTMLS_set_nonce(__FUNCTION__."1223")).'"'.$gt.$button.$lt.'/div'.$gt.$lt.'div style="padding: 0 30px;"'.$gt.$lt.'p'.$gt.$lt.'img src="'.GOTMLS_images_path.$img.$gt.$lt.'b'.$gt."WP Firewall 2 (Conflicting Firewall Rule)$lt/b$gt$lt/p$gt".__("The Conflicting Firewall Rule (WP_firewall_exclude_terms) activated by the WP Firewall 2 plugin has been shown to interfere with the Definition Updates and WP Core File Scans in my Anti-Malware plugin. I recommend that you disable this rule in the WP Firewall 2 plugin.",'gotmls').$end;
834 if (isset($_SERVER["REMOTE_ADDR"])) {
835 if (is_array($ips = maybe_unserialize(get_option("WP_firewall_whitelisted_ip", "not Array!"))) && in_array($_SERVER["REMOTE_ADDR"], $ips))
836 $wpfirewall_action = str_replace(array($img, $end), array('question.gif"', __(" However, your current IP has been Whitelisted so you could probably keep this rule enabled if you really want to.",'gotmls').$end), $wpfirewall_action);
837 else
838 $wpfirewall_action = str_replace(array($button, $end), array($button.$lt."br /$gt$lt".'input type="submit" onclick="document.getElementById(\'GOTMLS_wpfirewall_action\').value=\'whitelisted_ip\';" value="'.__("Whitelist your IP",'gotmls').'"'.$gt, __(" However, if you would like to keep this rule enabled you should at least Whitelist your IP.",'gotmls').$end), $wpfirewall_action);
839 }
840 $sec_opts = $wpfirewall_action.$sec_opts;
841 }
842 echo GOTMLS_box(__("Firewall Options",'gotmls'), $sec_opts.$admin_notice)."\n</div></div></div>";
843 }
844
845 function GOTMLS_update_definitions() {
846 global $wp_version;
847 $GOTMLS_definitions_versions = array();
848 foreach ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"] as $threat_level=>$definition_names)
849 foreach ($definition_names as $definition_name=>$definition_version)
850 if (is_array($definition_version) && isset($definition_version[0]) && strlen($definition_version[0]) == 5)
851 if (!isset($GOTMLS_definitions_versions[$threat_level]) || $definition_version[0] > $GOTMLS_definitions_versions[$threat_level])
852 $GOTMLS_definitions_versions[$threat_level] = $definition_version[0];
853 if (isset($_POST["UPDATE_definitions_array"]) && strlen($_POST["UPDATE_definitions_array"]) && GOTMLS_get_nonce()) {
854 if (strlen($_POST["UPDATE_definitions_array"]) > 1) {
855 $GOTnew_definitions = maybe_unserialize(GOTMLS_decode($_POST["UPDATE_definitions_array"]));
856 if (is_array($GOTnew_definitions))
857 $GLOBALS["GOTMLS"]["tmp"]["onLoad"] .= "updates_complete('Downloaded Definitions');";
858 } elseif (($DEF = GOTMLS_get_URL(GOTMLS_update_home.'definitions.php?ver='.GOTMLS_Version.'&wp='.$wp_version.'&ts='.date("YmdHis").'&d='.ur1encode(GOTMLS_siteurl))) && (($GOT_definitions = GOTMLS_decode($DEF)) != serialize($GLOBALS["GOTMLS"]["tmp"]["definitions_array"])) && is_array($GOTnew_definitions = maybe_unserialize($GOT_definitions)) && count($GOTnew_definitions)) {
859 if (!(isset($_REQUEST["check"]) && is_array($_REQUEST["check"])))
860 $_REQUEST["check"] = array();
861 foreach ($GOTnew_definitions as $threat_level=>$definition_names)
862 if (!isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["$threat_level"]) && !(is_array($GLOBALS["GOTMLS"]["tmp"]["settings"]["check"]) && in_array("$threat_level", $GLOBALS["GOTMLS"]["tmp"]["settings"]["check"])) && !in_array("$threat_level", $_REQUEST["check"]))
863 $_REQUEST["check"][] = "$threat_level";
864 $GLOBALS["GOTMLS"]["tmp"]["definitions_array"] = $GOTnew_definitions;
865 $GOTnew_definitions = array();
866 $GLOBALS["GOTMLS"]["tmp"]["onLoad"] .= "updates_complete('New Definitions Automatically Installed :-)');";
867 } else
868 $GOTnew_definitions = "";
869 } //elseif (file_exists(GOTMLS_plugin_path.'definitions_update.txt')) $GOTnew_definitions = maybe_unserialize(GOTMLS_decode(file_get_contents(GOTMLS_plugin_path.'definitions_update.txt')));
870 if (isset($GOTnew_definitions) && is_array($GOTnew_definitions)) {
871 $GLOBALS["GOTMLS"]["tmp"]["definitions_array"] = GOTMLS_array_replace_recursive($GLOBALS["GOTMLS"]["tmp"]["definitions_array"], $GOTnew_definitions);
872 if (file_exists(GOTMLS_plugin_path.'definitions_update.txt'))
873 @unlink(GOTMLS_plugin_path.'definitions_update.txt');
874 if (isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"]))
875 unset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"]);
876 update_option('GOTMLS_definitions_array', $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]);
877 foreach ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"] as $threat_level=>$definition_names)
878 foreach ($definition_names as $definition_name=>$definition_version)
879 if (is_array($definition_version) && isset($definition_version[0]) && strlen($definition_version[0]) == 5)
880 if (!isset($GOTMLS_definitions_versions[$threat_level]) || $definition_version[0] > $GOTMLS_definitions_versions[$threat_level])
881 $GOTMLS_definitions_versions[$threat_level] = $definition_version[0];
882 }
883 $GLOBALS["GOTMLS"]["tmp"]["Definition"]["Updates"] = '?div=Definition_Updates';
884 asort($GOTMLS_definitions_versions);
885 foreach ($GOTMLS_definitions_versions as $definition_name=>$GLOBALS["GOTMLS"]["tmp"]["Definition"]["Latest"])
886 $GLOBALS["GOTMLS"]["tmp"]["Definition"]["Updates"] .= "&ver[$definition_name]=".$GLOBALS["GOTMLS"]["tmp"]["Definition"]["Latest"];
887 }
888
889 function GOTMLS_settings() {
890 global $current_user, $wpdb, $wp_version, $GOTMLS_dirs_at_depth, $GOTMLS_dir_at_depth;
891 $GOTMLS_scan_groups = array();
892 $gt = ">";
893 $lt = "<";
894 GOTMLS_update_definitions();
895 if (($GOTMLS_nonce_found = GOTMLS_get_nonce()) && isset($_REQUEST["check"]) && is_array($_REQUEST["check"]))
896 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"] = $_REQUEST["check"];
897 /* $threat_names = array_keys($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["known"]);
898 foreach ($threat_names as $threat_name) {
899 if (isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["known"][$threat_name]) && is_array($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["known"][$threat_name]) && count($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["known"][$threat_name]) > 1) {
900 if ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["known"][$threat_name][0] > $GOTMLS_definitions_version)
901 $GOTMLS_definitions_version = $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["known"][$threat_name][0];
902 if (!(count($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"]) && in_array($threat_name, $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"]))) {
903 $GLOBALS["GOTMLS"]["tmp"]["threat_levels"][$threat_name] = count($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["known"][$threat_name]);
904 if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"]) && $GLOBALS["GOTMLS"]["tmp"]["threat_levels"][$threat_name] > 2)
905 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"] = "known";
906 }
907 }
908 }*/
909 if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"])) {
910 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"] = $GLOBALS["GOTMLS"]["tmp"]["threat_levels"];
911 update_option("GOTMLS_settings_array", $GLOBALS["GOTMLS"]["tmp"]["settings_array"]);
912 }
913 $dirs = GOTMLS_explode_dir(__FILE__);
914 for ($SL=0;$SL<intval($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_level"]);$SL++)
915 $GOTMLS_scan_groups[] = $lt.'b'.$gt.implode(GOTMLS_slash(), array_slice($dirs, -1 * (3 + $SL), 1)).$lt.'/b'.$gt;
916 if (isset($_POST["exclude_ext"])) {
917 if (strlen(trim(str_replace(",","",$_POST["exclude_ext"]).' ')) > 0)
918 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_ext"] = preg_split('/[\s]*([,]+[\s]*)+/', trim(str_replace('.', ',', htmlentities($_POST["exclude_ext"]))), -1, PREG_SPLIT_NO_EMPTY);
919 else
920 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_ext"] = array();
921 }
922 $default_exclude_ext = str_replace(",gotmls", "", implode(",", $GLOBALS["GOTMLS"]["tmp"]["skip_ext"]));
923 $GLOBALS["GOTMLS"]["tmp"]["skip_ext"] = $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_ext"];
924 if (isset($_POST["UPDATE_definitions_checkbox"])) {
925 if (isset($_POST[$_POST["UPDATE_definitions_checkbox"]]) && $_POST[$_POST["UPDATE_definitions_checkbox"]] == 1)
926 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["auto_UPDATE_definitions"] = 1;
927 else
928 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["auto_UPDATE_definitions"] = "";
929 }
930 if (isset($_POST["exclude_dir"])) {
931 if (strlen(trim(str_replace(",","",$_POST["exclude_dir"]).' ')) > 0)
932 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_dir"] = preg_split('/[\s]*([,]+[\s]*)+/', trim(htmlentities($_POST["exclude_dir"])), -1, PREG_SPLIT_NO_EMPTY);
933 else
934 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_dir"] = array();
935 for ($d=0; $d<count($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_dir"]); $d++)
936 if (dirname($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_dir"][$d]) != ".")
937 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_dir"][$d] = str_replace("\\", "", str_replace("/", "", str_replace(dirname($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_dir"][$d]), "", $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_dir"][$d])));
938 }
939 $GLOBALS["GOTMLS"]["tmp"]["skip_dirs"] = array_merge($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_dir"], $GLOBALS["GOTMLS"]["tmp"]["skip_dirs"]);
940 if (isset($_POST["scan_what"]) && is_numeric($_POST["scan_what"]) && $_POST["scan_what"] != $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_what"])
941 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_what"] = $_POST["scan_what"];
942 if (isset($_POST["check_custom"]) && $_POST["check_custom"] != $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check_custom"])
943 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check_custom"] = stripslashes($_POST["check_custom"]);
944 if (isset($_POST["scan_depth"]) && is_numeric($_POST["scan_depth"]) && $_POST["scan_depth"] != $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_depth"])
945 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_depth"] = $_POST["scan_depth"];
946 if (isset($_POST['check_htaccess']) && is_numeric($_POST['check_htaccess']) && $_POST['check_htaccess'] != $GLOBALS["GOTMLS"]["tmp"]["settings_array"]['check_htaccess'])
947 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]['check_htaccess'] = $_POST['check_htaccess'];
948 if (isset($_POST['check_timthumb']) && is_numeric($_POST['check_timthumb']) && $_POST['check_timthumb'] != $GLOBALS["GOTMLS"]["tmp"]["settings_array"]['check_timthumb'])
949 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]['check_timthumb'] = $_POST['check_timthumb'];
950 if (isset($_POST['check_wp_core']) && is_numeric($_POST['check_wp_core']) && $_POST['check_wp_core'] != $GLOBALS["GOTMLS"]["tmp"]["settings_array"]['check_wp_core'])
951 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]['check_wp_core'] = $_POST['check_wp_core'];
952 if (isset($_POST['check_known']) && is_numeric($_POST['check_known']) && $_POST['check_known'] != $GLOBALS["GOTMLS"]["tmp"]["settings_array"]['check_known'])
953 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]['check_known'] = $_POST['check_known'];
954 if (isset($_POST['check_potential']) && is_numeric($_POST['check_potential']) && $_POST['check_potential'] != $GLOBALS["GOTMLS"]["tmp"]["settings_array"]['check_potential'])
955 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]['check_potential'] = $_POST['check_potential'];
956 if (isset($_POST['skip_quarantine']) && $_POST['skip_quarantine'])
957 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]['skip_quarantine'] = $_POST['skip_quarantine'];
958 elseif (isset($_POST["exclude_ext"]))
959 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]['skip_quarantine'] = 0;
960 GOTMLS_update_scan_log(array("settings" => $GLOBALS["GOTMLS"]["tmp"]["settings_array"]));
961 $scan_whatopts = '';
962 $scan_optjs = "\n{$lt}script type=\"text/javascript\"$gt\nfunction showOnly(what) {\n";
963 foreach ($GOTMLS_scan_groups as $mg => $GOTMLS_scan_group) {
964 $scan_optjs .= "document.getElementById('only$mg').style.display = 'none';\n";
965 $scan_whatopts = "\n$lt/div$gt\n$lt/div$gt\n$scan_whatopts";
966 $dir = implode(GOTMLS_slash(), array_slice($dirs, 0, -1 * (2 + $mg)));
967 $files = GOTMLS_getfiles($dir);
968 if (is_array($files))
969 foreach ($files as $file)
970 if (is_dir(GOTMLS_trailingslashit($dir).$file))
971 $scan_whatopts = $lt.'input type="checkbox" name="scan_only[]" value="'.htmlentities($file).'" /'.$gt.htmlentities($file).$lt.'br /'.$gt.$scan_whatopts;
972 $scan_whatopts = "\n$lt".'div style="padding: 4px 30px;" id="scan_group_div_'.$mg.'"'.$gt.$lt.'input type="radio" name="scan_what" id="not-only'.$mg.'" value="'.$mg.'"'.($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_what"]==$mg?' checked':'').' /'.$gt.$lt.'a style="text-decoration: none;" href="#scan_what" onclick="showOnly(\''.$mg.'\');document.getElementById(\'not-only'.$mg.'\').checked=true;"'."$gt$GOTMLS_scan_group$lt/a$gt{$lt}br /$gt\n$lt".'div class="rounded-corners" style="position: absolute; display: none; background-color: #CCF; margin: 0; padding: 10px; z-index: 10;" id="only'.$mg.'"'.$gt.$lt.'div style="padding-bottom: 6px;"'.$gt.GOTMLS_close_button('only'.$mg, 0).$lt.'b'.$gt.str_replace(" ", "&nbsp;", __("Only Scan These Folders:",'gotmls')).$lt.'/b'.$gt.$lt.'/div'.$gt.$scan_whatopts;
973 }
974 $scan_optjs .= "document.getElementById('only'+what).style.display = 'block';\n}".((isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["auto_UPDATE_definitions"]) && $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["auto_UPDATE_definitions"])?"\nfunction auto_UPDATE_check() {\n\tif (auto_UPdef_check = document.getElementById('auto_UPDATE_definitions_check'))\n\t\tauto_UPdef_check.checked = true;\n}\nif (window.addEventListener)\n\twindow.addEventListener('load', auto_UPDATE_check)\nelse\n\tdocument.attachEvent('onload', auto_UPDATE_check);\n":"")."$lt/script$gt";
975 $GOTMLS_nonce_URL = GOTMLS_set_nonce(__FUNCTION__."853");
976 $scan_opts = "\n$lt".'form method="POST" name="GOTMLS_Form"'.$gt.$lt.'input type="hidden" name="'.str_replace('=', '" value="', $GOTMLS_nonce_URL).'"'.$gt.$lt.'input type="hidden" name="scan_type" id="scan_type" value="Complete Scan" /'.$gt.$lt.'div style="float: right;"'.$gt.$lt.'input type="submit" id="complete_scan" value="'.__("Run Complete Scan",'gotmls').'" class="button-primary" onclick="document.getElementById(\'scan_type\').value=\'Complete Scan\';" /'.$gt.$lt.'/div'.$gt.'
977 '.$lt.'div style="float: left;"'.$gt.$lt.'p'.$gt.$lt.'b'.$gt.__("What to look for:",'gotmls').$lt.'/b'.$gt.$lt.'/p'.$gt.'
978 '.$lt.'div style="padding: 0 30px;"'.$gt;
979 foreach ($GLOBALS["GOTMLS"]["tmp"]["threat_levels"] as $threat_level_name=>$threat_level) {
980 $scan_opts .= $lt.'div style="padding: 0; position: relative;" id="check_'.$threat_level.'_div"'.$gt;
981 if (($threat_level != "wp_core" && isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"][$threat_level])) || isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"][$threat_level]["$wp_version"])) {
982 $scan_opts .= $lt.'input type="checkbox" name="check[]" id="check_'.$threat_level.'_Yes" value="'.$threat_level.'"'.(in_array($threat_level,$GLOBALS["GOTMLS"]["log"]["settings"]["check"])?' checked':'').' /'.$gt.' '.$lt.'a style="text-decoration: none;" href="#check_'.$threat_level.'_div_0" onclick="document.getElementById(\'check_'.$threat_level.'_Yes\').checked=true;showhide(\'dont_check_'.$threat_level.'\');"'."$gt{$lt}b$gt$threat_level_name$lt/b$gt$lt/a$gt\n";
983 if (isset($_GET["SESSION"])) {
984 if (isset($_SESSION["GOTMLS_debug"][$threat_level]))
985 $lt.'div style="float: right;"'.$gt.print_r($_SESSION["GOTMLS_debug"][$threat_level],1)."$lt/div$gt";
986 $scan_opts .= "\n$lt".'div style="padding: 0 20px; position: relative; top: -18px; display: none;" id="dont_check_'.$threat_level.'"'.$gt.$lt.'a class="rounded-corners" style="position: absolute; left: 0; margin: 0; padding: 0 4px; text-decoration: none; color: #C00; background-color: #FCC; border: solid #F00 1px;" href="#check_'.$threat_level.'_div_0" onclick="showhide(\'dont_check_'.$threat_level.'\');"'.$gt.'X'.$lt.'/a'.$gt;
987 foreach ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"][$threat_level] as $threat_name => $threat_regex)
988 $scan_opts .= $lt."br /$gt\n$lt".'input type="checkbox" name="dont_check[]" value="'.htmlspecialchars($threat_name).'"'.(in_array($threat_name, $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"])?' checked /'.$gt.$lt.'script'.$gt.'showhide("dont_check_'.$threat_level.'", true);'.$lt.'/script'.$gt:' /'.$gt).(isset($_SESSION["GOTMLS_debug"][$threat_name])?$lt.'div style="float: right;"'.$gt.print_r($_SESSION["GOTMLS_debug"][$threat_name],1)."$lt/div$gt":"").$threat_name;
989 $scan_opts .= "\n$lt/div$gt";
990 }
991 } else
992 $scan_opts .= $lt.'a title="'.__("Download Definition Updates to Use this feature",'gotmls').'"'.$gt.$lt.'img src="'.GOTMLS_images_path.'blocked.gif" height=16 width=16 alt="X"'.$gt.$lt.'b'.$gt.'&nbsp; '.$threat_level_name.$lt.'/b'.$gt.$lt.'br /'.$gt.$lt.'div style="padding: 14px;" id="check_'.$threat_level.'_div_NA"'.$gt.$lt.'span style="color: #F00"'.$gt.__("Download the new definitions (Right sidebar) to activate this feature.",'gotmls')."$lt/span$gt$lt/div$gt";
993 $scan_opts .= "\n$lt/div$gt";
994 }
995 $scan_opts .= $lt.'/div'.$gt.$lt.'/div'.$gt.'
996 '.$lt.'div style="float: left;"'.$gt.$lt.'p'.$gt.$lt.'b'.$gt.__("What to scan:",'gotmls').$lt.'/b'.$gt.$lt.'/p'.$gt.$scan_whatopts.$scan_optjs.$lt.'/div'.$gt.'
997 '.$lt.'div style="float: left;" id="scanwhatfolder"'.$gt.$lt.'/div'.$gt.'
998 '.$lt.'div style="float: left;"'.$gt.$lt.'p'.$gt.$lt.'b'.$gt.__("Scan Depth:",'gotmls').$lt.'/b'.$gt.$lt.'/p'.$gt.'
999 '.$lt.'div style="padding: 0 30px;"'.$gt.$lt.'input type="text" value="'.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_depth"].'" name="scan_depth" size="5"'.$gt.$lt.'br /'.$gt.__("how far to drill down",'gotmls').$lt.'br /'.$gt.'('.__("-1 is infinite depth",'gotmls').')'.$lt.'/div'.$gt.$lt.'/div'.$gt.$lt.'br style="clear: left;"'.$gt;
1000 if (isset($_GET["SESSION"]) && isset($_SESSION["GOTMLS_debug"]['total'])) {$scan_opts .= $lt.'div style="float: right;"'.$gt.print_r($_SESSION["GOTMLS_debug"]['total'],1)."$lt/div$gt"; unset($_SESSION["GOTMLS_debug"]);}
1001 if (isset($_GET["eli"])) {//still testing this option
1002 $scan_opts .= "\n$lt".'div style="padding: 10px;"'.$gt.$lt.'p'.$gt.$lt.'b'.$gt.__("Custom RegExp:",'gotmls').$lt.'/b'.$gt.' ('.__("For very advanced users only. Do not use this without talking to Eli first. If used incorrectly you could easily break your site.",'gotmls').')'.$lt.'/p'.$gt.$lt.'input type="text" name="check_custom" style="width: 100%;" value="'.htmlspecialchars($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check_custom"]).'" /'."$gt$lt/div$gt\n$lt".'div style="padding: 10px;"'.$gt.$lt.'p'.$gt.$lt.'b'.$gt.__("Custom Code to be Checked:",'gotmls').$lt.'/b'.$gt.' ('.__("For very advanced users only. If you enter anything in this box then no other files will be scanned on your site.",'gotmls').')'.$lt.'/p'.$gt.$lt.'textarea name="check_code" style="width: 100%;" rows=3'.$gt.htmlspecialchars($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check_code"])."$lt/textarea$gt$lt/div$gt\n";
1003 }
1004 $QuickScan = $lt.((is_dir(dirname(__FILE__)."/../../../wp-includes") && is_dir(dirname(__FILE__)."/../../../wp-admin"))?'a href="'.admin_url("admin.php?page=GOTMLS-settings&scan_type=Quick+Scan&$GOTMLS_nonce_URL").'" class="button-primary" style="height: 22px; line-height: 13px; padding: 3px;">WP_Core</a':"!-- No wp-includes or wp-admin --").$gt;
1005 foreach (array("Plugins", "Themes") as $ScanFolder)
1006 $QuickScan .= '&nbsp;'.$lt.((is_dir(dirname(__FILE__)."/../../../wp-content/".strtolower($ScanFolder)))?'a href="'.admin_url("admin.php?page=GOTMLS-settings&scan_type=Quick+Scan&scan_only[]=wp-content/".strtolower($ScanFolder)."&$GOTMLS_nonce_URL")."\" class=\"button-primary\" style=\"height: 22px; line-height: 13px; padding: 3px;\"$gt$ScanFolder$lt/a":"!-- No $ScanFolder in wp-content --").$gt;
1007 $scan_opts .= "\n$lt".'p'.$gt.$lt.'b'.$gt.__("Skip files with the following extentions:",'gotmls')."$lt/b$gt".(($default_exclude_ext!=implode(",", $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_ext"]))?" {$lt}a href=\"javascript:void(0);\" onclick=\"document.getElementById('exclude_ext').value = '$default_exclude_ext';\"{$gt}[Restore Defaults]$lt/a$gt":"").$lt.'/p'.$gt.'
1008 '.$lt.'div style="padding: 0 30px;"'.$gt.$lt.'input type="text" placeholder="'.__("a comma separated list of file extentions to skip",'gotmls').'" name="exclude_ext" id="exclude_ext" value="'.implode(",", $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_ext"]).'" style="width: 100%;" /'."$gt$lt/div$gt$lt".'p'.$gt.$lt.'b'.$gt.__("Skip directories with the following names:",'gotmls')."$lt/b$gt$lt/p$gt$lt".'div style="padding: 0 30px;"'.$gt.$lt.'input type="text" placeholder="'.__("a folder name or comma separated list of folder names to skip",'gotmls').'" name="exclude_dir" value="'.implode(",", $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_dir"]).'" style="width: 100%;" /'.$gt.$lt.'/div'.$gt.'
1009 '.$lt.'table style="width: 100%" cellspacing="10"'.$gt.$lt.'tr'.$gt.$lt.'td nowrap valign="top" style="white-space: nowrap; width: 1px;"'.$gt.$lt.'b'.$gt.__("Automatically Update Definitions:",'gotmls').$lt."br$gt$lt/b$gt$lt/td$gt$lt".'td'.$gt.$lt.'div id="UPDATE_definitions_div"'.$gt.$lt.'br'.$gt.$lt.'span style="color: #C00;"'.$gt.__("This new BETA feature is only available to registered users who have donated at a certain level.",'gotmls')."$lt/span$gt$lt/div$gt$lt/td$gt$lt".'td align="right" valign="bottom"'.$gt.$lt.'input type="submit" id="save_settings" value="'.__("Save Settings",'gotmls').'" class="button-primary" onclick="document.getElementById(\'scan_type\').value=\'Save\';" /'."$gt$lt/td$gt$lt/tr$gt$lt/table$gt$lt/form$gt";
1010 @ob_start();
1011 $OB_default_handlers = array("default output handler", "zlib output compression");
1012 $OB_handlers = @ob_list_handlers();
1013 if (is_array($OB_handlers) && count($OB_handlers))
1014 foreach ($OB_handlers as $OB_last_handler)
1015 if (!in_array($OB_last_handler, $OB_default_handlers))
1016 echo $lt.'div class="error"'.$gt.sprintf(__("Another Plugin or Theme is using '%s' to handle output buffers. <br />This prevents actively outputing the buffer on-the-fly and will severely degrade the performance of this (and many other) Plugins. <br />Consider disabling caching and compression plugins (at least during the scanning process).",'gotmls'), $OB_last_handler)."$lt/div$gt";
1017 GOTMLS_display_header();
1018 $scan_groups = array_merge(array(__("Scanned Files",'gotmls')=>"scanned",__("Selected Folders",'gotmls')=>"dirs",__("Scanned Folders",'gotmls')=>"dir",__("Skipped Folders",'gotmls')=>"skipdirs",__("Skipped Files",'gotmls')=>"skipped",__("Read/Write Errors",'gotmls')=>"errors",__("Quarantined Files",'gotmls')=>"bad"), $GLOBALS["GOTMLS"]["tmp"]["threat_levels"]);
1019 echo $lt.'script type="text/javascript">
1020 var percent = 0;
1021 function changeFavicon(percent) {
1022 var oldLink = document.getElementById("wait_gif");
1023 if (oldLink) {
1024 if (percent >= 100) {
1025 document.getElementsByTagName("head")[0].removeChild(oldLink);
1026 var link = document.createElement("link");
1027 link.id = "wait_gif";
1028 link.type = "image/gif";
1029 link.rel = "shortcut icon";
1030 var threats = '.implode(" + ", array_merge($GLOBALS["GOTMLS"]["tmp"]["threat_levels"], array(__("Potential Threats",'gotmls')=>"errors",__("WP-Login Updates",'gotmls')=>"errors"))).';
1031 if (threats > 0) {
1032 if ((errors * 2) == threats)
1033 linkhref = "blocked";
1034 else
1035 linkhref = "threat";
1036 } else
1037 linkhref = "checked";
1038 link.href = "'.GOTMLS_images_path.'"+linkhref+".gif";
1039 document.getElementsByTagName("head")[0].appendChild(link);
1040 }
1041 } else {
1042 var icons = document.getElementsByTagName("link");
1043 var link = document.createElement("link");
1044 link.id = "wait_gif";
1045 link.type = "image/gif";
1046 link.rel = "shortcut icon";
1047 link.href = "'.GOTMLS_images_path.'wait.gif";
1048 // document.head.appendChild(link);
1049 document.getElementsByTagName("head")[0].appendChild(link);
1050 }
1051 }
1052 function update_status(title, time) {
1053 sdir = (dir+direrrors);
1054 if (arguments[2] >= 0 && arguments[2] <= 100)
1055 percent = arguments[2];
1056 else
1057 percent = Math.floor((sdir*100)/dirs);
1058 scan_state = "6F6";
1059 if (percent == 100) {
1060 showhide("pause_button", true);
1061 showhide("pause_button");
1062 title = "'.$lt.'b'.$gt.__("Scan Complete!",'gotmls').$lt.'/b'.$gt.'";
1063 } else
1064 scan_state = "99F";
1065 changeFavicon(percent);
1066 if (sdir) {
1067 if (arguments[2] >= 0 && arguments[2] <= 100)
1068 timeRemaining = Math.ceil(((time-startTime)*(100/percent))-(time-startTime));
1069 else
1070 timeRemaining = Math.ceil(((time-startTime)*(dirs/sdir))-(time-startTime));
1071 if (timeRemaining > 59)
1072 timeRemaining = Math.ceil(timeRemaining/60)+" Minute";
1073 else
1074 timeRemaining += " Second";
1075 if (timeRemaining.substr(0, 2) != "1 ")
1076 timeRemaining += "s";
1077 } else
1078 timeRemaining = "Calculating Time";
1079 timeElapsed = Math.ceil(time);
1080 if (timeElapsed > 59)
1081 timeElapsed = Math.floor(timeElapsed/60)+" Minute";
1082 else
1083 timeElapsed += " Second";
1084 if (timeElapsed.substr(0, 2) != "1 ")
1085 timeElapsed += "s";
1086 divHTML = \''.$lt.'div align="center" style="vertical-align: middle; background-color: #ccc; z-index: 3; height: 18px; width: 100%; border: solid #000 1px; position: relative; padding: 10px 0;"'.$gt.$lt.'div style="height: 18px; padding: 10px 0; position: absolute; top: 0px; left: 0px; background-color: #\'+scan_state+\'; width: \'+percent+\'%"'.$gt.$lt.'/div'.$gt.$lt.'div style="height: 32px; position: absolute; top: 3px; left: 10px; z-index: 5; line-height: 16px;" align="left"'.$gt.'\'+sdir+" Folder"+(sdir==1?"":"s")+" Checked'.$lt.'br /'.$gt.'"+timeElapsed+\' Elapsed'.$lt.'/div'.$gt.$lt.'div style="height: 38px; position: absolute; top: 0px; left: 0px; width: 100%; z-index: 5; line-height: 38px; font-size: 30px; text-align: center;"'.$gt.'\'+percent+\'%'.$lt.'/div'.$gt.$lt.'div style="height: 32px; position: absolute; top: 3px; right: 10px; z-index: 5; line-height: 16px;" align="right"'.$gt.'\'+(dirs-sdir)+" Folder"+((dirs-sdir)==1?"":"s")+" Remaining'.$lt.'br /'.$gt.'"+timeRemaining+" Remaining'.$lt.'/div'.$gt.$lt.'/div'.$gt.'";
1087 document.getElementById("status_bar").innerHTML = divHTML;
1088 document.getElementById("status_text").innerHTML = title;
1089 dis="none";
1090 divHTML = \''.$lt.'ul style="float: right; margin: 0 20px; text-align: right;"'.$gt.'\';
1091 /*'.$lt.'!--*'.'/';
1092 $MAX = 0;
1093 $vars = "var i, intrvl, direrrors=0";
1094 $fix_button_js = "";
1095 $found = "";
1096 $li_js = "return false;";
1097 foreach ($scan_groups as $scan_name => $scan_group) {
1098 if ($MAX++ == 6) {
1099 $quarantineCountOnly = GOTMLS_get_quarantine(true);
1100 $vars .= ", $scan_group=$quarantineCountOnly";
1101 echo "/*--{$gt}*"."/\n\tif ($scan_group > 0)\n\t\tscan_state = ' potential'; \n\telse\n\t\tscan_state = '';\n\tdivHTML += '</ul><ul style=\"text-align: left;\"><li class=\"GOTMLS_li\"><a href=\"admin.php?page=GOTMLS-View-Quarantine\" class=\"GOTMLS_plugin".("'+scan_state+'\" title=\"".GOTMLS_View_Quarantine_LANGUAGE)."\">'+$scan_group+'&nbsp;'+($scan_group==1?('$scan_name').slice(0,-1):'$scan_name')+'</a></li>';\n/*{$lt}!--*"."/";
1102 $found = "Found ";
1103 $fix_button_js = "\n\t\tdis='block';";
1104 } else {
1105 $vars .= ", $scan_group=0";
1106 if ($found && !in_array($scan_group, $GLOBALS["GOTMLS"]["log"]["settings"]["check"]))
1107 $potential_threat = ' potential" title="'.__("You are not currently scanning for this type of threat!",'gotmls');
1108 else
1109 $potential_threat = "";
1110 echo "/*--{$gt}*"."/\n\tif ($scan_group > 0) {\n\t\tscan_state = ' href=\"#found_$scan_group\" onclick=\"$li_js showhide(\\'found_$scan_group\\', true);\" class=\"GOTMLS_plugin $scan_group\"';$fix_button_js".($MAX>6?"\n\tshowhide('found_$scan_group', true);":"")."\n\t} else\n\t\tscan_state = ' class=\"GOTMLS_plugin$potential_threat\"';\n\tdivHTML += '<li class=\"GOTMLS_li\"><a'+scan_state+'>$found'+$scan_group+'&nbsp;'+($scan_group==1?('$scan_name').slice(0,-1):'$scan_name')+'</a></li>';\n/*{$lt}!--*"."/";
1111 }
1112 $li_js = "";
1113 if ($MAX > 11)
1114 $fix_button_js = "";
1115 }
1116 $ScanSettings = $lt.'div style="float: right;"'.$gt.GOTMLS_Run_Quick_Scan_LANGUAGE.":&nbsp;$QuickScan$lt/div$gt".GOTMLS_Scan_Settings_LANGUAGE;
1117 echo "/*--{$gt}*".'/
1118 document.getElementById("status_counts").innerHTML = divHTML+"'.$lt.'/ul'.$gt.'";
1119 document.getElementById("fix_button").style.display = dis;
1120 }
1121 '.$vars.';
1122 function showOnly(what) {
1123 document.getElementById("only_what").innerHTML = document.getElementById("only"+what).innerHTML;
1124 }
1125 var startTime = 0;
1126 '.$lt.'/script'.$gt.GOTMLS_box($ScanSettings, $scan_opts);
1127 if (isset($_REQUEST["scan_type"]) && $_REQUEST["scan_type"] == "Save") {
1128 if ($GOTMLS_nonce_found) {
1129 update_option('GOTMLS_settings_array', $GLOBALS["GOTMLS"]["tmp"]["settings_array"]);
1130 echo "\n{$lt}script type='text/javascript'$gt\nalert('Settings Saved!');\n$lt/script$gt\n";
1131 } else
1132 echo GOTMLS_box(GOTMLS_Invalid_Nonce(""), __("Saving these settings requires a valid Nonce Token. No valid Nonce Token was found at this time, either because the token have expired or because the data was invalid. Please try re-submitting the form above.",'gotmls')."\n{$lt}script type='text/javascript'$gt\nalert('".GOTMLS_Invalid_Nonce("")."');\n$lt/script$gt\n");
1133 } elseif (isset($_REQUEST["scan_what"]) && is_numeric($_REQUEST["scan_what"]) && ($_REQUEST["scan_what"] > -1)) {
1134 if ($GOTMLS_nonce_found) {
1135 update_option('GOTMLS_settings_array', $GLOBALS["GOTMLS"]["tmp"]["settings_array"]);
1136 if (!isset($_REQUEST["scan_type"]))
1137 $_REQUEST["scan_type"] = "Complete Scan";
1138 echo "\n$lt".'form method="POST" action="'.admin_url('admin-ajax.php?'.GOTMLS_set_nonce(__FUNCTION__."1030")).(isset($_SERVER["QUERY_STRING"])&&strlen($_SERVER["QUERY_STRING"])?"&".$_SERVER["QUERY_STRING"]:"").'" target="GOTMLS_iFrame" name="GOTMLS_Form_clean"'.$gt.$lt.'input type="hidden" name="action" value="GOTMLS_fix"'.$gt.$lt.'input type="hidden" id="GOTMLS_fixing" name="GOTMLS_fixing" value="1"'.$gt;
1139 foreach ($_POST as $name => $value) {
1140 if (substr($name, 0, 10) != 'GOTMLS_fix') {
1141 if (is_array($value)) {
1142 foreach ($value as $val)
1143 echo $lt.'input type="hidden" name="'.$name.'[]" value="'.htmlspecialchars($val).'"'.$gt;
1144 } else
1145 echo $lt.'input type="hidden" name="'.$name.'" value="'.htmlspecialchars($value).'"'.$gt;
1146 }
1147 }
1148 echo "\n$lt".'script type="text/javascript"'.$gt.'showhide("inside_'.md5($ScanSettings).'");'.$lt.'/script'.$gt.GOTMLS_box(htmlentities($_REQUEST["scan_type"]).' Status', $lt.'div id="status_text"'.$gt.$lt.'img src="'.GOTMLS_images_path.'wait.gif" height=16 width=16 alt="..."'.$gt.' '.GOTMLS_Loading_LANGUAGE.$lt.'/div'.$gt.$lt.'div id="status_bar"'.$gt.$lt.'/div'.$gt.$lt.'p id="pause_button" style="display: none; position: absolute; left: 0; text-align: center; margin-left: -30px; padding-left: 50%;"'.$gt.$lt.'input type="button" value="Pause" class="button-primary" onclick="pauseresume(this);" id="resume_button" /'.$gt.$lt.'/p'.$gt.$lt.'div id="status_counts"'.$gt.$lt.'/div'.$gt.$lt.'p id="fix_button" style="display: none; text-align: center;"'.$gt.$lt.'input id="repair_button" type="submit" value="'.GOTMLS_Automatically_Fix_LANGUAGE.'" class="button-primary" onclick="loadIframe(\'Examine Results\');" /'.$gt.$lt.'/p'.$gt);
1149 $scan_groups_UL = "";
1150 foreach ($scan_groups as $scan_name => $scan_group)
1151 $scan_groups_UL .= "\n{$lt}ul name=\"found_$scan_group\" id=\"found_$scan_group\" class=\"GOTMLS_plugin $scan_group\" style=\"background-color: #ccc; display: none; padding: 0;\"$gt{$lt}a class=\"rounded-corners\" name=\"link_$scan_group\" style=\"float: right; padding: 0 4px; margin: 5px 5px 0 30px; line-height: 16px; text-decoration: none; color: #C00; background-color: #FCC; border: solid #F00 1px;\" href=\"#found_top\" onclick=\"showhide('found_$scan_group');\"{$gt}X$lt/a$gt{$lt}h3$gt$scan_name$lt/h3$gt\n".($scan_group=='potential'?$lt.'p'.$gt.' &nbsp; * '.__("NOTE: These are probably not malicious scripts (but it's a good place to start looking <u>IF</u> your site is infected and no Known Threats were found).",'gotmls').$lt.'/p'.$gt:($scan_group=='wp_core'?$lt.'p'.$gt.' &nbsp; * '.sprintf(__("NOTE: We have detected changes to the WordPress Core files on your site. This could be an intentional modification or the malicious work of a hacker. We can restore these files to their original state to preserve the integrity of your original WordPress %s installation.",'gotmls'), $wp_version).' (for more info '.$lt.'a target="_blank" href="http://gotmls.net/tag/wp-core-files/"'.$gt.__("read my blog",'gotmls').$lt.'/a'.$gt.').'.$lt.'/p'.$gt:$lt.'br /'.$gt)).$lt.'/ul'.$gt;
1152 if (!($dir = implode(GOTMLS_slash(), array_slice($dirs, 0, -1 * (2 + $_REQUEST["scan_what"]))))) $dir = "/";
1153 GOTMLS_update_scan_log(array("scan" => array("dir" => $dir, "start" => time(), "type" => htmlentities($_REQUEST["scan_type"]))));
1154 echo GOTMLS_box($lt.'div style="float: right;"'.$gt.'&nbsp;('.$GLOBALS["GOTMLS"]["log"]["scan"]["dir"].")&nbsp;$lt/div$gt".__("Scan Details:",'gotmls'), $scan_groups_UL);
1155 $no_flush_LANGUAGE = __("Not flushing OB Handlers: %s",'gotmls');
1156 if (isset($_REQUEST["no_ob_end_flush"]))
1157 echo $lt.'div class="error"'.$gt.sprintf($no_flush_LANGUAGE, print_r(ob_list_handlers(), 1))."$lt/div$gt\n";
1158 elseif (is_array($OB_handlers) && count($OB_handlers)) {
1159 // $GOTMLS_OB_handlers = get_option("GOTMLS_OB_handlers", array());
1160 foreach (array_reverse($OB_handlers) as $OB_handler) {
1161 if (isset($GOTMLS_OB_handlers[$OB_handler]) && $GOTMLS_OB_handlers[$OB_handler] == "no_end_flush")
1162 echo $lt.'div class="error"'.$gt.sprintf($no_flush_LANGUAGE, $OB_handler)."$lt/div$gt\n";
1163 elseif (in_array($OB_handler, $OB_default_handlers)) {
1164 // $GOTMLS_OB_handlers[$OB_handler] = "no_end_flush";
1165 // update_option("GOTMLS_OB_handlers", $GOTMLS_OB_handlers);
1166 @ob_end_flush();
1167 // $GOTMLS_OB_handlers[$OB_handler] = "ob_end_flush";
1168 // update_option("GOTMLS_OB_handlers", $GOTMLS_OB_handlers);
1169 }
1170 }
1171 }
1172 @ob_start();
1173 if ($_REQUEST["scan_type"] == "Quick Scan") {
1174 $li_js = "\nfunction testComplete() {\n\tif (percent != 100)\n\t\talert('".__("The Quick Scan was unable to finish because of a shortage of memory or a problem accessing a file. Please try using the Complete Scan, it is slower but it will handle these errors better and continue scanning the rest of the files.",'gotmls')."');\n}\nwindow.onload=testComplete;\n$lt/script$gt\n$lt".'script type="text/javascript"'.$gt;
1175 if (is_numeric($check = array_search("potential", $GLOBALS["GOTMLS"]["log"]["settings"]["check"])))
1176 unset($GLOBALS["GOTMLS"]["log"]["settings"]["check"][$check]);
1177 }
1178 echo "\n{$lt}script type=\"text/javascript\"$gt$li_js\n/*{$lt}!--*"."/";
1179 if (is_dir($dir)) {
1180 $GOTMLS_dirs_at_depth[0] = 1;
1181 $GOTMLS_dir_at_depth[0] = 0;
1182 if (isset($_REQUEST['scan_only']) && is_array($_REQUEST['scan_only'])) {
1183 $GOTMLS_dirs_at_depth[0] += (count($_REQUEST['scan_only']) - 1);
1184 foreach ($_REQUEST['scan_only'] as $only_dir)
1185 if (is_dir(GOTMLS_trailingslashit($dir).$only_dir))
1186 GOTMLS_readdir(GOTMLS_trailingslashit($dir).$only_dir);
1187 } else
1188 GOTMLS_readdir($dir);
1189 } else
1190 echo GOTMLS_return_threat("errors", "blocked", $dir, GOTMLS_error_link("Not a valid directory!"));
1191 if ($_REQUEST["scan_type"] == "Quick Scan")
1192 echo GOTMLS_update_status(__("Completed!",'gotmls'), 100);
1193 else {
1194 echo GOTMLS_update_status(__("Starting Scan ...",'gotmls'))."/*--{$gt}*"."/";
1195 echo "\nvar scriptSRC = '".admin_url('admin-ajax.php?action=GOTMLS_scan&'.GOTMLS_set_nonce(__FUNCTION__."1087").'&mt='.$GLOBALS["GOTMLS"]["tmp"]["mt"].preg_replace('/\&(GOTMLS_scan|mt|GOTMLS_mt|action)=/', '&last_\1=', isset($_SERVER["QUERY_STRING"])&&strlen($_SERVER["QUERY_STRING"])?"&".$_SERVER["QUERY_STRING"]:"").'&GOTMLS_scan=')."';\nvar scanfilesArKeys = new Array('".implode("','", array_keys($GLOBALS["GOTMLS"]["tmp"]["scanfiles"]))."');\nvar scanfilesArNames = new Array('Scanning ".implode("','Scanning ", $GLOBALS["GOTMLS"]["tmp"]["scanfiles"])."');".'
1196 var scanfilesI = 0;
1197 var stopScanning;
1198 var gotStuckOn = "";
1199 function scanNextDir(gotStuck) {
1200 clearTimeout(stopScanning);
1201 if (gotStuck > -1) {
1202 if (scanfilesArNames[gotStuck].substr(0, 3) != "Re-") {
1203 if (scanfilesArNames[gotStuck].substr(0, 9) == "Checking ") {
1204 scanfilesArNames.push(scanfilesArNames[gotStuck]);
1205 scanfilesArKeys.push(scanfilesArKeys[gotStuck]+"&GOTMLS_skip_file[]="+encodeURIComponent(scanfilesArNames[gotStuck].substr(9)));
1206 } else {
1207 scanfilesArNames.push("Re-"+scanfilesArNames[gotStuck]);
1208 scanfilesArKeys.push(scanfilesArKeys[gotStuck]+"&GOTMLS_only_file=");
1209 }
1210 } else {
1211 scanfilesArNames.push("Got Stuck "+scanfilesArNames[gotStuck]);
1212 scanfilesArKeys.push(scanfilesArKeys[gotStuck]+"&GOTMLS_skip_dir="+scanfilesArKeys[gotStuck]);
1213 }
1214 }
1215 if (document.getElementById("resume_button").value != "Pause") {
1216 stopScanning=setTimeout("scanNextDir(-1)", 1000);
1217 startTime++;
1218 }
1219 else if (scanfilesI < scanfilesArKeys.length) {
1220 document.getElementById("status_text").innerHTML = scanfilesArNames[scanfilesI];
1221 var newscript = document.createElement("script");
1222 newscript.setAttribute("src", scriptSRC+scanfilesArKeys[scanfilesI]);
1223 divx = document.getElementById("found_scanned");
1224 if (divx)
1225 divx.appendChild(newscript);
1226 stopScanning=setTimeout("scanNextDir("+(scanfilesI++)+")",'.$GLOBALS["GOTMLS"]["tmp"]['execution_time'].'000);
1227 }
1228 }
1229 startTime = ('.ceil(time()-$GLOBALS["GOTMLS"]["log"]["scan"]["start"]).'+3);
1230 stopScanning=setTimeout("scanNextDir(-1)",3000);
1231 function pauseresume(butt) {
1232 if (butt.value == "Resume")
1233 butt.value = "Pause";
1234 else
1235 butt.value = "Resume";
1236 }
1237 showhide("pause_button", true);'."\n/*{$lt}!--*"."/";
1238 }
1239 if (@ob_get_level()) {
1240 GOTMLS_flush('script');
1241 @ob_end_flush();
1242 }
1243 echo "/*--{$gt}*"."/\n$lt/script$gt";
1244 } else
1245 echo GOTMLS_box(GOTMLS_Invalid_Nonce(""), __("Starting a Complete Scan requires a valid Nonce Token. No valid Nonce Token was found at this time, either because the token have expired or because the data was invalid. Please try re-submitting the form above.",'gotmls')."\n{$lt}script type='text/javascript'$gt\nalert('".GOTMLS_Invalid_Nonce("")."');\n$lt/script$gt\n");
1246 }
1247 echo "\n$lt/div$gt$lt/div$gt$lt/div$gt";
1248 }
1249
1250 function GOTMLS_login_form($form_id = "loginform") {
1251 $sess = time();
1252 $ajaxURL = admin_url("admin-ajax.php?action=GOTMLS_logintime&GOTMLS_sess=");
1253 echo '<input type="hidden" name="session_id" value="'.substr($sess, 4).'"><input type="hidden" id="offset_id" value="0" name="sess'.substr($sess, 4).'"><script type="text/javascript">'."\nvar GOTMLS_login_offset = new Date();\nvar GOTMLS_login_script = document.createElement('script');\nGOTMLS_login_script.src = '$ajaxURL'+GOTMLS_login_offset.getTime();\n//GOTMLS_login_script.onload = set_offset_id();\ndocument.head.appendChild(GOTMLS_login_script);\n</script>\n";
1254 }
1255 add_action("login_form", "GOTMLS_login_form");
1256
1257 function GOTMLS_ajax_logintime() {
1258 @header("Content-type: text/javascript");
1259 $sess = (false && isset($_GET["GOTMLS_sess"]) && is_numeric($_GET["GOTMLS_sess"])) ? $_GET["sess"] : time();
1260 die("\n//Permission Error: User not authenticated!\nvar GOTMLS_login_offset = new Date();\nvar GOTMLS_login_offset_start = GOTMLS_login_offset.getTime() - ".$sess."000;\nfunction set_offset_id() {\n\tGOTMLS_login_offset = new Date();\n\tif (form_login = document.getElementById('offset_id'))\n\t\tform_login.value = GOTMLS_login_offset.getTime() - GOTMLS_login_offset_start;\n\tsetTimeout(set_offset_id, 15673);\n}\nset_offset_id();");
1261 }
1262 add_action('wp_ajax_nopriv_GOTMLS_logintime', 'GOTMLS_ajax_logintime');
1263 add_action('wp_ajax_GOTMLS_logintime', 'GOTMLS_ajax_logintime');
1264
1265 function GOTMLS_ajax_lognewkey() {
1266 @header("Content-type: text/javascript");
1267 if (GOTMLS_get_nonce()) {
1268 if (isset($_POST["GOTMLS_installation_key"]) && ($_POST["GOTMLS_installation_key"] == GOTMLS_installation_key)) {
1269 $keys = maybe_unserialize(get_option('GOTMLS_Installation_Keys', array()));
1270 if (is_array($keys)) {
1271 $count = count($keys);
1272 if (!array_key_exists(GOTMLS_installation_key, $keys))
1273 $keys = array_merge($keys, array(GOTMLS_installation_key => GOTMLS_siteurl));
1274 } else
1275 $keys = array(GOTMLS_installation_key => GOTMLS_siteurl);
1276 update_option("GOTMLS_Installation_Keys", serialize($keys));
1277 die("\n//$count~".count($keys));
1278 } else
1279 die("\n//0");
1280 } else
1281 die(GOTMLS_Invalid_Nonce("\n//Log New Key Error: ")."\n");
1282 }
1283 add_action('wp_ajax_GOTMLS_lognewkey', 'GOTMLS_ajax_lognewkey');
1284 add_action('wp_ajax_nopriv_GOTMLS_lognewkey', 'GOTMLS_ajax_nopriv');
1285
1286 function GOTMLS_set_plugin_action_links($links_array, $plugin_file) {
1287 if ($plugin_file == substr(str_replace("\\", "/", __FILE__), (-1 * strlen($plugin_file))) && strlen($plugin_file) > 10)
1288 $links_array = array_merge(array('<a href="'.admin_url('admin.php?page=GOTMLS-settings').'"><span class="dashicons dashicons-admin-settings"></span>'.GOTMLS_Scan_Settings_LANGUAGE.'</a>'), $links_array);
1289 return $links_array;
1290 }
1291 add_filter("plugin_action_links", "GOTMLS_set_plugin_action_links", 1, 2);
1292
1293 function GOTMLS_set_plugin_row_meta($links_array, $plugin_file) {
1294 if ($plugin_file == substr(str_replace("\\", "/", __FILE__), (-1 * strlen($plugin_file))) && strlen($plugin_file) > 10)
1295 $links_array = array_merge($links_array, array('<a target="_blank" href="http://gotmls.net/faqs/">FAQ</a>','<a target="_blank" href="http://gotmls.net/support/">Support</a>','<a target="_blank" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZHD8QHZ2E7PE"><span class="dashicons dashicons-heart"></span>Donate</a>'));
1296 return $links_array;
1297 }
1298 add_filter("plugin_row_meta", "GOTMLS_set_plugin_row_meta", 1, 2);
1299
1300 function GOTMLS_in_plugin_update_message($args) {
1301 $transient_name = 'GOTMLS_upgrade_notice_'.$args["Version"].'_'.$args["new_version"];
1302 if ((false === ($upgrade_notice = get_transient($transient_name))) && ($ret = GOTMLS_get_URL("https://plugins.svn.wordpress.org/gotmls/trunk/readme.txt"))) {
1303 $upgrade_notice = '';
1304 if ($match = preg_split('/==\s*Upgrade Notice\s*==\s+/i', $ret)) {
1305 if (preg_match('/\n+=\s*'.str_replace(".", "\\.", GOTMLS_Version).'\s*=\s+/is', $match[1]))
1306 $notice = (array) preg_split('/\n+=\s*'.str_replace(".", "\\.", GOTMLS_Version).'\s*=\s+/is', $match[1]);
1307 else
1308 $notice = (array) preg_split('/\n+=/is', $match[1]."\n=");
1309 $upgrade_notice .= '<div class="GOTMLS_upgrade_notice">'.preg_replace('/=\s*([\.0-9]+)\s*=\s*([^=]+)/i', '<li><b>${1}:</b> ${2}</li>', preg_replace('~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $notice[0])).'</div>';
1310 set_transient($transient_name, $upgrade_notice, DAY_IN_SECONDS);
1311 }
1312 }
1313 echo $upgrade_notice;
1314 }
1315 add_action("in_plugin_update_message-gotmls/index.php", "GOTMLS_in_plugin_update_message");
1316
1317 function GOTMLS_init() {
1318 if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_what"]))
1319 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_what"] = 2;
1320 if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_depth"]))
1321 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_depth"] = -1;
1322 if (isset($_REQUEST["scan_type"]) && $_REQUEST["scan_type"] == "Quick Scan") {
1323 if (!isset($_REQUEST["scan_what"])) $_REQUEST["scan_what"] = 2;
1324 if (!isset($_REQUEST["scan_depth"]))
1325 $_REQUEST["scan_depth"] = 2;
1326 if (!isset($_REQUEST["scan_only"]))
1327 $_REQUEST["scan_only"] = array("","wp-includes","wp-admin");
1328 if ($_REQUEST["scan_only"] && !is_array($_REQUEST["scan_only"]))
1329 $_REQUEST["scan_only"] = array($_REQUEST["scan_only"]);
1330 }//$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check_custom"] = stripslashes($_POST["check_custom"]);
1331 if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check_custom"]))
1332 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check_custom"] = "";
1333 if (isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_level"]) && is_numeric($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_level"]))
1334 $scan_level = intval($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_level"]);
1335 else
1336 $scan_level = count(explode('/', trailingslashit(get_option("siteurl")))) - 1;
1337 if (GOTMLS_get_nonce()) {
1338 if (isset($_REQUEST["dont_check"]) && is_array($_REQUEST["dont_check"]) && count($_REQUEST["dont_check"]))
1339 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"] = $_REQUEST["dont_check"];
1340 elseif (isset($_POST["scan_type"]) || !(isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"])))
1341 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"] = array();
1342 if (isset($_POST["scan_level"]) && is_numeric($_POST["scan_level"]))
1343 $scan_level = intval($_POST["scan_level"]);
1344 if (isset($scan_level) && is_numeric($scan_level))
1345 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_level"] = intval($scan_level);
1346 else
1347 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_level"] = count(explode('/', trailingslashit(get_option("siteurl")))) - 1;
1348 }
1349 }
1350 add_action("admin_init", "GOTMLS_init");
1351
1352 function GOTMLS_ajax_position() {
1353 if (GOTMLS_get_nonce()) {
1354 $GLOBALS["GOTMLS_msg"] = __("Default position",'gotmls');
1355 $properties = array("body" => 'style="margin: 0; padding: 0;"');
1356 if (isset($_GET["GOTMLS_msg"]) && $_GET["GOTMLS_msg"] == $GLOBALS["GOTMLS_msg"]) {
1357 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"] = $GLOBALS["GOTMLS"]["tmp"]["default"]["msg_position"];
1358 $gl = '><';
1359 $properties["html"] = $gl.'head'.$gl.'script type="text/javascript">
1360 if (curDiv = window.parent.document.getElementById("div_file")) {
1361 curDiv.style.left = "'.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][0].'";
1362 curDiv.style.top = "'.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][1].'";
1363 curDiv.style.height = "'.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][2].'";
1364 curDiv.style.width = "'.$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][3].'";
1365 }
1366 </script'.$gl.'/head';
1367 } elseif (isset($_GET["GOTMLS_x"]) || isset($_GET["GOTMLS_y"]) || isset($_GET["GOTMLS_h"]) || isset($_GET["GOTMLS_w"])) {
1368 if (isset($_GET["GOTMLS_x"]))
1369 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][0] = $_GET["GOTMLS_x"];
1370 if (isset($_GET["GOTMLS_y"]))
1371 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][1] = $_GET["GOTMLS_y"];
1372 if (isset($_GET["GOTMLS_h"]))
1373 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][2] = $_GET["GOTMLS_h"];
1374 if (isset($_GET["GOTMLS_w"]))
1375 $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][3] = $_GET["GOTMLS_w"];
1376 $_GET["GOTMLS_msg"] = __("New position",'gotmls');
1377 } else
1378 die("\n//Position Error: No new position to save!\n");
1379 update_option("GOTMLS_settings_array", $GLOBALS["GOTMLS"]["tmp"]["settings_array"]);
1380 die(GOTMLS_html_tags(array("html" => array("body" => htmlentities($_GET["GOTMLS_msg"]).' '.__("saved.",'gotmls').(implode($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"]) == implode($GLOBALS["GOTMLS"]["tmp"]["default"]["msg_position"])?"":' <a href="'.admin_url('admin-ajax.php?action=GOTMLS_position&'.GOTMLS_set_nonce(__FUNCTION__."1350").'&GOTMLS_msg='.urlencode($GLOBALS["GOTMLS_msg"])).'">['.$GLOBALS["GOTMLS_msg"].']</a>'))), $properties));
1381 } else
1382 die(GOTMLS_Invalid_Nonce("\n//Position Error: ")."\n");
1383 }
1384 add_action('wp_ajax_GOTMLS_position', 'GOTMLS_ajax_position');
1385
1386 function GOTMLS_ajax_empty_trash() {
1387 global $wpdb;
1388 $gl = '><';
1389 if (GOTMLS_get_nonce()) {
1390 if ($trashed = $wpdb->query("DELETE FROM $wpdb->posts WHERE `post_type` = 'GOTMLS_quarantine' AND `post_status` != 'private'")) {
1391 $wpdb->query("REPAIR TABLE $wpdb->posts");
1392 $trashmsg = __("Emptied $trashed item from the quarantine trash.",'gotmls');
1393 } else
1394 $trashmsg = __("Failed to empty the trash.",'gotmls');
1395 } else
1396 $trashmsg = GOTMLS_Invalid_Nonce("");
1397 $properties = array("html" => $gl.'head'.$gl."script type='text/javascript'>\nif (curDiv = window.parent.document.getElementById('empty_trash_link'))\n\tcurDiv.style.display = 'none';\nalert('$trashmsg');\n</script$gl/head", "body" => 'style="margin: 0; padding: 0;"');
1398 die(GOTMLS_html_tags(array("html" => array("body" => $trashmsg)), $properties));
1399 }
1400 add_action('wp_ajax_GOTMLS_empty_trash', 'GOTMLS_ajax_empty_trash');
1401
1402 function GOTMLS_ajax_whitelist() {
1403 if (GOTMLS_get_nonce()) {
1404 if (isset($_POST['GOTMLS_whitelist']) && isset($_POST['GOTMLS_chksum'])) {
1405 $file = GOTMLS_decode($_POST['GOTMLS_whitelist']);
1406 $chksum = explode("O", $_POST['GOTMLS_chksum']."O");
1407 if (strlen($chksum[0]) == 32 && strlen($chksum[1]) == 32 && is_file($file) && md5(@file_get_contents($file)) == $chksum[0]) {
1408 $filesize = @filesize($file);
1409 if (true) {
1410 if (!isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"][$file][0]))
1411 $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"][$file][0] = "A0002";
1412 $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"][$file][$chksum[0].'O'.$filesize] = "A0002";
1413 } else
1414 unset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"][$file]);
1415 update_option("GOTMLS_definitions_array", $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]);
1416 $body = "Added $file to Whitelist!<br />\n<iframe style='width: 90%; height: 250px; border: none;' src='".GOTMLS_plugin_home."whitelist.html?whitelist=".$_POST['GOTMLS_whitelist']."&hash=$chksum[0]&size=$filesize&key=$chksum[1]'></iframe>";
1417 } else
1418 $body = "<li>Invalid Data!</li>";
1419 die(GOTMLS_html_tags(array("html" => array("body" => $body))));
1420 } else
1421 die("\n//Whitelist Error: Invalid checksum!\n");
1422 } else
1423 die(GOTMLS_Invalid_Nonce("\n//Whitelist Error: ")."\n");
1424 }
1425 add_action('wp_ajax_GOTMLS_whitelist', 'GOTMLS_ajax_whitelist');
1426
1427 function GOTMLS_ajax_fix() {
1428 if (GOTMLS_get_nonce()) {
1429 if (isset($_POST["GOTMLS_fix"]) && !is_array($_POST["GOTMLS_fix"]))
1430 $_POST["GOTMLS_fix"] = array($_POST["GOTMLS_fix"]);
1431 if (isset($_REQUEST["GOTMLS_fix"]) && is_array($_REQUEST["GOTMLS_fix"]) && isset($_REQUEST["GOTMLS_fixing"]) && $_REQUEST["GOTMLS_fixing"]) {
1432 GOTMLS_update_scan_log(array("settings" => $GLOBALS["GOTMLS"]["tmp"]["settings_array"]));
1433 $callAlert = "clearTimeout(callAlert);\ncallAlert=setTimeout('alert_repaired(1)', 30000);";
1434 $li_js = "\n<script type=\"text/javascript\">\nvar callAlert;\nfunction alert_repaired(failed) {\nclearTimeout(callAlert);\nif (failed)\nfilesFailed='the rest, try again to change more.';\nwindow.parent.check_for_donation('Changed '+filesFixed+' files, failed to change '+filesFailed);\n}\n$callAlert\nwindow.parent.showhide('GOTMLS_iFrame', true);\nfilesFixed=0;\nfilesFailed=0;\nfunction fixedFile(file) {\n filesFixed++;\nif (li_file = window.parent.document.getElementById('check_'+file))\n\tli_file.checked=false;\nif (li_file = window.parent.document.getElementById('list_'+file))\n\tli_file.className='GOTMLS_plugin';\nif (li_file = window.parent.document.getElementById('GOTMLS_quarantine_'+file)) {\n\tli_file.style.display='none';\n\tli_file.innerHTML='';\n\t}\n}\nfunction DeletedFile(file) {\n filesFixed++;\nif (li_file = window.parent.document.getElementById('check_'+file))\n\tli_file.checked=false;\nif (li_file = window.parent.document.getElementById('GOTMLS_quarantine_'+file)) {\n\tli_file.style.display='none';\n\tli_file.innerHTML='';\n\t}}\nfunction failedFile(file) {\n filesFailed++;\nwindow.parent.document.getElementById('check_'+file).checked=false; \n}\n</script>\n<script type=\"text/javascript\">\n/*<!--*"."/";
1435 @set_time_limit($GLOBALS["GOTMLS"]["tmp"]['execution_time'] * 2);
1436 $HTML = explode("split-here-for-content", GOTMLS_html_tags(array("html" => array("body" => "split-here-for-content"))));
1437 echo $HTML[0];
1438 GOTMLS_update_scan_log(array("scan" => array("dir" => count($_REQUEST["GOTMLS_fix"])." Files", "start" => time())));
1439 foreach ($_REQUEST["GOTMLS_fix"] as $clean_file) {
1440 if (is_numeric($clean_file)) {
1441 if (($Q_post = GOTMLS_get_quarantine($clean_file)) && isset($Q_post["post_type"]) && strtolower($Q_post["post_type"]) == "gotmls_quarantine" && isset($Q_post["post_status"]) && strtolower($Q_post["post_status"]) == "private") {
1442 $path = $Q_post["post_title"];
1443 if ($_REQUEST["GOTMLS_fixing"] > 1) {
1444 echo "<li>Removing $path ... ";
1445 $Q_post["post_status"] = "trash";
1446 if (wp_update_post($Q_post)) {
1447 echo __("Done!",'gotmls');
1448 $li_js .= "/*-->*"."/\nDeletedFile('$clean_file');\n/*<!--*"."/";
1449 } else {
1450 echo __("Failed to delete!",'gotmls');
1451 $li_js .= "/*-->*"."/\nfailedFile('$clean_file');\n/*<!--*"."/";
1452 }
1453 GOTMLS_update_scan_log(array("scan" => array("finish" => time(), "type" => "Removal from Quarantine")));
1454 } else {
1455 echo "<li>Restoring $path ... ";
1456 $Q_post["post_status"] = "pending";
1457 if (GOTMLS_file_put_contents($path, GOTMLS_decode($Q_post["post_content"])) && wp_update_post($Q_post)) {
1458 echo __("Complete!",'gotmls');
1459 $li_js .= "/*-->*"."/\nfixedFile('$clean_file');\n/*<!--*"."/";
1460 } else {
1461 echo __("Restore Failed!",'gotmls');
1462 $li_js .= "/*-->*"."/\nfailedFile('$clean_file');\n/*<!--*"."/";
1463 }
1464 GOTMLS_update_scan_log(array("scan" => array("finish" => time(), "type" => "Restoration from Quarantine")));
1465 }
1466 echo "</li>\n$li_js/*-->*"."/\n$callAlert\n</script>\n";
1467 $li_js = "<script type=\"text/javascript\">\n/*<!--*"."/";
1468 }//else print_r(array("i:$clean_file"=>$Q_post));
1469 } else {
1470 $path = realpath(GOTMLS_decode($clean_file));
1471 if (is_file($path)) {
1472 echo "<li>Fixing $path ... ";
1473 $li_js .= GOTMLS_scanfile($path);
1474 echo "</li>\n$li_js/*-->*"."/\n$callAlert\n//".$GLOBALS["GOTMLS"]["tmp"]["debug_fix"]."\n</script>\n";
1475 $li_js = "<script type=\"text/javascript\">\n/*<!--*"."/";
1476 } else
1477 echo "<li>".__("File ".htmlentities($path)." not found!",'gotmls')."</li>";
1478 GOTMLS_update_scan_log(array("scan" => array("finish" => time(), "type" => "Automatic Fix")));
1479 }
1480 }
1481 die('<div id="check_site_warning" style="background-color: #F00;">'.sprintf(__("Because some changes were made we need to check to make sure it did not break your site. If this stays Red and the frame below does not load please <a %s>revert the changes</a> made during this automated fix process.",'gotmls'), 'target="_top" href="admin.php?page=GOTMLS-View-Quarantine"').' <span style="color: #F00;">'.__("Never mind, it worked!",'gotmls').'</span></div><br /><iframe id="test_frame" name="test_frame" src="'.admin_url('admin.php?page=GOTMLS-settings&check_site=1&'.GOTMLS_set_nonce(__FUNCTION__."1451")).'" style="width: 100%; height: 200px"></iframe>'.$li_js."/*-->*"."/\nalert_repaired(0);\n</script>\n$HTML[1]");
1482 } else
1483 die(GOTMLS_html_tags(array("html" => array("body" => "<script type=\"text/javascript\">\nwindow.parent.showhide('GOTMLS_iFrame', true);\nalert('".__("Nothing Selected to be Changed!",'gotmls')."');\n</script>".__("Done!",'gotmls')))));
1484 } else
1485 die(GOTMLS_html_tags(array("html" => array("body" => "<script type=\"text/javascript\">\nwindow.parent.showhide('GOTMLS_iFrame', true);\nalert('".GOTMLS_Invalid_Nonce("")."');\n</script>".__("Done!",'gotmls')))));
1486 }
1487 add_action('wp_ajax_GOTMLS_fix', 'GOTMLS_ajax_fix');
1488
1489 function GOTMLS_ajax_scan() {
1490 if (GOTMLS_get_nonce()) {
1491 @error_reporting(0);
1492 if (isset($_GET["GOTMLS_scan"])) {
1493 @set_time_limit($GLOBALS["GOTMLS"]["tmp"]['execution_time'] - 5);
1494 $decode_list = array("Base64" => '/base64_decode\([\'"]([0-9\+\/\=a-z]+)[\'"]\)/', "Hex" => '/(\\\\(x[0-9a-f]{2}|[0-9]{1,3}))/');
1495 if (is_numeric($_GET["GOTMLS_scan"])) {
1496 if (($Q_post = GOTMLS_get_quarantine($_GET["GOTMLS_scan"])) && isset($Q_post["post_type"]) && $Q_post["post_type"] == "GOTMLS_quarantine" && isset($Q_post["post_status"]) && $Q_post["post_status"] == "private") {
1497 $clean_file = $Q_post["post_title"];
1498 $GLOBALS["GOTMLS"]["tmp"]["file_contents"] = GOTMLS_decode($Q_post["post_content"]);
1499 $fa = "";
1500 $function = 'GOTMLS_decode';
1501 if (isset($_GET[$function]) && is_array($_GET[$function])) {
1502 foreach ($_GET[$function] as $decode) {
1503 if (isset($decode_list[$decode])) {
1504 $GLOBALS["GOTMLS"]["tmp"]["file_contents"] = preg_replace($decode_list[$decode].substr($GLOBALS["GOTMLS"]["tmp"]["default_ext"], 0, 2), $function.$decode.'("\1")', $GLOBALS["GOTMLS"]["tmp"]["file_contents"]);
1505 $fa .= " $decode decoded";
1506 } else
1507 $fa .= " NO-$decode";
1508 }
1509 } elseif (isset($Q_post["post_excerpt"]) && strlen($Q_post["post_excerpt"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["threats_found"] = @maybe_unserialize(GOTMLS_decode($Q_post["post_excerpt"])))) {
1510 $f = 1;
1511 //print_r(array("excerpt:"=>$GLOBALS["GOTMLS"]["tmp"]["threats_found"]));
1512 foreach ($GLOBALS["GOTMLS"]["tmp"]["threats_found"] as $threats_found => $threats_name) {
1513 list($start, $end, $junk) = explode("-", "$threats_found--", 3);
1514 if (strlen($end) > 0 && is_numeric($start) && is_numeric($end)) {
1515 if ($start < $end)
1516 $fa .= ' <a title="'.htmlspecialchars($threats_name).'" href="javascript:select_text_range(\'ta_file\', '.$start.', '.$end.');">['.$f++.']</a>';
1517 else
1518 $fa .= ' <a title="'.htmlspecialchars($threats_name).'" href="javascript:select_text_range(\'ta_file\', '.$end.', '.$start.');">['.$f++.']</a>';
1519 } else {
1520 if (is_numeric($threats_found)) {
1521 $threats_found = $threats_name;
1522 $threats_name = $f;
1523 }
1524 $fpos = 0;
1525 $flen = 0;
1526 $potential_threat = str_replace("\r", "", $threats_found);
1527 while (($fpos = strpos(str_replace("\r", "", $GLOBALS["GOTMLS"]["tmp"]["file_contents"]), ($potential_threat), $flen + $fpos)) !== false) {
1528 $flen = strlen($potential_threat);
1529 $fa .= ' <a title="'.htmlspecialchars($threats_name).'" href="javascript:select_text_range(\'ta_file\', '.($fpos).', '.($fpos + $flen).');">['.$f++.']</a>';
1530 }
1531 }
1532 }
1533 } //else echo "excerpt:".$Q_post["post_excerpt"];
1534 foreach ($decode_list as $decode => $regex)
1535 if (preg_match($regex.substr($GLOBALS["GOTMLS"]["tmp"]["default_ext"], 0, 1), $GLOBALS["GOTMLS"]["tmp"]["file_contents"]))
1536 $fa .= ' <a href="'.GOTMLS_script_URI.'&'.$function.'[]='.$decode.'">decode['.$decode.']</a>';
1537 die("\n".'<script type="text/javascript">
1538 function select_text_range(ta_id, start, end) {
1539 ta_element = document.getElementById(ta_id);
1540 ta_element.focus();
1541 if(ta_element.setSelectionRange)
1542 ta_element.setSelectionRange(start, end);
1543 else {
1544 var r = ta_element.createTextRange();
1545 r.collapse(true);
1546 r.moveEnd(\'character\', end);
1547 r.moveStart(\'character\', start);
1548 r.select();
1549 }
1550 }
1551 window.parent.showhide("GOTMLS_iFrame", true);
1552 </script><table style="top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;"><tr><td style="width: 100%"><form style="margin: 0;" method="post" action="'.admin_url('admin-ajax.php?'.GOTMLS_set_nonce(__FUNCTION__."1522")).'" onsubmit="return confirm(\''.__("Are you sure you want to delete this file from the quarantine?",'gotmls').'\');"><input type="hidden" name="GOTMLS_fix[]" value="'.$Q_post["ID"].'"><input type="hidden" name="GOTMLS_fixing" value="2"><input type="hidden" name="action" value="GOTMLS_fix"><input type="submit" value="DELETE from Quarantine" style="background-color: #C00; float: right;"></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>File Details</b><br />encoding: '.(function_exists("mb_detect_encoding")?mb_detect_encoding($GLOBALS["GOTMLS"]["tmp"]["file_contents"]):"Unknown").'<br />size: '.strlen($GLOBALS["GOTMLS"]["tmp"]["file_contents"]).' bytes<br />infected:'.$Q_post["post_modified_gmt"].'<br />quarantined:'.$Q_post["post_date_gmt"].'</div><div style="overflow: auto;"><span onmouseover="document.getElementById(\'fileperms\').style.display=\'block\';" onmouseout="document.getElementById(\'fileperms\').style.display=\'none\';">'.__("File Details:",'gotmls').'</span> ('.$fa.' )</div></td></tr><tr><td style="height: 100%"><textarea id="ta_file" style="width: 100%; height: 100%">'.htmlentities(str_replace("\r", "", $GLOBALS["GOTMLS"]["tmp"]["file_contents"])).'</textarea></td></tr></table>');
1553 } else
1554 die(GOTMLS_html_tags(array("html" => array("body" => __("This file no longer exists in the quarantine.",'gotmls')."<br />\n<script type=\"text/javascript\">\nwindow.parent.showhide('GOTMLS_iFrame', true);\n</script>"))));
1555 } else {
1556 $file = GOTMLS_decode($_GET["GOTMLS_scan"]);
1557 if (is_dir($file)) {
1558 @error_reporting(0);
1559 @header("Content-type: text/javascript");
1560 if (isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_ext"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_ext"]))
1561 $GLOBALS["GOTMLS"]["tmp"]["skip_ext"] = $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_ext"];
1562 @ob_start();
1563 echo GOTMLS_scandir($file);
1564 if (@ob_get_level()) {
1565 GOTMLS_flush();
1566 @ob_end_flush();
1567 }
1568 die('//END OF JavaScript');
1569 } else {
1570 if (!file_exists($file))
1571 die(GOTMLS_html_tags(array("html" => array("body" => sprintf(__("The file %s does not exist, it must have already been deleted.",'gotmls'), $file)."<script type=\"text/javascript\">\nwindow.parent.showhide('GOTMLS_iFrame', true);\n</script>"))));
1572 else {
1573 GOTMLS_scanfile($file);
1574 $fa = "";
1575 $function = 'GOTMLS_decode';
1576 if (isset($_GET[$function]) && is_array($_GET[$function])) {
1577 foreach ($_GET[$function] as $decode) {
1578 if (isset($decode_list[$decode])) {
1579 $GLOBALS["GOTMLS"]["tmp"]["file_contents"] = preg_replace($decode_list[$decode].substr($GLOBALS["GOTMLS"]["tmp"]["default_ext"], 0, 2), $function.$decode.'("\1")', $GLOBALS["GOTMLS"]["tmp"]["file_contents"]);
1580 $fa .= " $decode decoded";
1581 } else
1582 $fa .= " NO-$decode";
1583 }
1584 } elseif (isset($GLOBALS["GOTMLS"]["tmp"]["threats_found"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["threats_found"]) && count($GLOBALS["GOTMLS"]["tmp"]["threats_found"])) {
1585 $f = 1;
1586 foreach ($GLOBALS["GOTMLS"]["tmp"]["threats_found"] as $threats_found=>$threats_name) {
1587 list($start, $end, $junk) = explode("-", "$threats_found--", 3);
1588 if ($start > $end)
1589 $fa .= 'ERROR['.($f++).']: Threat_size{'.$threats_found.'} Content_size{'.strlen($GLOBALS["GOTMLS"]["tmp"]["file_contents"]).'}';
1590 else
1591 $fa .= ' <a title="'.htmlspecialchars($threats_name).'" href="javascript:select_text_range(\'ta_file\', '.$start.', '.$end.');">['.$f++.']</a>';
1592 }
1593 } else
1594 $fa = " No Threats Found";
1595 foreach ($decode_list as $decode => $regex)
1596 if (preg_match($regex.substr($GLOBALS["GOTMLS"]["tmp"]["default_ext"], 0, 1), $GLOBALS["GOTMLS"]["tmp"]["file_contents"]))
1597 $fa .= ' <a href="'.GOTMLS_script_URI.'&'.$function.'[]='.$decode.'">decode['.$decode.']</a>';
1598 die("\n".'<script type="text/javascript">
1599 function select_text_range(ta_id, start, end) {
1600 ta_element = document.getElementById(ta_id);
1601 ta_element.focus();
1602 if(ta_element.setSelectionRange)
1603 ta_element.setSelectionRange(start, end);
1604 else {
1605 var r = ta_element.createTextRange();
1606 r.collapse(true);
1607 r.moveEnd(\'character\', end);
1608 r.moveStart(\'character\', start);
1609 r.select();
1610 }
1611 }
1612 window.parent.showhide("GOTMLS_iFrame", true);
1613 </script><table style="top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;"><tr><td style="width: 100%"><form style="margin: 0;" method="post" action="'.admin_url('admin-ajax.php?'.GOTMLS_set_nonce(__FUNCTION__."1583")).'" onsubmit="return confirm(\''.__("Are you sure this file is not infected and you want to ignore it in future scans?",'gotmls').'\');"><input type="hidden" name="GOTMLS_whitelist" value="'.GOTMLS_encode($file).'"><input type="hidden" name="action" value="GOTMLS_whitelist"><input type="hidden" name="GOTMLS_chksum" value="'.md5($GLOBALS["GOTMLS"]["tmp"]["file_contents"]).'O'.GOTMLS_installation_key.'"><input type="submit" value="Whitelist this file" style="float: right;"></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>File Details: '.basename($file).'</b><br />in: '.dirname(realpath($file)).'<br />encoding: '.(function_exists("mb_detect_encoding")?mb_detect_encoding($GLOBALS["GOTMLS"]["tmp"]["file_contents"]):"Unknown").'<br />size: '.strlen($GLOBALS["GOTMLS"]["tmp"]["file_contents"]).' ('.filesize(realpath($file)).'bytes)<br />permissions: '.GOTMLS_fileperms(realpath($file)).'<br />Owner/Group: '.fileowner(realpath($file)).'/'.filegroup(realpath($file)).' (you are: '.getmyuid().'/'.getmygid().')<br />modified:'.date(" Y-m-d H:i:s ", filemtime(realpath($file))).'<br />changed:'.date(" Y-m-d H:i:s ", filectime(realpath($file))).'</div><div style="overflow: auto;"><span onmouseover="document.getElementById(\'fileperms\').style.display=\'block\';" onmouseout="document.getElementById(\'fileperms\').style.display=\'none\';">'.__("Potential threats in file:",'gotmls').'</span> ('.$fa.' )</div></td></tr><tr><td style="height: 100%"><textarea id="ta_file" style="width: 100%; height: 100%">'.htmlentities(str_replace("\r", "", $GLOBALS["GOTMLS"]["tmp"]["file_contents"])).'</textarea></td></tr></table>');
1614 }
1615 }
1616 }
1617 } else
1618 die("\n//Directory Error: Nothing to scan!\n");
1619 } else {
1620 if (isset($_GET["GOTMLS_scan"]) && is_dir(GOTMLS_decode($_GET["GOTMLS_scan"])))
1621 @header("Content-type: text/javascript");
1622 die(GOTMLS_Invalid_Nonce("\n//Ajax Scan Error: ")."\n");
1623 }
1624 }
1625 add_action('wp_ajax_GOTMLS_scan', 'GOTMLS_ajax_scan');
1626
1627 function GOTMLS_ajax_nopriv() {
1628 die("\n//Permission Error: User not authenticated!\n");
1629 }
1630 add_action('wp_ajax_nopriv_GOTMLS_scan', 'GOTMLS_ajax_nopriv');
1631 add_action('wp_ajax_nopriv_GOTMLS_position', 'GOTMLS_ajax_nopriv');
1632 add_action('wp_ajax_nopriv_GOTMLS_fix', 'GOTMLS_ajax_nopriv');
1633 add_action('wp_ajax_nopriv_GOTMLS_whitelist', 'GOTMLS_ajax_nopriv');
1634 add_action('wp_ajax_nopriv_GOTMLS_empty_trash', 'GOTMLS_ajax_nopriv');
1635
1636 add_action("plugins_loaded", "GOTMLS_loaded");
1637 add_action("admin_notices", "GOTMLS_admin_notices");
1638 add_action("admin_menu", "GOTMLS_menu");
1639 add_action("network_admin_menu", "GOTMLS_menu");