BilkaPek

main_index.php

Sep 7th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.10 KB | None | 0 0
  1. <?php
  2.     /**
  3.      * @Project: Virtual Airlines Manager (VAM)
  4.      * @Author: Alejandro Garcia
  5.      * @Web http://virtualairlinesmanager.net
  6.      * Copyright (c) 2013 - 2016 Alejandro Garcia
  7.      * VAM is licensed under the following license:
  8.      *   Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
  9.      *   View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/4.0/
  10.      */
  11. ?>
  12. <?php
  13.     include ('./vam_index_header.php');
  14.     include ('./helpers/conversions.php');
  15.     if (!isset($_GET["page"]) || trim($_GET["page"]) == "") {
  16.         ?>
  17.         <?php
  18.             $sql = 'select callsign, arrival, departure, flight_status, name, surname, pending_nm, plane_type from vam_live_flights vf, gvausers gu where gu.gvauser_id = vf.gvauser_id ';
  19.             if (!$result = $db->query($sql)) {
  20.                 die('There was an error running the query [' . $db->error . ']');
  21.             }
  22.             $row_cnt = $result->num_rows;
  23.             $sql = "SELECT flight_id FROM `vam_live_flights` WHERE UNIX_TIMESTAMP (now())-UNIX_TIMESTAMP (last_update)>180";
  24.             if (!$result = $db->query($sql)) {
  25.                 die('There was an error running the query [' . $db->error . ']');
  26.             }
  27.             while ($row = $result->fetch_assoc())
  28.             {
  29.                 $sql_inner = "delete from vam_live_acars where flight_id='".$row["flight_id"]."'";
  30.                 if (!$result_acars = $db->query($sql_inner))
  31.                 {
  32.                 die('There was an error running the query [' . $db->error . ']');
  33.                 }
  34.                 $sql_inner = "delete from vam_live_flights where flight_id='".$row["flight_id"]."'";
  35.                 if (!$result_acars = $db->query($sql_inner))
  36.                 {
  37.                 die('There was an error running the query [' . $db->error . ']');
  38.                 }
  39.             }
  40.             if ($row_cnt>0){
  41.         ?>
  42.         <div class="row" id="live_flights">
  43.             <div class="col-md-12">
  44.                 <div class="panel panel-default">
  45.                     <div class="panel-heading">
  46.                         <h3 class="panel-title"><IMG src="images/icons/ic_flight_takeoff_white_18dp_1x.png">&nbsp;<?php echo "LIVE FIGHTS" ?></h3>
  47.                     </div>
  48.                     <div class="panel-body">
  49.                         <div class="table-responsive">
  50.                             <table class="table table-hover" id="live_flights_table">
  51.                             <?php
  52.                                     echo "<tr><th>" . LF_CALLSIG . "</th><th>" . LF_PILOT . "</th><th>" . LF_DEPARTURE . "</th><th>" . LF_ARRIVAL . "</th><th>" . FLIGHT_STAGE . "</th><th>". BOOK_ROUTE_ARICRAFT_TYPE . "</th><th>" . PERC_DONE ."</th><th>" . PENDING_NM . "</th></tr>";
  53.                             ?>
  54.                             </table>
  55.                         <?php include ('./vam_live_flights_map.php') ?>
  56.                     </div>
  57.                 </div>
  58.             </div>
  59.         </div>
  60.         <?php
  61.         }
  62.         ?>
  63.         <div class="row">
  64.             <div class="col-md-8">
  65.                 <div class="panel panel-default">
  66.                     <div class="panel-heading">
  67.                         <h3 class="panel-title"><IMG src="images/icons/ic_chat_white_18dp_1x.png">&nbsp;<?php echo WELCOME_VA . ' ' . $va_name; ?></h3>
  68.                     </div>
  69.                     <div class="panel-body">
  70.                         <?php
  71.                             $db = new mysqli($db_host , $db_username , $db_password , $db_database);
  72.                             $db->set_charset("utf8");
  73.                             if ($db->connect_errno > 0) {
  74.                                 die('Unable to connect to database [' . $db->connect_error . ']');
  75.                             }
  76.                             $sql = "select welcome_text from web_configurations";
  77.                             if (!$result = $db->query($sql)) {
  78.                                 die('There was an error running the query [' . $db->error . ']');
  79.                             }
  80.                             while ($row = $result->fetch_assoc()) {
  81.                                         echo $row["welcome_text"];
  82.                             }
  83.                         ?>
  84.                     </div>
  85.                 </div>
  86.             </div>
  87.             <div class="col-md-4">
  88.                 <div class="panel panel-default">
  89.                     <div class="panel-heading">
  90.                         <h3 class="panel-title"><IMG src="images/icons/ic_equalizer_white_18dp_1x.png">&nbsp;<?php echo STATISTICS_VA; ?></h3>
  91.                     </div>
  92.                     <div class="panel-body">
  93.                         <table class="table table-hover">
  94.                             <tr>
  95.                                 <td><i class="fa fa-users fa-fw"></i> <?php echo ST_NUMPILOTS; ?></td>
  96.                                 <td><?php echo $num_pilots; ?></td>
  97.                             </tr>
  98.                             <tr>
  99.                                 <td><i class="fa fa-plane fa-fw"></i> <?php echo ST_NUMPLANES; ?></td>
  100.                                 <td><?php echo $num_planes; ?></td>
  101.                             </tr>
  102.                             <tr>
  103.                                 <td><i class="fa fa-globe fa-fw"></i> <?php echo ST_NUMROUTES; ?></td>
  104.                                 <td><?php echo $num_routes; ?></td>
  105.                             </tr>
  106.                             <tr>
  107.                                 <td><i class="fa fa-clock-o fa-fw"></i> <?php echo PILOT_HOURS; ?></td>
  108.                                 <td><?php echo convertTime($va_hours,$va_time_format); ?></td>
  109.                             </tr>
  110.                             <tr>
  111.                                 <td><i class="fa fa-suitcase fa-fw"></i> <?php echo ST_NUMFLIGHTS; ?></td>
  112.                                 <td><?php echo $num_fskeeper + $num_pireps + $num_reports + $num_vamacars - $num_fsacars_rejected - $num_fskeeper_rejected - $num_pireps_rejected - $num_vamacars_rejected ; ?></td>
  113.                             </tr>
  114.                             <tr>
  115.                                 <td><i class="fa fa-exchange fa-fw"></i> <?php echo ST_NUMREGULAR; ?></td>
  116.                                 <td><?php echo $num_fskeeper_reg + $num_pireps_reg + $num_reports_reg + $num_vamacars_reg - $num_pireps_reg_rejected - $num_fskeeper_reg_rejected - $num_fsacars_reg_rejected - $num_vamacars_reg_rejected; ?></td>
  117.                             </tr>
  118.                             <tr>
  119.                                 <td><i class="fa fa-code-fork fa-fw"></i> <?php echo ST_NUMCHARTER; ?></td>
  120.                                 <td><?php echo $num_pireps + $num_fskeeper + $num_fsacars + $num_vamacars - $num_pireps_reg - $num_fskeeper_reg - $num_fsacars_reg - $num_vamacars_reg ; ?></td>
  121.                             </tr>
  122.                             <tr>
  123.                                 <td><i class="fa fa-bar-chart fa-fw"></i> <?php echo ST_PERREGULAR; ?></td>
  124.                                 <td><?php if (($num_fskeeper + $num_pireps + $num_reports + $num_vamacars - $num_fsacars_rejected - $num_fskeeper_rejected - $num_pireps_rejected - $num_vamacars_rejected) < 1) {
  125.                                         echo '0 %';
  126.                                     } else {
  127.                                         echo number_format((100 * ($num_pireps_reg + $num_fskeeper_reg + $num_fsacars_reg + $num_vamacars_reg - $num_pireps_reg_rejected - $num_fskeeper_reg_rejected - $num_fsacars_reg_rejected - $num_vamacars_reg_rejected)) / ($num_pireps + $num_fskeeper + $num_fsacars + $num_vamacars - $num_fsacars_rejected - $num_fskeeper_rejected - $num_pireps_rejected - $num_vamacars_rejected) , 2) . ' %';
  128.                                     }?></td>
  129.                             </tr>
  130.                         </table>
  131.                     </div>
  132.                 </div>
  133.                 <div class="clearfix visible-lg"></div>
  134.             </div>
  135.         </div>
  136.         <!-- Row 2 -->
  137.         <div class="row">
  138.             <div class="col-md-8">
  139.                 <div class="panel panel-default">
  140.                     <div class="panel-heading">
  141.                         <h3 class="panel-title"><IMG src="images/icons/ic_flight_white_18dp_1x.png">&nbsp;<?php echo LATEST_FLIGHTS_VA; ?></h3>
  142.                     </div>
  143.                     <div class="panel-body">
  144.                         <?php
  145.                             $db = new mysqli($db_host , $db_username , $db_password , $db_database);
  146.                             $db->set_charset("utf8");
  147.                             if ($db->connect_errno > 0) {
  148.                                 die('Unable to connect to database [' . $db->connect_error . ']');
  149.                             }
  150.                             $sql = "select v.gvauser_id,a1.name as dep_name, a2.name as arr_name, a1.iso_country as dep_country,a2.iso_country as arr_country,
  151.                                     v.callsign,v.pilot_name,v.departure,v.arrival, DATE_FORMAT(v.date,'$va_date_format') as date_string, date, format(time,2) as time,
  152.                                     landing_vs from v_last_5_flights v, airports a1, airports a2
  153.                                     INNER JOIN vampireps vp where v.departure=a1.ident and v.arrival=a2.ident and vp.gvauser_id = v.gvauser_id and time is not null GROUP by date desc";
  154.                             if (!$result = $db->query($sql)) {
  155.                                 die('There was an error running the query [' . $db->error . ']');
  156.                             }
  157.                         ?>
  158.                         <div class="table-responsive">
  159.                             <table class="table table-hover">
  160.                                 <?php
  161.                                     echo "<thead><tr><th>" . LF_CALLSIG . "</th><th>" . LF_PILOT . "</th><th>" . LF_DEPARTURE . "</th><th>" . LF_ARRIVAL . "</th><th>" . 'LANDING VS' . "</th><th>" . LF_FLIGHTDATE . "</th><th>" . LF_FLIGHTTIME . "</th></tr></thead>";
  162.                                     while ($row = $result->fetch_assoc()) {
  163.                                         echo '<td>';
  164.                                         echo '<a href="./index.php?page=pilot_details&pilot_id=' . $row["gvauser_id"] . '">' . $row["callsign"] . '</a></td><td>';
  165.                                         echo $row["pilot_name"] . '</td><td>';
  166.                                         echo '<IMG src="images/icons/ic_flight_takeoff_black_18dp_2x.png" WIDTH="20" HEIGHT="20" BORDER=0 ALT="">&nbsp;<IMG src="images/country-flags/'.$row["dep_country"].'.png" WIDTH="25" HEIGHT="20" BORDER=0 ALT="">&nbsp;<a href="./index.php?page=airport_info&airport=' . $row["departure"] . '">' . $row["departure"] . '</a></td><td>';
  167.                                         echo '<IMG src="images/icons/ic_flight_land_black_18dp_2x.png" WIDTH="20" HEIGHT="20" BORDER=0 ALT="">&nbsp;<IMG src="images/country-flags/'.$row["arr_country"].'.png" WIDTH="25" HEIGHT="20" BORDER=0 ALT="">&nbsp;<a href="./index.php?page=airport_info&airport=' . $row["arrival"] . '">' . $row["arrival"] . '</a> </td><td>';
  168.                                         echo $row["landing_vs"] . '</td><td>';
  169.                                         echo $row["date_string"] . '</td><td>';
  170.                                         echo '<i class="fa fa-clock-o"></i>&nbsp;'.convertTime($row["time"],$va_time_format). '</td></tr>';
  171.                                     }
  172.                                 ?>
  173.                             </table>
  174.                         </div>
  175.                     </div>
  176.                 </div>
  177.             </div>
  178.             <div class="col-md-4">
  179.                 <div class="panel panel-default">
  180.                     <div class="panel-heading">
  181.                         <h3 class="panel-title"><IMG src="images/icons/ic_person_add_white_18dp_1x.png">&nbsp;<?php echo NEWEST_PILOTS_VA; ?></h3>
  182.                     </div>
  183.                     <div class="panel-body">
  184.                         <?php
  185.                             $db = new mysqli($db_host , $db_username , $db_password , $db_database);
  186.                             $db->set_charset("utf8");
  187.                             if ($db->connect_errno > 0) {
  188.                                 die('Unable to connect to database [' . $db->connect_error . ']');
  189.                             }
  190.                             $sql = "select gvauser_id, concat(callsign,'-',name,' ',surname) as pilot , DATE_FORMAT(register_date,'$va_date_format') as register_date from gvausers where activation=1 order by DATE_FORMAT(register_date,'%Y%m%d') desc limit 5";
  191.                             if (!$result = $db->query($sql)) {
  192.                                 die('There was an error running the query [' . $db->error . ']');
  193.                             }
  194.                         ?>
  195.                         <table class="table table-hover">
  196.                             <?php
  197.                                 echo "<thead><tr><th>" . NEWPILOT . "</th><th>" . NEWJOINED . "</th></tr></thead>";
  198.                                 while ($row = $result->fetch_assoc()) {
  199.                                     echo "<td>";
  200.                                     echo '<a href="./index.php?page=pilot_details&pilot_id=' . $row["gvauser_id"] . '">' . $row["pilot"] . '</a></td><td>';
  201.                                     echo $row["register_date"] . '</td></tr>';
  202.                                 }
  203.                             ?>
  204.                         </table>
  205.                     </div>
  206.                 </div>
  207.                 <div class="clearfix visible-lg"></div>
  208.             </div>
  209.         </div>
  210.         <!-- Row 3 -->
  211.         <div class="row">
  212.             <div class="col-md-4">
  213.                 <div class="panel panel-default">
  214.                     <div class="panel-heading">
  215.                         <h3 class="panel-title"><IMG src="images/icons/ic_slow_motion_video_white_18dp_1x.png">&nbsp;<?php echo FUTURE_EVENTS; ?></h3>
  216.                     </div>
  217.                     <div class="panel-body">
  218.                         <?php
  219.                             $db = new mysqli($db_host , $db_username , $db_password , $db_database);
  220.                             $db->set_charset("utf8");
  221.                             if ($db->connect_errno > 0) {
  222.                                 die('Unable to connect to database [' . $db->connect_error . ']');
  223.                             }
  224.                             $sql = "select event_id,event_name,DATE_FORMAT(publish_date,'$va_date_format') as publish_date_web ,DATE_FORMAT(publish_date,'%Y%m%d') as publish_date,DATE_FORMAT(hide_date,'%Y%m%d') as hide_date, DATE_FORMAT(now(),'%Y%m%d') as currdat
  225. from events order by publish_date asc limit 5";
  226.                             if (!$result = $db->query($sql)) {
  227.                                 die('There was an error running the query [' . $db->error . ']');
  228.                             }
  229.                         ?>
  230.                         <table class="table table-hover">
  231.                             <?php
  232.                                 echo "<thead><tr><th>" . EVENT_NAME . "</th><th>" . EVENT_DATE . "</th></tr></thead>";
  233.                                 while ($row = $result->fetch_assoc()) {
  234.                                     if (($row["publish_date"]-$row["currdat"] <=0) && ($row["hide_date"]-$row["currdat"]>0))
  235.                                     {
  236.                                         echo '<tr><td>';
  237.                                         echo '<a href="index.php?page=event&event_id=' . $row["event_id"] . '">' . $row["event_name"] . '</a>' . '</td><td>';
  238.                                         echo $row["publish_date_web"] . '</td></tr>';
  239.                                     }
  240.                                 }
  241.                             ?>
  242.                         </table>
  243.                     </div>
  244.                 </div>
  245.             </div>
  246.             <div class="col-md-4">
  247.                 <div class="panel panel-default">
  248.                     <div class="panel-heading">
  249.                         <h3 class="panel-title"><IMG src="images/icons/ic_record_voice_over_white_18dp_1x.png">&nbsp;<?php echo TWEETS; ?></h3>
  250.                     </div>
  251.                     <div class="panel-body">
  252.                         <a class="twitter-timeline" href="https://twitter.com/pilotovirtual"
  253.                            data-widget-id="525729765416660992">Tweets por el @pilotovirtual.</a>
  254.                         <script>!function (d, s, id) {
  255.                                 var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https';
  256.                                 if (!d.getElementById(id)) {
  257.                                     js = d.createElement(s);
  258.                                     js.id = id;
  259.                                     js.src = p + "://platform.twitter.com/widgets.js";
  260.                                     fjs.parentNode.insertBefore(js, fjs);
  261.                                 }
  262.                             }(document, "script", "twitter-wjs");</script>
  263.                     </div>
  264.                 </div>
  265.             </div>
  266.             <div class="col-md-4">
  267.                 <div class="panel panel-default">
  268.                     <div class="panel-heading">
  269.                         <h3 class="panel-title"><IMG src="images/icons/ic_cast_white_18dp_1x.png">&nbsp;<?php echo NOTAMS_VA; ?></h3>
  270.                     </div>
  271.                     <div class="panel-body">
  272.                         <?php
  273.                             $db = new mysqli($db_host , $db_username , $db_password , $db_database);
  274.                             $db->set_charset("utf8");
  275.                             if ($db->connect_errno > 0) {
  276.                                 die('Unable to connect to database [' . $db->connect_error . ']');
  277.                             }
  278.                             $sql = "select notam_id,notam_name,DATE_FORMAT(publish_date,'%d-%m-%Y') as publish_date_web ,DATE_FORMAT(publish_date,'%Y%m%d') as publish_date,DATE_FORMAT(hide_date,'%Y%m%d') as hide_date, DATE_FORMAT(now(),'%Y%m%d') as currdat
  279. from notams order by publish_date asc limit 5";
  280.                             if (!$result = $db->query($sql)) {
  281.                                 die('There was an error running the query [' . $db->error . ']');
  282.                             }
  283.                         ?>
  284.                         <table class="table table-striped">
  285.                             <?php
  286.                                 echo "<thead><tr><th>" . NOTAM_NAME . "</th><th>" . NOTAM_DATE . "</th></tr></thead>";
  287.                                 while ($row = $result->fetch_assoc()) {
  288.                                     if (($row["publish_date"]-$row["currdat"] <=0) && ($row["hide_date"]-$row["currdat"]>0))
  289.                                     {
  290.                                         echo '<tr><td>';
  291.                                         echo '<a href="index.php?page=notam&notam_id=' . $row["notam_id"] . '">' . $row["notam_name"] . '</a>' . '</td><td>';
  292.                                         echo $row["publish_date_web"] . '</td></tr>';
  293.                                     }
  294.                                 }
  295.                             ?>
  296.                         </table>
  297.                     </div>
  298.                 </div>
  299.                 <div class="clearfix visible-lg"></div>
  300.             </div>
  301.             <!-- REMOVE COMMENTS to display ONLNE NETWORKS section
  302.             <div class="col-md-4">
  303.                 <div class="panel panel-default">
  304.                     <div class="panel-heading">
  305.                         <h3 class="panel-title"><?php //echo FLIGHT_NETWORKS; ?></h3>
  306.                     </div>
  307.                     <div class="panel-body">
  308.                         <div class="container">
  309.                             <?php
  310.                             /*
  311.                                 if ($ivao == 1) {
  312.                                     echo '<img src="./images/ivao.gif" height="50" width="50">';
  313.                                 }
  314.                                 if ($vatsim == 1) {
  315.                                     echo '<img src="./images/Vatsim.png" height="50" width="50">';
  316.                                 }
  317.                             */
  318.                             ?>
  319.                         </div>
  320.                     </div>
  321.                 </div>
  322.                 <div class="clearfix visible-lg"></div>
  323.             </div> -->
  324.         </div>
  325.         <br>
  326.         <!-- HOME PAGE End -->
  327.     <?php
  328.     }
  329.     if (!isset($_GET["page"]) || trim($_GET["page"]) == "") {
  330.     } else {
  331.         $Existe = file_exists($_GET["page"] . ".php");
  332.         if ($Existe == true) {
  333.             include($_GET["page"] . ".php");
  334.         } else {
  335.             echo "Page Not Found";
  336.         }
  337.     }
  338. ?>
  339. </div>
  340. <?php include('footer.php');?>
  341. </body>
  342. </html>
Add Comment
Please, Sign In to add comment