From 5af5ab01d7613d5a6246abe2bc1e6a08af3caea5 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 18 Dec 2016 05:21:41 +0100 Subject: [PATCH] #124 change password tbc account --- mojotrollz/api/api_mojotrollz.php | 12 ++- .../api/qq/MOJO_ACCOUNT_CHANGE_PASSWORD.php | 8 ++ .../page/account_tbc/tpl/account_tbc_new.tpl | 2 +- .../account_tbc_account.php | 34 ++++++++ .../page/account_tbc_account/autoload.inc | 3 + .../js/account_tbc_account.js | 20 +++++ .../qq/MOJO_ACCOUNT_CHARACTERS.php | 11 +++ .../tpl/account_tbc_account.tpl | 12 +++ .../tpl/account_tbc_changepassword.tpl | 5 ++ .../account_tbc_account/tpl/wow_character.tpl | 5 ++ .../account_tbc_changepassword.php | 27 +++++++ .../account_tbc_changepassword/autoload.inc | 2 + .../js/account_tbc_changepassword.js | 37 +++++++++ .../tpl/account_tbc_changepassword.tpl | 81 +++++++++++++++++++ mojotrollz/page/autoload.inc | 4 +- .../page/default_account/tpl/wow_account.tpl | 2 +- mojotrollz/page/page_mojotrollz.php | 6 ++ mojotrollz/sql/mysql/system_api.sql | 13 ++- mojotrollz/sql/mysql/system_page.sql | 6 +- 19 files changed, 281 insertions(+), 9 deletions(-) create mode 100644 mojotrollz/api/qq/MOJO_ACCOUNT_CHANGE_PASSWORD.php create mode 100644 mojotrollz/page/account_tbc_account/account_tbc_account.php create mode 100644 mojotrollz/page/account_tbc_account/autoload.inc create mode 100644 mojotrollz/page/account_tbc_account/js/account_tbc_account.js create mode 100644 mojotrollz/page/account_tbc_account/qq/MOJO_ACCOUNT_CHARACTERS.php create mode 100644 mojotrollz/page/account_tbc_account/tpl/account_tbc_account.tpl create mode 100644 mojotrollz/page/account_tbc_account/tpl/account_tbc_changepassword.tpl create mode 100644 mojotrollz/page/account_tbc_account/tpl/wow_character.tpl create mode 100644 mojotrollz/page/account_tbc_changepassword/account_tbc_changepassword.php create mode 100644 mojotrollz/page/account_tbc_changepassword/autoload.inc create mode 100644 mojotrollz/page/account_tbc_changepassword/js/account_tbc_changepassword.js create mode 100644 mojotrollz/page/account_tbc_changepassword/tpl/account_tbc_changepassword.tpl diff --git a/mojotrollz/api/api_mojotrollz.php b/mojotrollz/api/api_mojotrollz.php index 9354f58..36285ee 100644 --- a/mojotrollz/api/api_mojotrollz.php +++ b/mojotrollz/api/api_mojotrollz.php @@ -29,9 +29,17 @@ class api_mojotrollz extends \SYSTEM\API\api_system { throw new ERROR("Account creation failed. Retry later.");} return JsonResult::ok(); } - + public static function call_account_action_change_password($old_password_sha1, $new_password_sha1){ return \SYSTEM\SECURITY\security::change_password($old_password_sha1,$new_password_sha1);} + + public static function call_account_action_change_password_wow($account, $old_wow_password_sha1, $new_wow_password_sha1){ + if(!\SYSTEM\SECURITY\security::isLoggedIn()){ + throw new \SYSTEM\LOG\ERROR('You need to be logged in to change your WoW Account\'s Password.');} + $user = \SYSTEM\SECURITY\security::getUser(); + if(!$user->email_confirmed && $user->username != $account){ + throw new \SYSTEM\LOG\ERROR('You need to confirm your EMail to change this WoW Account\'s Password.');} + return self::wow_account_change_password($account,$old_wow_password_sha1,$new_wow_password_sha1,$user->email);} public static function call_account_action_change_email($new_email){ return \SYSTEM\SECURITY\security::change_email($new_email,'mojotrollz_post_scripts::change_email');} @@ -40,6 +48,8 @@ class api_mojotrollz extends \SYSTEM\API\api_system { return \SQL\MOJO_ACCOUNT_AVAILABLE::Q1(array($username), new \SQL\mangos_realm())['count'] == 0;} private static function wow_account_register($username,$email,$password){ return \SQL\MOJO_ACCOUNT_REGISTER::QI(array($username,$email,$password), new \SQL\mangos_realm());} + private static function wow_account_change_password($account,$old_wow_password_sha1,$new_wow_password_sha1,$email){ + return \SQL\MOJO_ACCOUNT_CHANGE_PASSWORD::QI(array($new_wow_password_sha1,$account,$old_wow_password_sha1,$email), new \SQL\mangos_realm()) ? JsonResult::ok() : JsonResult::fail();;} public static function call_tbc_action_item($id){ return \JsonResult::toString(\SQL\TBC_ITEM::Q1(array($id),new \SQL\mangos_one_world()));} diff --git a/mojotrollz/api/qq/MOJO_ACCOUNT_CHANGE_PASSWORD.php b/mojotrollz/api/qq/MOJO_ACCOUNT_CHANGE_PASSWORD.php new file mode 100644 index 0000000..455b66d --- /dev/null +++ b/mojotrollz/api/qq/MOJO_ACCOUNT_CHANGE_PASSWORD.php @@ -0,0 +1,8 @@ +
-

New Account

+

New WoW TBC Account

\ No newline at end of file diff --git a/mojotrollz/page/account_tbc_account/account_tbc_account.php b/mojotrollz/page/account_tbc_account/account_tbc_account.php new file mode 100644 index 0000000..3f7223a --- /dev/null +++ b/mojotrollz/page/account_tbc_account/account_tbc_account.php @@ -0,0 +1,34 @@ +account = $account; + } + 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_account/js/account_tbc_account.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);} + + $user = \SYSTEM\SECURITY\security::getUser(); + if(!$user->email_confirmed && $user->username != $this->account){ + $this->account = $user->username;} + + $vars['account'] = $this->account; + $vars['account_changepassword'] = $user->email_confirmed ? \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_tbc_account/tpl/account_tbc_changepassword.tpl'))->SERVERPATH(),$vars) : ''; + $vars['wow_characters'] = ''; + $res = \SQL\MOJO_ACCOUNT_CHARACTERS::QQ(array($user->email,$this->account)); + while($row = $res->next()){ + $row['online'] = $row['online'] == 1 ? 'online' : 'offline'; + $vars['wow_characters'] .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_tbc_account/tpl/wow_character.tpl'))->SERVERPATH(), $row);} + return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_tbc_account/tpl/account_tbc_account.tpl'))->SERVERPATH(), $vars); + } + + public static function css() {return array();} +} \ No newline at end of file diff --git a/mojotrollz/page/account_tbc_account/autoload.inc b/mojotrollz/page/account_tbc_account/autoload.inc new file mode 100644 index 0000000..d438772 --- /dev/null +++ b/mojotrollz/page/account_tbc_account/autoload.inc @@ -0,0 +1,3 @@ +"); + location.reload(true); + } else { + $('.help-block').html("Login not successfull.
User & Password combination wrong."); + } + }); + event.preventDefault(); + } + }); +} \ No newline at end of file diff --git a/mojotrollz/page/account_tbc_account/qq/MOJO_ACCOUNT_CHARACTERS.php b/mojotrollz/page/account_tbc_account/qq/MOJO_ACCOUNT_CHARACTERS.php new file mode 100644 index 0000000..4c57d4a --- /dev/null +++ b/mojotrollz/page/account_tbc_account/qq/MOJO_ACCOUNT_CHARACTERS.php @@ -0,0 +1,11 @@ + +

TBC WoW Account ${account}

+
+
+
Character
+
Level
+
Online
+
+ ${wow_characters} + ${account_changepassword} +
+ \ No newline at end of file diff --git a/mojotrollz/page/account_tbc_account/tpl/account_tbc_changepassword.tpl b/mojotrollz/page/account_tbc_account/tpl/account_tbc_changepassword.tpl new file mode 100644 index 0000000..ec56e86 --- /dev/null +++ b/mojotrollz/page/account_tbc_account/tpl/account_tbc_changepassword.tpl @@ -0,0 +1,5 @@ +
+ +
\ No newline at end of file diff --git a/mojotrollz/page/account_tbc_account/tpl/wow_character.tpl b/mojotrollz/page/account_tbc_account/tpl/wow_character.tpl new file mode 100644 index 0000000..21bd6a4 --- /dev/null +++ b/mojotrollz/page/account_tbc_account/tpl/wow_character.tpl @@ -0,0 +1,5 @@ +
+
${name}
+
${level}
+
${online}
+
\ No newline at end of file diff --git a/mojotrollz/page/account_tbc_changepassword/account_tbc_changepassword.php b/mojotrollz/page/account_tbc_changepassword/account_tbc_changepassword.php new file mode 100644 index 0000000..c1003d8 --- /dev/null +++ b/mojotrollz/page/account_tbc_changepassword/account_tbc_changepassword.php @@ -0,0 +1,27 @@ +account = $account;} + 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_changepassword/js/account_tbc_changepassword.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);} + + $user = \SYSTEM\SECURITY\security::getUser(); + if(!$user->email_confirmed && $user->username != $this->account){ + $this->account = $user->username;} + + $vars['account'] = $this->account; + return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_tbc_changepassword/tpl/account_tbc_changepassword.tpl'))->SERVERPATH(), $vars); + } + + public static function css() {return array();} +} \ No newline at end of file diff --git a/mojotrollz/page/account_tbc_changepassword/autoload.inc b/mojotrollz/page/account_tbc_changepassword/autoload.inc new file mode 100644 index 0000000..e2c9da4 --- /dev/null +++ b/mojotrollz/page/account_tbc_changepassword/autoload.inc @@ -0,0 +1,2 @@ + +

Change WoW TBC Account ${account}'s Password

+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + +
${basic_password_old} +
+ +
+


${basic_password_new} +
+
+ +
+
+ +
+
+

+
+
+

Back to WoW TBC Account

+
+

+ +

+
+

+
+
+
+
+

Caution! This function does not change your Website-Account's Password.

+

To change your Website-Accounts Password's visit your Account.

+
+
+
+ \ No newline at end of file diff --git a/mojotrollz/page/autoload.inc b/mojotrollz/page/autoload.inc index 33af770..e7b8c0d 100644 --- a/mojotrollz/page/autoload.inc +++ b/mojotrollz/page/autoload.inc @@ -16,4 +16,6 @@ require_once dirname(__FILE__).'/account_changepassword/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'; \ No newline at end of file +require_once dirname(__FILE__).'/account_tbc_new/autoload.inc'; +require_once dirname(__FILE__).'/account_tbc_account/autoload.inc'; +require_once dirname(__FILE__).'/account_tbc_changepassword/autoload.inc'; \ No newline at end of file diff --git a/mojotrollz/page/default_account/tpl/wow_account.tpl b/mojotrollz/page/default_account/tpl/wow_account.tpl index 073d346..5bf7c97 100644 --- a/mojotrollz/page/default_account/tpl/wow_account.tpl +++ b/mojotrollz/page/default_account/tpl/wow_account.tpl @@ -1,5 +1,5 @@
-
${username}
+
${count}
${online}
\ No newline at end of file diff --git a/mojotrollz/page/page_mojotrollz.php b/mojotrollz/page/page_mojotrollz.php index 05819b2..0dcad05 100644 --- a/mojotrollz/page/page_mojotrollz.php +++ b/mojotrollz/page/page_mojotrollz.php @@ -51,4 +51,10 @@ class page_mojotrollz extends \SYSTEM\API\api_default { public static function page_account_tbc_new(){ return (new account_tbc_new())->html();} + + public static function page_account_tbc_account($account){ + return (new account_tbc_account($account))->html();} + + public static function page_account_tbc_changepassword($account){ + return (new account_tbc_changepassword($account))->html();} } \ No newline at end of file diff --git a/mojotrollz/sql/mysql/system_api.sql b/mojotrollz/sql/mysql/system_api.sql index 17e3cf9..14f452c 100644 --- a/mojotrollz/sql/mysql/system_api.sql +++ b/mojotrollz/sql/mysql/system_api.sql @@ -15,10 +15,17 @@ REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `na -- 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'); -REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (220, 0, 2, 11, 'changepassword', 'old_password_sha1', 'STRING'); -REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (221, 0, 2, 11, 'changepassword', 'new_password_sha1', 'STRING'); +REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (216, 1, 2, 1, 'account_tbc_account', 'account', 'STRING'); +REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (217, 1, 2, 1, 'account_tbc_changepassword', 'account', 'STRING'); -REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (222, 0, 2, 11, 'changeemail', 'new_email', 'EMAIL'); +-- REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (220, 0, 2, 11, 'changepassword', 'old_password_sha1', 'STRING'); +-- REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (221, 0, 2, 11, 'changepassword', 'new_password_sha1', 'STRING'); + +-- REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (222, 0, 2, 11, 'changeemail', 'new_email', 'EMAIL'); + +REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (220, 0, 2, 11, 'change_password_wow', 'account', 'STRING'); +REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (221, 0, 2, 11, 'change_password_wow', 'old_wow_password_sha1', 'STRING'); +REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (222, 0, 2, 11, 'change_password_wow', 'new_wow_password_sha1', 'STRING'); REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (500, 0, 2, 11, 'item', 'id', 'INT'); REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (501, 0, 2, 11, 'itemextendedcost', 'id', 'INT'); \ No newline at end of file diff --git a/mojotrollz/sql/mysql/system_page.sql b/mojotrollz/sql/mysql/system_page.sql index 8f70c2b..85586eb 100644 --- a/mojotrollz/sql/mysql/system_page.sql +++ b/mojotrollz/sql/mysql/system_page.sql @@ -14,9 +14,11 @@ 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 (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, 'tbc_account', 'account', 20, 1, 1, '#content_account', './?page=account_tbc_account&account=${account}', 'init_account_tbc_account', 'account_tbc_account'); +REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (27, 1, 'tbc_changepassword', 'account', 20, 1, 1, '#content_account', './?page=account_tbc_changepassword&account=${account}', 'init_account_tbc_changepassword', 'account_tbc_changepassword'); -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 (28, 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 (29, 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');