PluginProbe ʕ •ᴥ•ʔ
Anti-Malware Security and Brute-Force Firewall / 4.23.68
Anti-Malware Security and Brute-Force Firewall v4.23.68
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 / safe-load / trace.php
gotmls / safe-load Last commit date
.htaccess 11 years ago index.php 2 years ago session.php 2 years ago trace.php 2 years ago wp-login.php 2 years ago wp-settings.php 2 years ago
trace.php
271 lines
1 <?php
2 /**
3 * GOTMLS Plugin Core Functions
4 * @package GOTMLS
5 */
6
7 define("GOTMLS_Version", '4.23.68');
8 define("GOTMLS_SAFELOAD_DIR", dirname(__FILE__)."/");
9 define("GOTMLS_CHMOD_FILE", 0644);
10 define("GOTMLS_CHMOD_DIR", 0755);
11 define("GOTMLS_require_version", "3.3");
12
13 function GOTMLS_define($DEF, $val) {
14 if (!defined($DEF))
15 define($DEF, $val);
16 }
17
18 function GOTMLS_safe_ip($ip) {
19 return substr(preg_replace('/[^0-9\.\:a-f]/i', "", $ip), 0, 40);
20 }
21
22 function GOTMLS_get_current_user_id($return = 0) {
23 if (function_exists("wp_get_current_user") && ($current_user = @wp_get_current_user()) && (@$current_user->ID > 0))
24 $return = $current_user->ID;
25 return $return;
26 }
27
28 function GOTMLS_save_contents($file, $content) {
29 $chmoded_file = false;
30 $chmoded_dir = false;
31 if ((is_dir(dirname($file)) || @mkdir(dirname($file), GOTMLS_CHMOD_DIR, true)) && !is_writable(dirname($file)) && ($GOTMLS_chmod_dir = @fileperms(dirname($file))))
32 $chmoded_dir = @chmod(dirname($file), 0777);
33 if (is_file($file) && !is_writable($file) && ($GOTMLS_chmod_file = @fileperms($file)))
34 $chmoded_file = @chmod($file, 0666);
35 if (function_exists("file_put_contents"))
36 $return = @file_put_contents($file, $content);
37 elseif ($fp = fopen($file, 'w')) {
38 if (false === fwrite($fp, $content))
39 $return = false;
40 else
41 $return = true;
42 fclose($fp);
43 } else
44 $return = false;
45 if ($chmoded_file === true)
46 @chmod($file, $GOTMLS_chmod_file);
47 if ($chmoded_dir === true)
48 @chmod(dirname($file), $GOTMLS_chmod_dir);
49 return $return;
50 }
51
52 function GOTMLS_create_session_file($GOTMLS_server_times = 0) {
53 if (!defined("GOTMLS_SESSION_FILE"))
54 define("GOTMLS_SESSION_FILE", dirname(__FILE__)."/_session/index.php");
55 if (!is_dir(dirname(GOTMLS_SESSION_FILE)))
56 @mkdir(dirname(GOTMLS_SESSION_FILE), GOTMLS_CHMOD_DIR);
57 if (is_dir(dirname(GOTMLS_SESSION_FILE)))
58 if (is_numeric($GOTMLS_server_times) && $GOTMLS_server_times)
59 $GOTMLS_server_times = GOTMLS_save_contents(GOTMLS_SESSION_FILE, "<?php if (!defined('GOTMLS_INSTALL_TIME')) define('GOTMLS_INSTALL_TIME', '$GOTMLS_server_times');");
60 if (is_file(GOTMLS_SESSION_FILE)) {
61 if ($GOTMLS_server_times === false)
62 unlink(GOTMLS_SESSION_FILE);
63 else
64 require_once(GOTMLS_SESSION_FILE);
65 }
66 return $GOTMLS_server_times;
67 }
68
69 define("GOTMLS_REMOTEADDR", GOTMLS_safe_ip(isset($_SERVER["HTTP_CF_CONNECTING_IP"])?$_SERVER["HTTP_CF_CONNECTING_IP"]:(isset($_SERVER["HTTP_X_FORWARDED_FOR"])?$_SERVER["HTTP_X_FORWARDED_FOR"]:(isset($_SERVER["REMOTE_ADDR"])?$_SERVER["REMOTE_ADDR"]:microtime(true)))));
70
71 $GOTMLS_mu = array('<?php
72 /**
73 * GOTMLS Brute-Force Login Protection
74 * @package GOTMLS
75 * @since '.GOTMLS_Version.'
76 */
77 ', '
78 if (defined("ABSPATH")) {
79 $GOTMLS_create_session_file = "no";
80 if (is_file(ABSPATH."wp-admin/includes/plugin.php"))
81 require_once(ABSPATH."wp-admin/includes/plugin.php");
82 if (defined("WP_PLUGIN_DIR") && is_file(WP_PLUGIN_DIR."/gotmls/safe-load/trace.php")) {
83 require_once(WP_PLUGIN_DIR."/gotmls/safe-load/trace.php");
84 GOTMLS_create_session_file();
85 if (function_exists("is_plugin_active") && is_plugin_active("gotmls/index.php")) {
86 if (!(defined("GOTMLS_INSTALL_TIME") && is_numeric(GOTMLS_INSTALL_TIME) && GOTMLS_INSTALL_TIME > 0))
87 $GOTMLS_create_session_file = GOTMLS_create_session_file(microtime(true));
88 } elseif (defined("GOTMLS_INSTALL_TIME") && is_numeric(GOTMLS_INSTALL_TIME) && GOTMLS_INSTALL_TIME > 0)
89 GOTMLS_create_session_file(-1 * microtime(true));
90 } elseif (defined("WP_PLUGIN_DIR") && is_dir(WP_PLUGIN_DIR) && defined("GOTMLS_MU_FILE") && (__FILE__ == GOTMLS_MU_FILE) && !is_dir(WP_PLUGIN_DIR."/gotmls"))
91 unlink(GOTMLS_MU_FILE);
92 }');
93
94 function GOTMLS_get_version($which = "") {
95 global $wp_version, $cp_version;
96 if (function_exists('classicpress_version'))
97 $match = array("GOTMLS_wp_version", "c", preg_replace( '#[+-].*$#', '', classicpress_version()));
98 elseif (isset($cp_version) && ($cp_version))
99 $match = array("GOTMLS_wp_version", "c", preg_replace( '#[+-].*$#', '', $cp_version));
100 elseif (isset($wp_version) && ($wp_version))
101 $match = array("GOTMLS_wp_version", "w", "$wp_version");
102 elseif (!(is_file($file = ABSPATH."wp-includes/version.php") && ($contents = @file_get_contents($file)) && preg_match('/\n\$(c|w)p_version\s*=\s*[\'"]([0-9\.]+)/i', $contents, $match)))
103 $match = array("GOTMLS_wp_version", "w", "Unknown");
104 GOTMLS_define("GOTMLS_wp_version", $match[2]);
105 if ($which == "URL")
106 return 'ver='.GOTMLS_Version.'&'.$match[1].'p='.GOTMLS_wp_version;
107 else
108 return GOTMLS_wp_version;
109 }
110
111 function GOTMLS_load_contents($TXT, $default_encoding = "UTF-8") {
112 global $wpdb;
113 $encoding = "UTF-8";
114 if (!(isset($GLOBALS["GOTMLS"]["tmp"]["custom_whitelist"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["custom_whitelist"]))) {
115 $GLOBALS["GOTMLS"]["tmp"]["custom_whitelist"] = array();
116 $get_whitelist_SQL = "SELECT CONCAT(`post_mime_type`, 'O', `comment_count`) AS `chksum`, `post_title` FROM `$wpdb->posts` WHERE `post_type` = 'GOTMLS_quarantine' AND `post_status` = 'pending'";
117 if (is_array($get_whitelist_rows = $wpdb->get_results($get_whitelist_SQL, ARRAY_A)))
118 foreach ($get_whitelist_rows as $get_whitelist_row)
119 $GLOBALS["GOTMLS"]["tmp"]["custom_whitelist"][$get_whitelist_row["chksum"]] = GOTMLS_decode($get_whitelist_row["post_title"]);
120 }
121 if (count($GLOBALS["GOTMLS"]["tmp"]["custom_whitelist"]) && isset($GLOBALS["GOTMLS"]["tmp"]["custom_whitelist"][md5($TXT)."O".strlen($TXT)]))
122 $GLOBALS["GOTMLS"]["tmp"]["contents_whitelist"] = md5($TXT)."O".strlen($TXT);
123 else
124 $GLOBALS["GOTMLS"]["tmp"]["contents_whitelist"] = false;
125 if (!(function_exists("mb_detect_encoding") && isset($GLOBALS["GOTMLS"]["tmp"]["default_encodings"]) && ($encoding = mb_detect_encoding($TXT, $GLOBALS["GOTMLS"]["tmp"]["default_encodings"])) && in_array($encoding, array('UCS-4', 'UCS-4LE', 'UTF-32', 'UTF-32BE', 'UTF-32LE', 'UTF-16', 'UTF-16BE', 'UTF-16LE', 'UTF-8', 'utf8', 'ASCII', 'US-ASCII', 'EUC-JP', 'eucJP', 'x-euc-jp', 'SJIS', 'eucJP-win', 'SJIS-win', 'CP932', 'MS932', 'Windows-31J', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16', 'EUC-CN', 'EUC_CN', 'eucCN', 'gb2312', 'EUC-TW', 'EUC_TW', 'eucTW', 'BIG-5', 'CN-BIG5', 'BIG-FIVE', 'BIGFIVE', 'EUC-KR', 'EUC_KR', 'eucKR', 'KOI8-R', 'KOI8R')))) {
126 if (substr($encoding, 0, 7) == 'Windows')
127 $encoding = 'ISO-8859-1';
128 else
129 $encoding = $default_encoding;
130 }
131 $GLOBALS["GOTMLS"]["tmp"]["file_contents"] = $TXT;
132 if (function_exists("mb_internal_encoding"))
133 mb_internal_encoding($encoding);
134 if (function_exists("mb_regex_encoding"))
135 mb_regex_encoding($encoding);
136 $GLOBALS["GOTMLS"]["tmp"]["encoding"] = $encoding;
137 return strlen($TXT);
138 }
139
140 function GOTMLS_htmlentities($TXT, $flags = ENT_COMPAT, $encoding = "ASCII") {
141 $prelen = strlen($TXT);
142 if ($prelen == 0)
143 return "";
144 if ($encoding == "ASCII")
145 $encoding = "UTF-8";
146 $encoded = htmlentities($TXT, $flags, $encoding);
147 if (strlen($encoded) == 0) {
148 $encoding = "ISO-8859-1";
149 $encoded = htmlentities($TXT, $flags, $encoding);
150 }
151 if (!$encoded)
152 $encoded = __("Failed to encode HTML entities!",'gotmls');
153 return $encoded;
154 }
155
156 function GOTMLS_htmlspecialchars($TXT, $flags = ENT_COMPAT, $encoding = "ASCII") {
157 $prelen = strlen($TXT);
158 if ($prelen == 0)
159 return "";
160 if ($encoding == "ASCII")
161 $encoding = "UTF-8";
162 $encoded = htmlspecialchars($TXT, $flags, $encoding);
163 if (strlen($encoded) == 0) {
164 $encoding = "ISO-8859-1";
165 $encoded = htmlspecialchars($TXT, $flags, $encoding);
166 }
167 if (!$encoded)
168 $encoded = __("Failed to encode HTML special characters!",'gotmls');
169 return $encoded;
170 }
171
172 function GOTMLS_encode_njG($timestamp = 0) {
173 $month = "zjfmayulgsovdz";
174 if (!(is_numeric($timestamp) && ($timestamp > 0)))
175 $timestamp = time();
176 if (($date = intval(date("j", $timestamp))) > 9)
177 $date = chr(88+$date);
178 return substr($month, intval(date("n", $timestamp)), 1).$date.chr(98+intval(date("G", $timestamp)));
179 }
180
181 function GOTMLS_convert_r($r_str) {
182 if (function_exists("mb_ereg_replace"))
183 return mb_ereg_replace("\r", "", $r_str);
184 else
185 return preg_replace('/\r/', "", $r_str);
186 }
187
188 function GOTMLS_error_div($error_str, $class = "error") {
189 return GOTMLS_html_tags(array('div' => $error_str), array('div' => "class=\"$class\""));
190 }
191
192 function GOTMLS_uckserialize($unsafe_serialized) {
193 if (!(is_array($unsafe_serialized)) && (is_array($safe_unserialized = @unserialize(preg_replace('/[oc]:\d+:".*?":(\d+):\{/is', 'a:\1:{', $unsafe_serialized)))))
194 return $safe_unserialized;
195 return $unsafe_serialized;
196 }
197
198 function GOTMLS_encode64($unencoded_string) {
199 $encoding = "BASE64";
200 if (function_exists(strtolower($encoding)."_encode"))
201 return base64_encode($unencoded_string);
202 elseif (function_exists("mb_convert_encoding"))
203 return mb_convert_encoding($unencoded_string, $encoding, "UTF-8");
204 else
205 return "Cannot encode: $unencoded_string";
206 }
207
208 function GOTMLS_encode($unencoded_string, $post_encode = "") {
209 $encoded_array = explode("=", GOTMLS_encode64($unencoded_string)."=");
210 $encoded_string = strtr($encoded_array[0], "+/0", "-_=").(count($encoded_array)-1);
211 if ($post_encode == "D")
212 $encoded_string = str_rot13($encoded_string).($post_encode);
213 return $encoded_string;
214 }
215
216 function GOTMLS_decode64($encoded_string) {
217 $encoding = "BASE64";
218 if (function_exists(strtolower($encoding)."_decode"))
219 return base64_decode($encoded_string, true);
220 elseif (function_exists("mb_convert_encoding"))
221 return mb_convert_encoding($encoded_string, "UTF-8", $encoding);
222 else
223 return "Cannot decode: $encoded_string";
224 }
225
226 function GOTMLS_decode($encoded_string) {
227 if (strlen($encoded_string) > 1 && substr($encoded_string, -1) == "D")
228 $encoded_string = str_rot13(substr($encoded_string, 0, -1));
229 $tail = 0;
230 if (strlen($encoded_string) > 1 && is_numeric(substr($encoded_string, -1)) && substr($encoded_string, -1) > 0)
231 $tail = substr($encoded_string, -1) - 1;
232 else
233 $encoded_string .= "$tail";
234 $encoded_string = strtr(substr($encoded_string, 0, -1), "-_=", "+/0").str_repeat("=", $tail);
235 return GOTMLS_decode64($encoded_string);
236 }
237
238 // Debug Tracer function by ELI at GOTMLS.NET
239 function GOTMLS_debug_trace($file) {
240 $mt = microtime(true);
241 if (!session_id())
242 @session_start();
243 if (!isset($_SESSION["GOTMLS_traces"]))
244 $_SESSION["GOTMLS_traces"] = 0;
245 if (!isset($_SESSION["GOTMLS_trace_includes"]))
246 $_SESSION["GOTMLS_trace_includes"] = array();
247 if (isset($_SESSION["GOTMLS_trace_includes"][$_SESSION["GOTMLS_traces"]][$file]))
248 $_SESSION["GOTMLS_traces"] = $mt;
249 if (!$GOTMLS_headers_sent && $GOTMLS_headers_sent = headers_sent($filename, $linenum)) {
250 if (!$filename)
251 $filename = __("an unknown file",'gotmls');
252 if (!is_numeric($linenum))
253 $linenum = __("unknown",'gotmls');
254 $mt .= sprintf(__(': Headers sent by %1$s on line %2$s.','gotmls'), $filename, $linenum);
255 }
256 if (!(isset($_SESSION["GOTMLS_OBs"]) && is_array($_SESSION["GOTMLS_OBs"])))
257 $_SESSION["GOTMLS_OBs"] = array();
258 if (($OBs = ob_list_handlers()) && is_array($OBs) && (count($_SESSION["GOTMLS_OBs"]) != count($OBs))) {
259 $mt .= print_r(array("ob"=>ob_list_handlers()),1);
260 $_SESSION["GOTMLS_OBs"] = $OBs;
261 }
262 $_SESSION["GOTMLS_trace_includes"][$_SESSION["GOTMLS_traces"]][$file] = $mt;
263 if (isset($_GET["GOTMLS_traces"]) && count($_SESSION["GOTMLS_trace_includes"][$_SESSION["GOTMLS_traces"]]) > $_GET["GOTMLS_includes"]) {
264 $_SESSION["GOTMLS_traces"] = $mt;
265 foreach ($_SESSION["GOTMLS_trace_includes"] as $trace => $array)
266 if ($trace < $_GET["GOTMLS_traces"])
267 unset($_SESSION["GOTMLS_trace_includes"][$trace]);
268 die(print_r(array("<a href='?GOTMLS_traces=".substr($_SESSION["GOTMLS_traces"], 0, 10)."'>".substr($_SESSION["GOTMLS_traces"], 0, 10)."</a><pre>",$_SESSION["GOTMLS_trace_includes"],"</pre>"),true));
269 }
270 }
271