Exemplo n.º 1
0
 /**
  * [getCharID description]
  * @param  string $name
  * @return int
  */
 public static function getCharID($name)
 {
     if (Bin::get("s:{$name}", null) != null) {
         return Bin::get("s:{$name}", null);
     }
     $id = (int) Db::queryField("select characterID from zz_characters where name = :name order by corporationID desc", "characterID", array(":name" => $name), 3600);
     if ($id == 0 || $id == NULL) {
         try {
             $pheal = Util::getPheal();
             $pheal->scope = "eve";
             $charInfo = $pheal->CharacterID(array("names" => $name));
             foreach ($charInfo->characters as $char) {
                 $id = $char->characterID;
                 if ($id != 0) {
                     // Verify that this is indeed a character
                     $charInfo = $pheal->CharacterInfo(array("characterid" => $id));
                     // If not a character an error would have been thrown and caught by the catch
                     $name = $charInfo->characterName;
                     Db::execute("insert ignore into zz_characters (characterID, name) values (:id, :name)", array(":id" => $id, ":name" => $name));
                 }
             }
         } catch (Exception $ex) {
             $id = 0;
         }
     }
     Bin::set("s:{$name}", $id);
     return $id;
 }