|
|
|
@ -0,0 +1,94 @@
|
|
|
|
|
<?php /*
|
|
|
|
|
Copyright © 2021 Pk11
|
|
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
copy of this software and associated documentation files (the “Software”),
|
|
|
|
|
to deal in the Software without restriction, including without limitation
|
|
|
|
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
DEALINGS IN THE SOFTWARE.
|
|
|
|
|
*/ ?>
|
|
|
|
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="ja">
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="utf-8">
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
|
|
|
|
|
|
<title>NexTrip停留所の情報</title>
|
|
|
|
|
|
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<?php $stop = $_GET['stop']; ?>
|
|
|
|
|
|
|
|
|
|
<header>
|
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
|
|
|
|
<div class="container-fluid">
|
|
|
|
|
<span class="navbar-brand">NexTrip停留所の情報</span>
|
|
|
|
|
</div>
|
|
|
|
|
</nav>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<main class="mt-3">
|
|
|
|
|
<div class="container-fluid">
|
|
|
|
|
<div class="row">
|
|
|
|
|
<div class="col-12">
|
|
|
|
|
<form>
|
|
|
|
|
<div class="input-group mb-3">
|
|
|
|
|
<label for="stop" class="input-group-text">停留所</label>
|
|
|
|
|
<input type="text" id="stop" name="stop" class="form-control" value="<?php echo $stop; ?>">
|
|
|
|
|
<input type="submit" class="btn btn-outline-secondary">
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
if(empty($stop)) {
|
|
|
|
|
echo '<h2 class="alert alert-info">以上で停留所の番号を入力してください。</h2>';
|
|
|
|
|
} else if(preg_match("/[^\\d]/", $stop)) {
|
|
|
|
|
echo "<h2 class=\"alert alert-danger\">{$stop}は無効な停留所です。</h2>";
|
|
|
|
|
} else {
|
|
|
|
|
$directions = [
|
|
|
|
|
"NB" => "北行",
|
|
|
|
|
"EB" => "東行",
|
|
|
|
|
"SB" => "南行",
|
|
|
|
|
"WB" => "西行"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$content = file_get_contents("https://svc.metrotransit.org/NexTrip/$stop?format=json");
|
|
|
|
|
$json = json_decode($content);
|
|
|
|
|
|
|
|
|
|
if(!$json) {
|
|
|
|
|
echo "<h2 class=\"alert alert-danger\">{$stop}は無効な停留所です。</h2>";
|
|
|
|
|
} else {
|
|
|
|
|
echo "<h2>停留所{$stop}のNexTrip情報</h2>";
|
|
|
|
|
echo '<div class="row row-cols-2 row-cols-md-4 row-cols-lg-6">';
|
|
|
|
|
foreach($json as $bus) {
|
|
|
|
|
echo '<div class="col">';
|
|
|
|
|
echo "<p><span class=\"fw-bold\">$bus->Route{$bus->Terminal}番線({$directions[$bus->RouteDirection]})</span><br>";
|
|
|
|
|
echo "$bus->DepartureText</p>";
|
|
|
|
|
echo '</div>';
|
|
|
|
|
}
|
|
|
|
|
echo '</div>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
</div>
|
|
|
|
|
</main>
|
|
|
|
|
|
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|