mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Cache moderator names? Output moderators for all forums in viewforum. Alter a few things in templates
git-svn-id: file:///svn/phpbb/trunk@3061 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -105,44 +105,11 @@ function get_moderators(&$forum_moderators, $forum_id = false)
|
||||
$forum_moderators[$row['forum_id']][] = (!empty($row['user_id'])) ? '<a href="profile.' . $phpEx . $SID . '&mode=viewprofile&u=' . $row['user_id'] . '">' . $row['username'] . '</a>' : '<a href="groupcp.' . $phpEx . $SID . '&g=' . $row['group_id'] . '">' . $row['groupname'] . '</a>';
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
/*
|
||||
$sql = "SELECT a.forum_id, u.user_id, u.username
|
||||
FROM " . ACL_OPTIONS_TABLE . " o, " . ACL_USERS_TABLE . " a, " . USERS_TABLE . " u
|
||||
WHERE a.auth_option_id = o.auth_option_id
|
||||
AND a.user_id = u.user_id
|
||||
AND o.auth_value = 'm_'
|
||||
AND a.auth_allow_deny = 1
|
||||
$forum_sql";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$forum_moderators[$row['forum_id']][] = '<a href="profile.' . $phpEx . $SID . '&mode=viewprofile&u=' . $row['user_id'] . '">' . $row['username'] . '</a>';
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "SELECT a.forum_id, g.group_name, g.group_id
|
||||
FROM " . ACL_OPTIONS_TABLE . " o, " . ACL_GROUPS_TABLE . " a, " . GROUPS_TABLE . " g
|
||||
WHERE a.auth_option_id = o.auth_option_id
|
||||
AND a.group_id = g.group_id
|
||||
AND o.auth_value = 'm_'
|
||||
AND a.auth_allow_deny = 1
|
||||
AND g.group_type <> " . GROUP_HIDDEN . "
|
||||
$forum_sql";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$forum_moderators[$row['forum_id']][] = '<a href="groupcp.' . $phpEx . $SID . '&g=' . $row['group_id'] . '">' . $row['group_name'] . '</a>';
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// User authorisation levels output
|
||||
//
|
||||
function get_forum_rules($mode, &$rules, &$forum_id)
|
||||
{
|
||||
global $SID, $auth, $user;
|
||||
|
@@ -454,6 +454,110 @@ function config_cache_write($match, $data)
|
||||
return;
|
||||
}
|
||||
|
||||
// Cache moderators, called whenever permissions are
|
||||
// changed via admin_permissions. Changes of username
|
||||
// and group names must be carried through for the
|
||||
// moderators table
|
||||
function cache_moderators($forum_id = false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (!empty($forum_id) && is_array($forum_id))
|
||||
{
|
||||
$forum_sql = 'AND forum_id IN (' . implode(', ', $forum_id) . ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_sql = ($forum_id) ? 'AND forum_id = ' . $forum_id : '';
|
||||
}
|
||||
|
||||
// Clear table
|
||||
$db->sql_query('TRUNCATE ' . MODERATOR_TABLE);
|
||||
|
||||
// Holding array
|
||||
$m_sql = array();
|
||||
$user_id_sql = '';
|
||||
|
||||
$sql = "SELECT a.forum_id, u.user_id, u.username
|
||||
FROM " . ACL_OPTIONS_TABLE . " o, " . ACL_USERS_TABLE . " a, " . USERS_TABLE . " u
|
||||
WHERE o.auth_value = 'm_'
|
||||
AND a.auth_option_id = o.auth_option_id
|
||||
AND a.auth_allow_deny = 1
|
||||
AND u.user_id = a.user_id
|
||||
$forum_sql";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$m_sql['f_' . $row['forum_id'] . '_u_' . $row['user_id']] = $row['forum_id'] . ', ' . $row['user_id'] . ', \'' . $row['username'] . '\', NULL, NULL';
|
||||
$user_id_sql .= (($user_id_sql) ? ', ' : '') . $row['user_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Remove users who have group memberships with DENY moderator permissions
|
||||
if ($user_id_sql)
|
||||
{
|
||||
$sql = "SELECT a.forum_id, ug.user_id
|
||||
FROM " . ACL_OPTIONS_TABLE . " o, " . ACL_GROUPS_TABLE . " a, " . USER_GROUP_TABLE . " ug
|
||||
WHERE o.auth_value = 'm_'
|
||||
AND a.auth_option_id = o.auth_option_id
|
||||
AND a.auth_allow_deny = 0
|
||||
AND a.group_id = ug.group_id
|
||||
AND ug.user_id IN ($user_id_sql)
|
||||
$forum_sql";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
unset($m_sql['f_' . $row['forum_id'] . '_u_' . $row['user_id']]);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$sql = "SELECT a.forum_id, g.group_name, g.group_id
|
||||
FROM " . ACL_OPTIONS_TABLE . " o, " . ACL_GROUPS_TABLE . " a, " . GROUPS_TABLE . " g
|
||||
WHERE o.auth_value = 'm_'
|
||||
AND a.auth_option_id = o.auth_option_id
|
||||
AND a.auth_allow_deny = 1
|
||||
AND g.group_id = a.group_id
|
||||
AND g.group_type NOT IN (" . GROUP_HIDDEN . ", " . GROUP_SPECIAL . ")
|
||||
$forum_sql";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$m_sql['f_' . $row['forum_id'] . '_g_' . $row['group_id']] = $row['forum_id'] . ', NULL, NULL, ' . $row['group_id'] . ', \'' . $row['group_name'] . '\'';
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (sizeof($m_sql))
|
||||
{
|
||||
switch (SQL_LAYER)
|
||||
{
|
||||
case 'mysql':
|
||||
case 'mysql4':
|
||||
$sql = 'INSERT INTO ' . MODERATOR_TABLE . ' (forum_id, user_id, username, group_id, groupname) VALUES ' . implode(', ', preg_replace('#^(.*)$#', '(\1)', $m_sql));
|
||||
$result = $db->sql_query($sql);
|
||||
$db->sql_freeresult($result);
|
||||
break;
|
||||
|
||||
case 'mssql':
|
||||
$sql = 'INSERT INTO ' . MODERATOR_TABLE . ' (forum_id, user_id, username, group_id, groupname)
|
||||
VALUES ' . implode(' UNION ALL ', preg_replace('#^(.*)$#', 'SELECT \1', $m_sql));
|
||||
$result = $db->sql_query($sql);
|
||||
$db->sql_freeresult($result);
|
||||
break;
|
||||
|
||||
default:
|
||||
foreach ($m_sql as $k => $sql)
|
||||
{
|
||||
$result = $db->sql_query('INSERT INTO ' . MODERATOR_TABLE . " (forum_id, user_id, username, group_id, groupname) VALUES ($sql)");
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Extension of auth class for changing permissions
|
||||
class auth_admin extends auth
|
||||
{
|
||||
|
@@ -21,7 +21,7 @@
|
||||
|
||||
function display_forums($root_data=array(), $display_moderators=TRUE)
|
||||
{
|
||||
global $db, $template, $auth, $user, $phpEx, $SID;
|
||||
global $db, $template, $auth, $user, $phpEx, $SID, $forum_moderators;
|
||||
|
||||
$where_sql = ($root_data['forum_id']) ? ' WHERE left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'] : '';
|
||||
|
||||
@@ -29,7 +29,8 @@ function display_forums($root_data=array(), $display_moderators=TRUE)
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$branch_root_id = $root_data['forum_id'];
|
||||
$forum_rows = $subforums = $forum_ids = $forum_moderators = array();
|
||||
$forum_rows = $subforums = $forum_moderators = array();
|
||||
$forum_ids = array($root_data['forum_id']);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
@@ -60,26 +61,19 @@ function display_forums($root_data=array(), $display_moderators=TRUE)
|
||||
// Direct child
|
||||
$forum_rows[] = $row;
|
||||
$parent_id = $row['forum_id'];
|
||||
$forum_ids[] = $row['forum_id'];
|
||||
|
||||
if (!$row['forum_postable'])
|
||||
{
|
||||
$branch_root_id = $row['forum_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_ids[] = $row['forum_id'];
|
||||
}
|
||||
}
|
||||
elseif ($row['parent_id'] == $branch_root_id)
|
||||
{
|
||||
// Forum directly under a category
|
||||
$forum_rows[] = $row;
|
||||
$parent_id = $row['forum_id'];
|
||||
|
||||
if ($row['forum_postable'])
|
||||
{
|
||||
$forum_ids[] = $row['forum_id'];
|
||||
}
|
||||
$forum_ids[] = $row['forum_id'];
|
||||
}
|
||||
elseif ($row['forum_postable'])
|
||||
{
|
||||
|
@@ -21,7 +21,7 @@
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
if ( !defined('IN_PHPBB') )
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
die('Hacking attempt');
|
||||
exit;
|
||||
@@ -78,7 +78,7 @@ if ($mode == 'register' && !isset($_POST['agreed']) && !isset($_GET['agreed']) &
|
||||
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
||||
}
|
||||
|
||||
$coppa = ( empty($_POST['coppa']) && empty($_GET['coppa']) ) ? 0 : TRUE;
|
||||
$coppa = (empty($_POST['coppa']) && empty($_GET['coppa'])) ? 0 : TRUE;
|
||||
|
||||
//
|
||||
// Check and initialize some variables if needed
|
||||
@@ -95,7 +95,7 @@ if (isset($_POST['submit']) || $mode == 'register')
|
||||
|
||||
foreach ($strip_var_list as $var => $param)
|
||||
{
|
||||
if ( !empty($_POST[$param]) )
|
||||
if (!empty($_POST[$param]))
|
||||
{
|
||||
$$var = trim(strip_tags($_POST[$param]));
|
||||
}
|
||||
@@ -105,7 +105,7 @@ if (isset($_POST['submit']) || $mode == 'register')
|
||||
|
||||
foreach ($strip_var_list as $var => $param)
|
||||
{
|
||||
if ( !empty($_POST[$param]) )
|
||||
if (!empty($_POST[$param]))
|
||||
{
|
||||
$$var = trim($_POST[$param]);
|
||||
}
|
||||
@@ -119,34 +119,34 @@ if (isset($_POST['submit']) || $mode == 'register')
|
||||
// empty strings if they fail.
|
||||
validate_optional_fields($icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature);
|
||||
|
||||
$viewemail = ( isset($_POST['viewemail']) ) ? ( ($_POST['viewemail']) ? TRUE : 0 ) : 0;
|
||||
$allowviewonline = ( isset($_POST['hideonline']) ) ? ( ($_POST['hideonline']) ? 0 : TRUE ) : TRUE;
|
||||
$notifyreply = ( isset($_POST['notifyreply']) ) ? ( ($_POST['notifyreply']) ? TRUE : 0 ) : 0;
|
||||
$notifypm = ( isset($_POST['notifypm']) ) ? ( ($_POST['notifypm']) ? TRUE : 0 ) : TRUE;
|
||||
$popuppm = ( isset($_POST['popup_pm']) ) ? ( ($_POST['popup_pm']) ? TRUE : 0 ) : TRUE;
|
||||
$viewemail = (isset($_POST['viewemail'])) ? (($_POST['viewemail']) ? TRUE : 0) : 0;
|
||||
$allowviewonline = (isset($_POST['hideonline'])) ? (($_POST['hideonline']) ? 0 : TRUE) : TRUE;
|
||||
$notifyreply = (isset($_POST['notifyreply'])) ? (($_POST['notifyreply']) ? TRUE : 0) : 0;
|
||||
$notifypm = (isset($_POST['notifypm'])) ? (($_POST['notifypm']) ? TRUE : 0) : TRUE;
|
||||
$popuppm = (isset($_POST['popup_pm'])) ? (($_POST['popup_pm']) ? TRUE : 0) : TRUE;
|
||||
|
||||
if ( $mode == 'register' )
|
||||
if ($mode == 'register')
|
||||
{
|
||||
$attachsig = ( isset($_POST['attachsig']) ) ? ( ($_POST['attachsig']) ? TRUE : 0 ) : $config['allow_sig'];
|
||||
$attachsig = (isset($_POST['attachsig'])) ? (($_POST['attachsig']) ? TRUE : 0) : $config['allow_sig'];
|
||||
|
||||
$allowhtml = ( isset($_POST['allowhtml']) ) ? ( ($_POST['allowhtml']) ? TRUE : 0 ) : $config['allow_html'];
|
||||
$allowbbcode = ( isset($_POST['allowbbcode']) ) ? ( ($_POST['allowbbcode']) ? TRUE : 0 ) : $config['allow_bbcode'];
|
||||
$allowsmilies = ( isset($_POST['allowsmilies']) ) ? ( ($_POST['allowsmilies']) ? TRUE : 0 ) : $config['allow_smilies'];
|
||||
$allowhtml = (isset($_POST['allowhtml'])) ? (($_POST['allowhtml']) ? TRUE : 0) : $config['allow_html'];
|
||||
$allowbbcode = (isset($_POST['allowbbcode'])) ? (($_POST['allowbbcode']) ? TRUE : 0) : $config['allow_bbcode'];
|
||||
$allowsmilies = (isset($_POST['allowsmilies'])) ? (($_POST['allowsmilies']) ? TRUE : 0) : $config['allow_smilies'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$attachsig = ( isset($_POST['attachsig']) ) ? ( ($_POST['attachsig']) ? TRUE : 0 ) : 0;
|
||||
$attachsig = (isset($_POST['attachsig'])) ? (($_POST['attachsig']) ? TRUE : 0) : 0;
|
||||
|
||||
$allowhtml = ( isset($_POST['allowhtml']) ) ? ( ($_POST['allowhtml']) ? TRUE : 0 ) : $user->data['user_allowhtml'];
|
||||
$allowbbcode = ( isset($_POST['allowbbcode']) ) ? ( ($_POST['allowbbcode']) ? TRUE : 0 ) : $user->data['user_allowbbcode'];
|
||||
$allowsmilies = ( isset($_POST['allowsmilies']) ) ? ( ($_POST['allowsmilies']) ? TRUE : 0 ) : $user->data['user_allowsmiles'];
|
||||
$allowhtml = (isset($_POST['allowhtml'])) ? (($_POST['allowhtml']) ? TRUE : 0) : $user->data['user_allowhtml'];
|
||||
$allowbbcode = (isset($_POST['allowbbcode'])) ? (($_POST['allowbbcode']) ? TRUE : 0) : $user->data['user_allowbbcode'];
|
||||
$allowsmilies = (isset($_POST['allowsmilies'])) ? (($_POST['allowsmilies']) ? TRUE : 0) : $user->data['user_allowsmiles'];
|
||||
}
|
||||
|
||||
$user_style = ( isset($_POST['style']) ) ? intval($_POST['style']) : $config['default_style'];
|
||||
$user_style = (isset($_POST['style'])) ? intval($_POST['style']) : $config['default_style'];
|
||||
|
||||
if ( !empty($_POST['language']) )
|
||||
if (!empty($_POST['language']))
|
||||
{
|
||||
if ( preg_match('/^[a-z_]+$/i', $_POST['language']) )
|
||||
if (preg_match('/^[a-z_]+$/i', $_POST['language']))
|
||||
{
|
||||
$user_lang = $_POST['language'];
|
||||
}
|
||||
@@ -161,8 +161,8 @@ if (isset($_POST['submit']) || $mode == 'register')
|
||||
$user_lang = $config['default_lang'];
|
||||
}
|
||||
|
||||
$user_timezone = ( isset($_POST['timezone']) ) ? doubleval($_POST['timezone']) : $config['board_timezone'];
|
||||
$user_dateformat = ( !empty($_POST['dateformat']) ) ? trim($_POST['dateformat']) : $config['default_dateformat'];
|
||||
$user_timezone = (isset($_POST['timezone'])) ? doubleval($_POST['timezone']) : $config['board_timezone'];
|
||||
$user_dateformat = (!empty($_POST['dateformat'])) ? trim($_POST['dateformat']) : $config['default_dateformat'];
|
||||
|
||||
}
|
||||
|
||||
@@ -172,40 +172,40 @@ if (isset($_POST['submit']) || $mode == 'register')
|
||||
if (isset($_POST['submit']))
|
||||
{
|
||||
$passwd_sql = '';
|
||||
if ( $mode == 'editprofile' )
|
||||
if ($mode == 'editprofile')
|
||||
{
|
||||
if ( $user_id != $user->data['user_id'] )
|
||||
if ($user_id != $user->data['user_id'])
|
||||
{
|
||||
$error = TRUE;
|
||||
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $user->lang['Wrong_Profile'];
|
||||
$error_msg .= ((isset($error_msg)) ? '<br />' : '') . $user->lang['Wrong_Profile'];
|
||||
}
|
||||
}
|
||||
else if ( $mode == 'register' )
|
||||
else if ($mode == 'register')
|
||||
{
|
||||
if ( empty($username) || empty($password) || empty($password_confirm) || empty($email) )
|
||||
if (empty($username) || empty($password) || empty($password_confirm) || empty($email))
|
||||
{
|
||||
$error = TRUE;
|
||||
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $user->lang['Fields_empty'];
|
||||
$error_msg .= ((isset($error_msg)) ? '<br />' : '') . $user->lang['Fields_empty'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$passwd_sql = '';
|
||||
if ( !empty($password) && !empty($password_confirm) )
|
||||
if (!empty($password) && !empty($password_confirm))
|
||||
{
|
||||
if ( $password != $password_confirm )
|
||||
if ($password != $password_confirm)
|
||||
{
|
||||
$error = TRUE;
|
||||
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $user->lang['Password_mismatch'];
|
||||
$error_msg .= ((isset($error_msg)) ? '<br />' : '') . $user->lang['Password_mismatch'];
|
||||
}
|
||||
else if ( strlen($password) > 32 )
|
||||
else if (strlen($password) > 32)
|
||||
{
|
||||
$error = TRUE;
|
||||
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $user->lang['Password_long'];
|
||||
$error_msg .= ((isset($error_msg)) ? '<br />' : '') . $user->lang['Password_long'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $mode == 'editprofile' )
|
||||
if ($mode == 'editprofile')
|
||||
{
|
||||
$sql = "SELECT user_password
|
||||
FROM " . USERS_TABLE . "
|
||||
@@ -214,24 +214,24 @@ if (isset($_POST['submit']))
|
||||
|
||||
$row = $db->sql_fetchrow($result);
|
||||
|
||||
if ( $row['user_password'] != md5($password_current) )
|
||||
if ($row['user_password'] != md5($password_current))
|
||||
{
|
||||
$error = TRUE;
|
||||
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $user->lang['Current_password_mismatch'];
|
||||
$error_msg .= ((isset($error_msg)) ? '<br />' : '') . $user->lang['Current_password_mismatch'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$error )
|
||||
if (!$error)
|
||||
{
|
||||
$password = md5($password);
|
||||
$passwd_sql = "user_password = '$password', ";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( ( empty($password) && !empty($password_confirm) ) || ( !empty($password) && empty($password_confirm) ) )
|
||||
else if ((empty($password) && !empty($password_confirm)) || (!empty($password) && empty($password_confirm)))
|
||||
{
|
||||
$error = TRUE;
|
||||
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $user->lang['Password_mismatch'];
|
||||
$error_msg .= ((isset($error_msg)) ? '<br />' : '') . $user->lang['Password_mismatch'];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -241,17 +241,17 @@ if (isset($_POST['submit']))
|
||||
//
|
||||
// Do a ban check on this email address
|
||||
//
|
||||
if ( $email != $user->data['user_email'] || $mode == 'register' )
|
||||
if ($email != $user->data['user_email'] || $mode == 'register')
|
||||
{
|
||||
if (($result = validate_email($email)) != false)
|
||||
{
|
||||
$email = $user->data['user_email'];
|
||||
|
||||
$error = TRUE;
|
||||
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $result;
|
||||
$error_msg .= ((isset($error_msg)) ? '<br />' : '') . $result;
|
||||
}
|
||||
|
||||
if ( $mode == 'editprofile' )
|
||||
if ($mode == 'editprofile')
|
||||
{
|
||||
$sql = "SELECT user_password
|
||||
FROM " . USERS_TABLE . "
|
||||
@@ -260,30 +260,30 @@ if (isset($_POST['submit']))
|
||||
|
||||
$row = $db->sql_fetchrow($result);
|
||||
|
||||
if ( $row['user_password'] != md5($password_current) )
|
||||
if ($row['user_password'] != md5($password_current))
|
||||
{
|
||||
$email = $user->data['user_email'];
|
||||
|
||||
$error = TRUE;
|
||||
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $user->lang['Current_password_mismatch'];
|
||||
$error_msg .= ((isset($error_msg)) ? '<br />' : '') . $user->lang['Current_password_mismatch'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$username_sql = '';
|
||||
if ( $config['allow_namechange'] || $mode == 'register' )
|
||||
if ($config['allow_namechange'] || $mode == 'register')
|
||||
{
|
||||
if ( empty($username) )
|
||||
if (empty($username))
|
||||
{
|
||||
$error = TRUE;
|
||||
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $user->lang['Username_disallowed'];
|
||||
$error_msg .= ((isset($error_msg)) ? '<br />' : '') . $user->lang['Username_disallowed'];
|
||||
}
|
||||
else if ( $username != $user->data['username'] || $mode == 'register' )
|
||||
else if ($username != $user->data['username'] || $mode == 'register')
|
||||
{
|
||||
if (($result = validate_username($username)) != false)
|
||||
{
|
||||
$error = TRUE;
|
||||
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $result;
|
||||
$error_msg .= ((isset($error_msg)) ? '<br />' : '') . $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -299,33 +299,33 @@ if (isset($_POST['submit']))
|
||||
}
|
||||
}
|
||||
|
||||
if ( $signature != '' )
|
||||
if ($signature != '')
|
||||
{
|
||||
if ( strlen($signature) > $config['max_sig_chars'] )
|
||||
if (strlen($signature) > $config['max_sig_chars'])
|
||||
{
|
||||
$error = TRUE;
|
||||
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $user->lang['Signature_too_long'];
|
||||
$error_msg .= ((isset($error_msg)) ? '<br />' : '') . $user->lang['Signature_too_long'];
|
||||
}
|
||||
|
||||
if ( $signature_bbcode_uid == '' )
|
||||
if ($signature_bbcode_uid == '')
|
||||
{
|
||||
// $signature_bbcode_uid = ( $allowbbcode ) ? make_bbcode_uid() : '';
|
||||
// $signature_bbcode_uid = ($allowbbcode) ? make_bbcode_uid() : '';
|
||||
}
|
||||
// $signature = prepare_message($signature, $allowhtml, $allowbbcode, $allowsmilies, $signature_bbcode_uid);
|
||||
}
|
||||
|
||||
if ( !$error )
|
||||
if (!$error)
|
||||
{
|
||||
if ( ( ( $mode == 'editprofile' && $auth->acl_get('a_') && $email != $current_email ) || ( $mode == 'register' || $coppa ) ) && ( $config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN ) )
|
||||
if ((($mode == 'editprofile' && $auth->acl_get('a_') && $email != $current_email) || ($mode == 'register' || $coppa)) && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN))
|
||||
{
|
||||
$user_actkey = gen_rand_string(true);
|
||||
$key_len = 54 - (strlen($server_url));
|
||||
$key_len = ( $key_len > 6 ) ? $key_len : 6;
|
||||
$key_len = ($key_len > 6) ? $key_len : 6;
|
||||
|
||||
$user_actkey = substr($user_actkey, 0, $key_len);
|
||||
$user_active = 0;
|
||||
|
||||
if ( $user->data['user_id'] != ANONYMOUS )
|
||||
if ($user->data['user_id'] != ANONYMOUS)
|
||||
{
|
||||
$user->destroy();
|
||||
}
|
||||
@@ -378,12 +378,18 @@ if (isset($_POST['submit']))
|
||||
if ($config['newest_user_id'] == $user_id)
|
||||
{
|
||||
$sql = 'UPDATE ' . CONFIG_TABLE . "
|
||||
SET config_value = '" . sql_quote($username) . "'
|
||||
WHERE config_name = 'newest_username'";
|
||||
SET config_value = '" . sql_quote($username) . "'
|
||||
WHERE config_name = 'newest_username'";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
if ( !$user_active )
|
||||
// Update moderator cache table as appropriate
|
||||
$sql = 'UPDATE ' . CONFIG_TABLE . "
|
||||
SET username = '" . sql_quote($username) . "'
|
||||
WHERE user_id = $user_id";
|
||||
$db->sql_query($sql);
|
||||
|
||||
if (!$user_active)
|
||||
{
|
||||
//
|
||||
// The users account has been deactivated, send them an email with a new activation key
|
||||
@@ -429,7 +435,7 @@ if (isset($_POST['submit']))
|
||||
$user_id = $db->sql_nextid();
|
||||
|
||||
// Place into appropriate group, either REGISTERED or INACTIVE depending on config
|
||||
$group_name = ( $config['require_activation'] == USER_ACTIVATION_NONE ) ? 'REGISTERED' : 'INACTIVE';
|
||||
$group_name = ($config['require_activation'] == USER_ACTIVATION_NONE) ? 'REGISTERED' : 'INACTIVE';
|
||||
$sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending) SELECT $user_id, group_id, 0 FROM " . GROUPS_TABLE . " WHERE group_name = '$group_name'";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
@@ -452,17 +458,17 @@ if (isset($_POST['submit']))
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
|
||||
if ( $coppa )
|
||||
if ($coppa)
|
||||
{
|
||||
$message = $user->lang['COPPA'];
|
||||
$email_template = 'coppa_welcome_inactive';
|
||||
}
|
||||
else if ( $config['require_activation'] == USER_ACTIVATION_SELF )
|
||||
else if ($config['require_activation'] == USER_ACTIVATION_SELF)
|
||||
{
|
||||
$message = $user->lang['Account_inactive'];
|
||||
$email_template = 'user_welcome_inactive';
|
||||
}
|
||||
else if ( $config['require_activation'] == USER_ACTIVATION_ADMIN )
|
||||
else if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
|
||||
{
|
||||
$message = $user->lang['Account_inactive_admin'];
|
||||
$email_template = 'admin_welcome_inactive';
|
||||
@@ -523,7 +529,7 @@ if (isset($_POST['submit']))
|
||||
$emailer->send();
|
||||
$emailer->reset();
|
||||
|
||||
if ( $config['require_activation'] == USER_ACTIVATION_ADMIN )
|
||||
if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
|
||||
{
|
||||
$emailer->use_template("admin_activate", stripslashes($user_lang));
|
||||
$emailer->email_address($config['board_email']);
|
||||
@@ -548,7 +554,7 @@ if (isset($_POST['submit']))
|
||||
} // End of submit
|
||||
|
||||
|
||||
if ( $error )
|
||||
if ($error)
|
||||
{
|
||||
//
|
||||
// If an error occured we need to stripslashes on returned data
|
||||
@@ -572,7 +578,7 @@ if ( $error )
|
||||
$user_lang = stripslashes($user_lang);
|
||||
$user_dateformat = stripslashes($user_dateformat);
|
||||
}
|
||||
else if ( $mode == 'editprofile' )
|
||||
else if ($mode == 'editprofile')
|
||||
{
|
||||
$user_id = $user->data['user_id'];
|
||||
$username = htmlspecialchars($user->data['username']);
|
||||
@@ -590,7 +596,7 @@ else if ( $mode == 'editprofile' )
|
||||
$occupation = htmlspecialchars($user->data['user_occ']);
|
||||
$interests = htmlspecialchars($user->data['user_interests']);
|
||||
$signature_bbcode_uid = $user->data['user_sig_bbcode_uid'];
|
||||
$signature = ( $signature_bbcode_uid != '' ) ? preg_replace("/\:(([a-z0-9]:)?)$signature_bbcode_uid/si", '', $user->data['user_sig']) : $user->data['user_sig'];
|
||||
$signature = ($signature_bbcode_uid != '') ? preg_replace("/\:(([a-z0-9]:)?)$signature_bbcode_uid/si", '', $user->data['user_sig']) : $user->data['user_sig'];
|
||||
|
||||
$viewemail = $user->data['user_viewemail'];
|
||||
$notifypm = $user->data['user_notify_pm'];
|
||||
@@ -612,9 +618,9 @@ else if ( $mode == 'editprofile' )
|
||||
// Default pages
|
||||
//
|
||||
|
||||
if ( $mode == 'editprofile' )
|
||||
if ($mode == 'editprofile')
|
||||
{
|
||||
if ( $user_id != $user->data['user_id'] )
|
||||
if ($user_id != $user->data['user_id'])
|
||||
{
|
||||
$error = TRUE;
|
||||
$error_msg = $user->lang['Wrong_Profile'];
|
||||
@@ -622,12 +628,12 @@ if ( $mode == 'editprofile' )
|
||||
}
|
||||
|
||||
|
||||
if ( !isset($coppa) )
|
||||
if (!isset($coppa))
|
||||
{
|
||||
$coppa = FALSE;
|
||||
}
|
||||
|
||||
if ( !isset($user_template) )
|
||||
if (!isset($user_template))
|
||||
{
|
||||
$selected_template = $config['system_template'];
|
||||
}
|
||||
@@ -635,7 +641,7 @@ if ( $mode == 'editprofile' )
|
||||
$signature = preg_replace('/\:[0-9a-z\:]*?\]/si', ']', $signature);
|
||||
|
||||
$s_hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="agreed" value="true" /><input type="hidden" name="coppa" value="' . $coppa . '" />';
|
||||
if( $mode == 'editprofile' )
|
||||
if($mode == 'editprofile')
|
||||
{
|
||||
$s_hidden_fields .= '<input type="hidden" name="user_id" value="' . $user->data['user_id'] . '" />';
|
||||
//
|
||||
@@ -645,14 +651,14 @@ if ( $mode == 'editprofile' )
|
||||
$s_hidden_fields .= '<input type="hidden" name="current_email" value="' . $user->data['user_email'] . '" />';
|
||||
}
|
||||
|
||||
if ( !empty($user_avatar_local) )
|
||||
if (!empty($user_avatar_local))
|
||||
{
|
||||
$s_hidden_fields .= '<input type="hidden" name="avatarlocal" value="' . $user_avatar_local . '" />';
|
||||
}
|
||||
|
||||
$html_status = ( $user->data['user_allowhtml'] && $config['allow_html'] ) ? $user->lang['HTML_is_ON'] : $user->lang['HTML_is_OFF'];
|
||||
$bbcode_status = ( $user->data['user_allowbbcode'] && $config['allow_bbcode'] ) ? $user->lang['BBCode_is_ON'] : $user->lang['BBCode_is_OFF'];
|
||||
$smilies_status = ( $user->data['user_allowsmile'] && $config['allow_smilies'] ) ? $user->lang['Smilies_are_ON'] : $user->lang['Smilies_are_OFF'];
|
||||
$html_status = ($user->data['user_allowhtml'] && $config['allow_html']) ? $user->lang['HTML_is_ON'] : $user->lang['HTML_is_OFF'];
|
||||
$bbcode_status = ($user->data['user_allowbbcode'] && $config['allow_bbcode'] ) ? $user->lang['BBCode_is_ON'] : $user->lang['BBCode_is_OFF'];
|
||||
$smilies_status = ($user->data['user_allowsmile'] && $config['allow_smilies'] ) ? $user->lang['Smilies_are_ON'] : $user->lang['Smilies_are_OFF'];
|
||||
|
||||
//
|
||||
// Let's do an overall check for settings/versions which would prevent
|
||||
@@ -672,24 +678,24 @@ if ( $mode == 'editprofile' )
|
||||
'LOCATION' => $location,
|
||||
'WEBSITE' => $website,
|
||||
'SIGNATURE' => str_replace('<br />', "\n", $signature),
|
||||
'VIEW_EMAIL_YES' => ( $viewemail ) ? 'checked="checked"' : '',
|
||||
'VIEW_EMAIL_NO' => ( !$viewemail ) ? 'checked="checked"' : '',
|
||||
'HIDE_USER_YES' => ( !$allowviewonline ) ? 'checked="checked"' : '',
|
||||
'HIDE_USER_NO' => ( $allowviewonline ) ? 'checked="checked"' : '',
|
||||
'NOTIFY_PM_YES' => ( $notifypm ) ? 'checked="checked"' : '',
|
||||
'NOTIFY_PM_NO' => ( !$notifypm ) ? 'checked="checked"' : '',
|
||||
'POPUP_PM_YES' => ( $popuppm ) ? 'checked="checked"' : '',
|
||||
'POPUP_PM_NO' => ( !$popuppm ) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ADD_SIGNATURE_YES' => ( $attachsig ) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ADD_SIGNATURE_NO' => ( !$attachsig ) ? 'checked="checked"' : '',
|
||||
'NOTIFY_REPLY_YES' => ( $notifyreply ) ? 'checked="checked"' : '',
|
||||
'NOTIFY_REPLY_NO' => ( !$notifyreply ) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ALLOW_BBCODE_YES' => ( $allowbbcode ) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ALLOW_BBCODE_NO' => ( !$allowbbcode ) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ALLOW_HTML_YES' => ( $allowhtml ) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ALLOW_HTML_NO' => ( !$allowhtml ) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ALLOW_SMILIES_YES' => ( $allowsmilies ) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ALLOW_SMILIES_NO' => ( !$allowsmilies ) ? 'checked="checked"' : '',
|
||||
'VIEW_EMAIL_YES' => ($viewemail) ? 'checked="checked"' : '',
|
||||
'VIEW_EMAIL_NO' => (!$viewemail) ? 'checked="checked"' : '',
|
||||
'HIDE_USER_YES' => (!$allowviewonline) ? 'checked="checked"' : '',
|
||||
'HIDE_USER_NO' => ($allowviewonline) ? 'checked="checked"' : '',
|
||||
'NOTIFY_PM_YES' => ($notifypm) ? 'checked="checked"' : '',
|
||||
'NOTIFY_PM_NO' => (!$notifypm) ? 'checked="checked"' : '',
|
||||
'POPUP_PM_YES' => ($popuppm) ? 'checked="checked"' : '',
|
||||
'POPUP_PM_NO' => (!$popuppm) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ADD_SIGNATURE_YES' => ($attachsig) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ADD_SIGNATURE_NO' => (!$attachsig) ? 'checked="checked"' : '',
|
||||
'NOTIFY_REPLY_YES' => ($notifyreply) ? 'checked="checked"' : '',
|
||||
'NOTIFY_REPLY_NO' => (!$notifyreply) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ALLOW_BBCODE_YES' => ($allowbbcode) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ALLOW_BBCODE_NO' => (!$allowbbcode) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ALLOW_HTML_YES' => ($allowhtml) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ALLOW_HTML_NO' => (!$allowhtml) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ALLOW_SMILIES_YES' => ($allowsmilies) ? 'checked="checked"' : '',
|
||||
'ALWAYS_ALLOW_SMILIES_NO' => (!$allowsmilies) ? 'checked="checked"' : '',
|
||||
'LANGUAGE_SELECT' => language_select($user_lang, 'language'),
|
||||
'STYLE_SELECT' => style_select($user_style, 'style'),
|
||||
'TIMEZONE_SELECT' => tz_select($user_timezone, 'timezone'),
|
||||
@@ -699,11 +705,11 @@ if ( $mode == 'editprofile' )
|
||||
'SMILIES_STATUS' => $smilies_status,
|
||||
|
||||
'L_CURRENT_PASSWORD' => $user->lang['Current_password'],
|
||||
'L_NEW_PASSWORD' => ( $mode == 'register' ) ? $user->lang['Password'] : $user->lang['New_password'],
|
||||
'L_NEW_PASSWORD' => ($mode == 'register') ? $user->lang['Password'] : $user->lang['New_password'],
|
||||
'L_CONFIRM_PASSWORD' => $user->lang['Confirm_password'],
|
||||
'L_CONFIRM_PASSWORD_EXPLAIN' => ( $mode == 'editprofile' ) ? $user->lang['Confirm_password_explain'] : '',
|
||||
'L_PASSWORD_IF_CHANGED' => ( $mode == 'editprofile' ) ? $user->lang['password_if_changed'] : '',
|
||||
'L_PASSWORD_CONFIRM_IF_CHANGED' => ( $mode == 'editprofile' ) ? $user->lang['password_confirm_if_changed'] : '',
|
||||
'L_CONFIRM_PASSWORD_EXPLAIN' => ($mode == 'editprofile') ? $user->lang['Confirm_password_explain'] : '',
|
||||
'L_PASSWORD_IF_CHANGED' => ($mode == 'editprofile') ? $user->lang['password_if_changed'] : '',
|
||||
'L_PASSWORD_CONFIRM_IF_CHANGED' => ($mode == 'editprofile') ? $user->lang['password_confirm_if_changed'] : '',
|
||||
'L_SUBMIT' => $user->lang['Submit'],
|
||||
'L_RESET' => $user->lang['Reset'],
|
||||
'L_ICQ_NUMBER' => $user->lang['ICQ'],
|
||||
@@ -742,7 +748,7 @@ if ( $mode == 'editprofile' )
|
||||
'L_PROFILE_INFO_NOTICE' => $user->lang['Profile_info_warn'],
|
||||
'L_EMAIL_ADDRESS' => $user->lang['Email_address'],
|
||||
|
||||
'S_PROFILE_EDIT' => ( $mode == 'editprofile' ) ? true : false,
|
||||
'S_PROFILE_EDIT' => ($mode == 'editprofile') ? true : false,
|
||||
'S_HIDDEN_FIELDS' => $s_hidden_fields,
|
||||
'S_FORM_ENCTYPE' => $form_enctype,
|
||||
'S_PROFILE_ACTION' => "profile.$phpEx$SID")
|
||||
|
Reference in New Issue
Block a user