示例#1
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;
}
示例#2
0
<?php

include dirname(__FILE__) . '/bootstrap.inc.php';
echo '<pre>';
Config::set('TWITTER_AIRLINE_ACCOUNT', 'nabeels');
Config::set('TWITTER_ENABLE_PUSH', false);
ActivityData::readTwitter();
// Push a test message to Twitter
Config::set('TWITTER_ENABLE_PUSH', true);
$pirep = PIREPData::getRecentReportsByCount(20);
$idx = rand(0, count($pirep) - 1);
$pirep = $pirep[$idx];
$message = Lang::get('activity.new.pirep');
foreach ($pirep as $key => $value) {
    $message = str_replace('$' . $key, $value, $message);
}
# Push a new PIREP
$ret = ActivityData::pushToTwitter(array('pilotid' => $pirep->pilotid, 'type' => ACTIVITY_NEW_PIREP, 'refid' => $pirep->pirepid, 'message' => $message));
var_dump($ret);