public function execute($parameters, $db) { $result = $db->query("select b.hash, a.killID from zz_killmails a left join (select hash, count(*) as count from zz_killmails where processed = 1 group by 1 having count(*) >= 2) as b on (a.hash = b.hash) where b.hash is not null and a.killID < 0", array(), 0); foreach ($result as $row) { $hash = $row["hash"]; $mKillID = $row["killID"]; $killID = $db->queryField("select killID from zz_killmails where hash = :hash and killID > 0 limit 1", "killID", array(":hash" => $hash), 0); Kills::cleanDupe($mKillID, $killID); } Log::log("Cleaned up " . sizeof($result) . " dupes"); }
/** * @param string $keyID string * @param $charID int * @param $killlog string * @return int */ public static function processRawApi($keyID, $charID, $killlog) { $count = 0; $maxKillID = Db::queryField("select maxKillID from zz_api_characters where keyID = :keyID and characterID = :charID", "maxKillID", array(":keyID" => $keyID, ":charID" => $charID), 0); if ($maxKillID === null) { $maxKillID = 0; } $insertedMaxKillID = $maxKillID; foreach ($killlog->kills as $kill) { $killID = $kill->killID; //if ($killID < $maxKillID) continue; $insertedMaxKillID = max($insertedMaxKillID, $killID); $json = json_encode($kill->toArray()); $hash = Util::getKillHash(null, $kill); try { $mKillID = Db::queryField("select killID from zz_killmails where killID < 0 and processed = 1 and hash = :hash", "killID", array(":hash" => $hash), 0); } catch (Exception $ex) { $mKillID = 0; //Log::log("Error: $keyID " . $ex->getMessage()); } if ($mKillID) { Kills::cleanDupe($mKillID, $killID); } $added = Db::execute("insert ignore into zz_killmails (killID, hash, source, kill_json) values (:killID, :hash, :source, :json)", array(":killID" => $killID, ":hash" => $hash, ":source" => "keyID:{$keyID}", ":json" => $json)); $count += $added; } if ($maxKillID != $insertedMaxKillID) { Db::execute("INSERT INTO zz_api_characters (keyID, characterID, maxKillID) VALUES (:keyID, :characterID, :maxKillID) ON DUPLICATE KEY UPDATE maxKillID = :maxKillID", array(":keyID" => $keyID, ":characterID" => $charID, ":maxKillID" => $insertedMaxKillID)); } return $count; }
/** * @param \Pheal\Core\Result $data * @param mixed $db * @return int */ private static function processAPI($data, $db) { $count = 0; foreach ($data->kills as $kill) { if ($kill->killID > 0) { $killID = $kill->killID; } else { $killID = $kill->killInternalID * -1; } if ($killID == 0) { continue; } $killArray = $kill->toArray(); // Remove all the unwanted crud that EDK sets unset($killArray["killInternalID"]); unset($killArray["hash"]); unset($killArray["trust"]); // If the killID is below zero, we'll just replace the killID in the array with the minus one.. if ($killID < 0) { $killArray["killID"] = $killID; } $json = json_encode($killArray); $hash = Util::getKillHash(null, $kill); $source = "EDK Feed Fetch"; $mKillID = $db->queryField("select killID from zz_killmails where killID < 0 and processed = 1 and hash = :hash", "killID", array(":hash" => $hash), 0); if ($mKillID) { Kills::cleanDupe($mKillID, $killID); } // If the killID is negative at this point, we need to create a raw mail, and use that to insert it into the zz_manual_mails table, so we can get a manual mail id if ($killID < 0) { $rawText = Kills::getRawMail(null, Info::addInfo($killArray)); $db->execute("INSERT IGNORE INTO zz_manual_mails (hash, rawText) VALUES (:hash, :rawText)", array(":hash" => $hash, ":rawText" => $rawText)); $killID = $db->queryField("SELECT mKillID FROM zz_manual_mails WHERE hash = :hash ORDER BY mKillID DESC LIMIT 1", array(":hash" => $hash), 0); } $added = $db->execute("insert ignore into zz_killmails (killID, hash, source, kill_json) values (:killID, :hash, :source, :json)", array(":killID" => $killID, ":hash" => $hash, ":source" => $source, ":json" => $json)); $count += $added; } return $count; }