Example #1
0
 public function execute($nick, $uhost, $channel, $command, $parameters, $nickAccessLevel)
 {
     if (sizeof($parameters) == 0 || $parameters[0] == "") {
         irc_error("Usage: |g|.z help <command>|n| To see the list of commands: |g|.z commands|n|");
     }
     $command = $parameters[0];
     $base = __DIR__;
     $fileName = "{$base}/irc_{$command}.php";
     if (!file_exists($fileName)) {
         irc_error("|r|Unknown command: {$command} |n|");
     }
     require_once $fileName;
     $className = "irc_{$command}";
     $class = new $className();
     if (!is_a($class, "ircCommand")) {
         irc_error("|r|Module {$command} does not implement interface ircCommand!|n|");
     }
     $dscr = $class->getDescription();
     irc_out("{$command}: {$dscr}");
 }
 public function execute($nick, $uhost, $channel, $command, $parameters, $nickAccessLevel)
 {
     if (Util::isMaintenanceMode()) {
         irc_error("|r|Cannot reprice while in maintenance mode");
     }
     @($killID = (int) $parameters[0]);
     if ($killID == 0) {
         irc_error("|r|Please provide a valid killID.");
     }
     $count = Db::queryField("select count(*) count from zz_participants where killID = :killID", "count", array(":killID" => $killID));
     if ($count == 0) {
         irc_error("|r|KillID {$killID} does not exist!");
     }
     Stats::calcStats($killID, false);
     Db::execute("update zz_killmails set processed = 0 where killID = :killID", array(":killID" => $killID));
     do {
         sleep(1);
         $processed = Db::queryField("select processed from zz_killmails where killID = :killID", "processed", array(":killID" => $killID), 0);
     } while ($processed == 0);
     $kill = Db::queryRow("select * from zz_participants where isVictim = 1 and killID = :killID", array(":killID" => $killID), 0);
     $total = $kill["total_price"];
     $points = $kill["points"];
     irc_out("|g|{$killID}|n| repriced to|g| " . number_format($total, 2) . "|n| ISK and |g|" . number_format($points, 0) . "|n| points");
 }
Example #3
0
        irc_error("Module {$command} does not implement interface ircCommand!");
    }
    $accessLevel = Db::queryField("select accessLevel from zz_irc_access where name = :name and host = :host", "accessLevel", array(":name" => $nick, ":host" => $uhost), 0);
    if ($accessLevel === null) {
        $accessLevel = 0;
    }
    if ($accessLevel < $class->getRequiredAccessLevel()) {
        irc_error("You do not have access to the {$command} command.");
    }
    $params = implode(" ", $params);
    $params = trim($params);
    $params = explode(" ", $params);
    irc_log($nick, $uhost, $command, $params);
    $class->execute($nick, $uhost, $channel, $command, $params, $accessLevel);
} catch (Exception $ex) {
    irc_error("{$command} ended with error: " . $ex->getMessage());
}
function irc_log($nick, $uhost, $command, $params)
{
    $id = Db::queryField("SELECT id FROM zz_irc_access WHERE name = :nick AND host = :uhost", "id", array(":nick" => $nick, ":uhost" => $uhost));
    if ($id == null) {
        $id = 0;
    }
    Db::execute("INSERT INTO zz_irc_log (id, nick, command, parameters) VALUES (:id, :nick, :command, :params)", array(":nick" => $nick, ":id" => $id, ":command" => $command, ":params" => implode(" ", $params)));
}
function irc_error($text)
{
    $text = Log::addIRCColors($text);
    irc_out($text);
    die;
}
 public function execute($nick, $uhost, $channel, $command, $parameters, $nickAccessLevel)
 {
     $keyIDs = array();
     $entity = trim(implode(" ", $parameters));
     if ($entity == "all") {
         Db::execute("update zz_api_characters set lastChecked = 0, cachedUntil = 0, maxKillID = 0, errorCode = 0 where errorCode != 0");
         Db::execute("update zz_api set lastValidation = 0, errorCode = 0 where errorCode != 0");
         irc_out("|g|All API keys have been reset.");
         return;
     }
     if (strlen($entity) == 0) {
         irc_error("|r|Please specify a name, keyID, or all");
     }
     if (sizeof($parameters) == 1 && (int) $parameters[0]) {
         $keyIDs[] = (int) $parameters[0];
     } else {
         // Perform a search
         $chars = array();
         $corps = array();
         $charResult = Db::query("select characterID from zz_characters where name = :s", array(":s" => $entity));
         foreach ($charResult as $char) {
             $chars[] = $char["characterID"];
         }
         foreach ($chars as $charID) {
             $corpID = Db::queryField("select corporationID from zz_participants where characterID = :c order by killID desc limit 1", "corporationID", array(":c" => $charID));
             if ($corpID !== null && $corpID > 0) {
                 $corps[] = $corpID;
             }
         }
         if (sizeof($chars)) {
             $keys = Db::query("select distinct keyID from zz_api_characters where isDirector = 'F' and characterID in (" . implode(",", $chars) . ")");
             foreach ($keys as $key) {
                 $keyIDs[] = $key["keyID"];
             }
         } else {
             $corpID = Db::queryField("select corporationID from zz_corporations where name = :s order by memberCount desc", "corporationID", array(":s" => $entity));
             if ($corpID !== null && $corpID > 0) {
                 $corps[] = $corpID;
             }
         }
         if (sizeof($corps)) {
             $keys = Db::query("select distinct keyID from zz_api_characters where isDirector = 'T' and corporationID in (" . implode(",", $corps) . ")");
             foreach ($keys as $key) {
                 $keyIDs[] = $key["keyID"];
             }
         }
     }
     if (sizeof($keyIDs) == 0) {
         irc_out("|r|Unable to locate any keys associated with {$entity} |n|");
     } else {
         $keyIDs = array_unique($keyIDs);
         sort($keyIDs);
         $key = sizeof($keyIDs) == 1 ? "keyID" : "keyIDs";
         $keys = implode(", ", $keyIDs);
         Db::execute("update zz_api_characters set lastChecked = 0, cachedUntil = 0, maxKillID = 0 where keyID in ({$keys})");
         Db::execute("update zz_api set lastValidation = 0, errorCode = 0 where keyID in ({$keys})");
         if (sizeof($keyIDs)) {
             irc_out("Resetting {$key}: {$keys}");
         }
     }
 }