FIx unclosed script tags in analytics
--- a/feedback.php
+++ b/feedback.php
@@ -1,11 +1,11 @@
<?php
-include ('include/common.inc.php');
+include ("include/common.inc.php");
include_header("Feedback", "feedback");
function sendEmail($topic, $message)
{
$address = "maxious@lambdacomplex.org";
if (file_exists("/tmp/aws.php")) {
- include_once ('lib/ses.php');
+ include_once ("lib/ses.php");
include_once ("/tmp/aws.php");
$con = new SimpleEmailService($accessKey, $secretKey);
//$con->verifyEmailAddress($address);
@@ -24,16 +24,29 @@
mail($address, $topic, $message);
}
}
+
+$stopid = "";
+$stopcode = "";
+$urlparts = explode("?",$_SERVER["HTTP_REFERER"]);
+if (isset($urlparts[1])) {
+ $getparams = explode("&",$urlparts[1]);
+ foreach ($getparams as $param) {
+ $paramparts=explode("=",$param);
+ if ($paramparts[0] == "stopid") $stopid = $paramparts[1];
+ if ($paramparts[0] == "stopcode") $stopcode = $paramparts[1];
+ }
+}
+
?>
<h3>Add/Move/Delete a Bus Stop Location</h3>
-StopID:
-or StopCode:
-<small> if you click on feedback from a stop page, these will get filled in automatically. else describe the location/street of the stop <input type="text" name="stoplocation" /> </small>
+StopID: <input type="text" name="stopid" value="<?php echo $stopid ?>"/><br>
+or StopCode: <input type="text" name="stopcode" value="<?php echo $stopcode ?>"/><br>
+<small> if you click on feedback from a stop page, these will get filled in automatically. else describe the location/street of the stop in one of these boxes </small><br>
-Suggested Stop Location (lat/long or words):
-<small> if your device supports javascript, you can pick a location from the map above</small>
+Suggested Stop Location (lat/long or words): <input type="text" name="newlocation"/><br>
+<small> if your device supports javascript, you can pick a location from the map above</small><br>
-Submit!
+<input type="submit" value="Submit!"/>
<h3>Bug Report/Feedback</h3>
Please leave feedback about bugs/errors or general suggestions about improvements that could be made to the way the data is presented!
@@ -41,14 +54,15 @@
</textarea>
<textarea id="extrainfo">
<?php
- echo ' Referrer URL
- User Agent
- User host/IP
- Server host/IP
- Current date/time
- Dump of $_SESSION ';
+ echo "Referrer URL: ".$_SERVER["HTTP_REFERER"];
+ echo "\nUser Agent: ".$_SERVER["HTTP_USER_AGENT"];
+ echo "\nUser host/IP: ".$_SERVER["HTTP_X_FORWARDED_FOR"]." ".$_SERVER["REMOTE_ADDR"];
+ echo "\nServer host/IP: ".php_uname("n");
+ echo "\nCurrent date/time: ". date("c");
+ echo "\nDump of session: ".print_r($_SESSION,true);
?>
</textarea>
-Submit!
+<input type="submit" value="Submit!"/>
+
--- a/include/common-template.inc.php
+++ b/include/common-template.inc.php
@@ -36,9 +36,17 @@
if ($datepicker) echo '<link rel="stylesheet" href="css/jquery.ui.datepicker.mobile.css" />';
if (isDebugServer()) echo '<link rel="stylesheet" href="css/jquery-mobile-1.0a3.css" />
<script type="text/javascript" src="js/jquery-1.5.js"></script>
+ <script>$(document).bind("mobileinit", function(){
+ $.mobile.ajaxEnabled = false;
+});
+</script>
<script type="text/javascript" src="js/jquery-mobile-1.0a3.js"></script>';
else echo '<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
+ <script>$(document).bind("mobileinit", function(){
+ $.mobile.ajaxEnabled = false;
+});
+</script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>';
if ($datepicker) echo '<script>
//reset type=date inputs to text
@@ -81,6 +89,10 @@
.min-width-480px .viaPoints {
display: block;
}
+ #extrainfo {
+ visibility: hidden;
+ display: none;
+ }
// source http://webaim.org/techniques/skipnav/
#skip a, #skip a:hover, #skip a:visited
{
@@ -110,14 +122,14 @@
function success(position) {
$('#geolocate').val(position.coords.latitude+','+position.coords.longitude);
-$.ajax({ url: \"common.inc.php?geolocate=yes&lat=\"+position.coords.latitude+\"&lon=\"+position.coords.longitude });
-$('#here').click(function(event) { $('#geolocate').val(doAJAXrequestForGeolocSessionHere()); return false;});
-$('#here').show();
+$.ajax({ url: \"include/common.inc.php?geolocate=yes&lat=\"+position.coords.latitude+\"&lon=\"+position.coords.longitude });
+location.reload(true);
}
function error(msg) {
console.log(msg);
}
+function geolocate() {
if (navigator.geolocation) {
var options = {
enableHighAccuracy: false,
@@ -126,8 +138,14 @@
}
navigator.geolocation.getCurrentPosition(success, error, options);
}
-
-</script> ";
+}
+$(document).ready(function() {
+ $('#here').click(function(event) { $('#geolocate').val(geolocate()); return false;});
+$('#here').show();
+});
+";
+if (!isset($_SESSION['lat']) || $_SESSION['lat'] == "") echo "geolocate();";
+echo "</script> ";
}
if (isAnalyticsOn()) echo '
<script type="text/javascript">'."
@@ -159,12 +177,6 @@
}
function include_footer()
{
- if ($geolocate && isset($_SESSION['lat'])) {
- echo "<script>
- $('#here').click(function(event) { $('#geolocate').val(doAJAXrequestForGeolocSessionHere()); return false;});
-$('#here').show();
-</script>";
- }
echo '<div id="footer"><a href="about.php">About/Contact Us</a> <a href="feedback.php">Feedback/Bug Report</a></a>';
echo '</div>';
if (isAnalyticsOn()) {
@@ -175,9 +187,9 @@
'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
- })();";
+ })();</script>";
$googleAnalyticsImageUrl = googleAnalyticsGetImageUrl();
- echo '<img src="' . $googleAnalyticsImageUrl . '" />';
+ echo '<noscript><img src="' . $googleAnalyticsImageUrl . '" /></noscript>';
}
}
function timePlaceSettings($geolocate = false)
@@ -194,7 +206,7 @@
}
echo '<div data-role="collapsible" data-collapsed="' . !$geoerror . '">
<h3>Change Time/Place (' . (isset($_SESSION['time']) ? $_SESSION['time'] : "Current Time,") . ' ' . ucwords(service_period()) . ')...</h3>
- <form action="'.basename($_SERVER['PHP_SELF']).'" method="post">
+ <form action="'.basename($_SERVER['PHP_SELF'])."?".$_SERVER['QUERY_STRING'].'" method="post">
<div class="ui-body">
<div data-role="fieldcontain">
<label for="geolocate"> Current Location: </label>
@@ -202,7 +214,8 @@
</div>
<div data-role="fieldcontain">
<label for="time"> Time: </label>
- <input type="time" name="time" id="time" value="' . (isset($_SESSION['time']) ? $_SESSION['time'] : date("H:i")) . '"/> <a href="#" name="currentTime" id="currentTime">Current Time?</a>
+ <input type="time" name="time" id="time" value="' . (isset($_SESSION['time']) ? $_SESSION['time'] : date("H:i")) . '"/>
+ <a href="#" name="currentTime" id="currentTime" onClick="var d = new Date();'. "$('#time').val(d.getHours() +':'+ d.getMinutes());".'">Current Time?</a>
</div>
<div data-role="fieldcontain">
<label for="service_period"> Service Period: </label>
@@ -220,7 +233,7 @@
}
function trackEvent($category, $action, $label = "", $value = -1) {
if (isAnalyticsOn()) {
- echo "<script> _gaq.push(['_trackEvent', $category, $action".($label != "" ? ", $label" : "").($value != -1 ? ", $value" : "")."]);";
+ echo "<script> _gaq.push(['_trackEvent', $category, $action".($label != "" ? ", $label" : "").($value != -1 ? ", $value" : "")."]);</script>";
}
}
?>
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -59,7 +59,7 @@
}
}
}
- if ($_SESSION['lat'] != "" && isMetricsOn()) {
+ if ($_SESSION['lat'] != "" && isAnalyticsOn()) {
trackEvent("Geolocation","Updated Location", "Geocoded - ".($geocoded ? "Yes" : "No"));
}
}
--- a/index.php
+++ b/index.php
@@ -1,6 +1,6 @@
<?php
include ('include/common.inc.php');
-include_header("bus.lambdacomplex.org", "index", false, true)
+include_header("bus.lambdacomplex.org", "index", false)
?>
<div data-role="page">
<div data-role="content">
@@ -12,7 +12,7 @@
<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b">
<li data-role="list-divider">Timetables - Stops</li>
<li><a href="stopList.php">Major (Timing Point) Stops</a></li>
- <li><a href="stopList.php">All Stops</a></li>
+ <li><a href="stopList.php?allstops=yes">All Stops</a></li>
<li><a href="stopList.php?suburbs=yes">Stops By Suburb</a></li>
<li><a class="nearby" href="stopList.php?nearby=yes">Nearby Stops</a></li>
</ul>
--- a/routeList.php
+++ b/routeList.php
@@ -37,11 +37,15 @@
$url = $APIurl . "/json/stopzonesearch?q=" . $suburb;
include_header("Routes by Suburb", "routeList");
trackEvent("Route Lists","Routes By Suburb", $suburb);
-
}
if ($_REQUEST['nearby']) {
$url = $APIurl . "/json/neareststops?lat={$_SESSION['lat']}&lon={$_SESSION['lon']}&limit=15";
- include_header("Routes Nearby", "routeList");
+ include_header("Routes Nearby", "routeList", true, true);
+ timePlaceSettings(true);
+ if (!isset($_SESSION['lat']) || !isset($_SESSION['lat']) || $_SESSION['lat'] == "" || $_SESSION['lon'] == "") {
+ include_footer();
+ die();
+ }
}
$stops = json_decode(getPage($url));
$routes = Array();
--- a/stopList.php
+++ b/stopList.php
@@ -48,7 +48,7 @@
else if ($_REQUEST['nearby']) {
$listType = 'nearby=yes';
$url = $APIurl . "/json/neareststops?lat={$_SESSION['lat']}&lon={$_SESSION['lon']}&limit=15";
- include_header("Nearby Stops", "stopList");
+ include_header("Nearby Stops", "stopList", true, true);
navbar();
timePlaceSettings(true);
if (!isset($_SESSION['lat']) || !isset($_SESSION['lat']) || $_SESSION['lat'] == "" || $_SESSION['lon'] == "") {