public function resetdistances() { echo '<h3>Updating and Calculating Distances</h3>'; # Update all of the schedules echo '<p><strong>Updating schedules...</strong></p>'; //$allschedules = SchedulesData::GetSchedulesNoDistance(); $allschedules = SchedulesData::findSchedules(array()); if (!$allschedules) { echo 'No schedules to update'; $allschedules = array(); } # Check 'em foreach ($allschedules as $sched) { $distance = SchedulesData::distanceBetweenPoints($sched->deplat, $sched->deplng, $sched->arrlat, $sched->arrlng); $distance = sprintf("%.6f", $distance); echo "{$sched->code}{$sched->flightnum} - {$sched->depname} to {$sched->arrname} " . "is {$distance} " . Config::Get('UNIT') . '<br />'; SchedulesData::updateScheduleFields($sched->id, array('distance' => $distance)); } # Update all of the PIREPS echo '<p><strong>Updating PIREPs...</strong></p>'; $allpireps = PIREPData::findPIREPS(array()); if (!$allpireps) { echo 'No PIREPs need updating!'; $allpireps = array(); } foreach ($allpireps as $pirep) { # Find the schedule, and the distance supplied by the schedule: $distance = SchedulesData::distanceBetweenPoints($pirep->deplat, $pirep->deplng, $pirep->arrlat, $pirep->arrlng); $distance = sprintf("%.2f", $distance); echo "PIREP Number {$pirep->pirepid} ({$pirep->code}{$pirep->flightnum}) " . "{$pirep->depname} to {$pirep->arrname} is {$distance} " . Config::Get('UNIT') . '<br />'; PIREPData::editPIREPFields($pirep->pirepid, array('distance' => $distance)); } echo '<p>Completed!</p><br />'; LogData::addLog(Auth::$userinfo->pilotid, 'Reset distances'); }
# if ($_GET['more'] == '1') { # # We have more coming to the log # $report = PIREPData::GetLastReports($pilotid, 1); /* Check for any other data which might be in the other chunks sent by fsacars, because it's stupid and doesn't just do POST */ $log = explode('*', $_GET['log']); /* Find the landing rate */ $pos = find_in_fsacars_log('TouchDown:Rate', $log); $landingrate = str_replace('TouchDown:Rate', '', $log[$pos]); $count = preg_match('/([0-9]*:[0-9]*).*([-+]\\d*).*/i', $landingrate, $matches); if ($count > 0) { PIREPData::editPIREPFields($report->pirepid, array('landingrate' => $matches[2])); } PIREPData::AppendToLog($report->pirepid, $_GET['log']); echo 'OK'; return; } # Full PIREP, run with it preg_match('/^([A-Za-z]*)(\\d*)/', $_GET['pilot'], $matches); $code = $matches[1]; $log = explode('*', $_GET['log']); # Find where flight IATA is # And extract the code and flight number $pos = find_in_fsacars_log('Flight IATA', $log); $flightnum = str_replace('Flight IATA:', '', $log[$pos]); //preg_match('/^([A-Za-z]*)(\d*)/', $flightnum, $matches); $flightinfo = SchedulesData::getProperFlightNum($flightnum);