public function isOldKey($userID, $APIKey) { PhealConfig::getInstance()->api_customkeys = false; $data = $this->CallAPI("account", "Characters", null, $userID, $APIKey); if ($data == false) { return false; } return true; }
function fetchXML() { PhealConfig::getInstance()->http_timeout = 5; try { $data = $this->CallAPI("server", "ServerStatus", null, null, null); } catch (Exception $e) { return false; } if ($data == false) { return false; } self::$serverOpen = (bool) $data->serverOpen; self::$onlinePlayers = (int) $data->onlinePlayers; return true; }
/** * method will do the actual http call using file() * remember: on some installations, file_get_contents(url) might not be available due to * restrictions via allow_url_fopen * @param String $url url beeing requested * @param array $opts an array of query paramters * @return string raw http response */ public static function request_http_file($url, $opts) { $options = array(); $options['http'] = array(); $options['http']['ignore_errors'] = true; // set custom user agent if (($http_user_agent = PhealConfig::getInstance()->http_user_agent) != false) { $options['http']['user_agent'] = $http_user_agent; } // set custom http timeout if (($http_timeout = PhealConfig::getInstance()->http_timeout) != false) { $options['http']['timeout'] = $http_timeout; } // ignore ssl peer verification if needed if (substr($url, 5) == "https") { $options['ssl']['verify_peer'] = PhealConfig::getInstance()->http_ssl_verifypeer; } // use post for params if (count($opts) && PhealConfig::getInstance()->http_post) { $options['http']['method'] = 'POST'; $options['http']['content'] = http_build_query($opts, '', '&'); } elseif (count($opts)) { $url .= "?" . http_build_query($opts, '', '&'); } // set track errors. needed for $php_errormsg $oldTrackErrors = ini_get('track_errors'); ini_set('track_errors', true); // create context with options and request api call // suppress the 'warning' message which we'll catch later with $php_errormsg if (count($options)) { $context = stream_context_create($options); $result = @file_get_contents($url, false, $context); } else { $result = @file_get_contents($url); } // check for http errors via magic $http_response_header $httpCode = 200; if (isset($http_response_header[0])) { list($httpVersion, $httpCode, $httpMsg) = explode(' ', $http_response_header[0], 3); } // http errors if (is_numeric($httpCode) && $httpCode >= 400) { switch ($httpCode) { case 400: case 403: case 500: case 503: return $result; break; default: } throw new PhealHTTPException($httpCode, $url); } // throw error if ($result === false) { $message = $php_errormsg ? $php_errormsg : 'HTTP Request Failed'; // set track_errors back to the old value ini_set('track_errors', $oldTrackErrors); throw new PhealConnectionException($message); // return result } else { // set track_errors back to the old value ini_set('track_errors', $oldTrackErrors); return $result; } }
/** * Return Instance of PhealConfig Object * @return PhealConfig */ public static function getInstance() { if (is_null(self::$myInstance)) { self::$myInstance = new PhealConfig(); } return self::$myInstance; }
function IsCached() { $isCached = (bool) PhealConfig::getInstance()->cache->load($keyID, $vCode, $this->options['scope'], $this->options['name'], $api['args']); }
/** * logs failed request api call including options and error message * @param string $scope * @param string $name * @param array $opts * @param string $message */ public function errorLog($scope, $name, $opts, $message) { // stop measure the response time $this->stop(); // get filename, return if disabled if (!($filename = $this->filename('error_log'))) { return false; } // remove htmltags, newlines, and coherent blanks $message = preg_replace("/(\\s\\s+|[\n\r])/", ' ', strip_tags($message)); // log file_put_contents($filename, sprintf($this->options['error_format'], date('r'), PhealConfig::getInstance()->http_post ? 'POST' : 'GET', $this->responseTime, $this->formatUrl($scope, $name, $opts), $message), FILE_APPEND); }
function Api() { require_once "../common/pheal/Pheal.php"; spl_autoload_register("Pheal::classload"); PhealConfig::getInstance()->http_method = 'curl'; PhealConfig::getInstance()->http_post = false; PhealConfig::getInstance()->http_keepalive = true; PhealConfig::getInstance()->http_keepalive = 10; PhealConfig::getInstance()->http_timeout = 60; PhealConfig::getInstance()->http_ssl_verifypeer = false; }
<?php if (!defined("APP_PATH")) { define("APP_PATH", realpath(dirname(__FILE__) . "/..")); } King23_Classloader::init(APP_PATH . "/lib/King23/lib"); King23_Classloader::init(APP_PATH . "/views"); King23_Classloader::init(APP_PATH . "/lib/Kingboard"); King23_Classloader::init(APP_PATH . "/lib/PHPMarkdown"); King23_Classloader::init(APP_PATH . "/model"); $reg = King23_Registry::getInstance(); // set this to your host $reg->baseHost = "kings-of-eve.com"; $connection = new Mongo('localhost'); $reg->mongo = array('connection' => $connection, 'db' => $connection->Kingboard); King23_Classloader::init(APP_PATH . "/lib/Pheal"); $pc = PhealConfig::getInstance(); $pc->cache = new PhealFileCache(APP_PATH . "/cache/"); // Sith Template configuration require_once APP_PATH . "/lib/SithTemplate/lib/SithTemplate.php"; $reg->sith = new TemplateEnviron(array('inputPrefix' => APP_PATH . "/templates/", 'outputPrefix' => APP_PATH . "/templates_c/", 'loadPlugins' => true, 'useDefaultPluginsPath' => true, 'pluginsPaths' => array(APP_PATH . "/lib/Kingboard/SithPlugin/"), 'recompilationMode' => 1, 'defaultIODriver' => "file", 'autoEscape' => false)); $reg->imagePaths = array('ships' => 'http://image.eveonline.com/Render/', 'items' => 'http://image.eveonline.com/Type/', 'characters' => 'http://image.eveonline.com/Character/', 'corporations' => 'http://image.eveonline.com/Corporation/', 'alliances' => 'http://image.eveonline.com/Alliance/'); $reg->apimailreceiver = "CHARACTERNAME"; $reg->apimailreceiverCharacterID = 123456; $reg->apimailreceiverApiUserID = "123456"; $reg->apimailreceiverApiKey = "APIKEYHERE"; // this can be fetched from a specific ownerID provider // which maps host to id for example on hosted boards $reg->ownerID = 99000289; require_once "routes.php"; session_start();