function getFlightInfo(&$track, &$geoServerStatus) { $id = $track['flightId']; $query = "SELECT * FROM flightInfo WHERE id='{$id}'"; $result = mysql_query($query) or die('Query error: ' . mysql_error()); if (mysql_num_rows($result) == 1) { $flightInfo = mysql_fetch_object($result); } else { $query = "INSERT INTO flightInfo (id) VALUES ('{$id}')"; $result = mysql_query($query) or die('Query error: ' . mysql_error()); $query = "SELECT * FROM flightInfo WHERE id='{$id}'"; $result = mysql_query($query) or die('Query error: ' . mysql_error()); $flightInfo = mysql_fetch_object($result); } // Retrieve take-off information if ($flightInfo->startLocation == NULL) { $track['start']['location'] = getNearbyPlace($track['start']['lat'], $track['start']['lon'], $geoServerStatus); if ($track['start']['location']['place'] != '-') { $query = "UPDATE flightInfo " . "SET startLocation = '" . format_mysql($track['start']['location']['place']) . "', " . "startCountry = '" . format_mysql($track['start']['location']['country']) . "' " . "WHERE id='{$id}'"; $result = mysql_query($query) or die('Query error: ' . mysql_error()); } } else { $track['start']['location']['place'] = $flightInfo->startLocation; $track['start']['location']['country'] = $flightInfo->startCountry; } // Retrieve position / landing information if ($flightInfo->endLocation == NULL || $track['live']) { $track['end']['location'] = getNearbyPlace($track['end']['lat'], $track['end']['lon'], $geoServerStatus); if ($track['end']['location']['place'] != '-' && !$track['live']) { $query = "UPDATE flightInfo " . "SET endLocation = '" . format_mysql($track['end']['location']['place']) . "', " . "endCountry = '" . format_mysql($track['end']['location']['country']) . "' " . "WHERE id='{$id}'"; $result = mysql_query($query) or die('Query error: ' . mysql_error()); } } else { $track['end']['location']['place'] = $flightInfo->endLocation; $track['end']['location']['country'] = $flightInfo->endCountry; } // Retrieve timezone information if ($flightInfo->timezone == NULL) { $flightInfo->timezone = getTimeZone($track['start']['lat'], $track['start']['lon'], $geoServerStatus); if ($flightInfo->timezone != NULL) { $query = "UPDATE flightInfo " . "SET timezone = '{$flightInfo->timezone}' " . "WHERE id='{$id}'"; $result = mysql_query($query) or die('Query error: ' . mysql_error()); } } return $flightInfo; }
$timeZone[] = mktime($resetTimeArray[0], $resetTimeArray[1], 0, $nowTimeArray0[1], (string) ($nowTimeArray0[2] + 1), $nowTimeArray0[0]); } return $timeZone; } function isInTimeZone($nearTime, $nowTime, $timeZone) { if ($nearTime >= $timeZone[0] && $nearTime < $timeZone[1] && $nowTime < $timeZone[1]) { return true; } else { return false; } } $resetTime = '12:00'; // $prayNumArray from your data $nowDateTime = time(); $timeZone = getTimeZone(date('y/m/d H:i', $nowDateTime), $resetTime); $lastTime = 0; $existPrayNum = 1; while ($existPrayNum < 3) { //get last time,lastTime is not null,Assignment to give it if (isInTimeZone($lastTime, $nowDateTime, $timeZone)) { if ($existPrayNum < 3) { echo $existPrayNum . "<br>"; } } else { //get last time if ($lastTime == 0) { $lastTime = time(); } $existPrayNum = 0; echo "0<br>";
include 'functions.php'; // Only process POST reqeusts. if ($_SERVER["REQUEST_METHOD"] == "POST") { // Get the form fields and remove whitespace. $formDate = $_POST["date"]; // Check that data was sent to the mailer. if (empty($formDate)) { // Set a 400 (bad request) response code and exit. http_response_code(400); echo "Oops! There was a problem with your submission. Please complete the form and try again."; exit; } // Send data. if ($formDate == "today") { // get the current month, day, and hour of the users' time zone getTimeZone(); $currMonth = date(m); $currHour = date(a) == 'am' ? date(h) : date(h) + 12; // convert to military $currDate = date(d); // if september, check if we're befor or after the 15th if ($currMonth == "09") { if (date(d) < "15") { echo "only until sept 15th"; } else { if (date(d) >= "15") { echo "only after sept 15th"; } } } // Set a 200 (okay) response code.