Exemplo n.º 1
0
 public function refreshAPIKey($type)
 {
     global $settings;
     if ($this->keyStatus == 1 and $this->accessMask == MINIMUM_API and $this->expires == 'No Expiration' and $this->keyType == 'Account') {
         $update = $this->updateAPIKey();
         if ($update) {
             if ($settings->getSlackIntegration() and $settings->getSlackAPINotifications() and $type == 'new') {
                 sendComplexSlackNotification($settings->getSlackAuthToken(), $settings->getGroupTicker() . ' Auth Notifications', $settings->getSlackAPIChannel(), 'New API Key submitted by ' . User::fetchUserName($this->uid) . '.', 'aura', 'chat.postMessage');
             }
             $character_array = array();
             foreach ($this->getCharacters() as $character) {
                 $character_array[$character['characterID']] = $character['characterID'];
                 $char = new Character($character['characterID'], $this->keyID, $this->vcode, $this->accessMask, $this->db, $this->uid);
                 if ($char->getExistance() or $char->getExistance() == FALSE) {
                     $char->updateCharacterInfo();
                     $char->updateCharacterSkills();
                 }
             }
             $stmt = $this->db->prepare('UPDATE core_cron SET cron_updated = 1 WHERE api_keyID = ?');
             $stmt->execute(array($this->keyID));
             $this->removeOrphanedCharacter($this->keyID, $this->uid, $character_array);
             return TRUE;
         }
     } elseif ($this->keyStatus != 1 and $type == 'new') {
         if ($settings->getSlackIntegration() and $settings->getSlackAPINotifications()) {
             sendComplexSlackNotification($settings->getSlackAuthToken(), $settings->getGroupTicker() . ' Auth Notifications', $settings->getSlackAPIChannel(), 'API Key submitted by ' . User::fetchUserName($this->uid) . ' has been rejected as it is invalid.', 'aura', 'chat.postMessage');
         }
         setAlert('danger', 'The API Key Is Invalid', 'The API Key provided is invalid and cannot be used. Please create a new API key, and ensure you have copied the keyID and verification code correctly.');
     } elseif (!($this->accessMask == MINIMUM_API) and $this->getKeyStatus() == 1 and $type == "new") {
         if ($settings->getSlackIntegration() and $settings->getSlackAPINotifications()) {
             sendComplexSlackNotification($settings->getSlackAuthToken(), $settings->getGroupTicker() . ' Auth Notifications', $settings->getSlackAPIChannel(), 'API Key submitted by ' . User::fetchUserName($this->uid) . ' has been rejected due to an incorrect access mask.', 'aura', 'chat.postMessage');
         }
         setAlert('danger', 'The API Key Does Not Meet Minimum Requirements', 'The required minimum Access Mask for API keys is ' . MINIMUM_API . '. Please create a new key using the Create Key link.');
     } elseif ($this->expires != 'No Expiration' and $type == "new") {
         if ($settings->getSlackIntegration() and $settings->getSlackAPINotifications()) {
             sendComplexSlackNotification($settings->getSlackAuthToken(), $settings->getGroupTicker() . ' Auth Notifications', $settings->getSlackAPIChannel(), 'API Key submitted by ' . User::fetchUserName($this->uid) . ' has been rejected because it has an expiration.', 'aura', 'chat.postMessage');
         }
         setAlert('danger', 'The API Key Expires', 'The provided API Key has an expiration set. Please create a new key using the Create Key link and ensure you select the No Expiration checkbox.');
     } elseif ($this->keyType != 'Account' and $type == "new") {
         if ($settings->getSlackIntegration() and $settings->getSlackAPINotifications()) {
             sendComplexSlackNotification($settings->getSlackAuthToken(), $settings->getGroupTicker() . ' Auth Notifications', $settings->getSlackAPIChannel(), 'API Key submitted by ' . User::fetchUserName($this->uid) . ' has been rejected because it is a single character key.', 'aura', 'chat.postMessage');
         }
         setAlert('danger', 'The API Key Provided is Single-Character', 'All API Keys must be account-wide. Please create a new key using the Create Key link, and do not change the key from an Account Key to a Single Character key.');
     }
 }
Exemplo n.º 2
0
 $key = new ApiKey($apiLookup['api_keyID'], $apiLookup['api_vCode'], $apiLookup['uid'], $db);
 // Checking to see if the key is valid
 if ($key->getKeyStatus() == 1) {
     // Key is valid, updating it
     $updateKey = $key->updateAPIKey();
     // Checking the access mask for the key
     if ($key->accessMaskCheck()) {
         // Looping through the characters
         foreach ($key->getCharacters() as $character) {
             $char = new Character($character['characterID'], $key->getKeyID(), $key->getVCode(), $key->getAccessMask(), $db, $apiLookup['uid']);
             if ($char->getExistance() or $char->getExistance() == FALSE) {
                 $char->updateCharacterInfo();
                 /*
                  * SKILLS UPDATE SECTION
                  */
                 $skills = $char->updateCharacterSkills();
                 // Checking for skills update success
                 if ($skills === "SDE Failure") {
                     echo date('Ymd H:i:s', time()) . " - cron_update.php - FAILURE - Skill detected that does not exist in SDE for charid " . $character['characterID'] . "\n";
                 } elseif ($skills === FALSE) {
                     echo date('Ymd H:i:s', time()) . " - cron_update.php - FAILURE - General processing error for charid " . $character['characterID'] . "\n";
                 }
                 /*
                  * SKILLPLAN UPDATE SECTION
                  */
                 $skillPlans = $char->updateSkillPlanProgress();
                 /*
                  * DOCTRINE COMPLIANCE SECTION
                  */
                 Fitting::getDoctrineCompliance($character['characterID']);
                 /*