/** * @param array $parameters * @param Database $db */ public function execute($parameters, $db) { $timer = new Timer(); do { $crests = Db::query("select * from zz_crest_killmail where processed = 0 order by killID limit 30", array(), 0); foreach ($crests as $crest) { try { $killID = $crest["killID"]; $hash = trim($crest["hash"]); $url = "http://public-crest.eveonline.com/killmails/{$killID}/{$hash}/"; $perrymail = \Perry\Perry::fromUrl($url); $killmail = array(); $killmail["killID"] = (int) $killID; $killmail["solarSystemID"] = (int) $perrymail->solarSystem->id; $killmail["killTime"] = str_replace(".", "-", $perrymail->killTime); $killmail["moonID"] = (int) @$perrymail->moon->id; $victim = array(); $killmail["victim"] = self::getVictim($perrymail->victim); $killmail["attackers"] = self::getAttackers($perrymail->attackers); $killmail["items"] = self::getItems($perrymail->victim->items); $json = json_encode($killmail); $killmailHash = Util::getKillHash(null, json_decode($json)); Db::execute("insert ignore into zz_killmails (killID, hash, source, kill_json) values (:killID, :hash, :source, :json)", array(":killID" => $killID, ":hash" => $hash, ":source" => "crest:{$killID}", ":json" => $json)); Db::execute("update zz_crest_killmail set processed = 1 where killID = :killID", array(":killID" => $killID)); // Write this file to eve-kill's parse directory $xml = Util::xmlOut(array($killmail), array()); $file = "/var/killboard/zkb_killlogs/0_0_{$killID}.xml"; @unlink($file); @error_log($xml, 3, $file); } catch (Exception $ex) { Db::execute("update zz_crest_killmail set processed = -1 where killID = :killID", array(":killID" => $killID)); } } if (count($crests) == 0) { sleep(1); } } while ($timer->stop() < 65000); }
public static function getCrest($url) { \Perry\Setup::$fetcherOptions = ['connect_timeout' => 15, 'timeout' => 30]; return \Perry\Perry::fromUrl($url); }
/** * call method, allows references to be called * * @param array $args * @return Base * @throws \Exception */ public function call($args = array()) { return Perry::fromUrl($this->href, $this->perryReferredType); }