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 --- --- /dev/null +++ b/.box @@ -1,1 +1,5 @@ +shared_writable_dirs: + - /labs/tiles + - /lib/staticmaplite/cache +php_extensions: [pgsql, pdo, pdo_pgsql, curl] --- a/css/local.css.php +++ b/css/local.css.php @@ -25,11 +25,11 @@ margin: 0 !important; } .ui-icon-navigation { - background-image: url('.$_REQUEST['labsPath'].'css/images/113-navigation.png); + background-image: url(images/113-navigation.png); background-position: 1px 0; } .ui-icon-beaker { - background-image: url('.$_REQUEST['labsPath'].'css/images/91-beaker-2.png); + background-image: url(images/91-beaker-2.png); background-position: 1px 0; } #footer { --- a/include/common-template.inc.php +++ b/include/common-template.inc.php @@ -23,44 +23,42 @@ $url.= "&guid=ON"; return str_replace("&", "&", $url); } - function include_header($pageTitle, $pageType, $opendiv = true, $geolocate = false, $datepicker = false) { -global $labsPath; + global $labsPath; echo ' -' . $pageTitle . ' - - '; +' . $pageTitle . ' - Canberra Bus Timetable + + + + '; if (isDebugServer()) { - echo ' - - - + - '; - } - else { - echo ' - - - '; - } - echo ' - - - - + + + + + + + - '; + '; echo ''; - -echo ''; - - + echo ''; + echo ''; if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPod') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) { echo ' @@ -149,28 +142,26 @@
Back

' . $pageTitle . '

- Home + Home
'; $overrides = getServiceOverride(); if ($overrides['service_id']) { - if ($overrides['service_id'] == "noservice") { - echo '
Buses are not running today due to industrial action/public holiday. See Buses are not running today due to industrial action/public holiday. See http://www.action.act.gov.au for details.
'; - } - else { - echo '
Buses are running on an altered timetable today due to industrial action/public holiday. See http://www.action.act.gov.au for details.
'; - } + } + else { + echo '
Buses are running on an altered timetable today due to industrial action/public holiday. See http://www.action.act.gov.au for details.
'; } } - + } } function include_footer() { - -global $labsPath; - echo '
"; -} -function timePlaceSettings($geolocate = false) + } + echo "\n"; +} +function placeSettings() { global $service_periods; $geoerror = false; - if ($geolocate == true) { $geoerror = !isset($_SESSION['lat']) || !isset($_SESSION['lat']) || $_SESSION['lat'] == "" || $_SESSION['lon'] == ""; - } + echo '
'; if ($geoerror) { echo 'Sorry, but your location could not currently be detected. @@ -202,27 +191,13 @@ } echo '
'; echo '
-

Change Time/Place (' . (isset($_SESSION['time']) ? $_SESSION['time'] : "Current Time,") . ' ' . ucwords(service_period()) . ')...

+

Change Location...

-
- - - Current Time? -
-
- - - -
--- 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/include/db/trip-dao.inc.php +++ b/include/db/trip-dao.inc.php @@ -173,6 +173,22 @@ $r = $query->fetch(PDO::FETCH_ASSOC); return $r['arrival_time']; } +function getTripEndTime($tripID) +{ + global $conn; + $query = "SELECT trip_id,max(arrival_time) as arrival_time from stop_times + WHERE stop_times.arrival_time IS NOT NULL and trip_id = :tripID group by trip_id"; + debug($query, "database"); + $query = $conn->prepare($query); + $query->bindParam(":tripID", $tripID); + $query->execute(); + if (!$query) { + databaseError($conn->errorInfo()); + return Array(); + } + $r = $query->fetch(PDO::FETCH_ASSOC); + return $r['arrival_time']; +} function getActiveTrips($time) { global $conn; --- a/index.php +++ b/index.php @@ -24,7 +24,6 @@
  • Nearby Routes
  • Busness R&D'; include_footer(true) ?> --- /dev/null +++ b/js/LAB.min.js @@ -1,1 +1,5 @@ - +/*! LAB.js (LABjs :: Loading And Blocking JavaScript) + v2.0.1 (c) Kyle Simpson + MIT License +*/ +(function(o){var K=o.$LAB,y="UseLocalXHR",z="AlwaysPreserveOrder",u="AllowDuplicates",A="CacheBust",B="BasePath",C=/^[^?#]*\//.exec(location.href)[0],D=/^\w+\:\/\/\/?[^\/]+/.exec(C)[0],i=document.head||document.getElementsByTagName("head"),L=(o.opera&&Object.prototype.toString.call(o.opera)=="[object Opera]")||("MozAppearance"in document.documentElement.style),q=document.createElement("script"),E=typeof q.preload=="boolean",r=E||(q.readyState&&q.readyState=="uninitialized"),F=!r&&q.async===true,M=!r&&!F&&!L;function G(a){return Object.prototype.toString.call(a)=="[object Function]"}function H(a){return Object.prototype.toString.call(a)=="[object Array]"}function N(a,c){var b=/^\w+\:\/\//;if(/^\/\/\/?/.test(a)){a=location.protocol+a}else if(!b.test(a)&&a.charAt(0)!="/"){a=(c||"")+a}return b.test(a)?a:((a.charAt(0)=="/"?D:C)+a)}function s(a,c){for(var b in a){if(a.hasOwnProperty(b)){c[b]=a[b]}}return c}function O(a){var c=false;for(var b=0;b0){for(var a=0;a=0;){d=n.shift();a=a[d.type].apply(null,d.args)}return a},noConflict:function(){o.$LAB=K;return m},sandbox:function(){return J()}};return m}o.$LAB=J();(function(a,c,b){if(document.readyState==null&&document[a]){document.readyState="loading";document[a](c,b=function(){document.removeEventListener(c,b,false);document.readyState="complete"},false)}})("addEventListener","DOMContentLoaded")})(this); --- 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_freqdist.php +++ b/labs/myway_timeliness_freqdist.php @@ -38,41 +38,8 @@ grid: { hoverable: true, clickable: true, labelMargin: 17 }, }); - /* var o; - o = plot.pointOffset({ x: midnight+ (9*60*60*1000), y: -1.2}); - placeholder.append('
    9am
    '); - o = plot.pointOffset({ x: midnight+ (16*60*60*1000), y: -1.2}); - placeholder.append('
    4pm
    '); - */ + }); - /* - var previousPoint = null; - $("#placeholder").bind("plothover", function (event, pos, item) { - $("#x").text(pos.x.toFixed(2)); - $("#y").text(pos.y.toFixed(2)); - if (item) { - if (previousPoint != item.dataIndex) { - previousPoint = item.dataIndex; - - $("#tooltip").remove(); - var x = item.datapoint[0].toFixed(2), - y = item.datapoint[1].toFixed(2); - - var d = new Date(); -d.setTime(x); -var time = d.getUTCHours() +':'+ (d.getUTCMinutes().toString().length == 1 ? '0'+ d.getMinutes(): d.getUTCMinutes()) - - - showTooltip(item.pageX, item.pageY, - item.series.label + " at "+ time +" = " + Math.abs(new Number(y/60).toFixed(2))+" minutes "+(y >0 ? "early":"late")); - } - } - else { - $("#tooltip").remove(); - previousPoint = null; - } - }); - */ --- /dev/null +++ b/labs/myway_timeliness_overview.php @@ -1,1 +1,97 @@ + + + + +prepare($query); +$query->execute(); +if (!$query) { + databaseError($conn->errorInfo()); + return Array(); +} +foreach ($query->fetchAll() as $row) { + echo ""; +}; +?> + + +prepare($query); +$query->execute(); +if (!$query) { + databaseError($conn->errorInfo()); + return Array(); +} +foreach ($query->fetchAll() as $row) { + echo ""; +}; +?> + + +prepare($query); +$query->execute(); +if (!$query) { + databaseError($conn->errorInfo()); + return Array(); +} +foreach ($query->fetchAll() as $row) { + echo ""; +}; +?> + +prepare($query); +$query->execute(); +if (!$query) { + databaseError($conn->errorInfo()); + return Array(); +} +foreach ($query->fetchAll() as $row) { + echo ""; +}; +?> + + + 1 order by myway_stop"; +$query = $conn->prepare($query); +$query->execute(); +if (!$query) { + databaseError($conn->errorInfo()); + return Array(); +} +foreach ($query->fetchAll() as $row) { + echo ""; +}; +?> + + 1 order by route_full_name"; +$query = $conn->prepare($query); +$query->execute(); +if (!$query) { + databaseError($conn->errorInfo()); + return Array(); +} +foreach ($query->fetchAll() as $row) { + echo ""; +}; +?> + + +
    MeanStandard
    Deviation
    Sample Size
    Overall
    {$row[0]}" . floor($row[1]) . "" . floor($row[2]) . "{$row[3]}
    Hour of Day
    {$row[0]}" . floor($row[1]) . "" . floor($row[2]) . "{$row[3]}
    Day of Week
    {$row[0]}" . floor($row[1]) . "" . floor($row[2]) . "{$row[3]}
    Month
    {$row[0]}" . floor($row[1]) . "" . floor($row[2]) . "{$row[3]}
    Stop
    {$row[0]}" . floor($row[1]) . "" . floor($row[2]) . "{$row[3]}
    Route
    {$row[0]}" . floor($row[1]) . "" . floor($row[2]) . "{$row[3]}
    + + + --- 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 @@ }); + --- a/labs/mywaybalance.php +++ b/labs/mywaybalance.php @@ -113,6 +113,10 @@
    +
    + + +
    '; } include_footer(); --- /dev/null +++ b/labs/travelAllRoutes.php @@ -1,1 +1,23 @@ +prepare($query); + $query->execute(); +echo ""; +$total = 0; +$count = 0; +foreach($query->fetchAll() as $r) { + $trips = getRouteTrips($r['route_id']); + $startTime = $trips[0]['arrival_time']; + $endTime = getTripEndTime($trips[0]['trip_id']); + $timeDiff = strtotime($endTime) - strtotime($startTime); + $total += $timeDiff; + $count ++; + echo ""; +} +echo "
    Route NumberFirst Trip StartFirst Trip EndLength
    {$r['route_short_name']}$startTime$endTime$timeDiff seconds ie. ". ($timeDiff/60). " minutes
    "; +echo "Total time: $total seconds ie. " .($total/60/60). " hours
    "; +echo "$count Routes"; +?> --- a/routeList.php +++ b/routeList.php @@ -44,7 +44,7 @@ include_header("Routes Nearby", "routeList", true, true); trackEvent("Route Lists", "Routes Nearby", $_SESSION['lat'] . "," . $_SESSION['lon']); navbar(); - timePlaceSettings(true); + placeSettings(); if (!isset($_SESSION['lat']) || !isset($_SESSION['lat']) || $_SESSION['lat'] == "" || $_SESSION['lon'] == "") { include_footer(); die(); --- a/sitemap.xml.php +++ b/sitemap.xml.php @@ -3,10 +3,13 @@ $last_updated = date('Y-m-d',@filemtime('cbrfeed.zip')); header("Content-Type: text/xml"); echo ""; - echo '' . "\n"; + echo '' . "\n"; echo " ".curPageURL()."index.php1.0\n"; foreach (scandir("./") as $file) { if (strpos($file,".php") !== false && $file != "index.php" && $file != "sitemap.xml.php") echo " ".curPageURL()."$file0.3\n"; +} +foreach (scandir("./labs") as $file) { + if (strpos($file,".php") !== false) echo " ".curPageURL()."/labs/$file0.3\n"; } foreach (getStops() as $stop) { echo " ".curPageURL()."stop.php?stopid=".htmlspecialchars ($stop["stop_id"]).""; --- a/stop.php +++ b/stop.php @@ -61,6 +61,7 @@ } } include_header($stop['stop_name'], "stop"); + /*$serviceAlerts = json_decode(getPage(curPageURL() . "/servicealerts_api.php?filter_class=stop&filter_id=".$stopid) , true); foreach($serviceAlerts['entities'] as $serviceAlert) { @@ -82,7 +83,31 @@ ) )) ; } -timePlaceSettings(); + +// time settings +echo '
    +

    Change Time (' . (isset($_SESSION['time']) ? $_SESSION['time'] : "Current Time,") . ' ' . ucwords(service_period()) . ')...

    +
    +
    +
    + + + Current Time? +
    +
    + + + +
    + + +
    +
    '; + echo ''; echo '
      '; if (sizeof($allStopsTrips) > 0) { --- a/stopList.php +++ b/stopList.php @@ -40,7 +40,6 @@ $stops = getStops(); include_header("All Stops", "stopList"); navbar(); - timePlaceSettings(); } else if (isset($nearby)) { $listType = 'nearby=yes'; @@ -48,7 +47,7 @@ trackEvent("Stop Lists", "Stops Nearby", $_SESSION['lat'] . "," . $_SESSION['lon']); navbar(); if (!isset($_SESSION['lat']) || !isset($_SESSION['lat']) || $_SESSION['lat'] == "" || $_SESSION['lon'] == "") { - timePlaceSettings(true); + placeSettings(); include_footer(); die(); } @@ -65,7 +64,7 @@ ); } echo staticmap($stopPositions, 0, "iconb", true, true); - timePlaceSettings(true); + placeSettings(); echo ''; } else if (isset($suburb)) { @@ -78,7 +77,6 @@ $stops = getStops(true, $firstLetter); include_header("Timing Points / Major Stops", "stopList"); navbar(); - timePlaceSettings(); } echo '
        '; if (!isset($firstLetter) && !isset($suburb) && !isset($nearby)) { --- a/updatedb.php +++ b/updatedb.php @@ -1,4 +1,5 @@