function luc_update_SearchEngine($text, $date_from, $date_to) { echo "<thead><tr><th scope='col' colspan='2'>Updating Search Engines</th></tr></thead>\n\t\t\t\t<tbody>\n\t\t\t\t<tr>"; global $wpdb; $table_name = STATPRESS_V_TABLE_NAME; $wpdb->query("UPDATE {$table_name}\n\t\t\t\t\tSET searchengine = '', search=''\n\t\t\t\t\tWHERE date BETWEEN {$date_from} AND {$date_to}"); $qry = $wpdb->get_results("SELECT id, referrer\n\t\t\t\tFROM {$table_name}\n\t\t\t\tWHERE referrer <> ''\n\t\t\t\t\tAND feed =''\n\t\t\t\t\tAND date BETWEEN {$date_from} AND {$date_to} "); foreach ($qry as $rk) { list($searchengine, $search_phrase) = explode("|", luc_GetSE($rk->referrer)); if ($searchengine != '') { $qry = "UPDATE {$table_name}\n\t\t\t\t\tSET searchengine = '{$searchengine}', search = '" . addslashes($search_phrase) . "'\n\t\t\t\t\tWHERE id= '" . $rk->id . "'"; $wpdb->query($qry); } } luc_update_footer($wpdb->num_queries, $date_to, $date_from); if (isset($text)) { $text .= ','; } $text = $text . " Searchs engines"; return $text; }
function luc_StatAppend() { global $wpdb, $StatPressV_Option, $userdata; $table_name = STATPRESS_V_TABLE_NAME; get_currentuserinfo(); $feed = ''; // Time $timestamp = current_time('timestamp'); $vdate = gmdate("Ymd", $timestamp); $vtime = gmdate("H:i:s", $timestamp); // IP if (strnatcmp(phpversion(), '5.2.0') >= 0) { $ipAddress = htmlentities(luc_get_ip()); } else { $ipAddress = htmlentities($_SERVER['REMOTE_ADDR']); } if (luc_CheckBanIP($ipAddress) === true) { return ''; } // URL (requested) $urlRequested = luc_StatPressV_URL(); $post_title = luc_post_title_Decode($urlRequested); $real_post = $post_title == $urlRequested ? 0 : 1; $referrer = isset($_SERVER['HTTP_REFERER']) ? esc_url_raw($_SERVER['HTTP_REFERER']) : ''; $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? htmlentities($_SERVER['HTTP_USER_AGENT']) : ''; $spider = luc_GetSpider($userAgent); if ($spider != '' and $StatPressV_Option['StatPressV_Dont_Collect_Spider'] == 'checked') { return ''; } if ($spider != '') { $os = ''; $browser = ''; } else { // Trap feeds $prsurl = parse_url(get_bloginfo('url')); $feed = luc_StatPressV_Is_Feed($prsurl['scheme'] . '://' . $prsurl['host'] . htmlentities($_SERVER['REQUEST_URI'])); // Get OS and browser $os = luc_GetOS($userAgent); $browser = luc_GetBrowser($userAgent); $refsearch = luc_GetSE($referrer); if ($refsearch !== null) { list($searchengine, $search_phrase) = explode("|", $refsearch); } else { $searchengine = ""; $search_phrase = ""; } } $code = explode(';', htmlentities($_SERVER['HTTP_ACCEPT_LANGUAGE'])); $code = explode(',', $code[0]); $lang = explode('-', $code[0]); $language = $lang[0]; $country = $lang[1]; if ((!isset($lang[1]) or $StatPressV_Option['StatPressV_locate_IP'] == 'GeoIP') & ($StatPressV_Option['StatPressV_Use_GeoIP'] == 'checked' & function_exists('geoip_open'))) { // Use GeoIP? http://geolite.maxmind.com/download/geoip/api/php/ // Open the database to read and save info $gi = geoip_open(luc_GeoIP_dbname('country'), GEOIP_STANDARD); $cc = geoip_country_code_by_addr($gi, $ipAddress); if ($cc !== false) { $country = $cc; } else { $country = NULL; } } // Auto-delete visits if... $today = gmdate('Ymd', current_time('timestamp')); if ($today != $StatPressV_Option['StatPressV_Delete_Today']) { $StatPressV_Option['StatPressV_Delete_Today'] = $today; if ($StatPressV_Option['StatPressV_AutoDelete_spider'] != '') { $t = gmdate("Ymd", strtotime('-' . $StatPressV_Option['StatPressV_AutoDelete_spider'])); $results = $wpdb->query("DELETE FROM " . $table_name . " WHERE date < '" . $t . "' AND spider <> ''"); $results = $wpdb->query('OPTIMIZE TABLE ' . $table_name); } if ($StatPressV_Option['StatPressV_AutoDelete'] != '') { $t = gmdate("Ymd", strtotime('-' . $StatPressV_Option['StatPressV_AutoDelete'])); $results = $wpdb->query("DELETE FROM " . $table_name . " WHERE date < '" . $t . "'"); $results = $wpdb->query('OPTIMIZE TABLE ' . $table_name); } update_option('StatPressV_Option', $StatPressV_Option); } if (!is_user_logged_in() or $StatPressV_Option['StatPressV_Dont_Collect_Logged_User'] != 'checked' or $StatPressV_Option['StatPressV_Dont_Collect_Logged_User'] == 'checked' and !current_user_can($StatPressV_Option['StatPressV_Dont_Collect_Logged_User_MinPermit'])) { $result = $wpdb->insert($table_name, array('date' => $vdate, 'time' => $vtime, 'ip' => $ipAddress, 'urlrequested' => mysql_real_escape_string(strip_tags($urlRequested)), 'agent' => mysql_real_escape_string(strip_tags($userAgent)), 'referrer' => mysql_real_escape_string(strip_tags($referrer)), 'search' => mysql_real_escape_string(strip_tags($search_phrase)), 'os' => mysql_real_escape_string(strip_tags($os)), 'browser' => mysql_real_escape_string(strip_tags($browser)), 'searchengine' => mysql_real_escape_string(strip_tags($searchengine)), 'spider' => mysql_real_escape_string(strip_tags($spider)), 'feed' => $feed, 'user' => $userdata->user_login, 'timestamp' => $timestamp, 'language' => mysql_real_escape_string(strip_tags($language)), 'country' => mysql_real_escape_string(strip_tags($country)), 'realpost' => $real_post, 'post_title' => $post_title), array('%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%s', '%s', '%d', '%s')); } }