aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2002-07-14 14:45:26 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2002-07-14 14:45:26 +0000
commit4bc4397f4a71972555f55e6e5d6e1aa87efb1428 (patch)
treefa6bb402fd18347b664e825421f8e3aa31147d7a /phpBB
parentd03de47b51173dac761e4fdf6e7004661a5565ac (diff)
downloadforums-4bc4397f4a71972555f55e6e5d6e1aa87efb1428.tar
forums-4bc4397f4a71972555f55e6e5d6e1aa87efb1428.tar.gz
forums-4bc4397f4a71972555f55e6e5d6e1aa87efb1428.tar.bz2
forums-4bc4397f4a71972555f55e6e5d6e1aa87efb1428.tar.xz
forums-4bc4397f4a71972555f55e6e5d6e1aa87efb1428.zip
Updates for permissions, sessions, lots of things ... note that _many_ things _do_not_work_ now ... I'm commiting them to stop people complaining about my holding on to everything :) There is _no_ update script at present for all these changes, you'll have to work out what's needed yourselves till I finish various things
git-svn-id: file:///svn/phpbb/trunk@2673 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/common.php255
-rw-r--r--phpBB/faq.php33
-rw-r--r--phpBB/groupcp.php84
-rw-r--r--phpBB/index.php391
-rw-r--r--phpBB/login.php145
-rw-r--r--phpBB/memberlist.php130
-rw-r--r--phpBB/modcp.php35
-rw-r--r--phpBB/posting.php119
-rw-r--r--phpBB/privmsg.php6
-rw-r--r--phpBB/profile.php23
-rw-r--r--phpBB/search.php60
-rw-r--r--phpBB/viewforum.php755
-rw-r--r--phpBB/viewonline.php221
-rw-r--r--phpBB/viewtopic.php781
14 files changed, 1279 insertions, 1759 deletions
diff --git a/phpBB/common.php b/phpBB/common.php
index 1169bd6cf0..23a034f795 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -8,7 +8,6 @@
*
* $Id$
*
- *
***************************************************************************/
/***************************************************************************
@@ -22,60 +21,23 @@
if ( !defined('IN_PHPBB') )
{
- die("Hacking attempt");
+ die('Hacking attempt');
}
error_reporting (E_ERROR | E_WARNING | E_PARSE); // This will NOT report uninitialized variables
set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
-//
-// addslashes to vars if magic_quotes_gpc is off this is a security precaution
-// to prevent someone trying to break out of a SQL statement.
-//
-function slash_input_data(&$data)
-{
- if ( is_array($data) )
- {
- while( list($k, $v) = each($data) )
- {
- $data[$k] = ( is_array($v) ) ? slash_input_data($v) : addslashes($v);
- }
-
- @reset($data);
- }
- return $data;
-}
+require($phpbb_root_path . 'config.'.$phpEx);
-if ( !get_magic_quotes_gpc() )
+if ( !defined('PHPBB_INSTALLED') )
{
- $HTTP_GET_VARS = slash_input_data($HTTP_GET_VARS);
- $HTTP_POST_VARS = slash_input_data($HTTP_POST_VARS);
- $HTTP_COOKIE_VARS = slash_input_data($HTTP_COOKIE_VARS);
+ header('Location: install/install.'.$phpEx);
+ exit;
}
//
-// Define some basic configuration arrays this also prevents
-// malicious rewriting of language and otherarray values via
-// URI params
+// Define some constants/variables
//
-$board_config = array();
-$userdata = array();
-$theme = array();
-$images = array();
-$lang = array();
-$gen_simple_header = FALSE;
-
-require($phpbb_root_path . 'config.'.$phpEx);
-
-if( !defined("PHPBB_INSTALLED") )
-{
- header("Location: install.$phpEx");
-}
-
-// Debug Level
-define('DEBUG', 1); // Debugging on
-//define('DEBUG', 0); // Debugging off
-
// User Levels <- Do not change the values of USER or ADMIN
define('ANONYMOUS', -1);
@@ -83,55 +45,39 @@ define('USER', 0);
define('ADMIN', 1);
define('MOD', 2);
-
// User related
define('USER_ACTIVATION_NONE', 0);
define('USER_ACTIVATION_SELF', 1);
define('USER_ACTIVATION_ADMIN', 2);
+define('USER_ACTIVATION_CLOSED', 3);
define('USER_AVATAR_NONE', 0);
define('USER_AVATAR_UPLOAD', 1);
define('USER_AVATAR_REMOTE', 2);
define('USER_AVATAR_GALLERY', 3);
-
// Group settings
define('GROUP_OPEN', 0);
define('GROUP_CLOSED', 1);
define('GROUP_HIDDEN', 2);
-
// Forum state
define('FORUM_UNLOCKED', 0);
define('FORUM_LOCKED', 1);
-
// Topic status
define('TOPIC_UNLOCKED', 0);
define('TOPIC_LOCKED', 1);
define('TOPIC_MOVED', 2);
-define('TOPIC_WATCH_NOTIFIED', 1);
-define('TOPIC_WATCH_UN_NOTIFIED', 0);
-
// Topic types
define('POST_NORMAL', 0);
define('POST_STICKY', 1);
define('POST_ANNOUNCE', 2);
-define('POST_GLOBAL_ANNOUNCE', 3);
-
-
-// SQL codes
-define('BEGIN_TRANSACTION', 1);
-define('END_TRANSACTION', 2);
-
// Error codes
-define('GENERAL_MESSAGE', 200);
-define('GENERAL_ERROR', 202);
-define('CRITICAL_MESSAGE', 203);
-define('CRITICAL_ERROR', 204);
-
+define('MESSAGE', 200);
+define('ERROR', 201);
// Private messaging
define('PRIVMSGS_READ_MAIL', 0);
@@ -141,81 +87,41 @@ define('PRIVMSGS_SAVED_IN_MAIL', 3);
define('PRIVMSGS_SAVED_OUT_MAIL', 4);
define('PRIVMSGS_UNREAD_MAIL', 5);
-
-// URL PARAMETERS
-define('POST_TOPIC_URL', 't');
-define('POST_CAT_URL', 'c');
-define('POST_FORUM_URL', 'f');
-define('POST_USERS_URL', 'u');
-define('POST_POST_URL', 'p');
-define('POST_GROUPS_URL', 'g');
-
// Session parameters
define('SESSION_METHOD_COOKIE', 100);
define('SESSION_METHOD_GET', 101);
-
-// Page numbers for session handling
-define('PAGE_INDEX', 0);
-define('PAGE_LOGIN', -1);
-define('PAGE_SEARCH', -2);
-define('PAGE_REGISTER', -3);
-define('PAGE_PROFILE', -4);
-define('PAGE_VIEWONLINE', -6);
-define('PAGE_VIEWMEMBERS', -7);
-define('PAGE_FAQ', -8);
-define('PAGE_POSTING', -9);
-define('PAGE_PRIVMSGS', -10);
-define('PAGE_GROUPCP', -11);
-define('PAGE_TOPIC_OFFSET', 5000);
-
-
-// Auth settings
-define('AUTH_LIST_ALL', 0);
-define('AUTH_ALL', 0);
-
-define('AUTH_REG', 1);
-define('AUTH_ACL', 2);
-define('AUTH_MOD', 3);
-define('AUTH_ADMIN', 5);
-
-define('AUTH_VIEW', 1);
-define('AUTH_READ', 2);
-define('AUTH_POST', 3);
-define('AUTH_REPLY', 4);
-define('AUTH_EDIT', 5);
-define('AUTH_DELETE', 6);
-define('AUTH_ANNOUNCE', 7);
-define('AUTH_STICKY', 8);
-define('AUTH_POLLCREATE', 9);
-define('AUTH_VOTE', 10);
-define('AUTH_ATTACH', 11);
-
-
// Table names
-define('AUTH_ACCESS_TABLE', $table_prefix.'auth_access');
+define('ACL_GROUPS_TABLE', $table_prefix.'auth_groups');
+define('ACL_OPTIONS_TABLE', $table_prefix.'auth_options');
+define('ACL_PREFETCH_TABLE', $table_prefix.'auth_prefetch');
+define('ACL_USERS_TABLE', $table_prefix.'auth_users');
define('BANLIST_TABLE', $table_prefix.'banlist');
-define('CATEGORIES_TABLE', $table_prefix.'categories');
+define('CATEGORIES_TABLE', $table_prefix.'categories'); //
define('CONFIG_TABLE', $table_prefix.'config');
-define('DISALLOW_TABLE', $table_prefix.'disallow');
+define('DISALLOW_TABLE', $table_prefix.'disallow'); //
define('FORUMS_TABLE', $table_prefix.'forums');
define('FORUMS_WATCH_TABLE', $table_prefix.'forums_watch');
define('GROUPS_TABLE', $table_prefix.'groups');
+define('ICONS_TABLE', $table_prefix.'icons');
+define('LOG_ADMIN_TABLE', $table_prefix.'log_admin');
+define('LOG_MOD_TABLE', $table_prefix.'log_moderators');
define('POSTS_TABLE', $table_prefix.'posts');
define('POSTS_TEXT_TABLE', $table_prefix.'posts_text');
define('PRIVMSGS_TABLE', $table_prefix.'privmsgs');
define('PRIVMSGS_TEXT_TABLE', $table_prefix.'privmsgs_text');
-define('PRIVMSGS_IGNORE_TABLE', $table_prefix.'privmsgs_ignore');
-define('PRUNE_TABLE', $table_prefix.'forum_prune');
define('RANKS_TABLE', $table_prefix.'ranks');
define('SEARCH_TABLE', $table_prefix.'search_results');
define('SEARCH_WORD_TABLE', $table_prefix.'search_wordlist');
define('SEARCH_MATCH_TABLE', $table_prefix.'search_wordmatch');
define('SESSIONS_TABLE', $table_prefix.'sessions');
define('SMILIES_TABLE', $table_prefix.'smilies');
-define('THEMES_TABLE', $table_prefix.'themes');
-define('THEMES_NAME_TABLE', $table_prefix.'themes_name');
+define('STYLES_TABLE', $table_prefix.'styles');
+define('STYLES_TPL_TABLE', $table_prefix.'styles_template');
+define('STYLES_CSS_TABLE', $table_prefix.'styles_theme');
+define('STYLES_IMAGE_TABLE', $table_prefix.'styles_imageset');
define('TOPICS_TABLE', $table_prefix.'topics');
+define('TOPICS_RATINGS_TABLE', $table_prefix.'topics_rating');
define('TOPICS_WATCH_TABLE', $table_prefix.'topics_watch');
define('USER_GROUP_TABLE', $table_prefix.'user_group');
define('USERS_TABLE', $table_prefix.'users');
@@ -224,81 +130,41 @@ define('VOTE_DESC_TABLE', $table_prefix.'vote_desc');
define('VOTE_RESULTS_TABLE', $table_prefix.'vote_results');
define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');
-include($phpbb_root_path . 'includes/template.'.$phpEx);
-include($phpbb_root_path . 'includes/sessions.'.$phpEx);
-include($phpbb_root_path . 'includes/auth.'.$phpEx);
-include($phpbb_root_path . 'includes/functions.'.$phpEx);
-
-switch($dbms)
+if ( !get_magic_quotes_gpc() )
{
- case 'mysql':
- include($phpbb_root_path . 'db/mysql.'.$phpEx);
- break;
-
- case 'mysql4':
- include($phpbb_root_path . 'db/mysql4.'.$phpEx);
- break;
-
- case 'postgres':
- include($phpbb_root_path . 'db/postgres7.'.$phpEx);
- break;
-
- case 'mssql':
- include($phpbb_root_path . 'db/mssql.'.$phpEx);
- break;
-
- case 'oracle':
- include($phpbb_root_path . 'db/oracle.'.$phpEx);
- break;
-
- case 'msaccess':
- include($phpbb_root_path . 'db/msaccess.'.$phpEx);
- break;
-
- case 'mssql-odbc':
- include($phpbb_root_path . 'db/mssql-odbc.'.$phpEx);
- break;
+ $HTTP_GET_VARS = slash_input_data($HTTP_GET_VARS);
+ $HTTP_POST_VARS = slash_input_data($HTTP_POST_VARS);
+ $HTTP_COOKIE_VARS = slash_input_data($HTTP_COOKIE_VARS);
}
-// Make the database connection.
-$db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, false);
-if ( !$db->db_connect_id )
-{
- message_die(CRITICAL_ERROR, "Could not connect to the database");
-}
+$board_config = array();
+$userdata = array();
+$theme = array();
+$images = array();
+$lang = array();
//
-// Mozilla navigation bar
-// Default items that should be valid on all pages.
-// Defined here and not in page_header.php so they can be redefined in the code
+// Include files
//
-$nav_links['top'] = array (
- 'url' => append_sid($phpbb_root_dir."index.".$phpEx),
- 'title' => sprintf($lang['Forum_Index'], $board_config['sitename'])
-);
-$nav_links['search'] = array (
- 'url' => append_sid($phpbb_root_dir."search.".$phpEx),
- 'title' => $lang['Search']
-);
-$nav_links['help'] = array (
- 'url' => append_sid($phpbb_root_dir."faq.".$phpEx),
- 'title' => $lang['FAQ']
-);
-$nav_links['author'] = array (
- 'url' => append_sid($phpbb_root_dir."memberlist.".$phpEx),
- 'title' => $lang['Memberlist']
-);
+require($phpbb_root_path . 'includes/template.'.$phpEx);
+require($phpbb_root_path . 'includes/session.'.$phpEx);
+require($phpbb_root_path . 'includes/functions.'.$phpEx);
+require($phpbb_root_path . 'db/' . $dbms . '.'.$phpEx);
+
+$session = new session();
+$db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
//
-// Obtain and encode users IP
+// Obtain users IP, not encoded in 2.2
//
-if( getenv('HTTP_X_FORWARDED_FOR') != '' )
+if ( $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'] != '' || $HTTP_ENV_VARS['HTTP_X_FORWARDED_FOR'] != '' )
{
$user_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : $REMOTE_ADDR );
+ $x_ip = ( !empty($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']) ) ? $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'] : $HTTP_ENV_VARS['HTTP_X_FORWARDED_FOR'];
- if ( preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", getenv('HTTP_X_FORWARDED_FOR'), $ip_list) )
+ if ( preg_match('/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/', $x_ip, $ip_list) )
{
- $private_ip = array('/^127\.0\.0\.1/', '/^192\.168\..*/', '/^172\.16\..*/', '/^10..*/', '/^224..*/', '/^240..*/');
+ $private_ip = array('/^0\./', '/^127\.0\.0\.1/', '/^192\.168\..*/', '/^172\.16\..*/', '/^10\..*/', '/^224\..*/', '/^240\..*/');
$user_ip = preg_replace($private_ip, $client_ip, $ip_list[1]);
}
}
@@ -308,18 +174,14 @@ else
}
//
-// Setup forum wide options, if this fails
-// then we output a CRITICAL_ERROR since
+// Setup forum wide options, if this fails we output a CRITICAL_ERROR since
// basic forum information is not available
//
$sql = "SELECT *
FROM " . CONFIG_TABLE;
-if ( !($result = $db->sql_query($sql)) )
-{
- message_die(CRITICAL_ERROR, 'Could not query config information', '', __LINE__, __FILE__, $sql);
-}
+$result = $db->sql_query($sql);
-while($row = $db->sql_fetchrow($result))
+while ( $row = $db->sql_fetchrow($result) )
{
$board_config[$row['config_name']] = $row['config_value'];
}
@@ -329,7 +191,26 @@ while($row = $db->sql_fetchrow($result))
//
if ( $board_config['board_disable'] && !defined('IN_ADMIN') && !defined('IN_LOGIN') )
{
- message_die(GENERAL_MESSAGE, 'Board_disable', 'Information');
+ $message = ( !empty($board_config['board_disable_msg']) ) ? $board_config['board_disable_msg'] : 'Board_disable';
+ message_die(MESSAGE, $message, 'Information');
+}
+
+//
+// addslashes to vars if magic_quotes_gpc is off this is a security precaution
+// to prevent someone trying to break out of a SQL statement.
+//
+function slash_input_data(&$data)
+{
+ if ( is_array($data) )
+ {
+ while ( list($k, $v) = each($data) )
+ {
+ $data[$k] = ( is_array($v) ) ? slash_input_data($v) : addslashes($v);
+ }
+
+ @reset($data);
+ }
+ return $data;
}
?> \ No newline at end of file
diff --git a/phpBB/faq.php b/phpBB/faq.php
index 7c406eb79f..cc3afea50e 100644
--- a/phpBB/faq.php
+++ b/phpBB/faq.php
@@ -28,16 +28,21 @@ include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
-$userdata = session_pagestart($user_ip, PAGE_FAQ);
-init_userprefs($userdata);
+$userdata = $session->start();
+$acl = new auth('list', $userdata);
//
// End session management
//
//
+// Configure style, language, etc.
+//
+$session->configure($userdata);
+
+//
// Load the appropriate faq file
//
-if( isset($HTTP_GET_VARS['mode']) )
+if ( isset($HTTP_GET_VARS['mode']) )
{
switch( $HTTP_GET_VARS['mode'] )
{
@@ -69,7 +74,7 @@ $faq_block_titles = array();
for($i = 0; $i < count($faq); $i++)
{
- if( $faq[$i][0] != '--' )
+ if ( $faq[$i][0] != '--' )
{
$faq_block[$j][$counter]['id'] = $counter_2;
$faq_block[$j][$counter]['question'] = $faq[$i][0];
@@ -91,14 +96,6 @@ for($i = 0; $i < count($faq); $i++)
//
// Lets build a page ...
//
-$page_title = $l_title;
-include($phpbb_root_path . 'includes/page_header.'.$phpEx);
-
-$template->set_filenames(array(
- 'body' => 'faq_body.tpl')
-);
-make_jumpbox('viewforum.'.$phpEx, $forum_id);
-
$template->assign_vars(array(
'L_FAQ_TITLE' => $l_title,
'L_BACK_TO_TOP' => $lang['Back_to_top'])
@@ -106,7 +103,7 @@ $template->assign_vars(array(
for($i = 0; $i < count($faq_block); $i++)
{
- if( count($faq_block[$i]) )
+ if ( count($faq_block[$i]) )
{
$template->assign_block_vars('faq_block', array(
'BLOCK_TITLE' => $faq_block_titles[$i])
@@ -121,6 +118,7 @@ for($i = 0; $i < count($faq_block); $i++)
$row_class = ( !($j % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars('faq_block.faq_row', array(
+ 'ROW_COUNT' => $j,
'ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class,
'FAQ_QUESTION' => $faq_block[$i][$j]['question'],
@@ -130,6 +128,7 @@ for($i = 0; $i < count($faq_block); $i++)
);
$template->assign_block_vars('faq_block_link.faq_row_link', array(
+ 'ROW_COUNT' => $j,
'ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class,
'FAQ_LINK' => $faq_block[$i][$j]['question'],
@@ -140,7 +139,13 @@ for($i = 0; $i < count($faq_block); $i++)
}
}
-$template->pparse('body');
+$page_title = $l_title;
+include($phpbb_root_path . 'includes/page_header.'.$phpEx);
+
+$template->set_filenames(array(
+ 'body' => 'faq_body.html')
+);
+make_jumpbox('viewforum.'.$phpEx, $forum_id);
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
diff --git a/phpBB/groupcp.php b/phpBB/groupcp.php
index df0109e346..238344799a 100644
--- a/phpBB/groupcp.php
+++ b/phpBB/groupcp.php
@@ -111,8 +111,8 @@ function generate_user_info(&$row, $date_format, $group_mod, &$from, &$posts, &$
//
// Start session management
//
-$userdata = session_pagestart($user_ip, PAGE_GROUPCP);
-init_userprefs($userdata);
+$userdata = $session->start();
+$acl = new auth('list', $userdata);
//
// End session management
//
@@ -166,7 +166,7 @@ if ( isset($HTTP_POST_VARS['groupstatus']) && $group_id )
WHERE group_id = $group_id";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not obtain user and group information', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not obtain user and group information', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
@@ -179,7 +179,7 @@ if ( isset($HTTP_POST_VARS['groupstatus']) && $group_id )
$message = $lang['Not_group_moderator'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
+ message_die(MESSAGE, $message);
}
$sql = "UPDATE " . GROUPS_TABLE . "
@@ -187,7 +187,7 @@ if ( isset($HTTP_POST_VARS['groupstatus']) && $group_id )
WHERE group_id = $group_id";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not obtain user and group information', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not obtain user and group information', '', __LINE__, __FILE__, $sql);
}
$template->assign_vars(array(
@@ -196,7 +196,7 @@ if ( isset($HTTP_POST_VARS['groupstatus']) && $group_id )
$message = $lang['Group_type_updated'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
+ message_die(MESSAGE, $message);
}
else if ( isset($HTTP_POST_VARS['joingroup']) && $group_id )
@@ -217,7 +217,7 @@ else if ( isset($HTTP_POST_VARS['joingroup']) && $group_id )
AND ug.group_id = g.group_id";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not obtain user and group information', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not obtain user and group information', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
@@ -234,7 +234,7 @@ else if ( isset($HTTP_POST_VARS['joingroup']) && $group_id )
$message = $lang['Already_member_group'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
+ message_die(MESSAGE, $message);
}
} while ( $row = $db->sql_fetchrow($result) );
}
@@ -246,19 +246,19 @@ else if ( isset($HTTP_POST_VARS['joingroup']) && $group_id )
$message = $lang['This_closed_group'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
+ message_die(MESSAGE, $message);
}
}
else
{
- message_die(GENERAL_MESSAGE, $lang['No_groups_exist']);
+ message_die(MESSAGE, $lang['No_groups_exist']);
}
$sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending)
VALUES ($group_id, " . $userdata['user_id'] . ", 1)";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, "Error inserting user group subscription", "", __LINE__, __FILE__, $sql);
+ message_die(ERROR, "Error inserting user group subscription", "", __LINE__, __FILE__, $sql);
}
$sql = "SELECT u.user_email, u.username, u.user_lang, g.group_name
@@ -267,7 +267,7 @@ else if ( isset($HTTP_POST_VARS['joingroup']) && $group_id )
AND g.group_id = $group_id";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, "Error getting group moderator data", "", __LINE__, __FILE__, $sql);
+ message_die(ERROR, "Error getting group moderator data", "", __LINE__, __FILE__, $sql);
}
$moderator = $db->sql_fetchrow($result);
@@ -298,7 +298,7 @@ else if ( isset($HTTP_POST_VARS['joingroup']) && $group_id )
$message = $lang['Group_joined'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
+ message_die(MESSAGE, $message);
}
else if ( isset($HTTP_POST_VARS['unsub']) || isset($HTTP_POST_VARS['unsubpending']) && $group_id )
{
@@ -322,7 +322,7 @@ else if ( isset($HTTP_POST_VARS['unsub']) || isset($HTTP_POST_VARS['unsubpending
AND group_id = $group_id";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not delete group memebership data', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not delete group memebership data', '', __LINE__, __FILE__, $sql);
}
if ( $userdata['user_level'] != ADMIN && $userdata['user_level'] == MOD )
@@ -334,7 +334,7 @@ else if ( isset($HTTP_POST_VARS['unsub']) || isset($HTTP_POST_VARS['unsubpending
AND aa.auth_mod = 1";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not obtain moderator status', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not obtain moderator status', '', __LINE__, __FILE__, $sql);
}
if ( !($row = $db->sql_fetchrow($result)) )
@@ -344,7 +344,7 @@ else if ( isset($HTTP_POST_VARS['unsub']) || isset($HTTP_POST_VARS['unsubpending
WHERE user_id = " . $userdata['user_id'];
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
}
}
}
@@ -355,7 +355,7 @@ else if ( isset($HTTP_POST_VARS['unsub']) || isset($HTTP_POST_VARS['unsubpending
$message = $lang['Usub_success'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
+ message_die(MESSAGE, $message);
}
else
{
@@ -437,7 +437,7 @@ else if ( $group_id )
}
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not get moderator information', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not get moderator information', '', __LINE__, __FILE__, $sql);
}
if ( $group_info = $db->sql_fetchrow($result) )
@@ -467,7 +467,7 @@ else if ( $group_id )
$message = $lang['Not_group_moderator'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
+ message_die(MESSAGE, $message);
}
if ( isset($HTTP_POST_VARS['add']) )
@@ -479,7 +479,7 @@ else if ( $group_id )
WHERE username = '" . str_replace("\'", "''", $username) . "'";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, "Could not get user information", $lang['Error'], __LINE__, __FILE__, $sql);
+ message_die(ERROR, "Could not get user information", $lang['Error'], __LINE__, __FILE__, $sql);
}
if ( !($row = $db->sql_fetchrow($result)) )
@@ -490,7 +490,7 @@ else if ( $group_id )
$message = $lang['Could_not_add_user'] . "<br /><br />" . sprintf($lang['Click_return_group'], "<a href=\"" . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_index'], "<a href=\"" . append_sid("index.$phpEx") . "\">", "</a>");
- message_die(GENERAL_MESSAGE, $message);
+ message_die(MESSAGE, $message);
}
if ( $row['user_id'] == ANONYMOUS )
@@ -501,7 +501,7 @@ else if ( $group_id )
$message = $lang['Could_not_anon_user'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
+ message_die(MESSAGE, $message);
}
$sql = "SELECT ug.user_id, u.user_level
@@ -511,7 +511,7 @@ else if ( $group_id )
AND ug.group_id = $group_id";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not get user information', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not get user information', '', __LINE__, __FILE__, $sql);
}
if ( !($db->sql_fetchrow($result)) )
@@ -520,7 +520,7 @@ else if ( $group_id )
VALUES (" . $row['user_id'] . ", $group_id, 0)";
if ( !$db->sql_query($sql) )
{
- message_die(GENERAL_ERROR, 'Could not add user to group', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not add user to group', '', __LINE__, __FILE__, $sql);
}
if ( $row['user_level'] != ADMIN && $row['user_level'] != MOD && $group_info['auth_mod'] )
@@ -530,7 +530,7 @@ else if ( $group_id )
WHERE user_id = " . $row['user_id'];
if ( !$db->sql_query($sql) )
{
- message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
}
}
@@ -543,7 +543,7 @@ else if ( $group_id )
WHERE group_id = $group_id";
if ( !($result = $db->sql_query($group_sql)) )
{
- message_die(GENERAL_ERROR, 'Could not get group information', '', __LINE__, __FILE__, $group_sql);
+ message_die(ERROR, 'Could not get group information', '', __LINE__, __FILE__, $group_sql);
}
$group_name_row = $db->sql_fetchrow($result);
@@ -578,7 +578,7 @@ else if ( $group_id )
$message = $lang['User_is_member_group'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
+ message_die(MESSAGE, $message);
}
}
else
@@ -604,7 +604,7 @@ else if ( $group_id )
AND user_level NOT IN (" . MOD . ", " . ADMIN . ")";
if ( !$db->sql_query($sql) )
{
- message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
}
}
@@ -629,7 +629,7 @@ else if ( $group_id )
ORDER BY ug.user_id, ug.group_id";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not obtain moderator status', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not obtain moderator status', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
@@ -659,7 +659,7 @@ else if ( $group_id )
AND user_level NOT IN (" . ADMIN . ")";
if ( !$db->sql_query($sql) )
{
- message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
}
}
}
@@ -672,7 +672,7 @@ else if ( $group_id )
if ( !$db->sql_query($sql) )
{
- message_die(GENERAL_ERROR, 'Could not update user group table', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not update user group table', '', __LINE__, __FILE__, $sql);
}
//
@@ -682,7 +682,7 @@ else if ( $group_id )
{
if ( !($result = $db->sql_query($sql_select)) )
{
- message_die(GENERAL_ERROR, 'Could not get user email information', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not get user email information', '', __LINE__, __FILE__, $sql);
}
$email_addresses = '';
@@ -699,7 +699,7 @@ else if ( $group_id )
WHERE group_id = $group_id";
if ( !($result = $db->sql_query($group_sql)) )
{
- message_die(GENERAL_ERROR, 'Could not get group information', '', __LINE__, __FILE__, $group_sql);
+ message_die(ERROR, 'Could not get group information', '', __LINE__, __FILE__, $group_sql);
}
$group_name_row = $db->sql_fetchrow($result);
@@ -734,7 +734,7 @@ else if ( $group_id )
}
else
{
- message_die(GENERAL_MESSAGE, $lang['No_groups_exist']);
+ message_die(MESSAGE, $lang['No_groups_exist']);
}
//
@@ -746,12 +746,12 @@ else if ( $group_id )
AND group_single_user = 0";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
}
if ( !($group_info = $db->sql_fetchrow($result)) )
{
- message_die(GENERAL_MESSAGE, $lang['Group_not_exist']);
+ message_die(MESSAGE, $lang['Group_not_exist']);
}
//
@@ -762,7 +762,7 @@ else if ( $group_id )
WHERE user_id = " . $group_info['group_moderator'];
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Error getting user list for group', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Error getting user list for group', '', __LINE__, __FILE__, $sql);
}
$group_moderator = $db->sql_fetchrow($result);
@@ -779,7 +779,7 @@ else if ( $group_id )
ORDER BY u.username";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Error getting user list for group', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Error getting user list for group', '', __LINE__, __FILE__, $sql);
}
$group_members = $db->sql_fetchrowset($result);
@@ -795,7 +795,7 @@ else if ( $group_id )
ORDER BY u.username";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Error getting user pending information', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Error getting user pending information', '', __LINE__, __FILE__, $sql);
}
$modgroup_pending_list = $db->sql_fetchrowset($result);
@@ -1153,7 +1153,7 @@ else
ORDER BY g.group_name, ug.user_id";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
@@ -1192,7 +1192,7 @@ else
ORDER BY g.group_name";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
}
$s_group_list_opt = '';
@@ -1261,7 +1261,7 @@ else
}
else
{
- message_die(GENERAL_MESSAGE, $lang['No_groups_exist']);
+ message_die(MESSAGE, $lang['No_groups_exist']);
}
}
diff --git a/phpBB/index.php b/phpBB/index.php
index e3c57ee5e5..d63a1970cb 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -8,7 +8,6 @@
*
* $Id$
*
- *
***************************************************************************/
/***************************************************************************
@@ -28,15 +27,21 @@ include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
-$userdata = session_pagestart($user_ip, PAGE_INDEX);
-init_userprefs($userdata);
+$userdata = $session->start();
+$acl = new auth('list', $userdata);
//
// End session management
//
-$viewcat = ( !empty($HTTP_GET_VARS[POST_CAT_URL]) ) ? $HTTP_GET_VARS[POST_CAT_URL] : -1;
+//
+// Configure style, language, etc.
+//
+$session->configure($userdata);
+
+$viewcat = ( !empty($HTTP_GET_VARS['c']) ) ? intval($HTTP_GET_VARS['c']) : -1;
+$forum_id = ( !empty($HTTP_GET_VARS['f']) ) ? intval($HTTP_GET_VARS['f']) : 0;
-if( isset($HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']) )
+if ( isset($HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']) )
{
$mark_read = ( isset($HTTP_POST_VARS['mark']) ) ? $HTTP_POST_VARS['mark'] : $HTTP_GET_VARS['mark'];
}
@@ -48,46 +53,41 @@ else
//
// Handle marking posts
//
-if( $mark_read == 'forums' )
+if ( $mark_read == 'forums' )
{
- if( $userdata['session_logged_in'] )
+ if ( $userdata['user_id'] != ANONYMOUS )
{
setcookie($board_config['cookie_name'] . '_f_all', time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
}
$template->assign_vars(array(
- "META" => '<meta http-equiv="refresh" content="3;url=' .append_sid("index.$phpEx") . '">')
+ 'META' => '<meta http-equiv="refresh" content="3;url=' . "index.$phpEx$SID" . '">')
);
- $message = $lang['Forums_marked_read'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a> ');
-
- message_die(GENERAL_MESSAGE, $message);
+ $message = $lang['Forums_marked_read'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . "index.$phpEx$SID" . '">', '</a> ');
+ message_die(MESSAGE, $message);
}
//
// End handle marking posts
//
-$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
-$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();
+$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
+$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
//
// If you don't use these stats on your index you may want to consider
// removing them
//
$total_posts = get_db_stat('postcount');
-//$total_users = get_db_stat('usercount');
-//$newest_userdata = get_db_stat('newestuser');
-//$newest_user = $newest_userdata['username'];
-//$newest_uid = $newest_userdata['user_id'];
$total_users = $board_config['num_users'];
$newest_user = $board_config['newest_username'];
$newest_uid = $board_config['newest_user_id'];
-if( $total_posts == 0 )
+if ( $total_posts == 0 )
{
$l_total_post_s = $lang['Posted_articles_zero_total'];
}
-else if( $total_posts == 1 )
+else if ( $total_posts == 1 )
{
$l_total_post_s = $lang['Posted_article_total'];
}
@@ -96,11 +96,11 @@ else
$l_total_post_s = $lang['Posted_articles_total'];
}
-if( $total_users == 0 )
+if ( $total_users == 0 )
{
$l_total_user_s = $lang['Registered_users_zero_total'];
}
-else if( $total_users == 1 )
+else if ( $total_users == 1 )
{
$l_total_user_s = $lang['Registered_user_total'];
}
@@ -110,43 +110,191 @@ else
}
+/*
+switch ( SQL_LAYER )
+{
+ case 'oracle':
+ break;
+
+ default:
+ $sql = "SELECT f1.*, p.post_time, p.post_username, u.username, u.user_id
+ FROM ((( " . FORUMS_TABLE . " f1
+ LEFT JOIN " . FORUMS_TABLE . " f2
+ LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f2.forum_last_post_id )
+ LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
+ WHERE f1.forum_left_id BETWEEN f2.forum_left_id AND f2.forum_right_id
+ ORDER BY f2.forum_id";
+ break;
+}
+$result = $db->sql_query($sql);
+
+$forum_data = array();
+if ( $row = $db->sql_fetchrow($result) )
+{
+ do
+ {
+ $forum_data[] = $row;
+ }
+ while ( $row = $db->sql_fetchrow($result) );
+
+ $total_forums = sizeof($forum_data);
+}
+
+if ( $total_forums > 1 )
+{
+ $last_forum_right_id = 0;
+ for( $i = 0; $i < $total_forums; $i++)
+ {
+ $row_forum_id = $forum_data[$i]['forum_id'];
+
+ //
+ // A non-postable forum on the index is treated as a category
+ //
+ if ( $forum_data[$i]['forum_status'] == 2 || $row_forum_id == $forum_id )
+ {
+ $template->assign_block_vars('catrow', array(
+ 'CAT_ID' => $forum_id,
+ 'CAT_DESC' => $forum_data[$i]['forum_name'],
+ 'U_VIEWCAT' => "index.$phpEx?$SID&amp;" . POST_FORUM_URL . "=$forum_id")
+ );
+
+ $current_parent = $row_forum_id;
+ }
+ else
+ {
+ if ( $forum_data[$i]['parent_id'] == $current_parent )
+ {
+ if ( $acl->get_acl($row_forum_id, 'forum', 'list') )
+ {
+ if ( $forum_data[$i]['forum_status'] == FORUM_LOCKED )
+ {
+ $folder_image = $theme['forum_locked'];
+ $folder_alt = $lang['Forum_locked'];
+ }
+ else
+ {
+ $unread_topics = false;
+ if ( $userdata['user_id'] != ANONYMOUS )
+ {
+ if ( !empty($new_topic_data[$row_forum_id]) )
+ {
+ $forum_last_post_time = 0;
+
+ while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$row_forum_id]) )
+ {
+ if ( empty($tracking_topics[$check_topic_id]) )
+ {
+ $unread_topics = true;
+ $forum_last_post_time = max($check_post_time, $forum_last_post_time);
+
+ }
+ else
+ {
+ if ( $tracking_topics[$check_topic_id] < $check_post_time )
+ {
+ $unread_topics = true;
+ $forum_last_post_time = max($check_post_time, $forum_last_post_time);
+ }
+ }
+ }
+
+ if ( !empty($tracking_forums[$row_forum_id]) )
+ {
+ if ( $tracking_forums[$row_forum_id] > $forum_last_post_time )
+ {
+ $unread_topics = false;
+ }
+ }
+
+ 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;
+ }
+ }
+
+ }
+ }
+
+ $folder_image = ( $unread_topics ) ? $theme['forum_new'] : $theme['forum'];
+ $folder_alt = ( $unread_topics ) ? $lang['New_posts'] : $lang['No_new_posts'];
+ }
+
+ $posts = $forum_data[$i]['forum_posts'];
+ $topics = $forum_data[$i]['forum_topics'];
+
+ if ( $forum_data[$i]['forum_last_post_id'] )
+ {
+ $last_post_time = create_date($board_config['default_dateformat'], $forum_data[$i]['post_time'], $board_config['board_timezone']);
+
+ $last_post = $last_post_time . '<br />';
+
+ $last_post .= ( $forum_data[$i]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$i]['post_username'] != '' ) ? $forum_data[$i]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . "profile.$phpEx$SID&amp;mode=viewprofile&amp;" . POST_USERS_URL . '=' . $forum_data[$i]['user_id'] . '">' . $forum_data[$i]['username'] . '</a> ';
+
+ $last_post .= '<a href="' . "viewtopic.$phpEx$SID&amp;" . POST_POST_URL . '=' . $forum_data[$i]['forum_last_post_id'] . '#' . $forum_data[$i]['forum_last_post_id'] . '"><img src="' . $theme['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
+ }
+ else
+ {
+ $last_post = $lang['No_Posts'];
+ }
+
+ if ( count($forum_moderators[$row_forum_id]) > 0 )
+ {
+ $l_moderators = ( count($forum_moderators[$row_forum_id]) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
+ $moderator_list = implode(', ', $forum_moderators[$row_forum_id]);
+ }
+ else
+ {
+ $l_moderators = '&nbsp;';
+ $moderator_list = '&nbsp;';
+ }
+
+ $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
+ $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
+
+ $template->assign_block_vars('catrow.forumrow', array(
+ 'ROW_COLOR' => '#' . $row_color,
+ 'ROW_CLASS' => $row_class,
+ 'FORUM_FOLDER_IMG' => $folder_image,
+ 'FORUM_NAME' => $forum_data[$i]['forum_name'],
+ 'FORUM_DESC' => $forum_data[$i]['forum_desc'],
+ 'POSTS' => $forum_data[$i]['forum_posts'],
+ 'TOPICS' => $forum_data[$i]['forum_topics'],
+ 'LAST_POST' => $last_post,
+ 'MODERATORS' => $moderator_list,
+
+ 'L_MODERATOR' => $l_moderators,
+ 'L_FORUM_FOLDER_ALT' => $folder_alt,
+
+ 'U_VIEWFORUM' => "viewforum.$phpEx$SID&amp;" . POST_FORUM_URL . "=$row_forum_id")
+ );
+ }
+ }
+ }
+ }
+
+ $template->assign_var_from_handle('SUB_FORUM', 'forum');
+}
+*/
+
//
// Start page proper
//
$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
FROM " . CATEGORIES_TABLE . " c
ORDER BY c.cat_order";
-if( !($result = $db->sql_query($sql)) )
-{
- message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
-}
+$result = $db->sql_query($sql);
-while( $category_rows[] = $db->sql_fetchrow($result) );
+while ( $category_rows[] = $db->sql_fetchrow($result) );
-if( ( $total_categories = count($category_rows) ) )
+if ( ( $total_categories = count($category_rows) ) )
{
//
// Define appropriate SQL
//
- switch(SQL_LAYER)
+ switch ( SQL_LAYER )
{
- case 'postgresql':
- $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
- FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
- WHERE p.post_id = f.forum_last_post_id
- AND u.user_id = p.poster_id
- UNION (
- SELECT f.*, NULL, NULL, NULL, NULL
- FROM " . FORUMS_TABLE . " f
- WHERE NOT EXISTS (
- SELECT p.post_time
- FROM " . POSTS_TABLE . " p
- WHERE p.post_id = f.forum_last_post_id
- )
- )
- ORDER BY cat_id, forum_order";
- break;
-
case 'oracle':
$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
@@ -163,37 +311,26 @@ if( ( $total_categories = count($category_rows) ) )
ORDER BY f.cat_id, f.forum_order";
break;
}
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql);
- }
+ $result = $db->sql_query($sql);
$forum_data = array();
- while( $row = $db->sql_fetchrow($result) )
+ while ( $row = $db->sql_fetchrow($result) )
{
$forum_data[] = $row;
}
- if ( !($total_forums = count($forum_data)) )
- {
- message_die(GENERAL_MESSAGE, $lang['No_forums']);
- }
-
//
// Obtain a list of topic ids which contain
// posts made since user last visited
//
- if ( $userdata['session_logged_in'] )
+/* if ( $userdata['user_id'] != ANONYMOUS )
{
$sql = "SELECT t.forum_id, t.topic_id, p.post_time
FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
WHERE p.post_id = t.topic_last_post_id
AND p.post_time > " . $userdata['user_lastvisit'] . "
AND t.topic_moved_id = 0";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql);
- }
+ $result = $db->sql_query($sql);
$new_topic_data = array();
while( $topic_data = $db->sql_fetchrow($result) )
@@ -201,74 +338,22 @@ if( ( $total_categories = count($category_rows) ) )
$new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time'];
}
}
-
+*/
//
// Obtain list of moderators of each forum
// First users, then groups ... broken into two queries
//
- $sql = "SELECT aa.forum_id, u.user_id, u.username
- FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
- WHERE aa.auth_mod = " . TRUE . "
- AND g.group_single_user = 1
- AND ug.group_id = aa.group_id
- AND g.group_id = aa.group_id
- AND u.user_id = ug.user_id
- GROUP BY u.user_id, u.username, aa.forum_id
- ORDER BY aa.forum_id, u.user_id";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
- }
-
$forum_moderators = array();
- while( $row = $db->sql_fetchrow($result) )
- {
- $forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $row['username'] . '</a>';
- }
-
- $sql = "SELECT aa.forum_id, g.group_id, g.group_name
- FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
- WHERE aa.auth_mod = " . TRUE . "
- AND g.group_single_user = 0
- AND g.group_type <> " . GROUP_HIDDEN . "
- AND ug.group_id = aa.group_id
- AND g.group_id = aa.group_id
- GROUP BY g.group_id, g.group_name, aa.forum_id
- ORDER BY aa.forum_id, g.group_id";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
- }
-
- while( $row = $db->sql_fetchrow($result) )
- {
- $forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
- }
-
- //
- // Find which forums are visible for this user
- //
- $is_auth_ary = array();
- $is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_data);
-
- //
- // Start output of page
- //
- $page_title = $lang['Index'];
- include($phpbb_root_path . 'includes/page_header.'.$phpEx);
-
- $template->set_filenames(array(
- 'body' => 'index_body.tpl')
- );
+ get_moderators($forum_moderators);
$template->assign_vars(array(
'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts),
'TOTAL_USERS' => sprintf($l_total_user_s, $total_users),
- 'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$newest_uid") . '">', $newest_user, '</a>'),
+ 'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' . "profile.$phpEx$SID&amp;mode=viewprofile&amp;u=$newest_uid" . '">', $newest_user, '</a>'),
- 'FORUM_IMG' => $images['forum'],
- 'FORUM_NEW_IMG' => $images['forum_new'],
- 'FORUM_LOCKED_IMG' => $images['forum_locked'],
+ 'FORUM_IMG' => create_img($theme['forum'], $lang['No_new_posts']),
+ 'FORUM_NEW_IMG' => create_img($theme['forum_new'], $lang['New_posts']),
+ 'FORUM_LOCKED_IMG' => create_img($theme['forum_locked'], $lang['No_new_posts_locked']),
'L_FORUM' => $lang['Forum'],
'L_TOPICS' => $lang['Topics'],
@@ -282,11 +367,15 @@ if( ( $total_categories = count($category_rows) ) )
'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'],
'L_ONLINE_EXPLAIN' => $lang['Online_explain'],
- 'L_MODERATOR' => $lang['Moderators'],
+ 'L_VIEW_MODERATORS' => $lang['View_moderators'],
'L_FORUM_LOCKED' => $lang['Forum_is_locked'],
'L_MARK_FORUMS_READ' => $lang['Mark_all_forums'],
+ 'L_LEGEND' => $lang['Legend'],
+ 'L_NO_FORUMS' => $lang['No_forums'],
- 'U_MARK_READ' => append_sid("index.$phpEx?mark=forums"))
+ 'S_LEGEND' => $legend,
+
+ 'U_MARK_READ' => "index.$phpEx$SID&amp;mark=forums")
);
//
@@ -300,9 +389,9 @@ if( ( $total_categories = count($category_rows) ) )
// Should we display this category/forum set?
//
$display_forums = false;
- for($j = 0; $j < $total_forums; $j++)
+ for($j = 0; $j < sizeof($forum_data); $j++)
{
- if ( $is_auth_ary[$forum_data[$j]['forum_id']]['auth_view'] && $forum_data[$j]['cat_id'] == $cat_id )
+ if ( $acl->get_acl($forum_data[$j]['forum_id'], 'forum', 'list') && $forum_data[$j]['cat_id'] == $cat_id )
{
$display_forums = true;
}
@@ -317,34 +406,35 @@ if( ( $total_categories = count($category_rows) ) )
$template->assign_block_vars('catrow', array(
'CAT_ID' => $cat_id,
'CAT_DESC' => $category_rows[$i]['cat_title'],
- 'U_VIEWCAT' => append_sid("index.$phpEx?" . POST_CAT_URL . "=$cat_id"))
+ 'U_VIEWCAT' => "index.$phpEx$SID&amp;c=$cat_id",
+ 'HAVE_FORUMS' => true)
);
if ( $viewcat == $cat_id || $viewcat == -1 )
{
- for($j = 0; $j < $total_forums; $j++)
+ for($j = 0; $j < sizeof($forum_data); $j++)
{
if ( $forum_data[$j]['cat_id'] == $cat_id )
{
- $forum_id = $forum_data[$j]['forum_id'];
+ $row_forum_id = $forum_data[$j]['forum_id'];
- if ( $is_auth_ary[$forum_id]['auth_view'] )
+ if ( $acl->get_acl($row_forum_id, 'forum', 'list') )
{
if ( $forum_data[$j]['forum_status'] == FORUM_LOCKED )
{
- $folder_image = $images['forum_locked'];
+ $folder_image = $theme['forum_locked'];
$folder_alt = $lang['Forum_locked'];
}
else
{
$unread_topics = false;
- if ( $userdata['session_logged_in'] )
+ if ( $userdata['user_id'] != ANONYMOUS )
{
- if ( !empty($new_topic_data[$forum_id]) )
+ if ( !empty($new_topic_data[$row_forum_id]) )
{
$forum_last_post_time = 0;
- while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
+ foreach ( $new_topic_data[$row_forum_id] as $check_topic_id => $check_post_time )
{
if ( empty($tracking_topics[$check_topic_id]) )
{
@@ -362,9 +452,9 @@ if( ( $total_categories = count($category_rows) ) )
}
}
- if ( !empty($tracking_forums[$forum_id]) )
+ if ( !empty($tracking_forums[$row_forum_id]) )
{
- if ( $tracking_forums[$forum_id] > $forum_last_post_time )
+ if ( $tracking_forums[$row_forum_id] > $forum_last_post_time )
{
$unread_topics = false;
}
@@ -381,7 +471,7 @@ if( ( $total_categories = count($category_rows) ) )
}
}
- $folder_image = ( $unread_topics ) ? $images['forum_new'] : $images['forum'];
+ $folder_image = ( $unread_topics ) ? $theme['forum_new'] : $theme['forum'];
$folder_alt = ( $unread_topics ) ? $lang['New_posts'] : $lang['No_new_posts'];
}
@@ -394,19 +484,19 @@ if( ( $total_categories = count($category_rows) ) )
$last_post = $last_post_time . '<br />';
- $last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';
+ $last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . "profile.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $forum_data[$j]['user_id'] . '">' . $forum_data[$j]['username'] . '</a> ';
- $last_post .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
+ $last_post .= '<a href="' . "viewtopic.$phpEx$SID&amp;f=$row_forum_id&amp;p=" . $forum_data[$j]['forum_last_post_id'] . '#' . $forum_data[$j]['forum_last_post_id'] . '">' . create_img($theme['goto_post_latest'], $lang['View_latest_post']) . '</a>';
}
else
{
$last_post = $lang['No_Posts'];
}
- if ( count($forum_moderators[$forum_id]) > 0 )
+ if ( count($forum_moderators[$row_forum_id]) > 0 )
{
- $l_moderators = ( count($forum_moderators[$forum_id]) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
- $moderator_list = implode(', ', $forum_moderators[$forum_id]);
+ $l_moderators = ( count($forum_moderators[$row_forum_id]) == 1 ) ? $lang['Moderator'] . ':' : $lang['Moderators'] . ':' ;
+ $moderator_list = implode(', ', $forum_moderators[$row_forum_id]);
}
else
{
@@ -414,13 +504,9 @@ if( ( $total_categories = count($category_rows) ) )
$moderator_list = '&nbsp;';
}
- $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
- $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
-
$template->assign_block_vars('catrow.forumrow', array(
- 'ROW_COLOR' => '#' . $row_color,
- 'ROW_CLASS' => $row_class,
- 'FORUM_FOLDER_IMG' => $folder_image,
+ 'ROW_COUNT' => $i,
+ 'FORUM_FOLDER_IMG' => create_img($folder_image, $folder_alt),
'FORUM_NAME' => $forum_data[$j]['forum_name'],
'FORUM_DESC' => $forum_data[$j]['forum_desc'],
'POSTS' => $forum_data[$j]['forum_posts'],
@@ -428,10 +514,12 @@ if( ( $total_categories = count($category_rows) ) )
'LAST_POST' => $last_post,
'MODERATORS' => $moderator_list,
+ 'FORUM_IMG' => $forum_data[$j]['forum_image'],
+
'L_MODERATOR' => $l_moderators,
'L_FORUM_FOLDER_ALT' => $folder_alt,
- 'U_VIEWFORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
+ 'U_VIEWFORUM' => "viewforum.$phpEx$SID&amp;f=$row_forum_id")
);
}
}
@@ -441,15 +529,16 @@ if( ( $total_categories = count($category_rows) ) )
} // for ... categories
}// if ... total_categories
-else
-{
- message_die(GENERAL_MESSAGE, $lang['No_forums']);
-}
//
-// Generate the page
+// Start output of page
//
-$template->pparse('body');
+$page_title = $lang['Index'];
+include($phpbb_root_path . 'includes/page_header.'.$phpEx);
+
+$template->set_filenames(array(
+ 'body' => 'index_body.html')
+);
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
diff --git a/phpBB/login.php b/phpBB/login.php
index c37c9954b9..425d934fcb 100644
--- a/phpBB/login.php
+++ b/phpBB/login.php
@@ -24,8 +24,7 @@
// Allow people to reach login page if
// board is shut down
//
-define("IN_LOGIN", true);
-
+define('IN_LOGIN', true);
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
@@ -34,75 +33,66 @@ include($phpbb_root_path . 'common.'.$phpEx);
//
// Set page ID for session management
//
-$userdata = session_pagestart($user_ip, PAGE_LOGIN);
-init_userprefs($userdata);
+$userdata = $session->start();
//
// End session management
//
+//
+// Configure style, language, etc.
+//
+$session->configure($userdata);
+
$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
-if( isset($HTTP_POST_VARS['login']) || isset($HTTP_GET_VARS['login']) || isset($HTTP_POST_VARS['logout']) || isset($HTTP_GET_VARS['logout']) )
+if ( isset($HTTP_POST_VARS['login']) || isset($HTTP_GET_VARS['login']) || isset($HTTP_POST_VARS['logout']) || isset($HTTP_GET_VARS['logout']) )
{
//
// This appears to work for IIS5 CGI under Win2K. Uses getenv
// since this doesn't exist for ISAPI mode and therefore the
// normal Location redirector is used in preference
//
- if( ( isset($HTTP_POST_VARS['login']) || isset($HTTP_GET_VARS['login']) ) && !$userdata['session_logged_in'] )
+ if ( ( isset($HTTP_POST_VARS['login']) || isset($HTTP_GET_VARS['login']) ) && !$userdata['session_logged_in'] )
{
- $username = isset($HTTP_POST_VARS['username']) ? $HTTP_POST_VARS['username'] : '';
- $password = isset($HTTP_POST_VARS['password']) ? $HTTP_POST_VARS['password'] : '';
+ $username = ( isset($HTTP_POST_VARS['username']) ) ? $HTTP_POST_VARS['username'] : '';
+ $password = ( isset($HTTP_POST_VARS['password']) ) ? $HTTP_POST_VARS['password'] : '';
- $sql = "SELECT user_id, username, user_password, user_active, user_level
+ $sql = "SELECT user_id, username, user_email, user_password, user_active, user_level
FROM " . USERS_TABLE . "
WHERE username = '" . str_replace("\'", "''", $username) . "'";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Error in obtaining userdata', '', __LINE__, __FILE__, $sql);
- }
+ $result = $db->sql_query($sql);
- if( $row = $db->sql_fetchrow($result) )
+ if ( $row = $db->sql_fetchrow($result) )
{
- if( $row['user_level'] != ADMIN && $board_config['board_disable'] )
+ if ( $row['user_level'] != ADMIN && $board_config['board_disable'] )
{
- header($header_location . append_sid("index.$phpEx", true));
+ header($header_location . "index.$phpEx$SID");
+ exit;
}
else
{
- if( md5($password) == $row['user_password'] && $row['user_active'] )
+ if ( md5($password) == $row['user_password'] && $row['user_active'] )
{
- $autologin = ( isset($HTTP_POST_VARS['autologin']) ) ? TRUE : 0;
+ $autologin = ( isset($HTTP_POST_VARS['autologin']) ) ? md5($password) : '';
+ $this_page = ( !empty($HTTP_SERVER_VARS['PHP_SELF']) ) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_ENV_VARS['PHP_SELF'];
+ $this_page .= '&' . ( ( !empty($HTTP_SERVER_VARS['QUERY_STRING']) ) ? $HTTP_SERVER_VARS['QUERY_STRING'] : $HTTP_ENV_VARS['QUERY_STRING'] );
+ $session_browser = ( !empty($HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) ? $HTTP_SERVER_VARS['HTTP_USER_AGENT'] : $HTTP_ENV_VARS['HTTP_USER_AGENT'];
- $session_id = session_begin($row['user_id'], $user_ip, PAGE_INDEX, FALSE, $autologin);
+ $userdata = $session->create($userdata['session_id'], $row['user_id'], $autologin, $this_page, $session_browser);
- if( $session_id )
- {
- if( !empty($HTTP_POST_VARS['redirect']) )
- {
- header($header_location . append_sid($HTTP_POST_VARS['redirect'], true));
- }
- else
- {
- header($header_location . append_sid("index.$phpEx", true));
- }
- }
- else
- {
- message_die(CRITICAL_ERROR, "Couldn't start session : login", "", __LINE__, __FILE__);
- }
+ header($header_location . $HTTP_POST_VARS['redirect']);
+ exit;
}
else
{
$redirect = ( !empty($HTTP_POST_VARS['redirect']) ) ? $HTTP_POST_VARS['redirect'] : '';
$template->assign_vars(array(
- 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("login.$phpEx?redirect=$redirect") . '">')
+ 'META' => '<meta http-equiv="refresh" content="3;url=' . "login.$phpEx$SID&amp;redirect=$redirect" . '">')
);
- $message = $lang['Error_login'] . '<br /><br />' . sprintf($lang['Click_return_login'], '<a href="' . append_sid("login.$phpEx?redirect=$redirect") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
-
- message_die(GENERAL_MESSAGE, $message);
+ $message = $lang['Error_login'] . '<br /><br />' . sprintf($lang['Click_return_login'], '<a href="' . "login.$phpEx$SID&amp;redirect=$redirect" . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . "index.$phpEx$SID" . '">', '</a>');
+ message_die(MESSAGE, $message);
}
}
}
@@ -111,41 +101,21 @@ if( isset($HTTP_POST_VARS['login']) || isset($HTTP_GET_VARS['login']) || isset($
$redirect = ( !empty($HTTP_POST_VARS['redirect']) ) ? $HTTP_POST_VARS['redirect'] : "";
$template->assign_vars(array(
- 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("login.$phpEx?redirect=$redirect") . '">')
+ 'META' => '<meta http-equiv="refresh" content="3;url=' . "login.$phpEx$SID&amp;redirect=$redirect" . '">')
);
- $message = $lang['Error_login'] . '<br /><br />' . sprintf($lang['Click_return_login'], '<a href="' . append_sid("login.$phpEx?redirect=$redirect") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
-
- message_die(GENERAL_MESSAGE, $message);
- }
- }
- else if( ( isset($HTTP_GET_VARS['logout']) || isset($HTTP_POST_VARS['logout']) ) && $userdata['session_logged_in'] )
- {
- if( $userdata['session_logged_in'] )
- {
- session_end($userdata['session_id'], $userdata['user_id']);
- }
-
- if( !empty($HTTP_POST_VARS['redirect']) )
- {
- header($header_location . append_sid($HTTP_POST_VARS['redirect'], true));
- }
- else
- {
- header($header_location . append_sid("index.$phpEx", true));
+ $message = $lang['Error_login'] . '<br /><br />' . sprintf($lang['Click_return_login'], '<a href="' . "login.$phpEx$SID&amp;redirect=$redirect" . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . "index.$phpEx$SID" . '">', '</a>');
+ message_die(MESSAGE, $message);
}
}
- else
+ else if ( ( isset($HTTP_GET_VARS['logout']) || isset($HTTP_POST_VARS['logout']) ) && $userdata['user_id'] != ANONYMOUS )
{
- if( !empty($HTTP_POST_VARS['redirect']) )
- {
- header($header_location . append_sid($HTTP_POST_VARS['redirect'], true));
- }
- else
- {
- header($header_location . append_sid("index.$phpEx", true));
- }
+ $session->destroy($userdata);
}
+
+ $redirect = ( !empty($HTTP_POST_VARS['redirect']) ) ? $HTTP_POST_VARS['redirect'] : "index.$phpEx$SID";
+ header($header_location . $redirect);
+ exit;
}
else
{
@@ -153,34 +123,27 @@ else
// Do a full login page dohickey if
// user not already logged in
//
- if( !$userdata['session_logged_in'] )
+ if ( $userdata['user_id'] == ANONYMOUS )
{
- $page_title = $lang['Login'];
- include($phpbb_root_path . 'includes/page_header.'.$phpEx);
-
- $template->set_filenames(array(
- 'body' => 'login_body.tpl')
- );
-
- if( isset($HTTP_POST_VARS['redirect']) || isset($HTTP_GET_VARS['redirect']) )
+ if ( isset($HTTP_POST_VARS['redirect']) || isset($HTTP_GET_VARS['redirect']) )
{
$forward_to = $HTTP_SERVER_VARS['QUERY_STRING'];
- if( preg_match("/^redirect=(.*)$/si", $forward_to, $forward_matches) )
+ if ( preg_match('/^redirect=(.*)$/si', $forward_to, $forward_matches) )
{
$forward_to = ( !empty($forward_matches[3]) ) ? $forward_matches[3] : $forward_matches[1];
$forward_match = explode('&', $forward_to);
- if(count($forward_match) > 1)
+ if ( count($forward_match) > 1 )
{
$forward_page = '';
for($i = 1; $i < count($forward_match); $i++)
{
- if( !ereg("sid=", $forward_match[$i]) )
+ if ( !ereg('sid=', $forward_match[$i]) )
{
- if( $forward_page != '' )
+ if ( $forward_page != '' )
{
$forward_page .= '&';
}
@@ -201,29 +164,31 @@ else
$forward_page = '';
}
- $username = ( $userdata['user_id'] != ANONYMOUS ) ? $userdata['username'] : '';
-
- $s_hidden_fields = '<input type="hidden" name="redirect" value="' . $forward_page . '" />';
-
- make_jumpbox('viewforum.'.$phpEx, $forum_id);
$template->assign_vars(array(
- 'USERNAME' => $username,
+ 'USERNAME' => ( $userdata['user_id'] != ANONYMOUS ) ? $userdata['username'] : '',
'L_ENTER_PASSWORD' => $lang['Enter_password'],
'L_SEND_PASSWORD' => $lang['Forgotten_password'],
- 'U_SEND_PASSWORD' => append_sid("profile.$phpEx?mode=sendpassword"),
+ 'U_SEND_PASSWORD' => "profile.$phpEx$SID&amp;mode=sendpassword",
- 'S_HIDDEN_FIELDS' => $s_hidden_fields)
+ 'S_HIDDEN_FIELDS' => '<input type="hidden" name="redirect" value="' . $forward_page . '" />')
);
- $template->pparse('body');
+ $page_title = $lang['Login'];
+ include($phpbb_root_path . 'includes/page_header.'.$phpEx);
+
+ $template->set_filenames(array(
+ 'body' => 'login_body.html')
+ );
+ make_jumpbox('viewforum.'.$phpEx, $forum_id);
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
else
{
- header($header_location . append_sid("index.$phpEx", true));
+ header($header_location . "index.$phpEx$SID");
+ exit;
}
}
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index 99b51bb36a..2ef335f0fc 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -27,19 +27,24 @@ include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
-$userdata = session_pagestart($user_ip, PAGE_VIEWMEMBERS);
-init_userprefs($userdata);
+$userdata = $session->start();
+$acl = new auth('list', $userdata);
//
// End session management
//
-$start = ( isset($HTTP_GET_VARS['start']) ) ? $HTTP_GET_VARS['start'] : 0;
+//
+// Configure style, language, etc.
+//
+$session->configure($userdata);
-if(isset($HTTP_POST_VARS['order']))
+$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
+
+if ( isset($HTTP_POST_VARS['order']) )
{
$sort_order = ($HTTP_POST_VARS['order'] == 'ASC') ? 'ASC' : 'DESC';
}
-else if(isset($HTTP_GET_VARS['order']))
+else if ( isset($HTTP_GET_VARS['order']) )
{
$sort_order = ($HTTP_GET_VARS['order'] == 'ASC') ? 'ASC' : 'DESC';
}
@@ -58,33 +63,32 @@ $select_sort_mode = '<select name="mode">';
for($i = 0; $i < count($mode_types_text); $i++)
{
$selected = ( $mode == $mode_types[$i] ) ? ' selected="selected"' : '';
- $select_sort_mode .= "<option value=\"" . $mode_types[$i] . "\"$selected>" . $mode_types_text[$i] . "</option>";
+ $select_sort_mode .= '<option value="' . $mode_types[$i] . '"' . $selected . '>' . $mode_types_text[$i] . '</option>';
}
$select_sort_mode .= '</select>';
$select_sort_order = '<select name="order">';
-if($sort_order == 'ASC')
+$select_sort_order .= ( $sort_order == 'ASC' ) ? '<option value="ASC" selected="selected">' . $lang['Sort_Ascending'] . '</option><option value="DESC">' . $lang['Sort_Descending'] . '</option>' : '<option value="ASC">' . $lang['Sort_Ascending'] . '</option><option value="DESC" selected="selected">' . $lang['Sort_Descending'] . '</option>';
+$select_sort_order .= '</select>';
+
+if ( $mode != 'topten' || $board_config['topics_per_page'] < 10 )
{
- $select_sort_order .= '<option value="ASC" selected="selected">' . $lang['Sort_Ascending'] . '</option><option value="DESC">' . $lang['Sort_Descending'] . '</option>';
+ $pagination = generate_pagination("memberlist.$phpEx?mode=$mode&amp;order=$sort_order", $board_config['num_users'], $board_config['topics_per_page'], $start). '&nbsp;';
+ $total_members = $board_config['num_users'];
}
else
{
- $select_sort_order .= '<option value="ASC">' . $lang['Sort_Ascending'] . '</option><option value="DESC" selected="selected">' . $lang['Sort_Descending'] . '</option>';
+ $pagination = '&nbsp;';
+ $total_members = 10;
}
-$select_sort_order .= '</select>';
//
// Generate page
//
-$page_title = $lang['Memberlist'];
-include($phpbb_root_path . 'includes/page_header.'.$phpEx);
-
-$template->set_filenames(array(
- 'body' => 'memberlist_body.tpl')
-);
-make_jumpbox('viewforum.'.$phpEx);
-
$template->assign_vars(array(
+ 'PAGINATION' => $pagination,
+ 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $total_members / $board_config['topics_per_page'] )),
+
'L_SELECT_SORT_METHOD' => $lang['Select_sort_method'],
'L_EMAIL' => $lang['Email'],
'L_WEBSITE' => $lang['Website'],
@@ -98,10 +102,11 @@ $template->assign_vars(array(
'L_ICQ' => $lang['ICQ'],
'L_JOINED' => $lang['Joined'],
'L_POSTS' => $lang['Posts'],
+ 'L_GOTO_PAGE' => $lang['Goto_page'],
'S_MODE_SELECT' => $select_sort_mode,
'S_ORDER_SELECT' => $select_sort_order,
- 'S_MODE_ACTION' => append_sid("memberlist.$phpEx"))
+ 'S_MODE_ACTION' => "memberlist.$phpEx$SID")
);
if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
@@ -110,6 +115,9 @@ if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
switch( $mode )
{
+ case 'topten':
+ $order_by = "user_posts DESC LIMIT 10";
+ break;
case 'joined':
$order_by = "user_regdate ASC LIMIT $start, " . $board_config['topics_per_page'];
break;
@@ -128,9 +136,6 @@ if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
case 'website':
$order_by = "user_website $sort_order LIMIT $start, " . $board_config['topics_per_page'];
break;
- case 'topten':
- $order_by = "user_posts DESC LIMIT 10";
- break;
default:
$order_by = "user_regdate $sort_order LIMIT $start, " . $board_config['topics_per_page'];
break;
@@ -145,10 +150,7 @@ $sql = "SELECT username, user_id, user_viewemail, user_posts, user_regdate, user
FROM " . USERS_TABLE . "
WHERE user_id <> " . ANONYMOUS . "
ORDER BY $order_by";
-if( !($result = $db->sql_query($sql)) )
-{
- message_die(GENERAL_ERROR, 'Could not query users', '', __LINE__, __FILE__, $sql);
-}
+$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
@@ -179,11 +181,11 @@ if ( $row = $db->sql_fetchrow($result) )
}
}
- if ( !empty($row['user_viewemail']) || $userdata['user_level'] == ADMIN )
+ if ( $row['user_viewemail'] || $acl->get_acl_admin() )
{
- $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&amp;" . POST_USERS_URL .'=' . $user_id) : 'mailto:' . $row['user_email'];
+ $email_uri = ( $board_config['board_email_form'] ) ? "profile.$phpEx$SID&amp;mode=email&amp;u=" . $user_id : 'mailto:' . $row['user_email'];
- $email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>';
+ $email_img = '<a href="' . $email_uri . '">' . create_img($theme['icon_email'], $lang['Send_email']) . '</a>';
$email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';
}
else
@@ -192,21 +194,21 @@ if ( $row = $db->sql_fetchrow($result) )
$email = '&nbsp;';
}
- $temp_url = append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$user_id");
- $profile_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_profile'] . '" alt="' . $lang['Read_profile'] . '" title="' . $lang['Read_profile'] . '" border="0" /></a>';
+ $temp_url = "profile.$phpEx$SID&amp;mode=viewprofile&amp;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>';
- $temp_url = append_sid("privmsg.$phpEx?mode=post&amp;" . POST_USERS_URL . "=$user_id");
- $pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>';
+ $temp_url = "privmsg.$phpEx$SID&amp;mode=post&amp;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>';
- $www_img = ( $row['user_website'] ) ? '<a href="' . $row['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '';
+ $www_img = ( $row['user_website'] ) ? '<a href="' . $row['user_website'] . '" target="_userwww">' . create_img($theme['icon_www'], $lang['Visit_website']) . '</a>' : '';
$www = ( $row['user_website'] ) ? '<a href="' . $row['user_website'] . '" target="_userwww">' . $lang['Visit_website'] . '</a>' : '';
if ( !empty($row['user_icq']) )
{
$icq_status_img = '<a href="http://wwp.icq.com/' . $row['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>';
- $icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $row['user_icq'] . '"><img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ'] . '" title="' . $lang['ICQ'] . '" border="0" /></a>';
+ $icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $row['user_icq'] . '">' . create_img($theme['icon_icq'], $lang['ICQ']) . '</a>';
$icq = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $row['user_icq'] . '">' . $lang['ICQ'] . '</a>';
}
else
@@ -216,27 +218,22 @@ if ( $row = $db->sql_fetchrow($result) )
$icq = '';
}
- $aim_img = ( $row['user_aim'] ) ? '<a href="aim:goim?screenname=' . $row['user_aim'] . '&amp;message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : '';
+ $aim_img = ( $row['user_aim'] ) ? '<a href="aim:goim?screenname=' . $row['user_aim'] . '&amp;message=Hello+Are+you+there?">' . create_img($theme['icon_aim'], $lang['AIM']) . '</a>' : '';
$aim = ( $row['user_aim'] ) ? '<a href="aim:goim?screenname=' . $row['user_aim'] . '&amp;message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : '';
- $temp_url = append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$user_id");
- $msn_img = ( $row['user_msnm'] ) ? '<a href="' . $temp_url . '"><img src="' . $images['icon_msnm'] . '" alt="' . $lang['MSNM'] . '" title="' . $lang['MSNM'] . '" border="0" /></a>' : '';
+ $temp_url = "profile.$phpEx$SID&amp;mode=viewprofile&amp;u=$user_id";
+ $msn_img = ( $row['user_msnm'] ) ? '<a href="' . $temp_url . '">' . create_img($theme['icon_msnm'], $lang['MSNM']) . '</a>' : '';
$msn = ( $row['user_msnm'] ) ? '<a href="' . $temp_url . '">' . $lang['MSNM'] . '</a>' : '';
- $yim_img = ( $row['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&amp;.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : '';
+ $yim_img = ( $row['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&amp;.src=pg">' . create_img($theme['icon_yim'], $lang['YIM']) . '</a>' : '';
$yim = ( $row['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&amp;.src=pg">' . $lang['YIM'] . '</a>' : '';
- $temp_url = append_sid("search.$phpEx?search_author=" . urlencode($username) . "&amp;showresults=posts");
- $search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . $lang['Search_user_posts'] . '" border="0" /></a>';
+ $temp_url = "search.$phpEx$SID&amp;search_author=" . urlencode($username) . "&amp;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>';
- $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
- $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
-
$template->assign_block_vars('memberrow', array(
- 'ROW_NUMBER' => $i + ( $HTTP_GET_VARS['start'] + 1 ),
- 'ROW_COLOR' => '#' . $row_color,
- 'ROW_CLASS' => $row_class,
+ 'ROW_NUMBER' => $i + ( $start + 1 ),
'USERNAME' => $username,
'FROM' => $from,
'JOINED' => $joined,
@@ -261,8 +258,10 @@ if ( $row = $db->sql_fetchrow($result) )
'MSN' => $msn,
'YIM_IMG' => $yim_img,
'YIM' => $yim,
+
+ 'S_ROW_COUNT' => $i,
- 'U_VIEWPROFILE' => append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$user_id"))
+ 'U_VIEWPROFILE' => "profile.$phpEx$SID&amp;mode=viewprofile&amp;u=$user_id")
);
$i++;
@@ -270,38 +269,13 @@ if ( $row = $db->sql_fetchrow($result) )
while ( $row = $db->sql_fetchrow($result) );
}
-if ( $mode != 'topten' || $board_config['topics_per_page'] < 10 )
-{
- $sql = "SELECT count(*) AS total
- FROM " . USERS_TABLE . "
- WHERE user_id <> " . ANONYMOUS;
-
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Error getting total users', '', __LINE__, __FILE__, $sql);
- }
-
- if ( $total = $db->sql_fetchrow($result) )
- {
- $total_members = $total['total'];
-
- $pagination = generate_pagination("memberlist.$phpEx?mode=$mode&amp;order=$sort_order", $total_members, $board_config['topics_per_page'], $start). '&nbsp;';
- }
-}
-else
-{
- $pagination = '&nbsp;';
- $total_members = 10;
-}
-
-$template->assign_vars(array(
- 'PAGINATION' => $pagination,
- 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $total_members / $board_config['topics_per_page'] )),
+$page_title = $lang['Memberlist'];
+include($phpbb_root_path . 'includes/page_header.'.$phpEx);
- 'L_GOTO_PAGE' => $lang['Goto_page'])
+$template->set_filenames(array(
+ 'body' => 'memberlist_body.html')
);
-
-$template->pparse('body');
+make_jumpbox('viewforum.'.$phpEx);
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
diff --git a/phpBB/modcp.php b/phpBB/modcp.php
index ae38866068..d0bdc7bba1 100644
--- a/phpBB/modcp.php
+++ b/phpBB/modcp.php
@@ -37,6 +37,15 @@ include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
//
+// Start session management
+//
+$userdata = $session->start();
+$acl = new auth('forum', $userdata);
+//
+// End session management
+//
+
+//
// Obtain initial var settings
//
if ( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL]) )
@@ -76,19 +85,19 @@ if ( isset($HTTP_POST_VARS['cancel']) )
{
if ( $topic_id )
{
- $redirect = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id";
+ $redirect = "viewtopic.$phpEx$SID&" . POST_TOPIC_URL . "=$topic_id";
}
else if ( $forum_id )
{
- $redirect = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id";
+ $redirect = "viewforum.$phpEx$SID&" . POST_FORUM_URL . "=$forum_id";
}
else
{
- $redirect = "index.$phpEx";
+ $redirect = "index.$phpEx$SID";
}
$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
- header($header_location . append_sid($redirect, true));
+ header($header_location . $redirect);
}
//
@@ -168,26 +177,12 @@ else
}
//
-// Start session management
-//
-$userdata = session_pagestart($user_ip, $forum_id);
-init_userprefs($userdata);
+// Auth check
//
-// End session management
-//
-
-//
-// Start auth check
-//
-$is_auth = auth(AUTH_ALL, $forum_id, $userdata);
-
-if ( !$is_auth['auth_mod'] )
+if ( !$acl->get_acl($forum_id, 'mod') )
{
message_die(GENERAL_MESSAGE, $lang['Not_Moderator'], $lang['Not_Authorised']);
}
-//
-// End Auth Check
-//
//
// Do major work ...
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 5418ff7a5d..e2ca65d44f 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -25,12 +25,12 @@ $phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
-include($phpbb_root_path . 'includes/functions_post.'.$phpEx);
+include($phpbb_root_path . 'includes/functions_posting.'.$phpEx);
//
// Check and set various parameters
//
-$params = array('submit' => 'post', 'confirm' => 'confirm', 'preview' => 'preview', 'delete' => 'delete', 'poll_delete' => 'poll_delete', 'poll_add' => 'add_poll_option', 'poll_edit' => 'edit_poll_option', 'mode' => 'mode', 'forum_id' => POST_FORUM_URL, 'topic_id' => POST_TOPIC_URL, 'post_id' => POST_POST_URL);
+$params = array('submit' => 'post', 'confirm' => 'confirm', 'preview' => 'preview', 'delete' => 'delete', 'poll_delete' => 'poll_delete', 'poll_add' => 'add_poll_option', 'poll_edit' => 'edit_poll_option', 'mode' => 'mode', 'forum_id' => 'f', 'topic_id' => 't', 'post_id' => 'p');
while( list($var, $param) = @each($params) )
{
@@ -76,35 +76,35 @@ if ( isset($HTTP_POST_VARS['cancel']) )
{
if ( $post_id )
{
- $redirect = "viewtopic.$phpEx?" . POST_POST_URL . "=$post_id";
+ $redirect = "viewtopic.$phpEx$SID&p=$post_id";
$post_append = "#$post_id";
}
else if ( $topic_id )
{
- $redirect = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id";
+ $redirect = "viewtopic.$phpEx$SID&t=$topic_id";
$post_append = '';
}
else if ( $forum_id )
{
- $redirect = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id";
+ $redirect = "viewforum.$phpEx$SID&f=$forum_id";
$post_append = '';
}
else
{
- $redirect = "index.$phpEx";
+ $redirect = "index.$phpEx$SID";
$post_append = '';
}
$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
- header($header_location . append_sid($redirect) . $post_append, true);
+ header($header_location . $redirect . $post_append, true);
exit;
}
//
// Start session management
//
-$userdata = session_pagestart($user_ip, PAGE_POSTING);
-init_userprefs($userdata);
+$userdata = $session->start();
+$acl = new auth('list', $userdata);
//
// End session management
//
@@ -147,7 +147,7 @@ switch( $mode )
$is_auth_type = 'auth_read';
break;
default:
- message_die(GENERAL_MESSAGE, $lang['No_post_mode']);
+ message_die(MESSAGE, $lang['No_post_mode']);
break;
}
@@ -162,7 +162,7 @@ switch ( $mode )
case 'newtopic':
if ( empty($forum_id) )
{
- message_die(GENERAL_MESSAGE, $lang['Forum_not_exist']);
+ message_die(MESSAGE, $lang['Forum_not_exist']);
}
$sql = "SELECT *
@@ -174,7 +174,7 @@ switch ( $mode )
case 'vote':
if ( empty( $topic_id) )
{
- message_die(GENERAL_MESSAGE, $lang['No_topic_id']);
+ message_die(MESSAGE, $lang['No_topic_id']);
}
$sql = "SELECT f.*, t.topic_status
@@ -189,7 +189,7 @@ switch ( $mode )
case 'poll_delete':
if ( empty($post_id) )
{
- message_die(GENERAL_MESSAGE, $lang['No_post_id']);
+ message_die(MESSAGE, $lang['No_post_id']);
}
$select_sql = ( !$submit ) ? ", t.topic_title, p.enable_bbcode, p.enable_html, p.enable_smilies, p.enable_sig, p.post_username, pt.post_subject, pt.post_text, pt.bbcode_uid, u.username, u.user_id, u.user_sig" : '';
@@ -205,25 +205,29 @@ switch ( $mode )
break;
default:
- message_die(GENERAL_MESSAGE, $lang['No_valid_mode']);
+ message_die(MESSAGE, $lang['No_valid_mode']);
}
if ( $result = $db->sql_query($sql) )
{
$post_info = $db->sql_fetchrow($result);
+ //
+ // Configure style, language, etc.
+ //
+ $userdata['user_style'] = ( $post_info['forum_style'] ) ? $post_info['user_style'] : $userdata['user_style'];
+ $session->configure($userdata);
+
$forum_id = $post_info['forum_id'];
$forum_name = $post_info['forum_name'];
- $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $post_info);
-
if ( $post_info['forum_status'] == FORUM_LOCKED && !$is_auth['auth_mod'])
{
- message_die(GENERAL_MESSAGE, $lang['Forum_locked']);
+ message_die(MESSAGE, $lang['Forum_locked']);
}
else if ( $mode != 'newtopic' && $post_info['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod'])
{
- message_die(GENERAL_MESSAGE, $lang['Topic_locked']);
+ message_die(MESSAGE, $lang['Topic_locked']);
}
if ( $mode == 'editpost' || $mode == 'delete' || $mode == 'poll_delete' )
@@ -245,10 +249,7 @@ if ( $result = $db->sql_query($sql) )
WHERE vd.topic_id = $topic_id
AND vr.vote_id = vd.vote_id
ORDER BY vr.vote_option_id";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Could not obtain vote data for this topic', '', __LINE__, __FILE__, $sql);
- }
+ $result = $db->sql_query($sql);
$poll_options = array();
$poll_results_sum = 0;
@@ -279,17 +280,17 @@ if ( $result = $db->sql_query($sql) )
if ( $post_info['poster_id'] != $userdata['user_id'] && !$is_auth['auth_mod'] )
{
$message = ( $delete || $mode == 'delete' ) ? $lang['Delete_own_posts'] : $lang['Edit_own_posts'];
- $message .= '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>');
+ $message .= '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . "viewtopic.$phpEx$SID&amp;t=$topic_id" . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
+ message_die(MESSAGE, $message);
}
else if ( !$post_data['last_post'] && !$is_auth['auth_mod'] && ( $mode == 'delete' || $delete ) )
{
- message_die(GENERAL_MESSAGE, $lang['Cannot_delete_replied']);
+ message_die(MESSAGE, $lang['Cannot_delete_replied']);
}
else if ( !$post_data['edit_poll'] && !$is_auth['auth_mod'] && ( $mode == 'poll_delete' || $poll_delete ) )
{
- message_die(GENERAL_MESSAGE, $lang['Cannot_delete_poll']);
+ message_die(MESSAGE, $lang['Cannot_delete_poll']);
}
}
else
@@ -307,18 +308,19 @@ if ( $result = $db->sql_query($sql) )
}
else
{
- message_die(GENERAL_MESSAGE, $lang['No_such_post']);
+ message_die(MESSAGE, $lang['No_such_post']);
}
//
// The user is not authed, if they're not logged in then redirect
// them, else show them an error message
//
+/*
if ( !$is_auth[$is_auth_type] )
{
if ( $userdata['session_logged_in'] )
{
- message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_' . $is_auth_type], $is_auth[$is_auth_type . "_type"]));
+ message_die(MESSAGE, sprintf($lang['Sorry_' . $is_auth_type], $is_auth[$is_auth_type . "_type"]));
}
switch( $mode )
@@ -337,10 +339,10 @@ if ( !$is_auth[$is_auth_type] )
}
$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
- header($header_location . append_sid("login.$phpEx?redirect=posting.$phpEx&" . $redirect, true));
+ header($header_location . "login.$phpEx$SID&redirect=posting.$phpEx&" . $redirect);
exit;
}
-
+*/
//
// Set toggles for various options
//
@@ -383,10 +385,7 @@ else
FROM " . TOPICS_WATCH_TABLE . "
WHERE topic_id = $topic_id
AND user_id = " . $userdata['user_id'];
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Could not obtain topic watch information', '', __LINE__, __FILE__, $sql);
- }
+ $result = $db->sql_query($sql);
$notify_user = ( $db->sql_fetchrow($result) ) ? TRUE : $userdata['user_notify'];
}
@@ -406,7 +405,7 @@ if ( ( $delete || $poll_delete || $mode == 'delete' ) && !$confirm )
//
// Confirm deletion
//
- $s_hidden_fields = '<input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />';
+ $s_hidden_fields = '<input type="hidden" name="p" value="' . $post_id . '" />';
$s_hidden_fields .= ( $delete || $mode == "delete" ) ? '<input type="hidden" name="mode" value="delete" />' : '<input type="hidden" name="mode" value="poll_delete" />';
$l_confirm = ( $delete || $mode == 'delete' ) ? $lang['Confirm_delete'] : $lang['Confirm_delete_poll'];
@@ -417,7 +416,7 @@ if ( ( $delete || $poll_delete || $mode == 'delete' ) && !$confirm )
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
- 'confirm_body' => 'confirm_body.tpl')
+ 'body' => 'confirm_body.html')
);
$template->assign_vars(array(
@@ -427,12 +426,10 @@ if ( ( $delete || $poll_delete || $mode == 'delete' ) && !$confirm )
'L_YES' => $lang['Yes'],
'L_NO' => $lang['No'],
- 'S_CONFIRM_ACTION' => append_sid("posting.$phpEx"),
+ 'S_CONFIRM_ACTION' => "posting.$phpEx$SID",
'S_HIDDEN_FIELDS' => $s_hidden_fields)
);
- $template->pparse('confirm_body');
-
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
else if ( $mode == 'vote' )
@@ -450,10 +447,7 @@ else if ( $mode == 'vote' )
AND vr.vote_id = vd.vote_id
AND vr.vote_option_id = $vote_option_id
GROUP BY vd.vote_id";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Could not obtain vote data for this topic', '', __LINE__, __FILE__, $sql);
- }
+ $result = $db->sql_query($sql);
if ( $vote_info = $db->sql_fetchrow($result) )
{
@@ -463,10 +457,7 @@ else if ( $mode == 'vote' )
FROM " . VOTE_USERS_TABLE . "
WHERE vote_id = $vote_id
AND vote_user_id = " . $userdata['user_id'];
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Could not obtain user vote data for this topic', '', __LINE__, __FILE__, $sql);
- }
+ $result = $db->sql_query($sql);
if ( !($row = $db->sql_fetchrow($result)) )
{
@@ -499,10 +490,10 @@ else if ( $mode == 'vote' )
}
$template->assign_vars(array(
- 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">')
+ 'META' => '<meta http-equiv="refresh" content="3;url=' . "viewtopic.$phpEx$SID&amp;" . POST_TOPIC_URL . "=$topic_id" . '">')
);
- $message .= '<br /><br />' . sprintf($lang['Click_view_message'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
+ $message .= '<br /><br />' . sprintf($lang['Click_view_message'], '<a href="' . "viewtopic.$phpEx$SID&amp;" . POST_TOPIC_URL . "=$topic_id" . '">', '</a>');
+ message_die(MESSAGE, $message);
}
}
else if ( $submit || $confirm )
@@ -571,7 +562,7 @@ else if ( $submit || $confirm )
$template->assign_vars(array(
"META" => $return_meta)
);
- message_die(GENERAL_MESSAGE, $return_message);
+ message_die(MESSAGE, $return_message);
}
}
@@ -677,7 +668,7 @@ if( $refresh || isset($HTTP_POST_VARS['del_poll_option']) || $error_msg != '' )
$preview_message = str_replace("\n", '<br />', $preview_message);
$template->set_filenames(array(
- 'preview' => 'posting_preview.tpl')
+ 'preview' => 'posting_preview.html')
);
$template->assign_vars(array(
@@ -697,7 +688,7 @@ if( $refresh || isset($HTTP_POST_VARS['del_poll_option']) || $error_msg != '' )
else if( $error_msg != '' )
{
$template->set_filenames(array(
- 'reg_header' => 'error_body.tpl')
+ 'reg_header' => 'error_body.html')
);
$template->assign_vars(array(
'ERROR_MESSAGE' => $error_msg)
@@ -868,7 +859,7 @@ if ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['first_post'] )
{
$template->assign_block_vars('switch_type_toggle', array());
- if( $is_auth['auth_sticky'] )
+ if( $acl->get_acl($forum_id, 'forum', 'sticky') )
{
$topic_type_toggle .= '<input type="radio" name="topictype" value="' . POST_STICKY . '"';
if ( $post_data['topic_type'] == POST_STICKY || $topic_type == POST_STICKY )
@@ -878,7 +869,7 @@ if ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['first_post'] )
$topic_type_toggle .= ' /> ' . $lang['Post_Sticky'] . '&nbsp;&nbsp;';
}
- if( $is_auth['auth_announce'] )
+ if ( $acl->get_acl($forum_id, 'forum', 'announce') )
{
$topic_type_toggle .= '<input type="radio" name="topictype" value="' . POST_ANNOUNCE . '"';
if ( $post_data['topic_type'] == POST_ANNOUNCE || $topic_type == POST_ANNOUNCE )
@@ -923,9 +914,9 @@ generate_smilies('inline', PAGE_POSTING);
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
- 'body' => 'posting_body.tpl',
- 'pollbody' => 'posting_poll_body.tpl',
- 'reviewbody' => 'posting_topic_review.tpl')
+ 'body' => 'posting_body.html',
+ 'pollbody' => 'posting_poll_body.html',
+ 'reviewbody' => 'posting_topic_review.html')
);
make_jumpbox('viewforum.'.$phpEx);
@@ -934,7 +925,7 @@ $template->assign_vars(array(
'L_POST_A' => $page_title,
'L_POST_SUBJECT' => $lang['Post_subject'],
- 'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
+ 'U_VIEW_FORUM' => "viewforum.$phpEx$SID&amp;" . POST_FORUM_URL . "=$forum_id")
);
//
@@ -951,7 +942,7 @@ $template->assign_vars(array(
'SUBJECT' => $subject,
'MESSAGE' => $message,
'HTML_STATUS' => $html_status,
- 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq.$phpEx?mode=bbcode") . '" target="_phpbbcode">', '</a>'),
+ 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . "faq.$phpEx$SID&amp;mode=bbcode" . '" target="_phpbbcode">', '</a>'),
'SMILIES_STATUS' => $smilies_status,
'L_SUBJECT' => $lang['Subject'],
@@ -1010,8 +1001,8 @@ $template->assign_vars(array(
'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'],
'L_STYLES_TIP' => $lang['Styles_tip'],
- 'U_VIEWTOPIC' => ( $mode == 'reply' ) ? append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postorder=desc") : '',
- 'U_REVIEW_TOPIC' => ( $mode == 'reply' ) ? append_sid("posting.$phpEx?mode=topicreview&amp;" . POST_TOPIC_URL . "=$topic_id") : '',
+ 'U_VIEWTOPIC' => ( $mode == 'reply' ) ? "viewtopic.$phpEx$SID&amp;m" . POST_TOPIC_URL . "=$topic_id&amp;postorder=desc" : '',
+ 'U_REVIEW_TOPIC' => ( $mode == 'reply' ) ? "posting.$phpEx$SID&amp;mmode=topicreview&amp;" . POST_TOPIC_URL . "=$topic_id" : '',
'S_HTML_CHECKED' => ( !$html_on ) ? 'checked="checked"' : '',
'S_BBCODE_CHECKED' => ( !$bbcode_on ) ? 'checked="checked"' : '',
@@ -1020,7 +1011,7 @@ $template->assign_vars(array(
'S_NOTIFY_CHECKED' => ( $notify_user ) ? 'checked="checked"' : '',
'S_TYPE_TOGGLE' => $topic_type_toggle,
'S_TOPIC_ID' => $topic_id,
- 'S_POST_ACTION' => append_sid("posting.$phpEx"),
+ 'S_POST_ACTION' => "posting.$phpEx$SID",
'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields)
);
@@ -1078,8 +1069,6 @@ if( $mode == 'reply' )
$template->assign_var_from_handle('TOPIC_REVIEW_BOX', 'reviewbody');
}
-$template->pparse('body');
-
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?> \ No newline at end of file
diff --git a/phpBB/privmsg.php b/phpBB/privmsg.php
index 04107dac60..48ad826c7e 100644
--- a/phpBB/privmsg.php
+++ b/phpBB/privmsg.php
@@ -74,15 +74,15 @@ else
if ( $cancel )
{
$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
- header($header_location . append_sid("privmsg.$phpEx?folder=$folder", true));
+ header($header_location . "privmsg.$phpEx$SIDfolder=$folder");
exit;
}
//
// Start session management
//
-$userdata = session_pagestart($user_ip, PAGE_PRIVMSGS);
-init_userprefs($userdata);
+$userdata = $session->start();
+$acl = new auth('list', $userdata);
//
// End session management
//
diff --git a/phpBB/profile.php b/phpBB/profile.php
index d544bbd570..f4c456a296 100644
--- a/phpBB/profile.php
+++ b/phpBB/profile.php
@@ -28,13 +28,18 @@ include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
-$userdata = session_pagestart($user_ip, PAGE_PROFILE);
-init_userprefs($userdata);
+$userdata = $session->start();
+$acl = new auth('list', $userdata);
//
// End session management
//
//
+// Configure style, language, etc.
+//
+$session->configure($userdata);
+
+//
// Set default email variables
//
$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
@@ -81,10 +86,16 @@ if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
}
else if ( $mode == 'editprofile' || $mode == 'register' )
{
- if ( !$userdata['session_logged_in'] && $mode == 'editprofile' )
+ if ( $userdata['user_id'] == ANONYMOUS && $mode == 'editprofile' )
+ {
+ $header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
+ header($header_location . "login.$phpEx$SID&redirect=profile.$phpEx&mode=editprofile");
+ exit;
+ }
+ else if ( $userdata['user_id'] != ANONYMOUS && $mode == 'register' )
{
$header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
- header($header_location . append_sid("login.$phpEx?redirect=profile.$phpEx&mode=editprofile", true));
+ header($header_location . "index.$phpEx$SID");
exit;
}
@@ -110,8 +121,8 @@ if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
else
{
$header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
- header($header_location . append_sid("index.$phpEx", true));
+ header($header_location . "index.$phpEx$SID");
exit;
}
-?>
+?> \ No newline at end of file
diff --git a/phpBB/search.php b/phpBB/search.php
index 46e811be37..fc99d18b31 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -25,13 +25,13 @@ $phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
-include($phpbb_root_path . 'includes/functions_search.'.$phpEx);
+include($phpbb_root_path . 'includes/functions_posting.'.$phpEx);
//
// Start session management
//
-$userdata = session_pagestart($user_ip, PAGE_SEARCH);
-init_userprefs($userdata);
+$userdata = $session->start();
+$acl = new auth('list', $userdata);
//
// End session management
//
@@ -192,7 +192,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
WHERE username LIKE '" . str_replace("\'", "''", $search_author) . "'";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, "Couldn't obtain list of matching users (searching for: $search_author)", "", __LINE__, __FILE__, $sql);
+ message_die(ERROR, "Couldn't obtain list of matching users (searching for: $search_author)", "", __LINE__, __FILE__, $sql);
}
$matching_userids = '';
@@ -206,7 +206,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
}
else
{
- message_die(GENERAL_MESSAGE, $lang['No_search_match']);
+ message_die(MESSAGE, $lang['No_search_match']);
}
$sql = "SELECT post_id
@@ -216,7 +216,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not obtain matched posts list', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not obtain matched posts list', '', __LINE__, __FILE__, $sql);
}
$search_ids = array();
@@ -278,7 +278,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
$search_msg_only";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not obtain matched posts list', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not obtain matched posts list', '', __LINE__, __FILE__, $sql);
}
$row = array();
@@ -342,37 +342,33 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
$auth_sql = '';
if ( $search_forum != -1 )
{
- $is_auth = auth(AUTH_READ, $search_forum, $userdata);
-
- if ( !$is_auth['auth_read'] )
+ if ( !$acl->get_acl($search_forum, 'forum', 'read') )
{
- message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']);
+ message_die(MESSAGE, $lang['No_searchable_forums']);
}
$auth_sql = "f.forum_id = $search_forum";
}
else
{
- $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
-
if ( $search_cat != -1 )
{
$auth_sql = "f.cat_id = $search_cat";
}
- $ignore_forum_sql = '';
- while( list($key, $value) = each($is_auth_ary) )
+ $auth_ary = $acl->get_acl();
+ @reset($auth_ary);
+
+ $allowed_forum_sql = '';
+ while( list($key, $value) = @each($auth_ary) )
{
- if ( !$value['auth_read'] )
+ if ( $value['forum']['read'] )
{
- $ignore_forum_sql .= ( ( $ignore_forum_sql != '' ) ? ', ' : '' ) . $key;
+ $allowed_forum_sql .= ( ( $allowed_forum_sql != '' ) ? ', ' : '' ) . $key;
}
}
- if ( $ignore_forum_sql != '' )
- {
- $auth_sql .= ( $auth_sql != '' ) ? " AND f.forum_id NOT IN ($ignore_forum_sql) " : "f.forum_id NOT IN ($ignore_forum_sql) ";
- }
+ $auth_sql .= ( $auth_sql != '' ) ? " AND f.forum_id IN ($allowed_forum_sql) " : "f.forum_id IN ($allowed_forum_sql) ";
}
//
@@ -427,7 +423,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not obtain topic ids', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not obtain topic ids', '', __LINE__, __FILE__, $sql);
}
$search_ids = array();
@@ -467,7 +463,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
WHERE $where_sql";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not obtain post ids', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not obtain post ids', '', __LINE__, __FILE__, $sql);
}
$search_ids = array();
@@ -502,7 +498,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not obtain post ids', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not obtain post ids', '', __LINE__, __FILE__, $sql);
}
$search_ids = array();
@@ -523,7 +519,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
}
else
{
- message_die(GENERAL_MESSAGE, $lang['No_search_match']);
+ message_die(MESSAGE, $lang['No_search_match']);
}
//
@@ -546,7 +542,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
WHERE session_id NOT IN (" . implode(", ", $delete_search_ids) . ")";
if ( !$result = $db->sql_query($sql) )
{
- message_die(GENERAL_ERROR, 'Could not delete old search id sessions', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not delete old search id sessions', '', __LINE__, __FILE__, $sql);
}
}
}
@@ -582,7 +578,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
VALUES($search_id, '" . $userdata['session_id'] . "', '" . str_replace("\'", "''", $result_array) . "')";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not insert search results', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not insert search results', '', __LINE__, __FILE__, $sql);
}
}
}
@@ -596,7 +592,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
AND session_id = '". $userdata['session_id'] . "'";
if ( !($result = $db->sql_query($sql)) )
{
- message_die(GENERAL_ERROR, 'Could not obtain search results', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not obtain search results', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
@@ -662,7 +658,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
if ( !$result = $db->sql_query($sql) )
{
- message_die(GENERAL_ERROR, 'Could not obtain search results', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not obtain search results', '', __LINE__, __FILE__, $sql);
}
$searchset = array();
@@ -1180,7 +1176,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
}
else
{
- message_die(GENERAL_MESSAGE, $lang['No_search_match']);
+ message_die(MESSAGE, $lang['No_search_match']);
}
}
@@ -1194,7 +1190,7 @@ $sql = "SELECT c.cat_title, c.cat_id, f.forum_name, f.forum_id
$result = $db->sql_query($sql);
if ( !$result )
{
- message_die(GENERAL_ERROR, 'Could not obtain forum_name/forum_id', '', __LINE__, __FILE__, $sql);
+ message_die(ERROR, 'Could not obtain forum_name/forum_id', '', __LINE__, __FILE__, $sql);
}
$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
@@ -1227,7 +1223,7 @@ if ( $s_forums != '' )
}
else
{
- message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']);
+ message_die(MESSAGE, $lang['No_searchable_forums']);
}
//
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 7771284c6f..1ccf2e4605 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -8,7 +8,6 @@
*
* $Id$
*
- *
***************************************************************************/
/***************************************************************************
@@ -26,31 +25,35 @@ include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
+// Start session management
+//
+$userdata = $session->start();
+//
+// End session management
+//
+
+//
// Start initial var setup
//
-if ( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL]) )
+if ( isset($HTTP_GET_VARS['f']) || isset($HTTP_POST_VARS['f']) )
{
- $forum_id = ( isset($HTTP_GET_VARS[POST_FORUM_URL]) ) ? intval($HTTP_GET_VARS[POST_FORUM_URL]) : intval($HTTP_POST_VARS[POST_FORUM_URL]);
-}
-else if ( isset($HTTP_GET_VARS['forum']))
-{
- $forum_id = intval($HTTP_GET_VARS['forum']);
+ $forum_id = ( isset($HTTP_GET_VARS['f']) ) ? intval($HTTP_GET_VARS['f']) : intval($HTTP_POST_VARS['f']);
}
else
{
$forum_id = '';
}
-$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
-
if ( isset($HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']) )
{
- $mark_read = (isset($HTTP_POST_VARS['mark'])) ? $HTTP_POST_VARS['mark'] : $HTTP_GET_VARS['mark'];
+ $mark_read = ( isset($HTTP_POST_VARS['mark']) ) ? $HTTP_POST_VARS['mark'] : $HTTP_GET_VARS['mark'];
}
else
{
$mark_read = '';
}
+
+$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
//
// End initial var setup
//
@@ -64,185 +67,69 @@ if ( !empty($forum_id) )
$sql = "SELECT *
FROM " . FORUMS_TABLE . "
WHERE forum_id = $forum_id";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
- }
+ $result = $db->sql_query($sql);
}
else
{
- message_die(GENERAL_MESSAGE, 'Forum_not_exist');
+ message_die(MESSAGE, 'Forum_not_exist');
}
-//
-// If the query doesn't return any rows this isn't a valid forum. Inform
-// the user.
-//
-if ( !($forum_row = $db->sql_fetchrow($result)) )
+if ( !($forum_data = $db->sql_fetchrow($result)) )
{
- message_die(GENERAL_MESSAGE, 'Forum_not_exist');
+ message_die(MESSAGE, 'Forum_not_exist');
}
//
-// Start session management
-//
-$userdata = session_pagestart($user_ip, $forum_id);
-init_userprefs($userdata);
-//
-// End session management
+// Configure style, language, etc.
//
+$acl = new auth('forum', $userdata, $forum_id);
+$userdata['user_style'] = ( $forum_data['forum_style'] ) ? $forum_data['user_style'] : $userdata['user_style'];
+$session->configure($userdata);
//
-// Start auth check
+// Auth check
//
-$is_auth = array();
-$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
-
-if ( !$is_auth['auth_read'] || !$is_auth['auth_view'] )
+if ( !$acl->get_acl($forum_id, 'forum', 'list') || !$acl->get_acl($forum_id, 'forum', 'read') )
{
- if ( !$userdata['session_logged_in'] )
+ if ( $userdata['user_id'] == ANONYMOUS )
{
- $redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : "" );
- $header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
- header($header_location . append_sid("login.$phpEx?redirect=viewforum.$phpEx&$redirect", true));
+ $redirect = "f=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' );
+ $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
+ header($header_location . "login.$phpEx$SID&redirect=viewforum.$phpEx&$redirect");
+ exit;
}
+
//
// The user is not authed to read this forum ...
//
- $message = ( !$is_auth['auth_view'] ) ? $lang['Forum_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
+ $message = ( !$acl->get_acl($forum_id, 'forum', 'list') ) ? $lang['Forum_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth[$forum_id]['auth_read_type']);
- message_die(GENERAL_MESSAGE, $message);
+ message_die(MESSAGE, $message);
}
//
// End of auth check
//
//
-// Is user watching this thread?
+// Topic read tracking cookie info
//
-if( $userdata['session_logged_in'] )
-{
- $can_watch_forum = TRUE;
-
- $sql = "SELECT notify_status
- FROM " . FORUMS_WATCH_TABLE . "
- WHERE forum_id = $forum_id
- AND user_id = " . $userdata['user_id'];
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, "Could not obtain forum watch information", '', __LINE__, __FILE__, $sql);
- }
-
- if ( $row = $db->sql_fetchrow($result) )
- {
- if ( isset($HTTP_GET_VARS['unwatch']) )
- {
- if ( $HTTP_GET_VARS['unwatch'] == 'forum' )
- {
- $is_watching_forum = 0;
-
- $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
- $sql = "DELETE $sql_priority FROM " . FORUMS_WATCH_TABLE . "
- WHERE forum_id = $forum_id
- AND user_id = " . $userdata['user_id'];
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, "Could not delete forum watch information", '', __LINE__, __FILE__, $sql);
- }
- }
-
- $template->assign_vars(array(
- 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;start=$start") . '">')
- );
-
- $message = $lang['No_longer_watching_forum'] . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;start=$start") . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
- }
- else
- {
- $is_watching_forum = TRUE;
-
- if ( $row['notify_status'] )
- {
- $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
- $sql = "UPDATE $sql_priority " . FORUMS_WATCH_TABLE . "
- SET notify_status = 0
- WHERE forum_id = $forum_id
- AND user_id = " . $userdata['user_id'];
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, "Could not update forum watch information", '', __LINE__, __FILE__, $sql);
- }
- }
- }
- }
- else
- {
- if ( isset($HTTP_GET_VARS['watch']) )
- {
- if ( $HTTP_GET_VARS['watch'] == 'forum' )
- {
- $is_watching_forum = TRUE;
-
- $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
- $sql = "INSERT $sql_priority INTO " . FORUMS_WATCH_TABLE . " (user_id, forum_id, notify_status)
- VALUES (" . $userdata['user_id'] . ", $forum_id, 0)";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, "Could not insert forum watch information", '', __LINE__, __FILE__, $sql);
- }
- }
-
- $template->assign_vars(array(
- 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;start=$start") . '">')
- );
-
- $message = $lang['You_are_watching_forum'] . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;start=$start") . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
- }
- else
- {
- $is_watching_forum = 0;
- }
- }
-}
-else
-{
- if ( isset($HTTP_GET_VARS['unwatch']) )
- {
- if ( $HTTP_GET_VARS['unwatch'] == 'forum' )
- {
- $header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
- header($header_location . append_sid("login.$phpEx?redirect=viewforum.$phpEx&" . POST_FORUM_URL . "=$forum_id&unwatch=forum", true));
- }
- }
- else
- {
- $can_watch_forum = 0;
- $is_watching_forum = 0;
- }
-}
+$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : '';
+$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : '';
//
// Handle marking posts
//
if ( $mark_read == 'topics' )
{
- if ( $userdata['session_logged_in'] )
+ if ( $userdata['user_id'] != ANONYMOUS )
{
$sql = "SELECT MAX(post_time) AS last_post
FROM " . POSTS_TABLE . "
WHERE forum_id = $forum_id";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
- }
+ $result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
- $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
- $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
-
if ( ( count($tracking_forums) + count($tracking_topics) ) >= 150 && empty($tracking_forums[$forum_id]) )
{
asort($tracking_forums);
@@ -258,28 +145,24 @@ if ( $mark_read == 'topics' )
}
$template->assign_vars(array(
- 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">')
+ 'META' => '<meta http-equiv="refresh" content="3;url=' . "viewforum.$phpEx$SID&amp;f=$forum_id" . '">')
);
}
- $message = $lang['Topics_marked_read'] . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a> ');
- message_die(GENERAL_MESSAGE, $message);
+ $message = $lang['Topics_marked_read'] . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . "viewforum.$phpEx$SID&amp;f=$forum_id" . '">', '</a> ');
+ message_die(MESSAGE, $message);
}
//
// End handle marking posts
//
-$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : '';
-$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : '';
-
//
// Do the forum Prune
//
-if ( $is_auth['auth_mod'] && $board_config['prune_enable'] )
+if ( $acl->get_acl($forum_id, 'mod', 'prune') && $board_config['prune_enable'] )
{
- if ( $forum_row['prune_next'] < time() && $forum_row['prune_enable'] )
+ if ( $forum_data['prune_next'] < time() && $forum_data['prune_enable'] )
{
- include($phpbb_root_path . 'includes/prune.'.$phpEx);
require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
auto_prune($forum_id);
}
@@ -289,394 +172,286 @@ if ( $is_auth['auth_mod'] && $board_config['prune_enable'] )
//
//
-// Obtain list of moderators of each forum
-// First users, then groups ... broken into two queries
+// Forum rules, subscription info and word censors
//
-$sql = "SELECT u.user_id, u.username
- FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
- WHERE aa.forum_id = $forum_id
- AND aa.auth_mod = " . TRUE . "
- AND g.group_single_user = 1
- AND ug.group_id = aa.group_id
- AND g.group_id = aa.group_id
- AND u.user_id = ug.user_id
- GROUP BY u.user_id, u.username
- ORDER BY u.user_id";
-if ( !($result = $db->sql_query($sql)) )
-{
- message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
-}
-
-$moderators = array();
-while( $row = $db->sql_fetchrow($result) )
-{
- $moderators[] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $row['username'] . '</a>';
-}
+$s_watching_forum = '';
+$s_watching_forum_img = '';
+watch_topic_forum('forum', $s_watching_forum, $s_watching_forum_img, $userdata['user_id'], $forum_id);
-$sql = "SELECT g.group_id, g.group_name
- FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
- WHERE aa.forum_id = $forum_id
- AND aa.auth_mod = " . TRUE . "
- AND g.group_single_user = 0
- AND g.group_type <> ". GROUP_HIDDEN ."
- AND ug.group_id = aa.group_id
- AND g.group_id = aa.group_id
- GROUP BY g.group_id, g.group_name
- ORDER BY g.group_id";
-if ( !($result = $db->sql_query($sql)) )
-{
- message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
-}
+$s_forum_rules = '';
+get_forum_rules('forum', $s_forum_rules, $forum_id);
-while( $row = $db->sql_fetchrow($result) )
-{
- $moderators[] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
-}
-
-$l_moderators = ( count($moderators) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
-$forum_moderators = ( count($moderators) ) ? implode(', ', $moderators) : $lang['None'];
-unset($moderators);
+$orig_word = array();
+$replacement_word = array();
+obtain_word_list($orig_word, $replacement_word);
//
-// Generate a 'Show topics in previous x days' select box. If the topicsdays var is sent
-// then get it's value, find the number of topics with dates newer than it (to properly
-// handle pagination) and alter the main query
+// Topic ordering options
//
-$previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
-$previous_days_text = array($lang['All_Topics'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']);
+$previous_days = array(0 => $lang['All_Topics'], 1 => $lang['1_Day'], 7 => $lang['7_Days'], 14 => $lang['2_Weeks'], 30 => $lang['1_Month'], 90 => $lang['3_Months'], 180 => $lang['6_Months'], 364 => $lang['1_Year']);
+$sort_by_text = array('a' => $lang['Author'], 't' => $lang['Post_time'], 'r' => $lang['Replies'], 's' => $lang['Subject'], 'v' => $lang['Views']);
+$sort_by = array('a' => 'u.username', 't' => 't.topic_last_post_id', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views');
-if ( !empty($HTTP_POST_VARS['topicdays']) || !empty($HTTP_GET_VARS['topicdays']) )
+if ( isset($HTTP_POST_VARS['sort']) )
{
- $topic_days = ( !empty($HTTP_POST_VARS['topicdays']) ) ? $HTTP_POST_VARS['topicdays'] : $HTTP_GET_VARS['topicdays'];
- $min_topic_time = time() - ($topic_days * 86400);
-
- $sql = "SELECT COUNT(t.topic_id) AS forum_topics
- FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
- WHERE t.forum_id = $forum_id
- AND p.post_id = t.topic_last_post_id
- AND p.post_time >= $min_topic_time";
-
- if ( !($result = $db->sql_query($sql)) )
+ if ( !empty($HTTP_POST_VARS['sort_days']) )
{
- message_die(GENERAL_ERROR, 'Could not obtain limited topics count information', '', __LINE__, __FILE__, $sql);
- }
- $row = $db->sql_fetchrow($result);
+ $sort_days = ( !empty($HTTP_POST_VARS['sort_days']) ) ? intval($HTTP_POST_VARS['sort_days']) : intval($HTTP_GET_VARS['sort_days']);
+ $min_topic_time = time() - ($sort_days * 86400);
- $topics_count = ( $forum_row['forum_topics'] ) ? $forum_row['forum_topics'] : 1;
- $limit_topics_time = "AND p.post_time >= $min_topic_time";
+ $sql = "SELECT COUNT(t.topic_id) AS forum_topics
+ FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
+ WHERE t.forum_id = $forum_id
+ AND p.post_id = t.topic_last_post_id
+ AND p.post_time >= $min_topic_time";
+ $result = $db->sql_query($sql);
- if ( !empty($HTTP_POST_VARS['topicdays']) )
- {
$start = 0;
+ $topics_count = ( $row = $db->sql_fetchrow($result) ) ? $row['forum_topics'] : 0;
+ $limit_topics_time = "AND p.post_time >= $min_topic_time";
}
+ else
+ {
+ $topics_count = ( $forum_data['forum_topics'] ) ? $forum_data['forum_topics'] : 1;
+ }
+
+ $sort_key = ( isset($HTTP_POST_VARS['sort_key']) ) ? $HTTP_POST_VARS['sort_key'] : $HTTP_GET_VARS['sort_key'];
+ $sort_dir = ( isset($HTTP_POST_VARS['sort_dir']) ) ? $HTTP_POST_VARS['sort_dir'] : $HTTP_GET_VARS['sort_dir'];
}
else
{
- $topics_count = ( $forum_row['forum_topics'] ) ? $forum_row['forum_topics'] : 1;
-
+ $topics_count = ( $forum_data['forum_topics'] ) ? $forum_data['forum_topics'] : 1;
$limit_topics_time = '';
- $topic_days = 0;
-}
-$select_topic_days = '<select name="topicdays">';
-for($i = 0; $i < count($previous_days); $i++)
-{
- $selected = ($topic_days == $previous_days[$i]) ? ' selected="selected"' : '';
- $select_topic_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';
+ $sort_days = 0;
+ $sort_key = 't';
+ $sort_dir = 'd';
}
-$select_topic_days .= '</select>';
-
-//
-// All announcement data, this keeps announcements
-// on each viewforum page ...
-//
-$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
- FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
- WHERE t.forum_id = $forum_id
- AND t.topic_poster = u.user_id
- AND p.post_id = t.topic_last_post_id
- AND p.poster_id = u2.user_id
- AND t.topic_type = " . POST_ANNOUNCE . "
- ORDER BY t.topic_last_post_id DESC ";
-if ( !($result = $db->sql_query($sql)) )
-{
- message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
-}
+$sort_order = $sort_by[$sort_key] . ' ' . ( ( $sort_dir == 'd' ) ? 'DESC' : 'ASC' );
-$topic_rowset = array();
-$total_announcements = 0;
-while( $row = $db->sql_fetchrow($result) )
+$select_sort_days = '<select name="sort_days">';
+foreach ( $previous_days as $day => $text )
{
- $topic_rowset[] = $row;
- $total_announcements++;
+ $selected = ( $sort_days == $day ) ? ' selected="selected"' : '';
+ $select_sort_days .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>';
}
+$select_sort_days .= '</select>';
-$db->sql_freeresult($result);
-
-//
-// Grab all the basic data (all topics except announcements)
-// for this forum
-//
-$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
- FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
- WHERE t.forum_id = $forum_id
- AND t.topic_poster = u.user_id
- AND p.post_id = t.topic_first_post_id
- AND p2.post_id = t.topic_last_post_id
- AND u2.user_id = p2.poster_id
- AND t.topic_type <> " . POST_ANNOUNCE . "
- $limit_topics_time
- ORDER BY t.topic_type DESC, t.topic_last_post_id DESC
- LIMIT $start, ".$board_config['topics_per_page'];
-if ( !($result = $db->sql_query($sql)) )
+$select_sort = '<select name="sort_key">';
+foreach ( $sort_by_text as $key => $text )
{
- message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
+ $selected = ( $sort_key == $key ) ? ' selected="selected"' : '';
+ $select_sort .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>';
}
+$select_sort .= '</select>';
-$total_topics = 0;
-while( $row = $db->sql_fetchrow($result) )
-{
- $topic_rowset[] = $row;
- $total_topics++;
-}
+$select_sort_dir = '<select name="sort_dir">';
+$select_sort_dir .= ( $sort_dir == 'a' ) ? '<option value="a" selected="selected">' . $lang['Ascending'] . '</option><option value="d">' . $lang['Descending'] . '</option>' : '<option value="a">' . $lang['Ascending'] . '</option><option value="d" selected="selected">' . $lang['Descending'] . '</option>';
+$select_sort_dir .= '</select>';
-$db->sql_freeresult($result);
+$post_alt = ( $forum_data['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'];
+$post_img = '<img src=' . (( $forum_data['forum_status'] == FORUM_LOCKED ) ? $theme['post_locked'] : $theme['post_new'] ) . ' border="0" alt="' . $post_alt . '" title="' . $post_alt . '" />';
-//
-// Total topics ...
-//
-$total_topics += $total_announcements;
-
-//
-// Define censored word matches
-//
-$orig_word = array();
-$replacement_word = array();
-obtain_word_list($orig_word, $replacement_word);
-
-//
-// Post URL generation for templating vars
-//
$template->assign_vars(array(
- 'L_DISPLAY_TOPICS' => $lang['Display_topics'],
-
- 'U_POST_NEW_TOPIC' => append_sid("posting.$phpEx?mode=newtopic&amp;" . POST_FORUM_URL . "=$forum_id"),
+ 'FORUM_ID' => $forum_id,
+ 'FORUM_NAME' => $forum_data['forum_name'],
+ 'POST_IMG' => $post_img,
+ 'PAGINATION' => generate_pagination("viewforum.$phpEx$SID&amp;f=$forum_id&amp;topicdays=$topic_days", $topics_count, $board_config['topics_per_page'], $start),
+ 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / $board_config['topics_per_page'] )),
+
+ 'FOLDER_IMG' => create_img($theme['folder'], $lang['No_new_posts']),
+ 'FOLDER_NEW_IMG' => create_img($theme['folder_new'], $lang['New_posts']),
+ 'FOLDER_HOT_IMG' => create_img($theme['folder_hot'], $lang['No_new_posts_hot']),
+ 'FOLDER_HOT_NEW_IMG' => create_img($theme['folder_hot_new'], $lang['New_posts_hot']),
+ 'FOLDER_LOCKED_IMG' => create_img($theme['folder_locked'], $lang['No_new_posts_locked']),
+ 'FOLDER_LOCKED_NEW_IMG' => create_img($theme['folder_locked_new'], $lang['New_posts_locked']),
+ 'FOLDER_STICKY_IMG' => create_img($theme['folder_sticky'], $lang['Post_Sticky']),
+ 'FOLDER_STICKY_NEW_IMG' => create_img($theme['folder_sticky_new'], $lang['Post_Sticky']),
+ 'FOLDER_ANNOUNCE_IMG' => create_img($theme['folder_announce'], $lang['Post_Announcement']),
+ 'FOLDER_ANNOUNCE_NEW_IMG' => create_img($theme['folder_announce_new'], $lang['Post_Announcement']),
+
+ 'L_TOPICS' => $lang['Topics'],
+ 'L_REPLIES' => $lang['Replies'],
+ 'L_VIEWS' => $lang['Views'],
+ 'L_POSTS' => $lang['Posts'],
+ 'L_LASTPOST' => $lang['Last_Post'],
+ 'L_VIEW_MODERATORS' => $lang['View_moderators'],
+ 'L_DISPLAY_TOPICS' => $lang['Display_topics'],
+ 'L_SORT_BY' => $lang['Sort_by'],
+ 'L_MARK_TOPICS_READ' => $lang['Mark_all_topics'],
+ 'L_NO_NEW_POSTS' => $lang['No_new_posts'],
+ 'L_NEW_POSTS' => $lang['New_posts'],
+ 'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'],
+ 'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'],
+ 'L_NO_NEW_POSTS_HOT' => $lang['No_new_posts_hot'],
+ 'L_NEW_POSTS_HOT' => $lang['New_posts_hot'],
+ 'L_ANNOUNCEMENT' => $lang['Post_Announcement'],
+ 'L_STICKY' => $lang['Post_Sticky'],
+ 'L_POSTED' => $lang['Posted'],
+ 'L_JOINED' => $lang['Joined'],
+ 'L_AUTHOR' => $lang['Author'],
+ 'L_NO_TOPICS' => ( $forum_data['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['No_topics_post_one'],
+ 'L_GOTO_PAGE' => $lang['Goto_page'],
+
+ 'S_SELECT_SORT_DIR' => $select_sort_dir,
+ 'S_SELECT_SORT_KEY' => $select_sort,
+ 'S_SELECT_SORT_DAYS' => $select_sort_days,
+ 'S_AUTH_LIST' => $s_forum_rules,
+ 'S_WATCH_FORUM' => $s_watching_forum,
+ 'S_FORUM_ACTION' => 'viewforum.' . $phpEx . $SID . '&amp;f=' . $forum_id . "&amp;start=$start",
- 'S_SELECT_TOPIC_DAYS' => $select_topic_days,
- 'S_POST_DAYS_ACTION' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_id . "&amp;start=$start"))
+ 'U_POST_NEW_TOPIC' => 'posting.' . $phpEx . $SID . '&amp;mode=newtopic&amp;f=' . $forum_id,
+ 'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&amp;f=' . $forum_id,
+ 'U_VIEW_MODERATORS' => 'memberslist.' . $phpEx . $SID . '&amp;mode=moderators&amp;f=' . $forum_id,
+ 'U_MARK_READ' => 'viewforum.' . $phpEx . $SID . '&amp;f=' . $forum_id . '&amp;mark=topics')
);
//
-// User authorisation levels output
+// Grab all the basic data. If we're not on page 1 we also grab any
+// announcements that may exist.
//
-$s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '<br />';
-$s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '<br />';
-$s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '<br />';
-$s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '<br />';
-$s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . '<br />';
-
-if ( $is_auth['auth_mod'] )
-{
- $s_auth_can .= sprintf($lang['Rules_moderate'], '<a href="' . append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
-}
+$total_topics = 0;
+$topic_rowset = array();
-$s_watching_forum = '';
-if ( $can_watch_forum )
+if ( $start )
{
- if ( $is_watching_forum )
- {
- $watch_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;unwatch=forum&amp;start=$start");
- $s_watching_forum = '<a href="' . $watch_url . '">' . $lang['Stop_watching_forum'] . '</a>';
- $s_watching_forum_img = ( isset($images['Forum_un_watch']) ) ? '<a href="' . $watch_url . '"><img src="' . $images['Forum_un_watch'] . '" alt="' . $lang['Stop_watching_forum'] . '" title="' . $lang['Stop_watching_forum'] . '" border="0"></a>' : '';
- }
- else
+ $sql = "SELECT t.*, i.icons_url, i.icons_width, i.icons_height, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username AS post_username2
+ FROM " . TOPICS_TABLE . " t, " . ICONS_TABLE . " i, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
+ WHERE t.forum_id = $forum_id
+ AND t.topic_type = " . POST_ANNOUNCE . "
+ AND i.icons_id = t.topic_icon
+ AND u.user_id = t.topic_poster
+ AND p.post_id = t.topic_last_post_id
+ AND u2.user_id = p.poster_id
+ ORDER BY $sort_order
+ LIMIT " . $board_config['topics_per_page'];
+ $result = $db->sql_query($sql);
+
+ while( $row = $db->sql_fetchrow($result) )
{
- $watch_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;watch=forum&amp;start=$start");
- $s_watching_forum = '<a href="' . $watch_url . '">' . $lang['Start_watching_forum'] . '</a>';
- $s_watching_forum_img = ( isset($images['Forum_watch']) ) ? '<a href="' . $watch_url . '"><img src="' . $images['Forum_watch'] . '" alt="' . $lang['Stop_watching_forum'] . '" title="' . $lang['Start_watching_forum'] . '" border="0"></a>' : '';
+ $topic_rowset[] = $row;
+ $total_topics++;
}
}
-//
-// Mozilla navigation bar
-//
-$nav_links['up'] = array(
- 'url' => append_sid('index.'.$phpEx),
- 'title' => sprintf($lang['Forum_Index'], $board_config['sitename'])
-);
-
-//
-// Dump out the page header and load viewforum template
-//
-$page_title = $lang['View_forum'] . ' - ' . $forum_row['forum_name'];
-include($phpbb_root_path . 'includes/page_header.'.$phpEx);
-
-$template->set_filenames(array(
- 'body' => 'viewforum_body.tpl')
-);
-make_jumpbox('viewforum.'.$phpEx);
-
-$template->assign_vars(array(
- 'FORUM_ID' => $forum_id,
- 'FORUM_NAME' => $forum_row['forum_name'],
- 'MODERATORS' => $forum_moderators,
- 'POST_IMG' => ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new'],
-
- 'FOLDER_IMG' => $images['folder'],
- 'FOLDER_NEW_IMG' => $images['folder_new'],
- 'FOLDER_HOT_IMG' => $images['folder_hot'],
- 'FOLDER_HOT_NEW_IMG' => $images['folder_hot_new'],
- 'FOLDER_LOCKED_IMG' => $images['folder_locked'],
- 'FOLDER_LOCKED_NEW_IMG' => $images['folder_locked_new'],
- 'FOLDER_STICKY_IMG' => $images['folder_sticky'],
- 'FOLDER_STICKY_NEW_IMG' => $images['folder_sticky_new'],
- 'FOLDER_ANNOUNCE_IMG' => $images['folder_announce'],
- 'FOLDER_ANNOUNCE_NEW_IMG' => $images['folder_announce_new'],
-
- 'L_TOPICS' => $lang['Topics'],
- 'L_REPLIES' => $lang['Replies'],
- 'L_VIEWS' => $lang['Views'],
- 'L_POSTS' => $lang['Posts'],
- 'L_LASTPOST' => $lang['Last_Post'],
- 'L_MODERATOR' => $l_moderators,
- 'L_MARK_TOPICS_READ' => $lang['Mark_all_topics'],
- 'L_POST_NEW_TOPIC' => ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'],
- 'L_NO_NEW_POSTS' => $lang['No_new_posts'],
- 'L_NEW_POSTS' => $lang['New_posts'],
- 'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'],
- 'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'],
- 'L_NO_NEW_POSTS_HOT' => $lang['No_new_posts_hot'],
- 'L_NEW_POSTS_HOT' => $lang['New_posts_hot'],
- 'L_ANNOUNCEMENT' => $lang['Post_Announcement'],
- 'L_STICKY' => $lang['Post_Sticky'],
- 'L_POSTED' => $lang['Posted'],
- 'L_JOINED' => $lang['Joined'],
- 'L_AUTHOR' => $lang['Author'],
-
- 'S_AUTH_LIST' => $s_auth_can,
- 'S_WATCH_FORUM' => $s_watching_forum,
+$sql = "SELECT t.*, i.icons_url, i.icons_width, i.icons_height, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
+ FROM " . TOPICS_TABLE . " t, " . ICONS_TABLE . " i, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
+ WHERE t.forum_id = $forum_id
+ AND i.icons_id = t.topic_icon
+ AND u.user_id = t.topic_poster
+ AND p.post_id = t.topic_first_post_id
+ AND p2.post_id = t.topic_last_post_id
+ AND u2.user_id = p2.poster_id
+ $limit_topics_time
+ ORDER BY t.topic_type DESC, $sort_order
+ LIMIT $start, " . $board_config['topics_per_page'];
+$result = $db->sql_query($sql);
- 'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL ."=$forum_id"),
+while( $row = $db->sql_fetchrow($result) )
+{
+ $topic_rowset[] = $row;
+ $total_topics++;
+}
- 'U_MARK_READ' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;mark=topics"))
-);
-//
-// End header
-//
+$db->sql_freeresult($result);
//
// Okay, lets dump out the page ...
//
-if( $total_topics )
+if ( $total_topics )
{
+ $row_count = 0;
+
for($i = 0; $i < $total_topics; $i++)
{
$topic_id = $topic_rowset[$i]['topic_id'];
$topic_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];
- $replies = $topic_rowset[$i]['topic_replies'];
-
$topic_type = $topic_rowset[$i]['topic_type'];
- if( $topic_type == POST_ANNOUNCE )
- {
- $topic_type = $lang['Topic_Announcement'] . ' ';
- }
- else if( $topic_type == POST_STICKY )
- {
- $topic_type = $lang['Topic_Sticky'] . ' ';
- }
- else
- {
- $topic_type = '';
- }
-
- if( $topic_rowset[$i]['topic_vote'] )
- {
- $topic_type .= $lang['Topic_Poll'] . ' ';
- }
-
- if( $topic_rowset[$i]['topic_status'] == TOPIC_MOVED )
+ $topic_type = '';
+ if ( $topic_rowset[$i]['topic_status'] == TOPIC_MOVED )
{
$topic_type = $lang['Topic_Moved'] . ' ';
$topic_id = $topic_rowset[$i]['topic_moved_id'];
- $folder_image = $images['folder'];
+ $folder_image = $theme['folder'];
$folder_alt = $lang['Topic_Moved'];
$newest_post_img = '';
}
else
{
- if( $topic_rowset[$i]['topic_type'] == POST_ANNOUNCE )
- {
- $folder = $images['folder_announce'];
- $folder_new = $images['folder_announce_new'];
- }
- else if( $topic_rowset[$i]['topic_type'] == POST_STICKY )
- {
- $folder = $images['folder_sticky'];
- $folder_new = $images['folder_sticky_new'];
- }
- else if( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED )
- {
- $folder = $images['folder_locked'];
- $folder_new = $images['folder_locked_new'];
- }
- else
+ switch ( $topic_rowset[$i]['topic_type'] )
{
- if($replies >= $board_config['hot_threshold'])
- {
- $folder = $images['folder_hot'];
- $folder_new = $images['folder_hot_new'];
- }
- else
- {
- $folder = $images['folder'];
- $folder_new = $images['folder_new'];
- }
+ case POST_ANNOUNCE:
+ $topic_type = $lang['Topic_Announcement'] . ' ';
+ $folder = $theme['folder_announce'];
+ $folder_new = $theme['folder_announce_new'];
+ break;
+ case POST_STICKY:
+ $topic_type = $lang['Topic_Sticky'] . ' ';
+ $folder = $theme['folder_sticky'];
+ $folder_new = $theme['folder_sticky_new'];
+ break;
+ case TOPIC_LOCKED:
+ $folder = $theme['folder_locked'];
+ $folder_new = $theme['folder_locked_new'];
+ break;
+ default:
+ if ( $replies >= $board_config['hot_threshold'] )
+ {
+ $folder = $theme['folder_hot'];
+ $folder_new = $theme['folder_hot_new'];
+ }
+ else
+ {
+ $folder = $theme['folder'];
+ $folder_new = $theme['folder_new'];
+ }
+ break;
}
$newest_post_img = '';
- if( $userdata['session_logged_in'] )
+ if ( $userdata['user_id'] != ANONYMOUS )
{
- if( $topic_rowset[$i]['post_time'] > $userdata['user_lastvisit'] )
+ if ( $topic_rowset[$i]['post_time'] > $userdata['user_lastvisit'] )
{
- if( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
+ if ( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
{
$unread_topics = true;
- if( !empty($tracking_topics[$topic_id]) )
+ if ( !empty($tracking_topics[$topic_id]) )
{
- if( $tracking_topics[$topic_id] >= $topic_rowset[$i]['post_time'] )
+ if ( $tracking_topics[$topic_id] >= $topic_rowset[$i]['post_time'] )
{
$unread_topics = false;
}
}
- if( !empty($tracking_forums[$forum_id]) )
+ if ( !empty($tracking_forums[$forum_id]) )
{
- if( $tracking_forums[$forum_id] >= $topic_rowset[$i]['post_time'] )
+ if ( $tracking_forums[$forum_id] >= $topic_rowset[$i]['post_time'] )
{
$unread_topics = false;
}
}
- if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
+ if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
{
- if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] >= $topic_rowset[$i]['post_time'] )
+ if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] >= $topic_rowset[$i]['post_time'] )
{
$unread_topics = false;
}
}
- if( $unread_topics )
+ if ( $unread_topics )
{
$folder_image = $folder_new;
$folder_alt = $lang['New_posts'];
- $newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
+ $newest_post_img = '<a href="viewtopic.' . $phpEx . $SID . '&amp;t=' . $topic_id . '&amp;view=newest">' . create_img($theme['goto_post_newest'], $lang['View_newest_post']) . '</a> ';
}
else
{
@@ -691,7 +466,7 @@ if( $total_topics )
$folder_image = $folder_new;
$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
- $newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
+ $newest_post_img = '<a href="viewtopic.' . $phpEx . $SID . '&amp;t=' . $topic_id . '&amp;view=newest">' . create_img($theme['goto_post_newest'], $lang['View_newest_post']) . '</a> ';
}
}
else
@@ -711,16 +486,21 @@ if( $total_topics )
}
}
- if( ( $replies + 1 ) > $board_config['posts_per_page'] )
+ if ( $topic_rowset[$i]['topic_vote'] )
+ {
+ $topic_type .= $lang['Topic_Poll'] . ' ';
+ }
+
+ if ( ( $replies + 1 ) > $board_config['posts_per_page'] )
{
$total_pages = ceil( ( $replies + 1 ) / $board_config['posts_per_page'] );
- $goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';
+ $goto_page = ' [ <img src=' . $theme['goto_post'] . ' alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';
$times = 1;
for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page'])
{
- $goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&amp;start=$j") . '">' . $times . '</a>';
- if( $times == 1 && $total_pages > 4 )
+ $goto_page .= '<a href="viewtopic.' . $phpEx . $SID . '&amp;t=' . $topic_id . '&amp;start=' . $j . '">' . $times . '</a>';
+ if ( $times == 1 && $total_pages > 4 )
{
$goto_page .= ' ... ';
$times = $total_pages - 3;
@@ -739,9 +519,9 @@ if( $total_topics )
$goto_page = '';
}
- $view_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
+ $view_topic_url = 'viewtopic.' . $phpEx . $SID . '&amp;f=' . $forum_id . '&amp;t=' . $topic_id;
- $topic_author = ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $topic_rowset[$i]['user_id']) . '">' : '';
+ $topic_author = ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $topic_rowset[$i]['user_id'] . '">' : '';
$topic_author .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? $topic_rowset[$i]['username'] : ( ( $topic_rowset[$i]['post_username'] != '' ) ? $topic_rowset[$i]['post_username'] : $lang['Guest'] );
$topic_author .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? '</a>' : '';
@@ -750,68 +530,61 @@ if( $total_topics )
$last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']);
- $last_post_author = ( $topic_rowset[$i]['id2'] == ANONYMOUS ) ? ( ($topic_rowset[$i]['post_username2'] != '' ) ? $topic_rowset[$i]['post_username2'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $topic_rowset[$i]['id2']) . '">' . $topic_rowset[$i]['user2'] . '</a>';
+ $last_post_author = ( $topic_rowset[$i]['id2'] == ANONYMOUS ) ? ( ( $topic_rowset[$i]['post_username2'] != '' ) ? $topic_rowset[$i]['post_username2'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $topic_rowset[$i]['id2'] . '">' . $topic_rowset[$i]['user2'] . '</a>';
- $last_post_url = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $topic_rowset[$i]['topic_last_post_id']) . '#' . $topic_rowset[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" border="0" /></a>';
+ $last_post_url = '<a href="viewtopic.' . $phpEx . $SID . '&amp;p=' . $topic_rowset[$i]['topic_last_post_id'] . '#' . $topic_rowset[$i]['topic_last_post_id'] . '">' . create_img($theme['goto_post_latest'], $lang['View_latest_post']) . '</a>';
$views = $topic_rowset[$i]['topic_views'];
-
- $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
- $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
+ $replies = $topic_rowset[$i]['topic_replies'];
+
+ $topic_icon = ( !empty($topic_rowset[$i]['icons_url']) ) ? '<img src="' . $board_config['icons_path'] . '/' . $topic_rowset[$i]['icons_url'] . '" width="' . $topic_rowset[$i]['icons_width'] . '" height="' . $topic_rowset[$i]['icons_height'] . '" alt="" title="" />' : '';
+
+ $topic_rating = ( !empty($topic_rowset[$i]['topic_rating']) ) ? '<img src=' . str_replace('{RATE}', $topic_rowset[$i]['topic_rating'], $theme['rating']) . ' alt="' . $topic_rowset[$i]['topic_rating'] . '" title="' . $topic_rowset[$i]['topic_rating'] . '" />' : '';
$template->assign_block_vars('topicrow', array(
- 'ROW_COLOR' => $row_color,
- 'ROW_CLASS' => $row_class,
'FORUM_ID' => $forum_id,
'TOPIC_ID' => $topic_id,
- 'TOPIC_FOLDER_IMG' => $folder_image,
+ 'TOPIC_FOLDER_IMG' => create_img($folder_image, $folder_alt),
'TOPIC_AUTHOR' => $topic_author,
'GOTO_PAGE' => $goto_page,
'REPLIES' => $replies,
'NEWEST_POST_IMG' => $newest_post_img,
'TOPIC_TITLE' => $topic_title,
'TOPIC_TYPE' => $topic_type,
+ 'TOPIC_ICON' => $topic_icon,
+ 'TOPIC_RATING' => $topic_rating,
'VIEWS' => $views,
'FIRST_POST_TIME' => $first_post_time,
'LAST_POST_TIME' => $last_post_time,
'LAST_POST_AUTHOR' => $last_post_author,
'LAST_POST_IMG' => $last_post_url,
- 'L_TOPIC_FOLDER_ALT' => $folder_alt,
+ 'S_ROW_COUNT' => $i,
'U_VIEW_TOPIC' => $view_topic_url)
);
- }
-
- $template->assign_vars(array(
- 'PAGINATION' => generate_pagination("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;topicdays=$topic_days", $topics_count, $board_config['topics_per_page'], $start),
- 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / $board_config['topics_per_page'] )),
-
- 'L_GOTO_PAGE' => $lang['Goto_page'])
- );
-}
-else
-{
- //
- // No topics
- //
- $no_topics_msg = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['No_topics_post_one'];
- $template->assign_vars(array(
- 'L_NO_TOPICS' => $no_topics_msg)
- );
-
- $template->assign_block_vars('switch_no_topics', array() );
+ $row_count++;
+ }
}
//
-// Parse the page and print
+// Dump out the page header and load viewforum template
//
-$template->pparse('body');
+$page_title = $lang['View_forum'] . ' - ' . $forum_data['forum_name'];
+
+$nav_links['up'] = array(
+ 'url' => 'index.' . $phpEx . $SID,
+ 'title' => sprintf($lang['Forum_Index'], $board_config['sitename'])
+);
+
+include($phpbb_root_path . 'includes/page_header.'.$phpEx);
+
+$template->set_filenames(array(
+ 'body' => 'viewforum_body.html')
+);
+make_jumpbox('viewforum.'.$phpEx);
-//
-// Page footer
-//
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?> \ No newline at end of file
diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php
index d1838cd69d..813f3879d0 100644
--- a/phpBB/viewonline.php
+++ b/phpBB/viewonline.php
@@ -8,7 +8,6 @@
*
* $Id$
*
- *
***************************************************************************/
/***************************************************************************
@@ -28,66 +27,38 @@ include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
-$userdata = session_pagestart($user_ip, PAGE_VIEWONLINE);
-init_userprefs($userdata);
+$userdata = $session->start();
+$acl = new auth('list', $userdata);
//
// End session management
//
//
-// Output page header and load viewonline template
+// Configure style, language, etc.
//
-$page_title = $lang['Who_is_online'];
-include($phpbb_root_path . 'includes/page_header.'.$phpEx);
-
-$template->set_filenames(array(
- 'body' => 'viewonline_body.tpl')
-);
-make_jumpbox('viewforum.'.$phpEx);
-
-$template->assign_vars(array(
- 'L_WHOSONLINE' => $lang['Who_is_online'],
- 'L_ONLINE_EXPLAIN' => $lang['Online_explain'],
- 'L_USERNAME' => $lang['Username'],
- 'L_FORUM_LOCATION' => $lang['Forum_Location'],
- 'L_LAST_UPDATE' => $lang['Last_updated'])
-);
+$session->configure($userdata);
//
// Forum info
//
-$sql = "SELECT forum_name, forum_id
+$sql = "SELECT forum_id, forum_name
FROM " . FORUMS_TABLE;
-if ( $result = $db->sql_query($sql) )
-{
- while( $row = $db->sql_fetchrow($result) )
- {
- $forum_data[$row['forum_id']] = $row['forum_name'];
- }
-}
-else
+$result = $db->sql_query($sql);
+
+while( $row = $db->sql_fetchrow($result) )
{
- message_die(GENERAL_ERROR, 'Could not obtain user/online forums information', '', __LINE__, __FILE__, $sql);
+ $forum_data[$row['forum_id']] = $row['forum_name'];
}
//
-// Get auth data
-//
-$is_auth_ary = array();
-$is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata);
-
-//
// Get user list
//
-$sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_time, s.session_page, s.session_ip
- FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
+$sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, s.session_time, s.session_page, s.session_ip
+ FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE . " s
WHERE u.user_id = s.session_user_id
AND s.session_time >= ".( time() - 300 ) . "
- ORDER BY u.username ASC, s.session_ip ASC";
-if ( !($result = $db->sql_query($sql)) )
-{
- message_die(GENERAL_ERROR, 'Could not obtain regd user/online information', '', __LINE__, __FILE__, $sql);
-}
+ ORDER BY u.username ASC, s.session_ip ASC, s.session_time DESC";
+$result = $db->sql_query($sql);
$guest_users = 0;
$registered_users = 0;
@@ -102,7 +73,7 @@ while ( $row = $db->sql_fetchrow($result) )
{
$view_online = false;
- if ( $row['session_logged_in'] )
+ if ( $row['user_id'] != ANONYMOUS )
{
$user_id = $row['user_id'];
@@ -110,16 +81,6 @@ while ( $row = $db->sql_fetchrow($result) )
{
$username = $row['username'];
- $style_color = '';
- if ( $row['user_level'] == ADMIN )
- {
- $username = '<b style="color:#' . $theme['fontcolor3'] . '">' . $username . '</b>';
- }
- else if ( $row['user_level'] == MOD )
- {
- $username = '<b style="color:#' . $theme['fontcolor2'] . '">' . $username . '</b>';
- }
-
if ( !$row['user_allow_viewonline'] )
{
$view_online = ( $userdata['user_level'] == ADMIN ) ? true : false;
@@ -155,69 +116,85 @@ while ( $row = $db->sql_fetchrow($result) )
if ( $view_online )
{
- if ( $row['session_page'] < 1 || !$is_auth_ary[$row['session_page']]['auth_view'] )
+ preg_match('/\/?([a-z]+)\.' . $phpEx . '/', $row['session_page'], $on_page);
+
+ switch ( $on_page[1] )
{
- switch( $row['session_page'] )
- {
- case PAGE_INDEX:
- $location = $lang['Forum_index'];
- $location_url = "index.$phpEx";
- break;
- case PAGE_POSTING:
- $location = $lang['Posting_message'];
- $location_url = "index.$phpEx";
- break;
- case PAGE_LOGIN:
- $location = $lang['Logging_on'];
- $location_url = "index.$phpEx";
- break;
- case PAGE_SEARCH:
- $location = $lang['Searching_forums'];
- $location_url = "search.$phpEx";
- break;
- case PAGE_PROFILE:
- $location = $lang['Viewing_profile'];
- $location_url = "index.$phpEx";
- break;
- case PAGE_VIEWONLINE:
- $location = $lang['Viewing_online'];
- $location_url = "viewonline.$phpEx";
- break;
- case PAGE_VIEWMEMBERS:
- $location = $lang['Viewing_member_list'];
- $location_url = "memberlist.$phpEx";
- break;
- case PAGE_PRIVMSGS:
- $location = $lang['Viewing_priv_msgs'];
- $location_url = "privmsg.$phpEx";
- break;
- case PAGE_FAQ:
- $location = $lang['Viewing_FAQ'];
- $location_url = "faq.$phpEx";
- break;
- default:
+ case 'index':
+ $location = $lang['Forum_index'];
+ $location_url = "index.$phpEx$SID";
+ break;
+
+ case 'posting':
+ case 'viewforum':
+ case 'viewtopic':
+ preg_match('/f=([0-9]+)/', $row['session_page'], $forum_id);
+ $forum_id = $forum_id[1];
+
+ if ( $acl->get_acl($forum_id, 'forum' , 'list') )
+ {
+ $location = '';
+ switch ( $on_page[1] )
+ {
+ case 'posting':
+ $location = sprintf($lang['Posting_message'], $forum_data[$forum_id]);
+ break;
+ case 'viewtopic':
+ $location = sprintf($lang['Reading_topic'], $forum_data[$forum_id]);
+ break;
+ case 'viewforum':
+ $location .= $forum_data[$forum_id];
+ break;
+ }
+ $location_url = "viewforum.$phpEx$SID&amp;f=$forum_id";
+ }
+ else
+ {
$location = $lang['Forum_index'];
- $location_url = "index.$phpEx";
- }
+ $location_url = "index.$phpEx$SID";
+ }
+ break;
+
+ case 'search':
+ $location = $lang['Searching_forums'];
+ $location_url = "search.$phpEx$SID";
+ break;
+
+ case 'profile':
+ $location = $lang['Viewing_profile'];
+ $location_url = "index.$phpEx$SID";
+ break;
+
+ case 'faq':
+ $location = $lang['Viewing_FAQ'];
+ $location_url = "faq.$phpEx$SID";
+ break;
+
+ case 'viewonline':
+ $location = $lang['Viewing_online'];
+ $location_url = "viewonline.$phpEx$SID";
+ break;
+
+ case 'memberslist':
+ $location = $lang['Viewing_member_list'];
+ $location_url = "memberlist.$phpEx$SID";
+ break;
+
+ default:
+ $location = $lang['Forum_index'];
+ $location_url = "index.$phpEx$SID";
+ break;
}
- else
- {
- $location_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $row['session_page']);
- $location = $forum_data[$row['session_page']];
- }
-
- $row_color = ( $$which_counter % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
- $row_class = ( $$which_counter % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars("$which_row", array(
- 'ROW_COLOR' => '#' . $row_color,
- 'ROW_CLASS' => $row_class,
'USERNAME' => $username,
'LASTUPDATE' => create_date($board_config['default_dateformat'], $row['session_time'], $board_config['board_timezone']),
'FORUM_LOCATION' => $location,
- 'U_USER_PROFILE' => append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $user_id),
- 'U_FORUM_LOCATION' => append_sid($location_url))
+ 'S_ROW_COUNT' => $$which_counter,
+
+ 'U_USER_PROFILE' => "profile.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $user_id,
+ 'U_FORUM_LOCATION' => $location_url)
);
$$which_counter++;
@@ -265,24 +242,24 @@ else
$template->assign_vars(array(
'TOTAL_REGISTERED_USERS_ONLINE' => sprintf($l_r_user_s, $registered_users) . sprintf($l_h_user_s, $hidden_users),
- 'TOTAL_GUEST_USERS_ONLINE' => sprintf($l_g_user_s, $guest_users))
-);
+ 'TOTAL_GUEST_USERS_ONLINE' => sprintf($l_g_user_s, $guest_users),
-if ( $registered_users + $hidden_users == 0 )
-{
- $template->assign_vars(array(
- 'L_NO_REGISTERED_USERS_BROWSING' => $lang['No_users_browsing'])
- );
-}
+ 'L_WHOSONLINE' => $lang['Who_is_online'],
+ 'L_ONLINE_EXPLAIN' => $lang['Online_explain'],
+ 'L_USERNAME' => $lang['Username'],
+ 'L_FORUM_LOCATION' => $lang['Forum_Location'],
+ 'L_LAST_UPDATE' => $lang['Last_updated'],
+ 'L_NO_GUESTS_BROWSING' => $lang['No_users_browsing'],
+ 'L_NO_REGISTERED_USERS_BROWSING' => $lang['No_users_browsing'])
+);
-if ( $guest_users == 0 )
-{
- $template->assign_vars(array(
- 'L_NO_GUESTS_BROWSING' => $lang['No_users_browsing'])
- );
-}
+$page_title = $lang['Who_is_online'];
+include($phpbb_root_path . 'includes/page_header.'.$phpEx);
-$template->pparse('body');
+$template->set_filenames(array(
+ 'body' => 'viewonline_body.html')
+);
+make_jumpbox('viewforum.'.$phpEx);
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 5c2e7e58a3..c458e94bb7 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -8,7 +8,6 @@
*
* $Id$
*
- *
***************************************************************************/
/***************************************************************************
@@ -29,32 +28,20 @@ include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
//
// Start initial var setup
//
-if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) )
-{
- $topic_id = intval($HTTP_GET_VARS[POST_TOPIC_URL]);
-}
-else if ( isset($HTTP_GET_VARS['topic']) )
-{
- $topic_id = intval($HTTP_GET_VARS['topic']);
-}
-
-if ( isset($HTTP_GET_VARS[POST_POST_URL]))
-{
- $post_id = intval($HTTP_GET_VARS[POST_POST_URL]);
-}
-
+$topic_id = ( isset($HTTP_GET_VARS['t']) ) ? intval($HTTP_GET_VARS['t']) : 0;
+$post_id = ( isset($HTTP_GET_VARS['p'])) ? intval($HTTP_GET_VARS['p']) : 0;
$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
-if ( !isset($topic_id) && !isset($post_id) )
+if ( empty($topic_id) && empty($post_id) )
{
- message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
+ message_die(MESSAGE, 'Topic_post_not_exist');
}
//
// Find topic id if user requested a newer
// or older topic
//
-if ( isset($HTTP_GET_VARS['view']) && empty($HTTP_GET_VARS[POST_POST_URL]) )
+if ( isset($HTTP_GET_VARS['view']) && empty($post_id) )
{
if ( $HTTP_GET_VARS['view'] == 'newest' )
{
@@ -71,26 +58,24 @@ if ( isset($HTTP_GET_VARS['view']) && empty($HTTP_GET_VARS[POST_POST_URL]) )
WHERE s.session_id = '$session_id'
AND u.user_id = s.session_user_id
AND p.topic_id = $topic_id
+ AND p.post_approved = " . TRUE . "
AND p.post_time >= u.user_lastvisit
ORDER BY p.post_time ASC
LIMIT 1";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Could not obtain newer/older topic information', '', __LINE__, __FILE__, $sql);
- }
+ $result = $db->sql_query($sql);
if ( !($row = $db->sql_fetchrow($result)) )
{
- message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit');
+ message_die(MESSAGE, 'No_new_posts_last_visit');
}
$post_id = $row['post_id'];
- header($header_location . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id", true));
+ header($header_location . 'viewtopic.' . $phpEx . '?sid=' . $session_id . '&p=' . $post_id . '#' . $post_id);
exit;
}
}
- header($header_location . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true));
+ header($header_location . 'viewtopic.' . $phpEx . $SID . '&t=' . $topic_id);
exit;
}
else if ( $HTTP_GET_VARS['view'] == 'next' || $HTTP_GET_VARS['view'] == 'previous' )
@@ -104,25 +89,17 @@ if ( isset($HTTP_GET_VARS['view']) && empty($HTTP_GET_VARS[POST_POST_URL]) )
AND p2.post_id = t2.topic_last_post_id
AND t.forum_id = t2.forum_id
AND p.post_id = t.topic_last_post_id
+ AND p.post_approved = " . TRUE . "
AND p.post_time $sql_condition p2.post_time
AND p.topic_id = t.topic_id
ORDER BY p.post_time $sql_ordering
LIMIT 1";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, "Could not obtain newer/older topic information", '', __LINE__, __FILE__, $sql);
- }
+ $result = $db->sql_query($sql);
if ( !($row = $db->sql_fetchrow($result)) )
{
- if( $HTTP_GET_VARS['view'] == 'next' )
- {
- message_die(GENERAL_MESSAGE, 'No_newer_topics');
- }
- else
- {
- message_die(GENERAL_MESSAGE, 'No_older_topics');
- }
+ $message = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'No_newer_topics' : 'No_older_topics';
+ message_die(MESSAGE, $message);
}
else
{
@@ -132,220 +109,166 @@ if ( isset($HTTP_GET_VARS['view']) && empty($HTTP_GET_VARS[POST_POST_URL]) )
}
//
+// Start session management
+//
+$userdata = $session->start();
+//
+// End session management
+//
+
+if ( $userdata['user_id'] != ANONYMOUS && isset($HTTP_POST_VARS['rating']) )
+{
+ $sql = "SELECT rating
+ FROM " . TOPICS_RATINGS_TABLE . "
+ WHERE topic_id = $topic_id
+ AND user_id = " . $userdata['user_id'];
+ $result = $db->sql_query($sql);
+
+ $rating = ( $row = $db->sql_fetchrow($result) ) ? $row['rating'] : '';
+
+ if ( empty($HTTP_POST_VARS['rating_value']) && $rating != '' )
+ {
+ }
+ else
+ {
+ $new_rating = intval($HTTP_POST_VARS['rating']);
+
+ $sql = ( $rating != '' ) ? "UPDATE " . TOPICS_RATING_TABLE . " SET rating = $new_rating WHERE user_id = " . $userdata['user_id'] . " AND topic_id = $topic_id" : "INSERT INTO " . TOPICS_RATING_TABLE . " (topic_id, user_id, rating) VALUES ($topic_id, " . $userdata['user_id'] . ", $new_rating)";
+ }
+}
+
+//
// This rather complex gaggle of code handles querying for topics but
// also allows for direct linking to a post (and the calculation of which
// page the post is on and the correct display of viewtopic)
//
-$join_sql_table = ( !isset($post_id) ) ? '' : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 ";
-$join_sql = ( !isset($post_id) ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id";
-$count_sql = ( !isset($post_id) ) ? '' : ", COUNT(p2.post_id) AS prev_posts";
+$join_sql_table = ( !$post_id ) ? '' : ', ' . POSTS_TABLE . ' p, ' . POSTS_TABLE . ' p2 ';
+$join_sql = ( !$post_id ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND p.post_approved = " . TRUE . " AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_approved = " . TRUE . " AND p2.post_id <= $post_id";
+$count_sql = ( !$post_id ) ? '' : ", COUNT(p2.post_id) AS prev_posts";
+$order_sql = ( !$post_id ) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, f.forum_name, f.forum_status, f.forum_id ORDER BY p.post_id ASC";
-$order_sql = ( !isset($post_id) ) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC";
-
-$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments" . $count_sql . "
+$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, f.forum_name, f.forum_status, f.forum_id " . $count_sql . "
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . "
WHERE $join_sql
AND f.forum_id = t.forum_id
$order_sql";
-if ( !($result = $db->sql_query($sql)) )
-{
- message_die(GENERAL_ERROR, "Could not obtain topic information", '', __LINE__, __FILE__, $sql);
-}
+$result = $db->sql_query($sql);
-if ( !($forum_row = $db->sql_fetchrow($result)) )
+if ( !($forum_data = $db->sql_fetchrow($result)) )
{
- message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
+ message_die(MESSAGE, 'Topic_post_not_exist');
}
-$forum_id = $forum_row['forum_id'];
-
//
-// Start session management
-//
-$userdata = session_pagestart($user_ip, $forum_id);
-init_userprefs($userdata);
-//
-// End session management
+// Configure style, language, etc.
//
+$userdata['user_style'] = ( $forum_data['forum_style'] ) ? $forum_data['user_style'] : $userdata['user_style'];
+$session->configure($userdata);
+
+$forum_id = $forum_data['forum_id'];
+
+$acl = new auth('forum', $userdata, $forum_id);
//
// Start auth check
//
-$is_auth = array();
-$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
-
-if( !$is_auth['auth_view'] || !$is_auth['auth_read'] )
+if ( !$acl->get_acl($forum_id, 'forum', 'read') )
{
- if ( !$userdata['session_logged_in'] )
+ if ( $userdata['user_id'] != ANONYMOUS )
{
- $redirect = ( isset($post_id) ) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
+ $redirect = ( isset($post_id) ) ? "p=$post_id" : "t=$topic_id";
$redirect .= ( isset($start) ) ? "&start=$start" : '';
- $header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
- header($header_location . append_sid("login.$phpEx?redirect=viewtopic.$phpEx&$redirect", true));
+ $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
+ header($header_location . 'login.' . $phpEx . $SID . '&redirect=viewtopic.' . $phpEx . '&' . $redirect);
+ exit;
}
- $message = ( !$is_auth['auth_view'] ) ? $lang['Topic_post_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
+ $message = sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
- message_die(GENERAL_MESSAGE, $message);
+ message_die(MESSAGE, $message);
}
//
// End auth check
//
-$forum_name = $forum_row['forum_name'];
-$topic_title = $forum_row['topic_title'];
-$topic_id = $forum_row['topic_id'];
-$topic_time = $forum_row['topic_time'];
+$forum_name = $forum_data['forum_name'];
+$topic_title = $forum_data['topic_title'];
+$topic_id = $forum_data['topic_id'];
+$topic_time = $forum_data['topic_time'];
if ( !empty($post_id) )
{
- $start = floor(($forum_row['prev_posts'] - 1) / $board_config['posts_per_page']) * $board_config['posts_per_page'];
+ $start = floor(($forum_data['prev_posts'] - 1) / $board_config['posts_per_page']) * $board_config['posts_per_page'];
}
+$s_watching_topic = '';
+$s_watching_topic_img = '';
+watch_topic_forum('topic', $s_watching_topic, $s_watching_topic_img, $userdata['user_id'], $topic_id);
+
//
-// Is user watching this thread?
+// Post ordering options
//
-if( $userdata['session_logged_in'] )
-{
- $can_watch_topic = TRUE;
+$previous_days = array(0 => $lang['All_Posts'], 1 => $lang['1_Day'], 7 => $lang['7_Days'], 14 => $lang['2_Weeks'], 30 => $lang['1_Month'], 90 => $lang['3_Months'], 180 => $lang['6_Months'], 364 => $lang['1_Year']);
+$sort_by_text = array('a' => $lang['Author'], 't' => $lang['Post_time'], 's' => $lang['Subject']);
+$sort_by = array('a' => 'u.username', 't' => 'p.post_id', 's' => 'pt.post_subject');
- $sql = "SELECT notify_status
- FROM " . TOPICS_WATCH_TABLE . "
- WHERE topic_id = $topic_id
- AND user_id = " . $userdata['user_id'];
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, "Could not obtain topic watch information", '', __LINE__, __FILE__, $sql);
- }
-
- if ( $row = $db->sql_fetchrow($result) )
+if ( isset($HTTP_POST_VARS['sort']) )
+{
+ if ( !empty($HTTP_POST_VARS['sort_days']) )
{
- if ( isset($HTTP_GET_VARS['unwatch']) )
- {
- if ( $HTTP_GET_VARS['unwatch'] == 'topic' )
- {
- $is_watching_topic = 0;
+ $sort_days = ( !empty($HTTP_POST_VARS['sort_days']) ) ? intval($HTTP_POST_VARS['sort_days']) : intval($HTTP_GET_VARS['sort_days']);
+ $min_post_time = time() - ( $sort_days * 86400 );
- $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
- $sql = "DELETE $sql_priority FROM " . TOPICS_WATCH_TABLE . "
- WHERE topic_id = $topic_id
- AND user_id = " . $userdata['user_id'];
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, "Could not delete topic watch information", '', __LINE__, __FILE__, $sql);
- }
- }
-
- $template->assign_vars(array(
- 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">')
- );
-
- $message = $lang['No_longer_watching'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
- }
- else
- {
- $is_watching_topic = TRUE;
+ $sql = "SELECT COUNT(post_id) AS num_posts
+ FROM " . POSTS_TABLE . "
+ WHERE topic_id = $topic_id
+ AND post_time >= $min_post_time
+ AND post_approved = " . TRUE;
+ $result = $db->sql_query($sql);
- if ( $row['notify_status'] )
- {
- $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
- $sql = "UPDATE $sql_priority " . TOPICS_WATCH_TABLE . "
- SET notify_status = 0
- WHERE topic_id = $topic_id
- AND user_id = " . $userdata['user_id'];
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, "Could not update topic watch information", '', __LINE__, __FILE__, $sql);
- }
- }
- }
+ $start = 0;
+ $total_replies = ( $row = $db->sql_fetchrow($result) ) ? $row['num_posts'] : 0;
+ $limit_posts_time = "AND p.post_time >= $min_post_time ";
}
else
{
- if ( isset($HTTP_GET_VARS['watch']) )
- {
- if ( $HTTP_GET_VARS['watch'] == 'topic' )
- {
- $is_watching_topic = TRUE;
-
- $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
- $sql = "INSERT $sql_priority INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)
- VALUES (" . $userdata['user_id'] . ", $topic_id, 0)";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, "Could not insert topic watch information", '', __LINE__, __FILE__, $sql);
- }
- }
-
- $template->assign_vars(array(
- 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">')
- );
-
- $message = $lang['You_are_watching'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">', '</a>');
- message_die(GENERAL_MESSAGE, $message);
- }
- else
- {
- $is_watching_topic = 0;
- }
+ $total_replies = ( $forum_data['topic_replies'] ) ? $forum_data['topic_replies'] + 1 : 1;
}
+
+ $sort_key = ( isset($HTTP_POST_VARS['sort_key']) ) ? $HTTP_POST_VARS['sort_key'] : $HTTP_GET_VARS['sort_key'];
+ $sort_dir = ( isset($HTTP_POST_VARS['sort_dir']) ) ? $HTTP_POST_VARS['sort_dir'] : $HTTP_GET_VARS['sort_dir'];
}
else
{
- if ( isset($HTTP_GET_VARS['unwatch']) )
- {
- if ( $HTTP_GET_VARS['unwatch'] == 'topic' )
- {
- $header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
- header($header_location . append_sid("login.$phpEx?redirect=viewtopic.$phpEx&" . POST_TOPIC_URL . "=$topic_id&unwatch=topic", true));
- }
- }
- else
- {
- $can_watch_topic = 0;
- $is_watching_topic = 0;
- }
+ $total_replies = $forum_data['topic_replies'] + 1;
+ $limit_posts_time = '';
+
+ $sort_days = 0;
+ $sort_key = 't';
+ $sort_dir = 'a';
}
-//
-// Generate a 'Show posts in previous x days' select box. If the postdays var is POSTed
-// then get it's value, find the number of topics with dates newer than it (to properly
-// handle pagination) and alter the main query
-//
-$previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
-$previous_days_text = array($lang['All_Posts'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']);
+$sort_order = $sort_by[$sort_key] . ' ' . ( ( $sort_dir == 'd' ) ? 'DESC' : 'ASC' );
-if( !empty($HTTP_POST_VARS['postdays']) || !empty($HTTP_GET_VARS['postdays']) )
+$select_sort_days = '<select name="sort_days">';
+foreach ( $previous_days as $day => $text )
{
- $post_days = ( !empty($HTTP_POST_VARS['postdays']) ) ? $HTTP_POST_VARS['postdays'] : $HTTP_GET_VARS['postdays'];
- $min_post_time = time() - ($post_days * 86400);
-
- $sql = "SELECT COUNT(post_id) AS num_posts
- FROM " . POSTS_TABLE . "
- WHERE topic_id = $topic_id
- AND post_time >= $min_post_time";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, "Could not obtain limited topics count information", '', __LINE__, __FILE__, $sql);
- }
-
- $total_replies = ( $row = $db->sql_fetchrow($result) ) ? $row['num_posts'] : 0;
-
- $limit_posts_time = "AND p.post_time >= $min_post_time ";
-
- if ( !empty($HTTP_POST_VARS['postdays']))
- {
- $start = 0;
- }
+ $selected = ( $sort_days == $day ) ? ' selected="selected"' : '';
+ $select_sort_days .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>';
}
-else
-{
- $total_replies = $forum_row['topic_replies'] + 1;
+$select_sort_days .= '</select>';
- $limit_posts_time = '';
- $post_days = 0;
+$select_sort = '<select name="sort_key">';
+foreach ( $sort_by_text as $key => $text )
+{
+ $selected = ( $sort_key == $key ) ? ' selected="selected"' : '';
+ $select_sort .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>';
}
+$select_sort .= '</select>';
+
+$select_sort_dir = '<select name="sort_dir">';
+$select_sort_dir .= ( $sort_dir == 'a' ) ? '<option value="a" selected="selected">' . $lang['Ascending'] . '</option><option value="d">' . $lang['Descending'] . '</option>' : '<option value="a">' . $lang['Ascending'] . '</option><option value="d" selected="selected">' . $lang['Descending'] . '</option>';
+$select_sort_dir .= '</select>';
$select_post_days = '<select name="postdays">';
for($i = 0; $i < count($previous_days); $i++)
@@ -361,7 +284,7 @@ $select_post_days .= '</select>';
if ( !empty($HTTP_POST_VARS['postorder']) || !empty($HTTP_GET_VARS['postorder']) )
{
$post_order = (!empty($HTTP_POST_VARS['postorder'])) ? $HTTP_POST_VARS['postorder'] : $HTTP_GET_VARS['postorder'];
- $post_time_order = ($post_order == "asc") ? "ASC" : "DESC";
+ $post_time_order = ( $post_order == 'asc' ) ? 'ASC' : 'DESC';
}
else
{
@@ -385,16 +308,14 @@ $select_post_order .= '</select>';
//
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
- WHERE p.topic_id = $topic_id
+ WHERE p.topic_id = $topic_id
+ AND p.post_approved = " . TRUE . "
$limit_posts_time
AND pt.post_id = p.post_id
AND u.user_id = p.poster_id
- ORDER BY p.post_time $post_time_order
- LIMIT $start, ".$board_config['posts_per_page'];
-if ( !($result = $db->sql_query($sql)) )
-{
- message_die(GENERAL_ERROR, "Could not obtain post/user information.", '', __LINE__, __FILE__, $sql);
-}
+ ORDER BY $sort_order
+ LIMIT $start, " . $board_config['posts_per_page'];
+$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
@@ -410,16 +331,13 @@ if ( $row = $db->sql_fetchrow($result) )
}
else
{
- message_die(GENERAL_MESSAGE, $lang['No_posts_topic']);
+ message_die(MESSAGE, $lang['No_posts_topic']);
}
$sql = "SELECT *
FROM " . RANKS_TABLE . "
ORDER BY rank_special, rank_min";
-if ( !($result = $db->sql_query($sql)) )
-{
- message_die(GENERAL_ERROR, "Could not obtain ranks information.", '', __LINE__, __FILE__, $sql);
-}
+$result = $db->sql_query($sql);
$ranksrow = array();
while ( $row = $db->sql_fetchrow($result) )
@@ -428,19 +346,26 @@ while ( $row = $db->sql_fetchrow($result) )
}
$db->sql_freeresult($result);
-//
-// Define censored word matches
-//
-$orig_word = array();
-$replacement_word = array();
-obtain_word_list($orig_word, $replacement_word);
-
-//
-// Censor topic title
-//
-if ( count($orig_word) )
+$rating = '';
+if ( $userdata['user_id'] != ANONYMOUS )
{
- $topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
+ $rating_text = array(-5 => $lang['Very_poor'], -2 => $lang['Quite_poor'], 0 => $lang['Unrated'], 2 => $lang['Quite_good'], 5 => $lang['Very_good']);
+
+ $sql = "SELECT rating
+ FROM " . TOPICS_RATINGS_TABLE . "
+ WHERE topic_id = $topic_id
+ AND user_id = " . $userdata['user_id'];
+ $result = $db->sql_query($sql);
+
+ $user_rating = ( $row = $db->sql_fetchrow($result) ) ? $row['rating'] : 0;
+
+ for($i = -5; $i < 6; $i++)
+ {
+ $selected = ( $user_rating == $i ) ? ' selected="selected"' : '';
+ $rating .= '<option value="' . $i . '"' . $selected . '>' . $i . ( ( !empty($rating_text[$i]) ) ? ' > ' . $rating_text[$i] : '' ) . '</option>';
+ }
+
+ $rating = '<select name="rating">' . $rating . '</select>';
}
//
@@ -461,7 +386,7 @@ if ( isset($HTTP_GET_VARS['highlight']) )
{
if ( trim($words[$i]) != '' )
{
- $highlight_match[] = '#\b(' . str_replace("*", "([\w]+)?", $words[$i]) . ')\b#is';
+ $highlight_match[] = '#\b(' . str_replace('*', '([\w]+)?', $words[$i]) . ')\b#is';
}
}
@@ -473,40 +398,50 @@ else
}
//
-// Post, reply and other URL generation for
-// templating vars
+// Define censored word matches
//
-$new_topic_url = append_sid("posting.$phpEx?mode=newtopic&amp;" . POST_FORUM_URL . "=$forum_id");
-$reply_topic_url = append_sid("posting.$phpEx?mode=reply&amp;" . POST_TOPIC_URL . "=$topic_id");
-$view_forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id");
-$view_prev_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=previous");
-$view_next_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=next");
+$orig_word = array();
+$replacement_word = array();
+obtain_word_list($orig_word, $replacement_word);
//
-// Mozilla navigation bar
+// User authorisation levels output
//
-$nav_links['prev'] = array(
- 'url' => $view_prev_topic_url,
- 'title' => $lang['View_previous_topic']
-);
-$nav_links['next'] = array(
- 'url' => $view_next_topic_url,
- 'title' => $lang['View_next_topic']
-);
-$nav_links['up'] = array(
- 'url' => $view_forum_url,
- 'title' => $forum_name
-);
+$s_forum_rules = '';
+get_forum_rules('topic', $s_forum_rules, $forum_id);
+
+$topic_mod .= ( $acl->get_acl($forum_id, 'mod', 'lock') ) ? ( ( $forum_data['topic_status'] == TOPIC_UNLOCKED ) ? '<a href="' . "modcp.$phpEx?t=$topic_id&amp;mode=lock" . '"><img src="' . $theme['topic_mod_lock'] . '" alt="' . $lang['Lock_topic'] . '" title="' . $lang['Lock_topic'] . '" border="0" /></a>&nbsp;' : '<a href="' . "modcp.$phpEx$SID&amp;t=$topic_id&amp;mode=unlock" . '"><img src="' . $theme['topic_mod_unlock'] . '" alt="' . $lang['Unlock_topic'] . '" title="' . $lang['Unlock_topic'] . '" border="0" /></a>&nbsp;' ) : '';
-$reply_img = ( $forum_row['forum_status'] == FORUM_LOCKED || $forum_row['topic_status'] == TOPIC_LOCKED ) ? $images['reply_locked'] : $images['reply_new'];
-$reply_alt = ( $forum_row['forum_status'] == FORUM_LOCKED || $forum_row['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['Reply_to_topic'];
-$post_img = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new'];
-$post_alt = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'];
+$topic_mod = ( $acl->get_acl($forum_id, 'mod', 'delete') ) ? '<a href="' . "modcp.$phpEx$SID&amp;t=$topic_id&amp;mode=delete" . '"><img src="' . $theme['topic_mod_delete'] . '" alt="' . $lang['Delete_topic'] . '" title="' . $lang['Delete_topic'] . '" border="0" /></a>&nbsp;' : '';
+
+$topic_mod .= ( $acl->get_acl($forum_id, 'mod', 'move') ) ? '<a href="' . "modcp.$phpEx$SID&amp;t=$topic_id&amp;mode=move". '"><img src="' . $theme['topic_mod_move'] . '" alt="' . $lang['Move_topic'] . '" title="' . $lang['Move_topic'] . '" border="0" /></a>&nbsp;' : '';
+
+$topic_mod .= ( $acl->get_acl($forum_id, 'mod', 'split') ) ? '<a href="' . "modcp.$phpEx$SID&amp;t=$topic_id&amp;mode=split" . '"><img src="' . $theme['topic_mod_split'] . '" alt="' . $lang['Split_topic'] . '" title="' . $lang['Split_topic'] . '" border="0" /></a>&nbsp;' : '';
+
+$topic_mod .= ( $acl->get_acl($forum_id, 'mod', 'merge') ) ? '<a href="' . "modcp.$phpEx$SID&amp;t=$topic_id&amp;mode=merge" . '"><img src="' . $theme['topic_mod_merge'] . '" alt="' . $lang['Merge_topic'] . '" title="' . $lang['Merge_topic'] . '" border="0" /></a>&nbsp;' : '';
+
+//
+// If we've got a hightlight set pass it on to pagination.
+//
+$pagination = ( $highlight_active ) ? generate_pagination("viewtopic.$phpEx$SID&amp;t=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order&amp;highlight=" . $HTTP_GET_VARS['highlight'], $total_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx$SID&amp;t=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start);
+
+//
+// Post, reply and other URL generation for
+// templating vars
+//
+$new_topic_url = 'posting.' . $phpEx . $SID . '&amp;mode=newtopic&amp;f=' . $forum_id;
+$reply_topic_url = 'posting.' . $phpEx . $SID . '&amp;mode=reply&amp;f=' . $forum_id . '&amp;t=' . $topic_id;
+$view_forum_url = 'viewforum.' . $phpEx . $SID . '&amp;f=' . $forum_id;
+$view_prev_topic_url = 'viewtopic.' . $phpEx . $SID . '&amp;f=' . $forum_id . '&amp;t=' . $topic_id . '&amp;view=previous';
+$view_next_topic_url = 'viewtopic.' . $phpEx . $SID . '&amp;f=' . $forum_id . '&amp;t=' . $topic_id . '&amp;view=next';
+
+$reply_img = ( $forum_data['forum_status'] == FORUM_LOCKED || $forum_data['topic_status'] == TOPIC_LOCKED ) ? create_img($theme['reply_locked'], $lang['Topic_locked']) : create_img($theme['reply_new'], $lang['Reply_to_topic']);
+$post_img = ( $forum_data['forum_status'] == FORUM_LOCKED ) ? create_img($theme['post_locked'], $lang['Forum_locked']) : create_img($theme['post_new'], $lang['Post_new_topic']);
//
// Set a cookie for this topic
//
-if ( $userdata['session_logged_in'] )
+if ( $userdata['user_id'] != ANONYMOUS )
{
$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
@@ -539,7 +474,7 @@ if ( $userdata['session_logged_in'] )
// Load templates
//
$template->set_filenames(array(
- 'body' => 'viewtopic_body.tpl')
+ 'body' => 'viewtopic_body.html')
);
make_jumpbox('viewforum.'.$phpEx, $forum_id);
@@ -549,53 +484,12 @@ make_jumpbox('viewforum.'.$phpEx, $forum_id);
$page_title = $lang['View_topic'] .' - ' . $topic_title;
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
-//
-// User authorisation levels output
-//
-$s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '<br />';
-$s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '<br />';
-$s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '<br />';
-$s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '<br />';
-$s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . '<br />';
-
-if ( $is_auth['auth_mod'] )
-{
- $s_auth_can .= sprintf($lang['Rules_moderate'], '<a href="' . append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
-
- $topic_mod = '<a href="' . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=delete") . '"><img src="' . $images['topic_mod_delete'] . '" alt="' . $lang['Delete_topic'] . '" title="' . $lang['Delete_topic'] . '" border="0" /></a>&nbsp;';
-
- $topic_mod .= '<a href="' . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=move"). '"><img src="' . $images['topic_mod_move'] . '" alt="' . $lang['Move_topic'] . '" title="' . $lang['Move_topic'] . '" border="0" /></a>&nbsp;';
-
- $topic_mod .= ( $forum_row['topic_status'] == TOPIC_UNLOCKED ) ? '<a href="' . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=lock") . '"><img src="' . $images['topic_mod_lock'] . '" alt="' . $lang['Lock_topic'] . '" title="' . $lang['Lock_topic'] . '" border="0" /></a>&nbsp;' : '<a href="' . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=unlock") . '"><img src="' . $images['topic_mod_unlock'] . '" alt="' . $lang['Unlock_topic'] . '" title="' . $lang['Unlock_topic'] . '" border="0" /></a>&nbsp;';
-
- $topic_mod .= '<a href="' . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=split") . '"><img src="' . $images['topic_mod_split'] . '" alt="' . $lang['Split_topic'] . '" title="' . $lang['Split_topic'] . '" border="0" /></a>&nbsp;';
-}
-
-//
-// Topic watch information
-//
-$s_watching_topic = '';
-if ( $can_watch_topic )
+if ( count($orig_word) )
{
- if ( $is_watching_topic )
- {
- $s_watching_topic = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start") . '">' . $lang['Stop_watching_topic'] . '</a>';
- $s_watching_topic_img = ( isset($images['Topic_un_watch']) ) ? '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start") . '"><img src="' . $images['Topic_un_watch'] . '" alt="' . $lang['Stop_watching_topic'] . '" title="' . $lang['Stop_watching_topic'] . '" border="0"></a>' : '';
- }
- else
- {
- $s_watching_topic = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start") . '">' . $lang['Start_watching_topic'] . '</a>';
- $s_watching_topic_img = ( isset($images['Topic_watch']) ) ? '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start") . '"><img src="' . $images['Topic_watch'] . '" alt="' . $lang['Stop_watching_topic'] . '" title="' . $lang['Start_watching_topic'] . '" border="0"></a>' : '';
- }
+ $topic_title = preg_replace($orig_word, $replacement_word, $topic_title); // Censor topic title
}
//
-// If we've got a hightlight set pass it on to pagination,
-// I get annoyed when I lose my highlight after the first page.
-//
-$pagination = ( $highlight_active ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order&amp;highlight=" . $HTTP_GET_VARS['highlight'], $total_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start);
-
-//
// Send vars to template
//
$template->assign_vars(array(
@@ -615,8 +509,6 @@ $template->assign_vars(array(
'L_POST_SUBJECT' => $lang['Post_subject'],
'L_VIEW_NEXT_TOPIC' => $lang['View_next_topic'],
'L_VIEW_PREVIOUS_TOPIC' => $lang['View_previous_topic'],
- 'L_POST_NEW_TOPIC' => $post_alt,
- 'L_POST_REPLY_TOPIC' => $reply_alt,
'L_BACK_TO_TOP' => $lang['Back_to_top'],
'L_DISPLAY_POSTS' => $lang['Display_posts'],
'L_LOCK_TOPIC' => $lang['Lock_topic'],
@@ -625,16 +517,20 @@ $template->assign_vars(array(
'L_SPLIT_TOPIC' => $lang['Split_topic'],
'L_DELETE_TOPIC' => $lang['Delete_topic'],
'L_GOTO_PAGE' => $lang['Goto_page'],
-
- 'S_TOPIC_LINK' => POST_TOPIC_URL,
- 'S_SELECT_POST_DAYS' => $select_post_days,
- 'S_SELECT_POST_ORDER' => $select_post_order,
- 'S_POST_DAYS_ACTION' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . "&amp;start=$start"),
- 'S_AUTH_LIST' => $s_auth_can,
+ 'L_SORT_BY' => $lang['Sort_by'],
+ 'L_RATE_TOPIC' => $lang['Rate_topic'],
+
+ 'S_TOPIC_LINK' => 't',
+ 'S_SELECT_SORT_DIR' => $select_sort_dir,
+ 'S_SELECT_SORT_KEY' => $select_sort,
+ 'S_SELECT_SORT_DAYS' => $select_sort_days,
+ 'S_SELECT_RATING' => $rating,
+ 'S_TOPIC_ACTION' => "viewtopic.$phpEx$SID&amp;t=" . $topic_id . "&amp;start=$start",
+ 'S_AUTH_LIST' => $s_forum_rules,
'S_TOPIC_ADMIN' => $topic_mod,
'S_WATCH_TOPIC' => $s_watching_topic,
- 'U_VIEW_TOPIC' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start&amp;postdays=$post_days&amp;postorder=$post_order&amp;highlight=" . $HTTP_GET_VARS['highlight']),
+ 'U_VIEW_TOPIC' => "viewtopic.$phpEx$SID&amp;t=$topic_id&amp;start=$start&amp;postdays=$post_days&amp;postorder=$post_order&amp;highlight=" . $HTTP_GET_VARS['highlight'],
'U_VIEW_FORUM' => $view_forum_url,
'U_VIEW_OLDER_TOPIC' => $view_prev_topic_url,
'U_VIEW_NEWER_TOPIC' => $view_next_topic_url,
@@ -643,19 +539,32 @@ $template->assign_vars(array(
);
//
+// Mozilla navigation bar
+//
+$nav_links['prev'] = array(
+ 'url' => $view_prev_topic_url,
+ 'title' => $lang['View_previous_topic']
+);
+$nav_links['next'] = array(
+ 'url' => $view_next_topic_url,
+ 'title' => $lang['View_next_topic']
+);
+$nav_links['up'] = array(
+ 'url' => $view_forum_url,
+ 'title' => $forum_name
+);
+
+//
// Does this topic contain a poll?
//
-if ( !empty($forum_row['topic_vote']) )
+if ( !empty($forum_data['topic_vote']) )
{
$sql = "SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result
FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr
WHERE vd.topic_id = $topic_id
AND vr.vote_id = vd.vote_id
ORDER BY vr.vote_option_id ASC";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, "Could not obtain vote data for this topic", '', __LINE__, __FILE__, $sql);
- }
+ $result = $db->sql_query($sql);
if ( $vote_info = $db->sql_fetchrowset($result) )
{
@@ -669,10 +578,7 @@ if ( !empty($forum_row['topic_vote']) )
FROM " . VOTE_USERS_TABLE . "
WHERE vote_id = $vote_id
AND vote_user_id = " . $userdata['user_id'];
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, "Could not obtain user vote data for this topic", '', __LINE__, __FILE__, $sql);
- }
+ $result = $db->sql_query($sql);
$user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0;
$db->sql_freeresult($result);
@@ -688,46 +594,38 @@ if ( !empty($forum_row['topic_vote']) )
$poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0;
- if ( $user_voted || $view_result || $poll_expired || !$is_auth['auth_vote'] || $forum_row['topic_status'] == TOPIC_LOCKED )
+ if ( $user_voted || $view_result || $poll_expired || !$acl->get_acl($forum_id, 'forum', 'vote') || $forum_data['topic_status'] == TOPIC_LOCKED )
{
- $template->set_filenames(array(
- 'pollbox' => 'viewtopic_poll_result.tpl')
- );
-
$vote_results_sum = 0;
-
for($i = 0; $i < $vote_options; $i++)
{
$vote_results_sum += $vote_info[$i]['vote_result'];
}
- $vote_graphic = 0;
- $vote_graphic_max = count($images['voting_graphic']);
-
for($i = 0; $i < $vote_options; $i++)
{
$vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0;
- $vote_graphic_length = round($vote_percent * $board_config['vote_graphic_length']);
-
- $vote_graphic_img = $images['voting_graphic'][$vote_graphic];
- $vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0;
+ $poll_length = round($vote_percent * $board_config['vote_graphic_length']);
+ $vote_percent = sprintf("%.1d%%", ($vote_percent * 100));
+ $vote_graphic_img = create_img($theme['voting_graphic'] . ' width="' . $poll_length . '"', $vote_percent);
if ( count($orig_word) )
{
$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
}
- $template->assign_block_vars("poll_option", array(
+ $template->assign_block_vars('poll_option', array(
'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'],
'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'],
- 'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)),
+ 'POLL_OPTION_PERCENT' => $vote_percent,
- 'POLL_OPTION_IMG' => $vote_graphic_img,
- 'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length)
+ 'POLL_OPTION_IMG' => $vote_graphic_img)
);
}
$template->assign_vars(array(
+ 'S_HAS_POLL_DISPLAY' => true,
+
'L_TOTAL_VOTES' => $lang['Total_votes'],
'TOTAL_VOTES' => $vote_results_sum)
);
@@ -735,10 +633,6 @@ if ( !empty($forum_row['topic_vote']) )
}
else
{
- $template->set_filenames(array(
- 'pollbox' => 'viewtopic_poll_ballot.tpl')
- );
-
for($i = 0; $i < $vote_options; $i++)
{
if ( count($orig_word) )
@@ -746,17 +640,19 @@ if ( !empty($forum_row['topic_vote']) )
$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
}
- $template->assign_block_vars("poll_option", array(
+ $template->assign_block_vars('poll_option', array(
'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'],
'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'])
);
}
$template->assign_vars(array(
+ 'S_HAS_POLL_OPTIONS' => true,
+
'L_SUBMIT_VOTE' => $lang['Submit_vote'],
'L_VIEW_RESULTS' => $lang['View_results'],
- 'U_VIEW_RESULTS' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order&amp;vote=viewresult"))
+ 'U_VIEW_RESULTS' => "viewtopic.$phpEx$SID&amp;t=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order&amp;vote=viewresult")
);
$s_hidden_fields = '<input type="hidden" name="topic_id" value="' . $topic_id . '"><input type="hidden" name="mode" value="vote">';
@@ -771,10 +667,8 @@ if ( !empty($forum_row['topic_vote']) )
'POLL_QUESTION' => $vote_title,
'S_HIDDEN_FIELDS' => ( !empty($s_hidden_fields) ) ? $s_hidden_fields : '',
- 'S_POLL_ACTION' => append_sid("posting.$phpEx?" . POST_TOPIC_URL . "=$topic_id"))
+ 'S_POLL_ACTION' => "posting.$phpEx$SID&amp;t=$topic_id")
);
-
- $template->assign_var_from_handle('POLL_DISPLAY', 'pollbox');
}
}
@@ -784,10 +678,12 @@ if ( !empty($forum_row['topic_vote']) )
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_views = topic_views + 1
WHERE topic_id = $topic_id";
-if ( !$db->sql_query($sql) )
-{
- message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql);
-}
+$db->sql_query($sql);
+
+//
+// Container for user details, only process once
+//
+$poster_details = array();
//
// Okay, let's do the loop, yeah come on baby let's do the loop
@@ -806,19 +702,18 @@ for($i = 0; $i < $total_posts; $i++)
$poster_joined = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Joined'] . ': ' . create_date($lang['DATE_FORMAT'], $postrow[$i]['user_regdate'], $board_config['board_timezone']) : '';
- $poster_avatar = '';
- if ( $postrow[$i]['user_avatar_type'] && $poster_id != ANONYMOUS && $postrow[$i]['user_allowavatar'] )
+ if ( $postrow[$i]['user_avatar_type'] && $poster_id != ANONYMOUS && $postrow[$i]['user_allowavatar'] && !isset($poster_details[$poster_id]) )
{
switch( $postrow[$i]['user_avatar_type'] )
{
case USER_AVATAR_UPLOAD:
- $poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
+ $poster_details[$poster_id]['avatar'] = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $postrow[$i]['user_avatar'] . '" width="' . $postrow[$i]['user_avatar_width'] . '" height="' . $postrow[$i]['user_avatar_height'] . '" border="0" alt="" />' : '';
break;
case USER_AVATAR_REMOTE:
- $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
+ $poster_details[$poster_id]['avatar'] = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $postrow[$i]['user_avatar'] . '" width="' . $postrow[$i]['user_avatar_width'] . '" height="' . $postrow[$i]['user_avatar_height'] . '" border="0" alt="" />' : '';
break;
case USER_AVATAR_GALLERY:
- $poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
+ $poster_details[$poster_id]['avatar'] = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $postrow[$i]['user_avatar'] . '" width="' . $postrow[$i]['user_avatar_width'] . '" height="' . $postrow[$i]['user_avatar_height'] . '" border="0" alt="" />' : '';
break;
}
}
@@ -826,46 +721,33 @@ for($i = 0; $i < $total_posts; $i++)
//
// Define the little post icon
//
- if ( $userdata['session_logged_in'] && $postrow[$i]['post_time'] > $userdata['user_lastvisit'] && $postrow[$i]['post_time'] > $topic_last_read )
- {
- $mini_post_img = $images['icon_minipost_new'];
- $mini_post_alt = $lang['New_post'];
- }
- else
- {
- $mini_post_img = $images['icon_minipost'];
- $mini_post_alt = $lang['Post'];
- }
+ $mini_post_img = ( $postrow[$i]['post_time'] > $userdata['user_lastvisit'] && $postrow[$i]['post_time'] > $topic_last_read ) ? create_img($theme['goto_post_new'], $lang['New_post']) : create_img($theme['goto_post'], $lang['Post']);
- $mini_post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '#' . $postrow[$i]['post_id'];
-
//
// Generate ranks, set them to empty string initially.
//
- $poster_rank = '';
- $rank_image = '';
- if ( $postrow[$i]['user_id'] == ANONYMOUS )
- {
- }
- else if ( $postrow[$i]['user_rank'] )
+ if ( !isset($poster_details[$poster_id]['rank_title']) )
{
- for($j = 0; $j < count($ranksrow); $j++)
+ if ( $postrow[$i]['user_rank'] )
{
- if ( $postrow[$i]['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
+ for($j = 0; $j < count($ranksrow); $j++)
{
- $poster_rank = $ranksrow[$j]['rank_title'];
- $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
+ if ( $postrow[$i]['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
+ {
+ $poster_details[$poster_id]['rank_title'] = $ranksrow[$j]['rank_title'];
+ $poster_details[$poster_id]['rank_image'] = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" border="0" alt="' . $poster_rank . '" title="' . $poster_rank . '" /><br />' : '';
+ }
}
}
- }
- else
- {
- for($j = 0; $j < count($ranksrow); $j++)
+ else
{
- if ( $postrow[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
+ for($j = 0; $j < count($ranksrow); $j++)
{
- $poster_rank = $ranksrow[$j]['rank_title'];
- $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
+ if ( $postrow[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
+ {
+ $poster_details[$poster_id]['rank_title'] = $ranksrow[$j]['rank_title'];
+ $poster_details[$poster_id]['rank_image'] = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" border="0" alt="' . $poster_rank . '" title="' . $poster_rank . '" /><br />' : '';
+ }
}
}
}
@@ -883,19 +765,19 @@ for($i = 0; $i < $total_posts; $i++)
if ( $poster_id != ANONYMOUS )
{
- $temp_url = append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id");
- $profile_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_profile'] . '" alt="' . $lang['Read_profile'] . '" title="' . $lang['Read_profile'] . '" border="0" /></a>';
+ $temp_url = "profile.$phpEx$SID&amp;mode=viewprofile&amp;u=$poster_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>';
- $temp_url = append_sid("privmsg.$phpEx?mode=post&amp;" . POST_USERS_URL . "=$poster_id");
- $pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>';
+ $temp_url = "privmsg.$phpEx$SID&amp;mode=post&amp;u=$poster_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>';
- if ( !empty($postrow[$i]['user_viewemail']) || $is_auth['auth_mod'] )
+ if ( !empty($postrow[$i]['user_viewemail']) || $acl->get_acl($forum_id, 'mod') )
{
- $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&amp;" . POST_USERS_URL .'=' . $poster_id) : 'mailto:' . $postrow[$i]['user_email'];
+ $email_uri = ( $board_config['board_email_form'] ) ? "profile.$phpEx$SID&amp;mode=email&amp;u=" . $poster_id : 'mailto:' . $postrow[$i]['user_email'];
- $email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>';
+ $email_img = '<a href="' . $email_uri . '">' . create_img($theme['icon_email'], $lang['Send_email']) . '</a>';
$email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';
}
else
@@ -904,13 +786,13 @@ for($i = 0; $i < $total_posts; $i++)
$email = '';
}
- $www_img = ( $postrow[$i]['user_website'] ) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '';
+ $www_img = ( $postrow[$i]['user_website'] ) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_userwww">' . create_img($theme['icon_www'], $lang['Visit_website']) . '</a>' : '';
$www = ( $postrow[$i]['user_website'] ) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_userwww">' . $lang['Visit_website'] . '</a>' : '';
if ( !empty($postrow[$i]['user_icq']) )
{
$icq_status_img = '<a href="http://wwp.icq.com/' . $postrow[$i]['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $postrow[$i]['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>';
- $icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow[$i]['user_icq'] . '"><img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ'] . '" title="' . $lang['ICQ'] . '" border="0" /></a>';
+ $icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow[$i]['user_icq'] . '">' . create_img($theme['icon_icq'], $lang['ICQ']) . '</a>';
$icq = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow[$i]['user_icq'] . '">' . $lang['ICQ'] . '</a>';
}
else
@@ -920,14 +802,14 @@ for($i = 0; $i < $total_posts; $i++)
$icq = '';
}
- $aim_img = ( $postrow[$i]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[$i]['user_aim'] . '&amp;message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : '';
+ $aim_img = ( $postrow[$i]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[$i]['user_aim'] . '&amp;message=Hello+Are+you+there?">' . create_img($theme['icon_aim'], $lang['AIM']) . '</a>' : '';
$aim = ( $postrow[$i]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[$i]['user_aim'] . '&amp;message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : '';
- $temp_url = append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id");
- $msn_img = ( $postrow[$i]['user_msnm'] ) ? '<a href="' . $temp_url . '"><img src="' . $images['icon_msnm'] . '" alt="' . $lang['MSNM'] . '" title="' . $lang['MSNM'] . '" border="0" /></a>' : '';
+ $temp_url = "profile.$phpEx$SID&amp;mode=viewprofile&amp;u=$poster_id";
+ $msn_img = ( $postrow[$i]['user_msnm'] ) ? '<a href="' . $temp_url . '">' . create_img($theme['icon_msnm'], $lang['MSNM']) . '</a>' : '';
$msn = ( $postrow[$i]['user_msnm'] ) ? '<a href="' . $temp_url . '">' . $lang['MSNM'] . '</a>' : '';
- $yim_img = ( $postrow[$i]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[$i]['user_yim'] . '&amp;.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : '';
+ $yim_img = ( $postrow[$i]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[$i]['user_yim'] . '&amp;.src=pg">' . create_img($theme['icon_yim'], $lang['YIM']) . '</a>' : '';
$yim = ( $postrow[$i]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[$i]['user_yim'] . '&amp;.src=pg">' . $lang['YIM'] . '</a>' : '';
}
else
@@ -951,18 +833,26 @@ for($i = 0; $i < $total_posts; $i++)
$yim = '';
}
- $temp_url = append_sid("posting.$phpEx?mode=quote&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
- $quote_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_quote'] . '" alt="' . $lang['Reply_with_quote'] . '" title="' . $lang['Reply_with_quote'] . '" border="0" /></a>';
+ $temp_url = 'posting.' . $phpEx . $SID . '&amp;mode=quote&amp;p=' . $postrow[$i]['post_id'];
+ $quote_img = '<a href="' . $temp_url . '">' . create_img($theme['icon_quote'], $lang['Reply_with_quote']) . '</a>';
$quote = '<a href="' . $temp_url . '">' . $lang['Reply_with_quote'] . '</a>';
- $temp_url = append_sid("search.$phpEx?search_author=" . urlencode($postrow[$i]['username']) . "&amp;showresults=posts");
- $search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . $lang['Search_user_posts'] . '" border="0" /></a>';
- $search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>';
+ if ( $acl->get_acl($forum_id, 'forum', 'search') )
+ {
+ $temp_url = 'search.' . $phpEx . $SID . '&amp;search_author=' . urlencode($postrow[$i]['username']) .'"&amp;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>';
+ }
+ else
+ {
+ $search_img = '';
+ $search = '';
+ }
- if ( ( $userdata['user_id'] == $poster_id && $is_auth['auth_edit'] ) || $is_auth['auth_mod'] )
+ if ( ( $userdata['user_id'] == $poster_id && $acl->get_acl($forum_id, 'forum', 'edit') ) || $acl->get_acl($forum_id, 'mod', 'edit') )
{
- $temp_url = append_sid("posting.$phpEx?mode=editpost&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
- $edit_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_edit'] . '" alt="' . $lang['Edit_delete_post'] . '" title="' . $lang['Edit_delete_post'] . '" border="0" /></a>';
+ $temp_url = "posting.$phpEx$SID&amp;mode=editpost&amp;p=" . $postrow[$i]['post_id'];
+ $edit_img = '<a href="' . $temp_url . '">' . create_img($theme['icon_edit'], $lang['Edit_delete_post']) . '</a>';
$edit = '<a href="' . $temp_url . '">' . $lang['Edit_delete_post'] . '</a>';
}
else
@@ -971,32 +861,28 @@ for($i = 0; $i < $total_posts; $i++)
$edit = '';
}
- if ( $is_auth['auth_mod'] )
+ if ( $acl->get_acl($forum_id, 'mod', 'ip') )
{
- $temp_url = append_sid("modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;" . POST_TOPIC_URL . "=" . $topic_id);
- $ip_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_ip'] . '" alt="' . $lang['View_IP'] . '" title="' . $lang['View_IP'] . '" border="0" /></a>';
+ $temp_url = "modcp.$phpEx$SID&amp;mode=ip&amp;p=" . $postrow[$i]['post_id'] . "&amp;t=" . $topic_id;
+ $ip_img = '<a href="' . $temp_url . '">' . create_img($theme['icon_ip'], $lang['View_IP']) . '</a>';
$ip = '<a href="' . $temp_url . '">' . $lang['View_IP'] . '</a>';
-
- $temp_url = append_sid("posting.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
- $delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" border="0" /></a>';
- $delpost = '<a href="' . $temp_url . '">' . $lang['Delete_post'] . '</a>';
}
else
{
$ip_img = '';
$ip = '';
+ }
- if ( $userdata['user_id'] == $poster_id && $is_auth['auth_delete'] && $i == $total_replies - 1 )
- {
- $temp_url = append_sid("posting.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
- $delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" border="0" /></a>';
- $delpost = '<a href="' . $temp_url . '">' . $lang['Delete_post'] . '</a>';
- }
- else
- {
- $delpost_img = '';
- $delpost = '';
- }
+ if ( ( $userdata['user_id'] == $poster_id && $acl->get_acl($forum_id, 'forum', 'delete') && $forum_topic_data['topic_last_post_id'] == $postrow[$i]['post_id'] ) || $acl->get_acl($forum_id, 'mod', 'delete') )
+ {
+ $temp_url = "posting.$phpEx$SID&amp;mode=delete&amp;p=" . $postrow[$i]['post_id'];
+ $delpost_img = '<a href="' . $temp_url . '">' . create_img($theme['icon_delete'], $lang['Delete_post']) . '</a>';
+ $delpost = '<a href="' . $temp_url . '">' . $lang['Delete_post'] . '</a>';
+ }
+ else
+ {
+ $delpost_img = '';
+ $delpost = '';
}
$post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : '';
@@ -1008,7 +894,7 @@ for($i = 0; $i < $total_posts; $i++)
$user_sig_bbcode_uid = $postrow[$i]['user_sig_bbcode_uid'];
//
- // Note! The order used for parsing the message _is_ important, moving things around could break any
+ // Note! The order used for parsing the message _is_ important, moving things around could break
// output
//
@@ -1016,14 +902,14 @@ for($i = 0; $i < $total_posts; $i++)
// If the board has HTML off but the post has HTML
// on then we process it, else leave it alone
//
- if ( !$board_config['allow_html'] )
+ if ( !$acl->get_acl($forum_id, 'forum', 'html') )
{
if ( $user_sig != '' && $userdata['user_allowhtml'] )
{
$user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $user_sig);
}
- if ( $postrow[$i]['enable_html'] )
+ if ( $postrow[$i]['enable_html'] && $acl->get_acl($forum_id, 'forum', 'bbcode') )
{
$message = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $message);
}
@@ -1032,24 +918,28 @@ for($i = 0; $i < $total_posts; $i++)
//
// Parse message and/or sig for BBCode if reqd
//
- if ( $board_config['allow_bbcode'] )
+ if ( $user_sig != '' && $user_sig_bbcode_uid != '' && !isset($poster_details[$poster_id]['sig']) && $acl->get_acl($forum_id, 'forum', 'sigs') )
{
- if ( $user_sig != '' && $user_sig_bbcode_uid != '' )
- {
- $user_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $user_sig);
- }
+ $poster_details[$poster_id]['sig'] = bbencode_second_pass($user_sig, $user_sig_bbcode_uid, $acl->get_acl($forum_id, 'forum', 'img'));
+ $poster_details[$poster_id]['sig'] = make_clickable($poster_details[$poster_id]['sig']);
- if ( $bbcode_uid != '' )
+ if ( $postrow[$i]['user_allowsmile'] )
{
- $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
+ $poster_details[$poster_id]['sig'] = smilies_pass($poster_details[$poster_id]['sig']);
}
+
+ $poster_details[$poster_id]['sig'] = '<br />_________________<br />' . str_replace("\n", "\n<br />\n", $poster_details[$poster_id]['sig']);
}
- if ( $user_sig != '' && $board_config['allow_sig'] )
+ if ( $bbcode_uid != '' )
{
- $user_sig = make_clickable($user_sig);
+ $message = ( $acl->get_acl($forum_id, 'forum', 'bbcode') ) ? bbencode_second_pass($message, $bbcode_uid, $acl->get_acl($forum_id, 'forum', 'img')) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
+ }
+
+ if ( $postrow[$i]['enable_magic_url'] )
+ {
+ $message = make_clickable($message);
}
- $message = make_clickable($message);
//
// Highlight active words (primarily for search)
@@ -1143,29 +1033,9 @@ for($i = 0; $i < $total_posts; $i++)
$message = preg_replace($orig_word, $replacement_word, $message);
}
- //
- // Parse smilies
- //
- if ( $board_config['allow_smilies'] )
+ if ( $postrow[$i]['enable_smilies'] && $acl->get_acl($forum_id, 'forum', 'smilies') )
{
- if ( $postrow[$i]['user_allowsmile'] && $user_sig != '' )
- {
- $user_sig = smilies_pass($user_sig);
- }
-
- if ( $postrow[$i]['enable_smilies'] )
- {
- $message = smilies_pass($message);
- }
- }
-
- //
- // Replace newlines (we use this rather than nl2br because
- // till recently it wasn't XHTML compliant)
- //
- if ( $user_sig != '' )
- {
- $user_sig = '<br />_________________<br />' . str_replace("\n", "\n<br />\n", $user_sig);
+ $message = smilies_pass($message);
}
$message = str_replace("\n", "\n<br />\n", $message);
@@ -1188,23 +1058,18 @@ for($i = 0; $i < $total_posts; $i++)
// Again this will be handled by the templating
// code at some point
//
- $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
- $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
-
$template->assign_block_vars('postrow', array(
- 'ROW_COLOR' => '#' . $row_color,
- 'ROW_CLASS' => $row_class,
'POSTER_NAME' => $poster,
- 'POSTER_RANK' => $poster_rank,
- 'RANK_IMAGE' => $rank_image,
+ 'POSTER_RANK' => $poster_details[$poster_id]['rank_title'],
+ 'RANK_IMAGE' => $poster_details[$poster_id]['rank_image'],
'POSTER_JOINED' => $poster_joined,
'POSTER_POSTS' => $poster_posts,
'POSTER_FROM' => $poster_from,
- 'POSTER_AVATAR' => $poster_avatar,
+ 'POSTER_AVATAR' => $poster_details[$poster_id]['avatar'],
'POST_DATE' => $post_date,
'POST_SUBJECT' => $post_subject,
'MESSAGE' => $message,
- 'SIGNATURE' => $user_sig,
+ 'SIGNATURE' => $poster_details[$poster_id]['sig'],
'EDITED_MESSAGE' => $l_edited_by,
'MINI_POST_IMG' => $mini_post_img,
@@ -1238,13 +1103,13 @@ for($i = 0; $i < $total_posts; $i++)
'L_MINI_POST_ALT' => $mini_post_alt,
+ 'S_ROW_COUNT' => $i,
+
'U_MINI_POST' => $mini_post_url,
'U_POST_ID' => $postrow[$i]['post_id'])
);
}
-$template->pparse('body');
-
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?> \ No newline at end of file