/** * Fetch a new feed. */ private function fetch() { if (!$this->url) { return false; } $this->posted = array(); $this->skipped = array(); $this->duplicate = array(); $this->lastReturned = 0; $this->time = ''; $this->cachedTime = ''; global $idfeedversion; $http = new http_request($this->getFullURL()); $http->set_useragent("EDK IDFeedfetcher " . $idfeedversion); $http->set_timeout(300); //accept gzip encoding $http->set_header('Accept-Encoding: gzip'); if (strpos($http->get_header(), 'Content-Encoding: gzip') !== false) { $this->xml = gzdecode($http->get_content()); } else { $this->xml = $http->get_content(); } if ($http->get_http_code() != 200) { trigger_error("HTTP error " . $http->get_http_code() . " while fetching feed from " . $this->url . $options . ".", E_USER_WARNING); return false; } if ($this->xml) { return true; } else { return false; } }
/** * Fetch an image from the image server. * * Returns the image resource or false on failure. * @param integer $id * @param integer $size * @return resource|boolean The image resource or false on failure. */ private static function fetchImage($id, $size = 64) { $url = 'http://' . IMG_SERVER . "/" . "InventoryType" . "/" . $id . "_" . $size . ".png"; if (function_exists('curl_init')) { // in case of a dead eve server we only want to wait 2 seconds @ini_set('default_socket_timeout', 2); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); $file = curl_exec($ch); //list($header, $file) = explode("\n\n", $file, 2); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); } else { // in case of a dead eve server we only want to wait 2 seconds @ini_set('default_socket_timeout', 2); // try alternative access via fsockopen // happens if allow_url_fopen wrapper is false $http = new http_request($url); $file = $http->get_content(); $http_code = $http->get_http_code(); } return @imagecreatefromstring($file); }
function fetchImage($id, $type = 'Character', $size = 128, $ext = "jpg") { include_once 'kbconfig.php'; require_once 'common/includes/globals.php'; require_once "common/includes/class.cachehandler.php"; $url = 'http://' . IMG_SERVER . "/" . $type . "/" . $id . "_" . $size . "." . $ext; if (function_exists('curl_init')) { // in case of a dead eve server we only want to wait 2 seconds @ini_set('default_socket_timeout', 2); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); // CURLOPT_FOLLOWLOCATION doesn't work if safe mode or open_basedir is set // For pilots we should try from oldportraits.eveonline.com if the main server doesn't have them. //if($type != 'Character') curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //curl_setopt($ch, CURLOPT_HEADER, true); $file = curl_exec($ch); //list($header, $file) = explode("\n\n", $file, 2); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($http_code != 200) { if ($type == 'Character') { $url = "http://oldportraits.eveonline.com/Character/" . $id . "_" . $size . "." . $ext; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $file = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($http_code != 200) { $file = file_get_contents("img/1_{$size}.jpg"); } } else { if ($type == 'Alliance') { $file = file_get_contents("img/alliances/default.png"); } else { if ($type == 'Corporation') { $file = file_get_contents("img/corps/default.png"); } else { show404(); } } } } curl_close($ch); } else { require_once 'common/includes/class.httprequest.php'; // in case of a dead eve server we only want to wait 2 seconds @ini_set('default_socket_timeout', 2); // try alternative access via fsockopen // happens if allow_url_fopen wrapper is false $http = new http_request($url); $file = $http->get_content(); $http_code = $http->get_http_code(); if ($http_code != 200) { if ($type == 'Character') { $url = "http://oldportraits.eveonline.com/Character/" . $id . "_" . $size . "." . $ext; $http = new http_request($url); $file = $http->get_content(); $http_code = $http->get_http_code(); if ($http_code != 200) { $file = file_get_contents("img/1_{$size}.jpg"); } } else { if ($type == 'Alliance') { $file = file_get_contents("img/alliances/default.png"); } else { if ($type == 'Corporation') { $file = file_get_contents("img/corps/default.png"); } else { show404(); } } } } } if ($img = @imagecreatefromstring($file)) { CacheHandler::put($id . '_' . $size . '.' . $ext, $file, 'img'); } return $img; }