public function GetOutput($Db)
    {
        /*<img src="http://image.eveonline.com/Character/<?php echo $chid;  ?>_256.jpg" height=118 width=118>*/
        $full_url = FULL_URL;
        // TODO
        $time_start = microtime_float();
        $corpinf = cache_api_retrieve($Db, "/corp/CorporationSheet.xml.aspx", array("corporationID" => CORP_ID), 3 * 24 * 60 * 60)->value;
        $this->Title = "About " . $corpinf->result->corporationName;
        $time_end = microtime_float();
        $time_api = $time_end - $time_start;
        $this->Output .= <<<EOD
<table><tr><td>
<img src="http://image.eveonline.com/Corporation/{$corpinf->result->corporationID}_128.png" height=108 width=108>
</td><td valign=top>
<table>
<tr><td>CEO </td><td>{$corpinf->result->ceoName}</tr>
<tr><td>Members&nbsp;&nbsp;</td><td>{$corpinf->result->memberCount}</tr>
<tr><td>Tax </td><td>{$corpinf->result->taxRate}%</tr>
<tr><td>URL </td><td><a href="{$corpinf->result->url}" target="_blank">{$corpinf->result->url}</a></td></tr>
EOD;
        if ((int) $corpinf->result->allianceID != 0) {
            $this->Output .= "<tr><td>Alliance </td><td>" . $corpinf->result->allianceName . "</tr>";
        }
        $this->Output .= "\r\n\t\t</table>\r\n\t\t</td></table>\r\n\t\t<br>\r\n\t\t<div>";
        $this->Output .= parse_ccptml($corpinf->result->description);
        $this->Output .= "</div><br>";
        $this->Times = getPageTimes($Db, $time_api, microtime_float() - $time_start);
        return true;
    }
 public function fetchMailBody($chid, $usid, $apik, $id)
 {
     $api_ret = cache_api_retrieve($this->Db->link, "/char/MailBodies.xml.aspx", array("characterID" => $chid, "keyID" => $usid, "vCode" => $apik, "ids" => $id));
     if (!$api_ret) {
         return "";
     }
     $body = $api_ret->value->xpath("/eveapi/result/rowset[@name='messages']/row");
     return $body[0];
 }
 private function getTransTypes()
 {
     $trans = cache_api_retrieve($this->Db, "/eve/RefTypes.xml.aspx");
     $transTypeIds = $trans->value;
     $result = $transTypeIds->xpath("/eveapi/result/rowset/row");
     $types = array();
     foreach ($result as $entry) {
         $types[(int) $entry['refTypeID']] = (string) $entry['refTypeName'];
     }
     $this->transTypes = $types;
 }
 protected function fetch_xml($apicall, $args = array(), $override = 0)
 {
     $result = cache_api_retrieve($this->Db->link, $apicall, $args, $override);
     if ($result->http_error) {
         $this->Error = "HTTP error " . $result->value;
         return false;
     }
     if (!$this->APIInit($result)) {
         return false;
     }
     return $this->LoadAPI();
 }
 public function fetchMailBody($chid, $usid, $apik, $id)
 {
     $api_ret = cache_api_retrieve($this->Db, "/char/MailBodies.xml.aspx", array("characterID" => $chid, "keyID" => $usid, "vCode" => $apik, "ids" => $id));
     if (!$api_ret) {
         return "";
     }
     if (is_int($api_ret->value)) {
         return "Http error" . $api_ret->value;
     }
     $body = $api_ret->value->xpath("/eveapi/result/rowset[@name='messages']/row");
     if (empty($body)) {
         return null;
     }
     if (isset($_SESSION) && isset($_SESSION['mailFormatted']) && $_SESSION['mailFormatted'] == true) {
         //should you show the message with or without formatting
         return $body[0];
     } else {
         return preg_replace('#</?font[^>]*>#is', '', $body[0]);
     }
 }
 public function fetchBids($ids)
 {
     $this->hasAuctions = true;
     $args = array("characterID" => $this->chid, "keyID" => $this->usid, "vCode" => $this->apik);
     $sql = "SELECT * FROM " . DB_PREFIX . CONTRACT_BIDS_TABLE . " WHERE contractID IN (" . implode(",", $ids) . ")";
     $result = $this->Db->query($sql);
     $bids = array();
     if ($result) {
         while ($row = mysql_fetch_assoc($result)) {
             $id = (double) $row["contractID"];
             if (!isset($bids[$id])) {
                 $bids[$id] = array();
             }
             $bids[$id][$row["bidID"]] = $row;
         }
         mysql_free_result($result);
     }
     foreach ($bids as &$bidset) {
         usort($bidset, "bids_sortfunc");
     }
     $args = array("characterID" => $this->chid, "keyID" => $this->usid, "vCode" => $this->apik);
     $result = cache_api_retrieve($this->Db->link, "/" . ($this->corp ? "corp" : "char") . "/ContractBids.xml.aspx", $args);
     if ($result->error) {
         $this->bids = $bids;
         return;
     }
     $rows = $result->value->xpath("/eveapi/result/rowset/row");
     if (count($rows) == 0) {
         $this->bids = $bids;
         return;
     }
     $storetosql = array();
     foreach ($rows as $bid) {
         $id = (double) $bid["contractID"];
         $bidid = (double) $bid["bidID"];
         if (!isset($bids[$id])) {
             $bids[$id] = array();
         } else {
             if (isset($bids[$id][$bidid])) {
                 continue;
             }
         }
         $bids[$id][$bidid] = array((double) $bid["amount"], (double) $bid["bidderID"], (string) $bid["dateBid"]);
         $storetosql[] = "({$id},{$bidid}," . (double) $bid["bidderID"] . "," . (double) $bid["amount"] . ",'" . mysql_real_escape_string((string) $bid["dateBid"]) . "')";
     }
     if (count($storetosql) > 0) {
         $sql = "INSERT INTO " . DB_PREFIX . CONTRACT_BIDS_TABLE . " VALUES " . implode(",", $storetosql);
         $result = $this->Db->query($sql);
     }
     foreach ($bids as &$bidset) {
         usort($bidset, "bids_sortfunc");
     }
     $this->bids = $bids;
 }
 public function fetchBids($ids)
 {
     $this->hasAuctions = true;
     $args = array("characterID" => $this->chid, "keyID" => $this->usid, "vCode" => $this->apik);
     //$sql    = "SELECT * FROM ".DB_PREFIX.CONTRACT_BIDS_TABLE." WHERE contractID IN (".implode(",",$ids).")";
     //$result = $this->Db->query($sql);
     $result = $this->Db->selectWhere(CONTRACT_BIDS_TABLE, ['contractID' => ["IN", $ids]]);
     $bids = array();
     if ($result) {
         foreach ($result->results as $row) {
             $id = (double) $row["contractID"];
             if (!isset($bids[$id])) {
                 $bids[$id] = array();
             }
             $bids[$id][$row["bidID"]] = $row;
         }
     }
     foreach ($bids as &$bidset) {
         usort($bidset, "bids_sortfunc");
     }
     $args = array("characterID" => $this->chid, "keyID" => $this->usid, "vCode" => $this->apik);
     $result = cache_api_retrieve($this->Db, "/" . ($this->corp ? "corp" : "char") . "/ContractBids.xml.aspx", $args);
     if ($result->error) {
         $this->bids = $bids;
         return;
     }
     $rows = $result->value->xpath("/eveapi/result/rowset/row");
     if (count($rows) == 0) {
         $this->bids = $bids;
         return;
     }
     $insertStatement = $this->Db->prepare()->insert(CONTRACT_BIDS_TABLE, ['contractID' => '?', 'bidID' => '?', 'bidderID' => '?', 'amount' => '?', 'bidTime' => '?']);
     foreach ($rows as $bid) {
         $id = (double) $bid["contractID"];
         $bidid = (double) $bid["bidID"];
         if (!isset($bids[$id])) {
             $bids[$id] = array();
         } else {
             if (isset($bids[$id][$bidid])) {
                 continue;
             }
         }
         $bids[$id][$bidid] = array((double) $bid["amount"], (double) $bid["bidderID"], (string) $bid["dateBid"]);
         $insertStatement->execute(['contractID' => $id, 'bidID' => $bidid, 'bidderID' => (double) $bid["bidderID"], 'amount' => (double) $bid["amount"], 'bidTime' => (string) $bid["dateBid"]]);
     }
     foreach ($bids as &$bidset) {
         usort($bidset, "bids_sortfunc");
     }
     $this->bids = $bids;
 }
示例#8
0
 public function updateConqStations()
 {
     $result = cache_api_retrieve($this->link, "/eve/ConquerableStationList.xml.aspx", array(), 3 * 24 * 60 * 60);
     if ($result->error) {
         return false;
     }
     if ($result->hit) {
         return true;
     }
     // it was cached still, no point in updating
     $result = $result->value->xpath("/eveapi/result/rowset[@name='outposts']/row");
     foreach ($result as $station) {
         $stationName = $station["stationName"];
         $sql = "SELECT corporationID FROM " . DB_PREFIX . "staStations WHERE stationID='" . mysql_real_escape_string($station["stationID"]) . "'";
         $result = mysql_query($sql, $this->link);
         if (!$result) {
             echo 'MySQL Error: ' . mysql_error();
             return false;
         }
         if (mysql_num_rows($result) > 0) {
             mysql_free_result($result);
             $sql = "UPDATE " . DB_PREFIX . "staStations SET corporationID='" . mysql_real_escape_string($station["corporationID"]) . "', stationName='" . mysql_real_escape_string(addslashes($stationName)) . "' WHERE stationID=" . mysql_real_escape_string($station["stationID"]);
             $result = mysql_query($sql, $this->link);
         } else {
             $sql = "INSERT INTO " . DB_PREFIX . "staStations (stationID, stationTypeID, corporationID, solarSystemID, stationName) VALUES (" . mysql_real_escape_string($station["stationID"]) . ", " . mysql_real_escape_string($station["stationTypeID"]) . ", " . mysql_real_escape_string($station["corporationID"]) . ", " . mysql_real_escape_string($station["solarSystemID"]) . ", '" . mysql_real_escape_string(addslashes($stationName)) . "');";
             $result = mysql_query($sql, $this->link);
         }
     }
     $this->conqUpdated = true;
     return true;
 }
function isFullApi($link, $chid, $usid, $apik)
{
    $key = md5("IDLOOKUP:" . $usid . ";" . $apik);
    // first try to look up cached values in the DB
    $result = mysql_query("SELECT * FROM " . DB_PREFIX . "api_type_cache WHERE keyv='" . addslashes($key) . "' LIMIT 1", $link);
    if ($result != false) {
        if (mysql_num_rows($result) > 0) {
            // got it! return it and have done
            $row = mysql_fetch_assoc($result);
            mysql_free_result($result);
            return $row['type'] == "1";
        }
        mysql_free_result($result);
    }
    $xmlstr = cache_api_retrieve($link, "/char/AccountBalance.xml.aspx", array("characterID" => $chid, "keyID" => $usid, "vCode" => $apik));
    if ($xmlstr->http_error) {
        return false;
    }
    $isFull = true;
    if ($xmlstr->api_error) {
        $isFull = false;
    }
    mysql_query("INSERT INTO " . DB_PREFIX . TYPE_CACHE_TABLE . " (keyv, type) VALUES ('" . addslashes($key) . "', " . ($isFull ? "1" : "0") . ")", $link);
    // insert the new values into cache
    return $isFull;
}
function add_api_key($link, $uid, $keyID, $vCode, $name, $notes = "")
{
    $apikey = make_short_key($link, $keyID, $vCode, $uid);
    $ID = check_saved_key($link, $apikey, $uid);
    if ($ID) {
        return $ID . "<321>Api Code Already added";
    }
    if (!$name) {
        $name = "No Name Set";
    }
    $name = mysql_real_escape_string($name, $link);
    $keyInfo = cache_api_retrieve($link, "/account/APIKeyInfo.xml.aspx", array("keyID" => $keyID, "vCode" => $vCode), 5 * 60)->value;
    echo $keyInfo->error;
    if ($keyInfo->error) {
        if ($keyInfo->error == 222) {
            return "0<321>Api Key expired";
        } else {
            if ($keyInfo->error == 203) {
                return "0<321>Api vCode or Id Incorrect";
            } else {
                return "0<321>Unable to load API. Verify the key is correct and not expired.";
            }
        }
        return false;
    }
    $type = (string) $keyInfo->result->key["type"];
    $notes = mysql_real_escape_string($notes, $link);
    foreach ($keyInfo->result->key->rowset->row as $char) {
        if (isset($char["characterName"])) {
            if (isset($characters)) {
                $characters .= "<br/>" . $char["characterName"] . "," . $char["characterId"];
            } else {
                $characters = $char["characterName"] . "," . $char["characterId"];
            }
        }
    }
    $keyID = mysql_real_escape_string($apikey, $link);
    $sql = "INSERT INTO " . DB_PREFIX . "keyInformation (apiKey,userID,keyName,characters,type,notes) VALUES ('{$keyID}','{$uid}','{$name}','{$characters}','{$type}','{$notes}')";
    $result = mysql_query($sql, $link);
    if (!$result) {
        echo "QUERY: '{$sql}'\n\n" . mysql_error() . "\n\nBacktrace:\n";
        debug_print_backtrace();
        exit;
    }
    if (mysql_affected_rows($link)) {
        return mysql_insert_id($link) . "<321>Api Key successfully added";
    }
}
function api_retrieve($link, $apicall, $args = array())
{
    return cache_api_retrieve($link, $apicall, $args, -1);
}
示例#12
0
function add_api_key($Db, $uid, $keyID, $vCode, $name, $notes = "")
{
    $apikey = make_short_key($Db, $keyID, $vCode, $uid);
    $ID = check_saved_key($apikey, $uid);
    if ($ID) {
        return ["result" => "failure", "id" => $ID, "response" => "Api Code Already added"];
    }
    if (!$name) {
        $name = "No Name Set";
    }
    $keyInfo = cache_api_retrieve($Db, "/account/APIKeyInfo.xml.aspx", array("keyID" => $keyID, "vCode" => $vCode), 5 * 60)->value;
    echo $keyInfo->error;
    if ($keyInfo->error) {
        if ($keyInfo->error == 222) {
            return ["result" => "failure", "response" => "Api Key expired"];
        } else {
            if ($keyInfo->error == 203) {
                return ["result" => "failure", "response" => "Api vCode or Id Incorrect"];
            } else {
                return ["result" => "failure", "response" => "Unable to load API. Verify the key is correct and not expired."];
            }
        }
        return false;
    }
    $type = (string) $keyInfo->result->key["type"];
    foreach ($keyInfo->result->key->rowset->row as $char) {
        if (isset($char["characterName"])) {
            if (isset($characters)) {
                $characters .= "<br/>" . $char["characterName"] . "," . $char["characterId"];
            } else {
                $characters = $char["characterName"] . "," . $char["characterId"];
            }
        }
    }
    $result = $Db->insert("keyInformation", ['apiKey' => $apikey, 'userID' => $uid, 'keyName' => $name, 'characters' => $characters, 'type' => $type, 'notes' => $notes]);
    if (!$result) {
        return false;
    } else {
        return ["id" => $Db->lastid, "response" => "Api Key successfully added"];
    }
}
示例#13
0
    // die
}
if (!isset($_SESSION['redFlagText'])) {
    $_SESSION['redFlagText'] = "";
}
if (!isset($_SESSION['redFlagIds'])) {
    $_SESSION['redFlagIds'] = array();
}
define("USER_ID", $userid);
define("API_KEY", $apikey);
$multiplechars = false;
function canAccess($mask)
{
    return (KEY_MASK & $mask) == $mask;
}
$keyInfo = cache_api_retrieve($Db, "/account/APIKeyInfo.xml.aspx", array("keyID" => USER_ID, "vCode" => API_KEY), 5 * 60)->value;
if (!is_object($keyInfo) || $keyInfo->error) {
    fatal_error("Unable to load API. Verify the key is correct and not expired.");
}
define("KEY_MASK", (double) $keyInfo->result->key["accessMask"]);
$multiplechars = count($keyInfo->result->key->rowset->row) > 1;
if (!$multiplechars) {
    $chid = (string) $keyInfo->result->key->rowset->row[0]["characterID"];
}
if (isset($chid)) {
    $char = $keyInfo->api->xpath("//row[@characterID='{$chid}']");
    if (count($char) == 0) {
        fatal_error("The character ID was not found on this account.");
    }
    define("CHAR_NAME", (string) $char[0]["characterName"]);
}
示例#14
0
function isFullApi($db, $chid, $usid, $apik)
{
    $key = md5("IDLOOKUP:" . $usid . ";" . $apik);
    // first try to look up cached values in the DB
    //$result = $link->query("SELECT * FROM ".DB_PREFIX."api_type_cache WHERE keyv='".addslashes($key)."' LIMIT 1");
    $result = $db->selectWhere("api_type_cache", ['keyv' => $key]);
    if ($result != false) {
        if ($result->rows > 0) {
            // got it! return it and have done
            $row = $result->results[0];
            return $row['type'] == "1";
        }
    }
    $xmlstr = cache_api_retrieve($db, "/char/AccountBalance.xml.aspx", array("characterID" => $chid, "keyID" => $usid, "vCode" => $apik));
    if ($xmlstr->http_error) {
        return false;
    }
    $isFull = true;
    if ($xmlstr->api_error) {
        $isFull = false;
    }
    $db->insert(TYPE_CACHE_TABLE, ['keyv' => $key, 'type' => $isFull ? "1" : "0"]);
    return $isFull;
}
示例#15
0
 public function updateConqStations()
 {
     $result = cache_api_retrieve($this, "/eve/ConquerableStationList.xml.aspx", array(), 3 * 24 * 60 * 60);
     if ($result->error) {
         return false;
     }
     if ($result->hit) {
         return true;
     }
     // it was cached still, no point in updating
     $result = $result->value->xpath("/eveapi/result/rowset[@name='outposts']/row");
     foreach ($result as $station) {
         $stationName = $station["stationName"];
         //$sql = "SELECT corporationID FROM ".DB_PREFIX."staStations WHERE stationID='".$this->ref->real_escape_string($station["stationID"])."'";
         $result = $this->selectWhere("staStations", ['stationID' => $station["stationID"]], ['corporationID']);
         if (!$result) {
             echo 'MySQL Error: ' . $this->ref->error;
             return false;
         }
         if ($result->rows > 0) {
             //$sql = "UPDATE ".DB_PREFIX."staStations SET corporationID='".$this->ref->real_escape_string($station["corporationID"])."', stationName='".$this->ref->real_escape_string(addslashes($stationName))."' WHERE stationID=".$this->ref->real_escape_string($station["stationID"]);
             //$result = $this->ref->query($sql);
             $this->update("staStations", ['stationID' => $station["stationID"]], ['corporationID' => $station["corporationID"], 'stationName' => $stationName]);
         } else {
             //$sql = "INSERT INTO ".DB_PREFIX."staStations (stationID, stationTypeID, corporationID, solarSystemID, stationName) VALUES (".$this->ref->real_escape_string($station["stationID"]).", ".$this->ref->real_escape_string($station["stationTypeID"]).", ".$this->ref->real_escape_string($station["corporationID"]).", ".$this->ref->real_escape_string($station["solarSystemID"]).", '".$this->ref->real_escape_string(addslashes($stationName))."');";
             //$result = $this->ref->query($sql);
             $this->insert('staStations', ['stationID' => $station["stationID"], 'stationTypeID' => $station["stationTypeID"], 'corporationID' => $station["corporationID"], 'solarSystemID' => $station["solarSystemID"], 'stationName' => $stationName]);
         }
     }
     $this->conqUpdated = true;
     return true;
 }