diff options
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/auth/auth_apache.php | 4 | ||||
-rw-r--r-- | phpBB/includes/auth/auth_db.php | 4 | ||||
-rw-r--r-- | phpBB/includes/auth/auth_ldap.php | 8 | ||||
-rw-r--r-- | phpBB/includes/forums_display.php | 43 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 207 | ||||
-rw-r--r-- | phpBB/includes/functions_admin.php | 150 | ||||
-rw-r--r-- | phpBB/includes/page_header.php | 219 | ||||
-rw-r--r-- | phpBB/includes/page_tail.php | 12 | ||||
-rw-r--r-- | phpBB/includes/session.php | 424 | ||||
-rw-r--r-- | phpBB/includes/usercp_viewprofile.php | 88 |
10 files changed, 582 insertions, 577 deletions
diff --git a/phpBB/includes/auth/auth_apache.php b/phpBB/includes/auth/auth_apache.php index 4226c4ca53..88d5be4f4f 100644 --- a/phpBB/includes/auth/auth_apache.php +++ b/phpBB/includes/auth/auth_apache.php @@ -2,7 +2,7 @@ // // Authentication plug-ins is largely down to -// Sergey Kanareykin, our thanks to him. +// Sergey Kanareykin, our thanks to him. // function login_apache(&$username, &$password) { @@ -13,7 +13,7 @@ function login_apache(&$username, &$password) if ( $php_auth_user && $php_auth_pw ) { - $sql = "SELECT user_id, username, user_password, user_email, user_active + $sql = "SELECT user_id, username, user_password, user_email, user_active FROM " . USERS_TABLE . " WHERE username = '" . str_replace("\'", "''", $username) . "'"; $result = $db->sql_query($sql); diff --git a/phpBB/includes/auth/auth_db.php b/phpBB/includes/auth/auth_db.php index 0c9d0adf3e..6fad9eb986 100644 --- a/phpBB/includes/auth/auth_db.php +++ b/phpBB/includes/auth/auth_db.php @@ -2,13 +2,13 @@ // // Authentication plug-ins is largely down to -// Sergey Kanareykin, our thanks to him. +// Sergey Kanareykin, our thanks to him. // function login_db(&$username, &$password) { global $db, $board_config; - $sql = "SELECT user_id, username, user_password, user_email, user_active + $sql = "SELECT user_id, username, user_password, user_email, user_active FROM " . USERS_TABLE . " WHERE username = '" . str_replace("\'", "''", $username) . "'"; $result = $db->sql_query($sql); diff --git a/phpBB/includes/auth/auth_ldap.php b/phpBB/includes/auth/auth_ldap.php index d715dc837e..79af7a23e6 100644 --- a/phpBB/includes/auth/auth_ldap.php +++ b/phpBB/includes/auth/auth_ldap.php @@ -47,19 +47,19 @@ function login_ldap(&$username, &$password) // function admin_ldap(&$new) { - global $lang; + global $user; ?> <tr> - <td class="row1"><?php echo $lang['LDAP_server']; ?>:<br /><span class="gensmall"><?php echo $lang['LDAP_server_explain']; ?></span></td> + <td class="row1"><?php echo $user->lang['LDAP_server']; ?>:<br /><span class="gensmall"><?php echo $user->lang['LDAP_server_explain']; ?></span></td> <td class="row2"><input type="text" size="40" name="ldap_server" value="<?php echo $new['ldap_server']; ?>" /></td> </tr> <tr> - <td class="row1"><?php echo $lang['LDAP_dn']; ?>:<br /><span class="gensmall"><?php echo $lang['LDAP_dn_explain']; ?></span></td> + <td class="row1"><?php echo $user->lang['LDAP_dn']; ?>:<br /><span class="gensmall"><?php echo $user->lang['LDAP_dn_explain']; ?></span></td> <td class="row2"><input type="text" size="40" name="ldap_base_dn" value="<?php echo $new['ldap_base_dn']; ?>" /></td> </tr> <tr> - <td class="row1"><?php echo $lang['LDAP_uid']; ?>:<br /><span class="gensmall"><?php echo $lang['LDAP_uid_explain']; ?></span></td> + <td class="row1"><?php echo $user->lang['LDAP_uid']; ?>:<br /><span class="gensmall"><?php echo $user->lang['LDAP_uid_explain']; ?></span></td> <td class="row2"><input type="text" size="40" name="ldap_uid" value="<?php echo $new['ldap_uid']; ?>" /></td> </tr> <?php diff --git a/phpBB/includes/forums_display.php b/phpBB/includes/forums_display.php index ef86294f66..820d7cb2e3 100644 --- a/phpBB/includes/forums_display.php +++ b/phpBB/includes/forums_display.php @@ -53,57 +53,42 @@ foreach ($forum_rows as $row) switch ($forum_status) { case ITEM_CATEGORY: - $folder_image = $theme['sub_forum']; - $folder_alt = $lang['Category']; + $folder_image = 'sub_forum'; + $folder_alt = 'Category'; break; case ITEM_LOCKED: - $folder_image = $theme['forum_locked']; - $folder_alt = $lang['Forum_locked']; + $folder_image = 'forum_locked'; + $folder_alt = 'Forum_locked'; break; default: $unread_topics = false; - if ($userdata['user_id'] && $forum_last_post_time > $userdata['user_lastvisit']) + if ($user->data['user_id'] && $forum_last_post_time > $user->data['user_lastvisit']) { $unread_topics = true; - if (isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'])) - { - if ($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time) - { - $unread_topics = false; - } - } - - if (isset($mark_topics[$forum_id]) || isset($mark_forums[$forum_id])) - { - if ($mark_forums[$forum_id] > $userdata['user_lastvisit'] || !max($mark_topics[$forum_id])) - { - $unread_topics = false; - } - } } - $folder_image = ($unread_topics) ? $theme['forum_new'] : $theme['forum']; - $folder_alt = ($unread_topics) ? $lang['New_posts'] : $lang['No_new_posts']; + $folder_image = ($unread_topics) ? 'forum_new' : 'forum'; + $folder_alt = ($unread_topics) ? 'New_posts' : 'No_new_posts'; } if ($forum_last_post_id) { - $last_post = create_date($board_config['default_dateformat'], $forum_last_post_time, $board_config['board_timezone']) . '<br />'; + $last_post = $user->format_date($forum_last_post_time) . '<br />'; - $last_post .= ($forum_last_poster_id == ANONYMOUS) ? (($forum_last_poster_name != '') ? $forum_last_poster_name . ' ' : $lang['Guest'] . ' ') : '<a href="profile.' . $phpEx . $SID . '&mode=viewprofile&u=' . $forum_last_poster_id . '">' . $username . '</a> '; + $last_post .= ($forum_last_poster_id == ANONYMOUS) ? (($forum_last_poster_name != '') ? $forum_last_poster_name . ' ' : $user->lang['Guest'] . ' ') : '<a href="profile.' . $phpEx . $SID . '&mode=viewprofile&u=' . $forum_last_poster_id . '">' . $username . '</a> '; - $last_post .= '<a href="viewtopic.' . $phpEx . '$SID&f=' . $forum_id . '&p=' . $forum_last_post_id . '#' . $forum_last_post_id . '">' . create_img($theme['goto_post_latest'], $lang['View_latest_post']) . '</a>'; + $last_post .= '<a href="viewtopic.' . $phpEx . $SID . '&f=' . $forum_id . '&p=' . $forum_last_post_id . '#' . $forum_last_post_id . '">' . $user->img('goto_post_latest', 'View_latest_post') . '</a>'; } else { - $last_post = $lang['No_Posts']; + $last_post = $user->lang['No_Posts']; } if (!empty($forum_moderators[$forum_id])) { - $l_moderator = (count($forum_moderators[$forum_id]) == 1) ? $lang['Moderator'] . ': ' : $lang['Moderators'] . ': ' ; + $l_moderator = (count($forum_moderators[$forum_id]) == 1) ? $user->lang['Moderator'] . ': ' : $user->lang['Moderators'] . ': ' ; $moderators_list = implode(', ', $forum_moderators[$forum_id]); } else @@ -127,7 +112,7 @@ foreach ($forum_rows as $row) } $subforums_list = implode(', ', $links); - $l_subforums = (count($subforums[$forum_id]) == 1) ? $lang['Subforum'] . ': ' : $lang['Subforums'] . ': '; + $l_subforums = (count($subforums[$forum_id]) == 1) ? $user->lang['Subforum'] . ': ' : $user->lang['Subforums'] . ': '; } else { @@ -157,7 +142,7 @@ foreach ($forum_rows as $row) $template->assign_block_vars('forumrow', array( $forum_type_switch => TRUE, - 'FORUM_FOLDER_IMG' => create_img($folder_image, $folder_alt), + 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), 'FORUM_NAME' => $forum_name, 'FORUM_DESC' => $forum_desc, diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 07002056ed..06e901842d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -103,14 +103,16 @@ function get_forum_branch($forum_id, $type='all', $order='descending', $include_ default: $condition = 'f2.left_id BETWEEN f1.left_id AND f1.right_id OR f1.left_id BETWEEN f2.left_id AND f2.right_id'; } - $sql = 'SELECT f2.* - FROM ' . FORUMS_TABLE . ' f1 - LEFT JOIN ' . FORUMS_TABLE . " f2 ON $condition - WHERE f1.forum_id = $forum_id - ORDER BY f2.left_id " . (($order == 'descending') ? 'ASC' : 'DESC'); $rows = array(); + + $sql = 'SELECT f2.* + FROM ( ' . FORUMS_TABLE . ' f1 + LEFT JOIN ' . FORUMS_TABLE . " f2 ON $condition ) + WHERE f1.forum_id = $forum_id + ORDER BY f2.left_id " . ( ($order == 'descending') ? 'ASC' : 'DESC' ); $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { if (!$include_forum && $row['forum_id'] == $forum_id) @@ -122,10 +124,8 @@ function get_forum_branch($forum_id, $type='all', $order='descending', $include_ return $rows; } -// // Obtain list of moderators of each forum // First users, then groups ... broken into two queries -// function get_moderators(&$forum_moderators, $forum_id = false) { global $SID, $db, $phpEx; @@ -166,17 +166,17 @@ function get_moderators(&$forum_moderators, $forum_id = false) // function get_forum_rules($mode, &$rules, &$forum_id) { - global $SID, $auth, $lang, $phpEx; + global $SID, $auth, $user, $phpEx; - $rules .= ( ( $auth->acl_get('f_post', $forum_id) ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '<br />'; - $rules .= ( ( $auth->acl_get('f_reply', $forum_id) ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '<br />'; - $rules .= ( ( $auth->acl_get('f_edit', $forum_id) ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '<br />'; - $rules .= ( ( $auth->acl_get('f_delete', $forum_id) || $auth->acl_get('m_delete', $forum_id) ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '<br />'; - $rules .= ( ( $auth->acl_get('f_attach', $forum_id) ) ? $lang['Rules_attach_can'] : $lang['Rules_attach_cannot'] ) . '<br />'; + $rules .= ( ( $auth->acl_get('f_post', $forum_id) ) ? $user->lang['Rules_post_can'] : $user->lang['Rules_post_cannot'] ) . '<br />'; + $rules .= ( ( $auth->acl_get('f_reply', $forum_id) ) ? $user->lang['Rules_reply_can'] : $user->lang['Rules_reply_cannot'] ) . '<br />'; + $rules .= ( ( $auth->acl_get('f_edit', $forum_id) ) ? $user->lang['Rules_edit_can'] : $user->lang['Rules_edit_cannot'] ) . '<br />'; + $rules .= ( ( $auth->acl_get('f_delete', $forum_id) || $auth->acl_get('m_delete', $forum_id) ) ? $user->lang['Rules_delete_can'] : $user->lang['Rules_delete_cannot'] ) . '<br />'; + $rules .= ( ( $auth->acl_get('f_attach', $forum_id) ) ? $user->lang['Rules_attach_can'] : $user->lang['Rules_attach_cannot'] ) . '<br />'; if ( $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id) ) { - $rules .= sprintf($lang['Rules_moderate'], '<a href="modcp.' . $phpEx . $SID . '&f=' . $forum_id . '">', '</a>'); + $rules .= sprintf($user->lang['Rules_moderate'], '<a href="modcp.' . $phpEx . $SID . '&f=' . $forum_id . '">', '</a>'); } return; @@ -184,9 +184,9 @@ function get_forum_rules($mode, &$rules, &$forum_id) function make_jumpbox($action, $forum_id = false) { - global $auth, $template, $lang, $db, $nav_links, $phpEx; + global $auth, $template, $user, $db, $nav_links, $phpEx; - $boxstring = '<select name="f" onChange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"><option value="-1">' . $lang['Select_forum'] . '</option><option value="-1"> </option>'; + $boxstring = '<select name="f" onChange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"><option value="-1">' . $user->lang['Select_forum'] . '</option><option value="-1"> </option>'; $sql = 'SELECT forum_id, forum_name, forum_status, left_id, right_id FROM ' . FORUMS_TABLE . ' @@ -249,9 +249,7 @@ function make_jumpbox($action, $forum_id = false) $holding = ''; } - // // TODO: do not add empty categories to nav links - // $nav_links['chapter forum'][$row['forum_id']] = array ( 'url' => ($row['forum_status'] == ITEM_CATEGORY) ? "index.$phpEx$SIDc=" : "viewforum.$phpEx$SID&f=" . $row['forum_id'], 'title' => $row['forum_name'] @@ -263,13 +261,13 @@ function make_jumpbox($action, $forum_id = false) if (!$right) { - $boxstring .= '<option value="-1">' . $lang['No_forums'] . '</option>'; + $boxstring .= '<option value="-1">' . $user->lang['No_forums'] . '</option>'; } $boxstring .= '</select>'; $template->assign_vars(array( - 'L_GO' => $lang['Go'], - 'L_JUMP_TO' => $lang['Jump_to'], + 'L_GO' => $user->lang['Go'], + 'L_JUMP_TO' => $user->lang['Jump_to'], 'S_JUMPBOX_SELECT' => $boxstring, 'S_JUMPBOX_ACTION' => $action) @@ -278,16 +276,14 @@ function make_jumpbox($action, $forum_id = false) return; } -// // Pick a language, any language ... -// function language_select($default, $select_name = "language", $dirname="language") { global $phpEx; $dir = opendir($dirname); - $lang = array(); + $user = array(); while ( $file = readdir($dir) ) { if ( preg_match('#^lang_#', $file) && !is_file($dirname . '/' . $file) && !is_link($dirname . '/' . $file) ) @@ -295,30 +291,28 @@ function language_select($default, $select_name = "language", $dirname="language $filename = trim(str_replace('lang_', '', $file)); $displayname = preg_replace('/^(.*?)_(.*)$/', '\\1 [ \\2 ]', $filename); $displayname = preg_replace('/\[(.*?)_(.*)\]/', '[ \\1 - \\2 ]', $displayname); - $lang[$displayname] = $filename; + $user->lang[$displayname] = $filename; } } closedir($dir); - @asort($lang); - @reset($lang); + @asort($user); + @reset($user); - $lang_select = '<select name="' . $select_name . '">'; - foreach ( $lang as $displayname => $filename ) + $user_select = '<select name="' . $select_name . '">'; + foreach ( $user as $displayname => $filename ) { $selected = ( strtolower($default) == strtolower($filename) ) ? ' selected="selected"' : ''; - $lang_select .= '<option value="' . $filename . '"' . $selected . '>' . ucwords($displayname) . '</option>'; + $user_select .= '<option value="' . $filename . '"' . $selected . '>' . ucwords($displayname) . '</option>'; } - $lang_select .= '</select>'; + $user_select .= '</select>'; - return $lang_select; + return $user_select; } -// // Pick a template/theme combo, -// -function style_select($default_style, $select_name = "style", $dirname = "templates") +function style_select($default_style, $select_name = 'style', $dirname = 'templates') { global $db; @@ -339,15 +333,13 @@ function style_select($default_style, $select_name = "style", $dirname = "templa return $style_select; } -// // Pick a timezone -// function tz_select($default, $select_name = 'timezone') { - global $sys_timezone, $lang; + global $sys_timezone, $user; $tz_select = '<select name="' . $select_name . '">'; - while( list($offset, $zone) = @each($lang['tz']) ) + foreach ( $user->lang['tz'] as $offset => $zone ) { $selected = ( $offset == $default ) ? ' selected="selected"' : ''; $tz_select .= '<option value="' . $offset . '"' . $selected . '>' . $zone . '</option>'; @@ -357,20 +349,16 @@ function tz_select($default, $select_name = 'timezone') return $tz_select; } -// // Topic and forum watching common code -// function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $match_id) { - global $template, $db, $lang, $phpEx, $SID, $start; + global $template, $db, $user, $phpEx, $SID, $start; $table_sql = ( $mode == 'forum' ) ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE; $where_sql = ( $mode == 'forum' ) ? 'forum_id' : 'topic_id'; $u_url = ( $mode == 'forum' ) ? 'f' : 't'; - // // Is user watching this thread? - // if ( $user_id ) { $can_watch = TRUE; @@ -399,7 +387,7 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat 'META' => '<meta http-equiv="refresh" content="3;url=' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">') ); - $message = $lang['No_longer_watching_' . $mode] . '<br /><br />' . sprintf($lang['Click_return_' . $mode], '<a href="' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">', '</a>'); + $message = $user->lang['No_longer_watching_' . $mode] . '<br /><br />' . sprintf($user->lang['Click_return_' . $mode], '<a href="' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">', '</a>'); message_die(MESSAGE, $message); } else @@ -433,7 +421,7 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat 'META' => '<meta http-equiv="refresh" content="3;url=' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">') ); - $message = $lang['You_are_watching_' . $mode] . '<br /><br />' . sprintf($lang['Click_return_' . $mode], '<a href="' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">', '</a>'); + $message = $user->lang['You_are_watching_' . $mode] . '<br /><br />' . sprintf($user->lang['Click_return_' . $mode], '<a href="' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">', '</a>'); message_die(MESSAGE, $message); } else @@ -460,58 +448,16 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat if ( $can_watch ) { - if ( $is_watching ) - { - $watch_url = "view$mode." . $phpEx . $SID . '&' . $u_url . "=$match_id&unwatch=$mode&start=$start"; - $img = ( $mode == 'forum' ) ? $images['Forum_un_watch'] : $images['Topic_un_watch']; - - $s_watching = '<a href="' . $watch_url . '">' . $lang['Stop_watching_' . $mode] . '</a>'; - $s_watching_img = ( isset($img) ) ? '<a href="' . $watch_url . '"><img src="' . $img . '" alt="' . $lang['Stop_watching_' . $mode] . '" title="' . $lang['Stop_watching_' . $mode] . '" border="0"></a>' : ''; - } - else - { - $watch_url = "view$mode." . $phpEx . $SID . '&' . $u_url . "=$match_id&watch=$mode&start=$start"; - $img = ( $mode == 'forum' ) ? $images['Forum_watch'] : $images['Topic_watch']; - - $s_watching = '<a href="' . $watch_url . '">' . $lang['Start_watching_' . $mode] . '</a>'; - $s_watching_img = ( isset($img) ) ? '<a href="' . $watch_url . '"><img src="' . $img . '" alt="' . $lang['Stop_watching_' . $mode] . '" title="' . $lang['Start_watching_' . $mode] . '" border="0"></a>' : ''; - } + $s_watching = ( $is_watching ) ? '<a href="' . "view$mode." . $phpEx . $SID . '&' . $u_url . "=$match_id&unwatch=$mode&start=$start" . '">' . $user->lang['Stop_watching_' . $mode] . '</a>' : '<a href="' . "view$mode." . $phpEx . $SID . '&' . $u_url . "=$match_id&watch=$mode&start=$start" . '">' . $user->lang['Start_watching_' . $mode] . '</a>'; } return; } -// -// Create date/time from format and timezone -// -function create_date($format, $gmepoch, $tz) -{ - global $board_config, $lang; - static $translate; - - if ( empty($translate) && $board_config['default_lang'] != 'english' ) - { - foreach ( $lang['datetime'] as $match => $replace ) - { - $translate[$match] = $replace; - } - } - - return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz)); -} - -function create_img($img, $alt = '') -{ - return '<img src=' . $img . ' alt="' . $alt . '" title="' . $alt . '" />'; -} - -// -// Pagination routine, generates -// page number sequence -// +// Pagination routine, generates page number sequence function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = TRUE) { - global $lang; + global $user; $total_pages = ceil($num_items/$per_page); @@ -522,7 +468,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add $on_page = floor($start_item / $per_page) + 1; - $page_string = ( $on_page == 1 ) ? '<b>1</b>' : '<a href="' . $base_url . "&start=" . ( ( $on_page - 2 ) * $per_page ) . '">' . $lang['Previous'] . '</a> <a href="' . $base_url . '">1</a>'; + $page_string = ( $on_page == 1 ) ? '<b>1</b>' : '<a href="' . $base_url . "&start=" . ( ( $on_page - 2 ) * $per_page ) . '">' . $user->lang['Previous'] . '</a> <a href="' . $base_url . '">1</a>'; if ( $total_pages > 5 ) { @@ -556,18 +502,18 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add } } - $page_string .= ( $on_page == $total_pages ) ? '<b>' . $total_pages . '</b>' : '<a href="' . $base_url . '&start=' . ( ( $total_pages - 1 ) * $per_page ) . '">' . $total_pages . '</a> <a href="' . $base_url . "&start=" . ( $on_page * $per_page ) . '">' . $lang['Next'] . '</a>'; + $page_string .= ( $on_page == $total_pages ) ? '<b>' . $total_pages . '</b>' : '<a href="' . $base_url . '&start=' . ( ( $total_pages - 1 ) * $per_page ) . '">' . $total_pages . '</a> <a href="' . $base_url . "&start=" . ( $on_page * $per_page ) . '">' . $user->lang['Next'] . '</a>'; - $page_string = $lang['Goto_page'] . ' ' . $page_string; + $page_string = $user->lang['Goto_page'] . ' ' . $page_string; return $page_string; } function on_page($num_items, $per_page, $start) { - global $lang; + global $user; - return sprintf($lang['Page_of'], floor( $start / $per_page ) + 1, max(ceil( $num_items / $per_page ), 1) ); + return sprintf($user->lang['Page_of'], floor( $start / $per_page ) + 1, max(ceil( $num_items / $per_page ), 1) ); } // Obtain list of naughty words and build preg style replacement arrays for use by the @@ -581,25 +527,20 @@ function obtain_word_list(&$orig_word, &$replacement_word) FROM " . WORDS_TABLE; $result = $db->sql_query($sql); - if ( $row = $db->sql_fetchrow($result) ) + while ( $row = $db->sql_fetchrow($result) ) { - do - { - $orig_word[] = '#\b(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')\b#i'; - $replacement_word[] = $row['replacement']; - } - while ( $row = $db->sql_fetchrow($result) ); + $orig_word[] = '#\b(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')\b#i'; + $replacement_word[] = $row['replacement']; } return true; } -// // Redirects the user to another page then exits the script nicely -// function redirect($location) { global $db; + if (isset($db)) { $db->sql_close(); @@ -610,39 +551,26 @@ function redirect($location) exit; } -// // This is general replacement for die(), allows templated output in users (or default) // language, etc. $msg_code can be one of these constants: // // -> MESSAGE : Use for any simple text message, eg. results of an operation, authorisation // failures, etc. // -> ERROR : Use for any error, a simple page will be output -// -// $errno, $errstr, $errfile, $errline function message_die($msg_code, $msg_text = '', $msg_title = '') { - global $db, $session, $auth, $template, $board_config, $theme, $lang, $user; - global $userdata, $user_ip, $phpEx, $phpbb_root_path, $nav_links, $starttime; + global $db, $auth, $template, $board_config, $user, $nav_links; + global $phpEx, $phpbb_root_path, $starttime; switch ( $msg_code ) { case MESSAGE: - if ( empty($lang) && !empty($board_config['default_lang']) ) - { - if ( !file_exists($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx) ) - { - $board_config['default_lang'] = 'english'; - } - - include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx); - } - - $msg_title = ( $msg_title == '' ) ? $lang['Information'] : $msg_title; - $msg_text = ( !empty($lang[$msg_text]) ) ? $lang[$msg_text] : $msg_text; + $msg_title = ( $msg_title == '' ) ? $user->lang['Information'] : $msg_title; + $msg_text = ( !empty($user->lang[$msg_text]) ) ? $user->lang[$msg_text] : $msg_text; if ( !defined('HEADER_INC') ) { - if ( empty($userdata) ) + if ( empty($user->lang) ) { echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="admin/subSilver.css" type="text/css"><style type="text/css">th { background-image: url(\'admin/images/cellpic3.gif\') } td.cat { background-image: url(\'admin/images/cellpic1.gif\') }</style><title>' . $msg_title . '</title></html>' . "\n"; echo '<body><table width="100%" height="100%" border="0"><tr><td align="center" valign="middle"><table class="bg" width="80%" cellspacing="1" cellpadding="4" border="0"><tr><th>' . $msg_title . '</th></tr><tr><td class="row1" align="center">' . $msg_text . '</td></tr></table></td></tr></table></body></html>'; @@ -694,8 +622,8 @@ function message_die($msg_code, $msg_text = '', $msg_title = '') // Error and message handler, call with trigger_error if reqd function msg_handler($errno, $msg_text, $errfile, $errline) { - global $db, $session, $auth, $template, $board_config, $theme, $lang, $userdata, $user_ip; - global $phpEx, $phpbb_root_path, $nav_links, $starttime; + global $db, $auth, $template, $board_config, $user, $nav_links; + global $phpEx, $phpbb_root_path, $starttime; switch ( $errno ) { @@ -705,33 +633,26 @@ function msg_handler($errno, $msg_text, $errfile, $errline) case E_NOTICE: break; - case E_ERROR: case E_USER_ERROR: - $db->sql_close(); + if ( isset($db) ) + { + $db->sql_close(); + } - echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>phpBB 2 :: General Error</title></html>' . "\n"; - echo '<body><h1 style="font-family:Verdana,serif;font-size:18pt;font-weight:bold">phpBB2 :: General Error</h1><hr style="height:2px;border-style:dashed;color:black" /><p style="font-family:Verdana,serif;font-size:10pt">' . $msg_text . '</p><hr style="height:2px;border-style:dashed;color:black" /><p style="font-family:Verdana,serif;font-size:10pt">Contact the site administrator to report this failure</p></body></html>'; + echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="admin/subSilver.css" type="text/css"><style type="text/css">th { background-image: url(\'admin/images/cellpic3.gif\') } td.cat { background-image: url(\'admin/images/cellpic1.gif\') }</style><title>' . $msg_title . '</title></html>' . "\n"; + echo '<body><table width="100%" height="100%" border="0"><tr><td align="center" valign="middle"><table class="bg" width="80%" cellspacing="1" cellpadding="4" border="0"><tr><th>' . $msg_title . '</th></tr><tr><td class="row1" align="center">' . $msg_text . '</td></tr></table></td></tr></table></body></html>'; + exit; break; case E_USER_NOTICE: - if ( empty($lang) && !empty($board_config['default_lang']) ) - { - if ( !file_exists($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx) ) - { - $board_config['default_lang'] = 'english'; - } - - include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx); - } - - $msg_text = ( !empty($lang[$msg_text]) ) ? $lang[$msg_text] : $msg_text; + $msg_text = ( !empty($user->lang[$msg_text]) ) ? $user->lang[$msg_text] : $msg_text; if ( !defined('HEADER_INC') ) { - if ( empty($userdata) ) + if ( empty($user->data) ) { - echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="admin/subSilver.css" type="text/css"><style type="text/css">th { background-image: url(\'admin/images/cellpic3.gif\') } td.cat { background-image: url(\'admin/images/cellpic1.gif\') }</style><title>' . $lang['Information'] . '</title></html>' . "\n"; - echo '<body><table width="100%" height="100%" border="0"><tr><td align="center" valign="middle"><table class="bg" width="80%" cellspacing="1" cellpadding="4" border="0"><tr><th>' . $lang['Information'] . '</th></tr><tr><td class="row1" align="center">' . $msg_text . '</td></tr></table></td></tr></table></body></html>'; + echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="admin/subSilver.css" type="text/css"><style type="text/css">th { background-image: url(\'admin/images/cellpic3.gif\') } td.cat { background-image: url(\'admin/images/cellpic1.gif\') }</style><title>' . $user->lang['Information'] . '</title></html>' . "\n"; + echo '<body><table width="100%" height="100%" border="0"><tr><td align="center" valign="middle"><table class="bg" width="80%" cellspacing="1" cellpadding="4" border="0"><tr><th>' . $user->lang['Information'] . '</th></tr><tr><td class="row1" align="center">' . $msg_text . '</td></tr></table></td></tr></table></body></html>'; $db->sql_close(); exit; } diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 2707b5adef..4995db0a4f 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -387,7 +387,6 @@ function split_sql_file($sql, $delimiter) // save memory. $tokens[$j] = ''; } - } // for.. } // else } @@ -399,107 +398,63 @@ function split_sql_file($sql, $delimiter) // Extension of auth class for changing permissions class auth_admin extends auth { - function acl_set_user(&$forum_id, &$user_id, &$auth) + // Note that the set/delete methods are basically the same + // so if possible they should be merged + function acl_set($mode, &$forum_id, &$ug_id, &$auth) { global $db; - $forum_sql = ( $forum_id ) ? "AND a.forum_id IN ($forum_id, 0)" : ''; - - $sql = "SELECT o.auth_option_id, o.auth_value, a.auth_allow_deny - FROM " . ACL_USERS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o - WHERE a.auth_option_id = o.auth_option_id - $forum_sql - AND a.user_id = $user_id"; - $result = $db->sql_query($sql); - - $user_auth = array(); - if ( $row = $db->sql_fetchrow($result) ) - { - do - { - $user_auth[$user_id][$row['auth_option_id']] = $row['auth_allow_deny']; - } - while ( $row = $db->sql_fetchrow($result) ); - } - $db->sql_freeresult($result); - - foreach ( $auth as $auth_option_id => $allow ) - { - if ( !empty($user_auth) ) - { - foreach ( $user_auth as $user => $user_auth_ary ) - { - $sql_ary[] = ( !isset($user_auth_ary[$auth_option_id]) ) ? "INSERT INTO " . ACL_USERS_TABLE . " (user_id, forum_id, auth_option_id, auth_allow_deny) VALUES ($user_id, $forum_id, $auth_option_id, $allow)" : ( ( $user_auth_ary[$auth_option_id] != $allow ) ? "UPDATE " . ACL_USERS_TABLE . " SET auth_allow_deny = $allow WHERE user_id = $user_id AND forum_id = $forum_id AND auth_option_id = $auth_option_id" : '' ); - } - } - else - { - $sql_ary[] = "INSERT INTO " . ACL_USERS_TABLE . " (user_id, forum_id, auth_option_id, auth_allow_deny) VALUES ($user_id, $forum_id, $auth_option_id, $allow)"; - } - } - - foreach ( $sql_ary as $sql ) + if ( !is_array($forum_id) ) { - $db->sql_query($sql); + $forum_id = array($forum_id); } + // NOTE THIS USED TO BE IN ($forum_id, 0) ... + $forum_sql = 'AND a.forum_id IN (' . implode(', ', $forum_id) . ')'; - unset($user_auth); - unset($sql_ary); - - $this->acl_clear_prefetch(); - } - - function acl_set_group(&$forum_id, &$group_id, &$auth) - { - global $db; - - $forum_sql = "AND a.forum_id IN ($forum_id, 0)"; - - $sql = "SELECT o.auth_option_id, o.auth_value, a.auth_allow_deny - FROM " . ACL_GROUPS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o - WHERE a.auth_option_id = o.auth_option_id - $forum_sql - AND a.group_id = $group_id"; + $sql = ( $mode == 'user' ) ? "SELECT o.auth_option_id, o.auth_value, a.forum_id, a.auth_allow_deny FROM " . ACL_USERS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o WHERE a.auth_option_id = o.auth_option_id $forum_sql AND a.user_id = $ug_id" :"SELECT o.auth_option_id, o.auth_value, a.forum_id, a.auth_allow_deny FROM " . ACL_GROUPS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o WHERE a.auth_option_id = o.auth_option_id $forum_sql AND a.group_id = $ug_id"; $result = $db->sql_query($sql); - $group_auth = array(); - if ( $row = $db->sql_fetchrow($result) ) + $cur_auth = array(); + while ( $row = $db->sql_fetchrow($result) ) { - do - { - $group_auth[$group_id][$row['auth_option_id']] = $row['auth_allow_deny']; - } - while ( $row = $db->sql_fetchrow($result) ); + $cur_auth[$row['forum_id']][$row['auth_option_id']] = $row['auth_allow_deny']; } $db->sql_freeresult($result); - foreach ( $auth as $auth_option_id => $allow ) + $table = ( $mode == 'user' ) ? ACL_USERS_TABLE : ACL_GROUPS_TABLE; + $id_field = $mode . '_id'; + + foreach ( $forum_id as $forum) { - if ( !empty($group_auth) ) + foreach ( $auth as $auth_option_id => $allow ) { - foreach ( $group_auth as $group => $group_auth_ary ) + if ( !empty($cur_auth[$forum]) ) { - $sql_ary[] = ( !isset($group_auth_ary[$auth_option_id]) ) ? "INSERT INTO " . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_allow_deny) VALUES ($group_id, $forum_id, $auth_option_id, $allow)" : ( ( $group_auth_ary[$auth_option_id] != $allow ) ? "UPDATE " . ACL_GROUPS_TABLE . " SET auth_allow_deny = $allow WHERE group_id = $group_id AND forum_id = $forum_id and auth_option_id = $auth_option_id" : '' ); + $sql_ary[] = ( !isset($cur_auth[$forum][$auth_option_id]) ) ? "INSERT INTO $table ($id_field, forum_id, auth_option_id, auth_allow_deny) VALUES ($ug_id, $forum, $auth_option_id, $allow)" : ( ( $cur_auth[$forum][$auth_option_id] != $allow ) ? "UPDATE " . $table . " SET auth_allow_deny = $allow WHERE $id_field = $ug_id AND forum_id = $forum AND auth_option_id = $auth_option_id" : '' ); + } + else + { + $sql_ary[] = "INSERT INTO $table ($id_field, forum_id, auth_option_id, auth_allow_deny) VALUES ($ug_id, $forum, $auth_option_id, $allow)"; } - } - else - { - $sql_ary[] = "INSERT INTO " . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_allow_deny) VALUES ($group_id, $forum_id, $auth_option_id, $allow)"; } } + unset($forum_id); + unset($user_auth); foreach ( $sql_ary as $sql ) { - $db->sql_query($sql); + if ( $sql != '' ) + { + $result = $db->sql_query($sql); + $db->sql_freeresult($result); + } } - - unset($group_auth); unset($sql_ary); $this->acl_clear_prefetch(); } - function acl_delete_user($forum_id, $user_id, $auth_ids = false) + function acl_delete($mode, &$forum_id, &$ug_id, $auth_ids = false) { global $db; @@ -513,8 +468,11 @@ class auth_admin extends auth $auth_sql = " AND auth_option_id IN ($auth_sql)"; } - $sql = "DELETE FROM " . ACL_USERS_TABLE . " - WHERE user_id = $user_id + $table = ( $mode == 'user' ) ? ACL_USERS_TABLE : ACL_GROUPS_TABLE; + $id_field = $mode . '_id'; + + $sql = "DELETE FROM $table + WHERE $id_field = $ug_id AND forum_id = $forum_id $auth_sql"; $db->sql_query($sql); @@ -522,38 +480,34 @@ class auth_admin extends auth $this->acl_clear_prefetch(); } - function acl_delete_group($forum_id, $group_id, $auth_type = false) + function acl_clear_prefetch() { global $db; - $auth_sql = ''; - if ( $auth_ids ) - { - for($i = 0; $i < count($auth_ids); $i++) - { - $auth_sql .= ( ( $auth_sql != '' ) ? ', ' : '' ) . $auth_ids[$i]; - } - $auth_sql = " AND auth_option_id IN ($auth_sql)"; - } - - $sql = "DELETE FROM " . ACL_GROUPS_TABLE . " - WHERE group_id = $group_id - AND forum_id = $forum_id - $auth_sql"; + $sql = "UPDATE " . USERS_TABLE . " + SET user_permissions = ''"; $db->sql_query($sql); - $this->acl_clear_prefetch(); + return; } - function acl_clear_prefetch() + function acl_add_option($options) { global $db; - $sql = "UPDATE " . USERS_TABLE . " - SET user_permissions = ''"; - $db->sql_query($sql); + if ( !is_array($options) ) + { + message_die(ERROR, 'Incorrect parameter for acl_add_option'); + } + + // If we go with the | GLOBAL | FORUM | setup the array + // needs to be a hash setup appropriately. We then need + // to insert each new option with an appropriate global + // or local id + // + // If we stay with the current | FORUM | setup the array + // need not be a hash. Each entry would simply be inserted - return; } } diff --git a/phpBB/includes/page_header.php b/phpBB/includes/page_header.php index 7bbd33a2a4..49e673e7ff 100644 --- a/phpBB/includes/page_header.php +++ b/phpBB/includes/page_header.php @@ -36,22 +36,19 @@ if ( $board_config['gzip_compress'] ) } // Generate logged in/logged out status -if ( $userdata['user_id'] ) +if ( $user->data['user_id'] ) { $u_login_logout = 'login.'.$phpEx. $SID . '&logout=true'; - $l_login_logout = $lang['Logout'] . ' [ ' . $userdata['username'] . ' ]'; + $l_login_logout = $user->lang['Logout'] . ' [ ' . $user->data['username'] . ' ]'; } else { $u_login_logout = 'login.'.$phpEx . $SID; - $l_login_logout = $lang['Login']; + $l_login_logout = $user->lang['Login']; } // Last visit date/time -$s_last_visit = ( $userdata['user_id'] ) ? $user->format_date($userdata['session_last_visit']) : ''; - -// Timezone : $user->dst -$s_timezone = ( $userdata['user_dst'] ) ? sprintf($lang['All_times'], $lang[floatval($board_config['board_timezone'])], $lang['tz']['dst']) : sprintf($lang['All_times'], $lang[floatval($board_config['board_timezone'])], ''); +$s_last_visit = ( $user->data['user_id'] ) ? $user->format_date($user->data['session_last_visit']) : ''; // Get users online list $userlist_ary = array(); @@ -64,12 +61,17 @@ $online_userlist = ''; $prev_user_id = 0; $prev_user_ip = ''; -// && $auth->acl_get('forum', 'read', $_GET['f']) -$user_forum_sql = ( empty($_GET['f'])) ? '' : "AND s.session_page LIKE '%f=" . intval($_GET['f']) . "%'"; + +$reading_sql = ''; +if ( !empty($_GET['f']) || !empty($_GET['t']) ) +{ + $reading_sql = "AND s.session_page LIKE '%" . ( ( !empty($_GET['t']) ) ? 't=' . intval($_GET['t']) : 'f=' . intval($_GET['f']) ) . "%'"; +} + $sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_colour, s.session_ip FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE ." s WHERE s.session_time >= ".( time() - 300 ) . " - $user_forum_sql + $reading_sql AND u.user_id = s.session_user_id ORDER BY u.username ASC, s.session_ip ASC"; $result = $db->sql_query($sql, false); @@ -77,7 +79,7 @@ $result = $db->sql_query($sql, false); while( $row = $db->sql_fetchrow($result) ) { // User is logged in and therefor not a guest - if ( $row['user_id'] ) + if ($row['user_id'] != ANONYMOUS) { // Skip multiple sessions for one user if ( $row['user_id'] != $prev_user_id ) @@ -120,16 +122,16 @@ while( $row = $db->sql_fetchrow($result) ) if ( empty($online_userlist) ) { - $online_userlist = $lang['None']; + $online_userlist = $user->lang['None']; } if ( empty($_GET['f']) ) { - $online_userlist = $lang['Registered_users'] . ' ' . $online_userlist; + $online_userlist = $user->lang['Registered_users'] . ' ' . $online_userlist; } else { - $l_online = ( $guests_online == 1 ) ? $lang['Browsing_forum_guest'] : $lang['Browsing_forum_guests']; + $l_online = ( $guests_online == 1 ) ? $user->lang['Browsing_forum_guest'] : $user->lang['Browsing_forum_guests']; $online_userlist = sprintf($l_online, $online_userlist, $guests_online); } @@ -153,54 +155,54 @@ if ( $total_online_users > $board_config['record_online_users']) if ( $total_online_users == 0 ) { - $l_t_user_s = $lang['Online_users_zero_total']; + $l_t_user_s = $user->lang['Online_users_zero_total']; } else if ( $total_online_users == 1 ) { - $l_t_user_s = $lang['Online_user_total']; + $l_t_user_s = $user->lang['Online_user_total']; } else { - $l_t_user_s = $lang['Online_users_total']; + $l_t_user_s = $user->lang['Online_users_total']; } if ( $logged_visible_online == 0 ) { - $l_r_user_s = $lang['Reg_users_zero_total']; + $l_r_user_s = $user->lang['Reg_users_zero_total']; } else if ( $logged_visible_online == 1 ) { - $l_r_user_s = $lang['Reg_user_total']; + $l_r_user_s = $user->lang['Reg_user_total']; } else { - $l_r_user_s = $lang['Reg_users_total']; + $l_r_user_s = $user->lang['Reg_users_total']; } if ( $logged_hidden_online == 0 ) { - $l_h_user_s = $lang['Hidden_users_zero_total']; + $l_h_user_s = $user->lang['Hidden_users_zero_total']; } else if ( $logged_hidden_online == 1 ) { - $l_h_user_s = $lang['Hidden_user_total']; + $l_h_user_s = $user->lang['Hidden_user_total']; } else { - $l_h_user_s = $lang['Hidden_users_total']; + $l_h_user_s = $user->lang['Hidden_users_total']; } if ( $guests_online == 0 ) { - $l_g_user_s = $lang['Guest_users_zero_total']; + $l_g_user_s = $user->lang['Guest_users_zero_total']; } else if ( $guests_online == 1 ) { - $l_g_user_s = $lang['Guest_user_total']; + $l_g_user_s = $user->lang['Guest_user_total']; } else { - $l_g_user_s = $lang['Guest_users_total']; + $l_g_user_s = $user->lang['Guest_users_total']; } $l_online_users = sprintf($l_t_user_s, $total_online_users); @@ -208,62 +210,52 @@ $l_online_users .= sprintf($l_r_user_s, $logged_visible_online); $l_online_users .= sprintf($l_h_user_s, $logged_hidden_online); $l_online_users .= sprintf($l_g_user_s, $guests_online); -// -// Obtain number of new private messages -// if user is logged in -// -if ( $userdata['user_id'] ) +// Obtain number of new private messages if user is logged in +if ($user->data['user_id'] != ANONYMOUS) { - if ( $userdata['user_new_privmsg'] ) + if ($user->data['user_new_privmsg']) { - $l_message_new = ( $userdata['user_new_privmsg'] == 1 ) ? $lang['New_pm'] : $lang['New_pms']; - $l_privmsgs_text = sprintf($l_message_new, $userdata['user_new_privmsg']); + $l_message_new = ( $user->data['user_new_privmsg'] == 1 ) ? $user->lang['New_pm'] : $user->lang['New_pms']; + $l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']); - if ( $userdata['user_last_privmsg'] > $userdata['session_last_visit'] ) + if ( $user->data['user_last_privmsg'] > $user->data['session_last_visit'] ) { $sql = "UPDATE " . USERS_TABLE . " - SET user_last_privmsg = " . $userdata['session_last_visit'] . " - WHERE user_id = " . $userdata['user_id']; + SET user_last_privmsg = " . $user->data['session_last_visit'] . " + WHERE user_id = " . $user->data['user_id']; $db->sql_query($sql); $s_privmsg_new = 1; - $icon_pm = $images['pm_new_msg']; } else { $s_privmsg_new = 0; - $icon_pm = $images['pm_no_new_msg']; } } else { - $l_privmsgs_text = $lang['No_new_pm']; - + $l_privmsgs_text = $user->lang['No_new_pm']; $s_privmsg_new = 0; - $icon_pm = $images['pm_no_new_msg']; } - if ( $userdata['user_unread_privmsg'] ) + if ( $user->data['user_unread_privmsg'] ) { - $l_message_unread = ( $userdata['user_unread_privmsg'] == 1 ) ? $lang['Unread_pm'] : $lang['Unread_pms']; - $l_privmsgs_text_unread = sprintf($l_message_unread, $userdata['user_unread_privmsg']); + $l_message_unread = ( $user->data['user_unread_privmsg'] == 1 ) ? $user->lang['Unread_pm'] : $user->lang['Unread_pms']; + $l_privmsgs_text_unread = sprintf($l_message_unread, $user->data['user_unread_privmsg']); } else { - $l_privmsgs_text_unread = $lang['No_unread_pm']; + $l_privmsgs_text_unread = $user->lang['No_unread_pm']; } } else { - $icon_pm = $images['pm_no_new_msg']; - $l_privmsgs_text = $lang['Login_check_pm']; + $l_privmsgs_text = $user->lang['Login_check_pm']; $l_privmsgs_text_unread = ''; $s_privmsg_new = 0; } -// // Generate HTML required for Mozilla Navigation bar -// $nav_links_html = ''; /* $nav_link_proto = '<link rel="%s" href="%s" title="%s" />' . "\n"; @@ -283,77 +275,78 @@ foreach ( $nav_links as $nav_item => $nav_array ) } } */ -// + // The following assigns all _common_ variables that may be used at any point // in a template. -// $template->assign_vars(array( - 'SITENAME' => $board_config['sitename'], - 'SITE_DESCRIPTION' => $board_config['site_desc'], - 'PAGE_TITLE' => $page_title, - 'LAST_VISIT_DATE' => sprintf($lang['You_last_visit'], $s_last_visit), - 'CURRENT_TIME' => sprintf($lang['Current_time'], $user->format_date(time())), - 'TOTAL_USERS_ONLINE' => $l_online_users, - 'LOGGED_IN_USER_LIST' => $online_userlist, - 'RECORD_USERS' => sprintf($lang['Record_online_users'], $board_config['record_online_users'], $user->format_date($board_config['record_online_date'])), - 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, - 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, - 'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new, - - 'PRIVMSG_IMG' => $icon_pm, - - 'L_USERNAME' => $lang['Username'], - 'L_PASSWORD' => $lang['Password'], - 'L_LOGIN_LOGOUT' => $l_login_logout, - 'L_LOGIN' => $lang['Login'], - 'L_LOG_ME_IN' => $lang['Log_me_in'], - 'L_AUTO_LOGIN' => $lang['Log_me_in'], - 'L_INDEX' => sprintf($lang['Forum_Index'], $board_config['sitename']), - 'L_REGISTER' => $lang['Register'], - 'L_PROFILE' => $lang['Profile'], - 'L_SEARCH' => $lang['Search'], - 'L_PRIVATEMSGS' => $lang['Private_Messages'], - 'L_WHO_IS_ONLINE' => $lang['Who_is_Online'], - 'L_MEMBERLIST' => $lang['Memberlist'], - 'L_FAQ' => $lang['FAQ'], - 'L_USERGROUPS' => $lang['Usergroups'], - 'L_SEARCH_NEW' => $lang['Search_new'], - 'L_SEARCH_UNANSWERED' => $lang['Search_unanswered'], - 'L_SEARCH_SELF' => $lang['Search_your_posts'], - - 'U_SEARCH_UNANSWERED' => 'search.'.$phpEx.$SID.'&search_id=unanswered', - 'U_SEARCH_SELF' => 'search.'.$phpEx.$SID.'&search_id=egosearch', - 'U_SEARCH_NEW' => 'search.'.$phpEx.$SID.'&search_id=newposts', - 'U_INDEX' => 'index.'.$phpEx.$SID, - 'U_REGISTER' => 'profile.'.$phpEx.$SID.'&mode=register', - 'U_PROFILE' => 'profile.'.$phpEx.$SID.'&mode=editprofile', - 'U_PRIVATEMSGS' => 'privmsg.'.$phpEx.$SID.'&folder=inbox', - 'U_PRIVATEMSGS_POPUP' => 'privmsg.'.$phpEx.$SID.'&mode=newpm', - 'U_SEARCH' => 'search.'.$phpEx.$SID, - 'U_MEMBERLIST' => 'memberlist.'.$phpEx.$SID, - 'U_MODCP' => 'modcp.'.$phpEx.$SID, - 'U_FAQ' => 'faq.'.$phpEx.$SID, - 'U_VIEWONLINE' => 'viewonline.'.$phpEx.$SID, - 'U_LOGIN_LOGOUT' => $u_login_logout, + 'SITENAME' => $board_config['sitename'], + 'SITE_DESCRIPTION' => $board_config['site_desc'], + 'PAGE_TITLE' => $page_title, + 'LAST_VISIT_DATE' => sprintf($user->lang['You_last_visit'], $s_last_visit), + 'CURRENT_TIME' => sprintf($user->lang['Current_time'], $user->format_date(time())), + 'TOTAL_USERS_ONLINE' => $l_online_users, + 'LOGGED_IN_USER_LIST' => $online_userlist, + 'RECORD_USERS' => sprintf($user->lang['Record_online_users'], $board_config['record_online_users'], $user->format_date($board_config['record_online_date'])), + 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, + 'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new, + 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, + + 'L_USERNAME' => $user->lang['Username'], + 'L_PASSWORD' => $user->lang['Password'], + 'L_LOGIN_LOGOUT' => $l_login_logout, + 'L_LOGIN' => $user->lang['Login'], + 'L_LOG_ME_IN' => $user->lang['Log_me_in'], + 'L_AUTO_LOGIN' => $user->lang['Log_me_in'], + 'L_INDEX' => sprintf($user->lang['Forum_Index'], $board_config['sitename']), + 'L_FAQ' => $user->lang['FAQ'], + 'L_REGISTER' => $user->lang['Register'], + 'L_PROFILE' => $user->lang['Profile'], + 'L_SEARCH' => $user->lang['Search'], + 'L_PRIVATEMSGS' => $user->lang['Private_Messages'], + 'L_MEMBERLIST' => $user->lang['Memberlist'], + 'L_USERGROUPS' => $user->lang['Usergroups'], + 'L_SEARCH_NEW' => $user->lang['Search_new'], + 'L_SEARCH_SELF' => $user->lang['Search_your_posts'], + 'L_WHO_IS_ONLINE' => $user->lang['Who_is_Online'], + 'L_SEARCH_UNANSWERED' => $user->lang['Search_unanswered'], + + 'U_PRIVATEMSGS' => 'privmsg.'.$phpEx.$SID.'&folder=inbox', + 'U_MEMBERLIST' => 'memberlist.'.$phpEx.$SID, + 'U_VIEWONLINE' => 'viewonline.'.$phpEx.$SID, 'U_MEMBERSLIST' => 'memberlist.'.$phpEx.$SID, - 'U_GROUP_CP' => 'groupcp.'.$phpEx.$SID, - - 'S_USER_LOGGED_IN' => ( $userdata['user_id'] ) ? true : false, - 'S_USER_PM_POPUP' => ( !empty($userdata['user_popup_pm']) ) ? true : false, - 'S_USER_BROWSER' => $userdata['session_browser'], - 'S_CONTENT_DIRECTION' => $lang['DIRECTION'], - 'S_CONTENT_ENCODING' => $lang['ENCODING'], - 'S_CONTENT_DIR_LEFT' => $lang['LEFT'], - 'S_CONTENT_DIR_RIGHT' => $lang['RIGHT'], - 'S_TIMEZONE' => $s_timezone, - 'S_LOGIN_ACTION' => 'login.'.$phpEx.$SID, - - 'T_STYLESHEET_DATA' => $theme['css_data'], - 'T_STYLESHEET_LINK' => 'templates/' . $theme['css_external'], + 'U_GROUP_CP' => 'groupcp.'.$phpEx.$SID, + 'U_LOGIN_LOGOUT'=> $u_login_logout, + 'U_INDEX' => 'index.'.$phpEx.$SID, + 'U_SEARCH' => 'search.'.$phpEx.$SID, + 'U_REGISTER' => 'profile.'.$phpEx.$SID.'&mode=register', + 'U_PROFILE' => 'profile.'.$phpEx.$SID.'&mode=editprofile', + 'U_MODCP' => 'modcp.'.$phpEx.$SID, + 'U_FAQ' => 'faq.'.$phpEx.$SID, + 'U_SEARCH_SELF' => 'search.'.$phpEx.$SID.'&search_id=egosearch', + 'U_SEARCH_NEW' => 'search.'.$phpEx.$SID.'&search_id=newposts', + 'U_PRIVATEMSGS_POPUP' => 'privmsg.'.$phpEx.$SID.'&mode=newpm', + 'U_SEARCH_UNANSWERED' => 'search.'.$phpEx.$SID.'&search_id=unanswered', + + 'S_USER_LOGGED_IN' => ( $user->data['user_id'] ) ? true : false, + 'S_USER_PM_POPUP' => ( !empty($user->data['user_popup_pm']) ) ? true : false, + 'S_USER_BROWSER' => $user->data['session_browser'], + 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], + 'S_CONTENT_ENCODING' => $user->lang['ENCODING'], + 'S_CONTENT_DIR_LEFT' => $user->lang['LEFT'], + 'S_CONTENT_DIR_RIGHT' => $user->lang['RIGHT'], + 'S_LOGIN_ACTION' => 'login.'.$phpEx.$SID, + 'S_TIMEZONE' => ( $user->data['user_dst'] ) ? sprintf($user->lang['All_times'], $user->lang[floatval($board_config['board_timezone'])], $user->lang['tz']['dst']) : sprintf($user->lang['All_times'], $user->lang[floatval($board_config['board_timezone'])], ''), + + 'T_STYLESHEET_DATA' => $user->theme['css_data'], + 'T_STYLESHEET_LINK' => 'templates/' . $user->theme['css_external'], 'NAV_LINKS' => $nav_links_html) ); +/*if ( $board_config['send_encoding'] ) +{ + header ('Content-type: text/html; charset: ' . $user->lang['ENCODING']); +}*/ header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0'); header ('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); diff --git a/phpBB/includes/page_tail.php b/phpBB/includes/page_tail.php index 96360cb5e6..67c99e3ed7 100644 --- a/phpBB/includes/page_tail.php +++ b/phpBB/includes/page_tail.php @@ -19,14 +19,10 @@ * ***************************************************************************/ -// // Close our DB connection. -// $db->sql_close(); -// // Output page creation time -// if (defined('DEBUG')) { $mtime = explode(' ', microtime()); @@ -44,15 +40,15 @@ if (defined('DEBUG')) if ($auth->acl_get('a_')) { - $debug_output .= ' | <a href="' . $_SERVER['REQUEST_URI'] . '&explain=1">Explain</a>'; + $debug_output .= ' | <a href="' . $_SERVER['REQUEST_URI'] . '&explain=1">Explain</a>'; } $debug_output .= ' ]'; } $template->assign_vars(array( - 'PHPBB_VERSION' => $board_config['version'], - 'ADMIN_LINK' => ( $auth->acl_get('a_') ) ? '<a href="' . "admin/index.$phpEx?sid=" . $userdata['session_id'] . '">' . $lang['Admin_panel'] . '</a><br /><br />' : '', - 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '' + 'PHPBB_VERSION' => $board_config['version'], + 'ADMIN_LINK' => ( $auth->acl_get('a_') ) ? '<a href="' . "admin/index.$phpEx?sid=" . $user->data['session_id'] . '">' . $user->lang['Admin_panel'] . '</a><br /><br />' : '', + 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '' )); $template->display('body'); diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 9e8ea85e4c..3b4f5df354 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -19,17 +19,19 @@ * ***************************************************************************/ -class session { - +class session +{ var $session_id = ''; + var $data = array(); var $browser = ''; + var $user_ip = ''; var $page = ''; var $load; // Called at each page start ... checks for, updates and/or creates a session function start($update = true) { - global $SID, $db, $board_config, $user_ip; + global $SID, $db, $board_config; $current_time = time(); $this->browser = ( !empty($_SERVER['HTTP_USER_AGENT']) ) ? $_SERVER['HTTP_USER_AGENT'] : $_ENV['HTTP_USER_AGENT']; @@ -49,16 +51,28 @@ class session { $SID = '?sid=' . $this->session_id; } + // Obtain users IP + $this->ip = ( !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : $REMOTE_ADDR; + + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) + { + if ( preg_match('/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/', $_SERVER['HTTP_X_FORWARDED_FOR'], $ip_list) ) + { + $private_ip = array('/^0\./', '/^127\.0\.0\.1/', '/^192\.168\..*/', '/^172\.16\..*/', '/^10\..*/', '/^224\..*/', '/^240\..*/'); + $this->ip = preg_replace($private_ip, $this->ip, $ip_list[1]); + } + } + // Load limit check (if applicable) - if ( $board_config['limit_load'] && file_exists('/proc/loadavg') ) + if ( intval($board_config['limit_load']) && file_exists('/proc/loadavg') ) { if ( $load = @file('/proc/loadavg') ) { list($this->load) = explode(' ', $load[0]); - if ( $this->load > $board_config['limit_load'] ) + if ( $this->load > intval($board_config['limit_load']) ) { - message_die(MESSAGE, 'Board_unavailable'); + trigger_error('Board_unavailable'); } } } @@ -72,20 +86,20 @@ class session { AND u.user_id = s.session_user_id"; $result = $db->sql_query($sql); - $userdata = $db->sql_fetchrow($result); + $this->data = $db->sql_fetchrow($result); $db->sql_freeresult($result); // Did the session exist in the DB? - if ( isset($userdata['user_id']) ) + if ( isset($this->data['user_id']) ) { // Validate IP length according to admin ... has no effect on IPv6 - $s_ip = implode('.', array_slice(explode('.', $userdata['session_ip']), 0, $board_config['ip_check'])); - $u_ip = implode('.', array_slice(explode('.', $user_ip), 0, $board_config['ip_check'])); + $s_ip = implode('.', array_slice(explode('.', $this->data['session_ip']), 0, $board_config['ip_check'])); + $u_ip = implode('.', array_slice(explode('.', $this->ip), 0, $board_config['ip_check'])); if ( $u_ip == $s_ip ) { // Only update session DB a minute or so after last update or if page changes - if ( ( $current_time - $userdata['session_time'] > 60 || $userdata['session_page'] != $user_page ) && $update ) + if ( ( $current_time - $this->data['session_time'] > 60 || $this->data['session_page'] != $user_page ) && $update ) { $sql = "UPDATE " . SESSIONS_TABLE . " SET session_time = $current_time, session_page = '$this->page' @@ -93,7 +107,7 @@ class session { $db->sql_query($sql); } - return $userdata; + return true; } } } @@ -109,7 +123,7 @@ class session { // Create a new session function create(&$user_id, &$autologin) { - global $SID, $db, $board_config, $user_ip; + global $SID, $db, $board_config; $sessiondata = array(); $current_time = time(); @@ -127,7 +141,7 @@ class session { if ( intval($row['sessions']) > intval($board_config['active_sessions']) ) { - message_die(MESSAGE, 'Board_unavailable'); + trigger_error('Board_unavailable'); } } @@ -146,14 +160,14 @@ class session { ORDER BY s.session_time DESC"; $result = $db->sql_query($sql); - $userdata = $db->sql_fetchrow($result); + $this->data = $db->sql_fetchrow($result); $db->sql_freeresult($result); // Check autologin request, is it valid? - if ( $userdata['user_password'] != $autologin || !$userdata['user_active'] || !$user_id ) + if ( $this->data['user_password'] != $autologin || !$this->data['user_active'] || !$user_id ) { $autologin = ''; - $userdata['user_id'] = $user_id = ANONYMOUS; + $this->data['user_id'] = $user_id = ANONYMOUS; } $sql = "SELECT ban_ip, ban_userid, ban_email @@ -162,30 +176,26 @@ class session { OR ban_end = 0"; $result = $db->sql_query($sql); - if ( $row = $db->sql_fetchrow($result) ) + while ( $row = $db->sql_fetchrow($result) ) { - do + if ( ( $row['user_id'] == $this->data['user_id'] || + ( $row['ban_ip'] && preg_match('#^' . str_replace('*', '.*?', $row['ban_ip']) . '$#i', $this->ip) ) || + ( $row['ban_email'] && preg_match('#^' . str_replace('*', '.*?', $row['ban_email']) . '$#i', $this->data['user_email']) ) ) + && !$this->data['user_founder'] ) { - if ( ( $row['user_id'] == $userdata['user_id'] || - ( $row['ban_ip'] && preg_match('#^' . str_replace('*', '.*?', $row['ban_ip']) . '$#i', $user_ip) ) || - ( $row['ban_email'] && preg_match('#^' . str_replace('*', '.*?', $row['ban_email']) . '$#i', $userdata['user_email']) ) ) - && !$userdata['user_founder'] ) - { - message_die(MESSAGE, 'You_been_banned'); - } + trigger_error('You_been_banned'); } - while ( $row = $db->sql_fetchrow($result) ); } $db->sql_freeresult($result); // Is there an existing session? If so, grab last visit time from that - $userdata['session_last_visit'] = ( $userdata['session_time'] ) ? $userdata['session_time'] : ( ( $userdata['user_lastvisit'] ) ? $userdata['user_lastvisit'] : time() ); + $this->data['session_last_visit'] = ( $this->data['session_time'] ) ? $this->data['session_time'] : ( ( $this->data['user_lastvisit'] ) ? $this->data['user_lastvisit'] : time() ); // Create or update the session $db->sql_return_on_error(true); $sql = "UPDATE " . SESSIONS_TABLE . " - SET session_user_id = $user_id, session_last_visit = " . $userdata['session_last_visit'] . ", session_start = $current_time, session_time = $current_time, session_browser = '$this->browser', session_page = '$this->page' + SET session_user_id = $user_id, session_last_visit = " . $this->data['session_last_visit'] . ", session_start = $current_time, session_time = $current_time, session_browser = '$this->browser', session_page = '$this->page' WHERE session_id = '" . $this->session_id . "'"; if ( !$db->sql_query($sql) || !$db->sql_affectedrows() ) { @@ -194,12 +204,12 @@ class session { $sql = "INSERT INTO " . SESSIONS_TABLE . " (session_id, session_user_id, session_last_visit, session_start, session_time, session_ip, session_browser, session_page) - VALUES ('" . $this->session_id . "', $user_id, " . $userdata['session_last_visit'] . ", $current_time, $current_time, '$user_ip', '$this->browser', '$this->page')"; + VALUES ('" . $this->session_id . "', $user_id, " . $this->data['session_last_visit'] . ", $current_time, $current_time, '$this->ip', '$this->browser', '$this->page')"; $db->sql_query($sql); } $db->sql_return_on_error(false); - $userdata['session_id'] = $this->session_id; + $this->data['session_id'] = $this->session_id; $sessiondata['autologinid'] = ( $autologin && $user_id ) ? $autologin : ''; $sessiondata['userid'] = $user_id; @@ -208,17 +218,23 @@ class session { $this->set_cookie('sid', $this->session_id, 0); $SID = '?sid=' . $this->session_id; - // Events ... ? - if ( $userdata['user_id'] ) + if ( $this->data['user_id'] ) { + // Events ... ? // do_events('days'); + + // First page ... ? +// if (!empty($this->data['user_firstpage'])) +// { +// redirect($userdata['user_firstpage']); +// } } - return $userdata; + return true; } // Destroy a session - function destroy(&$userdata) + function destroy() { global $SID, $db, $board_config; @@ -230,13 +246,13 @@ class session { // Delete existing session, update last visit info first! $sql = "UPDATE " . USERS_TABLE . " - SET user_lastvisit = " . intval($userdata['session_time']) . " - WHERE user_id = " . $userdata['user_id']; + SET user_lastvisit = " . intval($this->data['session_time']) . " + WHERE user_id = " . $this->data['user_id']; $db->sql_query($sql); $sql = "DELETE FROM " . SESSIONS_TABLE . " WHERE session_id = '" . $this->session_id . "' - AND session_user_id = " . $userdata['user_id']; + AND session_user_id = " . $this->data['user_id']; $db->sql_query($sql); $this->session_id = ''; @@ -247,14 +263,14 @@ class session { // Garbage collection function gc(&$current_time) { - global $db, $board_config, $user_ip; + global $db, $board_config; // Get expired sessions, only most recent for each user $sql = "SELECT session_user_id, MAX(session_time) AS recent_time FROM " . SESSIONS_TABLE . " WHERE session_time < " . ( $current_time - $board_config['session_length'] ) . " GROUP BY session_user_id - LIMIT 10"; + LIMIT 5"; $result = $db->sql_query($sql); $del_user_id = ''; @@ -282,9 +298,9 @@ class session { $db->sql_query($sql); } - if ( $del_sessions < 10 ) + if ( $del_sessions < 5 ) { - // Less than 10 sessions, update gc timer ... else we want gc + // Less than 5 sessions, update gc timer ... else we want gc // called again to delete other sessions $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '$current_time' @@ -306,60 +322,65 @@ class session { // Contains (at present) basic user methods such as configuration // creating date/time ... keep this? -class user +class user extends session { - var $lang_name; - var $lang_path; + var $lang = array(); + var $theme = array(); var $date_format; var $timezone; var $dst; - function user(&$userdata, $lang_set = false, $style = false) + var $lang_name; + var $lang_path; + var $img_lang; + + function setup($lang_set = false, $style = false) { - global $db, $template, $lang, $board_config, $theme, $images; - global $phpEx, $phpbb_root_path; + global $db, $template, $board_config, $phpEx, $phpbb_root_path; - if ( $userdata['user_id'] ) + if ( $this->data['user_id'] != ANONYMOUS ) { - $this->lang_name = ( file_exists($phpbb_root_path . 'language/' . $userdata['user_lang']) ) ? $userdata['user_lang'] : $board_config['default_lang']; + $this->lang_name = ( file_exists($phpbb_root_path . 'language/' . $this->data['user_lang']) ) ? $this->data['user_lang'] : $board_config['default_lang']; $this->lang_path = $phpbb_root_path . 'language/' . $this->lang_name . '/'; - $this->date_format = $userdata['user_dateformat']; - $this->timezone = $userdata['user_timezone'] * 3600; - $this->dst = $userdata['user_dst'] * 3600; + $this->date_format = $this->data['user_dateformat']; + $this->timezone = $this->data['user_timezone'] * 3600; + $this->dst = $this->data['user_dst'] * 3600; } - else if ( isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) + else { $this->lang_name = $board_config['default_lang']; $this->lang_path = $phpbb_root_path . 'language/' . $this->lang_name . '/'; + $this->date_format = $board_config['default_dateformat']; + $this->timezone = $board_config['board_timezone'] * 3600; + $this->dst = 0; - $accept_lang_ary = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); - foreach ( $accept_lang_ary as $accept_lang ) + if ( isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) { - // Set correct format ... guess full xx_YY form - $accept_lang = substr($accept_lang, 0, 2) . '_' . strtoupper(substr($accept_lang, 3, 2)); - if ( file_exists($phpbb_root_path . 'language/' . $accept_lang) ) - { - $this->lang_name = $accept_lang; - $this->lang_path = $phpbb_root_path . 'language/' . $accept_lang . '/'; - break; - } - else + $accept_lang_ary = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); + foreach ( $accept_lang_ary as $accept_lang ) { - // No match on xx_YY so try xx - $accept_lang = substr($accept_lang, 0, 2); + // Set correct format ... guess full xx_YY form + $accept_lang = substr($accept_lang, 0, 2) . '_' . strtoupper(substr($accept_lang, 3, 2)); if ( file_exists($phpbb_root_path . 'language/' . $accept_lang) ) { $this->lang_name = $accept_lang; $this->lang_path = $phpbb_root_path . 'language/' . $accept_lang . '/'; break; } + else + { + // No match on xx_YY so try xx + $accept_lang = substr($accept_lang, 0, 2); + if ( file_exists($phpbb_root_path . 'language/' . $accept_lang) ) + { + $this->lang_name = $accept_lang; + $this->lang_path = $phpbb_root_path . 'language/' . $accept_lang . '/'; + break; + } + } } } - - $this->date_format = $board_config['default_dateformat']; - $this->timezone = $board_config['board_timezone'] * 3600; - $this->dst = 0; } include($this->lang_path . 'lang_main.' . $phpEx); @@ -367,6 +388,7 @@ class user { include($this->lang_path . 'lang_admin.' . $phpEx); } + /* if ( is_array($lang_set) ) { @@ -375,18 +397,18 @@ class user $lang_set = explode(',', $lang_set); foreach ( $lang_set as $lang_file ) { - include($this->lang_path . '/' . trim($lang_file) . '.' . $phpEx); + include($this->lang_path . '/' . $lang_file . '.' . $phpEx); } unset($lang_set); } else { include($this->lang_path . '/common.' . $phpEx); - include($this->lang_path . '/' . trim($lang_set) . '.' . $phpEx); + include($this->lang_path . '/' . $lang_set . '.' . $phpEx); } */ // Set up style - $style = ( $style ) ? $style : ( ( !$board_config['override_user_style'] && $userdata['user_id'] ) ? $userdata['user_style'] : $board_config['default_style'] ); + $style = ( $style ) ? $style : ( ( !$board_config['override_user_style'] && $this->data['user_id'] ) ? $this->data['user_style'] : $board_config['default_style'] ); $sql = "SELECT t.template_path, t.poll_length, t.pm_box_length, c.css_data, c.css_external, i.* FROM " . STYLES_TABLE . " s, " . STYLES_TPL_TABLE . " t, " . STYLES_CSS_TABLE . " c, " . STYLES_IMAGE_TABLE . " i @@ -396,33 +418,25 @@ class user AND i.imageset_id = s.imageset_id"; $result = $db->sql_query($sql); - if ( !($theme = $db->sql_fetchrow($result)) ) + if ( !($this->theme = $db->sql_fetchrow($result)) ) { message_die(ERROR, 'Could not get style data'); } - $template->set_template($theme['template_path']); - - $img_lang = ( file_exists('imagesets/' . $theme['imageset_path'] . '/' . $this->lang_name) ) ? $this->lang_name : $board_config['default_lang']; + $template->set_template($this->theme['template_path']); - $i10n = array('post_new', 'post_locked', 'post_pm', 'reply_new', 'reply_pm', 'reply_locked', 'icon_quote', 'icon_edit', 'icon_search', 'icon_profile', 'icon_pm', 'icon_email', 'icon_www', 'icon_icq', 'icon_aim', 'icon_yim', 'icon_msnm', 'icon_delete', 'icon_ip', 'icon_no_email', 'icon_no_www', 'icon_no_icq', 'icon_no_aim', 'icon_no_yim', 'icon_no_msnm'); - - foreach ( $i10n as $icon ) - { - $theme[$icon] = str_replace('{LANG}', $img_lang, $theme[$icon]); - } + $this->img_lang = ( file_exists($phpbb_root_path . 'imagesets/' . $this->theme['imageset_path'] . '/' . $this->lang_name) ) ? $this->lang_name : $board_config['default_lang']; return; } function format_date($gmepoch, $format = false) { - global $lang; static $lang_dates; if ( empty($lang_dates) ) { - foreach ( $lang['datetime'] as $match => $replace ) + foreach ( $this->lang['datetime'] as $match => $replace ) { $lang_dates[$match] = $replace; } @@ -431,6 +445,18 @@ class user $format = ( !$format ) ? $this->date_format : $format; return strtr(@gmdate($format, $gmepoch + $this->timezone + $this->dst), $lang_dates); } + + function img($img, $alt = '', $tag = false) + { + static $imgs; + + if (empty($imgs[$img])) + { + $imgs[$img] = '<img src=' . str_replace('{LANG}', $this->img_lang, $this->theme[$img]) . '" alt="' . $this->lang[$alt] . '" title="' . $this->lang[$alt] . '" />'; + } + + return $imgs[$img]; + } } // Will be keeping my eye of 'other products' to ensure these things don't @@ -438,29 +464,36 @@ class user class auth { var $founder = false; - var $acl = false; - var $options = array(); + var $acl = array(); + var $acl_options = array(); - function acl(&$userdata, $forum_id = false, $options = false) + function acl(&$userdata, $forum_id = false, $options_in = false, $options_or = false) { - global $db; + global $db, $acl_options; + + $this->acl_options = &$acl_options; if (!$this->founder = $userdata['user_founder']) { +// $mtime = explode(' ', microtime()); +// $starttime = $mtime[1] + $mtime[0]; +/* $in_sql = "'a_', 'f_list'"; + $or_sql = ''; - if ( $options ) + if ( is_array($options_in) ) { - if ( is_array($options) ) + foreach ( $options_in as $option ) { - foreach ( $options as $option ) - { - $in_sql .= ", '$option'"; - } + $in_sql .= ", '$option'"; } - else + } + + if ( is_array($options_or) ) + { + foreach ( $options_or as $option ) { - $or_sql = " OR auth_value LIKE '$option%'"; + $or_sql .= " OR auth_value LIKE '$option%'"; } } @@ -480,6 +513,9 @@ class auth } $db->sql_freeresult($result); +// $mtime = explode(' ', microtime()); +// echo $mtime[1] + $mtime[0] - $starttime . " :: "; + // This is preliminary and can no doubt be improved. The 12 in // the chunk_split relates to the current 96bits (12 bytes) per forum if ( !empty($userdata['user_permissions']) ) @@ -503,18 +539,84 @@ class auth $this->acl_cache($userdata); } -// $mtime = explode(' ', microtime()); -// echo $mtime[1] + $mtime[0] - $starttime . " :: "; +/* + $sql = "SELECT auth_value, global_id, local_id + FROM " . ACL_OPTIONS_TABLE . " + WHERE auth_value IN ($in_sql) $or_sql"; + $result = $db->sql_query($sql); + + while ( $row = $db->sql_fetchrow($result) ) + { + if ( isset($row['global_id']) ) + { + $this->options['global'][$row['auth_value']] = $row['global_id']; + } + if ( isset($row['local_id']) ) + { + $this->options['local'][$row['auth_value']] = $row['local_id']; + } + } + $db->sql_freeresult($result); +*/ + if ( empty($userdata['user_permissions']) ) + { + $this->acl_cache($userdata); + } + + // This is preliminary and can no doubt be improved + $global_chars = ceil(sizeof($this->acl_options['global']) / 8); + $local_chars = ceil(sizeof($this->acl_options['local']) / 8) + 2; + $globals = substr($userdata['user_permissions'], 0, $global_chars); + $locals = substr($userdata['user_permissions'], $global_chars); + + for($i = 0; $i < $global_chars; $i++) + { + $this->acl['global'] .= str_pad(decbin(ord(substr($globals, $i, 1))), 8, 0, STR_LEFT_PAD); + } + + $forums = explode("\r\n", chunk_split($locals, $local_chars)); + array_pop($forums); + foreach ( $forums as $forum ) + { + $forum_id = bindec(str_pad(decbin(ord(substr($forum, 0, 1))), 8, 0, STR_PAD_LEFT) . str_pad(decbin(ord(substr($forum, 1, 1))), 8, 0, STR_PAD_LEFT)); + + for($i = 2; $i < $local_chars; $i++) + { + $this->acl['local'][$forum_id] .= str_pad(decbin(ord(substr($forum, $i, 1))), 8, 0, STR_PAD_LEFT); + } + } + unset($forums); } +// $mtime = explode(' ', microtime()); +// echo $mtime[1] + $mtime[0] - $starttime . " :: "; + return; } // Look up an option function acl_get($option, $forum_id = 0) { - return ( $this->founder ) ? true : substr($this->acl[$forum_id], $this->options[$option], 1); -// return ( $this->founder ) ? true : $this->acl[$forum_id][$option]; + static $acl_cache; +/* + if ( !isset($acl_cache[$forum_id][$option]) && !$this->founder ) + { + $acl_cache[$forum_id][$option] = substr($this->acl[$forum_id], $this->options[$option], 1); + } +*/ + if ( !isset($acl_cache[$forum_id][$option]) && !$this->founder ) + { + if ( isset($this->acl_options['global'][$option]) ) + { + $acl_cache[$forum_id][$option] = substr($this->acl['global'], $this->acl_options['global'][$option], 1); + } + if ( isset($this->acl_options['local'][$option]) ) + { + $acl_cache[$forum_id][$option] |= substr($this->acl['local'][$forum_id], $this->acl_options['local'][$option], 1); + } + } + + return ( $this->founder ) ? true : $acl_cache[$forum_id][$option]; } // Cache data @@ -522,28 +624,18 @@ class auth { global $db; - $sql = "SELECT a.forum_id, a.auth_allow_deny, ao.auth_option_id, ao.auth_value + $acl_db = array(); + + $sql = "SELECT a.forum_id, a.auth_allow_deny, ao.auth_value FROM " . ACL_GROUPS_TABLE . " a, " . ACL_OPTIONS_TABLE . " ao, " . USER_GROUP_TABLE . " ug WHERE ug.user_id = " . $userdata['user_id'] . " AND a.group_id = ug.group_id AND ao.auth_option_id = a.auth_option_id"; $result = $db->sql_query($sql); - if ( $row = $db->sql_fetchrow($result) ) + while ( $row = $db->sql_fetchrow($result) ) { - do - { - switch ( $this->acl[$row['forum_id']][$row['auth_option_id']] ) - { - case ACL_PERMIT: - case ACL_DENY: - case ACL_PREVENT: - break; - default: - $this->acl[$row['forum_id']][$row['auth_option_id']] = $row['auth_allow_deny']; - } - } - while ( $row = $db->sql_fetchrow($result) ); + $acl_db[] = $row; } $db->sql_freeresult($result); @@ -553,33 +645,30 @@ class auth AND ao.auth_option_id = a.auth_option_id"; $result = $db->sql_query($sql); - if ( $row = $db->sql_fetchrow($result) ) + while ( $row = $db->sql_fetchrow($result) ) + { + $acl_db[] = $row; + } + $db->sql_freeresult($result); + + if ( is_array($acl_db) ) { - do + sort($acl_db); +/* foreach ( $acl_db as $row ) { - switch ( $this->acl[$row['forum_id']][$row['auth_option_id']] ) + if ( $row['auth_allow_deny'] != ACL_INHERIT && $this->acl[$row['forum_id']][$row['auth_value']] !== ACL_DENY ) { - case ACL_PERMIT: - case ACL_PREVENT: - break; - default: - $this->acl[$row['forum_id']][$row['auth_option_id']] = $row['auth_allow_deny']; - break; + $this->acl[$row['forum_id']][$row['auth_option_id']] = intval($row['auth_allow_deny']); } } - while ( $row = $db->sql_fetchrow($result) ); - } - $db->sql_freeresult($result); + unset($acl_db); - if ( is_array($this->acl) ) - { foreach ( $this->acl as $forum_id => $auth_ary ) { $holding = array(); for($i = 0; $i < 80; $i++) { - $allow = ( isset($this->acl[$forum_id][$i]) ) ? $this->acl[$forum_id][$i] : 0; - $holding[] = ( $allow == ACL_ALLOW || $allow == ACL_PERMIT ) ? 1 : 0; + $holding[] = ( isset($this->acl[$forum_id][$i]) ) ? $this->acl[$forum_id][$i] : 0; } $bitstring = explode("\r\n", chunk_split(str_pad(decbin($forum_id), 16, 0, STR_PAD_LEFT) . implode('', $holding), 8)); @@ -589,8 +678,75 @@ class auth $userdata['user_permissions'] .= chr(bindec($byte)); } } + unset($holding);*/ + + foreach ( $acl_db as $row ) + { + if ( $row['auth_allow_deny'] != ACL_INHERIT && $this->acl[$row['forum_id']][$row['auth_value']] !== ACL_DENY ) + { + $this->acl[$row['forum_id']][$row['auth_value']] = intval($row['auth_allow_deny']); + } + } + unset($acl_db); + + $global_bits = 8 * ceil(sizeof($this->acl_options['global']) / 8); + $local_bits = 8 * ceil(sizeof($this->acl_options['local']) / 8 ); + $local_hold = ''; + $global_hold = ''; + + foreach ( $this->acl as $forum_id => $auth_ary ) + { + $holding = array(); + + if ( !$forum_id ) + { + $fill = $global_bits; + $ary_key = 'global'; + $hold_str = 'global_hold'; + } + else + { + $fill = $local_bits; + $ary_key = 'local'; + $hold_str = 'local_hold'; + } + + for($i = 0; $i < $fill; $i++) + { + $holding[$i] = 0; + } + + foreach ( $auth_ary as $option => $allow ) + { + if ( $allow ) + { + $holding[$this->acl_options[$ary_key][$option]] = 1; + } + } + + $forum_id = ( $forum_id ) ? str_pad(decbin($forum_id), 16, 0, STR_PAD_LEFT) : ''; + $bitstring = explode("\r\n", chunk_split($forum_id . implode('', $holding), 8)); + array_pop($bitstring); + + foreach ( $bitstring as $byte ) + { + $$hold_str .= chr(bindec($byte)); + } + } unset($holding); + if ( $global_hold == '' ) + { + for($i = 0; $i < $global_bits; $i++) + { + $global_hold .= '0'; + } + } + + $userdata['user_permissions'] .= $global_hold . $local_hold; + unset($global_hold); + unset($local_hold); + $sql = "UPDATE " . USERS_TABLE . " SET user_permissions = '" . addslashes($userdata['user_permissions']) . "' WHERE user_id = " . $userdata['user_id']; @@ -625,7 +781,7 @@ class auth } } - message_die(ERROR, 'Authentication method not found'); + trigger_error('Authentication method not found', E_USER_ERROR); } } diff --git a/phpBB/includes/usercp_viewprofile.php b/phpBB/includes/usercp_viewprofile.php index 582c94558d..aee53196f3 100644 --- a/phpBB/includes/usercp_viewprofile.php +++ b/phpBB/includes/usercp_viewprofile.php @@ -27,11 +27,11 @@ if ( !defined('IN_PHPBB') ) exit; } -if ( empty($HTTP_GET_VARS['u']) || $HTTP_GET_VARS['u'] == ANONYMOUS ) +if ( empty($_GET['u']) || $_GET['u'] == ANONYMOUS ) { - message_die(MESSAGE, $lang['No_user_id_specified']); + message_die(MESSAGE, $user->lang['No_user_id_specified']); } -$profiledata = get_userdata(intval($HTTP_GET_VARS['u'])); +$profiledata = get_userdata(intval($_GET['u'])); $sql = "SELECT * FROM " . RANKS_TABLE . " @@ -117,8 +117,8 @@ if ( $profiledata['user_viewemail'] || $auth->acl_get('a_') ) { $email_uri = ( $board_config['board_email_form'] ) ? "profile.$phpEx$SID&mode=email&u=" . $profiledata['user_id'] : 'mailto:' . $profiledata['user_email']; - $email_img = '<a href="' . $email_uri . '">' . create_img($theme['icon_email'], $lang['Send_email']) . '</a>'; - $email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>'; + $email_img = '<a href="' . $email_uri . '">' . $user->img('icon_email', $user->lang['Send_email']) . '</a>'; + $email = '<a href="' . $email_uri . '">' . $user->lang['Send_email'] . '</a>'; } else { @@ -127,21 +127,21 @@ else } $temp_url = "profile.$phpEx$SID&mode=viewprofile&u=$user_id"; -$profile_img = '<a href="' . $temp_url . '">' . create_img($theme['icon_profile'], $lang['Read_profile']) . '</a>'; -$profile = '<a href="' . $temp_url . '">' . $lang['Read_profile'] . '</a>'; +$profile_img = '<a href="' . $temp_url . '">' . $user->img('icon_profile', $user->lang['Read_profile']) . '</a>'; +$profile = '<a href="' . $temp_url . '">' . $user->lang['Read_profile'] . '</a>'; $temp_url = "privmsg.$phpEx$SID&mode=post&u=$user_id"; -$pm_img = '<a href="' . $temp_url . '">' . create_img($theme['icon_pm'], $lang['Send_private_message']) . '</a>'; -$pm = '<a href="' . $temp_url . '">' . $lang['Send_private_message'] . '</a>'; +$pm_img = '<a href="' . $temp_url . '">' . $user->img('icon_pm', $user->lang['Send_private_message']) . '</a>'; +$pm = '<a href="' . $temp_url . '">' . $user->lang['Send_private_message'] . '</a>'; -$www_img = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww">' . create_img($theme['icon_www'], $lang['Visit_website']) . '</a>' : ''; -$www = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww">' . $lang['Visit_website'] . '</a>' : ''; +$www_img = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww">' . $user->img('icon_www', $user->lang['Visit_website']) . '</a>' : ''; +$www = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww">' . $user->lang['Visit_website'] . '</a>' : ''; if ( !empty($profiledata['user_icq']) ) { $icq_status_img = '<a href="http://wwp.icq.com/' . $profiledata['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $profiledata['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>'; - $icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '">' . create_img($theme['icon_icq'], $lang['ICQ']) . '</a>'; - $icq = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '">' . $lang['ICQ'] . '</a>'; + $icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '">' . $user->img('icon_icq', $user->lang['ICQ']) . '</a>'; + $icq = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '">' . $user->lang['ICQ'] . '</a>'; } else { @@ -150,36 +150,36 @@ else $icq = ''; } -$aim_img = ( $profiledata['user_aim'] ) ? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&message=Hello+Are+you+there?">' . create_img($theme['icon_aim'], $lang['AIM']) . '</a>' : ''; -$aim = ( $profiledata['user_aim'] ) ? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : ''; +$aim_img = ( $profiledata['user_aim'] ) ? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&message=Hello+Are+you+there?">' . $user->img('icon_aim', $user->lang['AIM']) . '</a>' : ''; +$aim = ( $profiledata['user_aim'] ) ? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&message=Hello+Are+you+there?">' . $user->lang['AIM'] . '</a>' : ''; $temp_url = "profile.$phpEx$SID&mode=viewprofile&u=$user_id"; -$msn_img = ( $profiledata['user_msnm'] ) ? '<a href="' . $temp_url . '">' . create_img($theme['icon_msnm'], $lang['MSNM']) . '</a>' : ''; -$msn = ( $profiledata['user_msnm'] ) ? '<a href="' . $temp_url . '">' . $lang['MSNM'] . '</a>' : ''; +$msn_img = ( $profiledata['user_msnm'] ) ? '<a href="' . $temp_url . '">' . $user->img('icon_msnm', $user->lang['MSNM']) . '</a>' : ''; +$msn = ( $profiledata['user_msnm'] ) ? '<a href="' . $temp_url . '">' . $user->lang['MSNM'] . '</a>' : ''; -$yim_img = ( $profiledata['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&.src=pg">' . create_img($theme['icon_yim'], $lang['YIM']) . '</a>' : ''; -$yim = ( $profiledata['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&.src=pg">' . $lang['YIM'] . '</a>' : ''; +$yim_img = ( $profiledata['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&.src=pg">' . $user->img('icon_yim', $user->lang['YIM']) . '</a>' : ''; +$yim = ( $profiledata['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&.src=pg">' . $user->lang['YIM'] . '</a>' : ''; $temp_url = "search.$phpEx$SID&search_author=" . urlencode($profiledata['username']) . "&showresults=posts"; -$search_img = '<a href="' . $temp_url . '">' . create_img($theme['icon_search'], $lang['Search_user_posts']) . '</a>'; -$search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>'; +$search_img = '<a href="' . $temp_url . '">' . $user->img('icon_search', $user->lang['Search_user_posts']) . '</a>'; +$search = '<a href="' . $temp_url . '">' . $user->lang['Search_user_posts'] . '</a>'; // // Generate page // -$page_title = $lang['Viewing_profile']; +$page_title = $user->lang['Viewing_profile']; include($phpbb_root_path . 'includes/page_header.'.$phpEx); $template->assign_vars(array( 'USERNAME' => $profiledata['username'], - 'JOINED' => $user->format_date($profiledata['user_regdate'], $lang['DATE_FORMAT']), + 'JOINED' => $user->format_date($profiledata['user_regdate'], $user->lang['DATE_FORMAT']), 'POSTER_RANK' => $poster_rank, 'RANK_IMAGE' => $rank_image, 'POSTS_PER_DAY' => $posts_per_day, 'POSTS' => $profiledata['user_posts'], 'PERCENTAGE' => $percentage . '%', - 'POST_DAY_STATS' => sprintf($lang['User_post_day_stats'], $posts_per_day), - 'POST_PERCENT_STATS' => sprintf($lang['User_post_pct_stats'], $percentage), + 'POST_DAY_STATS' => sprintf($user->lang['User_post_day_stats'], $posts_per_day), + 'POST_PERCENT_STATS' => sprintf($user->lang['User_post_pct_stats'], $percentage), 'SEARCH_IMG' => $search_img, 'SEARCH' => $search, @@ -204,25 +204,25 @@ $template->assign_vars(array( 'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : ' ', 'AVATAR_IMG' => $avatar_img, - 'L_VIEWING_PROFILE' => sprintf($lang['Viewing_user_profile'], $profiledata['username']), - 'L_ABOUT_USER' => sprintf($lang['About_user'], $profiledata['username']), - 'L_AVATAR' => $lang['Avatar'], - 'L_POSTER_RANK' => $lang['Poster_rank'], - 'L_JOINED' => $lang['Joined'], - 'L_TOTAL_POSTS' => $lang['Total_posts'], - 'L_SEARCH_USER_POSTS' => sprintf($lang['Search_user_posts'], $profiledata['username']), - 'L_CONTACT' => $lang['Contact'], - 'L_EMAIL_ADDRESS' => $lang['Email_address'], - 'L_EMAIL' => $lang['Email'], - 'L_PM' => $lang['Private_Message'], - 'L_ICQ_NUMBER' => $lang['ICQ'], - 'L_YAHOO' => $lang['YIM'], - 'L_AIM' => $lang['AIM'], - 'L_MESSENGER' => $lang['MSNM'], - 'L_WEBSITE' => $lang['Website'], - 'L_LOCATION' => $lang['Location'], - 'L_OCCUPATION' => $lang['Occupation'], - 'L_INTERESTS' => $lang['Interests'], + 'L_VIEWING_PROFILE' => sprintf($user->lang['Viewing_user_profile'], $profiledata['username']), + 'L_ABOUT_USER' => sprintf($user->lang['About_user'], $profiledata['username']), + 'L_AVATAR' => $user->lang['Avatar'], + 'L_POSTER_RANK' => $user->lang['Poster_rank'], + 'L_JOINED' => $user->lang['Joined'], + 'L_TOTAL_POSTS' => $user->lang['Total_posts'], + 'L_SEARCH_USER_POSTS' => sprintf($user->lang['Search_user_posts'], $profiledata['username']), + 'L_CONTACT' => $user->lang['Contact'], + 'L_EMAIL_ADDRESS' => $user->lang['Email_address'], + 'L_EMAIL' => $user->lang['Email'], + 'L_PM' => $user->lang['Private_Message'], + 'L_ICQ_NUMBER' => $user->lang['ICQ'], + 'L_YAHOO' => $user->lang['YIM'], + 'L_AIM' => $user->lang['AIM'], + 'L_MESSENGER' => $user->lang['MSNM'], + 'L_WEBSITE' => $user->lang['Website'], + 'L_LOCATION' => $user->lang['Location'], + 'L_OCCUPATION' => $user->lang['Occupation'], + 'L_INTERESTS' => $user->lang['Interests'], 'U_SEARCH_USER' => "search.$phpEx$SID&search_author=" . urlencode($profiledata['username']), |