1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 06:38:00 +02:00

Update db access - change admin password

This commit is contained in:
e107steved
2009-01-11 22:11:19 +00:00
parent 540146be8f
commit 70a2b51da7
4 changed files with 36 additions and 15 deletions

View File

@@ -9,8 +9,8 @@
* Administration Area - Update Admin * Administration Area - Update Admin
* *
* $Source: /cvs_backup/e107_0.8/e107_admin/updateadmin.php,v $ * $Source: /cvs_backup/e107_0.8/e107_admin/updateadmin.php,v $
* $Revision: 1.4 $ * $Revision: 1.5 $
* $Date: 2008-12-29 11:00:16 $ * $Date: 2009-01-11 22:11:19 $
* $Author: e107steved $ * $Author: e107steved $
* *
*/ */
@@ -21,6 +21,7 @@ $e_sub_cat = 'admin_pass';
require_once(e_ADMIN.'auth.php'); require_once(e_ADMIN.'auth.php');
require_once(e_HANDLER.'message_handler.php'); require_once(e_HANDLER.'message_handler.php');
require_once(e_HANDLER.'user_handler.php'); require_once(e_HANDLER.'user_handler.php');
require_once(e_HANDLER.'validator_class.php');
$userMethods = new UserHandler; $userMethods = new UserHandler;
$emessage = &eMessage::getInstance(); $emessage = &eMessage::getInstance();
@@ -29,25 +30,28 @@ if (isset($_POST['update_settings']))
if ($_POST['ac'] == md5(ADMINPWCHANGE)) if ($_POST['ac'] == md5(ADMINPWCHANGE))
{ {
$userData = array(); $userData = array();
$userData['data'] = array();
if ($_POST['a_password'] != '' && $_POST['a_password2'] != '' && ($_POST['a_password'] == $_POST['a_password2'])) if ($_POST['a_password'] != '' && $_POST['a_password2'] != '' && ($_POST['a_password'] == $_POST['a_password2']))
{ {
$userData['user_password'] = $sql->escape($userMethods->HashPassword($_POST['a_password'], $currentUser['user_loginname']), FALSE); $userData['data']['user_password'] = $sql->escape($userMethods->HashPassword($_POST['a_password'], $currentUser['user_loginname']), FALSE);
unset($_POST['a_password']); unset($_POST['a_password']);
unset($_POST['a_password2']); unset($_POST['a_password2']);
if (varsettrue($pref['allowEmailLogin'])) if (varsettrue($pref['allowEmailLogin']))
{ {
$user_prefs = unserialize($currentUser['user_prefs']); $user_prefs = unserialize($currentUser['user_prefs']);
$user_prefs['email_password'] = $userMethods->HashPassword($new_pass, $email); $user_prefs['email_password'] = $userMethods->HashPassword($new_pass, $email);
$userData['user_prefs'] = serialize($user_prefs); $userData['data']['user_prefs'] = serialize($user_prefs);
} }
$userData['user_pwchange'] =time(); $userData['data']['user_pwchange'] = time();
$userData['WHERE'] = 'user_id='.USERID;
validatorClass::addFieldTypes($userMethods->userVettingInfo,$userData, $userMethods->otherFieldTypes);
$check = $sql -> db_UpdateArray('user',$userData,' WHERE user_id='.USERID); $check = $sql -> db_Update('user',$userData);
if ($check) if ($check)
{ {
$admin_log->log_event('ADMINPW_01', '', E_LOG_INFORMATIVE, ''); $admin_log->log_event('ADMINPW_01', '', E_LOG_INFORMATIVE, '');
$userMethods->makeUserCookie(array('user_id' => USERID,'user_password' => $userData['user_password']), FALSE); // Can't handle autologin ATM $userMethods->makeUserCookie(array('user_id' => USERID,'user_password' => $userData['data']['user_password']), FALSE); // Can't handle autologin ATM
$emessage->add(UDALAN_3." ".ADMINNAME, E_MESSAGE_SUCCESS); $emessage->add(UDALAN_3." ".ADMINNAME, E_MESSAGE_SUCCESS);
$e_event -> trigger('adpword'); $e_event -> trigger('adpword');
$ns->tablerender(UDALAN_2, $emessage->render()); $ns->tablerender(UDALAN_2, $emessage->render());

View File

@@ -9,8 +9,8 @@
* Administration Area - Users * Administration Area - Users
* *
* $Source: /cvs_backup/e107_0.8/e107_admin/users.php,v $ * $Source: /cvs_backup/e107_0.8/e107_admin/users.php,v $
* $Revision: 1.26 $ * $Revision: 1.27 $
* $Date: 2009-01-11 21:06:46 $ * $Date: 2009-01-11 22:11:19 $
* $Author: e107steved $ * $Author: e107steved $
* *
*/ */
@@ -43,7 +43,7 @@ if (isset($_POST['useraction']) && $_POST['useraction'] == 'userclass')
exit; exit;
} }
var_dump($_POST); //var_dump($_POST);
if(isset($_POST['updateRanks'])) if(isset($_POST['updateRanks']))
{ {
updateRanks(); updateRanks();

View File

@@ -9,8 +9,8 @@
* Handler - user-related functions * Handler - user-related functions
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/user_handler.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/user_handler.php,v $
* $Revision: 1.7 $ * $Revision: 1.8 $
* $Date: 2009-01-11 21:06:46 $ * $Date: 2009-01-11 22:11:19 $
* $Author: e107steved $ * $Author: e107steved $
* *
*/ */
@@ -114,6 +114,19 @@ class UserHandler
'user_pwchange' => LAN_USER_24 'user_pwchange' => LAN_USER_24
// user_chats int(10) unsigned NOT NULL default '0', // user_chats int(10) unsigned NOT NULL default '0',
); );
$this->otherFieldTypes = array(
'user_join' => 'int',
'user_lastvisit' => 'int',
'user_currentvisit' => 'int',
'user_comments' => 'int',
'user_ip' => 'string',
'user_ban' => 'int',
'user_prefs' => 'string',
'user_visits' => 'int',
'user_admin' => 'int',
'user_perms' => 'string',
'user_pwchange' => 'int'
);
$this->passwordOpts = varset($pref['passwordEncoding'],0); $this->passwordOpts = varset($pref['passwordEncoding'],0);
$this->passwordEmail = varset($pref['allowEmailLogin'],FALSE); $this->passwordEmail = varset($pref['allowEmailLogin'],FALSE);

View File

@@ -9,8 +9,8 @@
* Handler - general purpose validation functions * Handler - general purpose validation functions
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $
* $Revision: 1.5 $ * $Revision: 1.6 $
* $Date: 2009-01-11 21:06:46 $ * $Date: 2009-01-11 22:11:19 $
* $Author: e107steved $ * $Author: e107steved $
* *
*/ */
@@ -397,7 +397,7 @@ class validatorClass
// Adds the _FIELD_TYPES array to the data, ready for saving in the DB. // Adds the _FIELD_TYPES array to the data, ready for saving in the DB.
// $fieldList is the standard definition array // $fieldList is the standard definition array
function addFieldTypes($fieldList, &$target) function addFieldTypes($fieldList, &$target, $auxList=FALSE)
{ {
$target['_FIELD_TYPES'] = array(); // We should always want to recreate the array, even if it exists $target['_FIELD_TYPES'] = array(); // We should always want to recreate the array, even if it exists
foreach ($target['data'] as $k => $v) foreach ($target['data'] as $k => $v)
@@ -406,6 +406,10 @@ class validatorClass
{ {
$target['_FIELD_TYPES'][$k] = $fieldList[$k]['fieldType']; $target['_FIELD_TYPES'][$k] = $fieldList[$k]['fieldType'];
} }
elseif (is_array($auxList) && isset($auxList[$k]))
{
$target['_FIELD_TYPES'][$k] = $auxList[$k];
}
} }
} }