Exemple #1
0
 private static function send_xml()
 {
     // Cover old and new format
     $api_server = Config::Get('VACENTRAL_API_SERVER');
     if ($api_server == '') {
         $api_server = Config::Get('PHPVMS_API_SERVER');
     }
     ob_start();
     $web_service = new CodonWebService();
     $options = array(CURLOPT_USERAGENT => 'phpVMS (' . PHPVMS_VERSION . ')');
     $web_service->setOptions($options);
     self::$xml_response = $web_service->post($api_server . '/update', self::$xml->asXML());
     if (!self::$xml_response) {
         if (Config::Get('VACENTRAL_DEBUG_MODE') == true) {
             Debug::log(self::$method . ' - ' . date('h:i:s A - m/d/Y'), 'vacentral');
             Debug::log(print_r($web_service->errors, true), 'vacentral');
         }
         self::$last_error = 'No response from API server';
         return false;
     }
     self::$response = @simplexml_load_string(self::$xml_response);
     ob_end_clean();
     if (!is_object(self::$response)) {
         if (Config::Get('VACENTRAL_DEBUG_MODE') == true) {
             Debug::log(self::$method . ' - ' . date('h:i:s A - m/d/Y'), 'vacentral');
             Debug::log('   - no response from server', 'vacentral');
         }
         self::$last_error = 'No response from API server';
         return false;
     }
     if (Config::Get('VACENTRAL_DEBUG_MODE') == true) {
         Debug::log(self::$method . ' - ' . date('h:i:s A - m/d/Y'), 'vacentral');
         Debug::log('   - ' . (string) self::$response->detail, 'vacentral');
         Debug::log('   - ' . (string) self::$response->dbg, 'vacentral');
         # Extra detail
         if (Config::Get('VACENTRAL_DEBUG_DETAIL') == '2') {
             Debug::log('SENT XML: ', 'vacentral');
             Debug::log(self::$xml->asXML(), 'vacentral');
             Debug::log('RECIEVED XML: ', 'vacentral');
             Debug::log(self::$response->asXML(), 'vacentral');
             Debug::log('', 'vacentral');
         }
     }
     if ((int) self::$response->responsecode != 200) {
         if (Config::Get('VACENTRAL_DEBUG_MODE') == true) {
             Debug::log(self::$method . ' - ', 'vacentral');
             Debug::log('   - ' . (string) self::$response->message->detail, 'vacentral');
         }
         self::$last_error = self::$response->message->detail;
         return false;
     }
     return true;
 }
Exemple #2
0
 public function get_vatsim_data()
 {
     //get new file from Vatsim if it is more than 5 minutes old
     if (!file_exists('vatsimdata.txt') || time() - filemtime('vatsimdata.txt') > 300) {
         //choose a random download location per VATSIM policy
         $random = rand(1, 4);
         if ($random == 1) {
             $url = 'http://www.net-flyer.net/DataFeed/vatsim-data.txt';
         }
         if ($random == 2) {
             $url = 'http://www.klain.net/sidata/vatsim-data.txt';
         }
         if ($random == 3) {
             $url = 'http://fsproshop.com/servinfo/vatsim-data.txt';
         }
         if ($random == 4) {
             $url = 'http://info.vroute.net/vatsim-data.txt';
         }
         //get the file
         $file = new CodonWebService();
         $contents = @$file->get($url);
         //save new file to server
         $newfile = "vatsimdata.txt";
         $file = fopen($newfile, "w");
         fwrite($file, $contents);
         fclose($file);
     }
     $contents = file('vatsimdata.txt');
     $this->section = array();
     $readsection = false;
     foreach ($contents as $line) {
         if (preg_match("/.*{$find}.*/i", $line, $matches)) {
             $readsection = true;
             continue;
         }
         if ($readsection) {
             if (trim($line) == ';') {
                 break;
             }
             $this->section[] = $line;
             $this->count++;
         }
     }
 }
Exemple #3
0
 /**
  * Send current installation data to phpVMS server
  * 
  * @param string $version
  * @return void
  */
 public static function RegisterInstall($version = '')
 {
     if ($version == '') {
         $version = PHPVMS_VERSION;
     }
     $ext = serialize(get_loaded_extensions());
     $params = new SimpleXMLElement('<registration/>');
     $params->addChild('name', SITE_NAME);
     $params->addChild('url', SITE_URL);
     $params->addChild('version', $version);
     $params->addChild('php', phpversion());
     $params->addChild('mysql', @mysql_get_server_info());
     $params->addChild('ext', $ext);
     $url = 'http://api.phpvms.net/register';
     error_reporting(0);
     $file = new CodonWebService();
     $response = $file->post($url, $params->asXML());
 }
 /**
  * This generates the forum signature of a pilot which
  *  can be used wherever. It's dynamic, and adjusts it's
  *  size, etc based on the background image.
  * 
  * Each image is output into the /lib/signatures directory,
  *  and is named by the pilot code+number (ie, VMA0001.png)
  * 
  * This is called whenever a PIREP is accepted by an admin,
  *  as not to burden a server with image generation
  * 
  * Also requires GD to be installed on the server
  * 
  * @param int The pilot ID for which to generate a signature for
  * @return bool Success
  */
 public static function generateSignature($pilotid)
 {
     $pilot = self::getPilotData($pilotid);
     $pilotcode = self::getPilotCode($pilot->code, $pilot->pilotid);
     if (Config::Get('TRANSFER_HOURS_IN_RANKS') === true) {
         $totalhours = $pilot->totalhours + $pilot->transferhours;
     } else {
         $totalhours = $pilot->totalhours;
     }
     # Configure what we want to show on each line
     $output = array();
     $output[] = $pilotcode . ' ' . $pilot->firstname . ' ' . $pilot->lastname;
     $output[] = $pilot->rank . ', ' . $pilot->hub;
     $output[] = 'Total Flights: ' . $pilot->totalflights;
     $output[] = 'Total Hours: ' . $totalhours;
     if (Config::Get('SIGNATURE_SHOW_EARNINGS') == true) {
         $output[] = 'Total Earnings: ' . (floatval($pilot->totalpay) + floatval($pilot->payadjust));
     }
     # Load up our image
     # Get the background image the pilot selected
     if (empty($pilot->bgimage)) {
         $bgimage = SITE_ROOT . '/lib/signatures/background/background.png';
     } else {
         $bgimage = SITE_ROOT . '/lib/signatures/background/' . $pilot->bgimage;
     }
     if (!file_exists($bgimage)) {
         # Doesn't exist so use the default
         $bgimage = SITE_ROOT . '/lib/signatures/background/background.png';
         if (!file_exists($bgimage)) {
             return false;
         }
     }
     $img = @imagecreatefrompng($bgimage);
     if (!$img) {
         $img = imagecreatetruecolor(300, 50);
     }
     $height = imagesy($img);
     $width = imagesx($img);
     $txtcolor = str_replace('#', '', Config::Get('SIGNATURE_TEXT_COLOR'));
     $color = sscanf($txtcolor, '%2x%2x%2x');
     $textcolor = imagecolorallocate($img, $color[0], $color[1], $color[2]);
     $font = 3;
     // Set the font-size
     $xoffset = Config::Get('SIGNATURE_X_OFFSET');
     # How many pixels, from left, to start
     $yoffset = Config::Get('SIGNATURE_Y_OFFSET');
     # How many pixels, from top, to start
     $font = Config::Get('SIGNATURE_FONT_PATH');
     $font_size = Config::Get('SIGNATURE_FONT_SIZE');
     if (function_exists('imageantialias')) {
         imageantialias($img, true);
     }
     /* Font stuff */
     if (!function_exists('imagettftext')) {
         Config::Set('SIGNATURE_USE_CUSTOM_FONT', false);
     }
     # The line height of each item to fit nicely, dynamic
     if (Config::Get('SIGNATURE_USE_CUSTOM_FONT') == false) {
         $stepsize = imagefontheight($font);
         $fontwidth = imagefontwidth($font);
     } else {
         // get the font width and step size
         $bb = imagettfbbox($font_size, 0, $font, 'A');
         $stepsize = $bb[3] - $bb[5] + Config::Get('SIGNATURE_FONT_PADDING');
         $fontwidth = $bb[2] - $bb[0];
     }
     $currline = $yoffset;
     $total = count($output);
     for ($i = 0; $i < $total; $i++) {
         if (Config::Get('SIGNATURE_USE_CUSTOM_FONT') == false) {
             imagestring($img, (int) $font, $xoffset, $currline, $output[$i], $textcolor);
         } else {
             // Use TTF
             $tmp = imagettftext($img, $font_size, 0, $xoffset, $currline, $textcolor, $font, $output[$i]);
             // Flag is placed at the end of of the first line, so have that bounding box there
             if ($i == 0) {
                 $flag_bb = $tmp;
             }
         }
         $currline += $stepsize;
     }
     # Add the country flag, line it up with the first line, which is the
     #	pilot code/name
     $country = strtolower($pilot->location);
     if (file_exists(SITE_ROOT . '/lib/images/countries/' . $country . '.png')) {
         $flagimg = imagecreatefrompng(SITE_ROOT . '/lib/images/countries/' . $country . '.png');
         if (Config::Get('SIGNATURE_USE_CUSTOM_FONT') == false) {
             $ret = imagecopy($img, $flagimg, strlen($output[0]) * $fontwidth, $yoffset + $stepsize / 2 - 5.5, 0, 0, 16, 11);
         } else {
             # figure out where it would go
             $ret = imagecopy($img, $flagimg, $flag_bb[4] + 5, $flag_bb[5] + 2, 0, 0, 16, 11);
         }
     }
     # Add the Rank image
     if (Config::Get('SIGNATURE_SHOW_RANK_IMAGE') == true && $pilot->rankimage != '') {
         $cws = new CodonWebService();
         $rankimg = @$cws->get($pilot->rankimage);
         $rankimg = imagecreatefromstring($rankimg);
         if (!$rankimg) {
             echo '';
         } else {
             $r_width = imagesx($rankimg);
             $r_height = imagesy($rankimg);
             imagecopy($img, $rankimg, $width - $r_width - $xoffset, $yoffset, 0, 0, $r_width, $r_height);
         }
     }
     if (Config::Get('SIGNATURE_SHOW_COPYRIGHT') == true) {
         #
         #  DO NOT remove this, as per the phpVMS license
         $font = 1;
         $text = 'powered by phpvms, ' . SITE_NAME . ' ';
         imagestring($img, $font, $width - strlen($text) * imagefontwidth($font), $height - imagefontheight($font), $text, $textcolor);
     }
     imagepng($img, SITE_ROOT . SIGNATURE_PATH . '/' . $pilotcode . '.png', 1);
     imagedestroy($img);
 }
 protected static function navDetailsFromServer($navpoints)
 {
     if (!is_array($navpoints) && count($navpoints) == 0) {
         return array();
     }
     /*	Send a simple XML string over:
     		
     			<phpvms>
     				<navpoints>
     					<navpoint>NAME</navpoint>
     					<navpoint>NAME2</navpoint>
     				</navpoints>
     			</phpvms>
     			
     			
     			@TODO: Convert send format to json, much smaller
     		*/
     $xml = new SimpleXMLElement('<phpvms/>');
     $nav_xml = $xml->addChild('navpoints');
     foreach ($navpoints as $p) {
         $nav_xml->addChild('navpoint', $p);
     }
     /*	Send the request, data is returned as JSON format */
     $web_service = new CodonWebService();
     $xml_response = $web_service->post(Config::Get('PHPVMS_API_SERVER') . '/navdata/get/json', $xml->asXML());
     $insert = array();
     $sql = 'INSERT INTO ' . TABLE_PREFIX . "navdata\n\t\t\t\t(`type`, `name`, `title`, `freq`, `lat`, `lng`) VALUES ";
     if (empty($xml_response)) {
         /*	None of those exist on the server, but cache them on this
         			side so we don't keep checking over and over */
         foreach ($navpoints as $point) {
             $insert[] = "(0, '{$point}', '{$point}', '0', '0', '0')";
         }
         $sql .= implode(',', $insert);
         DB::query($sql);
         return array();
     }
     $returned_points = json_decode($xml_response);
     if (empty($returned_points)) {
         foreach ($navpoints as $point) {
             $insert[] = "(0, '{$point}', '{$point}', '0', '0', '0')";
         }
         $sql .= implode(',', $insert);
         DB::query($sql);
         return array();
     }
     $return = array();
     foreach ($returned_points as $point) {
         $keys = array_keys($navpoints, $point->name);
         foreach ($keys as $k) {
             unset($navpoints[$k]);
         }
         $return[$point->name][] = $point;
         $insert[] = "({$point->type}, '{$point->name}', '{$point->title}', '{$point->freq}', '{$point->lat}', '{$point->lng}')";
     }
     // Then the ones not listed
     foreach ($navpoints as $point) {
         $insert[] = "(0, '{$point}', '{$point}', '0', '0', '0')";
     }
     $sql .= implode(',', $insert);
     DB::query($sql);
     return $return;
 }
 /**
  * Retrieve Airport Information
  */
 public static function RetrieveAirportInfo($icao)
 {
     $icao = strtoupper($icao);
     if (Config::Get('AIRPORT_LOOKUP_SERVER') == 'geonames') {
         $url = Config::Get('GEONAME_API_SERVER') . '/searchJSON?maxRows=1&style=medium&featureCode=AIRP&type=json&q=' . $icao;
     } elseif (Config::Get('AIRPORT_LOOKUP_SERVER') == 'phpvms') {
         $url = Config::Get('PHPVMS_API_SERVER') . '/index.php/airport/get/' . $icao;
     }
     # Updated to use CodonWebServer instead of simplexml_load_url() straight
     #	Could cause errors
     $file = new CodonWebService();
     $contents = @$file->get($url);
     $reader = json_decode($contents);
     if ($reader->totalResultsCount == 0 || !$reader) {
         return false;
     } else {
         if (isset($reader->geonames)) {
             $apt = $reader->geonames[0];
         } elseif (isset($reader->airports)) {
             $apt = $reader->airports[0];
         }
         if (!isset($apt->jeta)) {
             $apt->jeta = '';
         }
         // Add the AP
         $data = array('icao' => $icao, 'name' => $apt->name, 'country' => $apt->countryName, 'lat' => $apt->lat, 'lng' => $apt->lng, 'hub' => false, 'fuelprice' => $apt->jeta);
         OperationsData::addAirport($data);
     }
     return self::GetAirportInfo($icao);
 }
Exemple #7
0
 /**
  * Ask the API server for information about the fuel price
  *  This ignores the cache for retrieval, but does save
  *  to the cache on successful completion. Returns false
  *  if failed
  * 
  * Best practice is to use GetFuelPrice() which will
  *  check the cache before checking the server
  *
  * @param string $apt_icao Airport ICAO
  * @return float Returns the JET-A fuelprice
  *
  */
 public static function get_from_server($apt_icao)
 {
     if ($apt_icao == '') {
         return false;
     }
     # Bug fix, get the proper units from API server
     $unit = Config::Get('LIQUID_UNIT_NAMES', Config::Get('LiquidUnit'));
     $url = Config::Get('PHPVMS_API_SERVER') . '/fuel/get/' . $apt_icao . '/' . $unit;
     $curl_loader = new CodonWebService();
     $resp = $curl_loader->get($url);
     if ($resp == '' || $resp === false) {
         return false;
     }
     $results = @simplexml_load_string($resp);
     if ($results === false) {
         return false;
     }
     # Error message tag was there
     if (isset($results->errormessage)) {
         return false;
     } else {
         self::save_cached_price($results);
         return $results->jeta;
     }
 }
 public static function RegisterInstall($version = '')
 {
     if ($version == '') {
         $version = PHPVMS_VERSION;
     }
     $ext = serialize(get_loaded_extensions());
     $params = new SimpleXMLElement('<registration/>');
     $params->addChild('name', SITE_NAME);
     $params->addChild('url', SITE_URL);
     $params->addChild('email', SettingsData::GetSettingValue('ADMIN_EMAIL'));
     $params->addChild('version', $version);
     $params->addChild('php', phpversion());
     $params->addChild('mysql', @mysql_get_server_info());
     $params->addChild('ext', $ext);
     $url = 'http://api.phpvms.net/register';
     # Do fopen(), if that fails then it'll default to
     #	curl
     error_reporting(0);
     $file = new CodonWebService();
     $response = $file->post($url, $params->asXML());
 }
Exemple #9
0
    error('Error!', 'Must be running at least PHP 5.2');
} else {
    $version = phpversion();
    success('OK', "PHP version is {$version}.x");
}
echo '<br />';
echo '<strong>ASP Tags</strong><br />';
$val = ini_get('asp_tags');
if (!empty($val)) {
    error('Error!', 'The setting "asp_tags" in php.ini must be off!');
} else {
    success('OK', 'ASP-style tags are disabled');
}
echo '<br />';
echo '<strong>Checking connectivity...</strong><br />';
$file = new CodonWebService();
$contents = @$file->get(PHPVMS_API_SERVER . '/version');
if ($contents == '') {
    $error = $file->errors[count($file->errors) - 1];
    error('Connection failed', 'Could not connect to remote server - error is "' . $error . '"');
} else {
    success('OK', 'Can contact outside servers');
}
unset($file);
/* Simple XML? */
echo '<br />';
echo '<strong>Checking for SimpleXML module...</strong><br />';
if (function_exists('simplexml_load_string') == true) {
    success('OK', 'SimpleXML module exists!');
} else {
    error('Fail', 'SimpleXML module doesn\'t exist or is not installed. Contact your host');
Exemple #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);
         }
     }
 }
Exemple #11
0
    /**
     * Show the notification that an update is available
     */
    public function CheckForUpdates()
    {
        if (Config::Get('CHECK_RELEASE_VERSION') == true) {
            $url = Config::Get('PHPVMS_API_SERVER') . '/version/get/xml/' . PHPVMS_VERSION;
            # 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);
            if (!$xml) {
                $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;
            }
            $version = $xml->version;
            if (Config::Get('CHECK_BETA_VERSION') == true) {
                $version = $xml->betaversion;
            }
            $postversion = intval(str_replace('.', '', trim($version)));
            $currversion = intval(str_replace('.', '', PHPVMS_VERSION));
            if ($currversion < $postversion) {
                if (Config::Get('CHECK_BETA_VERSION') == true) {
                    $this->set('message', 'A beta version ' . $version . ' is available for download!');
                } else {
                    $this->set('message', 'Version ' . $version . ' is available for download! Please update ASAP');
                }
                $this->set('updateinfo', Template::GetTemplate('core_error.tpl', true));
            }
            /* Retrieve latest news from Feedburner RSS, in case the phpVMS site is down
             */
            $contents = $file->get(Config::Get('PHPVMS_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<b>{$news->title}</b> <br />{$news_content}\n\t\t\t\t\t\t\t\t<br /><br />\n\t\t\t\t\t\t\t\tPosted: {$date_posted}\n\t\t\t\t\t\t\t</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);
            }
        }
    }
Exemple #12
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');
 }
Exemple #13
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>