Example #1
0
require 'includes/header-no-nav.php';
//Checking to see if we've already submitted registration
if (isset($_POST['username'])) {
    //We have, registering the account
    $keyAddition = new ApiKey($_POST['keyID'], $_POST['vCode'], 0, $db);
    $success = User::doRegistration($_POST['username'], $_POST['password'], $_POST['password_verify'], $_POST['default_id'], $db);
    if ($success) {
        $stmt = $db->prepare('SELECT * FROM user_accounts WHERE username = ? LIMIT 1');
        $stmt->execute(array($_POST['username']));
        $accountInfo = $stmt->fetch();
        $keyAddition = new ApiKey($_POST['keyID'], $_POST['vCode'], $accountInfo['uid'], $db);
        $keyAddition->updateAPIKey();
        $char = new Character($_POST['default_id'], $keyAddition->getKeyID(), $keyAddition->getVCode(), $keyAddition->getAccessMask(), $db, $accountInfo['uid']);
        if ($char->getExistance() or $char->getExistance() == FALSE) {
            $char->updateCharacterInfo();
        }
        $register_success = TRUE;
    } else {
        $register_success = FALSE;
    }
}
?>

    <div class="opaque-container" style="height: 100%; padding-bottom: 50px; margin-top: 10%">

	    <div class="row" style="width: 100%;">
		<?php 
if ($request['action'] == '1' or !$request['action']) {
    ?>
			<div class="col-md-offset-4 col-md-4 col-sm-offset-2 col-sm-8 mobile-reconfig" style="padding-right: 0px">
 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.');
     }
 }