Exemplo n.º 1
0
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
$Spotter = new Spotter();
$orderby = $Spotter->getOrderBy();
$title = "Search";
$page_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
//$title = "Search";
require 'header.php';
if (isset($_GET['start_date'])) {
    //for the date manipulation into the query
    if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
        $start_date = $_GET['start_date'] . ":00";
        $end_date = $_GET['end_date'] . ":00";
        $sql_date = $start_date . "," . $end_date;
    } else {
        if ($_GET['start_date'] != "") {
            $start_date = $_GET['start_date'] . ":00";
            $sql_date = $start_date;
        } else {
            if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
                $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")) . "," . $_GET['end_date'] . ":00";
                $sql_date = $end_date;
            } else {
                $sql_date = '';
            }
        }
    }
} else {
    $sql_date = '';
Exemplo n.º 2
0
 /**
  * Gets all the spotter information based on calculated upcoming flights
  *
  * @return Array the spotter information
  *
  */
 public static function getUpcomingFlights($limit = '', $sort = '')
 {
     global $global_query, $globalDBdriver, $globalTimezone;
     date_default_timezone_set('UTC');
     if ($limit != "") {
         $limit_array = explode(",", $limit);
         $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
         $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
         if ($limit_array[0] >= 0 && $limit_array[1] >= 0) {
             //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
             $limit_query = " LIMIT " . $limit_array[1] . " OFFSET " . $limit_array[0];
         }
     }
     $currentHour = date("G");
     $next3Hours = date("G", strtotime("+3 hour"));
     //if the next 3 hours is already equal to/past midnight, we limit it to stay there, otherwise the query will fail
     if ($currentHour >= 21 && $next3Hours >= 00) {
         $next3Hours = 24;
     }
     $currentDayofWeek = date("l");
     if ($globalDBdriver == 'mysql') {
         if ($sort != "") {
             $search_orderby_array = Spotter::getOrderBy();
             $orderby_query = $search_orderby_array[$sort]['sql'];
         } else {
             $orderby_query = " ORDER BY HOUR(spotter_output.date) ASC";
         }
         $query = "SELECT spotter_output.*, count(spotter_output.ident) as ident_count\n\t\t\t    FROM spotter_output\n\t\t\t    WHERE DAYNAME(spotter_output.date) = '{$currentDayofWeek}' AND HOUR(spotter_output.date) >= '{$currentHour}' AND HOUR(spotter_output.date) <= '{$next3Hours}'\n\t\t\t    GROUP BY spotter_output.ident HAVING ident_count > 10 {$orderby_query}";
         $spotter_array = Spotter::getDataFromDB($query . $limit_query);
     } else {
         if ($globalDBdriver == 'pgsql') {
             if ($sort != "") {
                 $search_orderby_array = Spotter::getOrderBy();
                 $orderby_query = $search_orderby_array[$sort]['sql'];
             } else {
                 $orderby_query = " ORDER BY EXTRACT (HOUR FROM spotter_output.date) ASC";
             }
             $query = "SELECT spotter_output.*, count(spotter_output.ident) as ident_count\n\t\t\t    FROM spotter_output\n\t\t\t    WHERE DATE_PART('dow', spotter_output.date) = DATE_PART('dow', date 'now' AT TIME ZONE :timezone) AND EXTRACT (HOUR FROM spotter_output.date AT TIME ZONE :timezone) >= '{$currentHour}' AND EXTRACT (HOUR FROM spotter_output.date AT TIME ZONE :timezone) <= '{$next3Hours}'\n\t\t\t    GROUP BY spotter_output.ident, spotter_output.spotter_id HAVING count(spotter_output.ident) > 10 {$orderby_query}";
             $spotter_array = Spotter::getDataFromDB($query . $limit_query, array(':timezone' => $globalTimezone));
         }
     }
     return $spotter_array;
 }
Exemplo n.º 3
0
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
$orderby = Spotter::getOrderBy();
$title = "Search";
$page_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
//$title = "Search";
require 'header.php';
if (isset($_GET['start_date'])) {
    //for the date manipulation into the query
    if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
        $start_date = $_GET['start_date'] . ":00";
        $end_date = $_GET['end_date'] . ":00";
        $sql_date = $start_date . "," . $end_date;
    } else {
        if ($_GET['start_date'] != "") {
            $start_date = $_GET['start_date'] . ":00";
            $sql_date = $start_date;
        } else {
            if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
                $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")) . "," . $_GET['end_date'] . ":00";
                $sql_date = $end_date;
            } else {
                $sql_date = '';
            }
        }
    }
} else {
    $sql_date = '';
}