function iri_StatPress_Vars($body) { global $wpdb; $table_name = $wpdb->prefix . "statpress"; $normallimit = " and (statuscode!='404' or statuscode is null)"; $today = gmdate('Ymd', current_time('timestamp')); $yesterday = gmdate('Ymd', current_time('timestamp') - 86400); //今天来访者数量 if (strpos(strtolower($body), "%visits%") !== FALSE) { $qry = $wpdb->get_results("SELECT count(DISTINCT(ip)) as pageview FROM {$table_name} WHERE date = {$today} and spider='' and feed=''{$normallimit};"); $body = str_replace("%visits%", $qry[0]->pageview, $body); } //昨天来访者数量 if (strpos(strtolower($body), "%yesterdayvisits%") !== FALSE) { $body = str_replace("%yesterdayvisits%", get_option("statpress_archive_yesterday_visitors"), $body); } //来访者数量总计 if (strpos(strtolower($body), "%totalvisits%") !== FALSE) { $qry = $wpdb->get_results("SELECT count(DISTINCT(ip)) as pageview FROM {$table_name} WHERE spider='' and feed=''{$normallimit};"); $body = str_replace("%totalvisits%", $qry[0]->pageview, $body); } //今天页面访问数量 if (strpos(strtolower($body), "%pagevisits%") !== FALSE) { $qry = $wpdb->get_results("SELECT count(*) as pageview FROM {$table_name} WHERE spider='' and feed='' and date={$today}{$normallimit};"); $body = str_replace("%pagevisits%", $qry[0]->pageview, $body); } //昨天页面访问数量总计 if (strpos(strtolower($body), "%yesterdaypagevisits%") !== FALSE) { $qry = $wpdb->get_results("SELECT count(*) as pageview FROM {$table_name} WHERE spider='' and feed='' and date = {$yesterday}{$normallimit};"); $body = str_replace("%yesterdaypagevisits%", get_option("statpress_archive_yesterday_pageviews"), $body); } //页面访问数量总计 if (strpos(strtolower($body), "%totalpagevisits%") !== FALSE) { $qry = $wpdb->get_results("SELECT count(*) as pageview FROM {$table_name} WHERE spider='' and feed=''{$normallimit};"); $body = str_replace("%totalpagevisits%", $qry[0]->pageview, $body); } //当前页面被访问次数 if (strpos(strtolower($body), "%thistotalvisits%") !== FALSE) { $qry = $wpdb->get_results("SELECT count(*) as pageview FROM {$table_name} WHERE spider='' and feed='' AND urlrequested='" . iri_StatPress_URL() . "'{$normallimit};"); $body = str_replace("%thistotalvisits%", $qry[0]->pageview, $body); } //统计起始日期 if (strpos(strtolower($body), "%since%") !== FALSE) { $body = str_replace("%since%", get_option("statpress_date_first_sets"), $body); } //操作系统(当前访问者) if (strpos(strtolower($body), "%os%") !== FALSE) { $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $os = iriGetOS($userAgent); $body = str_replace("%os%", $os, $body); } //浏览器(当前访问者) if (strpos(strtolower($body), "%browser%") !== FALSE) { $browser = iriGetBrowser($userAgent); $body = str_replace("%browser%", $browser, $body); } //IP地址(当前访问者) if (strpos(strtolower($body), "%ip%") !== FALSE) { $ipAddress = $_SERVER['REMOTE_ADDR']; $body = str_replace("%ip%", $ipAddress, $body); } //FROM何地(当前访问者) if (strpos(strtolower($body), "%comefrom%") !== FALSE) { $comeFrom = iriDomain($_SERVER['REMOTE_ADDR']); $body = str_replace("%comefrom%", $comeFrom, $body); } //%pagesyouvisited% //if(strpos(strtolower($body),"%pagesyouvisited%") !== FALSE) { // $pagesyouvisited = $_SESSION['views']; // $body = str_replace("%pagesyouvisited%", $pagesyouvisited, $body); //} //最近一段时间(10分钟内)的访问者数量,类似于在线人数 if (strpos(strtolower($body), "%visitorsonline%") !== FALSE) { $to_time = current_time('timestamp'); $from_time = strtotime('-10 minutes', $to_time); $qry = $wpdb->get_results("SELECT count(DISTINCT(ip)) as visitors FROM {$table_name} WHERE spider='' and feed='' AND timestamp BETWEEN {$from_time} AND {$to_time}{$normallimit};"); $body = str_replace("%visitorsonline%", $qry[0]->visitors, $body); } //最近一段时间(10分钟内)的用户数量,这里用户指的登记在册的内容贡献者或订阅者 if (strpos(strtolower($body), "%usersonline%") !== FALSE) { $to_time = current_time('timestamp'); $from_time = strtotime('-10 minutes', $to_time); $qry = $wpdb->get_results("SELECT count(DISTINCT(ip)) as users FROM {$table_name} WHERE spider='' and feed='' AND user!='' AND timestamp BETWEEN {$from_time} AND {$to_time}{$normallimit};"); $body = str_replace("%usersonline%", $qry[0]->users, $body); } //访问最多的帖子 if (strpos(strtolower($body), "%toppost%") !== FALSE) { $qry = $wpdb->get_results("SELECT urlrequested,count(*) as totale FROM {$table_name} WHERE spider='' AND feed='' and pvalue !='' and pvalue !=0{$normallimit} GROUP BY pvalue ORDER BY totale DESC LIMIT 1;"); $body = str_replace("%toppost%", iri_StatPress_Decode($qry[0]->urlrequested), $body); } //使用最多的浏览器 if (strpos(strtolower($body), "%topbrowser%") !== FALSE) { $qry = $wpdb->get_results("SELECT browser,count(*) as totale FROM {$table_name} WHERE spider='' AND feed=''{$normallimit} GROUP BY browser ORDER BY totale DESC LIMIT 1;"); $body = str_replace("%topbrowser%", iri_StatPress_Decode($qry[0]->browser), $body); } //使用最多的操作系统 if (strpos(strtolower($body), "%topos%") !== FALSE) { $qry = $wpdb->get_results("SELECT os,count(*) as totale FROM {$table_name} WHERE spider='' AND feed=''{$normallimit} GROUP BY os ORDER BY totale DESC LIMIT 1;"); $body = str_replace("%topos%", iri_StatPress_Decode($qry[0]->os), $body); } //订阅数 if (strpos(strtolower($body), "%feeds%") !== FALSE) { $body = str_replace("%feeds%", iri_StatPress_FeedCount(), $body); } //blog文章总数,add by 蚊子 if (strpos(strtolower($body), "%blogtotalpost%") !== FALSE) { $qry = $wpdb->get_results("SELECT count(ID) as pageview FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post';"); $body = str_replace("%blogtotalpost%", $qry[0]->pageview, $body); } //blog页面总数 if (strpos(strtolower($body), "%blogtotalpage%") !== FALSE) { $qry = $wpdb->get_results("SELECT count(ID) as pageview FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'page';"); $body = str_replace("%blogtotalpage%", $qry[0]->pageview, $body); } //留言者总数 if (strpos(strtolower($body), "%blogtotalcommentor%") !== FALSE) { $qry = $wpdb->get_results("SELECT count(distinct(comment_author)) as pageview FROM {$wpdb->comments} WHERE comment_approved = '1';"); $body = str_replace("%blogtotalcommentor%", $qry[0]->pageview, $body); } //留言总数 if (strpos(strtolower($body), "%blogtotalcomment%") !== FALSE) { $qry = $wpdb->get_results("SELECT count(*) as pageview FROM {$wpdb->comments} WHERE comment_approved = '1';"); $body = str_replace("%blogtotalcomment%", $qry[0]->pageview, $body); } return $body; }
function iri_StatPress_Vars($body) { global $wpdb; $table_name = $wpdb->prefix . "statpress"; if (strpos(strtolower($body), "%visits%") !== false) { $qry = $wpdb->get_results("SELECT count(DISTINCT(ip)) as pageview FROM {$table_name} WHERE date = '" . gmdate("Ymd", current_time('timestamp')) . "' and spider='' and feed='';"); $body = str_replace("%visits%", $qry[0]->pageview, $body); } if (strpos(strtolower($body), "%totalvisits%") !== false) { $qry = $wpdb->get_results("SELECT count(DISTINCT(ip)) as pageview FROM {$table_name} WHERE spider='' and feed='';"); $body = str_replace("%totalvisits%", $qry[0]->pageview, $body); } if (strpos(strtolower($body), "%thistotalvisits%") !== false) { $qry = $wpdb->get_results("SELECT count(DISTINCT(ip)) as pageview FROM {$table_name} WHERE spider='' and feed='' AND urlrequested='" . mysql_real_escape_string(iri_StatPress_URL()) . "';"); $body = str_replace("%thistotalvisits%", $qry[0]->pageview, $body); } if (strpos(strtolower($body), "%since%") !== false) { $qry = $wpdb->get_results("SELECT date FROM {$table_name} ORDER BY date LIMIT 1;"); $body = str_replace("%since%", irihdate($qry[0]->date), $body); } if (strpos(strtolower($body), "%os%") !== false) { $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $os = iriGetOS($userAgent); $body = str_replace("%os%", $os, $body); } if (strpos(strtolower($body), "%browser%") !== false) { $browser = iriGetBrowser($userAgent); $body = str_replace("%browser%", $browser, $body); } if (strpos(strtolower($body), "%ip%") !== false) { $ipAddress = $_SERVER['REMOTE_ADDR']; $body = str_replace("%ip%", $ipAddress, $body); } if (strpos(strtolower($body), "%visitorsonline%") !== false) { $to_time = current_time('timestamp'); $from_time = strtotime('-4 minutes', $to_time); $qry = $wpdb->get_results("SELECT count(DISTINCT(ip)) as visitors FROM {$table_name} WHERE spider='' and feed='' AND timestamp BETWEEN {$from_time} AND {$to_time};"); $body = str_replace("%visitorsonline%", $qry[0]->visitors, $body); } if (strpos(strtolower($body), "%usersonline%") !== false) { $to_time = current_time('timestamp'); $from_time = strtotime('-4 minutes', $to_time); $qry = $wpdb->get_results("SELECT count(DISTINCT(ip)) as users FROM {$table_name} WHERE spider='' and feed='' AND user<>'' AND timestamp BETWEEN {$from_time} AND {$to_time};"); $body = str_replace("%usersonline%", $qry[0]->users, $body); } if (strpos(strtolower($body), "%toppost%") !== false) { $qry = $wpdb->get_results("SELECT urlrequested,count(*) as totale FROM {$table_name} WHERE spider='' AND feed='' AND urlrequested LIKE '%p=%' GROUP BY urlrequested ORDER BY totale DESC LIMIT 1;"); $body = str_replace("%toppost%", iri_StatPress_Decode($qry[0]->urlrequested), $body); } if (strpos(strtolower($body), "%topbrowser%") !== false) { $qry = $wpdb->get_results("SELECT browser,count(*) as totale FROM {$table_name} WHERE spider='' AND feed='' GROUP BY browser ORDER BY totale DESC LIMIT 1;"); $body = str_replace("%topbrowser%", iri_StatPress_Decode($qry[0]->browser), $body); } if (strpos(strtolower($body), "%topos%") !== false) { $qry = $wpdb->get_results("SELECT os,count(*) as totale FROM {$table_name} WHERE spider='' AND feed='' GROUP BY os ORDER BY totale DESC LIMIT 1;"); $body = str_replace("%topos%", iri_StatPress_Decode($qry[0]->os), $body); } if (strpos(strtolower($body), "%pagestoday%") !== false) { $qry = $wpdb->get_results("SELECT count(ip) as pageview FROM {$table_name} WHERE date = '" . gmdate("Ymd", current_time('timestamp')) . "' and spider='' and feed='';"); $body = str_replace("%pagestoday%", $qry[0]->pageview, $body); } if (strpos(strtolower($body), "%thistotalpages%") !== FALSE) { $qry = $wpdb->get_results("SELECT count(ip) as pageview FROM {$table_name} WHERE spider='' and feed='';"); $body = str_replace("%thistotalpages%", $qry[0]->pageview, $body); } if (strpos(strtolower($body), "%latesthits%") !== false) { $qry = $wpdb->get_results("SELECT search FROM {$table_name} WHERE search <> '' ORDER BY id DESC LIMIT 10"); $body = str_replace("%latesthits%", $qry[0]->search, $body); for ($counter = 0; $counter < 10; $counter += 1) { $body .= "<br>" . $qry[$counter]->search; } } if (strpos(strtolower($body), "%pagesyesterday%") !== false) { $yesterday = gmdate('Ymd', current_time('timestamp') - 86400); $qry = $wpdb->get_row("SELECT count(DISTINCT ip) AS visitsyesterday FROM {$table_name} WHERE feed='' AND spider='' AND date = '" . mysql_real_escape_string($yesterday) . "'"); $body = str_replace("%pagesyesterday%", iri_StatPress_Decode($qry[0]->visitsyesterday), $body); } return $body; }
function iri_StatPress_Vars($body) { global $wpdb; $table_name = $wpdb->prefix . "statpress"; if (strpos(strtolower($body), "%visits%") !== FALSE) { $qry = $wpdb->get_results("SELECT count(DISTINCT(ip)) as pageview FROM {$table_name} WHERE date = '" . gmdate("Ymd", current_time('timestamp')) . "' and spider='' and feed='';"); $body = str_replace("%visits%", $qry[0]->pageview, $body); } if (strpos(strtolower($body), "%totalvisits%") !== FALSE) { $qry = $wpdb->get_results("SELECT count(DISTINCT(ip)) as pageview FROM {$table_name} WHERE spider='' and feed='';"); $body = str_replace("%totalvisits%", $qry[0]->pageview, $body); } if (strpos(strtolower($body), "%thistotalvisits%") !== FALSE) { $qry = $wpdb->get_results("SELECT count(DISTINCT(ip)) as pageview FROM {$table_name} WHERE spider='' and feed='' AND urlrequested='" . iri_StatPress_URL() . "';"); $body = str_replace("%thistotalvisits%", $qry[0]->pageview, $body); } if (strpos(strtolower($body), "%since%") !== FALSE) { $qry = $wpdb->get_results("SELECT date FROM {$table_name} ORDER BY date LIMIT 1;"); $body = str_replace("%since%", irihdate($qry[0]->date), $body); } if (strpos(strtolower($body), "%os%") !== FALSE) { $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $os = iriGetOS($userAgent); $body = str_replace("%os%", $os, $body); } if (strpos(strtolower($body), "%browser%") !== FALSE) { $browser = iriGetBrowser($userAgent); $body = str_replace("%browser%", $browser, $body); } if (strpos(strtolower($body), "%ip%") !== FALSE) { $ipAddress = $_SERVER['REMOTE_ADDR']; $body = str_replace("%ip%", $ipAddress, $body); } if (strpos(strtolower($body), "%visitorsonline%") !== FALSE) { $to_time = current_time('timestamp'); $from_time = strtotime('-4 minutes', $to_time); $qry = $wpdb->get_results("SELECT count(DISTINCT(ip)) as visitors FROM {$table_name} WHERE spider='' and feed='' AND timestamp BETWEEN {$from_time} AND {$to_time};"); $body = str_replace("%visitorsonline%", $qry[0]->visitors, $body); } if (strpos(strtolower($body), "%usersonline%") !== FALSE) { $to_time = current_time('timestamp'); $from_time = strtotime('-4 minutes', $to_time); $qry = $wpdb->get_results("SELECT count(DISTINCT(ip)) as users FROM {$table_name} WHERE spider='' and feed='' AND user<>'' AND timestamp BETWEEN {$from_time} AND {$to_time};"); $body = str_replace("%usersonline%", $qry[0]->users, $body); } if (strpos(strtolower($body), "%toppost%") !== FALSE) { $qry = $wpdb->get_results("SELECT urlrequested,count(*) as totale FROM wp_statpress WHERE spider='' AND feed='' AND urlrequested LIKE '%p=%' GROUP BY urlrequested ORDER BY totale DESC LIMIT 1;"); $body = str_replace("%toppost%", iri_StatPress_Decode($qry[0]->urlrequested), $body); } if (strpos(strtolower($body), "%topbrowser%") !== FALSE) { $qry = $wpdb->get_results("SELECT browser,count(*) as totale FROM wp_statpress WHERE spider='' AND feed='' GROUP BY browser ORDER BY totale DESC LIMIT 1;"); $body = str_replace("%topbrowser%", iri_StatPress_Decode($qry[0]->browser), $body); } if (strpos(strtolower($body), "%topos%") !== FALSE) { $qry = $wpdb->get_results("SELECT os,count(*) as totale FROM wp_statpress WHERE spider='' AND feed='' GROUP BY os ORDER BY totale DESC LIMIT 1;"); $body = str_replace("%topos%", iri_StatPress_Decode($qry[0]->os), $body); } return $body; }