fixes in Admins.update(); use ApiCommand for theme-, language- and password-change
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -214,15 +214,11 @@ if ($page == 'overview') {
|
|||||||
} elseif($new_password != $new_password_confirm) {
|
} elseif($new_password != $new_password_confirm) {
|
||||||
standard_error('newpasswordconfirmerror');
|
standard_error('newpasswordconfirmerror');
|
||||||
} else {
|
} else {
|
||||||
$chgpwd_stmt = Database::prepare("
|
try {
|
||||||
UPDATE `" . TABLE_PANEL_ADMINS . "`
|
Admins::getLocal($userinfo, array('id' => $userinfo['adminid'], 'admin_password' => $new_password))->update();
|
||||||
SET `password`= :newpasswd
|
} catch (Exception $e) {
|
||||||
WHERE `adminid`= :adminid"
|
dynamic_error($e->getMessage());
|
||||||
);
|
}
|
||||||
Database::pexecute($chgpwd_stmt, array(
|
|
||||||
'newpasswd' => makeCryptPassword($new_password),
|
|
||||||
'adminid' => (int)$userinfo['adminid']
|
|
||||||
));
|
|
||||||
$log->logAction(ADM_ACTION, LOG_NOTICE, 'changed password');
|
$log->logAction(ADM_ACTION, LOG_NOTICE, 'changed password');
|
||||||
redirectTo($filename, Array('s' => $s));
|
redirectTo($filename, Array('s' => $s));
|
||||||
}
|
}
|
||||||
@@ -238,16 +234,13 @@ if ($page == 'overview') {
|
|||||||
$def_language = validate($_POST['def_language'], 'default language');
|
$def_language = validate($_POST['def_language'], 'default language');
|
||||||
|
|
||||||
if (isset($languages[$def_language])) {
|
if (isset($languages[$def_language])) {
|
||||||
$lng_stmt = Database::prepare("
|
try {
|
||||||
UPDATE `" . TABLE_PANEL_ADMINS . "`
|
Admins::getLocal($userinfo, array('id' => $userinfo['adminid'], 'def_language' => $def_language))->update();
|
||||||
SET `def_language`= :deflng
|
} catch (Exception $e) {
|
||||||
WHERE `adminid`= :adminid"
|
dynamic_error($e->getMessage());
|
||||||
);
|
}
|
||||||
Database::pexecute($lng_stmt, array(
|
|
||||||
'deflng' => $def_language,
|
|
||||||
'adminid' => (int)$userinfo['adminid']
|
|
||||||
));
|
|
||||||
|
|
||||||
|
// also update current session
|
||||||
$lng_stmt = Database::prepare("
|
$lng_stmt = Database::prepare("
|
||||||
UPDATE `" . TABLE_PANEL_SESSIONS . "`
|
UPDATE `" . TABLE_PANEL_SESSIONS . "`
|
||||||
SET `language`= :lng
|
SET `language`= :lng
|
||||||
@@ -258,7 +251,6 @@ if ($page == 'overview') {
|
|||||||
'hash' => $s
|
'hash' => $s
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$log->logAction(ADM_ACTION, LOG_NOTICE, "changed his/her default language to '" . $def_language . "'");
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "changed his/her default language to '" . $def_language . "'");
|
||||||
redirectTo($filename, array('s' => $s));
|
redirectTo($filename, array('s' => $s));
|
||||||
|
|
||||||
@@ -284,17 +276,13 @@ if ($page == 'overview') {
|
|||||||
&& $_POST['send'] == 'send'
|
&& $_POST['send'] == 'send'
|
||||||
) {
|
) {
|
||||||
$theme = validate($_POST['theme'], 'theme');
|
$theme = validate($_POST['theme'], 'theme');
|
||||||
|
try {
|
||||||
|
Admins::getLocal($userinfo, array('id' => $userinfo['adminid'], 'theme' => $theme))->update();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
dynamic_error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
$theme_stmt = Database::prepare("
|
// also update current session
|
||||||
UPDATE `" . TABLE_PANEL_ADMINS . "`
|
|
||||||
SET `theme`= :theme
|
|
||||||
WHERE `adminid`= :adminid"
|
|
||||||
);
|
|
||||||
Database::pexecute($theme_stmt, array(
|
|
||||||
'theme' => $theme,
|
|
||||||
'adminid' => (int)$userinfo['adminid']
|
|
||||||
));
|
|
||||||
|
|
||||||
$theme_stmt = Database::prepare("
|
$theme_stmt = Database::prepare("
|
||||||
UPDATE `" . TABLE_PANEL_SESSIONS . "`
|
UPDATE `" . TABLE_PANEL_SESSIONS . "`
|
||||||
SET `theme`= :theme
|
SET `theme`= :theme
|
||||||
|
|||||||
@@ -122,15 +122,11 @@ if ($page == 'overview') {
|
|||||||
standard_error('newpasswordconfirmerror');
|
standard_error('newpasswordconfirmerror');
|
||||||
} else {
|
} else {
|
||||||
// Update user password
|
// Update user password
|
||||||
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
|
try {
|
||||||
SET `password` = :newpassword
|
Customers::getLocal($userinfo, array('id' => $userinfo['customerid'], 'new_customer_password' => $new_password))->update();
|
||||||
WHERE `customerid` = :customerid"
|
} catch (Exception $e) {
|
||||||
);
|
dynamic_error($e->getMessage());
|
||||||
$params = array(
|
}
|
||||||
"newpassword" => makeCryptPassword($new_password),
|
|
||||||
"customerid" => $userinfo['customerid']
|
|
||||||
);
|
|
||||||
Database::pexecute($stmt, $params);
|
|
||||||
$log->logAction(USR_ACTION, LOG_NOTICE, 'changed password');
|
$log->logAction(USR_ACTION, LOG_NOTICE, 'changed password');
|
||||||
|
|
||||||
// Update ftp password
|
// Update ftp password
|
||||||
@@ -181,21 +177,20 @@ if ($page == 'overview') {
|
|||||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||||
$def_language = validate($_POST['def_language'], 'default language');
|
$def_language = validate($_POST['def_language'], 'default language');
|
||||||
if (isset($languages[$def_language])) {
|
if (isset($languages[$def_language])) {
|
||||||
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
|
try {
|
||||||
SET `def_language` = :lang
|
Customers::getLocal($userinfo, array('id' => $userinfo['customerid'], 'def_language' => $def_language))->update();
|
||||||
WHERE `customerid` = :customerid"
|
} catch (Exception $e) {
|
||||||
);
|
dynamic_error($e->getMessage());
|
||||||
Database::pexecute($stmt, array("lang" => $def_language, "customerid" => $userinfo['customerid']));
|
}
|
||||||
|
|
||||||
|
// also update current session
|
||||||
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_SESSIONS . "`
|
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_SESSIONS . "`
|
||||||
SET `language` = :lang
|
SET `language` = :lang
|
||||||
WHERE `hash` = :hash"
|
WHERE `hash` = :hash"
|
||||||
);
|
);
|
||||||
Database::pexecute($stmt, array("lang" => $def_language, "hash" => $s));
|
Database::pexecute($stmt, array("lang" => $def_language, "hash" => $s));
|
||||||
|
|
||||||
$log->logAction(USR_ACTION, LOG_NOTICE, "changed default language to '" . $def_language . "'");
|
|
||||||
}
|
}
|
||||||
|
$log->logAction(USR_ACTION, LOG_NOTICE, "changed default language to '" . $def_language . "'");
|
||||||
redirectTo($filename, array('s' => $s));
|
redirectTo($filename, array('s' => $s));
|
||||||
} else {
|
} else {
|
||||||
$default_lang = Settings::Get('panel.standardlanguage');
|
$default_lang = Settings::Get('panel.standardlanguage');
|
||||||
@@ -213,13 +208,13 @@ if ($page == 'overview') {
|
|||||||
} elseif ($page == 'change_theme') {
|
} elseif ($page == 'change_theme') {
|
||||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||||
$theme = validate($_POST['theme'], 'theme');
|
$theme = validate($_POST['theme'], 'theme');
|
||||||
|
try {
|
||||||
|
Customers::getLocal($userinfo, array('id' => $userinfo['customerid'], 'theme' => $theme))->update();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
dynamic_error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
|
// also update current session
|
||||||
SET `theme` = :theme
|
|
||||||
WHERE `customerid` = :customerid"
|
|
||||||
);
|
|
||||||
Database::pexecute($stmt, array("theme" => $theme, "customerid" => $userinfo['customerid']));
|
|
||||||
|
|
||||||
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_SESSIONS . "`
|
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_SESSIONS . "`
|
||||||
SET `theme` = :theme
|
SET `theme` = :theme
|
||||||
WHERE `hash` = :hash"
|
WHERE `hash` = :hash"
|
||||||
|
|||||||
@@ -313,14 +313,14 @@ class Admins extends ApiCommand implements ResourceEntity
|
|||||||
$name = $this->getParam('name', true, $result['name']);
|
$name = $this->getParam('name', true, $result['name']);
|
||||||
$idna_convert = new idna_convert_wrapper();
|
$idna_convert = new idna_convert_wrapper();
|
||||||
$email = $this->getParam('email', true, $idna_convert->decode($result['email']));
|
$email = $this->getParam('email', true, $idna_convert->decode($result['email']));
|
||||||
|
$password = $this->getParam('admin_password', true, '');
|
||||||
|
$def_language = $this->getParam('def_language', true, $result['def_language']);
|
||||||
$custom_notes = $this->getParam('custom_notes', true, $result['custom_notes']);
|
$custom_notes = $this->getParam('custom_notes', true, $result['custom_notes']);
|
||||||
$custom_notes_show = $this->getParam('custom_notes_show', true, $result['custom_notes_show']);
|
$custom_notes_show = $this->getParam('custom_notes_show', true, $result['custom_notes_show']);
|
||||||
$theme = $this->getParam('theme', true, $result['theme']);
|
$theme = $this->getParam('theme', true, $result['theme']);
|
||||||
|
|
||||||
// you cannot edit some of the details of yourself
|
// you cannot edit some of the details of yourself
|
||||||
if ($result['adminid'] == $this->getUserDetail('userid')) {
|
if ($result['adminid'] == $this->getUserDetail('userid')) {
|
||||||
$password = '';
|
|
||||||
$def_language = $result['def_language'];
|
|
||||||
$deactivated = $result['deactivated'];
|
$deactivated = $result['deactivated'];
|
||||||
$customers = $result['customers'];
|
$customers = $result['customers'];
|
||||||
$domains = $result['domains'];
|
$domains = $result['domains'];
|
||||||
@@ -341,8 +341,6 @@ class Admins extends ApiCommand implements ResourceEntity
|
|||||||
$traffic = $result['traffic'];
|
$traffic = $result['traffic'];
|
||||||
$ipaddress = $result['ip'];
|
$ipaddress = $result['ip'];
|
||||||
} else {
|
} else {
|
||||||
$password = $this->getParam('admin_password', true, '');
|
|
||||||
$def_language = $this->getParam('def_language', true, $result['def_language']);
|
|
||||||
$deactivated = $this->getParam('deactivated', true, $result['deactivated']);
|
$deactivated = $this->getParam('deactivated', true, $result['deactivated']);
|
||||||
|
|
||||||
$dec_places = Settings::Get('panel.decimal_places');
|
$dec_places = Settings::Get('panel.decimal_places');
|
||||||
@@ -377,6 +375,7 @@ class Admins extends ApiCommand implements ResourceEntity
|
|||||||
$def_language = validate($def_language, 'default language', '', '', array(), true);
|
$def_language = validate($def_language, 'default language', '', '', array(), true);
|
||||||
$custom_notes = validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true);
|
$custom_notes = validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true);
|
||||||
$theme = validate($theme, 'theme', '', '', array(), true);
|
$theme = validate($theme, 'theme', '', '', array(), true);
|
||||||
|
$password = validate($password, 'password', '', '', array(), true);
|
||||||
|
|
||||||
if (Settings::Get('system.mail_quota_enabled') != '1') {
|
if (Settings::Get('system.mail_quota_enabled') != '1') {
|
||||||
$email_quota = - 1;
|
$email_quota = - 1;
|
||||||
@@ -390,16 +389,6 @@ class Admins extends ApiCommand implements ResourceEntity
|
|||||||
$theme = Settings::Get('panel.default_theme');
|
$theme = Settings::Get('panel.default_theme');
|
||||||
}
|
}
|
||||||
|
|
||||||
$password = validate($password, 'password', '', '', array(), true);
|
|
||||||
// only check if not empty,
|
|
||||||
// cause empty == generate password automatically
|
|
||||||
if ($password != '') {
|
|
||||||
$password = validatePassword($password, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$diskspace = $diskspace * 1024;
|
|
||||||
$traffic = $traffic * 1024 * 1024;
|
|
||||||
|
|
||||||
if ($name == '') {
|
if ($name == '') {
|
||||||
standard_error(array(
|
standard_error(array(
|
||||||
'stringisempty',
|
'stringisempty',
|
||||||
|
|||||||
Reference in New Issue
Block a user