Ejemplo n.º 1
0
 public function refreshAPIKey($type)
 {
     if ($this->_keyStatus == 1 && $this->_keyExpiration == 'No Expiration' && $this->_keyType == 'Account') {
         $update = $this->updateAPIKey();
         if ($update) {
             $character_array = array();
             foreach ($this->getCharacters() as $character) {
                 $character_array[$character['characterID']] = $character['characterID'];
                 $char = new Blackbriar\Character($character['characterID'], $this->_keyID, $this->_vCode, $this->_accessMask, $this->_userID, $this->_db);
                 if ($char->getExistance() || $char->getExistance() == false) {
                     $char->updateCharacterInfo();
                     $char->updateCharacterSkills();
                 }
             }
             $this->removeOrphanedCharacter($this->_keyID, $this->_userID, $character_array);
             return true;
         }
     } elseif ($this->_keyStatus != 1 && $type == 'new') {
         $_SESSION['alert'] = new Alert('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_MASK) && $this->getKeyStatus() == 1 && $type == "new") {
         $_SESSION['alert'] = new Alert('danger', 'The API Key Does Not Meet Minimum Requirements', 'The required minimum Access Mask for API keys is ' . MINIMUM_API_MASK . '. Please create a new key using the Create Key link.');
     } elseif ($this->_keyExpiration != 'No Expiration' && $type == "new") {
         $_SESSION['alert'] = new Alert('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' && $type == "new") {
         $_SESSION['alert'] = new Alert('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.');
     }
 }