Ejemplo n.º 1
0
 /**
  * Save changes to a group
  * 
  * @param mixed $groupid
  * @param mixed $groupname
  * @param mixed $permissions
  * @return
  */
 public static function editGroup($groupid, $groupname, $permissions)
 {
     $groupid = intval($groupid);
     $groupname = DB::escape($groupname);
     $sql = 'UPDATE ' . TABLE_PREFIX . "groups\n\t\t\t\tSET `name`='{$groupname}', `permissions`={$permissions}\n\t\t\t\tWHERE `groupid`={$groupid}";
     $res = DB::query($sql);
     if (DB::errno() != 0) {
         return false;
     }
     CodonCache::delete('all_groups');
     return true;
 }
Ejemplo n.º 2
0
 public static function init($settings)
 {
     /*	These are the default settings, which will get merged with
     			the incoming settings passed to this function */
     self::$settings = array('active' => false, 'engine' => 'file', 'location' => dirname(__FILE__), 'prefix' => __CLASS__, 'suffix' => '.cache', 'profiles' => array('default' => array('duration' => '+10 minutes'), 'short' => array('duration' => '+5 minutes'), 'medium' => array('duration' => '+1 hour'), 'long' => array('duration' => '+6 hours')));
     if (is_array($settings)) {
         self::$settings = array_merge(self::$settings, $settings);
     }
     if (self::$settings['engine'] == 'file') {
         # Add a trailing slash
         if (substr(self::$settings['location'], -1, 1) != '/') {
             self::$settings['location'] .= '/';
         }
     }
 }
Ejemplo n.º 3
0
 public static function deleteField($id)
 {
     $sql = 'DELETE FROM ' . TABLE_PREFIX . 'customfields WHERE `fieldid`=' . $id;
     $res = DB::query($sql);
     $sql = 'DELETE FROM ' . TABLE_PREFIX . 'fieldvalues WHERE `fieldid`=' . $id;
     $res = DB::query($sql);
     CodonCache::delete('allfields');
 }
Ejemplo n.º 4
0
 public static function removeAirport($icao)
 {
     $icao = DB::escape($icao);
     $icao = strtoupper($icao);
     $sql = "DELETE FROM " . TABLE_PREFIX . "airports WHERE `icao`='{$icao}'";
     $res = DB::query($sql);
     if (DB::errno() != 0) {
         return false;
     }
     CodonCache::delete('get_airport_' . $icao);
     CodonCache::delete('all_airports_json');
     CodonCache::delete('all_airports');
     return true;
 }
Ejemplo n.º 5
0
 public function __construct()
 {
     CodonCache::setEnabled(false);
 }
Ejemplo n.º 6
0
Config::Set('MODULES_PATH', CORE_PATH . DS . 'modules');
Config::Set('MODULES_AUTOLOAD', true);
Template::init();
require CORE_PATH . DS . 'app.config.php';
@(include CORE_PATH . DS . 'local.config.php');
/* Set the language */
Lang::set_language(Config::Get('SITE_LANGUAGE'));
error_reporting(Config::Get('ERROR_LEVEL'));
Debug::$debug_enabled = Config::Get('DEBUG_MODE');
if (Debug::$debug_enabled == true) {
    ini_set('log_errors', 'On');
    ini_set('display_errors', 'Off');
    ini_set('error_log', LOGS_PATH . '/errors.txt');
}
/* Init caching engine */
CodonCache::init($cache_settings);
if (DBASE_NAME != '' && DBASE_SERVER != '' && DBASE_NAME != 'DBASE_NAME') {
    require CLASS_PATH . DS . 'ezdb/ezdb.class.php';
    DB::$show_errors = Config::Get('DEBUG_MODE');
    DB::$throw_exceptions = false;
    DB::init(DBASE_TYPE);
    DB::set_log_errors(Config::Get('DEBUG_MODE'));
    DB::set_error_handler(array('Debug', 'db_error'));
    DB::set_caching(false);
    DB::$table_prefix = TABLE_PREFIX;
    DB::set_cache_dir(CACHE_PATH);
    DB::$DB->debug_all = false;
    if (Config::Get('DEBUG_MODE') == true) {
        DB::show_errors();
    } else {
        DB::hide_errors();
Ejemplo n.º 7
0
 /**
  * Return the total number of schedules in the system
  *
  * @return int $airline_code Total number
  *
  */
 public static function TotalSchedules($airline_code = '')
 {
     $key = 'total_schedules';
     if ($airline_code != '') {
         $key .= '_' . $airline_code;
     }
     $total = CodonCache::read($key);
     if ($total === false) {
         $params = array('table' => TABLE_PREFIX . 'schedules', 'fields' => 'COUNT(`id`) as `total`');
         if (!empty($airline_code)) {
             $params['where'] = array('code' => $airline_code);
             $params['group'] = 'code';
         }
         $sql = DB::build_select($params);
         $results = DB::get_results($sql);
         if (!$results) {
             $total = 0;
         } else {
             $total = $results[0]->total;
         }
         CodonCache::write($key, $total, '15minute');
     }
     return $total;
 }
Ejemplo n.º 8
0
    /**
     * Delete a rank, and then recalculate
     */
    public static function deleteRank($rankid)
    {
        $sql = 'DELETE FROM ' . TABLE_PREFIX . 'ranks 
					WHERE rankid=' . $rankid;
        DB::query($sql);
        if (DB::errno() != 0) {
            return false;
        }
        CodonCache::delete('all_ranks');
        self::CalculatePilotRanks();
        return true;
    }
Ejemplo n.º 9
0
    /**
     * Get information about an airport
     */
    public static function getAirportInfo($icao)
    {
        $icao = strtoupper(DB::escape($icao));
        $key = 'get_airport_' . $icao;
        $airport_info = CodonCache::read($key);
        if ($airport_info === false) {
            $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'airports 
						WHERE `icao`=\'' . $icao . '\'';
            $airport_info = DB::get_row($sql);
            CodonCache::write($key, $airport_info, 'long');
        }
        return $airport_info;
    }
Ejemplo n.º 10
0
 /**
  * Show the notification that an update is available
  */
 public function CheckForUpdates()
 {
     if (Config::Get('CHECK_RELEASE_VERSION') == true) {
         $key = 'PHPVMS_LATEST_VERSION';
         $feed = CodonCache::read($key);
         if ($feed === false) {
             $url = Config::Get('PHPVMS_API_SERVER') . '/version/get/json/';
             # Default to fopen(), if that fails it'll use CURL
             $file = new CodonWebService();
             $contents = @$file->get($url);
             # Something should have been returned
             if ($contents == '') {
                 $msg = '<br /><b>Error:</b> The phpVMS update server could not be contacted. 
 						Check to make sure allow_url_fopen is set to ON in your php.ini, or 
 						that the cURL module is installed (contact your host).';
                 $this->set('latestnews', $msg);
                 return;
             }
             #$xml = @simplexml_load_string($contents);
             $message = json_decode($contents);
             if (!$message) {
                 $msg = '<br /><b>Error:</b> There was an error retrieving news. It may be temporary.
 						Check to make sure allow_url_fopen is set to ON in your php.ini, or 
 						that the cURL module is installed (contact your host).';
                 $this->set('latestnews', $msg);
                 return;
             }
             CodonCache::write($key, $message, 'medium_well');
         }
         if (Config::Get('CHECK_BETA_VERSION') == true) {
             $latest_version = $message->betaversion;
         } else {
             $latest_version = $message->version;
         }
         # GET THE VERSION THAT'S THE LATEST AVAILABLE
         preg_match('/^[v]?(.*)-([0-9]*)-(.*)/', $latest_version, $matches);
         list($FULL_VERSION_STRING, $full_version, $revision_count, $hash) = $matches;
         preg_match('/([0-9]*)\\.([0-9]*)\\.([0-9]*)/', $full_version, $matches);
         list($full, $major, $minor, $revision) = $matches;
         $latest_version = $major . $minor . ($revision + $revision_count);
         # GET THE CURRENT VERSION INFO INSTALLED
         $installed_version = PHPVMS_VERSION;
         preg_match('/^[v]?(.*)-([0-9]*)-(.*)/', $installed_version, $matches);
         list($FULL_VERSION_STRING, $full_version, $revision_count, $hash) = $matches;
         preg_match('/([0-9]*)\\.([0-9]*)\\.([0-9]*)/', $full_version, $matches);
         list($full, $major, $minor, $revision) = $matches;
         $installed_version = $major . $minor . ($revision + $revision_count);
         #echo "CURRVERSION : $installed_version<br>AVAILVERSION: $latest_version<br>";
         if ($installed_version < $latest_version) {
             if (Config::Get('CHECK_BETA_VERSION') == true) {
                 $this->set('message', 'Beta version ' . $message->betaversion . ' is available for download!');
             } else {
                 $this->set('message', 'Version ' . $message->version . ' is available for download! Please update ASAP');
             }
             $this->set('updateinfo', Template::GetTemplate('core_error.php', true));
         }
         /* Retrieve latest news from Feedburner RSS, in case the phpVMS site is down
          */
         $key = 'PHPVMS_NEWS_FEED';
         $feed_contents = CodonCache::read($key);
         if ($feed_contents === false) {
             $feed_contents = $file->get(Config::Get('PHPVMS_NEWS_FEED'));
             CodonCache::write($key, $feed_contents, 'medium_well');
         }
         $i = 1;
         $count = 5;
         $contents = '';
         $feed = simplexml_load_string($feed_contents);
         foreach ($feed->channel->item as $news) {
             $news_content = (string) $news->description;
             $guid = (string) $news->guid;
             $title = (string) $news->title;
             $date_posted = str_replace('-0400', '', (string) $news->pubDate);
             $contents .= "<div class=\"newsitem\">";
             $contents .= '<a href="' . $guid . '"><b>' . $title . '</b></a><br />';
             $contents .= $news_content;
             $contents .= '<br /><br />Posted: ' . $date_posted;
             $contents .= '</div>';
             if ($i++ == $count) {
                 break;
             }
         }
         $this->set('phpvms_news', $contents);
         if (Config::Get('VACENTRAL_ENABLED') == true) {
             /* Get the latest vaCentral News */
             $contents = $file->get(Config::Get('VACENTRAL_NEWS_FEED'));
             $feed = simplexml_load_string($contents);
             $contents = '';
             $i = 1;
             $count = 5;
             // Show the last 5
             foreach ($feed->channel->item as $news) {
                 $news_content = (string) $news->description;
                 $date_posted = str_replace('-0400', '', (string) $news->pubDate);
                 $contents .= "<div class=\"newsitem\">\n\t\t\t\t\t\t\t\t\t<b>{$news->title}</b> {$news_content}\n\t\t\t\t\t\t\t\t\t<br /><br />\n\t\t\t\t\t\t\t\t\tPosted: {$date_posted}\n\t\t\t\t\t\t\t\t</div>";
                 if ($i++ == $count) {
                     break;
                 }
             }
             $this->set('vacentral_news', $contents);
         }
     }
 }
Ejemplo n.º 11
0
<?php

include 'core/codon.config.php';
error_reporting(E_ALL);
ini_set('display_errors', 'on');
echo '<pre>';
CodonCache::setStatus(false);
$cws = new CodonWebService();
$xml = $cws->get('http://www.vacentral.net/airline/cva_canadianvirtualairlines/xml');
$xml = simplexml_load_string($xml);
echo "Our airline's rank is {$xml->rank}";
print_r($_POST);
echo 'set names<br>';
//$results = DB::query("SET NAMES 'utf8'");
DB::debug();
$params = array('column' => 'value', 'dateadded = CURDATE()', 'fruit' => array('apples', 'oranges', 'grapes'));
echo DB::build_where($params);
echo 'schedules<br>';
echo DB::build_where(array('params' => array('value1')));
//$results = DB::query('SELECT * FROM phpvms_schedules');
//$results = DB::query("SET NAMES 'utf8'");
?>

<form action="" method="post">
	<input type="hidden" name="name" value="Omega-Air" />
	<input type="submit" name="submit" value="Submit" />
</form>

Ejemplo n.º 12
0
    /**
     * StatsData::PilotAircraftFlownCounts()
     * 
     * @param mixed $pilotid
     * @return
     */
    public static function PilotAircraftFlownCounts($pilotid)
    {
        $key = 'ac_flown_counts_' . $pilotid;
        $counts = CodonCache::read($key);
        if ($counts === false) {
            //Select aircraft types
            $sql = 'SELECT a.name AS aircraft, COUNT(p.aircraft) AS count, SUM(p.flighttime) AS hours
					FROM ' . TABLE_PREFIX . 'pireps p, ' . TABLE_PREFIX . 'aircraft a 
					WHERE p.aircraft = a.id AND p.pilotid=' . intval($pilotid) . '
					GROUP BY a.name';
            $counts = DB::get_results($sql);
            CodonCache::write($key, $counts, 'medium');
        }
        return $counts;
    }