Frezi2005

Untitled

May 4th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. <html>
  2. <head>
  3. <link href="style.css" rel="stylesheet">
  4. <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
  5. </head>
  6. </html>
  7.  
  8. <?php
  9. // require the Faker autoloader
  10. require_once 'vendor/fzaninotto/faker/src/autoload.php';
  11. require_once __DIR__ . '/vendor/autoload.php';
  12. // alternatively, use another PSR-4 compliant autoloader
  13.  
  14. // use the factory to create a Faker\Generator instance
  15. $faker = Faker\Factory::create();
  16. // $date = new DateTime('now');
  17. // $now = $date->format('Y-m-d H:i:s');
  18. $startDeparture = strtotime("10 September 2009");
  19. $endDeparture = strtotime("10 July 2010");
  20. $startArrival = strtotime("30 September 2010");
  21. $endArrival = strtotime("15 July 2011");
  22. $departureOptional = date('Y-m-d', mt_rand($startDeparture, $endDeparture));
  23. $arrivalOptional = date('Y-m-d', mt_rand($startArrival, $endArrival));
  24. $departure = $faker->date;
  25. $arrival = $faker->date;
  26. $price = rand(100, 4000);
  27. $flightTime = abs(strtotime($departure) - strtotime($arrival));
  28. $flightTime = $flightTime/(60 * 60);
  29. $flightTimeOptional = abs(strtotime($departureOptional) - strtotime($arrivalOptional));
  30. $flightTimeOptional = $flightTimeOptional/(60 * 60);
  31. $list = file_get_contents("airports.json");
  32. $airportsList = json_decode($list, true);
  33. $airport1 = rand(0, count($airportsList) - 1);
  34. $airport2 = rand(0, count($airportsList) - 1);
  35. $tz = $airportsList[$airport2][tz];
  36. $arrivalTime = $faker->dateTime('now', $tz);
  37.  
  38. function planeTicketGenerator($faker, $price, $flightTime, $flightTimeOptional, $departure, $arrival, $departureOptional, $arrivalOptional, $airport1, $airport2, $airportsList, $arrivalTime) {
  39. echo <<<END
  40. <table>
  41. <tr style="background-color: #a8d8ff">
  42. <td colspan="3" style="text-align:left;">TICKETS IN REAL PRICE</td>
  43. </tr>
  44. <tr>
  45. <td style="width:220px;"></td>
  46. <td><img src="BoeingLogo.png" alt="BoeingLogo" style="width:200px;"/></td>
  47. <td><img src="AirPlaneLogo.png" alt="AirPlaneLogo" style="width:200px;"/></td>
  48. </tr>
  49. <tr style="height:50px;background-color: #93cfff;">
  50. END;
  51. print("<td>From: ".$airportsList[$airport1][country].", ".$airportsList[$airport1][city]."</td>");
  52. print("<td>To: ".$airportsList[$airport2][country].", ".$airportsList[$airport2][city]."</td>");
  53. print("<td>Arrival time: ".$arrivalTime."</td>");
  54. echo <<<END
  55. </tr>
  56. <tr style="background-color: #93cfff;">
  57. END;
  58.  
  59. print("<td>From: ".$airportsList[$airport1][name]."</td>");
  60. print("<td>To: ".$airportsList[$airport2][name]."</td>");
  61. echo "<td>Price: $price $faker->currencyCode</td>
  62. </tr>
  63. <tr style='background-color: #93cfff;height:50px;'>";
  64.  
  65. if ($departure < $arrival) {
  66. echo "<td>Departure: $departure</td>";
  67. echo "<td>Arrival: $arrival</td>";
  68. echo "<td>Flight time(in Hours): $flightTime</td>";
  69. } else {
  70. echo "<td>Departure: $departureOptional</td>";
  71. echo "<td>Arrival: $arrivalOptional</td>";
  72. echo "<td>Flight time(in Hours): $flightTimeOptional</td>";
  73. }
  74. echo <<<END
  75. </tr>
  76. <tr>
  77. <td>Flight with the airline: Ryanair</td>
  78. <td colspan="2">Passenger surname: $faker->firstName $faker->lastName</td>
  79. </tr>
  80. </table>
  81. END;
  82.  
  83. }
  84.  
  85. planeTicketGenerator($faker, $price, $flightTime, $flightTimeOptional, $departure, $arrival, $departureOptional, $arrivalOptional, $airport1, $airport2, $airportsList, $arrivalTime);
  86.  
  87. // $now
  88. // <br />
  89. // From: $faker->city To: $faker->city
  90. // <br />
  91. // Departure: $faker->date Arrival: $faker->date
  92. // <br />
  93. // Name: $faker->firstName Surname: $faker->lastName
  94. // <br />
  95. // Adress: $faker->streetAddress
  96. // <br />
  97. // Price: $price
  98. ?>
Advertisement
Add Comment
Please, Sign In to add comment