Пример #1
0
 /**
  * @param $killID
  * @param $processed
  * @param $hash
  * @param $source
  * @param $kill_json
  *
  * @return bool|int|string
  */
 public function insertKillmail($killID, $processed = 0, $hash, $source, $kill_json)
 {
     $insert = $this->db->execute("INSERT IGNORE INTO killmails (killID, processed, hash, source, kill_json) VALUES (:killID, :processed, :hash, :source, :kill_json)", array(":killID" => $killID, ":processed" => $processed, ":hash" => $hash, ":source" => $source, ":kill_json" => $kill_json));
     if ($insert) {
         \Resque::enqueue("now", "\\ProjectRena\\Task\\Resque\\killmailParser", array("killID" => $killID));
         $this->app->StatsD->increment("killmailsAdded");
     }
     return $insert;
 }
 /**
  * @param $categoryName
  *
  * @return string
  */
 public function getCategoryDescriptionByName($categoryName)
 {
     return $this->db->queryField("SELECT categoryDescription FROM dgmAttributeCategories WHERE categoryName = :name", "categoryDescription", array(":name" => $categoryName), 3600);
 }
Пример #3
0
 /**
  * @param $typeName
  *
  * @return string
  */
 public function getChanceOfDuplicatingByName($typeName)
 {
     return $this->db->queryField("SELECT chanceOfDuplicating FROM invTypes WHERE typeName = :name", "chanceOfDuplicating", array(":name" => $typeName), 3600);
 }
Пример #4
0
 /**
  * @param $code
  * @param $state
  */
 public function SSOLogin($code, $state)
 {
     // Get the login token
     $tokenURL = "https://login.eveonline.com/oauth/token";
     $base64 = base64_encode($this->config->getConfig("clientID", "crestsso") . ":" . $this->config->getConfig("secretKey", "crestsso"));
     $data = json_decode($this->app->cURL->sendData($tokenURL, array("grant_type" => "authorization_code", "code" => $code), array("Authorization: Basic {$base64}")));
     $accessToken = $data->access_token;
     $refreshToken = $data->refresh_token;
     //$expiresIn = $data->expires_in;
     // Verify token
     $verifyURL = "https://login.eveonline.com/oauth/verify";
     $data = json_decode($this->app->cURL->sendData($verifyURL, array(), array("Authorization: Bearer {$accessToken}")));
     $characterID = $data->CharacterID;
     $characterName = $data->CharacterName;
     $characterOwnerHash = $data->CharacterOwnerHash;
     //$expiresOn = $data->ExpiresOn;
     $scopes = $data->Scopes;
     $tokenType = $data->TokenType;
     // Generate a unique id
     $uniqueID = uniqid("", true);
     // Insert it all to the table
     $this->app->Db->execute("INSERT INTO users (characterName, characterID, characterOwnerHash, loginHash, accessToken, refreshToken, scopes, tokenType) VALUES (:characterName, :characterID, :characterOwnerHash, :loginHash, :accessToken, :refreshToken, :scopes, :tokenType) ON DUPLICATE KEY UPDATE characterName = :characterName, characterID = :characterID, characterOwnerHash = :characterOwnerHash, loginHash = :loginHash, accessToken = :accessToken, refreshToken = :refreshToken, scopes = :scopes, tokenType = :tokenType", array(":characterName" => $characterName, ":characterID" => $characterID, ":characterOwnerHash" => $characterOwnerHash, ":loginHash" => $uniqueID, ":accessToken" => $accessToken, ":refreshToken" => $refreshToken, ":scopes" => $scopes, ":tokenType" => $tokenType));
     // Create the auto login cookie
     $this->app->setEncryptedCookie($this->config->getConfig("name", "cookies", "rena"), $uniqueID, time() + $this->config->getConfig("time", "cookies", 3600 * 24 * 30), "/", $this->app->request->getHost(), $this->config->getConfig("ssl", "cookies", true), "true");
     // Setup the groups (corp and alli)
     $data = $this->app->characters->getAllByID($characterID);
     // Tell resque to do stuff
     if (!$data["characterID"]) {
         \Resque::enqueue("now", "\\ProjectRena\\Task\\Resque\\updateCharacter", array("characterID" => $characterID));
         sleep(6);
         // Sleep for 6 seconds, not ideal but whatever
         $data = $this->app->characters->getAllByID($characterID, 0);
         // Refetch the data, just this time we skip the cache!
     }
     // Only do all of the group stuff if the character exists in the database.. if said character doesn't exist, we'll push the character to resque and do it all there!
     if ($data) {
         // Check if the user is in groups they're not allowed to be in.. this goes for corporation and alliance only!
         $validGroups = array("corporation" => $data["corporationID"], "alliance" => $data["allianceID"]);
         foreach ($validGroups as $type => $id) {
             $innerData = $this->db->query("SELECT groupID, groupType FROM usersGroups WHERE userID = :id", array(":id" => $this->app->Users->getUserByName($characterName)["id"]));
             foreach ($innerData as $check) {
                 if ($check["groupType"] == $type) {
                     if ($check["groupID"] != $id) {
                         $this->db->execute("DELETE FROM usersGroups WHERE userID = :id AND groupID = :groupID", array(":id" => $this->app->Users->getUserByName($characterName)["id"], ":groupID" => $check["groupID"]));
                     }
                 }
             }
         }
         // Now add the user to the groups they're allowed to be in, this doesn't happen on anything but login so that we are a bit sql heavy there is fine!
         $this->app->Groups->updateGroup($data["corporationID"], $this->app->corporations->getAllByID($data["corporationID"])["corporationName"]);
         $this->app->UsersGroups->setGroup($this->app->Users->getUserByName($characterName)["id"], $data["corporationID"], "corporation");
         $this->app->Groups->setAdmins($data["corporationID"], array($this->app->corporations->getAllByID($data["corporationID"])["ceoID"]));
         if ($data["allianceID"] > 0) {
             $this->app->Groups->updateGroup($data["allianceID"], $this->app->alliances->getAllByID($data["allianceID"])["allianceName"]);
             $this->app->UsersGroups->setGroup($this->app->Users->getUserByName($characterName)["id"], $data["allianceID"], "alliance");
             $this->app->Groups->setAdmins($data["allianceID"], array($this->app->corporations->getAllByID($this->app->alliances->getAllByID($data["allianceID"])["executorCorporationID"])["ceoID"]));
         }
     }
     // Set the session
     $_SESSION["characterName"] = $characterName;
     $_SESSION["characterID"] = $characterID;
     $_SESSION["loggedIn"] = true;
     // Insert the IP
     $this->app->UsersLogins->updateIP($this->app->Users->getUserByName($characterName)["id"], $this->app->request->getIp());
     \Resque::enqueue("now", "\\ProjectRena\\Task\\Resque\\ipUpdater", array("userID" => $this->app->Users->getUserByName($characterName)["id"], "ip" => $this->app->request->getIp()));
     // Redirect back to where the person came from
     $this->app->redirect($state);
 }
Пример #5
0
 /**
  * @param $solarSystemName
  *
  * @return string
  */
 public function getSecurityClassByName($solarSystemName)
 {
     return $this->db->queryField("SELECT securityClass FROM mapSolarSystems WHERE solarSystemName = :name", "securityClass", array(":name" => $solarSystemName), 3600);
 }
Пример #6
0
 /**
  * @param $corporationID
  * @param $memberCount
  */
 public function setMemberCount($corporationID, $memberCount)
 {
     if ($memberCount) {
         $this->db->execute("UPDATE corporations SET memberCount = :memberCount WHERE corporationID = :corporationID", array(":memberCount" => $memberCount, ":corporationID" => $corporationID));
     }
 }
Пример #7
0
 /**
  * @param $orbitID
  *
  * @return array|bool
  * @throws \Exception
  */
 public function getAllByOrbitID($orbitID)
 {
     return $this->db->query("SELECT * FROM mapDenormalize WHERE orbitID = :orbitID", array(":orbitID" => $orbitID), 3600);
 }
Пример #8
0
 /**
  * @param $hash
  *
  * @return array
  */
 public function getUserDataByLoginHash($hash)
 {
     return $this->db->queryRow("SELECT * FROM users WHERE loginHash = :hash", array(":hash" => $hash));
 }
Пример #9
0
 /**
  * @param $allianceID
  * @param $memberCount
  */
 public function setMemberCount($allianceID, $memberCount)
 {
     if ($memberCount) {
         $this->db->execute("UPDATE alliances SET memberCount = :memberCount WHERE allianceID = :allianceID", array(":memberCount" => $memberCount, ":allianceID" => $allianceID));
     }
 }
Пример #10
0
 /**
  * @param $flagName
  *
  * @return string
  */
 public function getOrderIDByName($flagName)
 {
     return $this->db->queryField("SELECT orderID FROM invFlags WHERE flagName = :name", "orderID", array(":name" => $flagName), 3600);
 }
Пример #11
0
 /**
  * @param $attributeName
  *
  * @return string
  */
 public function getCategoryIDByName($attributeName)
 {
     return $this->db->queryField("SELECT categoryID FROM dgmAttributeTypes WHERE attributeName = :name", "categoryID", array(":name" => $attributeName), 3600);
 }
Пример #12
0
 /**
  * @param string $key
  * @param string $value
  *
  * @return bool|int|string
  */
 function set($key, $value)
 {
     return $this->db->execute("REPLACE INTO storage (`key`, value) VALUES (:key, :value)", array(":key" => $key, ":value" => $value));
 }
Пример #13
0
 /**
  * @param $regionName
  *
  * @return string
  */
 public function getFactionIDByName($regionName)
 {
     return $this->db->queryField("SELECT factionID FROM mapRegions WHERE regionName = :name", "factionID", array(":name" => $regionName), 3600);
 }
Пример #14
0
 /**
  * @param $groupName
  *
  * @return array
  */
 public function getAllByName($groupName)
 {
     return $this->db->queryRow("SELECT * FROM invGroups WHERE groupName = :name", array(":name" => $groupName), 3600);
 }
Пример #15
0
 /**
  * @param $typeID
  *
  * @return string
  */
 public function getValueFloatByID($typeID)
 {
     return $this->db->queryField("SELECT valueFloat FROM dgmTypeAttributes WHERE typeID = :id", "valueFloat", array(":id" => $typeID), 3600);
 }
Пример #16
0
 /**
  * @param $typeID
  *
  * @return string
  */
 function getIsDefaultByID($typeID)
 {
     return $this->db->queryField("SELECT isDefault FROM dgmTypeEffects WHERE typeID = :id", "isDefault", array(":id" => $typeID), 3600);
 }
Пример #17
0
 /**
  * @param $keyID
  * @param $errorCode
  *
  * @return bool|int|string
  */
 public function setErrorCode($keyID, $errorCode)
 {
     return $this->db->execute("UPDATE apiKeys SET errorCode = :errorCode WHERE keyID = :keyID", array(":errorCode" => $errorCode, ":keyID" => $keyID));
 }
Пример #18
0
 /**
  * @param string $lastUpdated
  */
 public function setLastUpdated($characterID, $lastUpdated)
 {
     if ($lastUpdated) {
         $this->db->execute("UPDATE characters SET lastUpdated = :lastUpdated WHERE characterID = :characterID", array(":lastUpdated" => $lastUpdated, ":characterID" => $characterID));
     }
 }
Пример #19
0
 /**
  * @param $effectName
  *
  * @return array
  */
 public function getAllByName($effectName)
 {
     return $this->db->queryRow("SELECT * FROM dgmEffects WHERE effectName = :name", array(":name" => $effectName), 3600);
 }