From a7d186fd9127db566ec2ad0a66aaeabe2d569004 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Sat, 26 Oct 2002 12:34:39 +0000 Subject: Preliminary 'freeze' on permissions system awaiting developer feedback, testing, etc. Caching of non-dynmaic config and acl option elements. git-svn-id: file:///svn/phpbb/trunk@2969 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 112 +++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 74 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 06e901842d..9aa3cd8800 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -19,55 +19,6 @@ * ***************************************************************************/ -function get_db_stat($mode) -{ - global $db; - - switch( $mode ) - { - case 'usercount': - $sql = "SELECT COUNT(user_id) - 1 AS total - FROM " . USERS_TABLE; - break; - - case 'newestuser': - $sql = "SELECT user_id, username - FROM " . USERS_TABLE . " - WHERE user_id <> " . ANONYMOUS . " - ORDER BY user_id DESC - LIMIT 1"; - break; - - case 'postcount': - case 'topiccount': - $sql = "SELECT SUM(forum_topics) AS topic_total, SUM(forum_posts) AS post_total - FROM " . FORUMS_TABLE; - break; - } - - $result = $db->sql_query($sql); - - $row = $db->sql_fetchrow($result); - - switch ( $mode ) - { - case 'usercount': - return $row['total']; - break; - case 'newestuser': - return $row; - break; - case 'postcount': - return $row['post_total']; - break; - case 'topiccount': - return $row['topic_total']; - break; - } - - return false; -} - function sql_quote($msg) { return str_replace("'", "''", $msg); @@ -126,18 +77,22 @@ function get_forum_branch($forum_id, $type='all', $order='descending', $include_ // Obtain list of moderators of each forum // First users, then groups ... broken into two queries +// We could cache this ... certainly into a DB table. Would +// better allow the admin to decide which moderators are +// displayed(?) function get_moderators(&$forum_moderators, $forum_id = false) { - global $SID, $db, $phpEx; + global $SID, $db, $acl_options, $phpEx; - $forum_sql = ( $forum_id ) ? 'AND au.forum_id = ' . $forum_id : ''; + $forum_sql = ( $forum_id ) ? 'AND m.forum_id = ' . $forum_id : ''; $sql = "SELECT au.forum_id, u.user_id, u.username - FROM " . ACL_USERS_TABLE . " au, " . ACL_OPTIONS_TABLE . " ao, " . USERS_TABLE . " u - WHERE ao.auth_value = 'm_global' - $forum_sql - AND au.auth_option_id = ao.auth_option_id - AND u.user_id = au.user_id"; + FROM " . ACL_OPTIONS_TABLE . " o, " . ACL_USERS_TABLE . " au, " . USERS_TABLE . " u + WHERE au.auth_option_id = o.auth_option_id + AND au.user_id = u.user_id + AND o.auth_value = 'm_' + AND au.auth_allow_deny = 1 + $forum_sql"; $result = $db->sql_query($sql); while ( $row = $db->sql_fetchrow($result) ) @@ -145,12 +100,14 @@ function get_moderators(&$forum_moderators, $forum_id = false) $forum_moderators[$row['forum_id']][] = '' . $row['username'] . ''; } - $sql = "SELECT au.forum_id, g.group_id, g.group_name - FROM " . ACL_GROUPS_TABLE . " au, " . ACL_OPTIONS_TABLE . " ao, " . GROUPS_TABLE . " g - WHERE ao.auth_value = 'm_global' - $forum_sql - AND au.auth_option_id = ao.auth_option_id - AND g.group_id = au.group_id"; + $sql = "SELECT ag.forum_id, g.group_name, g.group_id + FROM " . ACL_OPTIONS_TABLE . " o, " . ACL_GROUPS_TABLE . " ag, " . GROUPS_TABLE . " g + WHERE ag.auth_option_id = o.auth_option_id + AND ag.group_id = g.group_id + AND o.auth_value = 'm_' + AND ag.auth_allow_deny = 1 + AND g.group_type <> " . GROUP_HIDDEN . " + $forum_sql"; $result = $db->sql_query($sql); while ( $row = $db->sql_fetchrow($result) ) @@ -611,8 +568,10 @@ function message_die($msg_code, $msg_text = '', $msg_title = '') case ERROR: $db->sql_close(); - echo 'phpBB 2 :: General Error' . "\n"; - echo '

phpBB2 :: General Error


' . $msg_text . '


Contact the site administrator to report this failure

'; + echo '' . $msg_title . '
» ' . $msg_title . '   

' . $msg_text . '

'; break; } @@ -628,9 +587,17 @@ function msg_handler($errno, $msg_text, $errfile, $errline) switch ( $errno ) { case E_WARNING: +// if (defined('DEBUG')) +// { +// echo "PHP Warning on line $errline in $errfile :: $msg_text"; +// } break; case E_NOTICE: +// if (defined('DEBUG_EXTRA')) +// { +// echo "PHP Notice on line $errline in $errfile :: $msg_text"; +// } break; case E_USER_ERROR: @@ -639,8 +606,12 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $db->sql_close(); } - echo '' . $msg_title . '' . "\n"; - echo '
' . $msg_title . '
' . $msg_text . '
'; + echo '' . $msg_title . ''; + echo '
phpBB LogoGeneral Error      


' . $msg_text . '
Please notify the board administrator or webmaster : ' . $board_config['board_email'] . '

'; + exit; break; @@ -649,14 +620,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) if ( !defined('HEADER_INC') ) { - if ( empty($user->data) ) - { - echo '' . $user->lang['Information'] . '' . "\n"; - echo '
' . $user->lang['Information'] . '
' . $msg_text . '
'; - $db->sql_close(); - exit; - } - else if ( defined('IN_ADMIN') ) + if ( defined('IN_ADMIN') ) { page_header('', '', false); } -- cgit v1.2.1