function iriStatAppend() { global $wpdb; $table_name = $wpdb->prefix . "statpress"; global $_STATPRESS; $feed = ''; // Time $timestamp = current_time('timestamp'); $vdate = gmdate("Ymd", $timestamp); $vtime = gmdate("H:i:s", $timestamp); // IP $ipAddress = $_SERVER['REMOTE_ADDR']; $statuscode = !is_404() ? $_SERVER['REDIRECT_STATUS'] : 404; if (iriCheckBanIP($ipAddress)) { return ''; } //user $visitor = iriGetUser($ipAddress); if ($visitor == 'heart5' && preg_match("@^http://heart5\\.com@", get_option('home'))) { return ''; } // URL (requested) $urlRequested = iri_StatPress_URL(); if (eregi("ver=2.0", $urlRequested)) { return ''; } if (eregi(".ico\$", $urlRequested)) { return ''; } if (eregi("favicon.ico", $urlRequested)) { return ''; } if (eregi(".css\$", $urlRequested)) { return ''; } if (eregi(".js\$", $urlRequested)) { return ''; } if (stristr($urlRequested, "/wp-admin") != FALSE) { return ''; } if (stristr($urlRequested, "/wp-includes") != FALSE) { return ''; } if (stristr($urlRequested, "/wp-content/plugins") != FALSE) { return ''; } if (stristr($urlRequested, "/wp-content/themes") != FALSE) { return ''; } //处理形如 /wp-cron.php?check=1a7a02de8bf2f2e89d7bba7d0591d57c 的链接请求 if (stristr($urlRequested, "/wp-cron.php") != FALSE) { return ''; } if (stristr($urlRequested, "/wp-signup.php") != FALSE) { return ''; } if (stristr($urlRequested, "/wp-comments-post.php") != FALSE) { return ''; } if (stristr($urlRequested, "ver=") != FALSE) { return ''; } $referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $spider = iriGetSpider($userAgent); if ($spider != '' and !(get_option('statpress_collectspider') == 'checked')) { return ''; } // Trap feeds $feed = iri_StatPress_is_feed(); // Get OS and browser $os = iriGetOS($userAgent); $browser = iriGetBrowser($userAgent); list($searchengine, $search_phrase) = explode("|", iriGetSE($referrer)); // Auto-delete visits if... if (get_option('statpress_autodelete') != '') { $t = gmdate("Ymd", strtotime('-' . get_option('statpress_autodelete'))); $results = $wpdb->query("DELETE FROM " . $table_name . " WHERE date < '" . $t . "'"); } if (!is_user_logged_in() or get_option('statpress_collectloggeduser') == 'checked') { // if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { // iri_StatPress_CreateTable(); // } iri_StatPress_CreateTable(); $p = iri_StatPressCN_Url2P($urlRequested); if ($p == false) { $p[0] = ""; $p[1] = ''; } $insert = "INSERT INTO " . $table_name . " (date, time, ip, urlrequested, statuscode, ptype, pvalue, agent, referrer, search,nation,os,browser,searchengine,spider,feed,user,timestamp) " . "VALUES ('{$vdate}','{$vtime}','{$ipAddress}','" . addslashes(strip_tags($urlRequested)) . "','{$statuscode}','{$p['0']}','{$p['1']}','" . addslashes(strip_tags($userAgent)) . "','{$referrer}','" . addslashes(strip_tags($search_phrase)) . "','" . iriDomain($ipAddress) . "','{$os}','{$browser}','{$searchengine}','{$spider}','{$feed}','{$visitor}','{$timestamp}')"; $results = $wpdb->query($insert); } //优化统计数据库 $n = mt_rand(1, 1000); if ($n == 11) { // lucky number $wpdb->query("OPTIMIZE TABLE {$table_name}"); } }
function iriStatAppend() { global $wpdb; $table_name = $wpdb->prefix . "statpress"; global $userdata; global $_STATPRESS; get_currentuserinfo(); $feed = ''; // Time $timestamp = current_time('timestamp'); $vdate = gmdate("Ymd", $timestamp); $vtime = gmdate("H:i:s", $timestamp); // IP $ipAddress = $_SERVER['REMOTE_ADDR']; if (iriCheckBanIP($ipAddress) === true) { return ''; } // Determine Threats if http:bl installed $threat_score = 0; $threat_type = 0; $httpbl_key = get_option("httpbl_key"); if ($httpbl_key !== false) { $result = explode(".", gethostbyname($httpbl_key . "." . implode(".", array_reverse(explode(".", $ipAddress))) . ".dnsbl.httpbl.org")); // If the response is positive if ($result[0] == 127) { $threat_score = $result[2]; $threat_type = $result[3]; } } // URL (requested) $urlRequested = iri_StatPress_URL(); if (eregi(".ico\$", $urlRequested)) { return ''; } if (eregi("favicon.ico", $urlRequested)) { return ''; } if (eregi(".css\$", $urlRequested)) { return ''; } if (eregi(".js\$", $urlRequested)) { return ''; } if (stristr($urlRequested, "/wp-content/themes/wicketpixie/plugins") != false) { return ''; } if (stristr($urlRequested, "/wp-content/themes") != false) { return ''; } $referrer = isset($_SERVER['HTTP_REFERER']) ? htmlentities($_SERVER['HTTP_REFERER']) : ''; $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? htmlentities($_SERVER['HTTP_USER_AGENT']) : ''; $spider = iriGetSpider($userAgent); if ($spider != '' and get_option('statpress_donotcollectspider') == 'checked') { return ''; } if ($spider != '') { $os = ''; $browser = ''; } else { // Trap feeds $prsurl = parse_url(get_bloginfo('url')); $feed = iri_StatPress_is_feed($prsurl['scheme'] . '://' . $prsurl['host'] . $_SERVER['REQUEST_URI']); // Get OS and browser $os = iriGetOS($userAgent); $browser = iriGetBrowser($userAgent); list($searchengine, $search_phrase) = explode("|", iriGetSE($referrer)); } // Auto-delete visits if... if (get_option('statpress_autodelete_spider') != '') { $t = gmdate("Ymd", strtotime('-' . get_option('statpress_autodelete_spider'))); $results = $wpdb->query("DELETE FROM " . $table_name . " WHERE date < '" . $t . "' AND spider <> ''"); } if (get_option('statpress_autodelete') != '') { $t = gmdate("Ymd", strtotime('-' . get_option('statpress_autodelete'))); $results = $wpdb->query("DELETE FROM " . $table_name . " WHERE date < '" . $t . "'"); } if (!is_user_logged_in() or get_option('statpress_collectloggeduser') == 'checked') { if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { iri_StatPress_CreateTable(); } $insert = "INSERT INTO " . $table_name . " (date, time, ip, urlrequested, agent, referrer, search,nation,os,browser,searchengine,spider,feed,user,threat_score,threat_type,timestamp) " . "VALUES ('{$vdate}','{$vtime}','{$ipAddress}','" . mysql_real_escape_string($urlRequested) . "','" . mysql_real_escape_string(strip_tags($userAgent)) . "','" . mysql_real_escape_string($referrer) . "','" . mysql_real_escape_string(strip_tags($search_phrase)) . "','" . iriDomain($ipAddress) . "','" . mysql_real_escape_string($os) . "','" . mysql_real_escape_string($browser) . "','{$searchengine}','{$spider}','{$feed}','{$userdata->user_login}',{$threat_score},{$threat_type},'{$timestamp}')"; $results = $wpdb->query($insert); } }
function iriStatAppend() { global $wpdb; $table_name = $wpdb->prefix . "statpress"; global $userdata; global $_STATPRESS; get_currentuserinfo(); $feed = ''; // Time $timestamp = current_time('timestamp'); $vdate = gmdate("Ymd", $timestamp); $vtime = gmdate("H:i:s", $timestamp); // IP $ipAddress = $_SERVER['REMOTE_ADDR']; if (iriCheckBanIP($ipAddress) == '') { return ''; } // URL (requested) $urlRequested = iri_StatPress_URL(); if (eregi(".ico\$", $urlRequested)) { return ''; } if (eregi("favicon.ico", $urlRequested)) { return ''; } if (eregi(".css\$", $urlRequested)) { return ''; } if (eregi(".js\$", $urlRequested)) { return ''; } if (stristr($urlRequested, "/wp-content/plugins") != FALSE) { return ''; } if (stristr($urlRequested, "/wp-content/themes") != FALSE) { return ''; } $referrer = isset($_SERVER['HTTP_REFERER']) ? htmlentities($_SERVER['HTTP_REFERER']) : ''; $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? htmlentities($_SERVER['HTTP_USER_AGENT']) : ''; $spider = iriGetSpider($userAgent); if ($spider != '' and get_option('statpress_donotcollectspider') == 'checked') { return ''; } if ($spider != '') { $os = ''; $browser = ''; } else { // Trap feeds $feed = iri_StatPress_is_feed(get_bloginfo('url') . $_SERVER['REQUEST_URI']); // Get OS and browser $os = iriGetOS($userAgent); $browser = iriGetBrowser($userAgent); list($searchengine, $search_phrase) = explode("|", iriGetSE($referrer)); } // Auto-delete visits if... if (get_option('statpress_autodelete') != '') { $t = gmdate("Ymd", strtotime('-' . get_option('statpress_autodelete'))); $results = $wpdb->query("DELETE FROM " . $table_name . " WHERE date < '" . $t . "'"); } if (!is_user_logged_in() or get_option('statpress_collectloggeduser') == 'checked') { if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { iri_StatPress_CreateTable(); } $insert = "INSERT INTO " . $table_name . " (date, time, ip, urlrequested, agent, referrer, search,nation,os,browser,searchengine,spider,feed,user,timestamp) " . "VALUES ('{$vdate}','{$vtime}','{$ipAddress}','{$urlRequested}','" . addslashes(strip_tags($userAgent)) . "','{$referrer}','" . addslashes(strip_tags($search_phrase)) . "','" . iriDomain($ipAddress) . "','{$os}','{$browser}','{$searchengine}','{$spider}','{$feed}','{$userdata->user_login}','{$timestamp}')"; $results = $wpdb->query($insert); } }