From: Maxious Date: Sun, 04 Sep 2011 15:32:27 +0000 Subject: Try to avoid bots in analytics and improve page titles X-Git-Url: http://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=e1bdff3ead7371e46f0fd527ad0af3f82433aa99 --- Try to avoid bots in analytics and improve page titles --- --- a/include/common-template.inc.php +++ b/include/common-template.inc.php @@ -32,7 +32,7 @@ -' . $pageTitle . ' +' . $pageTitle . ' - Canberra Bus Timetable --- a/include/common.inc.php +++ b/include/common.inc.php @@ -31,7 +31,8 @@ function isDebugServer() { - return !isset($_SERVER['SERVER_NAME']) || $_SERVER['SERVER_NAME'] == "10.0.1.154" || $_SERVER['SERVER_NAME'] == "10.1.0.4" || $_SERVER['SERVER_NAME'] == "localhost" || $_SERVER['SERVER_NAME'] == "127.0.0.1" ; + return isset($_SERVER['SERVER_NAME']) && ( $_SERVER['SERVER_NAME'] == "10.0.1.154" || $_SERVER['SERVER_NAME'] == "10.1.0.4" || $_SERVER['SERVER_NAME'] == +"localhost" || $_SERVER['SERVER_NAME'] == "127.0.0.1") ; } include_once ("common-geo.inc.php"); @@ -46,7 +47,9 @@ function isAnalyticsOn() { - return !isDebugServer(); + $user_agent = $_SERVER['HTTP_USER_AGENT']; + return !isDebugServer() && !preg_match('/cloudkick/i', $user_agent) && !preg_match('/googlebot/i', $user_agent) && +!preg_match('/baidu/i', $user_agent); } function isDebug($debugReason = "other") { --- a/labs/myway_timeliness_calculate.php +++ b/labs/myway_timeliness_calculate.php @@ -1,6 +1,8 @@ "; var_dump($stopRoutes); + flush(); + } } // lowest delta is recorded delta @@ -119,7 +125,7 @@ $stmt->bindParam(':route_full_name', $route_full_name); $stmt->bindParam(':stop_code', $stop_code); $stmt->bindParam(':timing_delta', $lowestDelta); - $stmt->bindParam(':time', $time); + $stmt->bindParam(':time', $time_tz); $stmt->bindParam(':date', $date); $stmt->bindParam(':timing_period', $timing_period); $stmt->bindParam(':stop_sequence', $stop_sequence); @@ -129,6 +135,7 @@ echo "Recorded.
"; } var_dump($conn->errorInfo()); + flush(); } flush(); } --- a/labs/myway_timeliness_route.php +++ b/labs/myway_timeliness_route.php @@ -34,6 +34,10 @@ tickFormatter: yformatter }, grid: { hoverable: true, clickable: true, labelMargin: 32 }, +series: { + lines: { show: false }, + points: { show: true } + } }; var plot = $.plot(placeholder, data, options); @@ -118,3 +122,4 @@ }); + --- a/labs/myway_timeliness_stop.json.php +++ b/labs/myway_timeliness_stop.json.php @@ -29,3 +29,4 @@ else echo "[".implode(",",$points)."]"; ?> } + --- a/labs/myway_timeliness_stop.php +++ b/labs/myway_timeliness_stop.php @@ -40,6 +40,10 @@ tickFormatter: yformatter }, grid: { hoverable: true, clickable: true, labelMargin: 32 }, + series: { + lines: { show: false }, + points: { show: true } + } }; var plot = $.plot(placeholder, data, options); @@ -129,3 +133,4 @@ }); +