Esempio n. 1
0
 public function sendpireps()
 {
     echo '<h3>Sending all PIREPS</h3>';
     $within_timelimit = CronData::check_hoursdiff('update_pireps', CentralData::$limits['update_pireps']);
     if ($within_timelimit == true) {
         echo '<p>You can only export PIREPs every ' . CentralData::$limits['update_pireps'] . ' hours</p>';
         return false;
     }
     $ret = CentralData::send_all_pireps();
     $this->parse_response($ret);
     LogData::addLog(Auth::$userinfo->pilotid, 'vaCentral - PIREPS sent');
 }
Esempio n. 2
0
function post_module_load()
{
    /* Misc tasks which need to get done */
    /* If the setting to auto-retired pilots is on, then do that
       and only check every 24 hours
       */
    if (Config::Get('USE_CRON') == false) {
        if (Config::Get('PILOT_AUTO_RETIRE') == true) {
            $within_timelimit = CronData::check_hoursdiff('find_retired_pilots', '24');
            if ($within_timelimit === false) {
                PilotData::findRetiredPilots();
                CronData::set_lastupdate('find_retired_pilots');
            }
        }
        if (Config::Get('CLOSE_BIDS_AFTER_EXPIRE') === false) {
            $within_timelimit = CronData::check_hoursdiff('check_expired_bids', '24');
            if ($within_timelimit === false) {
                SchedulesData::deleteExpiredBids();
                CronData::set_lastupdate('check_expired_bids');
            }
        }
        /* Expenses, make sure they're all populated */
        $within_timelimit = CronData::check_hoursdiff('populate_expenses', 18);
        if ($within_timelimit === false) {
            FinanceData::updateAllExpenses();
            CronData::set_lastupdate('populate_expenses');
        }
        /* And finally, clear expired sessions */
        Auth::clearExpiredSessions();
    }
    if (Config::Get('TWITTER_AIRLINE_ACCOUNT') != '') {
        $within_timelimit = CronData::check_hoursdiff('twitter_update', '3');
        if ($within_timelimit === false) {
            ActivityData::readTwitter();
            CronData::set_lastupdate('twitter_update');
        }
    }
    // @TODO: Clean ACARS records older than one month
    if (Config::Get('MAINTENANCE_MODE') == true && !Auth::LoggedIn() && !PilotGroups::group_has_perm(Auth::$usergroups, FULL_ADMIN)) {
        Template::Show('maintenance.tpl');
        die;
    }
    return true;
}
Esempio n. 3
0
function post_module_load()
{
    /* Misc tasks which need to get done */
    /* If the setting to auto-retired pilots is on, then do that
    		and only check every 24 hours
    	 */
    if (Config::Get('USE_CRON') === true) {
        if (Config::Get('PILOT_AUTO_RETIRE') == true) {
            $within_timelimit = CronData::check_hoursdiff('find_retired_pilots', '24');
            if ($within_timelimit == false) {
                PilotData::findRetiredPilots();
                CronData::set_lastupdate('find_retired_pilots');
            }
        }
        if (Config::Get('CLOSE_BIDS_AFTER_EXPIRE') === false) {
            $within_timelimit = CronData::check_hoursdiff('check_expired_bids', '24');
            if ($within_timelimit == false) {
                SchedulesData::deleteExpiredBids();
                CronData::set_lastupdate('check_expired_bids');
            }
        }
        /* Expenses, make sure they're all populated */
        $within_timelimit = CronData::check_hoursdiff('populate_expenses', '18');
        if ($within_timelimit == false) {
            FinanceData::updateAllExpenses();
            CronData::set_lastupdate('populate_expenses');
        }
        /* And finally, clear expired sessions */
        Auth::clearExpiredSessions();
    }
    // @TODO: Clean ACARS records older than one month
    if (Config::Get('MAINTENANCE_MODE') == true && !Auth::LoggedIn() && !PilotGroups::group_has_perm(Auth::$usergroups, FULL_ADMIN)) {
        echo '<html><head><title>Down for maintenance - ' . SITE_NAME . '</title></head><body>';
        Debug::showCritical(Config::Get('MAINTENANCE_MESSAGE'), 'Down for maintenance');
        echo '</body></html>';
        die;
    }
    return true;
}
Esempio n. 4
0
 *
 * @author Nabeel Shahzad
 * @copyright Copyright (c) 2008, Nabeel Shahzad
 * @link http://www.phpvms.net
 * @license http://creativecommons.org/licenses/by-nc-sa/3.0/
 */
/*	This is the maintenance cron file, which can run nightly. 
	You should either point to this file directly in your web-host's control panel
	Or add an entry into the crontab file. I recommend running this maybe 2-3am, 
 */
define('ADMIN_PANEL', true);
include dirname(dirname(__FILE__)) . '/core/codon.config.php';
Auth::$userinfo->pilotid = 0;
error_reporting(E_ALL);
ini_set('display_errors', 'on');
/* Clear expired sessions */
Auth::clearExpiredSessions();
/* Update any expenses */
FinanceData::updateAllExpenses();
if (Config::Get('PILOT_AUTO_RETIRE') == true) {
    /* Find any retired pilots and set them to retired */
    PilotData::findRetiredPilots();
    CronData::set_lastupdate('find_retired_pilots');
}
if (Config::Get('CLOSE_BIDS_AFTER_EXPIRE') === false) {
    SchedulesData::deleteExpiredBids();
    CronData::set_lastupdate('check_expired_bids');
}
MaintenanceData::optimizeTables();
MainController::Run('Maintenance', 'resetpirepcount');
MainController::Run('Maintenance', 'resethours');
Esempio n. 5
0
 public static function send_acars_data($flight)
 {
     if (!self::central_enabled()) {
         return false;
     }
     self::set_xml('update_acars_flight');
     self::create_acars_flight($flight);
     CronData::set_lastupdate('update_acars');
     return self::send_xml();
 }
Esempio n. 6
0
 /**
  * Import the latest data from Twitter into the activity feed
  * 
  * @return void
  */
 public static function readTwitter()
 {
     # Don't pull data from Twitter if we are pushing
     if (Config::get('TWITTER_ENABLE_PUSH') == true) {
         return false;
     }
     $twitterAccount = Config::get('TWITTER_AIRLINE_ACCOUNT');
     if (empty($twitterAccount)) {
         return false;
     }
     $twitterURL = TWITTER_STATUS_URL . $twitterAccount;
     $lastsubmit = self::getActivity(array('a.type' => ACTIVITY_TWITTER), 1);
     if (count($lastsubmit) > 0) {
         $twitterURL .= '&since_id=' . $lastsubmit[0]->refid;
     }
     $cws = new CodonWebService();
     $feed_contents = $cws->get($twitterURL);
     $feed_contents = json_decode($feed_contents);
     if (isset($feed_contents->error)) {
         self::log('TWITTER ERROR: ' . $feed_contents->request . "\nError:" . $feed_contents->error);
         return false;
     }
     if (!is_array($feed_contents) || count($feed_contents) == 0) {
         return false;
     }
     foreach ($feed_contents as $tweet) {
         $date_created = strtotime($tweet->created_at);
         self::addActivity(array('pilotid' => 0, 'type' => ACTIVITY_TWITTER, 'refid' => $tweet->id, 'message' => DB::escape($tweet->text), 'submitdate' => 'FROM_UNIXTIME(' . $date_created . ')', 'checkrefid' => true));
     }
     CronData::set_lastupdate('twitter_update');
 }