コード例 #1
0
ファイル: class.idfeed.php プロジェクト: biow0lf/evedev-kb
 /**
  * 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;
     }
 }
コード例 #2
0
 private function loaddata($id)
 {
     $url = API_SERVER . "/eve/CharacterInfo.xml.aspx?characterID=" . urlencode($id);
     $http = new http_request($url);
     $http->set_useragent("PHPApi");
     return $http->get_content();
 }
コード例 #3
0
ファイル: class.standings.php プロジェクト: biow0lf/evedev-kb
 function loaddata($keystring, $typestring)
 {
     $configvalue = $this->API_characterID_ . '_Standings';
     $UseCaching = config::get('API_UseCache');
     $url = API_SERVER . "/" . $typestring . "/Standings.xml.aspx" . $keystring;
     $path = "/" . $typestring . "/Standings.xml.aspx";
     if (is_file(KB_CACHEDIR . '/api/' . $configvalue . '.xml')) {
         $cacheexists = true;
     } else {
         $cacheexists = false;
     }
     if (strtotime(gmdate("M d Y H:i:s")) - strtotime($CachedTime) > 0 || $UseCaching == 1 || !$cacheexists) {
         $http = new http_request($url);
         $http->set_useragent("PHPApi");
         foreach ($keystring as $key => $val) {
             $http->set_postform($key, $val);
         }
         $contents = $http->get_content();
         $start = strpos($contents, "?>");
         if ($start !== FALSE) {
             $contents = substr($contents, $start + strlen("\r\n\r\n"));
         }
         if ($UseCaching == 0) {
             $file = fopen(KB_CACHEDIR . '/api/' . $configvalue . '.xml', 'w+');
             fwrite($file, $contents);
             fclose($file);
             @chmod(KB_CACHEDIR . '/api/' . $configvalue . '.xml', 0666);
         }
     } else {
         // re-use cached XML
         if ($fp = @fopen(KB_CACHEDIR . '/api/' . $configvalue . '.xml', 'r')) {
             $contents = fread($fp, filesize(KB_CACHEDIR . '/api/' . $configvalue . '.xml'));
             fclose($fp);
         } else {
             return "<i>error loading cached file " . $configvalue . ".xml</i><br><br>";
         }
     }
     return $contents;
 }
コード例 #4
0
 function loaddata($keystring)
 {
     $configvalue = $this->CharName_ . '_CharacterSheet';
     $CachedTime = ApiCache::get($configvalue);
     $UseCaching = config::get('API_UseCache');
     $url = API_SERVER . "/char/CharacterSheet.xml.aspx" . $keystring;
     $path = '/char/CharacterSheet.xml.aspx';
     // API Caching system, If we're still under cachetime reuse the last XML, if not download the new one. Helps with Bug hunting and just better all round.
     if ($CachedTime == "") {
         $CachedTime = "2005-01-01 00:00:00";
         // fake date to ensure that it runs first time.
     }
     if (is_file(KB_CACHEDIR . '/api/' . $configvalue . '.xml')) {
         $cacheexists = true;
     } else {
         $cacheexists = false;
     }
     // if API_UseCache = 1 (off) then don't use cache
     if (strtotime(gmdate("M d Y H:i:s")) - strtotime($CachedTime) > 0 || $UseCaching == 1 || !$cacheexists) {
         $http = new http_request($url);
         $http->set_useragent("PHPApi");
         foreach ($keystring as $key => $val) {
             $http->set_postform($key, $val);
         }
         $contents = $http->get_content();
         $start = strpos($contents, "?>");
         if ($start !== FALSE) {
             $contents = substr($contents, $start + strlen("\r\n\r\n"));
         }
         // Save the file if we're caching (0 = true in Thunks world)
         if ($UseCaching == 0) {
             $file = fopen(KB_CACHEDIR . '/api/' . $configvalue . '.xml', 'w+');
             fwrite($file, $contents);
             fclose($file);
             @chmod(KB_CACHEDIR . '/api/' . $configvalue . '.xml', 0666);
         }
     } else {
         // re-use cached XML
         if ($fp = @fopen(KB_CACHEDIR . '/api/' . $configvalue . '.xml', 'r')) {
             $contents = fread($fp, filesize(KB_CACHEDIR . '/api/' . $configvalue . '.xml'));
             fclose($fp);
         } else {
             return "<i>error loading cached file " . $configvalue . ".xml</i><br><br>";
         }
     }
     return $contents;
 }