Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header("Content-Type: text/html; charset=utf-8");
- $from = $_GET["from"];
- $to = $_GET["to"];
- $date = $_GET["date"];
- $data = array(
- "station_from" => $from,
- "station_till" => $to,
- "date_dep" => $date,
- );
- $resultUZ = shell_exec("python uz.py " . escapeshellarg(json_encode($data)));
- $resultDataUZ = json_decode($resultUZ, true);
- $resultBus = shell_exec("python bus.py " . escapeshellarg(json_encode($data)));
- $resultDataBus = json_decode($resultBus, true);
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Результати</title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
- <style type="text/css">
- td {
- vertical-align: middle !important;
- text-align: center !important;
- }
- th {
- text-align: center !important;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="row" style="margin-top: 10px;">
- <table class="table table-bordered table-condensed table-responsive">
- <caption>tickets.bus.com.ua</caption>
- <thead>
- <tr>
- <th>Назва маршруту</th>
- <th>Звідки / Куди</th>
- <th>Відправлення</th>
- <th>Прибуття</th>
- <th>Ціна</th>
- </tr>
- </thead>
- <tbody>
- <?php
- $i=0;
- while($resultDataBus[$i])
- {
- echo "<tr>";
- echo "<td>".mb_convert_case(mb_strtolower(implode(" ", $resultDataBus[$i]["trip_number_name"]), "UTF-8"), MB_CASE_TITLE, "UTF-8")."</td>";
- echo "<td>".mb_convert_case(mb_strtolower($resultDataBus[$i]["city_from"][0], "UTF-8"), MB_CASE_TITLE, "UTF-8")." / ".mb_convert_case(mb_strtolower($resultDataBus[$i]["time_to"][1], "UTF-8"), MB_CASE_TITLE, "UTF-8")."</td>";
- echo "<td><b>".$resultDataBus[$i]["time_from"][0]."</b></td>";
- echo "<td><b>".$resultDataBus[$i]["time_to"][0]."</b></td>";
- echo "<td>".$resultDataBus[$i]["price"][0]."</td>";
- echo "</tr>";
- $i=$i+1;
- }
- ?>
- </tbody>
- </table>
- <table class="table table-bordered table-condensed table-responsive">
- <caption>booking.uz.gov.ua</caption>
- <thead>
- <tr>
- <th>№ поїзда</th>
- <th>Звідки / Куди</th>
- <th>Відправлення</th>
- <th>Прибуття</th>
- <th>Тривалість</th>
- <th colspan="2">Місця</th>
- </tr>
- </thead>
- <tbody>
- <?php
- $i=0;
- while($resultDataUZ["value"][$i])
- {
- echo "<tr>";
- echo "<td rowspan=\"".count($resultDataUZ["value"][$i]["types"])."\">".$resultDataUZ["value"][$i]["num"]."</td>"; // Номер поїзда
- echo "<td rowspan=\"".count($resultDataUZ["value"][$i]["types"])."\">".$resultDataUZ["value"][$i]["from"]["station"]." / ".$resultDataUZ["value"][$i]["till"]["station"]."</td>"; // Відправлення / Прибуття
- echo "<td class=\"date_departure\" rowspan=\"".count($resultDataUZ["value"][$i]["types"])."\">".$resultDataUZ["value"][$i]["from"]["src_date"]."</td>"; // Час відправлення
- echo "<td class=\"date_arrival\" rowspan=\"".count($resultDataUZ["value"][$i]["types"])."\">".$resultDataUZ["value"][$i]["till"]["src_date"]."</td>"; // Час прибуття
- echo "<td rowspan=\"".count($resultDataUZ["value"][$i]["types"])."\">".$resultDataUZ["value"][$i]["travel_time"]."</td>"; // Тривалість подорожі
- $j=0;
- while($resultDataUZ["value"][$i]["types"][$j])
- {
- if ($j >= 1) {
- echo "<tr>";
- echo "<td>".$resultDataUZ["value"][$i]["types"][$j]["title"]."</td>"; // Тип місця
- echo "<td>".$resultDataUZ["value"][$i]["types"][$j]["places"]."</td>"; // Місце
- echo "</tr>";
- } else {
- echo "<td>".$resultDataUZ["value"][$i]["types"][$j]["title"]."</td>"; // Тип місця
- echo "<td>".$resultDataUZ["value"][$i]["types"][$j]["places"]."</td>"; // Місце
- }
- $j=$j+1;
- }
- echo "</tr>";
- $i=$i+1;
- }
- ?>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/locale/uk.js"></script>
- <script>
- moment.locale('uk');
- for (var i = 0; i < document.getElementsByClassName("date_departure").length; i++) {
- document.getElementsByClassName("date_departure")[i].innerHTML = moment(document.getElementsByClassName("date_departure")[i].innerHTML).format("dddd, DD.MM.YYYY<br><b>HH:mm</b>");
- }
- for (var i = 0; i < document.getElementsByClassName("date_arrival").length; i++) {
- document.getElementsByClassName("date_arrival")[i].innerHTML = moment(document.getElementsByClassName("date_arrival")[i].innerHTML).format("dddd, DD.MM.YYYY<br><b>HH:mm</b>");
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement