#124 new tbc account

This commit is contained in:
Ulf Gebhardt 2016-12-18 03:01:07 +01:00
parent 11e223d747
commit 999e7e7a6c
12 changed files with 194 additions and 20 deletions

View File

@ -11,11 +11,21 @@ class api_mojotrollz extends \SYSTEM\API\api_system {
\SYSTEM\LOG\JsonResult::fail();
}
public static function call_account_action_create($username, $password, $email, $wowpassword){
public static function call_account_action_create($username, $password, $email, $wow_password){
if(!\SYSTEM\SECURITY\security::available($username,$email) || !self::wow_username_available($username)){
throw new \SYSTEM\LOG\ERROR('EMail is already in use or Username is not available.');}
if( !\SYSTEM\SECURITY\security::create($username, $password, $email, \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG)) ||
!self::wow_account_register($username,$email,$wowpassword)){
!self::wow_account_register($username,$email,$wow_password)){
throw new ERROR("Account creation failed. Retry later.");}
return JsonResult::ok();
}
public static function call_account_action_create_wow($username, $wow_password){
if(!\SYSTEM\SECURITY\security::isLoggedIn()){
throw new \SYSTEM\LOG\ERROR('You need to be logged in to register another WoW Account.');}
if(!self::wow_username_available($username)){
throw new \SYSTEM\LOG\ERROR('Username is not available.');}
if( !self::wow_account_register($username, \SYSTEM\SECURITY\security::getUser()->email,$wow_password)){
throw new ERROR("Account creation failed. Retry later.");}
return JsonResult::ok();
}

View File

@ -19,7 +19,9 @@ class account_tbc implements \SYSTEM\PAGE\Page {
while($row = $res->next()){
$row['online'] = $row['online'] == 1 ? 'online' : 'offline';
$vars['wow_accounts'] .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_account/tpl/wow_account.tpl'))->SERVERPATH(), $row);}
$vars['wow_accounts_confirm'] = \SYSTEM\SECURITY\security::getUser()->email_confirmed ? '' : \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_account/tpl/wow_accounts_confirm.tpl'))->SERVERPATH());
$vars['wow_accounts_confirm'] = \SYSTEM\SECURITY\security::getUser()->email_confirmed ?
\SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_tbc/tpl/account_tbc_new.tpl'))->SERVERPATH()) :
\SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_account/tpl/wow_accounts_confirm.tpl'))->SERVERPATH());
return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_tbc/tpl/account_tbc.tpl'))->SERVERPATH(), $vars);
}

View File

@ -0,0 +1,5 @@
<div class="row-fluid">
<div class="col-md-12">
<p style="padding-top: 10px;"><a href="#!account(tbc_new)"><b>New Account</b></a></p>
</div>
</div>

View File

@ -0,0 +1,19 @@
<?php
class account_tbc_new implements \SYSTEM\PAGE\Page {
public static function title(){
return \SYSTEM\PAGE\text::get('title_account');}
public static function meta(){
return \SYSTEM\PAGE\text::tag('meta_account');}
public static function js(){
return array(new \PPAGE('account_tbc_new/js/account_tbc_new.js'));}
public function html(){
$vars = \SYSTEM\PAGE\text::tag('mojotrollz');
if(!\SYSTEM\SECURITY\security::isLoggedIn()){
return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_account/tpl/account_login.tpl'))->SERVERPATH(), $vars);}
return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_tbc_new/tpl/account_tbc_new.tpl'))->SERVERPATH(), $vars);
}
public static function css() {return array();}
}

View File

@ -0,0 +1,3 @@
<?php
\SYSTEM\autoload::registerFolder(dirname(__FILE__));
//\SYSTEM\autoload::registerFolder(dirname(__FILE__).'/qq','SQL');

View File

@ -0,0 +1,47 @@
function init_account_tbc_new(){
$("#account_menu li").removeClass("active");
$('#li_tbc').addClass('active');
$("#login_form input").not("[type=submit]").jqBootstrapValidation({
preventSubmit: true,
submitError: function($form, event, errors) {},
submitSuccess: function($form, event){
system.account_login($('#bt_login_user').val(),$('#bt_login_password').val(),function(data){
if(data.status){
$('.help-block').html("Login successfull.</br>");
location.reload(true);
} else {
$('.help-block').html("Login not successfull.</br> User & Password combination wrong.");
}
});
event.preventDefault();
}
});
$("#register_tbc_form input").not("[type=submit]").jqBootstrapValidation({
preventSubmit: true,
submitError: function (form, event, errors) {},
submitSuccess: function($form, event){
var username = $('#register_username').val();
var password = $('#user_register_password2').val();
$.ajax({
dataType: "json",
url: './api.php',
data: {
call: 'account',
action: 'create_wow',
username: username,
wow_password: $.sha1(username.toUpperCase()+':'+password.toUpperCase()),
},
success: function (data) {
if(data.status){ // reload -> user will be loged in
$('#help_block_tbc_register').html('Account registered!');
}else{ // show errors
$('#help_block_tbc_register').html(data.result.message);
}
}
});
event.preventDefault();
}
});
}

View File

@ -0,0 +1,78 @@
<div class="panel panel-default">
<div class="panel-heading"><h4>Register a new TBC Account</h4></div>
<div class="panel-body" style="padding-bottom: 0;">
<div class="row">
<div class="col-md-8">
<form class="textbox" id="register_tbc_form">
<div class="control-group">
<table>
<tbody>
<tr>
<th style="width: 200px;">${basic_username}</th>
<td>
<div class="control-group controls">
<input type="text"
size="35"
style="margin-bottom: 15px; float: left;"
id="register_username"
placeholder="peter"
minlength="3" data-validation-minlength-message="${basic_username_short}"
required data-validation-required-message="${basic_username_miss}"/>
<br/>
</div>
</td>
</tr>
<tr>
<th style="vertical-align: top; padding-top: 7px;">${basic_password}</th>
<td>
<div class="control-group" id="change_user_password">
<div class="control-group controls" style="clear: both">
<input type="password"
size="35"
style="margin-bottom: 15px; float: left;"
id="user_register_password1"
name="user_register_password1"
placeholder="${basic_placeholder_password}"
minlength="5"
data-validation-minlength-message="${basic_password_short}"
required data-validation-required-message="${basic_password_miss}"/>
<br/>
</div>
<div class="control-group controls" style="clear: both">
<input type="password"
size="35"
style="margin-bottom: 15px; float: left;"
id="user_register_password2"
name="user_register_password2"
placeholder="${basic_placeholder_password}"
data-validation-matches-match="user_register_password1"
data-validation-matches-message="${basic_password_match}"/>
<br/>
</div>
</div>
</td>
</tr>
<tr>
<th>
<p style="float: left;"><a href="#!account(tbc)">Back to TBC-Accounts</a></p>
</th>
<td>
<p style="float: right; margin-top: 3px;">
<button class="btn btn-success" type="submit" style="width: 200px;"><i class="icon-ok icon-white"></i> Register Account</button>
</p>
</td>
</tr>
</tbody>
</table>
<p class="help-block" id="help_block_tbc_register" style="float: left; margin-top: 3px;"></p>
</div>
</form>
</div>
<div class="col-md-4">
<p>Create another WoW TBC Account for your Website Account.</p>
<p><a href="#!account"><b>Website-Accounts</b></a></p>
<p><a href="#!account(tbc)"><b>TBC-Accounts</b></a></p>
</div>
</div>
</div>
</div>

View File

@ -12,6 +12,8 @@ require_once dirname(__FILE__).'/default_register/autoload.inc';
require_once dirname(__FILE__).'/default_resetpassword/autoload.inc';
require_once dirname(__FILE__).'/account_website/autoload.inc';
require_once dirname(__FILE__).'/account_tbc/autoload.inc';
require_once dirname(__FILE__).'/account_changepassword/autoload.inc';
require_once dirname(__FILE__).'/account_changeemail/autoload.inc';
require_once dirname(__FILE__).'/account_changeemail/autoload.inc';
require_once dirname(__FILE__).'/account_tbc/autoload.inc';
require_once dirname(__FILE__).'/account_tbc_new/autoload.inc';

View File

@ -1,7 +1,7 @@
<div class="row-fluid">
<br><br>
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-primary">
<div class="panel panel-default">
<div class="panel-heading"><h4>Mojotrollz - Reset Password</h4></div>
<div class="panel-body" style="padding-bottom: 0;">
<table id="userLoginTable"> <!-- style="margin-left: 20px;" -->
@ -18,7 +18,7 @@
</tr>
<tr>
<th style="padding-top: 10px;">
<p style="float: left;"><a href="#!register">Register an Account</a></p>
<p style="float: left;"><a href="#!account">Login</a> or <a href="#!register">Register</a> an Account</p>
</th>
<td>
<p style="float: right;">

View File

@ -39,13 +39,16 @@ class page_mojotrollz extends \SYSTEM\API\api_default {
public static function page_account_website(){
return (new account_website())->html();}
public static function page_account_tbc(){
return (new account_tbc())->html();}
public static function page_account_changepassword(){
return (new account_changepassword())->html();}
public static function page_account_changeemail(){
return (new account_changeemail())->html();}
public static function page_account_tbc(){
return (new account_tbc())->html();}
public static function page_account_tbc_new(){
return (new account_tbc_new())->html();}
}

View File

@ -3,11 +3,14 @@ REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `na
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (200, 0, 2, 11, 'newserver', 'address', 'STRING');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (205, 0, 2, 11, 'vote', 'server', 'INT');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (210, 0, 2, 11, 'register', 'username', 'STRING');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (211, 0, 2, 11, 'register', 'password', 'STRING');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (212, 0, 2, 11, 'register', 'email', 'STRING');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (213, 0, 2, 11, 'register', 'wowpassword', 'STRING');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (214, 0, 3, 11, 'register', 'betakey', 'STRING');
-- REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (210, 0, 2, 11, 'register', 'username', 'STRING');
-- REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (211, 0, 2, 11, 'register', 'password_sha1', 'STRING');
-- REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (212, 0, 2, 11, 'register', 'email', 'STRING');
-- REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (213, 0, 2, 11, 'register', 'wow_password', 'STRING');
-- REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (214, 0, 3, 11, 'register', 'betakey', 'STRING');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (210, 0, 2, 11, 'create_wow', 'username', 'STRING');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (211, 0, 2, 11, 'create_wow', 'wow_password', 'STRING');
-- REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (210, 1, 3, 1, 'beta', 'key', 'STRING');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (215, 1, 2, 1, 'article', 'id', 'STRING');

View File

@ -9,12 +9,14 @@ REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (20, 1, 'account', 'account', -1, 0, 0, '#content', './?page=account', 'init_account', 'default_account');
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (21, 1, 'website', 'account', 20, 1, 0, '#content_account', './?page=account_website', 'init_account_website', 'account_website');
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (22, 1, 'tbc', 'account', 20, 1, 1, '#content_account', './?page=account_tbc', 'init_account_tbc', 'account_tbc');
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (23, 1, 'changepassword', 'account', 20, 1, 1, '#content_account', './?page=account_changepassword', 'init_account_changepassword', 'account_changepassword');
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (24, 1, 'changeemail', 'account', 20, 1, 1, '#content_account', './?page=account_changeemail', 'init_account_changeemail', 'account_changeemail');
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (22, 1, 'changepassword', 'account', 20, 1, 1, '#content_account', './?page=account_changepassword', 'init_account_changepassword', 'account_changepassword');
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (23, 1, 'changeemail', 'account', 20, 1, 1, '#content_account', './?page=account_changeemail', 'init_account_changeemail', 'account_changeemail');
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (25, 1, 'beta', 'beta', -1, 0, 0, '#content', './?page=beta', 'init_beta', 'default_beta');
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (26, 1, 'register', 'register', -1, 0, 0, '#content', './?page=register', 'init_register', 'default_register');
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (24, 1, 'tbc', 'account', 20, 1, 1, '#content_account', './?page=account_tbc', 'init_account_tbc', 'account_tbc');
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (25, 1, 'tbc_new', 'account', 20, 1, 1, '#content_account', './?page=account_tbc_new', 'init_account_tbc_new', 'account_tbc_new');
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (26, 1, 'beta', 'beta', -1, 0, 0, '#content', './?page=beta', 'init_beta', 'default_beta');
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (27, 1, 'register', 'register', -1, 0, 0, '#content', './?page=register', 'init_register', 'default_register');
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (30, 1, 'article', 'article', -1, 0, 0, '#content', './?page=article&id=${article}', 'init_article', 'default_article');