public function registerForm($request) { if (isset($_POST['XSRF'])) { if (Kingboard_Form::getXSRFToken() == $_POST['XSRF']) { if (!isset($_POST['passwd']) || !isset($_POST['passwd2']) || !isset($_POST['login'])) { $this->_context['registration_failed'] = 'Please fill in all fields'; } elseif ($_POST['passwd'] != $_POST['passwd2']) { $this->_context['registration_failed'] = 'both Password fields need to have the same value'; } elseif (!is_null(Kingboard_User::findOne(array('username' => $_POST['login'])))) { $this->_context['registration_failed'] = 'email/login allready in use'; } elseif (!Kingboard_Form::isEmail($_POST['login'])) { $this->_context['registration_failed'] = 'not a valid email adresse'; } else { $validationCode = sha1(mktime() . $_POST['login']); $user = new Kingboard_User(); $user->username = $_POST['login']; $user->password = $_POST['passwd']; $user->status = Kingboard_User::STATUS_NEW; $user->validationCode = $validationCode; $user->save(); $body = King23_Registry::getInstance()->sith->cachedGet('mails/verify_email.html')->render(array('username' => $_POST['login'], 'hostname' => $_SERVER['SERVER_NAME'], 'activationkey' => $validationCode), King23_Registry::getInstance()->sith); mail($_POST['login'], "Kingboard Activation", $body); $this->redirect('/'); } } else { $this->_context['registration_failed'] = 'XSRF Token Invalid.'; } } $this->render('user/registration.html', $_POST); }
public function key_activation(array $options) { $this->cli->header('updating key activates'); $reg = King23_Registry::getInstance(); $pheal = new Pheal($reg->apimailreceiverApiUserID, $reg->apimailreceiverApiKey, 'char'); $messages = $pheal->MailMessages(array('characterID' => $reg->apimailreceiverCharacterID))->messages; foreach ($messages as $message) { if ($message->toCharacterIDs != $reg->apimailreceiverCharacterID) { continue; } $token = trim($message->title); if (strlen($token) != Kingboard_ApiActivationToken::TOKEN_LENGTH) { continue; } if (!($token = Kingboard_ApiActivationToken::findOneByToken($token))) { continue; } $user = Kingboard_User::getById($token['userid']); $keys = $user['keys']; $apiuserid = $token['apiuserid']; $phealactivate = new Pheal($keys[$apiuserid]['apiuserid'], $keys[$apiuserid]['apikey']); $characters = $phealactivate->Characters()->characters; foreach ($characters as $character) { if ($character->characterID == $message->senderID) { $keys[$apiuserid]['active'] = true; $user['keys'] = $keys; $user->save(); $token->delete(); $body = King23_Registry::getInstance()->sith->cachedGet('mails/activate_apikey.html')->render(array('username' => $user['username'], 'apiuserid' => $apiuserid), King23_Registry::getInstance()->sith); mail($user['username'], "Kingboard API Key Activation", $body); break; } } } }
public static function login($username, $password) { $user = Kingboard_User::findOneByUsernameAndPassword($username, $password); if ($user) { $_SESSION["Kingboard_Auth"] = array("User" => $user); } return $user; }