diff --git a/class2.php b/class2.php
index 935f76673..3884e5d7c 100644
--- a/class2.php
+++ b/class2.php
@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/class2.php,v $
-| $Revision: 1.86 $
-| $Date: 2008-12-19 22:56:22 $
+| $Revision: 1.87 $
+| $Date: 2008-12-21 11:07:58 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
@@ -1446,7 +1446,6 @@ function init_session()
define('USEREMAIL', $result['user_email']);
define('USER', true);
define('USERCLASS', $result['user_class']);
- define('USERREALM', $result['user_realm']);
define('USERVIEWED', $result['user_viewed']);
define('USERIMAGE', $result['user_image']);
define('USERPHOTO', $result['user_sess']);
diff --git a/e107_admin/users.php b/e107_admin/users.php
index ed8a4f262..8d70a8216 100644
--- a/e107_admin/users.php
+++ b/e107_admin/users.php
@@ -1,20 +1,18 @@
localuser= $adminuser;
@@ -141,20 +141,27 @@ if (isset($_POST['test_mail']))
// ------- Update Options. --------------
if (isset($_POST['update_options']))
{
- $pref['avatar_upload'] = (FILE_UPLOADS ? $_POST['avatar_upload'] : 0);
- $pref['im_width'] = $_POST['im_width'];
- $pref['im_height'] = $_POST['im_height'];
- $pref['photo_upload'] = (FILE_UPLOADS ? $_POST['photo_upload'] : 0);
- $pref['del_unv'] = $_POST['del_unv'];
- $pref['profile_rate'] = $_POST['profile_rate'];
- $pref['profile_comments'] = $_POST['profile_comments'];
- $pref['track_online'] = $_POST['track_online'];
- $pref['force_userupdate'] = $_POST['force_userupdate'];
- $pref['memberlist_access'] = $_POST['memberlist_access'];
- save_prefs();
- unset($_POST['update_options']); // So we don't log it
- $admin_log->log_event('USET_03',$tp->toDB(implode('; ',$_POST)),E_LOG_INFORMATIVE);
- $user->show_message(USRLAN_1);
+ $temp = array();
+ $temp['avatar_upload'] = (FILE_UPLOADS ? $_POST['avatar_upload'] : 0);
+ $temp['im_width'] = $_POST['im_width'];
+ $temp['im_height'] = $_POST['im_height'];
+ $temp['photo_upload'] = (FILE_UPLOADS ? $_POST['photo_upload'] : 0);
+ $temp['del_unv'] = $_POST['del_unv'];
+ $temp['profile_rate'] = $_POST['profile_rate'];
+ $temp['profile_comments'] = $_POST['profile_comments'];
+ $temp['track_online'] = $_POST['track_online'];
+ $temp['force_userupdate'] = $_POST['force_userupdate'];
+ $temp['memberlist_access'] = $_POST['memberlist_access'];
+ $temp['user_new_period'] = $_POST['user_new_period'];
+ if ($admin_log->logArrayDiffs($temp, $pref, 'USET_03'))
+ {
+ save_prefs(); // Only save if changes
+ $user->show_message(USRLAN_1);
+ }
+ else
+ {
+ $user->show_message(USRLAN_193);
+ }
}
@@ -184,136 +191,89 @@ if (isset($_POST['prune']))
// ------- Quick Add User --------------
if (isset($_POST['adduser']))
{
- $e107cache->clear("online_menu_member_total");
- $e107cache->clear("online_menu_member_newest");
if (!$_POST['ac'] == md5(ADMINPWCHANGE))
{
exit;
}
- $user_data = array(); // Assemble the data into an array
-
- require_once(e_HANDLER."message_handler.php");
- $displayname = strip_tags($_POST['name']);
- if (($displayname != strip_tags($_POST['name'])) || (strstr($_POST['name'], "#") || strstr($_POST['name'], "=")))
- {
- message_handler("P_ALERT", USRLAN_92);
- $error = TRUE;
- }
- $displayname = trim(str_replace(" ", "", $displayname));
- if ($displayname == "Anonymous")
- {
- message_handler("P_ALERT", USRLAN_65);
- $error = TRUE;
- }
- if ((strlen($displayname) > varset($pref['displayname_maxlength'],15)) || (strlen($displayname) < 2))
- {
- message_handler('P_ALERT',USRLAN_154);
- $error = TRUE;
- }
- if ($sql->db_Count("user", "(*)", "WHERE user_name='".$displayname."' "))
- {
- message_handler("P_ALERT", USRLAN_66);
- $error = TRUE;
- }
+ $e107cache->clear('online_menu_member_total');
+ $e107cache->clear('online_menu_member_newest');
+ $error = FALSE;
if (isset($_POST['generateloginname']))
{
- $loginname = $user_info->generateUserLogin($pref['predefinedLoginName']);
+ $_POST['loginname'] = $userMethods->generateUserLogin($pref['predefinedLoginName']);
}
- else
- {
- $loginname = trim(preg_replace('/ |\#|\=|\$/', "", strip_tags($_POST['loginname'])));
- if ($loginname != $_POST['loginname'])
- {
- message_handler('P_ALERT',USRLAN_152);
- $error = TRUE;
- }
- }
- if ((strlen($loginname) > varset($pref['loginname_maxlength'],30)) || (strlen($loginname) < 3))
- {
- message_handler('P_ALERT',USRLAN_154);
- $error = TRUE;
- }
- if ($sql->db_Count("user", "(*)", "WHERE user_loginname='".$loginname."' "))
- {
- message_handler("P_ALERT", USRLAN_153);
- $error = TRUE;
- }
-
-
if (isset($_POST['generatepassword']))
{
- $_POST['password1'] = $user_info->generateRandomString('**********'); // 10-char password should be enough
- }
- else
- {
- if ($_POST['password1'] != $_POST['password2'])
- {
- message_handler("P_ALERT", USRLAN_67);
- $error = TRUE;
- }
+ $_POST['password1'] = $userMethods->generateRandomString('**********'); // 10-char password should be enough
+ $_POST['password2'] = $_POST['password1'];
}
- if ($_POST['name'] == "" || $_POST['password1'] == "" || $_POST['password2'] = "")
+ // Now validate everything
+ $allData = validatorClass::validateFields($_POST,$userMethods->userVettingInfo, TRUE); // Do basic validation
+ validatorClass::checkMandatory('user_name,user_loginname', $allData); // Check for missing fields (email done in userValidation() )
+ validatorClass::dbValidateArray($allData, $userMethods->userVettingInfo, 'user', 0); // Do basic DB-related checks
+ $userMethods->userValidation($allData); // Do user-specific DB checks
+ if (($_POST['password1'] != $_POST['password2']) && !isset($allData['errors']['user_password']))
{
- message_handler("P_ALERT", USRLAN_68);
- $error = TRUE;
+ $allData['errors']['user_password'] = ERR_PASSWORDS_DIFFERENT;
}
- if (!check_email($_POST['email']))
+ if (!check_class($pref['displayname_class'], $allData['validate']['user_class']))
{
- message_handler("P_ALERT", USRLAN_69);
- $error = TRUE;
+ if ($allData['validate']['user_name'] != $allData['validate']['user_loginname'])
+ {
+ $allData['errors']['user_name'] = ERR_FIELDS_DIFFERENT;
+ }
}
- if ($sql->db_Count("user", "(*)", "WHERE user_email='".$_POST['email']."' AND user_ban='1' "))
+
+ if (count($allData['errors']))
{
- message_handler("P_ALERT", USRLAN_147);
- $error = TRUE;
- }
- if ($sql->db_Count("banlist", "(*)", "WHERE banlist_ip='".$_POST['email']."'"))
- {
- message_handler("P_ALERT", USRLAN_148);
- $error = TRUE;
+ require_once(e_HANDLER."message_handler.php");
+ $temp = validatorClass::makeErrorList($allData,'USER_ERR_','%n - %x - %t: %v', '
', $userMethods->userVettingInfo);
+ message_handler('P_ALERT', $temp);
+ $error = TRUE;
}
// Always save some of the entered data - then we can redisplay on error
- $user_data['user_name'] = $displayname;
- $user_data['user_loginname'] = $loginname;
- $user_data['user_class'] = implode(",", $_POST['userclass']);
- $user_data['user_email'] = $tp->toDB($_POST['email']);
- $user_data['user_hideemail'] = 1;
- $user_data['user_login'] = $tp->toDB($_POST['realname']);
+ $user_data = $allData['validate'];
if (!$error)
{
- $user_data['user_password'] = $user_info->HashPassword($_POST['password1'],$loginname);
- $user_data['user_join'] = time();
- $user_data['user_lastvisit'] = 0;
- $user_data['user_currentvisit'] = 0;
- $user_data['user_pwchange'] = 0;
- if (admin_update($sql -> db_Insert("user", $user_data), 'insert', USRLAN_70))
- {
- // Add to admin log
- $admin_log->log_event('USET_02',"UName: {$user_data['user_name']}; Email: {$user_data['user_email']}",E_LOG_INFORMATIVE);
- // Add to user audit trail
- $admin_log->user_audit(USER_AUDIT_ADD_ADMIN,$user_data, 0,$user_data['user_loginname']);
- if (isset($_POST['sendconfemail']))
- { // Send confirmation email to user
- require_once(e_HANDLER.'mail.php');
- $e_message = str_replace(array('--SITE--','--LOGIN--','--PASSWORD--'),array(SITEURL,$loginname,$_POST['password1']),USRLAN_185).USRLAN_186;
- if (sendemail($user_data['user_email'],USRLAN_187.SITEURL,$e_message,$user_data['user_login'],'',''))
- {
- $message = USRLAN_188;
- }
- else
- {
- $message = USRLAN_189;
- }
+ $message = '';
+ $user_data['user_password'] = $userMethods->HashPassword($_POST['password1'],$loginname);
+ $user_data['user_join'] = time();
+ if ($userMethods->needEmailPassword())
+ { // Save separate password encryption for use with email address
+ $user_data['user_prefs'] = serialize(array('email_password' => $userMethods->HashPassword($_POST['password1'], $user_data['user_email'])));
+ }
+ $userMethods->addNonDefaulted($user_data);
+ if (admin_update($sql -> db_Insert("user", $user_data), 'insert', USRLAN_70))
+ {
+ // Add to admin log
+ $admin_log->log_event('USET_02',"UName: {$user_data['user_name']}; Email: {$user_data['user_email']}",E_LOG_INFORMATIVE);
+ // Add to user audit trail
+ $admin_log->user_audit(USER_AUDIT_ADD_ADMIN,$user_data, 0,$user_data['user_loginname']);
+ if (isset($_POST['sendconfemail']))
+ { // Send confirmation email to user
+ require_once(e_HANDLER.'mail.php');
+ $e_message = str_replace(array('--SITE--','--LOGIN--','--PASSWORD--'),array(SITEURL,$loginname,$_POST['password1']),USRLAN_185).USRLAN_186;
+ if (sendemail($user_data['user_email'],USRLAN_187.SITEURL,$e_message,$user_data['user_login'],'',''))
+ {
+ $message = USRLAN_188.'
';
+ }
+ else
+ {
+ $message = USRLAN_189.'
';
+ }
+ }
+ $message .= str_replace('--NAME--',$user_data['user_name'], USRLAN_174) ;
+ if (isset($_POST['generateloginname'])) $message .= '
'.USRLAN_173.': '.$loginname;
+ if (isset($_POST['generatepassword'])) $message .= '
'.USRLAN_172.': '.$_POST['password1'];
+
+ unset($user_data); // Don't recycle the data once the user's been accepted without error
}
- if (isset($_POST['generateloginname'])) $message .= '
'.USRLAN_173.': '.$loginname;
- if (isset($_POST['generatepassword'])) $message .= '
'.USRLAN_172.': '.$_POST['password1'];
- }
}
if (isset($message)) $user->show_message($message);
}
@@ -599,24 +559,25 @@ $unverified = $sql -> db_Count("user", "(*)", "WHERE user_ban = 2");
if (!e_QUERY) $action = "main";
switch ($action)
{
- case "unverified" :
- $user->show_existing_users($action, $sub_action, $id, $from, $amount);
- break;
+ case "unverified" :
+ $user->show_existing_users($action, $sub_action, $id, $from, $amount);
+ break;
- case "options" :
- $user->show_prefs();
- break;
+ case "options" :
+ $user->show_prefs();
+ break;
- case "prune" :
- $user->show_prune();
- break;
+ case "prune" :
+ $user->show_prune();
+ break;
- case "create" :
- $user->add_user($user_data);
- break;
+ case "create" :
+ $userMethods->deleteExpired(); // Remove time-expired users
+ $user->add_user($user_data);
+ break;
- default :
- $user->show_existing_users($action, $sub_action, $id, $from, $amount);
+ default :
+ $user->show_existing_users($action, $sub_action, $id, $from, $amount);
}
@@ -631,7 +592,7 @@ class users
function show_existing_users($action, $sub_action, $id, $from, $amount)
{
- global $sql, $rs, $ns, $tp, $mySQLdefaultdb,$pref,$unverified;
+ global $sql, $rs, $ns, $tp, $mySQLdefaultdb,$pref,$unverified, $userMethods;
// save the display choices.
if(isset($_POST['searchdisp']))
{
@@ -648,7 +609,8 @@ class users
$search_display = explode("|",$pref['admin_user_disp']);
}
- if ($sql->db_Select("userclass_classes")) {
+ if ($sql->db_Select("userclass_classes"))
+ {
while ($row = $sql->db_Fetch())
{
$class[$row['userclass_id']] = $tp->toHTML($row['userclass_name'],"","defs,emotes_off, no_make_clickable");
@@ -660,12 +622,12 @@ class users
if (isset($_POST['searchquery']) && $_POST['searchquery'] != "")
{
$_POST['searchquery'] = $tp->toDB(trim($_POST['searchquery']));
- $query = "WHERE ".
+ $query = "WHERE ".
$query .= (strpos($_POST['searchquery'], "@") !== FALSE) ? "user_email REGEXP('".$_POST['searchquery']."') OR ": "";
$query .= (strpos($_POST['searchquery'], ".") !== FALSE) ? "user_ip REGEXP('".$_POST['searchquery']."') OR ": "";
foreach($search_display as $disp)
{
- $query .= "$disp REGEXP('".$_POST['searchquery']."') OR ";
+ $query .= $disp." REGEXP('".$_POST['searchquery']."') OR ";
}
$query .= "user_login REGEXP('".$_POST['searchquery']."') OR ";
$query .= "user_name REGEXP('".$_POST['searchquery']."') ";
@@ -674,7 +636,9 @@ class users
$query .= " AND user_ban = 2 ";
}
$query .= " ORDER BY user_id";
- } else {
+ }
+ else
+ {
$query = "";
if($action == 'unverified')
{
@@ -684,75 +648,42 @@ class users
}
// $user_total = db_Count($table, $fields = '(*)',
- $qry_insert = "SELECT u.*, ue.* FROM #user AS u LEFT JOIN #user_extended AS ue ON ue.user_extended_id = u.user_id ";
-
- if ($user_total = $sql->db_Select_gen($qry_insert. $query)) {
+ $qry_insert = "SELECT u.*, ue.* FROM #user AS u LEFT JOIN #user_extended AS ue ON ue.user_extended_id = u.user_id ";
+
+ if ($user_total = $sql->db_Select_gen($qry_insert. $query))
+ {
$text .= "
ID | -".USRLAN_79." | "; - - -// Search Display Column header. - $display_lan = array( - 'user_id' => DUSRLAN_1, - 'user_name' => DUSRLAN_2, - 'user_loginname' => DUSRLAN_3, - 'user_customtitle' => DUSRLAN_4, - 'user_password' => DUSRLAN_5, - 'user_sess' => DUSRLAN_6, - 'user_email' => DUSRLAN_7, - 'user_homepage' => DUSRLAN_8, - 'user_icq' => DUSRLAN_9, - 'user_aim' => DUSRLAN_10, - 'user_msn' => DUSRLAN_11, - 'user_location' => DUSRLAN_12, - 'user_birthday' => DUSRLAN_13, - 'user_signature' => DUSRLAN_14, - 'user_image' => DUSRLAN_15, - 'user_timezone' => DUSRLAN_16, - 'user_hideemail' => DUSRLAN_17, - 'user_join' => DUSRLAN_18, - 'user_lastvisit' => DUSRLAN_19, - 'user_currentvisit' => DUSRLAN_20, - 'user_lastpost' => DUSRLAN_21, - 'user_chats' => DUSRLAN_22, - 'user_comments' => DUSRLAN_23, - 'user_forums' => DUSRLAN_24, - 'user_ip' => DUSRLAN_25, - 'user_ban' => DUSRLAN_26, - 'user_prefs' => DUSRLAN_27, - 'user_new' => DUSRLAN_28, - 'user_viewed' => DUSRLAN_29, - 'user_visits' => DUSRLAN_30, - 'user_admin' => DUSRLAN_31, - 'user_login' => DUSRLAN_32, - 'user_class' => DUSRLAN_33, - 'user_perms' => DUSRLAN_34, - 'user_realm' => DUSRLAN_35, - 'user_pwchange' => DUSRLAN_36, - 'user_xup' => DUSRLAN_37 - ); - - foreach($search_display as $disp){ - if (isset($display_lan[$disp])) { +||||
ID | +".USRLAN_79." | "; + + + // Search Display Column header. + $display_lan = $userMethods->getNiceNames(TRUE); // List of field names and descriptive names + foreach($search_display as $disp) + { + if (isset($display_lan[$disp])) + { $text .= "".$display_lan[$disp]." | "; - } else { + } + else + { $text .= "".ucwords(str_replace("_"," ",$disp))." | "; } } - -// ------------------------------ - + + // ------------------------------ + $text .= "".LAN_OPTIONS." | -|
$user_id | +{$user_id} | ";
-
+
if ($user_perms == "0") {
$text .= " ".LAN_MAINADMIN." ";
}
@@ -770,95 +701,96 @@ class users
} else {
$text .= " ";
}
-
+
$text .= " | ";
-
-
-
- // Display Chosen options -------------------------------------
-
- $datefields = array("user_lastpost","user_lastvisit","user_join","user_currentvisit");
- $boleanfields = array("user_admin","user_hideemail","user_ban");
-
- foreach($search_display as $disp)
- {
- $text .= "";
- if($disp == "user_class")
- {
- if ($user_class)
- {
- $tmp = explode(",", $user_class);
- while (list($key, $class_id) = each($tmp))
+
+
+
+ // Display Chosen options
+
+ $datefields = array("user_lastpost","user_lastvisit","user_join","user_currentvisit");
+ $boleanfields = array("user_admin","user_hideemail","user_ban");
+
+ foreach($search_display as $disp)
{
- $text .= ($class[$class_id] ? $class[$class_id]." \n" : ""); + $text .= " | ";
+ if($disp == "user_class")
+ {
+ if ($user_class)
+ {
+ $tmp = explode(",", $user_class);
+ while (list($key, $class_id) = each($tmp))
+ {
+ $text .= ($class[$class_id] ? $class[$class_id]." \n" : ""); + } + } + else + { + $text .= " "; + } + } + elseif (in_array($disp,$boleanfields)) + { + $text .= ($row[$disp]) ? ADMIN_TRUE_ICON : ""; + } + elseif(in_array($disp,$datefields)) + { + $text .= ($row[$disp]) ? strftime($pref['shortdate'],$row[$disp])." " : " "; + } + elseif($disp == "user_name") + { + $text .= "{$row['user_name']}"; + } + else + { + $text .= $row[$disp]." "; + } + if(!in_array($disp,$boleanfields) && isset($prev[$disp]) && $row[$disp] == $prev[$disp] && $prev[$disp] != "") + { // show matches + $text .= " *"; + } + + $text .= " | ";
+ $prev[$disp] = $row[$disp];
}
- }
- else
- {
- $text .= " ";
- }
- }elseif(in_array($disp,$boleanfields))
- {
- $text .= ($row[$disp]) ? ADMIN_TRUE_ICON : "";
- }
- elseif(in_array($disp,$datefields))
- {
- $text .= ($row[$disp]) ? strftime($pref['shortdate'],$row[$disp])." " : " ";
- }
- elseif($disp == "user_name")
- {
- $text .= "{$row['user_name']}";
- }
- else
- {
- $text .= $row[$disp]." ";
- }
- if(!in_array($disp,$boleanfields) && isset($prev[$disp]) && $row[$disp] == $prev[$disp] && $prev[$disp] != "")
- { // show matches
- $text .= " *";
- }
-
- $text .= "";
- $prev[$disp] = $row[$disp];
- }
-// -------------------------------------------------------------
+ // -------------------------------------------------------------
$qry = (e_QUERY) ? "?".e_QUERY : "";
$text .= "