diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2005-04-10 18:07:12 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2005-04-10 18:07:12 +0000 |
commit | 557d09bb72f7e9848b6fc50ed4e2ba651b89e743 (patch) | |
tree | 9db78285f2e35af8f70dfbb240712164b45bcfd2 /phpBB/includes | |
parent | c9478353171267a3ebc5d87b43d759d22684b21e (diff) | |
download | forums-557d09bb72f7e9848b6fc50ed4e2ba651b89e743.tar forums-557d09bb72f7e9848b6fc50ed4e2ba651b89e743.tar.gz forums-557d09bb72f7e9848b6fc50ed4e2ba651b89e743.tar.bz2 forums-557d09bb72f7e9848b6fc50ed4e2ba651b89e743.tar.xz forums-557d09bb72f7e9848b6fc50ed4e2ba651b89e743.zip |
- added updated coding guidelines
- introduced is_registered and is_bot flags for correct determinition of guest/registered/bot users
- changed bot code to act on useragent || ip
git-svn-id: file:///svn/phpbb/trunk@5117 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acm/acm_db.php | 5 | ||||
-rw-r--r-- | phpBB/includes/acm/acm_file.php | 2 | ||||
-rw-r--r-- | phpBB/includes/auth/auth_ldap.php | 2 | ||||
-rw-r--r-- | phpBB/includes/db/mssql-odbc.php | 2 | ||||
-rw-r--r-- | phpBB/includes/db/mysql.php | 2 | ||||
-rw-r--r-- | phpBB/includes/db/sqlite.php | 2 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 20 | ||||
-rw-r--r-- | phpBB/includes/functions_display.php | 12 | ||||
-rw-r--r-- | phpBB/includes/functions_jabber.php | 6 | ||||
-rw-r--r-- | phpBB/includes/functions_messenger.php | 10 | ||||
-rw-r--r-- | phpBB/includes/functions_posting.php | 6 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_topic.php | 2 | ||||
-rw-r--r-- | phpBB/includes/session.php | 24 | ||||
-rw-r--r-- | phpBB/includes/template.php | 2 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_main.php | 2 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm.php | 4 |
16 files changed, 62 insertions, 41 deletions
diff --git a/phpBB/includes/acm/acm_db.php b/phpBB/includes/acm/acm_db.php index 4b0cf6486c..e4d6e2b527 100644 --- a/phpBB/includes/acm/acm_db.php +++ b/phpBB/includes/acm/acm_db.php @@ -87,13 +87,14 @@ class acm } $this->var_expires = array(); - if (count($delete)) + if (sizeof($delete)) { $sql = 'DELETE FROM ' . CACHE_TABLE . " WHERE var_name IN ('" . implode("', '", $delete) . "')"; $db->sql_query($sql); } - if (count($insert)) + + if (sizeof($insert)) { switch (SQL_LAYER) { diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php index 6ab8b53668..da04c881d1 100644 --- a/phpBB/includes/acm/acm_file.php +++ b/phpBB/includes/acm/acm_file.php @@ -236,7 +236,7 @@ class acm // Remove extra spaces and tabs $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - $query_id = 'Cache id #' . count($this->sql_rowset); + $query_id = 'Cache id #' . sizeof($this->sql_rowset); if (!file_exists($this->cache_dir . 'sql_' . md5($query) . ".$phpEx")) { diff --git a/phpBB/includes/auth/auth_ldap.php b/phpBB/includes/auth/auth_ldap.php index a7c229932b..4a3293648e 100644 --- a/phpBB/includes/auth/auth_ldap.php +++ b/phpBB/includes/auth/auth_ldap.php @@ -39,7 +39,7 @@ function login_ldap(&$username, &$password) $search = @ldap_search($ldap, $config['ldap_base_dn'], $config['ldap_uid'] . '=' . $username, array($config['ldap_uid'])); $result = @ldap_get_entries($ldap, $search); - if (is_array($result) && count($result) > 1) + if (is_array($result) && sizeof($result) > 1) { if (@ldap_bind($ldap, $result[0]['dn'], $password)) { diff --git a/phpBB/includes/db/mssql-odbc.php b/phpBB/includes/db/mssql-odbc.php index a0a6125aa3..bd33bc63cb 100644 --- a/phpBB/includes/db/mssql-odbc.php +++ b/phpBB/includes/db/mssql-odbc.php @@ -558,7 +558,7 @@ class sql_db { while ($row = $this->sql_fetchrow($result)) { - if (!$html_table && count($row)) + if (!$html_table && sizeof($row)) { $html_table = TRUE; $html_hold .= '<table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center"><tr>'; diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 14778a7e66..b1aefc66ca 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -454,7 +454,7 @@ class sql_db { while ($row = mysql_fetch_assoc($result)) { - if (!$html_table && count($row)) + if (!$html_table && sizeof($row)) { $html_table = TRUE; $html_hold .= '<table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center"><tr>'; diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php index abeee3a358..f64e22eab1 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/sqlite.php @@ -148,7 +148,7 @@ class sql_db { while ($row = @sqlite_fetch_array($result, @sqlite_ASSOC)) { - if (!$html_table && count($row)) + if (!$html_table && sizeof($row)) { $html_table = TRUE; $this->sql_report .= "<table width=100% border=1 cellpadding=2 cellspacing=1>\n"; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 7eacbe91fd..848e97d935 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -110,7 +110,7 @@ function gen_rand_string($num_chars) list($usec, $sec) = explode(' ', microtime()); mt_srand($sec * $usec); - $max_chars = count($chars) - 1; + $max_chars = sizeof($chars) - 1; $rand_str = ''; for ($i = 0; $i < $num_chars; $i++) { @@ -505,7 +505,7 @@ function tz_select($default = '') global $sys_timezone, $user; $tz_select = ''; - foreach ($user->lang['tz'] as $offset => $zone) + foreach ($user->lang['tz']['zones'] as $offset => $zone) { if (is_numeric($offset)) { @@ -631,7 +631,7 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false) { global $config, $db, $user; - if ($user->data['user_id'] == ANONYMOUS) + if (!$user->data['is_registered']) { return; } @@ -1804,7 +1804,7 @@ function page_header($page_title = '') $s_privmsg_new = false; // Obtain number of new private messages if user is logged in - if ($user->data['user_id'] != ANONYMOUS) + if ($user->data['is_registered']) { if ($user->data['user_new_privmsg']) { @@ -1842,7 +1842,7 @@ function page_header($page_title = '') // Which timezone? $tz = ($user->data['user_id'] != ANONYMOUS) ? strval(doubleval($user->data['user_timezone'])) : strval(doubleval($config['board_timezone'])); - + // The following assigns all _common_ variables that may be used at any point // in a template. $template->assign_vars(array( @@ -1889,10 +1889,10 @@ function page_header($page_title = '') 'S_CONTENT_ENCODING' => $user->lang['ENCODING'], 'S_CONTENT_DIR_LEFT' => $user->lang['LEFT'], 'S_CONTENT_DIR_RIGHT' => $user->lang['RIGHT'], - 'S_TIMEZONE' => ($user->data['user_dst'] || ($user->data['user_id'] == ANONYMOUS && $config['board_dst'])) ? sprintf($user->lang['ALL_TIMES'], (($tz >= 0) ? '+' . $tz : $tz), $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], (($tz >= 0) ? '+' . $tz : $tz), ''), - 'S_DISPLAY_ONLINE_LIST' => (!empty($config['load_online'])) ? 1 : 0, - 'S_DISPLAY_SEARCH' => (!empty($config['load_search'])) ? 1 : 0, - 'S_DISPLAY_PM' => (!empty($config['allow_privmsg'])) ? 1 : 0, + 'S_TIMEZONE' => ($user->data['user_dst'] || ($user->data['user_id'] == ANONYMOUS && $config['board_dst'])) ? sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], ''), + 'S_DISPLAY_ONLINE_LIST' => ($config['load_online']) ? 1 : 0, + 'S_DISPLAY_SEARCH' => ($config['load_search']) ? 1 : 0, + 'S_DISPLAY_PM' => ($config['allow_privmsg'] && $user->data['is_registered']) ? 1 : 0, 'S_DISPLAY_MEMBERLIST' => (isset($auth)) ? $auth->acl_get('u_viewprofile') : 0, 'S_NEW_PM' => ($s_privmsg_new) ? 1 : 0, @@ -1957,7 +1957,7 @@ function page_footer() $template->assign_vars(array( 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '', - 'U_ACP' => ($auth->acl_get('a_') && $user->data['user_id'] != ANONYMOUS) ? "adm/index.$phpEx?sid=" . $user->data['session_id'] : '') + 'U_ACP' => ($auth->acl_get('a_') && $user->data['is_registered']) ? "adm/index.$phpEx?sid=" . $user->data['session_id'] : '') ); $template->display('body'); diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 3d5f7c3391..190d07015e 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -34,7 +34,7 @@ function display_forums($root_data = '', $display_moderators = TRUE) // Display list of active topics for this category? $show_active = (isset($root_data['forum_flags']) && $root_data['forum_flags'] & 16) ? true : false; - if ($config['load_db_lastread'] && $user->data['user_id'] != ANONYMOUS) + if ($config['load_db_lastread'] && $user->data['is_registered']) { switch (SQL_LAYER) { @@ -65,7 +65,7 @@ function display_forums($root_data = '', $display_moderators = TRUE) $forum_ids = array($root_data['forum_id']); while ($row = $db->sql_fetchrow($result)) { - if ($mark_read == 'forums' && $user->data['user_id'] != ANONYMOUS) + if ($mark_read == 'forums' && $user->data['is_registered']) { if ($auth->acl_get('f_list', $row['forum_id'])) { @@ -157,7 +157,7 @@ function display_forums($root_data = '', $display_moderators = TRUE) $mark_time_forum = ($config['load_db_lastread']) ? $row['mark_time'] : ((isset($tracking_topics[$forum_id][0])) ? base_convert($tracking_topics[$forum_id][0], 36, 10) + $config['board_startdate'] : 0); - if ($mark_time_forum < $row['forum_last_post_time'] && $user->data['user_id'] != ANONYMOUS) + if ($mark_time_forum < $row['forum_last_post_time'] && $user->data['is_registered']) { $forum_unread[$parent_id] = true; } @@ -240,7 +240,7 @@ function display_forums($root_data = '', $display_moderators = TRUE) } $subforums_list = implode(', ', $links); - $l_subforums = (count($subforums[$forum_id]) == 1) ? $user->lang['SUBFORUM'] . ': ' : $user->lang['SUBFORUMS'] . ': '; + $l_subforums = (sizeof($subforums[$forum_id]) == 1) ? $user->lang['SUBFORUM'] . ': ' : $user->lang['SUBFORUMS'] . ': '; } } @@ -290,7 +290,7 @@ function display_forums($root_data = '', $display_moderators = TRUE) $l_moderator = $moderators_list = ''; if ($display_moderators && !empty($forum_moderators[$forum_id])) { - $l_moderator = (count($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS']; + $l_moderator = (sizeof($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS']; $moderators_list = implode(', ', $forum_moderators[$forum_id]); } @@ -440,7 +440,7 @@ function topic_status(&$topic_row, $replies, $mark_time_topic, $mark_time_forum, $folder_new = 'folder_locked_new'; } - if ($user->data['user_id'] != ANONYMOUS) + if ($user->data['is_registered']) { $unread_topic = $new_votes = true; diff --git a/phpBB/includes/functions_jabber.php b/phpBB/includes/functions_jabber.php index a679b1508a..f1e7b130f0 100644 --- a/phpBB/includes/functions_jabber.php +++ b/phpBB/includes/functions_jabber.php @@ -389,7 +389,7 @@ class jabber { $temp = $this->_split_incoming($incoming); - for ($a = 0; $a < count($temp); $a++) + for ($a = 0, $size = sizeof($temp); $a < $size; $a++) { $this->packet_queue[] = $this->xmlize($temp[$a]); } @@ -957,7 +957,7 @@ class make_xml extends jabber $temp = @explode('/', $string); - for ($a = 0; $a < count($temp); $a++) + for ($a = 0, $size = sizeof($temp); $a < $size; $a++) { $temp[$a] = preg_replace('#^[@]{1}([a-z0-9_]*)$#i', '["@"]["\1"]', $temp[$a]); $temp[$a] = preg_replace('#^([a-z0-9_]*)\(([0-9]*)\)$/i', '["\1"][\2]', $temp[$a]); @@ -1001,7 +1001,7 @@ class make_xml extends jabber } elseif (is_array($value)) { - for ($a = 0; $a < count($value); $a++) + for ($a = 0, $size = sizeof($value); $a < $size; $a++) { $text .= "<$key"; diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index fdcbf74ab5..afcfd86a38 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -473,7 +473,7 @@ class queue @set_time_limit(60); $package_size = $data_ary['package_size']; - $num_items = (count($data_ary['data']) < $package_size) ? count($data_ary['data']) : $package_size; + $num_items = (sizeof($data_ary['data']) < $package_size) ? sizeof($data_ary['data']) : $package_size; switch ($object) { @@ -552,7 +552,7 @@ class queue } // No more data for this object? Unset it - if (!count($this->queue_data[$object]['data'])) + if (!sizeof($this->queue_data[$object]['data'])) { unset($this->queue_data[$object]); } @@ -602,10 +602,14 @@ class queue foreach ($this->queue_data as $object => $data_ary) { - if (count($this->data[$object])) + if (isset($this->data[$object]) && sizeof($this->data[$object])) { $this->data[$object]['data'] = array_merge($data_ary['data'], $this->data[$object]['data']); } + else + { + $this->data[$object]['data'] = $data_ary['data']; + } } } diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 352b7a4e4a..c43c809562 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -868,7 +868,8 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . " AND w.user_id NOT IN ($sql_ignore_users) AND w.notify_status = 0 - AND u.user_id = w.user_id"; + AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ') + AND u.user_id = w.user_id'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) @@ -900,7 +901,8 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id WHERE fw.forum_id = $forum_id AND fw.user_id NOT IN ($sql_ignore_users) AND fw.notify_status = 0 - AND u.user_id = fw.user_id"; + AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ') + AND u.user_id = fw.user_id'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index e73ddb51ad..7d0a0d9cd4 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -133,7 +133,7 @@ function mcp_topic_view($id, $mode, $action, $url) 'MESSAGE' => $message, 'POST_ID' => $row['post_id'], - 'POST_ICON_IMG' => ($row['post_time'] > $user->data['user_lastvisit'] && $user->data['user_id'] != ANONYMOUS) ? $user->img('icon_post_new', $user->lang['NEW_POST']) : $user->img('icon_post', $user->lang['POST']), + 'POST_ICON_IMG' => ($row['post_time'] > $user->data['user_lastvisit'] && $user->data['is_registered']) ? $user->img('icon_post_new', $user->lang['NEW_POST']) : $user->img('icon_post', $user->lang['POST']), 'S_CHECKBOX' => $s_checkbox, 'S_POST_REPORTED' => ($row['post_reported']) ? true : false, diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 28d46dd5d6..8f7963f616 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -110,6 +110,9 @@ class session WHERE session_id = '" . $db->sql_escape($this->session_id) . "'"; $db->sql_query($sql); } + + $this->data['is_registered'] = ($this->data['user_id'] != ANONYMOUS && ($this->data['user_type'] == USER_NORMAL || $this->data['user_type'] == USER_FOUNDER)) ? true : false; + $this->data['is_bot'] = (!$this->data['is_registered'] && $this->data['user_id'] != ANONYMOUS) ? true : false; return true; } @@ -135,7 +138,7 @@ class session $bot = false; // Pull bot information from DB and loop through it - $sql = 'SELECT user_id, bot_agent, bot_ip + $sql = 'SELECT user_id, bot_agent, bot_ip FROM ' . BOTS_TABLE . ' WHERE bot_active = 1'; $result = $db->sql_query($sql); @@ -146,8 +149,8 @@ class session { $bot = $row['user_id']; } - - if ($row['bot_ip'] && (!$row['bot_agent'] || $bot)) + + if ($row['bot_ip'] && (!$row['bot_agent'] || !$bot)) { foreach (explode(',', $row['bot_ip']) as $bot_ip) { @@ -276,6 +279,8 @@ class session // Is there an existing session? If so, grab last visit time from that $this->data['session_last_visit'] = ($this->data['session_time']) ? $this->data['session_time'] : (($this->data['user_lastvisit']) ? $this->data['user_lastvisit'] : time()); + $this->data['is_registered'] = (!$bot && $user_id != ANONYMOUS) ? true : false; + $this->data['is_bot'] = ($bot) ? true : false; // Create or update the session $db->sql_return_on_error(true); @@ -358,9 +363,18 @@ class session $db->sql_query($sql); // Reset some basic data immediately - $this->session_id = $this->data['username'] = $this->data['user_permissions'] = ''; $this->data['user_id'] = ANONYMOUS; - $this->data['session_admin'] = 0; + + $sql = 'SELECT * + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . ANONYMOUS; + $result = $db->sql_query($sql); + + $this->data = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + $this->session_id = $this->data['session_id'] = ''; + $this->data['session_time'] = $this->data['session_admin'] = 0; // Trigger EVENT_END_SESSION diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index d7a2bfa5f8..3d9e0d605a 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -763,7 +763,7 @@ class template $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1)); - array_splice($tokens, $is_arg_start, count($tokens), $new_tokens); + array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens); $i = $is_arg_start; diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index 1c7752cda8..692d1a53ea 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -441,7 +441,7 @@ class ucp_main extends module if ($config['load_db_lastread']) { - $mark_time_topic = ($user->data['user_id'] != ANONYMOUS) ? $row['mark_time'] : 0; + $mark_time_topic = ($user->data['is_registered']) ? $row['mark_time'] : 0; $mark_time_forum = $row['forum_mark_time']; } else diff --git a/phpBB/includes/ucp/ucp_pm.php b/phpBB/includes/ucp/ucp_pm.php index 0ec90c3886..ee67746592 100644 --- a/phpBB/includes/ucp/ucp_pm.php +++ b/phpBB/includes/ucp/ucp_pm.php @@ -45,7 +45,7 @@ class ucp_pm extends module { global $user, $template, $phpbb_root_path, $auth, $phpEx, $db, $SID, $config; - if ($user->data['user_id'] == ANONYMOUS) + if (!$user->data['is_registered']) { trigger_error('NO_MESSAGE'); } @@ -89,7 +89,7 @@ class ucp_pm extends module case 'popup': $l_new_message = ''; - if ($user->data['user_id'] != ANONYMOUS) + if ($user->data['is_registered']) { if ($user->data['user_new_privmsg']) { |