if (!defined("_GNUBOARD_")) exit; // Cookie存儲在您的計算機的IP , IP是不同的表 if (get_cookie('ck_visit_ip') != $_SERVER['REMOTE_ADDR']) { set_cookie('ck_visit_ip', $_SERVER['REMOTE_ADDR'], 86400); $tmp_row = sql_fetch(" select max(vi_id) as max_vi_id from $g4[visit_table] "); $vi_id = $tmp_row[max_vi_id] + 1; // $_SERVER 遠端變量 SQL Injection 防止竄改. 110810 $remote_addr = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); $referer = mysql_real_escape_string($_SERVER['HTTP_REFERER']); $user_agent = mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']); $sql = " insert $g4[visit_table] ( vi_id, vi_ip, vi_date, vi_time, vi_referer, vi_agent ) values ( '$vi_id', '$remote_addr', '$g4[time_ymd]', '$g4[time_his]', '$referer', '$user_agent' ) "; //$sql = " insert $g4[visit_table] ( vi_id, vi_ip, vi_date, vi_time, vi_referer, vi_agent ) values ( '$vi_id', '$_SERVER[REMOTE_ADDR]', '$g4[time_ymd]', '$g4[time_his]', '$_SERVER[HTTP_REFERER]', '$_SERVER[HTTP_USER_AGENT]' ) "; $result = sql_query($sql, FALSE); if ($result) { $sql = " insert $g4[visit_sum_table] ( vs_count, vs_date) values ( 1, '$g4[time_ymd]' ) "; $result = sql_query($sql, FALSE); if (!$result) { $sql = " update $g4[visit_sum_table] set vs_count = vs_count + 1 where vs_date = '$g4[time_ymd]' "; $result = sql_query($sql); } $sql = " select vs_count as cnt from $g4[visit_sum_table] where vs_date = '$g4[time_ymd]' "; $row = sql_fetch($sql); $vi_today = $row[cnt]; // 昨天 $sql = " select vs_count as cnt from $g4[visit_sum_table] where vs_date = DATE_SUB('$g4[time_ymd]', INTERVAL 1 DAY) "; $row = sql_fetch($sql); $vi_yesterday = $row[cnt]; // 最高 $sql = " select max(vs_count) as cnt from $g4[visit_sum_table] "; $row = sql_fetch($sql); $vi_max = $row[cnt]; // 滿的 //$sql = " select count(*) as cnt from $g4[visit_table] "; $sql = " select sum(vs_count) as total from $g4[visit_sum_table] "; $row = sql_fetch($sql); $vi_sum = $row[total]; $visit = "今日:$vi_today,昨日:$vi_yesterday,最高:$vi_max,全部:$vi_sum"; //默認設置供遊人寫下表 //遊客到表沒有讀輸出。 //查詢,相當一部分數量的減少的 sql_query(" update $g4[config_table] set cf_visit = '$visit' "); } } ?> //$config[title]語言 $ifenglish=0; ?>