From 8c590c9ab854193ef881d9e5290fb7a8e489940f Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sun, 29 May 2016 16:06:34 -0400 Subject: [PATCH 01/95] Make percentages consistently 2 digits after decimal. --- user/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/user/index.php b/user/index.php index 82755c00..4e8a3c25 100644 --- a/user/index.php +++ b/user/index.php @@ -143,6 +143,7 @@ function endsWith($haystack, $needle) $res = $db->query($sql_command); while ($row = $res->fetch_assoc()) { $percent = round($row['clinchedMileage'] / $row['totalMileage'] * 100.0, 2); + $percent = sprintf('%0.2f', $percent); echo "" . $row['country'] . "" . $row['name'] . "" . $row['clinchedMileage'] . "" . $row['totalMileage'] . "" . $percent . "%MapHB"; } $res->free(); From b4e406c18e4c5b0190018cd54d6d02e307419639 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Mon, 30 May 2016 10:36:07 -0400 Subject: [PATCH 02/95] Separate links on main index for logs and stats (which are now separate on the site). --- index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 008b5b87..bf6db347 100644 --- a/index.php +++ b/index.php @@ -31,8 +31,10 @@

Draft Highway Browser

Development Tools

From 0e4230ba5e2ff79b2a62a68c5d15f2b0c76b879b Mon Sep 17 00:00:00 2001 From: theFXexpert Date: Tue, 31 May 2016 10:23:29 -0400 Subject: [PATCH 03/95] Update GA credit links. --- credits.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/credits.php b/credits.php index 120ddee1..d80b4c03 100644 --- a/credits.php +++ b/credits.php @@ -442,8 +442,8 @@
  • Georgia, USA
  • Hawaii, USA From 2b888a3894c34216cb030fe4b56b1de188cd01f5 Mon Sep 17 00:00:00 2001 From: Eric Bryant Date: Tue, 31 May 2016 11:04:03 -0400 Subject: [PATCH 04/95] Update credits.php --- credits.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/credits.php b/credits.php index d80b4c03..dcd47847 100644 --- a/credits.php +++ b/credits.php @@ -103,10 +103,11 @@
  • List of Available Datasets. GIS shapefiles from GeoBase covering the Canadian provinces and territories.
  • - +
  • British Columbia, CAN
  • Nevada, USA @@ -570,6 +572,7 @@
  • North Carolina, USA @@ -695,8 +698,7 @@

    Project Contributors

      -
    • Eric Bryant (yakra)
      - The Maine Drag
    • +
    • Eric Bryant (yakra)
    • Dave Filpus (dfilpus)
      Filpus Roadgeek
    • Adam Froehlig (froggie)
      From e1846b768dbfce98c31386082873beb804332913 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Tue, 31 May 2016 23:36:53 -0400 Subject: [PATCH 05/95] Initial web updates to use consolidated DB. --- hbtest/mapview.php | 26 ++++++++++---------------- index.php | 2 -- login.php | 10 +--------- stat.php | 5 +---- user/region.php | 25 +++++++++++-------------- user/system.php | 10 +--------- 6 files changed, 24 insertions(+), 54 deletions(-) diff --git a/hbtest/mapview.php b/hbtest/mapview.php index a12357da..0d2d29bc 100644 --- a/hbtest/mapview.php +++ b/hbtest/mapview.php @@ -5,15 +5,7 @@ $_GET['u'] = $_COOKIE['lastuser']; } - $dbname = "TravelMapping"; - if (isset($_COOKIE['currentdb'])) { - $dbname = $_COOKIE['currentdb']; - } - - if (array_key_exists("db", $_GET)) { - $dbname = $_GET['db']; - setcookie("currentdb", $dbname, time() + (86400 * 30), "/"); - } + $dbname = "TravelMappingTest"; ?> - +
    • Connecticut, USA
      • Connecticut Roads. Hobbyist site by Scott Oglesby covering highways in Connecticut.
      • @@ -534,10 +545,11 @@
      • Missouri County Maps. Official county maps from the Missouri Department of Transportation.
    • - +
    • Nebraska, USA
    • - +
    • General
      • Road Numbering Systems. Hobbyist site about the various road numbering systems around the world.
      • From 98b4d147fee20bddf53960b69af5e3f2d9dc4514 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Thu, 2 Jun 2016 08:51:53 -0400 Subject: [PATCH 07/95] SD source update from user the_spui_ninja and link fix. --- credits.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/credits.php b/credits.php index faa08639..f2054074 100644 --- a/credits.php +++ b/credits.php @@ -643,7 +643,8 @@
      • South Dakota, USA
      • Tennessee, USA From 7b7f9f23aee1915d0446544ad878c76f2dc68dff Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Fri, 3 Jun 2016 00:55:07 -0400 Subject: [PATCH 08/95] Updates to use consolidated DB. --- user/index.php | 110 +++++++++++++++++++++++++++++++++--------------- user/region.php | 13 ------ 2 files changed, 76 insertions(+), 47 deletions(-) diff --git a/user/index.php b/user/index.php index 4e8a3c25..01c61433 100644 --- a/user/index.php +++ b/user/index.php @@ -6,8 +6,6 @@ A basic user stats page. URL Params: u - the user. - db - the database being used. Use 'TravelMappingDev' for in-development systems. - (u, [db]) --> @@ -40,22 +38,8 @@ = 0 && strpos($haystack, $needle, $temp) !== FALSE); - } - ?> @@ -89,19 +73,25 @@ function endsWith($haystack, $needle)

    Overall Stats

    - +
    + + + query($sql_command); $row = $res->fetch_assoc(); $res->free(); - echo "\n"; + echo ""; + echo ""; + echo ""; + echo ""; + + + //Second, fetch routes driven/clinched active only + $sql_command = "SELECT COUNT(cr.route) AS total FROM connectedRoutes AS cr LEFT JOIN systems ON cr.systemName = systems.systemName WHERE (systems.level = 'active');"; + echo ""; + $res = $db->query($sql_command); + $row = $res->fetch_assoc(); + $activeRoutes = $row['total']; + $res->free(); - //Second, fetch routes driven/clinched - $sql_command = "SELECT COUNT(cr.route) AS total, COUNT(ccr.route) AS driven, SUM(ccr.clinched) AS clinched, ROUND(COUNT(ccr.route) / COUNT(cr.route) * 100,2) AS drivenPercent, ROUND(SUM(ccr.clinched) / COUNT(cr.route) * 100,2) AS clinchedPercent FROM connectedRoutes AS cr LEFT JOIN clinchedConnectedRoutes AS ccr ON cr.firstRoot = ccr.route AND traveler = '" . $user . "';"; + $sql_command = "SELECT COUNT(ccr.route) AS driven, SUM(ccr.clinched) AS clinched, ROUND(COUNT(ccr.route) / ".$activeRoutes." * 100,2) AS drivenPercent, ROUND(SUM(ccr.clinched) / ".$activeRoutes." * 100,2) AS clinchedPercent FROM connectedRoutes AS cr LEFT JOIN clinchedConnectedRoutes AS ccr ON cr.firstRoot = ccr.route AND traveler = '" . $user . "' LEFT JOIN routes ON ccr.route = routes.root LEFT JOIN systems ON routes.systemName = systems.systemName WHERE systems.level = 'active';"; echo ""; $res = $db->query($sql_command); $row = $res->fetch_assoc(); - echo "\n"; - $res->free; + $activeDriven = $row['driven']; + $activeDrivenPct = $row['drivenPercent']; + $activeClinched = $row['clinched']; + $activeClinchedPct = $row['clinchedPercent']; + $res->free(); + + // and active+preview + $sql_command = "SELECT COUNT(cr.route) AS total FROM connectedRoutes AS cr LEFT JOIN systems ON cr.systemName = systems.systemName WHERE (systems.level = 'active' OR systems.level = 'preview');"; + echo ""; + $res = $db->query($sql_command); + $row = $res->fetch_assoc(); + $activePreviewRoutes = $row['total']; + $res->free(); + + $sql_command = "SELECT COUNT(ccr.route) AS driven, SUM(ccr.clinched) AS clinched, ROUND(COUNT(ccr.route) / ".$activeRoutes." * 100,2) AS drivenPercent, ROUND(SUM(ccr.clinched) / ".$activeRoutes." * 100,2) AS clinchedPercent FROM connectedRoutes AS cr LEFT JOIN clinchedConnectedRoutes AS ccr ON cr.firstRoot = ccr.route AND traveler = '" . $user . "' LEFT JOIN routes ON ccr.route = routes.root LEFT JOIN systems ON routes.systemName = systems.systemName WHERE (systems.level = 'active' OR systems.level = 'preview');"; + echo ""; + $res = $db->query($sql_command); + $row = $res->fetch_assoc(); + $activePreviewDriven = $row['driven']; + $activePreviewDrivenPct = $row['drivenPercent']; + $activePreviewClinched = $row['clinched']; + $activePreviewClinchedPct = $row['clinchedPercent']; + $res->free(); + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; ?>
    Active SystemsActive+Preview Systems
    OverallMiles Driven: " . $row['clinchedMileage'] . " mi (" . $row['percentage'] . "%)Total: " . $row['totalMileage'] . " mi
    Miles Driven" . $row['clinchedActiveMileage']; + echo "/" . $row['totalActiveMileage'] . " mi ("; + echo $row['activePercentage'] . "%)" . $row['clinchedActivePreviewMileage']; + echo "/" . $row['totalActivePreviewMileage'] . " mi ("; + echo $row['activePreviewPercentage'] . "%)
    RoutesDriven: " . $row['driven'] . " (" . $row['drivenPercent'] . "%)Clinched: " . $row['clinched'] . " (" . $row['clinchedPercent'] . "%)Total: " . $row['total'] . "
    Routes Driven".$activeDriven." of " . $activeRoutes . " (" . $activeDrivenPct . "%)".$activePreviewDriven." of " . $activePreviewRoutes . " (" . $activePreviewDrivenPct . "%)
    Routes Clinched".$activeClinched." of " . $activeRoutes . " (" . $activeClinchedPct . "%)".$activePreviewClinched." of " . $activePreviewRoutes . " (" . $activePreviewClinchedPct . "%)
    @@ -132,19 +169,24 @@ function endsWith($haystack, $needle) Region Clinched Mileage Overall Mileage - Percent Clinched + % Clinched + Clinched Mileage (incl preview) + Overall Mileage (incl preview) + % Clinched (incl preview) Map "; $res = $db->query($sql_command); while ($row = $res->fetch_assoc()) { - $percent = round($row['clinchedMileage'] / $row['totalMileage'] * 100.0, 2); - $percent = sprintf('%0.2f', $percent); - echo "" . $row['country'] . "" . $row['name'] . "" . $row['clinchedMileage'] . "" . $row['totalMileage'] . "" . $percent . "%MapHB"; + $activePercent = round($row['clinchedActiveMileage'] / $row['totalActiveMileage'] * 100.0, 2); + $activePercent = sprintf('%0.2f', $activePercent); + $activePreviewPercent = round($row['clinchedActivePreviewMileage'] / $row['totalActivePreviewMileage'] * 100.0, 2); + $activePreviewPercent = sprintf('%0.2f', $activePreviewPercent); + echo "" . $row['country'] . "" . $row['name'] . "" . sprintf('%0.2f', $row['clinchedActiveMileage']) . "" . sprintf('%0.2f', $row['totalActiveMileage']) . "" . $activePercent . "%" . sprintf('%0.2f', $row['clinchedActivePreviewMileage']) . "" . sprintf('%0.2f', $row['totalActivePreviewMileage']) . "" . $activePreviewPercent . "%MapHB"; } $res->free(); ?> @@ -167,7 +209,7 @@ function endsWith($haystack, $needle) "; $res = $db->query($sql_command); diff --git a/user/region.php b/user/region.php index 5e187864..a2e67166 100644 --- a/user/region.php +++ b/user/region.php @@ -98,19 +98,6 @@ echo ""; $regionInfo = mysql_fetch_array(mysql_query($sql_command)); - # functions from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php - function startsWith($haystack, $needle) - { - // search backwards starting from haystack length characters from the end - return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; - } - - function endsWith($haystack, $needle) - { - // search forward starting from end minus needle length characters - return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE); - } - function fetchWithRank($res, $rankBy) { global $user; From bc8e75baeef7c177185b726f28f0119d928c158e Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Fri, 3 Jun 2016 22:33:09 -0400 Subject: [PATCH 09/95] More DB consolidation conversion. --- user/index.php | 13 ++++++++----- user/system.php | 31 +++++++++++-------------------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/user/index.php b/user/index.php index 01c61433..911b34a0 100644 --- a/user/index.php +++ b/user/index.php @@ -162,17 +162,20 @@

    Stats by Region

    + + + - - + + + + + - - - diff --git a/user/system.php b/user/system.php index 1755949c..467ddbca 100644 --- a/user/system.php +++ b/user/system.php @@ -1,4 +1,5 @@ ERROR: 400 Missing user (u=) or system (sys=) params"; @@ -28,8 +30,7 @@ u - the user. sys - The system being viewed on this page rg - The region to study this system - db - the database being used. Use 'TravelMappingDev' for in-development systems. - (u, sys, [rg], [db]) + (u, sys, [rg]) --> @@ -88,20 +89,6 @@ echo ""; $systemInfo = mysql_fetch_array(mysql_query($sql_command)); - - # functions from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php - function startsWith($haystack, $needle) - { - // search backwards starting from haystack length characters from the end - return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; - } - - function endsWith($haystack, $needle) - { - // search forward starting from end minus needle length characters - return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE); - } - function fetchWithRank($res, $rankBy) { global $user; @@ -347,7 +334,7 @@ function waypointsFromSQL() { $res = mysql_query($sql_command); $row = fetchWithRank($res, 'percentage'); $link = "window.open('/hbtest/mapview.php?u=" . $user . "&sys=" . $system . "')"; - echo ""; + echo ""; //Second, fetch routes clinched/driven if (is_null($region)) { @@ -384,7 +371,7 @@ function waypointsFromSQL() { $row = fetchWithRank($res, 'clinched'); echo "\n"; + "\n"; ?>
    Active Systems OnlyActive+Preview Systems
    Country RegionClinched MileageOverall MileageClinched (mi)Overall (mi)% ClinchedClinched (mi)Overall (mi) % ClinchedClinched Mileage (incl preview)Overall Mileage (incl preview)% Clinched (incl preview) Map
    OverallMiles Driven: ".$row['clinched']." mi (".$row['percentage']."%)Total: ".$row['overall']." miRank: {$row['rank']}
    OverallMiles Driven: ".$row['clinched']." mi (".sprintf('%0.2f',$row['percentage'])."%)Total: ".$row['overall']." miRank (CHECK!): {$row['rank']}
    RoutesDriven: " . $row['driven'] . " (" . round($row['driven'] / $totalRoutes * 100, 2) . "%)Clinched: " . $row['clinched'] . " (" . round($row['clinched'] / $totalRoutes * 100, 2) . "%)Total: " . $totalRoutes . - "Rank: {$row['rank']}
    Rank (CHECK!): {$row['rank']}
    @@ -397,6 +384,8 @@ function waypointsFromSQL() { Route # + Banner + Abbrev Section Clinched Mileage Total Mileage @@ -407,9 +396,9 @@ function waypointsFromSQL() { "; echo "" . $row['route'] . ""; echo "" . $row['routeNum'] . ""; + echo "" . $row['banner'] . ""; + echo "" . $row['abbrev'] . ""; echo "" . $row['city'] . ""; echo "" . $row['clinchedMileage'] . ""; echo "" . $row['totalMileage'] . ""; From 2806cf2e28f44191c9f54030edbf5266f0d881f1 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Fri, 3 Jun 2016 23:50:26 -0400 Subject: [PATCH 10/95] First pass at DB conversion for region.php. --- user/region.php | 113 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 99 insertions(+), 14 deletions(-) diff --git a/user/region.php b/user/region.php index a2e67166..bc596d4f 100644 --- a/user/region.php +++ b/user/region.php @@ -26,8 +26,7 @@ URL Params: u - the user. rg - the region viewing stats for. - db - the database being used. Use 'TravelMappingDev' for in-development systems. - (u, rg, [db]) + (u, rg) --> @@ -293,32 +292,96 @@ function redirect($link) {
    TIP: Click on a column head to sort. Hold SHIFT in order to sort by multiple columns.
    - + + + + "; + $activePreviewTotalMileage = $row['totalActivePreviewMileage']; + $activePreviewClinchedMileage = $row['activePreviewClinched']; + $activePreviewMileagePercentage = $row['activePreviewPercentage']; + $activePreviewMileageRank = $row['rank']; + + echo ""; + echo ""; + echo ""; + echo ""; + +// echo ""; + + // Second, fetch routes clinched/driven + $totalActiveRoutes = mysql_fetch_array(mysql_query("SELECT COUNT(*) as t FROM routes LEFT JOIN systems on routes.systemName = systems.systemName WHERE region = '$region' AND systems.level = 'active'"))['t']; + $totalActivePreviewRoutes = mysql_fetch_array(mysql_query("SELECT COUNT(*) as t FROM routes LEFT JOIN systems on routes.systemName = systems.systemName WHERE region = '$region' AND ".$activeClause." "))['t']; + //error_log("Total Routes: $totalRoutes"); + $sql_command = <<"; + $res = mysql_query($sql_command); + $row = fetchWithRank($res, 'clinchedPct'); + + $drivenActiveRoutes = $row['driven']; + $drivenActiveRoutesPct = $row['drivenPct']; + $clinchedActiveRoutes = $row['clinched']; + $clinchedActiveRoutesPct = $row['clinchedPct']; + $clinchedActiveRoutesRank = $row['rank']; - //Second, fetch routes clinched/driven - $totalRoutes = mysql_fetch_array(mysql_query("SELECT COUNT(*) as t FROM routes LEFT JOIN systems on routes.systemName = systems.systemName WHERE region = '$region' AND ".$activeClause." "))['t']; - error_log("Total Routes: $totalRoutes"); $sql_command = <<"; $res = mysql_query($sql_command); $row = fetchWithRank($res, 'clinchedPct'); - echo "\n"; + + $drivenActivePreviewRoutes = $row['driven']; + $drivenActivePreviewRoutesPct = $row['drivenPct']; + $clinchedActivePreviewRoutes = $row['clinched']; + $clinchedActivePreviewRoutesPct = $row['clinchedPct']; + $clinchedActivePreviewRoutesRank = $row['rank']; + + + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + +// echo "\n"; ?>
    Overall Region Stats
    Overall Region Stats
    Active SystemsActive+Preview Systems
    OverallMiles Driven: ".$row['clinched']." mi (".$row['percentage']."%)Total: ".$row['overall']." miRank: {$row['rank']}
    Miles Driven" . $activeClinchedMileage; + echo "/" . $activeTotalMileage . " mi ("; + echo $activeMileagePercentage . "%) "; + echo "Rank: " . $activeMileageRank . "" . $activePreviewClinchedMileage; + echo "/" . $activePreviewTotalMileage . " mi ("; + echo $activePreviewMileagePercentage . "%) "; + echo "Rank: " . $activePreviewMileageRank . "
    OverallMiles Driven: ".$row['clinched']." mi (".$row['percentage']."%)Total: ".$row['overall']." miRank: {$row['rank']}
    RoutesDriven: " . $row['driven'] . " (" . $row['drivenPct'] . "%)Clinched: " . $row['clinched'] . " (" . $row['clinchedPct'] . "%)Total: " . $totalRoutes . "Rank: {$row['rank']}
    Routes Driven".$drivenActiveRoutes." of " . $totalActiveRoutes . " (" . $drivenActiveRoutesPct . "%) Rank: TBD".$drivenActivePreviewRoutes." of " . $totalActivePreviewRoutes . " (" . $drivenActivePreviewRoutesPct . "%) Rank: TBD
    Routes Clinched".$clinchedActiveRoutes." of " . $totalActiveRoutes . " (" . $clinchedActiveRoutesPct . "%) Rank: ". $clinchedActiveRoutesRank."".$clinchedActivePreviewRoutes." of " . $totalActivePreviewRoutes . " (" . $clinchedActivePreviewRoutesPct . "%) Rank: ". $clinchedActivePreviewRoutesRank."
    RoutesDriven: " . $row['driven'] . " (" . $row['drivenPct'] . "%)Clinched: " . $row['clinched'] . " (" . $row['clinchedPct'] . "%)Total: " . $totalRoutes . "Rank: {$row['rank']}
    From dcc4df93a04d4f3e1549b0d974f8764615a96f0a Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Fri, 3 Jun 2016 23:59:07 -0400 Subject: [PATCH 11/95] Added placeholder for rank and stop displaying systems with 0 miles. --- user/index.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/user/index.php b/user/index.php index 911b34a0..13737a7f 100644 --- a/user/index.php +++ b/user/index.php @@ -103,10 +103,10 @@ echo "Miles Driven"; echo "" . $row['clinchedActiveMileage']; echo "/" . $row['totalActiveMileage'] . " mi ("; - echo $row['activePercentage'] . "%)"; + echo $row['activePercentage'] . "%) Rank: TBD"; echo "" . $row['clinchedActivePreviewMileage']; echo "/" . $row['totalActivePreviewMileage'] . " mi ("; - echo $row['activePreviewPercentage'] . "%)"; + echo $row['activePreviewPercentage'] . "%) Rank: TBD"; echo ""; @@ -148,14 +148,14 @@ echo ""; echo "Routes Driven"; - echo "".$activeDriven." of " . $activeRoutes . " (" . $activeDrivenPct . "%)"; - echo "".$activePreviewDriven." of " . $activePreviewRoutes . " (" . $activePreviewDrivenPct . "%)"; + echo "".$activeDriven." of " . $activeRoutes . " (" . $activeDrivenPct . "%) Rank: TBD"; + echo "".$activePreviewDriven." of " . $activePreviewRoutes . " (" . $activePreviewDrivenPct . "%) Rank: TBD"; echo ""; echo ""; echo "Routes Clinched"; - echo "".$activeClinched." of " . $activeRoutes . " (" . $activeClinchedPct . "%)"; - echo "".$activePreviewClinched." of " . $activePreviewRoutes . " (" . $activePreviewClinchedPct . "%)"; + echo "".$activeClinched." of " . $activeRoutes . " (" . $activeClinchedPct . "%) Rank: TBD"; + echo "".$activePreviewClinched." of " . $activePreviewRoutes . " (" . $activePreviewClinchedPct . "%) Rank: TBD"; echo ""; ?> @@ -217,6 +217,7 @@ echo ""; $res = $db->query($sql_command); while ($row = $res->fetch_assoc()) { + if ($row['clinchedMileage'] == 0) continue; echo ""; echo "" . $row['countryCode'] . ""; echo "" . $row['systemName'] . ""; From 023cd47b8129678e5cf627ca175b211a0f8ef276 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sat, 4 Jun 2016 11:09:22 -0400 Subject: [PATCH 12/95] Removed db option in prep for new DB format. --- devel/hb.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/devel/hb.php b/devel/hb.php index 499816eb..b951e352 100644 --- a/devel/hb.php +++ b/devel/hb.php @@ -8,14 +8,14 @@ } $dbname = "TravelMapping"; -if (isset($_COOKIE['currentdb'])) { - $dbname = $_COOKIE['currentdb']; -} +//if (isset($_COOKIE['currentdb'])) { +// $dbname = $_COOKIE['currentdb']; +//} -if (array_key_exists("db", $_GET)) { - $dbname = $_GET['db']; - setcookie("currentdb", $dbname, time() + (86400 * 30), "/"); -} +//if (array_key_exists("db", $_GET)) { +// $dbname = $_GET['db']; +// setcookie("currentdb", $dbname, time() + (86400 * 30), "/"); +//} if (array_key_exists("rg", $_GET) and strlen($_GET['rg']) > 0) { $region = $_GET['rg']; @@ -34,8 +34,7 @@ * u - user to display highlighting for on map (optional) * rg - region to filter for on the highway browser list (optional) * sys - system to filter for on the highway browser list (optional) - * db - database to use (optional, defaults to TravelMapping - * ([r [u]] [rg | sys], [db]) + * ([r [u]] [rg | sys]) *** --> From b8a68d710cc7d43ddea10ecaadac926ac92abc12 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sat, 4 Jun 2016 11:47:44 -0400 Subject: [PATCH 13/95] Minor mapview updates to prep for consolidated DB. --- hbtest/mapview.php | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/hbtest/mapview.php b/hbtest/mapview.php index 0d2d29bc..53ac9e50 100644 --- a/hbtest/mapview.php +++ b/hbtest/mapview.php @@ -16,8 +16,7 @@ * rg - region to show routes for on the map (optional) * sys - system to show routes for on the map (optional) * rte - route name to show on the map. Supports pattern matching, with _ matching a single character, and % matching 0 or multiple characters. - * db - database to use (optional, defaults to TravelMapping - * (u, [rg|sys][rte], [db]) + * (u, [rg|sys][rte]) *** --> @@ -99,19 +98,6 @@ $con = mysql_connect("localhost", "travmap", "clinch") or die("Failed to connect to database"); mysql_select_db($dbname, $con); - # functions from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php - function startsWith($haystack, $needle) - { - // search backwards starting from haystack length characters from the end - return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; - } - - function endsWith($haystack, $needle) - { - // search forward starting from end minus needle length characters - return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE); - } - function orClauseBuilder($param, $name, $tablename = 'r') { $array = explode(",", $_GET[$param]); $clause = "("; @@ -131,6 +117,7 @@ function orClauseBuilder($param, $name, $tablename = 'r') { function waypointsFromSQL() { 0) { echo " (" . $row['city'] . ")"; } - echo "{$row['systemName']}".$row['clinched']."".$row['total']."".(round( $row['clinched'] / $row['total'] * 100, 2) )."%\n"; + $pct = sprintf("%0.2f",( $row['clinched'] / $row['total'] * 100) ); + echo "{$row['systemName']}".$row['clinched']."".$row['total']."".$pct."%\n"; } ?> From 3d9fa5202224fb23646752a13805d46f6716a967 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sat, 4 Jun 2016 11:47:56 -0400 Subject: [PATCH 14/95] Removed db cookie --- shields/clinched.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shields/clinched.php b/shields/clinched.php index 1a7c61c0..d8075b4a 100644 --- a/shields/clinched.php +++ b/shields/clinched.php @@ -11,13 +11,13 @@ } $dbname = "TravelMapping"; -if (isset($_COOKIE['currentdb'])) { - $dbname = $_COOKIE['currentdb']; -} +//if (isset($_COOKIE['currentdb'])) { +// $dbname = $_COOKIE['currentdb']; +//} if (array_key_exists("db", $_GET)) { $dbname = $_GET['db']; - setcookie("currentdb", $dbname, time() + (86400 * 30), "/"); +// setcookie("currentdb", $dbname, time() + (86400 * 30), "/"); } $db = new mysqli("localhost", "travmap", "clinch", $dbname) or die("Failed to connect to database"); From beff879904f71473e8910b1a60f8bba9ae0e0909 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sat, 4 Jun 2016 16:12:30 -0400 Subject: [PATCH 15/95] Fixes to cumulative stats and rankings. --- user/system.php | 81 ++++++++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 32 deletions(-) diff --git a/user/system.php b/user/system.php index 467ddbca..4d325ffd 100644 --- a/user/system.php +++ b/user/system.php @@ -103,7 +103,7 @@ function fetchWithRank($res, $rankBy) } $nextRank++; - error_log("($rank, {$row['traveler']}, {$row[$rankBy]})"); + error_log("($rank, $rankBy, {$row['traveler']}, {$row[$rankBy]})"); } $row['rank'] = $rank; return $row; @@ -296,45 +296,63 @@ function waypointsFromSQL() {
    - + "; $res = mysql_query($sql_command); - $row = fetchWithRank($res, 'percentage'); + $row = fetchWithRank($res, 'clinchedMileage'); + $percentage = $row['clinchedMileage'] / $systemMileage * 100; $link = "window.open('/hbtest/mapview.php?u=" . $user . "&sys=" . $system . "')"; - echo ""; + echo ""; //Second, fetch routes clinched/driven if (is_null($region)) { @@ -369,9 +387,8 @@ function waypointsFromSQL() { echo ""; $res = mysql_query($sql_command); $row = fetchWithRank($res, 'clinched'); - echo "\n"; + echo ""; + echo "\n"; ?>
    System Stats
    System Stats
    OverallMiles Driven: ".$row['clinched']." mi (".sprintf('%0.2f',$row['percentage'])."%)Total: ".$row['overall']." miRank (CHECK!): {$row['rank']}
    Miles Driven".sprintf('%0.2f', $row['clinchedMileage'])." of ".sprintf('%0.2f', $systemMileage)." mi (".sprintf('%0.2f',$percentage)."%) Rank: {$row['rank']}
    RoutesDriven: " . $row['driven'] . " (" . round($row['driven'] / $totalRoutes * 100, 2) . - "%)Clinched: " . $row['clinched'] . " (" . round($row['clinched'] / $totalRoutes * 100, 2) . "%)Total: " . $totalRoutes . - "Rank (CHECK!): {$row['rank']}
    Routes Driven" . $row['driven'] . " of ".$totalRoutes." (" . round($row['driven'] / $totalRoutes * 100, 2) ."%)
    Ruutes Clinched" . $row['clinched'] . " of " . $totalRoutes . " (" . round($row['clinched'] / $totalRoutes * 100, 2) . "%) Rank: {$row['rank']}
    @@ -379,7 +396,7 @@ function waypointsFromSQL() { TIP: Click on a column head to sort. Hold SHIFT in order to sort by multiple columns. - Statistics per Route + Statistics per Route Route From 06a87ae51301f6432d628a5cea4f781c85e3e485 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sat, 4 Jun 2016 16:15:16 -0400 Subject: [PATCH 16/95] Removed clinched mileage as computed in JS. --- lib/tmjsfuncs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tmjsfuncs.js b/lib/tmjsfuncs.js index c637f539..ee695edb 100644 --- a/lib/tmjsfuncs.js +++ b/lib/tmjsfuncs.js @@ -763,7 +763,7 @@ function updateMap() connections[i] = new google.maps.Polyline({path: edgePoints, strokeColor: color, strokeWeight: 10, strokeOpacity: 0.75, map: map}); } } - document.getElementById('controlboxinfo').innerHTML = clinchedMiles.toFixed(2) + " of " + totalMiles.toFixed(2) + " miles (" + (clinchedMiles/totalMiles*100).toFixed(1) + "%) clinched by " + traveler + "."; + document.getElementById('controlboxinfo').innerHTML = ""; //clinchedMiles.toFixed(2) + " of " + totalMiles.toFixed(2) + " miles (" + (clinchedMiles/totalMiles*100).toFixed(1) + "%) clinched by " + traveler + "."; } else if (genEdges) { connections[0] = new google.maps.Polyline({path: polypoints, strokeColor: "#0000FF", strokeWeight: 10, strokeOpacity: 0.75, map: map}); From 1a7ba905daf8a8634eab1bdbbff50029384558ad Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sat, 4 Jun 2016 16:51:41 -0400 Subject: [PATCH 17/95] Typo fix. --- user/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user/system.php b/user/system.php index 4d325ffd..7aa6aadd 100644 --- a/user/system.php +++ b/user/system.php @@ -388,7 +388,7 @@ function waypointsFromSQL() { $res = mysql_query($sql_command); $row = fetchWithRank($res, 'clinched'); echo "Routes Driven" . $row['driven'] . " of ".$totalRoutes." (" . round($row['driven'] / $totalRoutes * 100, 2) ."%)"; - echo "Ruutes Clinched" . $row['clinched'] . " of " . $totalRoutes . " (" . round($row['clinched'] / $totalRoutes * 100, 2) . "%) Rank: {$row['rank']}\n"; + echo "Routes Clinched" . $row['clinched'] . " of " . $totalRoutes . " (" . round($row['clinched'] / $totalRoutes * 100, 2) . "%) Rank: {$row['rank']}\n"; ?> From e99b8cc2aaf23b9d7ce78e9da0995b772c3bc2a3 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sat, 4 Jun 2016 19:08:50 -0400 Subject: [PATCH 18/95] Commented out error logging. --- stat.php | 56 +++++++++++++++++++++++++++++++++++++++++++------ user/region.php | 2 +- user/system.php | 2 +- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/stat.php b/stat.php index a9647751..c8367419 100644 --- a/stat.php +++ b/stat.php @@ -20,7 +20,7 @@ Traveler Statistics -

    Travel Mapping Highway Data Datacheck Errors

    + -

    Quick links: [Errors in Active Systems][Errors in Preview Systems][Errors in In-Dev Systems][Errors Marked as FPs].

    +

    Travel Mapping Highway Data Datacheck Errors

    -

    See also the [Log of Unmatched +

    Quick links: [Errors in Active Systems][Errors in Preview Systems][Errors in In-Dev Systems][Errors Marked as FPs].

    + +

    See also the [Log of Unmatched FPs from datacheckfps.csv] and the [Log of Unprocessed WPTs in the Repository]. Cleaning these up are low priority tasks for the @@ -53,37 +56,68 @@ function writeTable($db, $fpVal, $joins) {

    -

    Errors in Active Systems (not FPs)

    -

    These errors should be corrected, or reported as false positives by adding the entry from the last column to the datacheck FP list as soon as possible. Ideally, this list should always be empty.

    +

    Errors in Active Systems (not FPs)

    + +

    These errors should be + corrected, or reported as false positives by adding the entry from + the last column + to the + datacheck FP list as soon as possible. Ideally, this list + should always be empty.

    + +
    RouteWaypointsErrorInfoFP Entry to Submit
    -

    Errors in Preview Systems (not FPs)

    -

    These errors should be corrected, or reported as false positives by adding the entry from the last column to the datacheck FP list during the final review process to promote a system from 'preview' to 'active'. A system should have no entries here before activation.

    +

    Errors in Preview Systems (not FPs)

    + +

    These errors should be + corrected, or reported as false positives by adding the entry from + the last column + to the + datacheck FP list during the final review process to promote a + system from 'preview' to 'active'. A system should have no entries + here before activation.

    +
    RouteWaypointsErrorInfoFP Entry to Submit
    -

    Errors in In-Development Systems (not FPs)

    -

    These errors should be corrected, or reported as false positives by adding the entry from the last column to the datacheck FP list before the system is promoted from 'devel' to 'preview'.

    +

    Errors in In-Development Systems (not FPs)

    + +

    These errors should be + corrected, or reported as false positives by adding the entry from + the last column + to the + datacheck FP list before the system is promoted from 'devel' to + 'preview'.

    +
    RouteWaypointsErrorInfoFP Entry to Submit
    -

    Errors Marked as FPs ("Crossed Off")

    -

    These have been marked as FPs in the datacheck FP list and can normally be safely ignored. However, if any of these are discovered to be true errors, they should be removed from the list and fixed in the highway data.

    + +

    Errors Marked as FPs ("Crossed Off")

    + +

    These have been marked as FPs + in the + datacheck FP list and can normally be safely ignored. However, + if any of these are discovered to be true errors, they should be + removed from the list and fixed in the highway data.

    +
    RouteWaypointsErrorInfoFP Entry Matched
    + close(); diff --git a/devel/hb.php b/devel/hb.php index b951e352..c8958780 100644 --- a/devel/hb.php +++ b/devel/hb.php @@ -1,5 +1,5 @@ \n"; - if (array_key_exists("u", $_GET)) echo "" . $_GET['u'] . "-"; - echo "Home-"; - echo "Highway Browser"; echo "
    "; echo ""; echo ""; @@ -229,12 +226,10 @@ function waypointsFromSQL() { } else { echo "\n"; - if (array_key_exists("u", $_GET)) echo "" . $_GET['u'] . "-"; - echo "Home-"; - echo "Highway Browser"; } ?> - + +

    Travel Mapping Highway Browser (Draft)

    +

    Travel Mapping Highway Data Updates

    -

    Highway Data System Status Changes

    + +

    Quick links: [Highway System Status Changes][Updates to Highway Data in Active Systems].

    + + +

    Highway System Status Changes

    @@ -62,7 +67,7 @@ function endsWith($haystack, $needle) {
    DateCountry/RegionSystem CodeSystem DescriptionNew Status
    -

    Updates to Highway Data in Active Systems

    +

    Updates to Highway Data in Active Systems

    @@ -83,6 +88,7 @@ function endsWith($haystack, $needle) { ?>
    DateRegionRouteFile RootDescription
    + close(); diff --git a/hbtest/mapview.php b/hbtest/mapview.php index 2f513395..9e5372a0 100644 --- a/hbtest/mapview.php +++ b/hbtest/mapview.php @@ -302,9 +302,8 @@ function initFloatingHeaders($table) { } ); -- -Home- -Highway Browser + +

    Travel Mapping: Draft Map Overlay Viewer

    diff --git a/index.php b/index.php index 0885053a..8ade1512 100644 --- a/index.php +++ b/index.php @@ -4,47 +4,38 @@ Travel Mapping - + - - + + +

    Welcome to Travel Mapping

    + +

    + +Travel Mapping is a collaborative project implemented and maintained +by a group of travel +enthusiasts who enjoy tracking their cumulative travels. This site +allows its users to submit lists of highway +segments they've traveled on the highway +systems that have been included in the project. Those lists are +then imported into the project's database, to be included along with +other users' stats and maps. + +

    + +

    How to Participate

    + +

    + +Anyone can submit their travels to be included in the site. Please +see the information in the project forum for how +to create and submit your data. + +

    + + + diff --git a/lib/tmfooter.php b/lib/tmfooter.php new file mode 100644 index 00000000..a18d725d --- /dev/null +++ b/lib/tmfooter.php @@ -0,0 +1,8 @@ + + + diff --git a/lib/tmheader.php b/lib/tmheader.php new file mode 100644 index 00000000..2835fcec --- /dev/null +++ b/lib/tmheader.php @@ -0,0 +1,23 @@ + + + +Travel Mapping +

    + +

    +Tracking Cumulative Travels +

    +END; +} +?> + + diff --git a/shields/index.php b/shields/shieldgen.php similarity index 100% rename from shields/index.php rename to shields/shieldgen.php diff --git a/stat.php b/stat.php index 692030d8..3800190d 100644 --- a/stat.php +++ b/stat.php @@ -7,7 +7,6 @@ A rankings page. URL Params: u - the user, to show highlighting on page. - db - the database being used. Use 'TravelMappingDev' for in-development systems. --> @@ -38,6 +37,7 @@ }).css('text-align','right'); }); +

    Traveler Statistics

    @@ -123,4 +123,5 @@
    + \ No newline at end of file diff --git a/user/index.php b/user/index.php index 13737a7f..8840a28a 100644 --- a/user/index.php +++ b/user/index.php @@ -60,9 +60,8 @@ } ); + + + diff --git a/user/region.php b/user/region.php index 831dd4f3..dd5c2c4d 100644 --- a/user/region.php +++ b/user/region.php @@ -267,11 +267,8 @@ function redirect($link) { window.document.location=$link; } +
    + \ No newline at end of file diff --git a/user/system.php b/user/system.php index 8bc5ebe9..12015c7d 100644 --- a/user/system.php +++ b/user/system.php @@ -264,10 +264,8 @@ function waypointsFromSQL() { } ); +
  • + \ No newline at end of file From c4ccf3aa0ebba565964eb882b3eacd03f0308190 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sun, 5 Jun 2016 21:55:16 -0400 Subject: [PATCH 23/95] Some file rearrangement, phase 1. --- devel/hb.php => hb/index.php | 0 {devel => hb}/smallintersection.png | Bin index.php | 2 +- logo.svg | 39 ----------- menu.svg | 9 --- shields/clinched.php | 8 +-- style.css | 105 ---------------------------- 7 files changed, 5 insertions(+), 158 deletions(-) rename devel/hb.php => hb/index.php (100%) rename {devel => hb}/smallintersection.png (100%) delete mode 100644 logo.svg delete mode 100644 menu.svg delete mode 100644 style.css diff --git a/devel/hb.php b/hb/index.php similarity index 100% rename from devel/hb.php rename to hb/index.php diff --git a/devel/smallintersection.png b/hb/smallintersection.png similarity index 100% rename from devel/smallintersection.png rename to hb/smallintersection.png diff --git a/index.php b/index.php index 8ade1512..7df603ba 100644 --- a/index.php +++ b/index.php @@ -18,7 +18,7 @@ by a group of travel enthusiasts who enjoy tracking their cumulative travels. This site allows its users to submit lists of highway -segments they've traveled on the highway +segments they've traveled on the highway systems that have been included in the project. Those lists are then imported into the project's database, to be included along with other users' stats and maps. diff --git a/logo.svg b/logo.svg deleted file mode 100644 index afcdcf42..00000000 --- a/logo.svg +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - diff --git a/menu.svg b/menu.svg deleted file mode 100644 index b253b9ba..00000000 --- a/menu.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/shields/clinched.php b/shields/clinched.php index d8075b4a..e08dd4e7 100644 --- a/shields/clinched.php +++ b/shields/clinched.php @@ -1,5 +1,5 @@ Clinched Routes for <?php echo $user ?> + - Home - - Highway Browser - - {$user}" ?> + @@ -74,5 +73,6 @@ $res->free(); ?> + \ No newline at end of file diff --git a/style.css b/style.css deleted file mode 100644 index 531c38a4..00000000 --- a/style.css +++ /dev/null @@ -1,105 +0,0 @@ -body { - margin: 0; -} - -.container { - max-width: 800px; - margin: auto; - padding-left: 10px; - padding-right: 10px; -} - -#header { - background-color: #214478; -} - -#logo { - margin: 20px 0; - display: inline-block; - vertical-align: middle; - line-height: 64px; - width: 300px; - height: 60px; - background-image: url("/logo.svg"); - background-size: contain; -} - -#hamburger { - display: none; -} - -#nav ul { - list-style-type: none; - padding-left: 0; -} - -#nav ul li a { - display: inline-block; - padding: 10px; - color: white; - text-decoration: none; -} -#nav ul li a:hover { - color: #214478; - background-color: white; -} - -@media (min-width: 500px) { - #nav ul { - display: inline; - } - - #nav ul li { - display: inline; - } - - label[for="hamburger"] { - display: none; - } - - #main { - padding-top: 20px; - } -} - -@media (max-width: 499px) { - #logo { - width: 200px; - height: 40px; - margin: 15px 0; - } - - label[for="hamburger"] { - display: inline-block; - width: 15px; - height: 15px; - background-image: url("/menu.svg"); - background-size: contain; - cursor: pointer; - vertical-align: middle; - margin-left: 10px; - margin-right: 20px; - line-height: 64px; - } - - #nav { - display: none; - } - - #hamburger:checked ~ #nav { - display: block; - } - - #nav ul { - margin-top: 0; - padding-bottom: 10px; - } - - #nav ul li { - display: block; - } - - #main { - padding-top: 10px; - } -} From 9112a98326ee6b40ab0bfd334c8e3e34e2eeef8f Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sun, 5 Jun 2016 22:08:49 -0400 Subject: [PATCH 24/95] Updates to move hb to its own directory. --- devel/updates.php | 2 +- hb/index.php | 6 +++--- index.php | 2 +- lib/tmheader.php | 4 ++-- shields/clinched.php | 2 +- user/index.php | 4 ++-- user/region.php | 6 +++--- user/system.php | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/devel/updates.php b/devel/updates.php index 26edcf1a..579d0371 100644 --- a/devel/updates.php +++ b/devel/updates.php @@ -81,7 +81,7 @@ function endsWith($haystack, $needle) { echo "".$row['date']."".$row['region']."".$row['route']."(NONE)".$row['description']."\n"; } else { - echo "".$row['date']."".$row['region']."".$row['route']."".$row['root']."".$row['description']."\n"; + echo "".$row['date']."".$row['region']."".$row['route']."".$row['root']."".$row['description']."\n"; } } $res->free(); diff --git a/hb/index.php b/hb/index.php index c8958780..40c8a824 100644 --- a/hb/index.php +++ b/hb/index.php @@ -217,7 +217,7 @@ function waypointsFromSQL() { \n"; - echo ""; + echo ""; echo ""; echo ""; echo ""; @@ -345,7 +345,7 @@ function initFloatingHeaders($table) { if (strcmp($row['city'], "") != 0) { echo " (" . $row['city'] . ")"; } - echo "" . $row['region'] . " " . $row['route'] . $row['banner'] . $row['abbrev'] . "" . $row['level'] . "" . $row['root'] . "\n"; + echo "" . $row['region'] . " " . $row['route'] . $row['banner'] . $row['abbrev'] . "" . $row['level'] . "" . $row['root'] . "\n"; } $res->free(); echo "\n"; @@ -364,7 +364,7 @@ function initFloatingHeaders($table) { $sql_command = "SELECT * FROM systems LEFT JOIN countries ON countryCode = countries.code"; $res = $db->query($sql_command); while ($row = $res->fetch_assoc()) { - $linkJS = "window.open('hb.php?sys={$row['systemName']}')"; + $linkJS = "window.open('index.php?sys={$row['systemName']}')"; echo ""; if (strlen($row['name']) > 15) { echo "{$row['code']}"; diff --git a/index.php b/index.php index 7df603ba..c8e3e3e5 100644 --- a/index.php +++ b/index.php @@ -17,7 +17,7 @@ Travel Mapping is a collaborative project implemented and maintained by a group of travel enthusiasts who enjoy tracking their cumulative travels. This site -allows its users to submit lists of highway +allows its users to submit lists of highway segments they've traveled on the highway systems that have been included in the project. Those lists are then imported into the project's database, to be included along with diff --git a/lib/tmheader.php b/lib/tmheader.php index 2835fcec..28fb68ad 100644 --- a/lib/tmheader.php +++ b/lib/tmheader.php @@ -16,8 +16,8 @@ diff --git a/shields/clinched.php b/shields/clinched.php index e08dd4e7..571126e3 100644 --- a/shields/clinched.php +++ b/shields/clinched.php @@ -62,7 +62,7 @@ $rootList = explode(",", $row['clinchedRoutes']); $col = 0; foreach($rootList as $root) { - echo "".generate($root, $_GET['reload']).""; + echo "".generate($root, $_GET['reload']).""; $col++; if ($col > 8) { echo "
    "; diff --git a/user/index.php b/user/index.php index 8840a28a..58fdd311 100644 --- a/user/index.php +++ b/user/index.php @@ -188,7 +188,7 @@ $activePercent = sprintf('%0.2f', $activePercent); $activePreviewPercent = round($row['clinchedActivePreviewMileage'] / $row['totalActivePreviewMileage'] * 100.0, 2); $activePreviewPercent = sprintf('%0.2f', $activePreviewPercent); - echo "" . $row['country'] . "" . $row['name'] . "" . sprintf('%0.2f', $row['clinchedActiveMileage']) . "" . sprintf('%0.2f', $row['totalActiveMileage']) . "" . $activePercent . "%" . sprintf('%0.2f', $row['clinchedActivePreviewMileage']) . "" . sprintf('%0.2f', $row['totalActivePreviewMileage']) . "" . $activePreviewPercent . "%MapHB"; + echo "" . $row['country'] . "" . $row['name'] . "" . sprintf('%0.2f', $row['clinchedActiveMileage']) . "" . sprintf('%0.2f', $row['totalActiveMileage']) . "" . $activePercent . "%" . sprintf('%0.2f', $row['clinchedActivePreviewMileage']) . "" . sprintf('%0.2f', $row['totalActivePreviewMileage']) . "" . $activePreviewPercent . "%MapHB"; } $res->free(); ?> @@ -227,7 +227,7 @@ echo "" . $row['totalMileage'] . ""; echo "" . $row['percentage'] . "%"; echo "Map"; - echo "HB"; + echo "HB"; } $res->free(); ?> diff --git a/user/region.php b/user/region.php index dd5c2c4d..1999e614 100644 --- a/user/region.php +++ b/user/region.php @@ -468,7 +468,7 @@ function redirect($link) { echo "" . $row['clinchedMileage'] . ""; echo "" . $row['totalMileage'] . ""; echo "" . $row['percentage'] . "%"; - echo "HB"; + echo "HB"; } ?> @@ -484,7 +484,7 @@ function redirect($link) { echo ""; $res = mysql_query($sql_command); while ($row = mysql_fetch_array($res)) { - echo ""; + echo ""; echo "".$row['route']; if (strlen($row['banner']) > 0) { echo " ".$row['banner']." "; @@ -496,7 +496,7 @@ function redirect($link) { echo "".$row['clinchedMileage'].""; echo "".$row['totalMileage'].""; echo "".$row['percentage']."%"; - echo "HB"; + echo "HB"; } ?> diff --git a/user/system.php b/user/system.php index 12015c7d..4eb7ff9c 100644 --- a/user/system.php +++ b/user/system.php @@ -426,7 +426,7 @@ function waypointsFromSQL() { if (is_null($region)) { $link = "window.open('/hbtest/mapview.php?u=" . $user . "&rte=" . $row['route'] . "')"; } else { - $link = "window.open('/devel/hb.php?u=" . $user . "&r=" . $row['root'] . "')"; + $link = "window.open('/hb?u=" . $user . "&r=" . $row['root'] . "')"; } echo ""; From d4c91e571cc644741001be63b042c7bbb4a2cfe9 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sun, 5 Jun 2016 22:10:13 -0400 Subject: [PATCH 25/95] Move mapview to user directory. --- {hbtest => user}/mapview.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {hbtest => user}/mapview.php (100%) diff --git a/hbtest/mapview.php b/user/mapview.php similarity index 100% rename from hbtest/mapview.php rename to user/mapview.php From d0d6ed54ebf869c8abaf9417206d64033a63bc98 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sun, 5 Jun 2016 22:12:33 -0400 Subject: [PATCH 26/95] Further updates for mapview's move to user. --- hb/index.php | 2 +- user/index.php | 4 ++-- user/region.php | 6 +++--- user/system.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hb/index.php b/hb/index.php index 40c8a824..08a9b860 100644 --- a/hb/index.php +++ b/hb/index.php @@ -281,7 +281,7 @@ function initFloatingHeaders($table) { if ($showingmap == 1) { echo "
    \n"; echo "" . generate($_GET['r'], true) . ""; - echo "View Associated Routes"; + echo "View Associated Routes"; echo "\n"; $sql_command = "SELECT pointName, latitude, longitude FROM waypoints WHERE root = '" . $_GET['r'] . "';"; $res = $db->query($sql_command); diff --git a/user/index.php b/user/index.php index 58fdd311..bc3f5005 100644 --- a/user/index.php +++ b/user/index.php @@ -188,7 +188,7 @@ $activePercent = sprintf('%0.2f', $activePercent); $activePreviewPercent = round($row['clinchedActivePreviewMileage'] / $row['totalActivePreviewMileage'] * 100.0, 2); $activePreviewPercent = sprintf('%0.2f', $activePreviewPercent); - echo ""; + echo ""; } $res->free(); ?> @@ -226,7 +226,7 @@ echo ""; echo ""; echo ""; - echo ""; + echo ""; echo ""; } $res->free(); diff --git a/user/region.php b/user/region.php index 1999e614..59c660b9 100644 --- a/user/region.php +++ b/user/region.php @@ -305,7 +305,7 @@ function redirect($link) { SQL; $res = mysql_query($sql_command); $row = fetchWithRank($res, 'activePercentage'); - $link = "redirect('/hbtest/mapview.php?u=" . $user . "&rg=" . $region . "')"; + $link = "redirect('/user/mapview.php?u=" . $user . "&rg=" . $region . "')"; $activeTotalMileage = $row['totalActiveMileage']; $activeClinchedMileage = $row['activeClinched']; $activeMileagePercentage = $row['activePercentage']; @@ -321,7 +321,7 @@ function redirect($link) { SQL; $res = mysql_query($sql_command); $row = fetchWithRank($res, 'activePreviewPercentage'); - $link = "redirect('/hbtest/mapview.php?u=" . $user . "&rg=" . $region . "')"; + $link = "redirect('/user/mapview.php?u=" . $user . "&rg=" . $region . "')"; $activePreviewTotalMileage = $row['totalActivePreviewMileage']; $activePreviewClinchedMileage = $row['activePreviewClinched']; $activePreviewMileagePercentage = $row['activePreviewPercentage']; @@ -475,7 +475,7 @@ function redirect($link) {
    Waypoints
    CoordinatesWaypoint Name
    " . $row['country'] . "" . $row['name'] . "" . sprintf('%0.2f', $row['clinchedActiveMileage']) . "" . sprintf('%0.2f', $row['totalActiveMileage']) . "" . $activePercent . "%" . sprintf('%0.2f', $row['clinchedActivePreviewMileage']) . "" . sprintf('%0.2f', $row['totalActivePreviewMileage']) . "" . $activePreviewPercent . "%
    " . $row['country'] . "" . $row['name'] . "" . sprintf('%0.2f', $row['clinchedActiveMileage']) . "" . sprintf('%0.2f', $row['totalActiveMileage']) . "" . $activePercent . "%" . sprintf('%0.2f', $row['clinchedActivePreviewMileage']) . "" . sprintf('%0.2f', $row['totalActivePreviewMileage']) . "" . $activePreviewPercent . "%
    " . $row['clinchedMileage'] . "" . $row['totalMileage'] . "" . $row['percentage'] . "%
    - + diff --git a/user/system.php b/user/system.php index 4eb7ff9c..4dfad34d 100644 --- a/user/system.php +++ b/user/system.php @@ -349,7 +349,7 @@ function waypointsFromSQL() { $res = mysql_query($sql_command); $row = fetchWithRank($res, 'clinchedMileage'); $percentage = $row['clinchedMileage'] / $systemMileage * 100; - $link = "window.open('/hbtest/mapview.php?u=" . $user . "&sys=" . $system . "')"; + $link = "window.open('/user/mapview.php?u=" . $user . "&sys=" . $system . "')"; echo ""; //Second, fetch routes clinched/driven @@ -424,7 +424,7 @@ function waypointsFromSQL() { while ($row = mysql_fetch_array($res)) { if (is_null($region)) { - $link = "window.open('/hbtest/mapview.php?u=" . $user . "&rte=" . $row['route'] . "')"; + $link = "window.open('/user/mapview.php?u=" . $user . "&rte=" . $row['route'] . "')"; } else { $link = "window.open('/hb?u=" . $user . "&r=" . $row['root'] . "')"; } From 562594d2727e6543702fd0aebeb8de381508b296 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sun, 5 Jun 2016 22:14:12 -0400 Subject: [PATCH 27/95] Remove now unused hbtest directory. --- hbtest/index.php | 5 ----- hbtest/smallintersection.png | Bin 971 -> 0 bytes 2 files changed, 5 deletions(-) delete mode 100644 hbtest/index.php delete mode 100644 hbtest/smallintersection.png diff --git a/hbtest/index.php b/hbtest/index.php deleted file mode 100644 index 4cac0d39..00000000 --- a/hbtest/index.php +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/hbtest/smallintersection.png b/hbtest/smallintersection.png deleted file mode 100644 index aff56fbedffb743d385de589592678ee89e8d9b1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 971 zcmZ`&dq~q!6#iyyKAPIYrVR}rXb)TMp{c{l>DHWWYfiH?Qa5utZK&JQ9K%d9(4vQs zqy?qXn^r9dwscULQJ6FNGw=?@(vNqAAZQU;h}fcm|_ z6oKkL06W>hcp<<)1_W20uxBQdI)Or(Eh2=!Mx(-;_BZncK|lhb0s%lAu<*~Jji3AkT>ahCLu@GKWkBM3N^0f$kZ6XduJ5 zja)t36Ziu}7NQ1OULGXg)9no~-;=U_(|o)kOF^C#XhUiOWNE;0;41LML$Crw1ScXx zu_OwbO{gx$8XnTuU}+R83cw6Tl?wR^P-zHeKp{lIMlcpYl?g=}sIw3>7s4c<6}W<# znVCZ)1~q9cHY(*=2-EYNPC`I?ESq8?I&Bg>D=e?4R)RR{GD!{`BLt~bGu4w zceLNM*vuxo&0%Y^mUdcnx^m0rL0jW($wbLb+q#ih25CuAZx9R1qSZ%<_VBGt&ovOm z31ulIYUslcKRdz!SajNjI!|#6|+6Vsy6SS z=e_9UHZ%Ee=h>Mi?i8($zHjks*O5%8%jM);tNP-*p58l=@4D3_ak(V-mtD|~t)R!8 zjU4dPj7pr0@z$Kd)qV6E)!&tq0h;?9X4$0j_Dd=Kz`;c+<*Y3AxB5Yop2KA)CY4M{ za?kWq!bW3zeD(JIhJD>T^ST^mrw)hr@Z<-p&yM+8mg`$W6*Jry?ICvUGG4=Ti0;K+ z50u4UCOSkLMO%#9RmNg|k-nHXaM>Ili=D{g#AkDPd|o1-m%w7j@!4#{EB?ek1-gpu zT21Z$3%u$Z+<#%1`-ZFvjj=|hFNRnl4HuVI7>tG@y|&UAp0tvk5Y~}=nh+ro$%U5G G!iHbfiWCn3 From 81c0fd1ec29bc6f20e8ce3bb1eddfe223ccf2bac Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sun, 5 Jun 2016 22:28:52 -0400 Subject: [PATCH 28/95] Fix for #43. --- hb/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hb/index.php b/hb/index.php index 08a9b860..c4624e32 100644 --- a/hb/index.php +++ b/hb/index.php @@ -338,7 +338,7 @@ function initFloatingHeaders($table) { $sql_command .= ";"; echo "\n"; echo "
    \n"; - echo "
    Stats by Route: (" ?>Full Map)
    Stats by Route: (" ?>Full Map)
    RouteClinched MileageTotal Mileage%Map
    Miles Driven".sprintf('%0.2f', $row['clinchedMileage'])." of ".sprintf('%0.2f', $systemMileage)." mi (".sprintf('%0.2f',$percentage)."%) Rank: {$row['rank']}
    \n"; + echo "
    Select Route to Display (click a header to sort by that column)
    SystemRegionRoute Name.list NameLevelRoot
    \n"; $res = $db->query($sql_command); while ($row = $res->fetch_assoc()) { echo "\n"; + echo "\n"; } $res->free(); ?> @@ -74,14 +57,14 @@ function endsWith($haystack, $needle) { query($sql_command); + $res = tmdb_query($sql_command); while ($row = $res->fetch_assoc()) { if (strcmp($row['root'],"") == 0) { - echo "\n"; + echo "\n"; } else { - echo "\n"; + echo "\n"; } } $res->free(); @@ -91,6 +74,6 @@ function endsWith($haystack, $needle) { close(); + $tmdb->close(); ?> diff --git a/lib/tmfooter.php b/lib/tmfooter.php index a18d725d..08324021 100644 --- a/lib/tmfooter.php +++ b/lib/tmfooter.php @@ -6,3 +6,5 @@ Raw Stats     TM on GitHub

    + + diff --git a/lib/tmheader.php b/lib/tmheader.php index 28fb68ad..27556cea 100644 --- a/lib/tmheader.php +++ b/lib/tmheader.php @@ -21,3 +21,5 @@ Project Forum     Updates

    + + diff --git a/lib/tmphpfuncs.php b/lib/tmphpfuncs.php new file mode 100644 index 00000000..e605e0cb --- /dev/null +++ b/lib/tmphpfuncs.php @@ -0,0 +1,88 @@ + + element. +*/ + +// always attempt to establish a connection to the db, allow QS parameters +// to override defaults + +$tmdbname = "TravelMapping"; +$tmdbuser = "travmap"; +$tmdbpasswd = "clinch"; +$tmdbhost = "localhost"; + +if (array_key_exists("dbname", $_GET)) { + $tmdbname = $_GET['dbname']; +} + +if (array_key_exists("dbuser", $_GET)) { + $tmdbuser = $_GET['dbuser']; +} + +if (array_key_exists("dbpasswd", $_GET)) { + $tmdbpasswd = $_GET['dbpasswd']; +} + +if (array_key_exists("dbhost", $_GET)) { + $tmdbhost = $_GET['dbhost']; +} + +// sqldebug QS param to tell pages to show SQL commands in HTML comments +$tmsqldebug = FALSE; + +if (array_key_exists("sqldebug", $_GET)) { + $tmsqldebug = TRUE; +} + + +// make the connection +echo "\n"; +mysqli_report(MYSQLI_REPORT_STRICT); +try { + $tmdb = new mysqli($tmdbhost, $tmdbuser, $tmdbpasswd, $tmdbname); +} +catch ( Exception $e ) { + echo "

    Failed to connect to database ".$tmdbname." on ".$tmdbhost." Please try again later.

    "; + exit; +} + +// function to combine a query with a little error check +function tmdb_query($sql_command) { + + global $tmdb; + global $tmsqldebug; + if ($tmsqldebug) { + echo "\n"; + } + $res = $tmdb->query($sql_command); + if ($res) return $res; + die("

    Query failed: ".$sql_command."

    "); +} + +// function to call to free the DB instance (or just put this code +// at the bottom of a page + +function tmdb_close() { + global $tmdb; + $tmdb->close(); +} + +?> + From 7b73544efc2ecad41e06d477a0ab5b3c7b935108 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Tue, 7 Jun 2016 22:22:54 -0400 Subject: [PATCH 30/95] Improvements to overall user stats page. --- lib/tmphpfuncs.php | 29 ++++++++++++++ lib/tmphpuser.php | 23 +++++++++++ user/index.php | 96 +++++++++++++++++++++++----------------------- 3 files changed, 100 insertions(+), 48 deletions(-) create mode 100644 lib/tmphpuser.php diff --git a/lib/tmphpfuncs.php b/lib/tmphpfuncs.php index e605e0cb..0eed1dff 100644 --- a/lib/tmphpfuncs.php +++ b/lib/tmphpfuncs.php @@ -51,6 +51,12 @@ $tmsqldebug = TRUE; } +// get other common QS parameters + +// Note: u= is the user, stored in $tmuser variable, but this +// is set instead by the tmphpuser.php file which needs +// to be included before any other output is generated +// to avoid warnings from setcookie // make the connection echo "\n"; @@ -84,5 +90,28 @@ function tmdb_close() { $tmdb->close(); } +// function to generate a user selection input form +function tm_user_select_form() { + global $tmdb; + global $tmuser; + echo "

    \n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "

    \n"; +} + ?> diff --git a/lib/tmphpuser.php b/lib/tmphpuser.php new file mode 100644 index 00000000..be5415b9 --- /dev/null +++ b/lib/tmphpuser.php @@ -0,0 +1,23 @@ + diff --git a/user/index.php b/user/index.php index bc3f5005..958d6222 100644 --- a/user/index.php +++ b/user/index.php @@ -1,16 +1,15 @@ - + - + - + - + + <?php - echo "Traveler Stats for " . $user; - - // establish connection to db - $db = new mysqli("localhost", "travmap", "clinch", $dbname) or die("Failed to connect to database"); + echo "Traveler Stats for " . $tmuser; ?> @@ -61,18 +58,25 @@ ); -

    Overall Stats

    @@ -92,11 +96,9 @@ round(sum(coalesce(co.activePreviewMileage, 0)), 2) as clinchedActivePreviewMileage, round(sum(coalesce(co.activePreviewMileage, 0)) / sum(o.activePreviewMileage) * 100, 2) AS activePreviewPercentage FROM overallMileageByRegion o -LEFT JOIN clinchedOverallMileageByRegion co ON co.region = o.region AND traveler = '$user' +LEFT JOIN clinchedOverallMileageByRegion co ON co.region = o.region AND traveler = '$tmuser' SQL; - - echo ""; - $res = $db->query($sql_command); + $res = tmdb_query($sql_command); $row = $res->fetch_assoc(); $res->free(); echo "
    "; @@ -111,15 +113,13 @@ //Second, fetch routes driven/clinched active only $sql_command = "SELECT COUNT(cr.route) AS total FROM connectedRoutes AS cr LEFT JOIN systems ON cr.systemName = systems.systemName WHERE (systems.level = 'active');"; - echo ""; - $res = $db->query($sql_command); + $res = tmdb_query($sql_command); $row = $res->fetch_assoc(); $activeRoutes = $row['total']; $res->free(); - $sql_command = "SELECT COUNT(ccr.route) AS driven, SUM(ccr.clinched) AS clinched, ROUND(COUNT(ccr.route) / ".$activeRoutes." * 100,2) AS drivenPercent, ROUND(SUM(ccr.clinched) / ".$activeRoutes." * 100,2) AS clinchedPercent FROM connectedRoutes AS cr LEFT JOIN clinchedConnectedRoutes AS ccr ON cr.firstRoot = ccr.route AND traveler = '" . $user . "' LEFT JOIN routes ON ccr.route = routes.root LEFT JOIN systems ON routes.systemName = systems.systemName WHERE systems.level = 'active';"; - echo ""; - $res = $db->query($sql_command); + $sql_command = "SELECT COUNT(ccr.route) AS driven, SUM(ccr.clinched) AS clinched, ROUND(COUNT(ccr.route) / ".$activeRoutes." * 100,2) AS drivenPercent, ROUND(SUM(ccr.clinched) / ".$activeRoutes." * 100,2) AS clinchedPercent FROM connectedRoutes AS cr LEFT JOIN clinchedConnectedRoutes AS ccr ON cr.firstRoot = ccr.route AND traveler = '" . $tmuser . "' LEFT JOIN routes ON ccr.route = routes.root LEFT JOIN systems ON routes.systemName = systems.systemName WHERE systems.level = 'active';"; + $res = tmdb_query($sql_command); $row = $res->fetch_assoc(); $activeDriven = $row['driven']; $activeDrivenPct = $row['drivenPercent']; @@ -129,15 +129,13 @@ // and active+preview $sql_command = "SELECT COUNT(cr.route) AS total FROM connectedRoutes AS cr LEFT JOIN systems ON cr.systemName = systems.systemName WHERE (systems.level = 'active' OR systems.level = 'preview');"; - echo ""; - $res = $db->query($sql_command); + $res = tmdb_query($sql_command); $row = $res->fetch_assoc(); $activePreviewRoutes = $row['total']; $res->free(); - $sql_command = "SELECT COUNT(ccr.route) AS driven, SUM(ccr.clinched) AS clinched, ROUND(COUNT(ccr.route) / ".$activeRoutes." * 100,2) AS drivenPercent, ROUND(SUM(ccr.clinched) / ".$activeRoutes." * 100,2) AS clinchedPercent FROM connectedRoutes AS cr LEFT JOIN clinchedConnectedRoutes AS ccr ON cr.firstRoot = ccr.route AND traveler = '" . $user . "' LEFT JOIN routes ON ccr.route = routes.root LEFT JOIN systems ON routes.systemName = systems.systemName WHERE (systems.level = 'active' OR systems.level = 'preview');"; - echo ""; - $res = $db->query($sql_command); + $sql_command = "SELECT COUNT(ccr.route) AS driven, SUM(ccr.clinched) AS clinched, ROUND(COUNT(ccr.route) / ".$activeRoutes." * 100,2) AS drivenPercent, ROUND(SUM(ccr.clinched) / ".$activeRoutes." * 100,2) AS clinchedPercent FROM connectedRoutes AS cr LEFT JOIN clinchedConnectedRoutes AS ccr ON cr.firstRoot = ccr.route AND traveler = '" . $tmuser . "' LEFT JOIN routes ON ccr.route = routes.root LEFT JOIN systems ON routes.systemName = systems.systemName WHERE (systems.level = 'active' OR systems.level = 'preview');"; + $res = tmdb_query($sql_command); $row = $res->fetch_assoc(); $activePreviewDriven = $row['driven']; $activePreviewDrivenPct = $row['drivenPercent']; @@ -145,13 +143,13 @@ $activePreviewClinchedPct = $row['clinchedPercent']; $res->free(); - echo ""; + echo ""; echo ""; echo ""; echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; echo ""; @@ -180,15 +178,19 @@ "; - $res = $db->query($sql_command); + $sql_command = "SELECT rg.country, rg.code, rg.name, co.activeMileage AS clinchedActiveMileage, o.activeMileage AS totalActiveMileage, co.activePreviewMileage AS clinchedActivePreviewMileage, o.activePreviewMileage AS totalActivePreviewMileage FROM overallMileageByRegion AS o INNER JOIN clinchedOverallMileageByRegion AS co ON co.region = o.region INNER JOIN regions AS rg ON rg.code = co.region WHERE co.traveler = '" . $tmuser . "';"; + $res = tmdb_query($sql_command); while ($row = $res->fetch_assoc()) { - $activePercent = round($row['clinchedActiveMileage'] / $row['totalActiveMileage'] * 100.0, 2); - $activePercent = sprintf('%0.2f', $activePercent); + if ( $row['totalActiveMileage'] == 0) { + $activePercent = "0.00"; + } + else { + $activePercent = round($row['clinchedActiveMileage'] / $row['totalActiveMileage'] * 100.0, 2); + $activePercent = sprintf('%0.2f', $activePercent); + } $activePreviewPercent = round($row['clinchedActivePreviewMileage'] / $row['totalActivePreviewMileage'] * 100.0, 2); $activePreviewPercent = sprintf('%0.2f', $activePreviewPercent); - echo ""; + echo ""; } $res->free(); ?> @@ -211,13 +213,11 @@ "; - $res = $db->query($sql_command); + $sql_command = "SELECT sys.countryCode, sys.systemName, sys.level, sys.tier, sys.fullName, r.root, COALESCE(ROUND(SUM(cr.mileage), 2),0) AS clinchedMileage, COALESCE(ROUND(SUM(r.mileage), 2), 0) AS totalMileage, COALESCE(ROUND(SUM(cr.mileage) / SUM(r.mileage) * 100, 2), 0) AS percentage FROM systems AS sys INNER JOIN routes AS r ON r.systemName = sys.systemName LEFT JOIN clinchedRoutes AS cr ON cr.route = r.root AND cr.traveler = '" . $tmuser . "' WHERE (sys.level = 'active' OR sys.level = 'preview') GROUP BY r.systemName;"; + $res = tmdb_query($sql_command); while ($row = $res->fetch_assoc()) { if ($row['clinchedMileage'] == 0) continue; - echo ""; + echo ""; echo ""; echo ""; echo ""; @@ -226,7 +226,7 @@ echo ""; echo ""; echo ""; - echo ""; + echo ""; echo ""; } $res->free(); From 91dd1d71823a5e9867c1e72993f757d89e1627eb Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Wed, 8 Jun 2016 21:57:49 -0400 Subject: [PATCH 31/95] Some stats on main index page. --- index.php | 75 +++++++++++++++++++++++++++++++++++++++++++++- lib/tmphpfuncs.php | 30 +++++++++++++++++++ user/index.php | 3 ++ 3 files changed, 107 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index c8e3e3e5..99a0634e 100644 --- a/index.php +++ b/index.php @@ -1,8 +1,9 @@ - + + Travel Mapping @@ -25,6 +26,44 @@

    +

    Travel Mapping Highway Data

    + +

    + +Travel Mapping currently includes highway data for + + active systems. An additional + + systems are in "preview" status, which means they are substantially +complete, but still undergoing final revisions, and + + more are in development but are not yet complete. Active system +encompass + + routes for + + miles of "clinchable" highways in active systems, and that total is + + routes for + + miles when preview systems are included. + +

    +

    How to Participate

    @@ -35,7 +74,41 @@

    +

    + +Experienced users might also want to volunteer to help the project. +Start by reporting problems with existing highway data. Those who +have learned the project's structure and highway data rules and +guidelines can help greatly by providing review of new highway systems +in development. Most experienced users can learn how to plot new +highway systems under the guidance of experienced contributors. +Again, see the project forum for more information. +

    + + + +

    What's New?

    + +

    +Highway data gets updated almost +daily as corrections are made and progress is made on systems in +development. When a highway system is deemed correct and complete to +the best of our knowledge, it becomes "active". The newest systems to +become active: +

      +fetch_assoc()) { + echo "
    • ".$row['description']." (".$row['systemName'].")
    • \n"; +} +$res->free(); +?> +
    +

    +close(); +?> diff --git a/lib/tmphpfuncs.php b/lib/tmphpfuncs.php index 0eed1dff..9a939b4d 100644 --- a/lib/tmphpfuncs.php +++ b/lib/tmphpfuncs.php @@ -113,5 +113,35 @@ function tm_user_select_form() { echo "

    \n"; } +// function to get a count from a table of rows matching a "where" clause +function tm_count_rows($table, $clause) { + global $tmdb; + $sql_command = "SELECT COUNT(*) AS c FROM ".$table." ".$clause.";"; + global $tmsqldebug; + if ($tmsqldebug) { + echo "\n"; + } + $res = tmdb_query($sql_command); + $row = $res->fetch_assoc(); + $ans = $row['c']; + $res->free(); + return $ans; +} + + +// function to get a sum of a column from a table +function tm_sum_column($table, $column) { + global $tmdb; + $sql_command = "SELECT SUM(".$column.") AS s FROM ".$table.";"; + global $tmsqldebug; + if ($tmsqldebug) { + echo "\n"; + } + $res = tmdb_query($sql_command); + $row = $res->fetch_assoc(); + $ans = $row['s']; + $res->free(); + return $ans; +} ?> diff --git a/user/index.php b/user/index.php index 958d6222..b19c36f2 100644 --- a/user/index.php +++ b/user/index.php @@ -236,4 +236,7 @@ +close(); +?> From 478536e864ce928ce3a207fea92f81e7339280ce Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Wed, 8 Jun 2016 23:28:05 -0400 Subject: [PATCH 32/95] Initial conversion to mysqli. --- user/mapview.php | 71 ++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 41 deletions(-) diff --git a/user/mapview.php b/user/mapview.php index 9e5372a0..91926a9f 100644 --- a/user/mapview.php +++ b/user/mapview.php @@ -1,12 +1,4 @@ - + - + - + + -

    Travel Mapping: Draft Map Overlay Viewer

    -
    -  Show Markers - - - fetch_assoc(); - echo $row['region'] . " " . $row['route']; - if (strlen($row['banner']) > 0) { - echo " " . $row['banner']; - } - if (strlen($row['city']) > 0) { - echo " (" . $row['city'] . ")"; - } - echo ": "; - } else if (array_key_exists("rg", $_GET)) { - echo "Displaying region: " . $_GET['rg'] . "."; - } - ?> - - - -
    +
    +
    +
    +
    Select Route to Display (click a header to sort by that column)
    SystemRegionRoute Name.list NameLevelRoot
    " . $row['systemName'] . "" . $row['region'] . "" . $row['route'] . $row['banner']; From c5adc335384f44a49ab8027f9cce426b48742b72 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Tue, 7 Jun 2016 12:59:33 -0400 Subject: [PATCH 29/95] Some refactoring and HTML validation. --- devel/datacheck.php | 32 ++++++++++------- devel/updates.php | 37 ++++++------------- lib/tmfooter.php | 2 ++ lib/tmheader.php | 2 ++ lib/tmphpfuncs.php | 88 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 121 insertions(+), 40 deletions(-) create mode 100644 lib/tmphpfuncs.php diff --git a/devel/datacheck.php b/devel/datacheck.php index f7f592c2..d6e207e8 100644 --- a/devel/datacheck.php +++ b/devel/datacheck.php @@ -1,23 +1,26 @@ + - + \n"; + if ($tmsqldebug) { + echo "\n"; + } $res = $db->query($sql_command); while ($row = $res->fetch_assoc()) { - echo "
    ".$row['route'].""; + echo "
    ".$row['route'].""; if (strcmp($row['label1'],"") != 0) { echo $row['label1']; } @@ -36,8 +39,9 @@ function writeTable($db, $fpVal, $joins) { $res->free(); } ?> - + + + Travel Mapping Highway Data Datacheck Errors @@ -68,7 +72,7 @@ function writeTable($db, $fpVal, $joins) {
    RouteWaypointsErrorInfoFP Entry to Submit
    @@ -84,7 +88,7 @@ function writeTable($db, $fpVal, $joins) {
    RouteWaypointsErrorInfoFP Entry to Submit
    @@ -95,11 +99,13 @@ function writeTable($db, $fpVal, $joins) { the last column to the datacheck FP list before the system is promoted from 'devel' to - 'preview'.

    + 'preview'. Note: less severe errors, such as distance and angle + errors can be left until final preparation for promotion to + 'active'.

    RouteWaypointsErrorInfoFP Entry to Submit
    @@ -113,13 +119,13 @@ function writeTable($db, $fpVal, $joins) {
    RouteWaypointsErrorInfoFP Entry Matched
    close(); + $tmdb->close(); ?> diff --git a/devel/updates.php b/devel/updates.php index 579d0371..d386e65d 100644 --- a/devel/updates.php +++ b/devel/updates.php @@ -2,29 +2,12 @@ - + - + - - -= 0 && strpos($haystack, $needle, $temp) !== FALSE); - } -?> - + + Travel Mapping Highway Data Updates @@ -57,10 +40,10 @@ function endsWith($haystack, $needle) { query($sql_command); + $res = tmdb_query($sql_command); while ($row = $res->fetch_assoc()) { - echo "
    ".$row['date']."".$row['region']."".$row['systemName']."".$row['description']."".$row['statusChange']."
    ".$row['date']."".$row['region']."".$row['systemName']."".htmlspecialchars($row['description'])."".$row['statusChange']."
    ".$row['date']."".$row['region']."".$row['route']."(NONE)".$row['description']."
    ".$row['date']."".$row['region']."".$row['route']."(NONE)".htmlspecialchars($row['description'])."
    ".$row['date']."".$row['region']."".$row['route']."".$row['root']."".$row['description']."
    ".$row['date']."".$row['region']."".$row['route']."".$row['root']."".htmlspecialchars($row['description'])."
    Miles Driven
    Routes Driven".$activeDriven." of " . $activeRoutes . " (" . $activeDrivenPct . "%) Rank: TBD".$activePreviewDriven." of " . $activePreviewRoutes . " (" . $activePreviewDrivenPct . "%) Rank: TBD
    Routes Clinched".$activeClinched." of " . $activeRoutes . " (" . $activeClinchedPct . "%) Rank: TBD".$activePreviewClinched." of " . $activePreviewRoutes . " (" . $activePreviewClinchedPct . "%) Rank: TBD
    " . $row['country'] . "" . $row['name'] . "" . sprintf('%0.2f', $row['clinchedActiveMileage']) . "" . sprintf('%0.2f', $row['totalActiveMileage']) . "" . $activePercent . "%" . sprintf('%0.2f', $row['clinchedActivePreviewMileage']) . "" . sprintf('%0.2f', $row['totalActivePreviewMileage']) . "" . $activePreviewPercent . "%
    " . $row['country'] . "" . $row['name'] . "" . sprintf('%0.2f', $row['clinchedActiveMileage']) . "" . sprintf('%0.2f', $row['totalActiveMileage']) . "" . $activePercent . "%" . sprintf('%0.2f', $row['clinchedActivePreviewMileage']) . "" . sprintf('%0.2f', $row['totalActivePreviewMileage']) . "" . $activePreviewPercent . "%
    " . $row['countryCode'] . "" . $row['systemName'] . "" . $row['fullName'] . "" . $row['clinchedMileage'] . "" . $row['totalMileage'] . "" . $row['percentage'] . "%
    + + + + + + + + + + + + + + +
    Select Map Options
    +  Show Markers +
    User: + +
    Region(s):
    + +
    System(s):
    + +
    + +
    + +
    @@ -346,8 +355,8 @@ function initFloatingHeaders($table) { } $res = tmdb_query($sql_command); while($row = $res->fetch_assoc()) { - $link = "/devel/hb.php?u=".$_GET['u']."&r=".$row['root']; - echo "
    "; + $link = "/hb?u=".$_GET['u']."&r=".$row['root']; + echo "
    "; //REGION ROUTE BANNER (CITY) echo $row['region'] . " " . $row['route']; if (strlen($row['banner']) > 0) { @@ -363,6 +372,18 @@ function initFloatingHeaders($table) {
    +
    + + + +
    close(); From bcb25ca901d18cbaaac485dc616923d74b469c44 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sat, 11 Jun 2016 07:57:09 -0400 Subject: [PATCH 34/95] Add site update timestamp to main index. --- index.php | 5 ++++- lib/tmphpfuncs.php | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 99a0634e..b0811e18 100644 --- a/index.php +++ b/index.php @@ -94,7 +94,7 @@ daily as corrections are made and progress is made on systems in development. When a highway system is deemed correct and complete to the best of our knowledge, it becomes "active". The newest systems to -become active: +become active:

      free(); ?>
    + +

    +The most recent site update completed at .

    diff --git a/lib/tmphpfuncs.php b/lib/tmphpfuncs.php index 58956d48..d8892470 100644 --- a/lib/tmphpfuncs.php +++ b/lib/tmphpfuncs.php @@ -224,5 +224,22 @@ function tm_qs_multi_or_comma_to_array($param) { return array_diff($array, array("null")); } +// get the timestamp of most recent DB update +function tm_update_time() { + global $tmdb; + global $tmdbname; + $sql_command = "SELECT create_time FROM information_schema.tables WHERE TABLE_SCHEMA = '".$tmdbname."' ORDER BY create_time DESC;"; + global $tmsqldebug; + if ($tmsqldebug) { + echo "\n"; + } + $res = tmdb_query($sql_command); + $row = $res->fetch_assoc(); + $ans = $row['create_time']; + $res->free(); + return $ans; +} + + ?> From 901bfa4113b0c71fc6df93f7ba62f285219d81b0 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sat, 11 Jun 2016 07:57:54 -0400 Subject: [PATCH 35/95] Fix table sorting. --- user/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user/index.php b/user/index.php index b19c36f2..55d02efd 100644 --- a/user/index.php +++ b/user/index.php @@ -44,7 +44,7 @@ - - + - - + - + +> +Select a User and Region to Continue\n"; + echo "\n"; + require $_SERVER['DOCUMENT_ROOT']."/lib/tmfooter.php"; + echo "\n"; + echo "\n"; + exit; +} +?>
    -  Show Markers
    @@ -303,9 +240,10 @@ function redirect($link) { WHERE c.region = '$region' ORDER BY activePercentage DESC; SQL; - $res = mysql_query($sql_command); + $res = tmdb_query($sql_command); $row = fetchWithRank($res, 'activePercentage'); - $link = "redirect('/user/mapview.php?u=" . $user . "&rg=" . $region . "')"; + $res->free(); + $link = "redirect('/user/mapview.php?u=" . $tmuser . "&rg=" . $region . "')"; $activeTotalMileage = $row['totalActiveMileage']; $activeClinchedMileage = $row['activeClinched']; $activeMileagePercentage = $row['activePercentage']; @@ -319,9 +257,10 @@ function redirect($link) { WHERE c.region = '$region' ORDER BY activePreviewPercentage DESC; SQL; - $res = mysql_query($sql_command); + $res = tmdb_query($sql_command); $row = fetchWithRank($res, 'activePreviewPercentage'); - $link = "redirect('/user/mapview.php?u=" . $user . "&rg=" . $region . "')"; + $res->free(); + $link = "redirect('/user/mapview.php?u=" . $tmuser . "&rg=" . $region . "')"; $activePreviewTotalMileage = $row['totalActivePreviewMileage']; $activePreviewClinchedMileage = $row['activePreviewClinched']; $activePreviewMileagePercentage = $row['activePreviewPercentage']; @@ -338,12 +277,11 @@ function redirect($link) { echo "Rank: " . $activePreviewMileageRank . ""; echo ""; -// echo "OverallMiles Driven: ".$row['clinched']." mi (".$row['percentage']."%)Total: ".$row['overall']." miRank: {$row['rank']}"; - // Second, fetch routes clinched/driven - $totalActiveRoutes = mysql_fetch_array(mysql_query("SELECT COUNT(*) as t FROM routes LEFT JOIN systems on routes.systemName = systems.systemName WHERE region = '$region' AND systems.level = 'active'"))['t']; - $totalActivePreviewRoutes = mysql_fetch_array(mysql_query("SELECT COUNT(*) as t FROM routes LEFT JOIN systems on routes.systemName = systems.systemName WHERE region = '$region' AND ".$activeClause." "))['t']; - //error_log("Total Routes: $totalRoutes"); + $totalActiveRoutes = tm_count_rows("routes", "LEFT JOIN systems on routes.systemName = systems.systemName WHERE region = '$region' AND systems.level = 'active'"); + + $totalActivePreviewRoutes = tm_count_rows("routes", "LEFT JOIN systems on routes.systemName = systems.systemName WHERE region = '$region' AND ".$activeClause." "); + $sql_command = <<"; - $res = mysql_query($sql_command); + $res = tmdb_query($sql_command); $row = fetchWithRank($res, 'clinchedPct'); - + $res->free(); $drivenActiveRoutes = $row['driven']; $drivenActiveRoutesPct = $row['drivenPct']; $clinchedActiveRoutes = $row['clinched']; @@ -390,10 +327,9 @@ function redirect($link) { ORDER BY clinchedPct DESC; SQL; - echo ""; - $res = mysql_query($sql_command); + $res = tmdb_query($sql_command); $row = fetchWithRank($res, 'clinchedPct'); - + $res->free(); $drivenActivePreviewRoutes = $row['driven']; $drivenActivePreviewRoutesPct = $row['drivenPct']; $clinchedActivePreviewRoutes = $row['clinched']; @@ -402,20 +338,18 @@ function redirect($link) { - echo ""; + echo ""; echo "Routes Driven"; echo "".$drivenActiveRoutes." of " . $totalActiveRoutes . " (" . $drivenActiveRoutesPct . "%) Rank: TBD"; echo "".$drivenActivePreviewRoutes." of " . $totalActivePreviewRoutes . " (" . $drivenActivePreviewRoutesPct . "%) Rank: TBD"; echo ""; - echo ""; + echo ""; echo "Routes Clinched"; echo "".$clinchedActiveRoutes." of " . $totalActiveRoutes . " (" . $clinchedActiveRoutesPct . "%) Rank: ". $clinchedActiveRoutesRank.""; echo "".$clinchedActivePreviewRoutes." of " . $totalActivePreviewRoutes . " (" . $clinchedActivePreviewRoutesPct . "%) Rank: ". $clinchedActivePreviewRoutesRank.""; echo ""; - -// echo "RoutesDriven: " . $row['driven'] . " (" . $row['drivenPct'] . "%)Clinched: " . $row['clinched'] . " (" . $row['clinchedPct'] . "%)Total: " . $totalRoutes . "Rank: {$row['rank']}\n"; ?> @@ -456,35 +390,34 @@ function redirect($link) { ORDER BY sys.tier, sys.systemName; SQL; - $sql_command = str_replace("xxxxxxxxxxxxxxxxx", $user, $sql_command); + $sql_command = str_replace("xxxxxxxxxxxxxxxxx", $tmuser, $sql_command); $sql_command = str_replace("yyyyyyyyyyyyyyyyy", $region, $sql_command); - echo ""; - $res = mysql_query($sql_command); - while ($row = mysql_fetch_array($res)) { - echo ""; + $res = tmdb_query($sql_command); + while ($row = $res->fetch_assoc()) { + echo ""; echo "" . $row['systemName'] . ""; echo "" . $row['fullName'] . ""; echo "" . $row['clinchedMileage'] . ""; echo "" . $row['totalMileage'] . ""; echo "" . $row['percentage'] . "%"; - echo "HB"; + echo "HB"; } + $res->free(); ?> - + "; - $res = mysql_query($sql_command); - while ($row = mysql_fetch_array($res)) { - echo ""; + $sql_command = "SELECT r.route, r.root, r.banner, r.city, ROUND((COALESCE(r.mileage, 0)),2) AS totalMileage, ROUND((COALESCE(cr.mileage, 0)),2) AS clinchedMileage, COALESCE(ROUND((COALESCE(cr.mileage,0)) / (COALESCE(r.mileage, 0)) * 100,2), 0) AS percentage FROM routes AS r LEFT JOIN clinchedRoutes AS cr ON r.root = cr.route AND traveler = '".$tmuser."' WHERE region = '" . $region . "'"; + $res = tmdb_query($sql_command); + while ($row = $res->fetch_assoc()) { + echo ""; echo ""; echo ""; echo ""; - echo ""; + echo ""; } + $res->free(); ?>
    Stats by Route: (" ?>Full Map)
    Stats by Route: (" ?>Full Map)
    RouteClinched MileageTotal Mileage%Map
    ".$row['route']; if (strlen($row['banner']) > 0) { echo " ".$row['banner']." "; @@ -496,8 +429,9 @@ function redirect($link) { echo "".$row['clinchedMileage']."".$row['totalMileage']."".$row['percentage']."%
    @@ -505,4 +439,4 @@ function redirect($link) {
    - \ No newline at end of file + From 9887292c34c05236e2b8ec750355e628e3dec555 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Mon, 13 Jun 2016 00:01:34 -0400 Subject: [PATCH 39/95] system.php reorg --- lib/tmphpfuncs.php | 45 ++++++ user/region.php | 34 +---- user/system.php | 333 +++++++++++++++------------------------------ 3 files changed, 164 insertions(+), 248 deletions(-) diff --git a/lib/tmphpfuncs.php b/lib/tmphpfuncs.php index 1a2a08b8..835cfa51 100644 --- a/lib/tmphpfuncs.php +++ b/lib/tmphpfuncs.php @@ -194,6 +194,21 @@ function tm_sum_column($table, $column) { return $ans; } +// function to get a sum of a column from a table with a "where" +function tm_sum_column_where($table, $column, $where) { + global $tmdb; + $sql_command = "SELECT SUM(".$column.") AS s FROM ".$table." WHERE ".$where.";"; + global $tmsqldebug; + if ($tmsqldebug) { + echo "\n"; + } + $res = tmdb_query($sql_command); + $row = $res->fetch_assoc(); + $ans = $row['s']; + $res->free(); + return $ans; +} + // Function to retrieve the name of a region by code from the DB function tm_region_code_to_name($code) { global $tmdb; @@ -204,6 +219,16 @@ function tm_region_code_to_name($code) { return $ans; } +// Function to retrieve the name of a system by code from the DB +function tm_system_code_to_name($code) { + global $tmdb; + $res = tmdb_query("SELECT * FROM systems where systemName = '".$code."';"); + $row = $res->fetch_assoc(); + $ans = $row['fullName']; + $res->free(); + return $ans; +} + // Function to get an array of either multiple or comma-separated // qs parameters. // @@ -264,6 +289,26 @@ function tm_update_time() { return $ans; } +// function to find the rank of a given traveler in a SQL result +// ranked by a given field, rank is given in a returned row (an +// associative array) as the value associated with a new key 'rank'. +function tm_fetch_user_row_with_rank($res, $rankBy) { + global $tmuser; + $nextRank = 1; + $rank = 1; + $score = 0; + $row = array(); + while($row['traveler'] != $tmuser && $row = $res->fetch_assoc()) { + if ($score != $row[$rankBy]) { + $score = $row[$rankBy]; + $rank = $nextRank; + } + $nextRank++; + //error_log("($rank, {$row['traveler']}, {$row[$rankBy]})"); + } + $row['rank'] = $rank; + return $row; +} ?> diff --git a/user/region.php b/user/region.php index 8575cd0b..c0af3350 100644 --- a/user/region.php +++ b/user/region.php @@ -80,26 +80,6 @@ } $activeClause = "(systems.level='preview' OR systems.level='active')"; - function fetchWithRank($res, $rankBy) - { - global $tmuser; - $nextRank = 1; - $rank = 1; - $score = 0; - $row = array(); - while($row['traveler'] != $tmuser && $row = $res->fetch_assoc()) { - if ($score != $row[$rankBy]) { - $score = $row[$rankBy]; - $rank = $nextRank; - } - - $nextRank++; - //error_log("($rank, {$row['traveler']}, {$row[$rankBy]})"); - } - $row['rank'] = $rank; - return $row; - } - ?> <?php echo $regionName." - ".$tmuser; ?> - + - + -"> + +> + +Select a User and System to Continue\n"; + echo "
    \n"; + require $_SERVER['DOCUMENT_ROOT']."/lib/tmfooter.php"; + echo "\n"; + echo "\n"; + exit; +} +?>
    -  Show Markers
    @@ -299,17 +208,9 @@ function waypointsFromSQL() { "; - $res = mysql_query($sql_command); - $row = fetchWithRank($res, 'clinchedMileage'); - $percentage = $row['clinchedMileage'] / $systemMileage * 100; - $link = "window.open('/user/mapview.php?u=" . $user . "&sys=" . $system . "')"; - echo ""; + $res = tmdb_query($sql_command); + $row = tm_fetch_user_row_with_rank($res, 'clinchedMileage'); + $res->free(); + $percentage = $row['clinchedMileage'] / $system_mileage * 100; + $link = "window.open('/user/mapview.php?u=" . $user . "&sys=" . $system . "')"; + echo ""; //Second, fetch routes clinched/driven - if (is_null($region)) { - $totalRoutes = mysql_fetch_array(mysql_query("SELECT COUNT(*) as t FROM connectedRoutes WHERE systemName='$system'"))['t']; + if ($region == "") { + $totalRoutes = tm_count_rows("connectedRoutes", "WHERE systemName='".$system."'"); $sql_command = <<"; - $res = mysql_query($sql_command); - $row = fetchWithRank($res, 'clinched'); + $res = tmdb_query($sql_command); + $row = tm_fetch_user_row_with_rank($res, 'clinched'); + $res->free(); echo ""; echo "\n"; ?> @@ -410,23 +302,21 @@ function waypointsFromSQL() { "; - - $res = mysql_query($sql_command); + $res = tmdb_query($sql_command); - while ($row = mysql_fetch_array($res)) { - if (is_null($region)) { - $link = "window.open('/user/mapview.php?u=" . $user . "&rte=" . $row['route'] . "')"; + while ($row = $res->fetch_assoc()) { + if ($region == "") { + $link = "window.open('/user/mapview.php?u=" . $tmuser . "&rte=" . $row['route'] . "')"; } else { - $link = "window.open('/hb?u=" . $user . "&r=" . $row['root'] . "')"; + $link = "window.open('/hb?u=" . $tmuser . "&r=" . $row['root'] . "')"; } echo ""; @@ -439,6 +329,7 @@ function waypointsFromSQL() { echo ""; echo ""; } + $res->free(); ?>
    Miles Driven".sprintf('%0.2f', $row['clinchedMileage'])." of ".sprintf('%0.2f', $systemMileage)." mi (".sprintf('%0.2f',$percentage)."%) Rank: {$row['rank']}
    Miles Driven".sprintf('%0.2f', $row['clinchedMileage'])." of ".sprintf('%0.2f', $system_mileage)." mi (".sprintf('%0.2f',$percentage)."%) Rank: {$row['rank']}
    Routes Driven" . $row['driven'] . " of ".$totalRoutes." (" . round($row['driven'] / $totalRoutes * 100, 2) ."%)
    Routes Clinched" . $row['clinched'] . " of " . $totalRoutes . " (" . round($row['clinched'] / $totalRoutes * 100, 2) . "%) Rank: {$row['rank']}
    " . $row['totalMileage'] . "" . $row['percentage'] . "%
    @@ -446,4 +337,4 @@ function waypointsFromSQL() {
    - \ No newline at end of file + From ead9dda95e5e0808f250b08db5c37dddbde50267 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Mon, 13 Jun 2016 21:19:26 -0400 Subject: [PATCH 40/95] Completed first pass at code reorg/consolidation/cleanup. --- shields/clinched.php | 111 +++++++++++++++++++++++++++---------------- user/region.php | 5 +- user/system.php | 3 ++ 3 files changed, 77 insertions(+), 42 deletions(-) diff --git a/shields/clinched.php b/shields/clinched.php index 571126e3..e1783511 100644 --- a/shields/clinched.php +++ b/shields/clinched.php @@ -1,70 +1,96 @@ - + + + + - Clinched Routes for <?php echo $user ?> + Clinched Routes for <?php echo $tmuser ?> - - + + - -
    + + + - + + />All Traveled + />Clinched Only + - - +
    -

    Clinched Routes for :

    +Traveled Routes for $tmuser: \n"; + } + else { + echo "

    Clinched Routes for $tmuser:

    \n"; + } + +if ( $tmuser == "null") { + echo "

    Select a User to Continue

    \n"; + echo "
    \n"; + require $_SERVER['DOCUMENT_ROOT']."/lib/tmfooter.php"; + echo "\n"; + echo "\n"; + exit; +} +?> = 1)"; + } + else { + $clinched_clause = "AND ccr.clinched = 1"; + $having_clause = "HAVING (sum(ccr.clinched) >= 1)"; + } $sql = <<= 1) + {$having_clause} ORDER BY sys.tier, sys.systemName; SQL; - //echo $sql; - $db->query("SET SESSION group_concat_max_len = 5555555;"); - $res = $db->query($sql); + $tmdb->query("SET SESSION group_concat_max_len = 5555555;"); + $res = tmdb_query($sql); while($row = $res->fetch_assoc()) { - echo "

    {$row['fullName']} ({$row['clinched']} / {$row['total']})

    "; + echo "

    {$row['fullName']}"; + if ($cort == "c") { + echo " ({$row['clinched']} "; + } + else { + echo " ({$row['traveled']} "; + } + echo "/ {$row['total']})

    "; $rootList = explode(",", $row['clinchedRoutes']); $col = 0; foreach($rootList as $root) { - echo "".generate($root, $_GET['reload']).""; + echo "".generate($root, $_GET['reload']).""; $col++; - if ($col > 8) { + if ($col > 20) { echo "
    "; $col = 0; } @@ -75,4 +101,7 @@
    +close(); +?> \ No newline at end of file diff --git a/user/region.php b/user/region.php index c0af3350..0392abf4 100644 --- a/user/region.php +++ b/user/region.php @@ -1,7 +1,7 @@ - - - - + 0) { + $region = $regions[0]; + $regionName = tm_region_code_to_name($region); + } + else { + $region = ""; + $regionName = "No Region Specified"; } - function endsWith($haystack, $needle) - { - // search forward starting from end minus needle length characters - return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE); + $systems = tm_qs_multi_or_comma_to_array("sys"); + if (count($systems) > 0) { + $system = $systems[0]; + $systemName = tm_system_code_to_name($system); + } + else { + $system = ""; + $systemName = "No System Specified"; } + // if a specific route is specified, that's what we'll view if (array_key_exists("r", $_GET)) { - $showingmap = 1; + $routeparam = $_GET['r']; } else { - $showingmap = 0; + $routeparam = ""; } + ?> + + + + + + <?php - if ($showingmap == 1) { + if ($routeparam != "") { $sql_command = "SELECT * FROM routes WHERE root = '" . $_GET['r'] . "'"; - $routeInfo = $db->query($sql_command)->fetch_array(); + $res = tmdb_query($sql_command); + $routeInfo = $res->fetch_array(); + $res->free(); echo $routeInfo['region'] . " " . $routeInfo['route']; if (strlen($routeInfo['banner']) > 0) { echo " " . $routeInfo['banner']; @@ -213,24 +204,27 @@ function waypointsFromSQL() { } ?>Travel Mapping Highway Browser (Draft) +\n"; + require $_SERVER['DOCUMENT_ROOT']."/lib/tmheader.php"; + echo "

    Travel Mapping Highway Browser (Draft)

    "; echo "
    "; echo ""; - echo ""; + tm_system_select(FALSE); echo ""; - echo ""; - echo "
    "; + tm_region_select(FALSE); + echo ""; -} else { +} +else { echo "\n"; + require $_SERVER['DOCUMENT_ROOT']."/lib/tmheader.php"; + } ?> - - -

    Travel Mapping Highway Browser (Draft)

    \n"; echo "" . generate($_GET['r'], true) . ""; - echo "View Associated Routes"; + echo "View Associated Routes"; echo "\n"; - $sql_command = "SELECT pointName, latitude, longitude FROM waypoints WHERE root = '" . $_GET['r'] . "';"; - $res = $db->query($sql_command); + $sql_command = "SELECT pointName, latitude, longitude FROM waypoints WHERE root = '".$routeparam."';"; + $res = tmdb_query($sql_command); $waypointnum = 0; while ($row = $res->fetch_assoc()) { # only visible points should be in this table @@ -298,13 +293,12 @@ function initFloatingHeaders($table) {
    Waypoints
    CoordinatesWaypoint Name
    -  Show Markers - ENDA; - if (array_key_exists("r", $_GET)) { - $sql_command = "SELECT region, route, banner, city FROM routes WHERE root = '" . $_GET['r'] . "';"; - $res = $db->query($sql_command); + if ($routeparam != "") { + echo "
    "; + $sql_command = "SELECT region, route, banner, city FROM routes WHERE root = '" .$routeparam. "';"; + $res = tmdb_query($sql_command); $row = $res->fetch_assoc(); echo $row['region'] . " " . $row['route']; if (strlen($row['banner']) > 0) { @@ -313,33 +307,40 @@ function initFloatingHeaders($table) { if (strlen($row['city']) > 0) { echo " (" . $row['city'] . ")"; } - echo ": "; $res->free(); + echo ""; + echo " Show Markers "; + echo ""; + echo "
    "; + echo "User: "; + tm_user_select(); + echo "
    "; + echo ""; + echo ""; + echo "
    \n"; } echo << -
    ENDB; -} elseif (!is_null($region) or !is_null($system)) { // we have no r=, so we will show a list of all +} elseif (($region != "") or ($system != "")) { // we have no r=, so we will show a list of all $sql_command = "SELECT * FROM routes LEFT JOIN systems ON systems.systemName = routes.systemName"; //check for query string parameter for system and region filters - if (array_key_exists("sys", $_GET) && strlen($_GET["sys"]) > 0) { - $sql_command .= " where routes.systemName = '" . $_GET["sys"] . "'"; - if (array_key_exists("rg", $_GET) && strlen($_GET["rg"]) > 0) { - $sql_command .= "and routes.region = '" . $_GET["rg"] . "'"; + if ($system != "") { + $sql_command .= " WHERE routes.systemName = '" .$system. "'"; + if ($region != "") { + $sql_command .= "AND routes.region = '" .$region. "'"; } - } else if (array_key_exists("rg", $_GET) && strlen($_GET["rg"]) > 0) { - $sql_command .= " where routes.region = '" . $_GET["rg"] . "'"; + } else if ($region != "") { + $sql_command .= " WHERE routes.region = '" .$region. "'"; } $sql_command .= ";"; - echo "\n"; echo "
    \n"; echo "\n"; - $res = $db->query($sql_command); + $res = tmdb_query($sql_command); while ($row = $res->fetch_assoc()) { echo ""; @@ -377,7 +378,7 @@ function initFloatingHeaders($table) { echo "
    Select Route to Display (click a header to sort by that column)
    SystemRegionRoute Name.list NameLevelRoot
    " . $row['systemName'] . "" . $row['region'] . "" . $row['route'] . $row['banner']; if (strcmp($row['city'], "") != 0) { @@ -362,7 +363,7 @@ function initFloatingHeaders($table) { HTML; $sql_command = "SELECT * FROM systems LEFT JOIN countries ON countryCode = countries.code"; - $res = $db->query($sql_command); + $res = tmdb_query($sql_command); while ($row = $res->fetch_assoc()) { $linkJS = "window.open('index.php?sys={$row['systemName']}')"; echo "
    "; } -$db->close(); +$tmdb->close(); ?> diff --git a/index.php b/index.php index b0811e18..a78305d9 100644 --- a/index.php +++ b/index.php @@ -97,9 +97,9 @@ become active:

      fetch_assoc()) { - echo "
    • ".$row['description']." (".$row['systemName'].")
    • \n"; + echo "
    • ".$row['description']." (".$row['systemName']."), ".$row['date']."
    • \n"; } $res->free(); ?> diff --git a/lib/tmphpfuncs.php b/lib/tmphpfuncs.php index 835cfa51..b8c2bea3 100644 --- a/lib/tmphpfuncs.php +++ b/lib/tmphpfuncs.php @@ -310,5 +310,17 @@ function tm_fetch_user_row_with_rank($res, $rankBy) { return $row; } +// functions from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php + +function startsWith($haystack, $needle) { + // search backwards starting from haystack length characters from the end + return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; +} + +function endsWith($haystack, $needle) { + // search forward starting from end minus needle length characters + return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE); +} + ?> diff --git a/shields/clinched.php b/shields/clinched.php index e1783511..321f92b0 100644 --- a/shields/clinched.php +++ b/shields/clinched.php @@ -77,7 +77,7 @@ $tmdb->query("SET SESSION group_concat_max_len = 5555555;"); $res = tmdb_query($sql); while($row = $res->fetch_assoc()) { - echo "

      {$row['fullName']}"; + echo "

      {$row['fullName']}\n"; if ($cort == "c") { echo " ({$row['clinched']} "; } @@ -88,10 +88,10 @@ $rootList = explode(",", $row['clinchedRoutes']); $col = 0; foreach($rootList as $root) { - echo "".generate($root, $_GET['reload']).""; + echo "".generate($root, $_GET['reload'])."\n"; $col++; if ($col > 20) { - echo "
      "; + echo "
      \n"; $col = 0; } } diff --git a/shields/shieldgen.php b/shields/shieldgen.php index 124c17c5..57794f3d 100644 --- a/shields/shieldgen.php +++ b/shields/shieldgen.php @@ -1,16 +1,17 @@ query($sql_command); + $res = tmdb_query($sql_command); $row = $res->fetch_assoc(); + $res->free(); if (file_exists("{$dir}/template_" . $row['systemName'] . ".svg")) { $svg = file_get_contents("{$dir}/template_" . $row['systemName'] . ".svg"); @@ -78,7 +79,6 @@ function generate($r, $force_reload = false) case 'gbnm':case 'nirm': $routeNum = str_replace("M", "", $row['route']); - echo ""; if (strlen($routeNum) > 2) { $svg = file_get_contents("{$dir}/template_gbnm_wide.svg"); } diff --git a/shields/template_usawv.svg b/shields/template_usawv-broken.svg similarity index 100% rename from shields/template_usawv.svg rename to shields/template_usawv-broken.svg diff --git a/shields/template_usawv_wide.svg b/shields/template_usawv_wide-broken.svg similarity index 100% rename from shields/template_usawv_wide.svg rename to shields/template_usawv_wide-broken.svg diff --git a/user/index.php b/user/index.php index 55d02efd..0414bd69 100644 --- a/user/index.php +++ b/user/index.php @@ -143,7 +143,7 @@ $activePreviewClinchedPct = $row['clinchedPercent']; $res->free(); - echo ""; + echo ""; echo "Routes Driven"; echo "".$activeDriven." of " . $activeRoutes . " (" . $activeDrivenPct . "%) Rank: TBD"; echo "".$activePreviewDriven." of " . $activePreviewRoutes . " (" . $activePreviewDrivenPct . "%) Rank: TBD"; From 053eedaef6870d3b0cbc5c475c98e73842f7bedb Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Wed, 15 Jun 2016 10:18:09 -0400 Subject: [PATCH 42/95] Added updateprod script. --- updateprod.csh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 updateprod.csh diff --git a/updateprod.csh b/updateprod.csh new file mode 100644 index 00000000..d008d0dd --- /dev/null +++ b/updateprod.csh @@ -0,0 +1,5 @@ +#!/bin/csh -f +scp *.php blizzard.teresco.org:/home/www/tm/ +foreach dir (user lib devel hb shields) + scp $dir/*.{php,js} blizzard.teresco.org:/home/www/tm/$dir +end From bb30cec2461467b3f2ad37f9c199ee4c5d107858 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Sat, 18 Jun 2016 22:57:00 -0400 Subject: [PATCH 43/95] Added red style to high priority datacheck errors. --- devel/datacheck.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/devel/datacheck.php b/devel/datacheck.php index d6e207e8..4776c64e 100644 --- a/devel/datacheck.php +++ b/devel/datacheck.php @@ -30,7 +30,15 @@ function writeTable($db, $fpVal, $joins) { if (strcmp($row['label3'],"") != 0) { echo ",".$row['label3']; } - echo "".$row['code'].""; + if ((strcmp($row['code'],"VISIBLE_DISTANCE") == 0) || + (strcmp($row['code'],"LONG_DISTANCE") == 0) || + (strcmp($row['code'],"SHARP_ANGLE") == 0)) { + echo "".$row['code'].""; + } + else { + echo "".$row['code'].""; + + } if (strcmp($row['value'],"") != 0) { echo $row['value']; } @@ -84,7 +92,9 @@ function writeTable($db, $fpVal, $joins) { to the datacheck FP list during the final review process to promote a system from 'preview' to 'active'. A system should have no entries - here before activation.

      + here before activation. Errors shown in red should be fixed as soon as possible, while others + can wait until final preparation for system activation.

      Date: Tue, 21 Jun 2016 21:20:52 -0400 Subject: [PATCH 44/95] Minor main index update. --- index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index a78305d9..f3aae802 100644 --- a/index.php +++ b/index.php @@ -80,7 +80,7 @@ Start by reporting problems with existing highway data. Those who have learned the project's structure and highway data rules and guidelines can help greatly by providing review of new highway systems -in development. Most experienced users can learn how to plot new +in development. Highly experienced users can learn how to plot new highway systems under the guidance of experienced contributors. Again, see the project forum for more information.

      @@ -97,7 +97,7 @@ become active:

        fetch_assoc()) { echo "
      • ".$row['description']." (".$row['systemName']."), ".$row['date']."
      • \n"; } From 49dc907d21242abd36771e40475ef1e301dc072e Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Wed, 22 Jun 2016 11:15:59 -0400 Subject: [PATCH 45/95] New link to near match FP log. --- devel/datacheck.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/devel/datacheck.php b/devel/datacheck.php index 4776c64e..70a7e639 100644 --- a/devel/datacheck.php +++ b/devel/datacheck.php @@ -60,11 +60,13 @@ function writeTable($db, $fpVal, $joins) {

        Quick links: [Errors in Active Systems][Errors in Preview Systems][Errors in In-Dev Systems][Errors Marked as FPs].

        -

        See also the [Log of Unmatched -FPs from datacheckfps.csv] and +

        See also the [Log +of Unmatched FPs from datacheckfps.csv] and the [Log of Unprocessed WPTs in the Repository]. Cleaning these up are low priority tasks for the -project.

        +project. Some of these are likely fixable from the information in +the [Log of Near-Match FPs from +datacheckfps.csv].

        From c60c99794b1541cb044252df37a3200e799f51cf Mon Sep 17 00:00:00 2001 From: ovoss Date: Sat, 25 Jun 2016 22:18:06 -0400 Subject: [PATCH 46/95] Northwest Territories updates Fixes dead links in Northwest Territories credits/sources list --- credits.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/credits.php b/credits.php index 65498aaa..b95795e7 100644 --- a/credits.php +++ b/credits.php @@ -125,9 +125,9 @@ -->
      • Northwest Territories, CAN
      • Nova Scotia, CAN From bd49d39038e2d54c6bdb450c14024012066e51de Mon Sep 17 00:00:00 2001 From: ovoss Date: Sat, 25 Jun 2016 23:11:48 -0400 Subject: [PATCH 47/95] Yukon and GPS coordinates updates to credits list Replaces dead link under Yukon with an updated version of an official log book. I also added, under the general references "Path coordinates" (where we link to OSM), an item with no link for coordinates I gathered with my handheld GPS receiver. I'm not sure the new item is correctly formatted, may need a tweak --- credits.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/credits.php b/credits.php index b95795e7..ca1ad59c 100644 --- a/credits.php +++ b/credits.php @@ -28,6 +28,7 @@
      • Path Coordinates
        • OpenStreetMap. Crowd-sourced world highway map. Map data © OpenStreetMap contributors, CC-BY-SA.
        • +
        • Coordinates from handheld GPS receiver. contributed by Oscar Voss (used mainly in Alaska and northern and western Canada)
      • General Highway Maps and Imagery @@ -166,7 +167,7 @@
      • Yukon Territory, CAN
      • Croatia From 9fe9d7b2752ea0415de7edd6b343e00cfce04ad9 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Mon, 27 Jun 2016 13:07:57 -0400 Subject: [PATCH 48/95] Added time zone to main index timestamp. --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index f3aae802..4f22cfc4 100644 --- a/index.php +++ b/index.php @@ -106,7 +106,7 @@

      -The most recent site update completed at . +The most recent site update completed at US/Eastern.

      From cc107d597507490152482aded16df49f2339b00b Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Mon, 27 Jun 2016 13:08:25 -0400 Subject: [PATCH 49/95] Remove JS code not needed by TM. --- hb/index.php | 2 +- lib/tmjsfuncs.js | 430 ++--------------------------------------------- user/mapview.php | 2 +- user/region.php | 2 +- user/system.php | 2 +- 5 files changed, 14 insertions(+), 424 deletions(-) diff --git a/hb/index.php b/hb/index.php index 4a83ce20..35f69de6 100644 --- a/hb/index.php +++ b/hb/index.php @@ -220,7 +220,7 @@ function waypointsFromSQL() { } else { - echo "\n"; + echo "\n"; require $_SERVER['DOCUMENT_ROOT']."/lib/tmheader.php"; } diff --git a/lib/tmjsfuncs.js b/lib/tmjsfuncs.js index 43b8472a..ac5377f4 100644 --- a/lib/tmjsfuncs.js +++ b/lib/tmjsfuncs.js @@ -29,8 +29,7 @@ // 2015-06-17 JDT All highways in region support // 2015-08-19 JDT Fixed a few bugs with infowindows // 2016-05-25 JDT Consolidated some changes from copies of chmviewerfunc3.js -// -// $Id: chmviewerfunc3.js 2535 2015-01-28 18:46:22Z terescoj $ +// 2016-06-27 JDT Removed code not needed by TM // // global variable to hold the map, which will be assigned a google.maps.Map reference @@ -54,8 +53,6 @@ var markerinfo = new Array(); var polypoints = new Array(); // array of connections on map as google.maps.Polyline overlays var connections = new Array(); -// array of graph edges (for graph data) -var graphEdges = new Array(); // array of segments and clinched for "clinched by traveler" mapping var segments = new Array(); var clinched = new Array(); @@ -162,8 +159,11 @@ function loadmap() { var maptypelist = ['MQOpenMap', 'MQOpenSat', 'Mapnik', google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.TERRAIN, 'Blank']; var maptypecontroloptions = {mapTypeIds: maptypelist, position: google.maps.TOP_RIGHT, style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}; //var mapopt = {center: new google.maps.LatLng(42.664529, -73.786470), zoom: 12, mapTypeId: 'Mapnik', mapTypeControl: true, mapTypeControlOptions: maptypecontroloptions, streetViewControl: true, disableDefaultUI: true, panControl: true, zoomControl: true, scaleControl: true, overviewMapControl: true, keyboardShortcuts: true, disableDoubleClickZoom: false}; - // coordinates are Albertus Hall room 400-2 at The College of Saint Rose - var mapopt = {center: new google.maps.LatLng(42.664529, -73.786470), zoom: 16, mapTypeControl: true, mapTypeControlOptions: maptypecontroloptions}; + // OLD coordinates are Albertus Hall room 400-2 at The College of Saint Rose + //var mapopt = {center: new google.maps.LatLng(42.664529, -73.786470), zoom: 16, mapTypeControl: true, mapTypeControlOptions: maptypecontroloptions}; + + // coordinates are Roger Bacon 321 at Siena College + var mapopt = {center: new google.maps.LatLng(42.719450, 73.752063), zoom: 16, mapTypeControl: true, mapTypeControlOptions: maptypecontroloptions}; map = new google.maps.Map(document.getElementById("map"), mapopt); @@ -171,327 +171,6 @@ function loadmap() { map.mapTypes.set('MQOpenSat', typeMQOpenSat); map.mapTypes.set('Mapnik', typeMapnik); map.mapTypes.set('Blank', typeBlank); - - //document.getElementById('showHidden').checked=false; - //var showHidden = document.getElementById('showHidden').checked; - //DBG.write("loadmap: showHidden is " + showHidden); - - // check for a load query string parameter - //var qs = location.search.substring(1); - //DBG.write("qs: " + qs); - //var qsitems = qs.split('&'); - //for (var i = 0; i < qsitems.length; i++) { - //DBG.write("qsitems[" + i + "] = " + qsitems[i]); - //var qsitem = qsitems[i].split('='); - //DBG.write("qsitem[0] = " + qsitem[0]); - //if (qsitem[0] == "load") { - //var request = new XMLHttpRequest(); - //DBG.write("qsitem[1] = " + qsitem[1]); - //document.getElementById('filename').innerHTML = qsitem[1]; - //request.open("GET", qsitem[1], false); - //request.setRequestHeader("User-Agent", navigator.userAgent); - //request.send(null); - //if (request.status == 200) { - //processContents(request.responseText); - //} - //} - //} - waypointsFromSQL(); // function inserted by PHP in the index.php file - updateMap(); -} - -// when a file is selected, this will be called -function startRead() { - // first, retrieve the selected file (as a File object) - var file = document.getElementById('file').files[0]; - if (file) { - document.getElementById('filename').innerHTML = file.name; - if ((file.name.indexOf(".wpt") == -1) && - (file.name.indexOf(".pth") == -1) && - (file.name.indexOf(".nmp") == -1) && - (file.name.indexOf(".gra") == -1) && - (file.name.indexOf(".wpl") == -1)) { - document.getElementById('pointbox').innerHTML = "Unrecognized file type!"; - return; - } - document.getElementById('pointbox').innerHTML = - "Loading... (" + file.size + " bytes)"; - var reader; - try { - reader = new FileReader(); - } - catch(e) { - document.getElementById('pointbox').innerHTML = - "Error: unable to access file (Perhaps no browser support? Try recent Firefox or Chrome releases.)."; - return; - } - reader.readAsText(file, "UTF-8"); - reader.onload = fileLoaded; - //reader.onerror = fileLoadError; - } -} - - -// when the FileReader created in startRead has finished, this will be called -// to process the contents of the file -function fileLoaded(event) { - - // file done loading, read the contents - processContents(event.target.result); -} - -// process the contents of a String which came from a file or elsewhere -function processContents(fileContents) { - - // place the contents into the file contents area (will improve later) - document.getElementById('pointbox').innerHTML = "
      " + fileContents + "
      "; - - var pointboxContents = ""; - - // parse the file and process as appropriate - var fileName = document.getElementById('filename').innerHTML; - if (fileName.indexOf(".wpt") >= 0) { - document.getElementById('filename').innerHTML = fileName + " (Waypoint File)"; - pointboxContents = parseWPTContents(fileContents); - } - else if (fileName.indexOf(".pth") >= 0) { - document.getElementById('filename').innerHTML = fileName + " (Waypoint Path File)"; - pointboxContents = parsePTHContents(fileContents); - } - else if (fileName.indexOf(".nmp") >= 0) { - document.getElementById('filename').innerHTML = fileName + " (Near-Miss Point File)"; - pointboxContents = parseNMPContents(fileContents); - } - else if (fileName.indexOf(".wpl") >= 0) { - document.getElementById('filename').innerHTML = fileName + " (Waypoint List File)"; - pointboxContents = parseWPLContents(fileContents); - } - else if (fileName.indexOf(".gra") >= 0) { - document.getElementById('filename').innerHTML = fileName + " (Highway Graph File)"; - pointboxContents = parseGRAContents(fileContents); - } - - document.getElementById('pointbox').innerHTML = pointboxContents; - updateMap(); - -} - -// in case we get an error from the FileReader -function errorHandler(evt) { - - if (evt.target.error.code == evt.target.error.NOT_READABLE_ERR) { - // The file could not be read - document.getElementById('filecontents').innerHTML = "Error reading file..."; - } -} - -// parse the contents of a .gra file -// -// First line specifies the number of vertices, numV, and the number -// of edges, numE -// Next numV lines are a waypoint name (a String) followed by two -// floating point numbers specifying the latitude and longitude -// Next numE lines are vertex numbers (based on order in the file) -// that are connected by an edge followed by a String listing the -// highway names that connect those points -function parseGRAContents(fileContents) { - - var lines = fileContents.replace(/\r\n/g,"\n").split('\n'); - var counts = lines[0].split(' '); - var numV = parseInt(counts[0]); - var numE = parseInt(counts[1]); - var sideInfo = '

      ' + numV + " waypoints, " + numE + " connections.

      "; - - var vTable = '
      RouteWaypointsErrorInfoFP Entry to Submit
      '; - - waypoints = new Array(numV); - for (var i = 0; i < numV; i++) { - var vertexInfo = lines[i+1].split(' '); - waypoints[i] = new Waypoint(vertexInfo[0], vertexInfo[1], vertexInfo[2], "", ""); - vTable += '" - } - vTable += '
      Waypoints
      #CoordinatesWaypoint Name
      ' + i + - '(' + parseFloat(vertexInfo[1]).toFixed(3) + ',' + - parseFloat(vertexInfo[2]).toFixed(3) + ')' - + "" - + waypoints[i].label + "
      '; - - var eTable = ''; - graphEdges = new Array(numE); - for (var i = 0; i < numE; i++) { - var edgeInfo = lines[i+numV+1].split(' '); - graphEdges[i] = new GraphEdge(edgeInfo[0], edgeInfo[1], edgeInfo[2]); - eTable += ''; - } - eTable += '
      Connections
      #Route Name(s)Endpoints
      ' + i + '' + edgeInfo[2] + '' - + edgeInfo[0] + ': ' + waypoints[graphEdges[i].v1].label + - ' ↔ ' + edgeInfo[1] + ': ' - + waypoints[graphEdges[i].v2].label + '
      '; - genEdges = false; - return sideInfo + vTable + '

      ' + eTable; -} - -// parse the contents of a .wpt file -// -// Consists of a series of lines each containing a waypoint name -// and an OSM URL for that point's location: -// -/* -YT1_S http://www.openstreetmap.org/?lat=60.684924&lon=-135.059652 -MilCanRd http://www.openstreetmap.org/?lat=60.697199&lon=-135.047250 -+5 http://www.openstreetmap.org/?lat=60.705383&lon=-135.054932 -4thAve http://www.openstreetmap.org/?lat=60.712623&lon=-135.050619 -*/ -function parseWPTContents(fileContents) { - - var lines = fileContents.replace(/\r\n/g,"\n").split('\n'); - graphEdges = new Array(); - waypoints = new Array(); - for (var i = 0; i < lines.length; i++) { - if (lines[i].length > 0) { - waypoints[waypoints.length] = WPTLine2Waypoint(lines[i]); - } - } - genEdges = true; - return "

      Raw file contents:

      " + fileContents + "
      "; -} - -// parse the contents of a .pth file -// -// Consists of a series of lines each containing a waypoint name and a -// latitude and a longitude, and a route name, all space-separated, or -// a line containing a waypoint name followed by a lat,lng pair in -// parens, followed by a route name -// -/* -START YT1_S 60.684924 135.059652 -YT2 MilCanRd 60.697199 135.047250 -YT2 +5 60.705383 135.054932 -YT2 4thAve 60.712623 135.050619 - -or - -START YT1_S (60.684924,135.059652) -YT2 MilCanRd (60.697199,135.047250) -YT2 +5 (60.705383,135.054932) -YT2 4thAve (60.712623,135.050619) - -*/ -function parsePTHContents(fileContents) { - - var table = ''; - var lines = fileContents.replace(/\r\n/g,"\n").split('\n'); - graphEdges = new Array(); - waypoints = new Array(); - var totalMiles = 0.0; - var segmentMiles = 0.0; - for (var i = 0; i < lines.length; i++) { - if (lines[i].length > 0) { - waypoints[waypoints.length] = PTHLine2Waypoint(lines[i]); - if (waypoints.length > 1) { // make sure we are not at the first - segmentMiles = Mileage(waypoints[waypoints.length-2].lat, - waypoints[waypoints.length-2].lon, - waypoints[waypoints.length-1].lat, - waypoints[waypoints.length-1].lon); - totalMiles += segmentMiles; - } - table += ''; - } - } - table += '
      RouteTo PointSeg.
      Miles
      Cumul.
      Miles
      ' + waypoints[waypoints.length-1].elabel + - "" + waypoints[waypoints.length-1].label + - '' + segmentMiles.toFixed(2) + - '' + totalMiles.toFixed(2) + - '
      '; - genEdges = true; - return table; -} - -// parse the contents of a .nmp file -// -// Consists of a series of lines, each containing a waypoint name -// followed by two floating point numbers representing the point's -// latitude and longitude -// -// Entries are paired as "near-miss" points, and a graph edge is -// added between each pair for viewing. -// -function parseNMPContents(fileContents) { - - var table = ''; - // all lines describe waypoints - var lines = fileContents.replace(/\r\n/g,"\n").split('\n'); - waypoints = new Array(); - for (var i = 0; i < lines.length; i++) { - if (lines[i].length > 0) { - var xline = lines[i].split(' '); - if (xline.length == 3) { - waypoints[waypoints.length] = new Waypoint(xline[0], xline[1], xline[2], "", ""); - } - } - } - // graph edges between pairs, will be drawn as connections - var numE = waypoints.length/2; - graphEdges = new Array(numE); - for (var i = 0; i < numE; i++) { - // add the edge - graphEdges[i] = new GraphEdge(2*i, 2*i+1, ""); - - // add an entry to the table to be drawn in the pointbox - var miles = Mileage(waypoints[2*i].lat, waypoints[2*i].lon, waypoints[2*i+1].lat, waypoints[2*i+1].lon).toFixed(4); - var feet = Feet(waypoints[2*i].lat, waypoints[2*i].lon, waypoints[2*i+1].lat, waypoints[2*i+1].lon).toFixed(2); - table += ""; - } - - table += "
      " - + "
      " - + "" - + waypoints[2*i].label + "(" - + waypoints[2*i].lat + "," - + waypoints[2*i].lon + ")
      " - + "" - + waypoints[2*i+1].label + "(" - + waypoints[2*i+1].lat + "," - + waypoints[2*i+1].lon + ")
      " - + miles + " mi/" - + feet + " ft
      "; - genEdges = false; - return table; -} - -// parse the contents of a .wpl file -// -// Consists of a series of lines, each containing a waypoint name -// followed by two floating point numbers representing the point's -// latitude and longitude -// -function parseWPLContents(fileContents) { - - var table = ''; - // all lines describe waypoints - var lines = fileContents.replace(/\r\n/g,"\n").split('\n'); - waypoints = new Array(); - for (var i = 0; i < lines.length; i++) { - if (lines[i].length > 0) { - var xline = lines[i].split(' '); - if (xline.length == 3) { - waypoints[waypoints.length] = new Waypoint(xline[0], xline[1], xline[2], "", ""); - } - } - } - // no edges here - graphEdges = new Array(); - genEdges = false; - return "

      Raw file contents:

      " + fileContents + "
      "; } // construct a new Waypoint object (based on similar function by Tim Reichard) @@ -513,81 +192,6 @@ function CopyWaypoint(wpt) { return new Waypoint(wpt.label, wpt.lat, wpt.lon, wpt.errors, wpt.elabel); } -function WPTLine2Waypoint(line) { - - // remove extraneous spaces in the line - line = line.replace(' ', ' '); - line = line.replace(' ', ' '); - line = line.replace(' ', ' '); - line = line.replace(' ', ' '); - - var xline = line.split(' '); - if (xline.length < 2) { - return Waypoint('bad-line', 0, 0); - } - var label = xline[0]; - var url = xline[1]; - var latlon = Url2LatLon(url); - return new Waypoint(label, latlon[0], latlon[1], 0, ""); -} - -// convert an openstreetmap URL to a latitude/longitude -function Url2LatLon(url) { - - var latlon = new Array(0., 0.); - var floatpattern = '([-+]?[0-9]*\.?[0-9]+)'; - var latpattern = 'lat=' + floatpattern; - var lonpattern = 'lon=' + floatpattern; - - //search for lat - var matches = url.match(latpattern); - if (matches != null) { - latlon[0] = parseFloat(matches[1]).toFixed(6); - } - - //search for lon - matches = url.match(lonpattern); - if (matches != null) { - latlon[1] = parseFloat(matches[1]).toFixed(6); - } - - return latlon; -} - -function PTHLine2Waypoint(line) { - - // remove any extraneous spaces in the line - line = line.replace(' ', ' '); - line = line.replace(' ', ' '); - line = line.replace(' ', ' '); - line = line.replace(' ', ' '); - - var xline = line.split(' '); - // check for and convert a (lat,lng) format - if ((xline.length == 3) && - (xline[2].charAt(0) == '(') && - (xline[2].indexOf(',') > 0) && - (xline[2].charAt(xline[2].length-1) == ')')) { - newlatlng = xline[2].replace('(', ''); - newlatlng = newlatlng.replace(',', ' '); - newlatlng = newlatlng.replace(')', ''); - return PTHLine2Waypoint(xline[0] + " " + xline[1] + " " + newlatlng); - } - if (xline.length < 4) { - return Waypoint('bad-line', 0, 0); - } - return new Waypoint(xline[1], xline[2], xline[3], 0, xline[0]); -} - - -function GraphEdge(v1, v2, label) { - - this.v1 = parseInt(v1); - this.v2 = parseInt(v2); - this.label = label; - return this; -} - // update the map to the current set of waypoints and connections function updateMap() { @@ -647,22 +251,8 @@ function updateMap() //map.setZoom(zoom); map.fitBounds(bounds); - // if this is a graph, we draw edges as connections, - // otherwise we may be connecting waypoints in order - // to plot a path - if (graphEdges.length > 0) { - for (var i = 0; i < graphEdges.length; i++) { - var edgePoints = new Array(2); - var v1 = graphEdges[i].v1; - var v2 = graphEdges[i].v2; - // DBG.write("Adding edge " + i + " from " + v1 + "(" + waypoints[v1].lat + "," + waypoints[v1].lon + ") to " + v2 + "(" + waypoints[v2].lat + "," + waypoints[v2].lon + ")"); - edgePoints[0] = new google.maps.LatLng(waypoints[v1].lat, waypoints[v1].lon); - edgePoints[1] = new google.maps.LatLng(waypoints[v2].lat, waypoints[v2].lon); - connections[i] = new google.maps.Polyline({path: edgePoints, strokeColor: "#0000FF", strokeWeight: 10, strokeOpacity: 0.4, map: map}); - //map.addOverlay(connections[i]); - } - } - else if (mapClinched) { + // connecting waypoints in order to plot a path + if (mapClinched) { // clinched vs unclinched segments mapped with different colors var nextClinchedCheck = 0; var totalMiles = 0.0; @@ -771,8 +361,8 @@ function updateMap() connections[0] = new google.maps.Polyline({path: polypoints, strokeColor: "#0000FF", strokeWeight: 10, strokeOpacity: 0.75, map: map}); //map.addOverlay(connections[0]); } - // don't think this should not be needed, but an attempt to get hidden waypoints - // to be hidden when first created + // don't think this should not be needed, but an attempt to get + // hidden waypoints to be hidden when first created showHiddenClicked(); } diff --git a/user/mapview.php b/user/mapview.php index 5eb98dc2..a83f5bff 100644 --- a/user/mapview.php +++ b/user/mapview.php @@ -234,7 +234,7 @@ function waypointsFromSQL() { Travel Mapping: Draft Map Overlay Viewer - + @@ -365,7 +365,7 @@ function initFloatingHeaders($table) { $sql_command = "SELECT * FROM systems LEFT JOIN countries ON countryCode = countries.code"; $res = tmdb_query($sql_command); while ($row = $res->fetch_assoc()) { - $linkJS = "window.open('index.php?sys={$row['systemName']}')"; + $linkJS = "window.open('hb/index.php?sys={$row['systemName']}')"; echo ""; if (strlen($row['name']) > 15) { echo ""; diff --git a/lib/tmphpfuncs.php b/lib/tmphpfuncs.php index b8c2bea3..fa50ef3f 100644 --- a/lib/tmphpfuncs.php +++ b/lib/tmphpfuncs.php @@ -28,6 +28,10 @@ $tmdbpasswd = "clinch"; $tmdbhost = "localhost"; +// Google Maps API Key +// FIXME: Change to project-specific key (this is my (Thing342's) personal key) +$gmaps_api_key = 'AIzaSyDAKyOlyGyVeWVEaMqRmWkYQh-5RkwhUY0'; + if (array_key_exists("dbname", $_GET)) { $tmdbname = $_GET['dbname']; } diff --git a/user/mapview.php b/user/mapview.php index 8f298ee5..2703033d 100644 --- a/user/mapview.php +++ b/user/mapview.php @@ -1,4 +1,5 @@ + @@ -107,7 +108,7 @@ function orClauseBuilder($param, $name, $tablename = 'r') { ?> - + diff --git a/user/system.php b/user/system.php index 0350b2b3..d790030c 100644 --- a/user/system.php +++ b/user/system.php @@ -81,7 +81,7 @@ echo " - ".$tmuser; ?> From 309bd08558d497fea7c3151b18e1226525dcd2d1 Mon Sep 17 00:00:00 2001 From: Thing342 Date: Mon, 4 Jul 2016 08:37:09 -0400 Subject: [PATCH 61/95] #47 Fixed WV Shields --- shields/{template_usawv-broken.svg => template_usawv.svg} | 0 shields/template_usawv_wide-broken.svg | 1 - shields/template_usawv_wide.svg | 1 + 3 files changed, 1 insertion(+), 1 deletion(-) rename shields/{template_usawv-broken.svg => template_usawv.svg} (100%) delete mode 100644 shields/template_usawv_wide-broken.svg create mode 100644 shields/template_usawv_wide.svg diff --git a/shields/template_usawv-broken.svg b/shields/template_usawv.svg similarity index 100% rename from shields/template_usawv-broken.svg rename to shields/template_usawv.svg diff --git a/shields/template_usawv_wide-broken.svg b/shields/template_usawv_wide-broken.svg deleted file mode 100644 index 675bb997..00000000 --- a/shields/template_usawv_wide-broken.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/shields/template_usawv_wide.svg b/shields/template_usawv_wide.svg new file mode 100644 index 00000000..8935cd49 --- /dev/null +++ b/shields/template_usawv_wide.svg @@ -0,0 +1 @@ +***NUMBER*** \ No newline at end of file From fba9a666fc33297e1b6f8b33189b644cc7f083dd Mon Sep 17 00:00:00 2001 From: Thing342 Date: Mon, 4 Jul 2016 11:32:26 -0400 Subject: [PATCH 62/95] #53 Added system tier and root columns to region.php for better sorting --- user/region.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/user/region.php b/user/region.php index 44c6eacd..7d8125a5 100644 --- a/user/region.php +++ b/user/region.php @@ -161,7 +161,7 @@ function waypointsFromSQL() { "; + echo "Please go to {$redir_url} if you are not automatically redirected."; + exit(); } ?> From e5eded978b50b82f82e4025581f59239d190e89b Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Mon, 4 Jul 2016 23:03:24 -0400 Subject: [PATCH 66/95] Move DB info and API key to a config file on the server. --- lib/tmphpfuncs.php | 16 +++++++++------- updatetest.csh | 5 +++++ 2 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 updatetest.csh diff --git a/lib/tmphpfuncs.php b/lib/tmphpfuncs.php index fa50ef3f..e98a50cc 100644 --- a/lib/tmphpfuncs.php +++ b/lib/tmphpfuncs.php @@ -21,16 +21,18 @@ */ // always attempt to establish a connection to the db, allow QS parameters -// to override defaults +// to override defaults, which come from the 5 lines of tm.conf (which +// is not in source code control to protect the information there) -$tmdbname = "TravelMapping"; -$tmdbuser = "travmap"; -$tmdbpasswd = "clinch"; -$tmdbhost = "localhost"; +$tmconffile = fopen($_SERVER['DOCUMENT_ROOT']."/lib/tm.conf", "r"); +$tmdbname = chop(fgets($tmconffile)); +$tmdbuser = chop(fgets($tmconffile)); +$tmdbpasswd = chop(fgets($tmconffile)); +$tmdbhost = chop(fgets($tmconffile)); // Google Maps API Key -// FIXME: Change to project-specific key (this is my (Thing342's) personal key) -$gmaps_api_key = 'AIzaSyDAKyOlyGyVeWVEaMqRmWkYQh-5RkwhUY0'; +$gmaps_api_key = chop(fgets($tmconffile)); +fclose($tmconffile); if (array_key_exists("dbname", $_GET)) { $tmdbname = $_GET['dbname']; diff --git a/updatetest.csh b/updatetest.csh new file mode 100644 index 00000000..e759477a --- /dev/null +++ b/updatetest.csh @@ -0,0 +1,5 @@ +#!/bin/csh -f +scp *.php blizzard.teresco.org:/home/www/tmtest/ +foreach dir (user lib devel hb shields) + scp $dir/*.{php,js,svg} blizzard.teresco.org:/home/www/tmtest/$dir +end From 639779e57458463f13b5b459808ec47eb814b4ea Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Mon, 4 Jul 2016 23:23:42 -0400 Subject: [PATCH 67/95] More info about new config file. --- lib/tmphpfuncs.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/tmphpfuncs.php b/lib/tmphpfuncs.php index e98a50cc..631562d9 100644 --- a/lib/tmphpfuncs.php +++ b/lib/tmphpfuncs.php @@ -23,6 +23,14 @@ // always attempt to establish a connection to the db, allow QS parameters // to override defaults, which come from the 5 lines of tm.conf (which // is not in source code control to protect the information there) +// +// IMPORTANT: this file should also not be accessible through the +// web server, using an entry like: +// +// +// Require all denied +// + $tmconffile = fopen($_SERVER['DOCUMENT_ROOT']."/lib/tm.conf", "r"); $tmdbname = chop(fgets($tmconffile)); From 316b524d34e311d01049d1d2ca193461b44d5e5f Mon Sep 17 00:00:00 2001 From: Thing342 Date: Tue, 5 Jul 2016 22:04:59 -0400 Subject: [PATCH 68/95] Fixed #88. --- hb/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hb/index.php b/hb/index.php index 6e33769c..09fe95a1 100644 --- a/hb/index.php +++ b/hb/index.php @@ -211,7 +211,7 @@ function waypointsFromSQL() { echo "\n"; require $_SERVER['DOCUMENT_ROOT']."/lib/tmheader.php"; echo "

      Travel Mapping Highway Browser (Draft)

      "; - echo ""; + echo ""; echo ""; tm_system_select(FALSE); echo ""; @@ -311,7 +311,7 @@ function initFloatingHeaders($table) { echo "
      \n"; + echo "\n"; } $res->free(); echo "
      {$row['code']} "; echo " Show Markers "; echo ""; - echo ""; + echo ""; echo "User: "; tm_user_select(); echo ""; @@ -346,7 +346,7 @@ function initFloatingHeaders($table) { if (strcmp($row['city'], "") != 0) { echo " (" . $row['city'] . ")"; } - echo "" . $row['region'] . " " . $row['route'] . $row['banner'] . $row['abbrev'] . "" . $row['level'] . "" . $row['root'] . "
      " . $row['region'] . " " . $row['route'] . $row['banner'] . $row['abbrev'] . "" . $row['level'] . "" . $row['root'] . "

    \n"; @@ -365,7 +365,7 @@ function initFloatingHeaders($table) { $sql_command = "SELECT * FROM systems LEFT JOIN countries ON countryCode = countries.code"; $res = tmdb_query($sql_command); while ($row = $res->fetch_assoc()) { - $linkJS = "window.open('hb/index.php?sys={$row['systemName']}')"; + $linkJS = "window.open('/hb/index.php?sys={$row['systemName']}')"; echo ""; if (strlen($row['name']) > 15) { echo "{$row['code']}"; From e7d0b082eb5c21d53c1961c1aeee3510aec2470d Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Tue, 5 Jul 2016 23:13:18 -0400 Subject: [PATCH 69/95] Color coding of concurrency levels for HDX. --- lib/tmjsfuncs.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/tmjsfuncs.js b/lib/tmjsfuncs.js index 31d60d47..41aac527 100644 --- a/lib/tmjsfuncs.js +++ b/lib/tmjsfuncs.js @@ -310,7 +310,31 @@ function updateMap() } } edgePoints[nextPoint] = new google.maps.LatLng(waypoints[thisEdge.v2].lat, waypoints[thisEdge.v2].lon); - connections[edgeNum] = new google.maps.Polyline({path: edgePoints, strokeColor: "#0000FF", strokeWeight: 10, strokeOpacity: 0.4, map: map}); + // count the commas, which tell us how many + // concurrent routes are represented, as they will + // be comma-separated, then use that to choose a + // color to indicate the number of routes + // following the edge + concurrent = thisEdge.label.split(",").length; + color = ""; + switch (concurrent) { + case 1: + color = "#0000FF"; + break; + case 2: + color = "#00FF00"; + break; + case 3: + color = "#FF00FF"; + break; + case 4: + color = "#FFFF00"; + break; + default: + color = "#FF0000"; + break; + } + connections[edgeNum] = new google.maps.Polyline({path: edgePoints, strokeColor: color, strokeWeight: 10, strokeOpacity: 0.4, map: map}); edgeNum++; } } From 26a7554e8db63e869673d781cf2660b461a14337 Mon Sep 17 00:00:00 2001 From: Jim Teresco Date: Wed, 6 Jul 2016 21:01:58 -0400 Subject: [PATCH 70/95] Fixes to stat.php --- login.php | 13 ------------- stat.php | 34 ++++++++++++++-------------------- updateprod.csh | 4 ++-- updatetest.csh | 4 ++-- 4 files changed, 18 insertions(+), 37 deletions(-) delete mode 100644 login.php diff --git a/login.php b/login.php deleted file mode 100644 index 78e929c3..00000000 --- a/login.php +++ /dev/null @@ -1,13 +0,0 @@ - \ No newline at end of file diff --git a/stat.php b/stat.php index 3800190d..b79b2d59 100644 --- a/stat.php +++ b/stat.php @@ -1,7 +1,4 @@ - - + +

    + +Some experienced users volunteer to help the project. If this +interests you, start by reporting problems with existing highway data. +Those who have learned the project's structure and highway data rules +and guidelines can help greatly by providing review of new highway +systems in development. Highly experienced users can learn how to +plot new highway systems under the guidance of experienced +contributors. Again, see the project forum for +more information. +

    -

    What's New?

    +

    What's New with Highway Data?

    -Highway data gets updated almost -daily as corrections are made and progress is made on systems in +Highway data is updated almost daily +as corrections are made and progress is made on systems in development. When a highway system is deemed correct and complete to -the best of our knowledge, it becomes "active". The newest systems to -become active:

    +the best of our knowledge, it becomes "active". Here are the newest +systems to become active, with their activation dates:

      Date: Thu, 7 Jul 2016 15:39:37 -0400 Subject: [PATCH 72/95] Added red banner for DB update in progress message. --- css/travelMapping.css | 17 +++++++++++++++++ index.php | 3 +++ lib/tmheader.php | 12 ++++++++++++ 3 files changed, 32 insertions(+) diff --git a/css/travelMapping.css b/css/travelMapping.css index 640edb72..0de458a5 100644 --- a/css/travelMapping.css +++ b/css/travelMapping.css @@ -241,6 +241,23 @@ table.gratable tr.float th { text-decoration: underline; } +/* the errorbar when a DB update is in progress */ +.errorbar { + font-size: 14pt; + font-style: normal; + font-family: sans-serif; + text-align: center; + position: relative; + padding-right: 8px; + padding-bottom: 2px; + margin-top: 0px; + margin-bottom: 8px; + height: auto; + background: #FF0000; + color: #ffffff; + border: 3px solid #101080; +} + .main { width: 758px; } diff --git a/index.php b/index.php index b1715084..dd6f9ea7 100644 --- a/index.php +++ b/index.php @@ -30,6 +30,9 @@

      "; +} if (file_exists($_SERVER['DOCUMENT_ROOT']."/motd")) { $tmmotdfile = fopen($_SERVER['DOCUMENT_ROOT']."/motd", "r"); if ($tmmotdfile) { diff --git a/lib/tmheader.php b/lib/tmheader.php index 27556cea..e645d071 100644 --- a/lib/tmheader.php +++ b/lib/tmheader.php @@ -22,4 +22,16 @@ Updates

      + +Travel Mapping database update in progress. Some functionality might +not work. Please try again in a few minutes if you notice problems. +

      +END; +} +?> + From b53e4c1d04969c780b1b26fee6ed2c50d7133c26 Mon Sep 17 00:00:00 2001 From: Thing342 Date: Thu, 7 Jul 2016 23:17:38 -0400 Subject: [PATCH 73/95] Added information for current user in stat.php --- stat.php | 220 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 147 insertions(+), 73 deletions(-) diff --git a/stat.php b/stat.php index b79b2d59..8aa8b7e9 100644 --- a/stat.php +++ b/stat.php @@ -1,4 +1,4 @@ - + - - - - - - -Traveler Statistics + + + + + + + Traveler Statistics - + - -

      Traveler Statistics

      - - - -
      - - - - - - - +

      Traveler Statistics

      +
      Traveler Mileage in Active Systems
      RankUsernameMiles Traveled%
      +

      \n"; + echo "\n"; + tm_user_select(); + echo "\n"; + echo "

      \n"; + }else{ + echo << +HTML; + } + ?> + + - + +
      + + + + + +HTML; + echo ""; + $sql = <<{$row['traveler']}"; + echo ""; + echo ""; + + $sql = <<{$row['clinchedMileage']} / {$totalPreviewMileage} ({$row['percentage']}%)"; + echo ""; + echo << +
      Current User
      UserActive MileageRankActive + Preview MileageRank
      {$row['clinchedMileage']} / {$totalMileage} ({$row['percentage']}%){$row['rank']}{$row['rank']}
      +
      + + + + + + + + + + + + + + fetch_assoc()) { - if($row['traveler'] == $tmuser) { - $highlight = 'user-highlight'; - } else { - $highlight = ''; - } - echo <<fetch_assoc()) { + if ($row['traveler'] == $tmuser) { + $highlight = 'user-highlight'; + } else { + $highlight = ''; + } + echo << HTML; - $rank++; - } - $res->free(); + $rank++; + } + $res->free(); - ?> - -
      Traveler Mileage in Active Systems
      RankUsernameMiles Traveled%
      {$rank}{$row['traveler']}{$row['clinchedMileage']}{$row['percentage']}%
      -
      - - - - - - - + +
      Traveler Mileage in Active and Preview Systems
      RankUsernameMiles Traveled%
      +
      + + + + + + + + + + + + + + fetch_assoc()) { - if($row['traveler'] == $tmuser) { - $highlight = 'user-highlight'; - } else { - $highlight = ''; - } - echo <<fetch_assoc()) { + if ($row['traveler'] == $tmuser) { + $highlight = 'user-highlight'; + } else { + $highlight = ''; + } + echo << HTML; - $rank++; - } - $res->free(); + $rank++; + } + $res->free(); - ?> - -
      Traveler Mileage in Active and Preview Systems
      RankUsernameMiles Traveled%
      {$rank}{$row['traveler']}{$row['clinchedMileage']}{$row['percentage']}%
      + ?> +
      + + - + \ No newline at end of file From 01e5f2d23bcf65e9db99fff80be19d9712c76d5b Mon Sep 17 00:00:00 2001 From: Thing342 Date: Thu, 7 Jul 2016 23:18:31 -0400 Subject: [PATCH 74/95] Removed unneeded SQL columns and fixed grouping errors --- user/index.php | 17 +++++++++++++++-- user/region.php | 1 - user/system.php | 1 - 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/user/index.php b/user/index.php index 0414bd69..c9da7d90 100644 --- a/user/index.php +++ b/user/index.php @@ -61,6 +61,7 @@
      fetch_assoc()) { if ( $row['totalActiveMileage'] == 0) { @@ -213,7 +226,7 @@ fetch_assoc()) { if ($row['clinchedMileage'] == 0) continue; diff --git a/user/region.php b/user/region.php index 44051785..ad9dcbf4 100644 --- a/user/region.php +++ b/user/region.php @@ -356,7 +356,6 @@ function redirect($link) { sys.tier, sys.level AS status, sys.fullName, - r.root, COALESCE(ROUND(SUM(cr.mileage), 2), 0) AS clinchedMileage, COALESCE(ROUND(SUM(r.mileage), 2), 0) AS totalMileage, COALESCE(ROUND(SUM(cr.mileage) / SUM(r.mileage) * 100, 2), 0) AS percentage diff --git a/user/system.php b/user/system.php index 38c780db..ef8c4f6c 100644 --- a/user/system.php +++ b/user/system.php @@ -237,7 +237,6 @@ function waypointsFromSQL() { FROM clinchedSystemMileageByRegion WHERE systemName = '$system' AND region = '$region' - GROUP BY traveler ORDER BY clinchedMileage DESC; SQL; } From 50ce0ca7439d6b0713af541bb8363583c396fd2e Mon Sep 17 00:00:00 2001 From: Thing342 Date: Sat, 9 Jul 2016 11:39:53 -0400 Subject: [PATCH 75/95] Fixed #92 and improved mapview table sorting --- lib/jquery.tablesorter.min.js | 2 +- user/mapview.php | 78 ++++++++++++++++++++++++++++------- 2 files changed, 64 insertions(+), 16 deletions(-) diff --git a/lib/jquery.tablesorter.min.js b/lib/jquery.tablesorter.min.js index b8605df1..d3ff4308 100644 --- a/lib/jquery.tablesorter.min.js +++ b/lib/jquery.tablesorter.min.js @@ -1,4 +1,4 @@ (function($){$.extend({tablesorter:new function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:true,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:'/\.|\,/g',onRenderHeader:null,selectorHeaders:'thead th',debug:false};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}if(table.tBodies.length==0)return;var rows=table.tBodies[0].rows;if(rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function checkHeaderOptionsSortingLocked(table,i){if((table.config.headers[i])&&(table.config.headers[i].lockedOrder))return table.config.headers[i].lockedOrder;return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;i b["+i+"]) ? 1 : 0));";};function makeSortTextDesc(i){return"((b["+i+"] < a["+i+"]) ? -1 : ((b["+i+"] > a["+i+"]) ? 1 : 0));";};function makeSortNumeric(i){return"a["+i+"]-b["+i+"];";};function makeSortNumericDesc(i){return"b["+i+"]-a["+i+"];";};function sortText(a,b){if(table.config.sortLocaleCompare)return a.localeCompare(b);return((ab)?1:0));};function sortTextDesc(a,b){if(table.config.sortLocaleCompare)return b.localeCompare(a);return((ba)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$.data(this,"tablesorter",config);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){$this.trigger("sortStart");var $cell=$(this);var i=this.column;this.order=this.count++%2;if(this.lockedOrder)this.order=this.lockedOrder;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function checkHeaderOptionsSortingLocked(table,i){if((table.config.headers[i])&&(table.config.headers[i].lockedOrder))return table.config.headers[i].lockedOrder;return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;i b["+i+"]) ? 1 : 0));";};function makeSortTextDesc(i){return"((b["+i+"] < a["+i+"]) ? -1 : ((b["+i+"] > a["+i+"]) ? 1 : 0));";};function makeSortNumeric(i){return"a["+i+"]-b["+i+"];";};function makeSortNumericDesc(i){return"b["+i+"]-a["+i+"];";};function sortText(a,b){if(table.config.sortLocaleCompare)return a.localeCompare(b);return((ab)?1:0));};function sortTextDesc(a,b){if(table.config.sortLocaleCompare)return b.localeCompare(a);return((ba)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$.data(this,"tablesorter",config);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){$this.trigger("sortStart");var $cell=$(this);var i=this.column;this.order=this.count++%2;if(this.lockedOrder)this.order=this.lockedOrder;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i - + - + + fetch_assoc()) { $link = "/hb?u=".$_GET['u']."&r=".$row['root']; - echo "\n"; + echo << + + \n"; } ?> From 2fd8ea5cef9f27f470fe09c95e11eedb08e43ceb Mon Sep 17 00:00:00 2001 From: Thing342 Date: Sat, 9 Jul 2016 16:08:16 -0400 Subject: [PATCH 76/95] Implementation of #42 and site-wide improvements to user selection --- hb/index.php | 8 +++++--- lib/tmphpuser.php | 3 ++- stat.php | 2 +- user/index.php | 1 + user/system.php | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hb/index.php b/hb/index.php index 09fe95a1..c8f7c166 100644 --- a/hb/index.php +++ b/hb/index.php @@ -1,3 +1,4 @@ + + + + + Date: Sat, 22 Oct 2016 09:05:27 -0400 Subject: [PATCH 94/95] Updated credits from @michihdeu by email. --- credits.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/credits.php b/credits.php index 8ad61ebf..3b0accb0 100644 --- a/credits.php +++ b/credits.php @@ -220,7 +220,7 @@
    • Germany
      • Autobahn-Atlas. Hobbyist site by Patrick Scholl covering the detailed routings and plans for German motorways.
      • -
      • Road Construction. German motorway construction plans and maps from the Federal Minsitry of Transport, Building and Urban Development.
      • +
      • Road Construction. German motorway construction plans and maps from the Federal Minsitry of Transport, Building and Urban Development.
    • Greece @@ -360,6 +360,11 @@
    • System of Autonomous Highways. Road maps and video highway log from the Galicia Directorate of Intrastructure.
    • +
    • Sweden + +
    • Switzerland
      • List of Motorways and Expressways. Legislative highway definitions for the national highway network of Switzerland.
      • From 2a6459835829fadd97699adaba2cef18978ed289 Mon Sep 17 00:00:00 2001 From: Si Hollett Date: Wed, 2 Nov 2016 12:55:26 +0000 Subject: [PATCH 95/95] change unclinched "lightsalmon" changing it from gray to something more pink --- lib/tmjsfuncs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tmjsfuncs.js b/lib/tmjsfuncs.js index 97925322..e2c2825c 100644 --- a/lib/tmjsfuncs.js +++ b/lib/tmjsfuncs.js @@ -76,7 +76,7 @@ colorCodes[3] = { name: "yellow", unclinched: "rgb(255,255,128)", clinched: "rgb colorCodes[4] = { name: "teal", unclinched: "rgb(100,200,200)", clinched: "rgb(0,200,200)" }; colorCodes[5] = { name: "green", unclinched: "rgb(100,255,100)", clinched: "rgb(0,255,0)" }; colorCodes[6] = { name: "magenta", unclinched: "rgb(255,100,255)", clinched: "rgb(255,0,255)" }; -colorCodes[7] = { name: "lightsalmon", unclinched: "rgb(200,200,200)", clinched: "rgb(255,160,122)" }; +colorCodes[7] = { name: "lightsalmon", unclinched: "rgb(255,200,200)", clinched: "rgb(255,160,122)" }; // array of custom color codes to be pulled from query string parameter "colors=" var customColorCodes = new Array();
    • RouteSystemClinchedOverall%
      RouteSystemClinchedOverall%
      "; + echo "
      "; //REGION ROUTE BANNER (CITY) echo $row['region'] . " " . $row['route']; if (strlen($row['banner']) > 0) { @@ -361,7 +404,12 @@ function initFloatingHeaders($table) { echo " (" . $row['city'] . ")"; } $pct = sprintf("%0.2f",( $row['clinched'] / $row['total'] * 100) ); - echo "".$row['clinched']."".$row['total']."".$pct."%
      +HTML +.$row['clinched']."".$row['total']."".$pct."%
      DUMMY000000000.00%