Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.48 KB | None | 0 0
  1. <?php
  2.     header("Content-Type: text/html; charset=utf-8");
  3.     $from = $_GET["from"];
  4.     $to = $_GET["to"];
  5.     $date = $_GET["date"];
  6.  
  7.     $data = array(
  8.         "station_from" => $from,
  9.         "station_till" => $to,
  10.         "date_dep" => $date,
  11.     );
  12.     $resultUZ = shell_exec("python uz.py " . escapeshellarg(json_encode($data)));
  13.  
  14.     $resultDataUZ = json_decode($resultUZ, true);
  15.  
  16.     $resultBus = shell_exec("python bus.py " . escapeshellarg(json_encode($data)));
  17.  
  18.     $resultDataBus = json_decode($resultBus, true);
  19. ?>
  20. <!DOCTYPE html>
  21. <html>
  22. <head>
  23.     <meta charset="UTF-8">
  24.     <title>Результати</title>
  25.     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  26.     <style type="text/css">
  27.     td {
  28.         vertical-align: middle !important;
  29.         text-align: center !important;
  30.     }
  31.    
  32.     th {
  33.         text-align: center !important;
  34.     }
  35.     </style>
  36. </head>
  37. <body>
  38.     <div class="container">
  39.         <div class="row" style="margin-top: 10px;">
  40.             <table class="table table-bordered table-condensed table-responsive">
  41.                 <caption>tickets.bus.com.ua</caption>
  42.                 <thead>
  43.                     <tr>
  44.                         <th>Назва маршруту</th>
  45.                         <th>Звідки / Куди</th>
  46.                         <th>Відправлення</th>
  47.                         <th>Прибуття</th>
  48.                         <th>Ціна</th>
  49.                     </tr>
  50.                 </thead>
  51.                 <tbody>
  52.                     <?php
  53.                         $i=0;
  54.                         while($resultDataBus[$i])
  55.                         {
  56.                             echo "<tr>";
  57.                             echo "<td>".mb_convert_case(mb_strtolower(implode(" ", $resultDataBus[$i]["trip_number_name"]), "UTF-8"), MB_CASE_TITLE, "UTF-8")."</td>";
  58.                             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>";
  59.                             echo "<td><b>".$resultDataBus[$i]["time_from"][0]."</b></td>";
  60.                             echo "<td><b>".$resultDataBus[$i]["time_to"][0]."</b></td>";
  61.                             echo "<td>".$resultDataBus[$i]["price"][0]."</td>";
  62.                             echo "</tr>";
  63.                             $i=$i+1;
  64.                         }
  65.                     ?>
  66.                 </tbody>
  67.             </table>
  68.             <table class="table table-bordered table-condensed table-responsive">
  69.                 <caption>booking.uz.gov.ua</caption>
  70.                 <thead>
  71.                     <tr>
  72.                         <th>№ поїзда</th>
  73.                         <th>Звідки / Куди</th>
  74.                         <th>Відправлення</th>
  75.                         <th>Прибуття</th>
  76.                         <th>Тривалість</th>
  77.                         <th colspan="2">Місця</th>
  78.                     </tr>
  79.                 </thead>
  80.                 <tbody>
  81.                     <?php
  82.                         $i=0;
  83.                         while($resultDataUZ["value"][$i])
  84.                         {
  85.                             echo "<tr>";
  86.                             echo "<td rowspan=\"".count($resultDataUZ["value"][$i]["types"])."\">".$resultDataUZ["value"][$i]["num"]."</td>";  // Номер поїзда
  87.                             echo "<td rowspan=\"".count($resultDataUZ["value"][$i]["types"])."\">".$resultDataUZ["value"][$i]["from"]["station"]." / ".$resultDataUZ["value"][$i]["till"]["station"]."</td>";  // Відправлення / Прибуття
  88.                             echo "<td class=\"date_departure\" rowspan=\"".count($resultDataUZ["value"][$i]["types"])."\">".$resultDataUZ["value"][$i]["from"]["src_date"]."</td>";  // Час відправлення
  89.                             echo "<td class=\"date_arrival\" rowspan=\"".count($resultDataUZ["value"][$i]["types"])."\">".$resultDataUZ["value"][$i]["till"]["src_date"]."</td>";  // Час прибуття
  90.                             echo "<td rowspan=\"".count($resultDataUZ["value"][$i]["types"])."\">".$resultDataUZ["value"][$i]["travel_time"]."</td>";  // Тривалість подорожі
  91.  
  92.                             $j=0;
  93.                             while($resultDataUZ["value"][$i]["types"][$j])
  94.                             {
  95.                                 if ($j >= 1) {
  96.                                     echo "<tr>";
  97.                                     echo "<td>".$resultDataUZ["value"][$i]["types"][$j]["title"]."</td>";  // Тип місця
  98.                                     echo "<td>".$resultDataUZ["value"][$i]["types"][$j]["places"]."</td>";  // Місце
  99.                                     echo "</tr>";
  100.                                 } else {
  101.                                     echo "<td>".$resultDataUZ["value"][$i]["types"][$j]["title"]."</td>";  // Тип місця
  102.                                     echo "<td>".$resultDataUZ["value"][$i]["types"][$j]["places"]."</td>";  // Місце
  103.                                 }
  104.                                 $j=$j+1;
  105.                             }
  106.                             echo "</tr>";
  107.                             $i=$i+1;
  108.                         }
  109.                     ?>
  110.                 </tbody>
  111.             </table>
  112.         </div>
  113.     </div>
  114.     </div>
  115.  
  116.     <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
  117.     <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/locale/uk.js"></script>
  118.     <script>
  119.     moment.locale('uk');
  120.  
  121.     for (var i = 0; i < document.getElementsByClassName("date_departure").length; i++) {
  122.         document.getElementsByClassName("date_departure")[i].innerHTML = moment(document.getElementsByClassName("date_departure")[i].innerHTML).format("dddd, DD.MM.YYYY<br><b>HH:mm</b>");
  123.     }
  124.     for (var i = 0; i < document.getElementsByClassName("date_arrival").length; i++) {
  125.         document.getElementsByClassName("date_arrival")[i].innerHTML = moment(document.getElementsByClassName("date_arrival")[i].innerHTML).format("dddd, DD.MM.YYYY<br><b>HH:mm</b>");
  126.     }
  127.     </script>
  128. </body>
  129. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement