PluginProbe ʕ •ᴥ•ʔ
Anti-Malware Security and Brute-Force Firewall / trunk
Anti-Malware Security and Brute-Force Firewall vtrunk
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 1 year ago session.php 1 year ago trace.php 3 weeks ago wp-login.php 1 year ago wp-settings.php 2 years ago
trace.php
275 lines
1 <?php
2 /**
3 * GOTMLS Plugin Core Functions
4 * @package GOTMLS
5 */
6
7 define("GOTMLS_Version", '4.23.90');
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('/[^\d\.\: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*+[\'"]([\d\.]++)/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".GOTMLS_strlen($TXT)]))
122 $GLOBALS["GOTMLS"]["tmp"]["contents_whitelist"] = md5($TXT)."O".GOTMLS_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 GOTMLS_strlen($TXT);
138 }
139
140 function GOTMLS_strlen($TXT) {
141 return (is_string($TXT) ? (is_null($TXT) ? 0 : strlen($TXT)) : 0);
142 }
143
144 function GOTMLS_htmlentities($TXT, $flags = ENT_COMPAT, $encoding = "ASCII") {
145 $prelen = GOTMLS_strlen($TXT);
146 if ($prelen == 0)
147 return "";
148 if ($encoding == "ASCII")
149 $encoding = "UTF-8";
150 $encoded = htmlentities($TXT, $flags, $encoding);
151 if (GOTMLS_strlen($encoded) == 0) {
152 $encoding = "ISO-8859-1";
153 $encoded = htmlentities($TXT, $flags, $encoding);
154 }
155 if (!$encoded)
156 $encoded = __("Failed to encode HTML entities!",'gotmls');
157 return $encoded;
158 }
159
160 function GOTMLS_htmlspecialchars($TXT, $flags = ENT_COMPAT, $encoding = "ASCII") {
161 $prelen = GOTMLS_strlen($TXT);
162 if ($prelen == 0)
163 return "";
164 if ($encoding == "ASCII")
165 $encoding = "UTF-8";
166 $encoded = htmlspecialchars($TXT, $flags, $encoding);
167 if (GOTMLS_strlen($encoded) == 0) {
168 $encoding = "ISO-8859-1";
169 $encoded = htmlspecialchars($TXT, $flags, $encoding);
170 }
171 if (!$encoded)
172 $encoded = __("Failed to encode HTML special characters!",'gotmls');
173 return $encoded;
174 }
175
176 function GOTMLS_encode_njG($timestamp = 0) {
177 $month = "zjfmayulgsovdz";
178 if (!(is_numeric($timestamp) && ($timestamp > 0)))
179 $timestamp = time();
180 if (($date = intval(date("j", $timestamp))) > 9)
181 $date = chr(88+$date);
182 return substr($month, intval(date("n", $timestamp)), 1).$date.chr(98+intval(date("G", $timestamp)));
183 }
184
185 function GOTMLS_convert_r($r_str) {
186 if (function_exists("mb_ereg_replace"))
187 return mb_ereg_replace("\r", "", $r_str);
188 else
189 return preg_replace('/\r/', "", $r_str);
190 }
191
192 function GOTMLS_error_div($error_str, $class = "error") {
193 return GOTMLS_html_tags(array('div' => $error_str), array('div' => "class=\"$class\""));
194 }
195
196 function GOTMLS_uckserialize($unsafe_serialized) {
197 if (!(is_array($unsafe_serialized)) && (is_array($safe_unserialized = @unserialize(preg_replace('/[oc]:[\+\d]++:".*?":([\+\d]++):\{/is', 'a:\1:{', $unsafe_serialized)))))
198 return $safe_unserialized;
199 return $unsafe_serialized;
200 }
201
202 function GOTMLS_encode64($unencoded_string) {
203 $encoding = "BASE64";
204 if (function_exists(strtolower($encoding)."_encode"))
205 return base64_encode($unencoded_string);
206 elseif (function_exists("mb_convert_encoding"))
207 return mb_convert_encoding($unencoded_string, $encoding, "UTF-8");
208 else
209 return "Cannot encode: $unencoded_string";
210 }
211
212 function GOTMLS_encode($unencoded_string, $post_encode = "") {
213 $encoded_array = explode("=", GOTMLS_encode64($unencoded_string)."=");
214 $encoded_string = strtr($encoded_array[0], "+/0", "-_=").(count($encoded_array)-1);
215 if ($post_encode == "D")
216 $encoded_string = str_rot13($encoded_string).($post_encode);
217 return $encoded_string;
218 }
219
220 function GOTMLS_decode64($encoded_string) {
221 $encoding = "BASE64";
222 if (function_exists(strtolower($encoding)."_decode"))
223 return base64_decode($encoded_string, true);
224 elseif (function_exists("mb_convert_encoding"))
225 return mb_convert_encoding($encoded_string, "UTF-8", $encoding);
226 else
227 return "Cannot decode: $encoded_string";
228 }
229
230 function GOTMLS_decode($encoded_string) {
231 if (GOTMLS_strlen($encoded_string) > 1 && substr($encoded_string, -1) == "D")
232 $encoded_string = str_rot13(substr($encoded_string, 0, -1));
233 $tail = 0;
234 if (GOTMLS_strlen($encoded_string) > 1 && is_numeric(substr($encoded_string, -1)) && substr($encoded_string, -1) > 0)
235 $tail = substr($encoded_string, -1) - 1;
236 else
237 $encoded_string .= "$tail";
238 $encoded_string = strtr(substr($encoded_string, 0, -1), "-_=", "+/0").str_repeat("=", $tail);
239 return GOTMLS_decode64($encoded_string);
240 }
241
242 // Debug Tracer function by ELI at GOTMLS.NET
243 function GOTMLS_debug_trace($file) {
244 $mt = microtime(true);
245 if (!session_id())
246 @session_start();
247 if (!isset($_SESSION["GOTMLS_traces"]))
248 $_SESSION["GOTMLS_traces"] = 0;
249 if (!isset($_SESSION["GOTMLS_trace_includes"]))
250 $_SESSION["GOTMLS_trace_includes"] = array();
251 if (isset($_SESSION["GOTMLS_trace_includes"][$_SESSION["GOTMLS_traces"]][$file]))
252 $_SESSION["GOTMLS_traces"] = $mt;
253 if (!$GOTMLS_headers_sent && $GOTMLS_headers_sent = headers_sent($filename, $linenum)) {
254 if (!$filename)
255 $filename = __("an unknown file",'gotmls');
256 if (!is_numeric($linenum))
257 $linenum = __("unknown",'gotmls');
258 $mt .= sprintf(__(': Headers sent by %1$s on line %2$s.','gotmls'), $filename, $linenum);
259 }
260 if (!(isset($_SESSION["GOTMLS_OBs"]) && is_array($_SESSION["GOTMLS_OBs"])))
261 $_SESSION["GOTMLS_OBs"] = array();
262 if (($OBs = ob_list_handlers()) && is_array($OBs) && (count($_SESSION["GOTMLS_OBs"]) != count($OBs))) {
263 $mt .= print_r(array("ob"=>ob_list_handlers()),1);
264 $_SESSION["GOTMLS_OBs"] = $OBs;
265 }
266 $_SESSION["GOTMLS_trace_includes"][$_SESSION["GOTMLS_traces"]][$file] = $mt;
267 if (isset($_GET["GOTMLS_traces"]) && count($_SESSION["GOTMLS_trace_includes"][$_SESSION["GOTMLS_traces"]]) > $_GET["GOTMLS_includes"]) {
268 $_SESSION["GOTMLS_traces"] = $mt;
269 foreach ($_SESSION["GOTMLS_trace_includes"] as $trace => $array)
270 if ($trace < $_GET["GOTMLS_traces"])
271 unset($_SESSION["GOTMLS_trace_includes"][$trace]);
272 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));
273 }
274 }
275