diff --git a/phpBB/admin/admin_permissions.php b/phpBB/admin/admin_permissions.php index 8f8763a534..73c7535e3f 100644 --- a/phpBB/admin/admin_permissions.php +++ b/phpBB/admin/admin_permissions.php @@ -104,6 +104,8 @@ if (isset($_POST['update'])) $auth_admin->acl_set($_POST['type'], $forum_id, $id, $_POST['option']); } + cache_moderators(); + trigger_error('Permissions updated successfully'); } else if (isset($_POST['delete'])) @@ -135,6 +137,8 @@ else if (isset($_POST['delete'])) $auth_admin->acl_delete($_POST['type'], $forum_id, $id, $option_ids); } + cache_moderators(); + trigger_error('Permissions updated successfully'); } diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 646014f8ff..ccff70652e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -105,44 +105,11 @@ function get_moderators(&$forum_moderators, $forum_id = false) $forum_moderators[$row['forum_id']][] = (!empty($row['user_id'])) ? '' . $row['username'] . '' : '' . $row['groupname'] . ''; } $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']][] = '' . $row['username'] . ''; - } - $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']][] = '' . $row['group_name'] . ''; - } - $db->sql_freeresult($result); -*/ return; } -// // User authorisation levels output -// function get_forum_rules($mode, &$rules, &$forum_id) { global $SID, $auth, $user; diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index b55fe6fcbd..637ebfa17a 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -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 { diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index d34db4f63c..4a1830a703 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -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']) { diff --git a/phpBB/includes/usercp_register.php b/phpBB/includes/usercp_register.php index b1c4a495e2..1d964ed4e0 100644 --- a/phpBB/includes/usercp_register.php +++ b/phpBB/includes/usercp_register.php @@ -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) ) ? '
' : '' ) . $user->lang['Wrong_Profile']; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $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) ) ? '
' : '' ) . $user->lang['Fields_empty']; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $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) ) ? '
' : '' ) . $user->lang['Password_mismatch']; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Password_mismatch']; } - else if ( strlen($password) > 32 ) + else if (strlen($password) > 32) { $error = TRUE; - $error_msg .= ( ( isset($error_msg) ) ? '
' : '' ) . $user->lang['Password_long']; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $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) ) ? '
' : '' ) . $user->lang['Current_password_mismatch']; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $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) ) ? '
' : '' ) . $user->lang['Password_mismatch']; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $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) ) ? '
' : '' ) . $result; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $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) ) ? '
' : '' ) . $user->lang['Current_password_mismatch']; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $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) ) ? '
' : '' ) . $user->lang['Username_disallowed']; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $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) ) ? '
' : '' ) . $result; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $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) ) ? '
' : '' ) . $user->lang['Signature_too_long']; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $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 = ''; - if( $mode == 'editprofile' ) + if($mode == 'editprofile') { $s_hidden_fields .= ''; // @@ -645,14 +651,14 @@ if ( $mode == 'editprofile' ) $s_hidden_fields .= ''; } - if ( !empty($user_avatar_local) ) + if (!empty($user_avatar_local)) { $s_hidden_fields .= ''; } - $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('
', "\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") diff --git a/phpBB/posting.php b/phpBB/posting.php index d0417931d0..a1cf2a130b 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -621,7 +621,7 @@ switch ($mode) break; case 'edit': - $page_title = $user->lang['Edit_Post']; + $page_title = $user->lang['EDIT_POST']; $s_action .= '&p=' . intval($post_id); break; } diff --git a/phpBB/templates/subSilver/editor.js b/phpBB/templates/subSilver/editor.js index 1ace036de3..57ea604e93 100644 --- a/phpBB/templates/subSilver/editor.js +++ b/phpBB/templates/subSilver/editor.js @@ -152,7 +152,7 @@ function storeCaret(textEl) { if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate(); } -function unixSafeColours() +function colorPalette() { var r = 0, g = 0, b = 0; var numberList = new Array(6); @@ -171,7 +171,7 @@ function unixSafeColours() { color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]); document.write(''); - document.write('#' + color + ''); + document.write('#' + color + ''); document.writeln(''); } document.writeln(''); diff --git a/phpBB/templates/subSilver/posting_body.html b/phpBB/templates/subSilver/posting_body.html index 2a9eed5cf1..688faedbb6 100644 --- a/phpBB/templates/subSilver/posting_body.html +++ b/phpBB/templates/subSilver/posting_body.html @@ -38,7 +38,7 @@ function checkForm()
- + - + @@ -83,7 +83,7 @@ function checkForm() @@ -102,7 +102,7 @@ function checkForm() - +
{FORUM_NAME} :: {TOPIC_TITLE}
[ {L_VIEW_MODERATORS} ]

{LOGGED_IN_USER_LIST}
{FORUM_NAME} :: {TOPIC_TITLE}
{L_MODERATORS}: {MODERATORS}

{LOGGED_IN_USER_LIST}
{L_DELETE_POST} [ {L_DELETE_WARN} ] [ {L_DELETE_POST_WARN} ]
{L_TOPIC_ICON} - +
{L_NONE}  {L_NONE}
{L_MORE_SMILIES}{L_MORE_EMOTICONS}
@@ -128,27 +128,25 @@ function checkForm() - {L_BBCODE_CLOSE_TAGS} - - - - - - - - +
{L_FONT_COLOR}
{L_CLOSE_TAGS}
+ {L_FONT_COLOR} + + + + +
@@ -196,13 +194,13 @@ function checkForm() - {L_ATTACH_SIGNATURE} + {L_ATTACH_SIG} - {L_NOTIFY_ON_REPLY} + {L_NOTIFY_REPLY} @@ -215,7 +213,7 @@ function checkForm() - {L_ADD_A_POLL} + {L_ADD_POLL} {L_ADD_POLL_EXPLAIN} @@ -229,8 +227,8 @@ function checkForm() - {L_POLL_LENGTH} -  {L_DAYS} {L_POLL_LENGTH_EXPLAIN} + {L_POLL_FOR} +  {L_DAYS} {L_POLL_FOR_EXPLAIN} @@ -248,7 +246,7 @@ function checkForm() - {L_FILE_NAME} + {L_FILENAME} diff --git a/phpBB/templates/subSilver/viewforum_body.html b/phpBB/templates/subSilver/viewforum_body.html index d1a5865338..11cd6b09ed 100644 --- a/phpBB/templates/subSilver/viewforum_body.html +++ b/phpBB/templates/subSilver/viewforum_body.html @@ -2,16 +2,11 @@ - - + + - - -
- +
{FORUM_NAME}
- {MOD_CP}
-
{LOGGED_IN_USER_LIST}
{PAGINATION}{FORUM_NAME}
{L_MODERATORS}: {MODERATORS}

{LOGGED_IN_USER_LIST}
{MOD_CP}

{PAGINATION}
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index b0e6b3aae9..c1095ef5f3 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -139,6 +139,26 @@ $template->assign_vars(array( 'FORUM_DESC' => strip_tags($forum_data['forum_desc']) )); +// Moderators +$forum_moderators = array(); + +// Do we have subforums? if so, let's include this harmless file +if ($forum_data['left_id'] != $forum_data['right_id'] - 1) +{ + $template->assign_vars(array( + 'S_HAS_SUBFORUM' => TRUE, + 'L_SUBFORUM' => (count($forum_rows) == 1) ? $user->lang['Subforum'] : $user->lang['Subforums'] + )); + + include($phpbb_root_path . 'includes/functions_display.' . $phpEx); + display_forums($forum_data); +} +else +{ + get_moderators($forum_moderators, $forum_id); +} + +// Output forum listing if it is postable if ($forum_data['forum_postable']) { // Topic read tracking cookie info @@ -200,9 +220,7 @@ if ($forum_data['forum_postable']) $sort_days = (!empty($_POST['sort_days'])) ? intval($_POST['sort_days']) : intval($_GET['sort_days']); $min_topic_time = time() - ( $sort_days * 86400 ); - // // ref type on as rows as topics ... also not great - // $sql = "SELECT COUNT(topic_id) AS forum_topics FROM " . TOPICS_TABLE . " WHERE forum_id = $forum_id @@ -254,7 +272,8 @@ if ($forum_data['forum_postable']) 'POST_IMG' => (intval($forum_data['forum_status']) == ITEM_LOCKED) ? $user->img('post_locked', $post_alt) : $user->img('post_new', $post_alt), 'PAGINATION' => generate_pagination("viewforum.$phpEx$SID&f=$forum_id&topicdays=$topic_days", $topics_count, $config['topics_per_page'], $start), 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], (floor( $start / $config['topics_per_page'] ) + 1), ceil( $topics_count / $config['topics_per_page'] )), - 'MOD_CP' => ($auth->acl_gets('m_', 'a_', $forum_id)) ? sprintf($user->lang['MCP'], '', '') : '', + 'MOD_CP' => ($auth->acl_gets('m_', 'a_', $forum_id)) ? sprintf($user->lang['MCP'], '', '') : '', + 'MODERATORS' => (sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : $user->lang['None'], 'FOLDER_IMG' => $user->img('folder', 'No_new_posts'), 'FOLDER_NEW_IMG' => $user->img('folder_new', 'New_posts'), @@ -529,18 +548,6 @@ $nav_links['up'] = array( 'title' => sprintf($user->lang['Forum_Index'], $config['sitename']) ); -// Do we have subforums? if so, let's include this harmless file -if ($forum_data['left_id'] != $forum_data['right_id'] - 1) -{ - $template->assign_vars(array( - 'S_HAS_SUBFORUM' => TRUE, - 'L_SUBFORUM' => (count($forum_rows) == 1) ? $user->lang['Subforum'] : $user->lang['Subforums'] - )); - - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - display_forums($forum_data); -} - include($phpbb_root_path . 'includes/page_header.'.$phpEx); $template->set_filenames(array( diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index e6122766a9..678f4ffff9 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -26,9 +26,9 @@ include($phpbb_root_path . 'common.'.$phpEx); include($phpbb_root_path . 'includes/bbcode.'.$phpEx); // Start initial var setup -$topic_id = ( isset($_GET['t']) ) ? intval($_GET['t']) : 0; -$post_id = ( isset($_GET['p'])) ? intval($_GET['p']) : 0; -$start = ( isset($_GET['start']) ) ? intval($_GET['start']) : 0; +$topic_id = (isset($_GET['t'])) ? intval($_GET['t']) : 0; +$post_id = (isset($_GET['p'])) ? intval($_GET['p']) : 0; +$start = (isset($_GET['start'])) ? intval($_GET['start']) : 0; if (empty($topic_id) && empty($post_id)) { @@ -76,8 +76,8 @@ if (isset($_GET['view']) && empty($post_id)) } else if ($_GET['view'] == 'next' || $_GET['view'] == 'previous') { - $sql_condition = ( $_GET['view'] == 'next' ) ? '>' : '<'; - $sql_ordering = ( $_GET['view'] == 'next' ) ? 'ASC' : 'DESC'; + $sql_condition = ($_GET['view'] == 'next') ? '>' : '<'; + $sql_ordering = ($_GET['view'] == 'next') ? 'ASC' : 'DESC'; $sql = "SELECT t.topic_id FROM " . TOPICS_TABLE . " t, " . TOPICS_TABLE . " t2 @@ -112,7 +112,7 @@ if ($user->data['user_id'] != ANONYMOUS) $rating = ($row = $db->sql_fetchrow($result)) ? $row['rating'] : ''; - if ( empty($_POST['rating_value']) && $rating != '') + if (empty($_POST['rating_value']) && $rating != '') { } else @@ -175,8 +175,8 @@ if (!$auth->acl_gets('f_read', 'm_', 'a_', intval($forum_id))) { if ($user->data['user_id'] == ANONYMOUS) { - $redirect = ( isset($post_id) ) ? "p=$post_id" : "t=$topic_id"; - $redirect .= ( isset($start) ) ? "&start=$start" : ''; + $redirect = (isset($post_id)) ? "p=$post_id" : "t=$topic_id"; + $redirect .= (isset($start)) ? "&start=$start" : ''; redirect('login.' . $phpEx . $SID . '&redirect=viewtopic.' . $phpEx . '&' . $redirect); } @@ -203,7 +203,7 @@ if (isset($_POST['sort'])) if (!empty($_POST['sort_days'])) { $sort_days = (!empty($_POST['sort_days'])) ? intval($_POST['sort_days']) : intval($_GET['sort_days']); - $min_post_time = time() - ( $sort_days * 86400 ); + $min_post_time = time() - ($sort_days * 86400); $sql = "SELECT COUNT(post_id) AS num_posts FROM " . POSTS_TABLE . " @@ -213,7 +213,7 @@ if (isset($_POST['sort'])) $result = $db->sql_query($sql); $start = 0; - $topic_replies = ( $row = $db->sql_fetchrow($result) ) ? $row['num_posts'] : 0; + $topic_replies = ($row = $db->sql_fetchrow($result)) ? $row['num_posts'] : 0; $limit_posts_time = "AND p.post_time >= $min_post_time "; } else @@ -368,7 +368,7 @@ $template->assign_vars(array( 'TOPIC_ID' => $topic_id, 'TOPIC_TITLE' => $topic_title, 'PAGINATION' => $pagination, - 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], ( floor( $start / $config['posts_per_page'] ) + 1 ), ceil( $topic_replies / $config['posts_per_page'] )), + 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], (floor($start / $config['posts_per_page']) + 1), ceil($topic_replies / $config['posts_per_page'])), 'MOD_CP' => ($auth->acl_gets('m_', 'a_', $forum_id)) ? sprintf($user->lang['MCP'], '', '') : '', 'POST_IMG' => $post_img, @@ -460,7 +460,7 @@ if (!empty($poll_start)) foreach ($poll_info as $poll_option) { $poll_option['poll_option_text'] = (sizeof($orig_word)) ? preg_replace($orig_word, $replacement_word, $poll_option['poll_option_text']) : $poll_option['poll_option_text']; - $option_pct = ( $poll_total > 0 ) ? $poll_option['poll_option_total'] / $poll_total : 0; + $option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0; $option_pct_txt = sprintf("%.1d%%", ($option_pct * 100)); $template->assign_block_vars('poll_option', array( @@ -548,9 +548,9 @@ if ($row = $db->sql_fetchrow($result)) } // Generate ranks, set them to empty string initially. - if (!isset($poster_details[$poster_id]['rank_title']) ) + if (!isset($poster_details[$poster_id]['rank_title'])) { - if ($row['user_rank'] ) + if ($row['user_rank']) { for($j = 0; $j < count($ranksrow); $j++) { @@ -604,8 +604,8 @@ if ($row = $db->sql_fetchrow($result)) $poster_details[$poster_id]['email'] = ''; } - $poster_details[$poster_id]['www_img'] = ( $row['user_website'] ) ? '' . $user->img('icon_www', $user->lang['Visit_website']) . '' : ''; - $poster_details[$poster_id]['www'] = ( $row['user_website'] ) ? '' . $user->lang['Visit_website'] . '' : ''; + $poster_details[$poster_id]['www_img'] = ($row['user_website']) ? '' . $user->img('icon_www', $user->lang['Visit_website']) . '' : ''; + $poster_details[$poster_id]['www'] = ($row['user_website']) ? '' . $user->lang['Visit_website'] . '' : ''; if (!empty($row['user_icq'])) { @@ -723,7 +723,7 @@ if ($row = $db->sql_fetchrow($result)) // Parse message for admin-defined/templated BBCode if reqd if ($bbcode_uid != '') { -// $message = ( $auth->acl_get('f_bbcode', $forum_id) ) ? bbencode_second_pass($message, $bbcode_uid, $auth->acl_get('f_img', $forum_id)) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); +// $message = ($auth->acl_get('f_bbcode', $forum_id)) ? bbencode_second_pass($message, $bbcode_uid, $auth->acl_get('f_img', $forum_id)) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); } // If we allow users to disable display of emoticons