diff --git a/phpBB/common.php b/phpBB/common.php index e637594f5a..c332e35e61 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -45,13 +45,13 @@ if (!defined('PHPBB_INSTALLED')) } // Load Extensions -if ( (isset($load_extensions)) && ($load_extensions != '') ) +if (!empty($load_extensions)) { $load_extensions = explode(',', $load_extensions); - for ($i = 0; $i < count($load_extensions); $i++) + foreach ($load_extensions as $extension) { - @dl(trim($load_extensions[$i])); + @dl(trim($extension)); } } @@ -63,7 +63,7 @@ require($phpbb_root_path . 'includes/session.'.$phpEx); require($phpbb_root_path . 'includes/functions.'.$phpEx); // User related -define('ANONYMOUS', 0); +define('ANONYMOUS', 1); define('USER_ACTIVATION_NONE', 0); define('USER_ACTIVATION_SELF', 1); @@ -154,8 +154,6 @@ set_error_handler('msg_handler'); // Instantiate some basic classes $user = new user(); $auth = new auth(); - -// Need these here so instantiate them now $cache = new acm(); $template = new template(); $db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false); @@ -229,7 +227,7 @@ if (time() - $config['cache_interval'] >= $config['cache_last_gc']) // Show 'Board is disabled' message if ($config['board_disable'] && !defined('IN_ADMIN') && !defined('IN_LOGIN')) { - $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'Board_disable'; + $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; trigger_error($message); } diff --git a/phpBB/db/mysql.php b/phpBB/db/mysql.php index ba6a632b12..9e8d17b240 100644 --- a/phpBB/db/mysql.php +++ b/phpBB/db/mysql.php @@ -19,7 +19,7 @@ * ***************************************************************************/ -if ( !defined('SQL_LAYER') ) +if (!defined('SQL_LAYER')) { define('SQL_LAYER', 'mysql'); @@ -44,14 +44,14 @@ class sql_db $this->persistency = $persistency; $this->user = $sqluser; $this->password = $sqlpassword; - $this->server = $sqlserver . ( ( $port ) ? ':' . $port : '' ); + $this->server = $sqlserver . (($port) ? ':' . $port : ''); $this->dbname = $database; - $this->db_connect_id = ( $this->persistency ) ? @mysql_pconnect($this->server, $this->user, $this->password) : @mysql_connect($this->server, $this->user, $this->password); + $this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $this->password) : @mysql_connect($this->server, $this->user, $this->password); - if ( $this->db_connect_id && $this->dbname != '') + if ($this->db_connect_id && $this->dbname != '') { - if ( @mysql_select_db($this->dbname) ) + if (@mysql_select_db($this->dbname)) { return $this->db_connect_id; } @@ -93,20 +93,23 @@ class sql_db function sql_transaction($status = 'begin') { - switch ( $status ) + switch ($status) { case 'begin': $this->transaction = true; -// $result = mysql_query('BEGIN', $this->db_connect_id); + $result = @mysql_query('BEGIN', $this->db_connect_id); break; + case 'commit': $this->transaction = false; -// $result = mysql_query('COMMIT', $this->db_connect_id); + $result = @mysql_query('COMMIT', $this->db_connect_id); break; + case 'rollback': $this->transaction = false; -// $result = mysql_query('ROLLBACK', $this->db_connect_id); + $result = @mysql_query('ROLLBACK', $this->db_connect_id); break; + default: $result = true; } @@ -114,14 +117,13 @@ class sql_db return $result; } - // // Base query method - // function sql_query($query = '', $expire_time = 0) { if ($query != '') { global $cache; + if (!$expire_time || !$cache->sql_load($query, $expire_time)) { if ($expire_time) @@ -132,22 +134,26 @@ class sql_db $this->query_result = false; $this->num_queries++; - if (!empty($_REQUEST['explain'])) + if (!empty($_GET['explain'])) { global $starttime; + $curtime = explode(' ', microtime()); $curtime = $curtime[0] + $curtime[1] - $starttime; } + if (!$this->query_result = @mysql_query($query, $this->db_connect_id)) { $this->sql_error($query); } - if (!empty($_REQUEST['explain'])) + + if (!empty($_GET['explain'])) { $endtime = explode(' ', microtime()); $endtime = $endtime[0] + $endtime[1] - $starttime; $this->sql_report .= "
Query:\t" . htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n\t", $query)) . "\n\n";
+
 					if ($this->query_result)
 					{
 						$this->sql_report .= "Time before:  $curtime\nTime after:   $endtime\nElapsed time: " . ($endtime - $curtime) . "\n
"; @@ -157,7 +163,9 @@ class sql_db $error = $this->sql_error(); $this->sql_report .= 'FAILED - MySQL Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']) . '

';
 					}
+
 					$this->sql_time += $endtime - $curtime;
+
 					if (preg_match('/^SELECT/', $query))
 					{
 						$html_table = FALSE;
@@ -174,11 +182,13 @@ class sql_db
 								$this->sql_report .= "\n" . implode(" \n", array_values($row)) . " \n\n";
 							}
 						}
+
 						if ($html_table)
 						{
 							$this->sql_report .= '
'; } } + $this->sql_report .= "
\n"; } @@ -196,20 +206,17 @@ class sql_db return false; } - return ( $this->query_result) ? $this->query_result : false; + return ($this->query_result) ? $this->query_result : false; } - function sql_query_limit($query = '', $total, $offset = 0, $expire_time = 0) + function sql_query_limit($query, $total, $offset = 0, $expire_time = 0) { - if ( $query != '' ) + if ($query != '') { $this->query_result = false; $this->num_queries++; - if ( !empty($total) ) - { - $query .= ' LIMIT ' . ( ( !empty($offset) ) ? $offset . ', ' . $total : $total ); - } + $query .= ' LIMIT ' . ((!empty($offset)) ? $offset . ', ' . $total : $total); return $this->sql_query($query, $expire_time); } @@ -275,41 +282,42 @@ class sql_db return $query; } - // // Other query methods // // NOTE :: Want to remove _ALL_ reliance on sql_numrows from core code ... // don't want this here by a middle Milestone - // function sql_numrows($query_id = false) { - if ( !$query_id ) + if (!$query_id) { $query_id = $this->query_result; } - return ( $query_id ) ? @mysql_num_rows($query_id) : false; + return ($query_id) ? @mysql_num_rows($query_id) : false; } function sql_affectedrows() { - return ( $this->db_connect_id ) ? @mysql_affected_rows($this->db_connect_id) : false; + return ($this->db_connect_id) ? @mysql_affected_rows($this->db_connect_id) : false; } function sql_fetchrow($query_id = 0) { - if ( !$query_id ) + global $cache; + + if (!$query_id) { $query_id = $this->query_result; } - global $cache; if ($cache->sql_exists($query_id)) { - return $cache->sql_fetchrow($query_id); + $return = $cache->sql_fetchrow($query_id); + print_r($return); + return $return; } - return ( $query_id ) ? @mysql_fetch_assoc($query_id) : false; + return ($query_id) ? @mysql_fetch_assoc($query_id) : false; } function sql_fetchrowset($query_id = 0) @@ -371,27 +379,27 @@ class sql_db function sql_rowseek($rownum, $query_id = 0) { - if ( !$query_id ) + if (!$query_id) { $query_id = $this->query_result; } - return ( $query_id ) ? @mysql_data_seek($query_id, $rownum) : false; + return ($query_id) ? @mysql_data_seek($query_id, $rownum) : false; } function sql_nextid() { - return ( $this->db_connect_id ) ? @mysql_insert_id($this->db_connect_id) : false; + return ($this->db_connect_id) ? @mysql_insert_id($this->db_connect_id) : false; } function sql_freeresult($query_id = false) { - if ( !$query_id ) + if (!$query_id) { $query_id = $this->query_result; } - return ( $query_id ) ? @mysql_free_result($query_id) : false; + return ($query_id) ? @mysql_free_result($query_id) : false; } function sql_escape($msg) @@ -407,17 +415,17 @@ class sql_db 'code' => @mysql_errno() ); - if ( !$this->return_on_error ) + if (!$this->return_on_error) { - if ( $this->transaction ) + if ($this->transaction) { $this->sql_transaction(ROLLBACK); } - $this_page = ( !empty($_SERVER['PHP_SELF']) ) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF']; - $this_page .= '&' . ( ( !empty($_SERVER['QUERY_STRING']) ) ? $_SERVER['QUERY_STRING'] : $_ENV['QUERY_STRING'] ); + $this_page = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF']; + $this_page .= '&' . ((!empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : $_ENV['QUERY_STRING']); - $message = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . @mysql_error() . '

CALLING PAGE

' . $this_page . ( ( $sql != '' ) ? '

SQL

' . $sql : '' ) . '
'; + $message = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . @mysql_error() . '

CALLING PAGE

' . $this_page . (($sql != '') ? '

SQL

' . $sql : '') . '
'; trigger_error($message, E_USER_ERROR); } diff --git a/phpBB/db/mysql4.php b/phpBB/db/mysql4.php index 52a4a76ec7..c851acd947 100644 --- a/phpBB/db/mysql4.php +++ b/phpBB/db/mysql4.php @@ -19,7 +19,7 @@ * ***************************************************************************/ -if ( !defined('SQL_LAYER') ) +if (!defined('SQL_LAYER')) { define('SQL_LAYER', 'mysql4'); @@ -44,14 +44,14 @@ class sql_db $this->persistency = $persistency; $this->user = $sqluser; $this->password = $sqlpassword; - $this->server = $sqlserver . ( ( $port ) ? ':' . $port : '' ); + $this->server = $sqlserver . (($port) ? ':' . $port : ''); $this->dbname = $database; - $this->db_connect_id = ( $this->persistency ) ? @mysql_pconnect($this->server, $this->user, $this->password) : @mysql_connect($this->server, $this->user, $this->password); + $this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $this->password) : @mysql_connect($this->server, $this->user, $this->password); - if ( $this->db_connect_id && $this->dbname != '') + if ($this->db_connect_id && $this->dbname != '') { - if ( @mysql_select_db($this->dbname) ) + if (@mysql_select_db($this->dbname)) { return $this->db_connect_id; } @@ -93,20 +93,23 @@ class sql_db function sql_transaction($status = 'begin') { - switch ( $status ) + switch ($status) { case 'begin': $this->transaction = true; $result = mysql_query('BEGIN', $this->db_connect_id); break; + case 'commit': $this->transaction = false; $result = mysql_query('COMMIT', $this->db_connect_id); break; + case 'rollback': $this->transaction = false; $result = mysql_query('ROLLBACK', $this->db_connect_id); break; + default: $result = true; } @@ -117,88 +120,107 @@ class sql_db // // Base query method // - function sql_query($query = '') + function sql_query($query = '', $expire_time = 0) { if ($query != '') { - $this->query_result = false; - $this->num_queries++; + global $cache; - if (!empty($_REQUEST['explain'])) + if (!$expire_time || !$cache->sql_load($query, $expire_time)) { - global $starttime; - $curtime = explode(' ', microtime()); - $curtime = $curtime[0] + $curtime[1] - $starttime; - } - - if (!$this->query_result = @mysql_query($query, $this->db_connect_id)) - { - $this->sql_error($query); - } - - if (!empty($_REQUEST['explain'])) - { - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1] - $starttime; - - $this->sql_report .= "
Query:\t" . htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n\t", $query)) . "\n\n";
-				if ($this->query_result)
+				if ($expire_time)
 				{
-					$this->sql_report .= "Time before:  $curtime\nTime after:   $endtime\nElapsed time: " . ($endtime - $curtime) . "\n
"; + $cache_result = true; } - else + + $this->query_result = false; + $this->num_queries++; + + if (!empty($_GET['explain'])) { - $error = $this->sql_error(); - $this->sql_report .= 'FAILED - MySQL Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']) . '

';
+					global $starttime;
+
+					$curtime = explode(' ', microtime());
+					$curtime = $curtime[0] + $curtime[1] - $starttime;
 				}
-				$this->sql_time += $endtime - $curtime;
-				if (preg_match('/^SELECT/', $query))
+
+				if (!$this->query_result = @mysql_query($query, $this->db_connect_id))
 				{
-					$html_table = FALSE;
-					if ($result = mysql_query("EXPLAIN $query", $this->db_connect_id))
+					$this->sql_error($query);
+				}
+
+				if (!empty($_GET['explain']))
+				{
+					$endtime = explode(' ', microtime());
+					$endtime = $endtime[0] + $endtime[1] - $starttime;
+
+					$this->sql_report .= "
Query:\t" . htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n\t", $query)) . "\n\n";
+
+					if ($this->query_result)
 					{
-						while ($row = mysql_fetch_assoc($result))
+						$this->sql_report .= "Time before:  $curtime\nTime after:   $endtime\nElapsed time: " . ($endtime - $curtime) . "\n
"; + } + else + { + $error = $this->sql_error(); + $this->sql_report .= 'FAILED - MySQL Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']) . '

';
+					}
+
+					$this->sql_time += $endtime - $curtime;
+
+					if (preg_match('/^SELECT/', $query))
+					{
+						$html_table = FALSE;
+						if ($result = mysql_query("EXPLAIN $query", $this->db_connect_id))
 						{
-							if (!$html_table && count($row))
+							while ($row = mysql_fetch_assoc($result))
 							{
-								$html_table = TRUE;
-								$this->sql_report .= "\n";
-								$this->sql_report .= "\n\n\n\n";
+								if (!$html_table && count($row))
+								{
+									$html_table = TRUE;
+									$this->sql_report .= "
" . implode("", array_keys($row)) . "
\n"; + $this->sql_report .= "\n\n\n\n"; + } + $this->sql_report .= "\n\n\n\n"; } - $this->sql_report .= "\n\n\n\n"; + } + + if ($html_table) + { + $this->sql_report .= '
" . implode("", array_keys($row)) . "
" . implode(" ", array_values($row)) . " 
" . implode(" ", array_values($row)) . " 

'; } } - if ($html_table) - { - $this->sql_report .= '
'; - } + + $this->sql_report .= "
\n"; } - $this->sql_report .= "
\n"; + + $this->open_queries[] = $this->query_result; } - $this->open_queries[] = $this->query_result; + if (!empty($cache_result)) + { + $cache->sql_save($query, $this->query_result); + @mysql_free_result(array_pop($this->open_queries)); + } } else { return false; } - return ( $this->query_result) ? $this->query_result : false; + return ($this->query_result) ? $this->query_result : false; } - function sql_query_limit($query = '', $total, $offset = 0) + function sql_query_limit($query, $total, $offset = 0, $expire_time = 0) { - if ( $query != '' ) + if ($query != '') { $this->query_result = false; $this->num_queries++; - if ( !empty($total) ) - { - $query .= ' LIMIT ' . ( ( !empty($offset) ) ? $offset . ', ' . $total : $total ); - } + $query .= ' LIMIT ' . ((!empty($offset)) ? $total . ', ' . $offset : $total); - return $this->sql_query($query); + return $this->sql_query($query, $expire_time); } else { @@ -270,27 +292,34 @@ class sql_db // function sql_numrows($query_id = false) { - if ( !$query_id ) + if (!$query_id) { $query_id = $this->query_result; } - return ( $query_id ) ? @mysql_num_rows($query_id) : false; + return ($query_id) ? @mysql_num_rows($query_id) : false; } function sql_affectedrows() { - return ( $this->db_connect_id ) ? @mysql_affected_rows($this->db_connect_id) : false; + return ($this->db_connect_id) ? @mysql_affected_rows($this->db_connect_id) : false; } function sql_fetchrow($query_id = 0) { - if ( !$query_id ) + global $cache; + + if (!$query_id) { $query_id = $this->query_result; } - return ( $query_id ) ? @mysql_fetch_assoc($query_id) : false; + if ($cache->sql_exists($query_id)) + { + return $cache->sql_fetchrow($query_id); + } + + return ($query_id) ? @mysql_fetch_assoc($query_id) : false; } function sql_fetchrowset($query_id = 0) @@ -358,27 +387,27 @@ class sql_db function sql_rowseek($rownum, $query_id = 0) { - if ( !$query_id ) + if (!$query_id) { $query_id = $this->query_result; } - return ( $query_id ) ? @mysql_data_seek($query_id, $rownum) : false; + return ($query_id) ? @mysql_data_seek($query_id, $rownum) : false; } function sql_nextid() { - return ( $this->db_connect_id ) ? @mysql_insert_id($this->db_connect_id) : false; + return ($this->db_connect_id) ? @mysql_insert_id($this->db_connect_id) : false; } function sql_freeresult($query_id = false) { - if ( !$query_id ) + if (!$query_id) { $query_id = $this->query_result; } - return ( $query_id ) ? @mysql_free_result($query_id) : false; + return ($query_id) ? @mysql_free_result($query_id) : false; } function sql_escape($msg) @@ -389,17 +418,17 @@ class sql_db function sql_error($sql = '') { - if ( !$this->return_on_error ) + if (!$this->return_on_error) { - if ( $this->transaction ) + if ($this->transaction) { $this->sql_transaction(ROLLBACK); } - $this_page = ( !empty($_SERVER['PHP_SELF']) ) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF']; - $this_page .= '&' . ( ( !empty($_SERVER['QUERY_STRING']) ) ? $_SERVER['QUERY_STRING'] : $_ENV['QUERY_STRING'] ); + $this_page = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF']; + $this_page .= '&' . ((!empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : $_ENV['QUERY_STRING']); - $message = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . @mysql_error() . '

CALLING PAGE

' . $this_page . ( ( $sql != '' ) ? '

SQL

' . $sql : '' ) . '
'; + $message = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . @mysql_error() . '

CALLING PAGE

' . $this_page . (($sql != '') ? '

SQL

' . $sql : '') . '
'; trigger_error($message, E_USER_ERROR); } diff --git a/phpBB/language/en/lang_main.php b/phpBB/language/en/lang_main.php index 592af077ef..110f2d78e0 100644 --- a/phpBB/language/en/lang_main.php +++ b/phpBB/language/en/lang_main.php @@ -19,12 +19,22 @@ * ***************************************************************************/ +// DEVELOPERS PLEASE NOTE +// +// Placeholders can now contain order information, e.g. instead of +// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows +// translators to re-order the output of data while ensuring it remains correct +// +// You do not need this where single placeholders are used, e.g. 'Message %d' is fine +// equally where a string contains only two placeholders which are used to wrap text +// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine + $lang = array_merge($lang, array( - 'ENCODING' => 'iso-8859-15', - 'DIRECTION' => 'ltr', - 'LEFT' => 'left', - 'RIGHT' => 'right', - 'DATE_FORMAT' => 'd M Y', + 'ENCODING' => 'iso-8859-15', + 'DIRECTION' => 'ltr', + 'LEFT' => 'left', + 'RIGHT' => 'right', + 'DATE_FORMAT' => 'd M Y', 'FORUM' => 'Forum', 'SUBFORUM' => 'Subforum', @@ -45,6 +55,8 @@ $lang = array_merge($lang, array( 'TIME' => 'Time', 'HOURS' => 'Hours', 'MESSAGE' => 'Message', + 'POST_TIME' => 'Post time', + '1_DAY' => '1 Day', '7_DAYS' => '7 Days', '2_WEEKS' => '2 Weeks', @@ -54,7 +66,7 @@ $lang = array_merge($lang, array( '1_YEAR' => '1 Year', 'ASCENDING' => 'Ascending', 'DESCENDING' => 'Descending', - 'POST_TIME' => 'Post time', + 'GO' => 'Go', 'JUMP_TO' => 'Jump to', 'SUBMIT' => 'Submit', @@ -78,34 +90,72 @@ $lang = array_merge($lang, array( 'SELECT_FORUM' => 'Select a forum', 'VIEW_LATEST_POST' => 'View latest post', 'VIEW_NEWEST_POST' => 'View newest post', - 'PAGE_OF' => 'Page %d of %d', + 'PAGE_OF' => 'Page %1$d of %2$d', 'ICQ' => 'ICQ Number', 'AIM' => 'AIM Address', 'MSNM' => 'MSN Messenger', 'YIM' => 'Yahoo Messenger', - 'Forum_Index' => 'Board Index', + 'FORUM_INDEX' => 'Board Index', + + + 'POST_NEW_TOPIC' => 'Post new topic', + 'REPLY_TO_TOPIC' => 'Reply to topic', + 'REPLY_WITH_QUOTE' => 'Reply with quote', + + + 'RETURN_TOPIC' => 'Click %sHere%s to return to the topic', + 'RETURN_FORUM' => 'Click %sHere%s to return to the forum', + 'RETURN_LOGIN' => 'Click %sHere%s to try again', + 'RETURN_MCP' => 'Click %sHere%s to return to the Moderator Control Panel', + 'RETURN_GROUP' => 'Click %sHere%s to return to the Group Control Panel', - 'Post_new_topic' => 'Post new topic', - 'Reply_to_topic' => 'Reply to topic', - 'Reply_with_quote' => 'Reply with quote', - 'Click_return_topic' => 'Click %sHere%s to return to the topic', - 'Click_return_login' => 'Click %sHere%s to try again', - 'Click_return_forum' => 'Click %sHere%s to return to the forum', 'Click_view_message' => 'Click %sHere%s to view your message', - 'Click_return_mcp' => 'Click %sHere%s to return to the Moderator Control Panel', - 'Click_return_group' => 'Click %sHere%s to return to group information', - 'Admin_panel' => 'Go to Administration Panel', - 'Board_disable' => 'Sorry but this board is currently unavailable', - 'Board_unavailable' => 'Sorry but the board is temporarily unavailable, please try again in a few minutes', + + + 'BOARD_DISABLE' => 'Sorry but this board is currently unavailable', + 'BOARD_UNAVAILABLE' => 'Sorry but the board is temporarily unavailable, please try again in a few minutes', + 'BOARD_BANNED' => 'You have been banned from this forum
Please contact the %sboard administrator%s for more information', + + 'G_ADMINISTRATORS' => 'ADMINISTRATORS', 'G_SUPER_MODERATORS'=> 'SUPER MODERATORS', 'G_MODERATORS' => 'MODERATORS', 'G_REGISTERED' => 'REGISTERED USERS', 'G_INACTIVE' => 'INACTIVE USERS', 'G_GUESTS' => 'GUESTS', + + + 'YOU_LAST_VISIT' => 'You last visited on %s', + 'CURRENT_TIME' => 'The time now is %s', + 'SEARCH_NEW' => 'View posts since last visit', + 'SEARCH_SELF' => 'View your posts', + 'SEARCH_UNANSWERED' => 'View unanswered posts', + + 'REGISTER' => 'Register', + 'PROFILE' => 'User Control Panel', + 'SEARCH' => 'Search', + 'MEMBERLIST' => 'Members', + 'FAQ' => 'FAQ', + 'USERS' => 'Users', + 'USERGROUPS' => 'Groups', + 'LAST_POST' => 'Last Post', + 'MODERATOR' => 'Moderator', + 'MODERATORS' => 'Moderators', + 'New_pms' => '%d new messages', + 'New_pm' => '%d new message', + 'No_new_pm' => '0 new messages', + 'Unread_pms' => '%d unread messages', + 'Unread_pm' => '%d unread message', + 'No_unread_pm' => '0 unread messages', + 'You_new_pm' => 'A new private message is waiting for you in your Inbox', + 'You_new_pms' => 'New private messages are waiting for you in your Inbox', + 'You_no_new_pm' => 'No new private messages are waiting for you', + + + 'RECORD_ONLINE_USERS' => 'Most users ever online was %1$s on %2$s', 'Registered_users' => 'Registered Users:', - 'Browsing_forum_guest' => 'Users browsing this forum: %s and %d guest', - 'Browsing_forum_guests' => 'Users browsing this forum: %s and %d guests', + 'Browsing_forum_guest' => 'Users browsing this forum: %1$s and %2$d guest', + 'Browsing_forum_guests' => 'Users browsing this forum: %1$s and %2$d guests', 'Online_users_zero_total' => 'In total there are 0 users online :: ', 'Online_users_total' => 'In total there are %d users online :: ', 'Online_user_total' => 'In total there is %d user online :: ', @@ -118,40 +168,6 @@ $lang = array_merge($lang, array( 'Guest_users_zero_total' => '0 Guests', 'Guest_users_total' => '%d Guests', 'Guest_user_total' => '%d Guest', - 'Record_online_users' => 'Most users ever online was %s on %s', - 'Legend' => 'Legend', - 'Admin_online_color' => '%sAdministrator%s', - 'Mod_online_color' => '%sModerator%s', - 'User_online_color' => '%sUser%s', - 'You_last_visit' => 'You last visited on %s', - 'Current_time' => 'The time now is %s', - 'SEARCH_NEW' => 'View posts since last visit', - 'SEARCH_SELF' => 'View your posts', - 'SEARCH_UNANSWERED' => 'View unanswered posts', - 'REGISTER' => 'Register', - 'PROFILE' => 'User Control Panel', - 'Edit_profile' => 'Edit your profile', - 'SEARCH' => 'Search', - 'MEMBERLIST' => 'Members', - 'FAQ' => 'FAQ', - 'BBCode_guide' => 'BBCode Guide', - 'USERS' => 'Users', - 'USERGROUPS' => 'Groups', - 'LAST_POST' => 'Last Post', - 'MODERATOR' => 'Moderator', - 'MODERATORS' => 'Moderators', - 'VIEW_MODERATORS' => 'List forum moderators', - - 'New_pms' => '%d new messages', - 'New_pm' => '%d new message', - 'No_new_pm' => '0 new messages', - 'Unread_pms' => '%d unread messages', - 'Unread_pm' => '%d unread message', - 'No_unread_pm' => '0 unread messages', - 'You_new_pm' => 'A new private message is waiting for you in your Inbox', - 'You_new_pms' => 'New private messages are waiting for you in your Inbox', - 'You_no_new_pm' => 'No new private messages are waiting for you', - 'Posted_articles_zero_total' => 'Our users have posted a total of 0 article', 'Posted_articles_total' => 'Our users have posted a total of %d articles', 'Posted_article_total' => 'Our users have posted a total of %d article', @@ -162,7 +178,9 @@ $lang = array_merge($lang, array( 'Registered_users_total' => 'We have %d registered users', 'Registered_user_total' => 'We have %d registered user', 'Newest_user' => 'The newest registered user is %s%s%s', + 'No_new_posts_last_visit' => 'No new posts since your last visit', + 'NO_NEW_POSTS' => 'No new posts', 'NEW_POSTS' => 'New posts', 'NEW_POST' => 'New post', @@ -170,9 +188,12 @@ $lang = array_merge($lang, array( 'NEW_POSTS_HOT' => 'New posts [ Popular ]', 'NO_NEW_POSTS_LOCKED' => 'No new posts [ Locked ]', 'NEW_POSTS_LOCKED' => 'New posts [ Locked ]', + 'POST_STICKY' => 'Sticky', 'POST_ANNOUNCEMENT' => 'Announcement', 'FORUM_LOCKED' => 'Forum is locked', + + 'Enter_password' => 'Please enter your username and password to login', 'LOGIN' => 'Login', 'LOGOUT' => 'Logout', @@ -181,72 +202,85 @@ $lang = array_merge($lang, array( 'Error_login' => 'You have specified an incorrect or inactive username or an invalid password', 'Index' => 'Index', 'No_Posts' => 'No Posts', - 'No_forums' => 'This board has no forums', + 'NO_FORUMS' => 'This board has no forums', + 'NO_FORUM' => 'The forum you selected does not exist', 'Private_Message' => 'Private Message', 'Private_Messages' => 'Private Messages', 'WHO_IS_ONLINE' => 'Who is Online', 'MARK_FORUMS_READ' => 'Mark all forums read', 'Forums_marked_read' => 'All forums have been marked read', 'View_forum' => 'View Forum', - 'Forum_not_exist' => 'The forum you selected does not exist', 'Reached_on_error' => 'You have reached this page in error', 'DISPLAY_TOPICS' => 'Display topics from previous', - 'All_Topics' => 'All Topics', + 'ALL_TOPICS' => 'All Topics', 'Topic_Announcement' => 'Announcement:', 'Topic_Sticky' => 'Sticky:', 'Topic_Moved' => 'Moved:', 'Topic_Poll' => '[ Poll ]', 'MARK_TOPICS_READ' => 'Mark all topics read', 'Topics_marked_read' => 'The topics for this forum have now been marked read', - 'Rules_post_can' => 'You can post new topics in this forum', - 'Rules_post_cannot' => 'You cannot post new topics in this forum', - 'Rules_reply_can' => 'You can reply to topics in this forum', - 'Rules_reply_cannot' => 'You cannot reply to topics in this forum', - 'Rules_attach_can' => 'You can post attachments in this forum', - 'Rules_attach_cannot' => 'You cannot post attachments in this forum', - 'Rules_download_can' => 'You can download attachments in this forum', - 'Rules_download_cannot' => 'You cannot download attachments in this forum', - 'Rules_edit_can' => 'You can edit your posts in this forum', - 'Rules_edit_cannot' => 'You cannot edit your posts in this forum', - 'Rules_delete_can' => 'You can delete your posts in this forum', - 'Rules_delete_cannot' => 'You cannot delete your posts in this forum', - 'Rules_vote_can' => 'You can vote in polls in this forum', - 'Rules_vote_cannot' => 'You cannot vote in polls in this forum', + + + 'RULES_POST_CAN' => 'You can post new topics in this forum', + 'RULES_POST_CANNOT' => 'You cannot post new topics in this forum', + 'RULES_REPLY_CAN' => 'You can reply to topics in this forum', + 'RULES_REPLY_CANNOT' => 'You cannot reply to topics in this forum', + 'RULES_ATTACH_CAN' => 'You can post attachments in this forum', + 'RULES_ATTACH_CANNOT' => 'You cannot post attachments in this forum', + 'RULES_DOWNLOAD_CAN' => 'You can download attachments in this forum', + 'RULES_DOWNLOAD_CANNOT' => 'You cannot download attachments in this forum', + 'RULES_EDIT_CAN' => 'You can edit your posts in this forum', + 'RULES_EDIT_CANNOT' => 'You cannot edit your posts in this forum', + 'RULES_DELETE_CAN' => 'You can delete your posts in this forum', + 'RULES_DELETE_CANNOT' => 'You cannot delete your posts in this forum', + 'RULES_VOTE_CAN' => 'You can vote in polls in this forum', + 'RULES_VOTE_CANNOT' => 'You cannot vote in polls in this forum', + + + 'GUEST' => 'Guest', 'ACP' => '[ %sAdministration Control Panel%s ]', 'MCP' => '[ %sModerator Control Panel%s ]', - 'No_topics_post_one' => 'There are no posts in this forum
Click on the Post New Topic link on this page to post one', + + + 'NO_TOPICS' => 'There are no posts in this forum
Click on the Post New Topic link on this page to post one', + 'NO_TOPIC' => 'The requested topic does not exist', + + 'Stop_watching_forum' => 'Stop watching this forum', 'Start_watching_forum' => 'Watch this forum for new posts', 'No_longer_watching_forum' => 'You are no longer watching this forum', 'You_are_watching_forum' => 'You are now watching this forum', + 'View_topic' => 'View topic', - 'GUEST' => 'Guest', + 'POST_SUBJECT' => 'Post subject', + 'PRINT_TOPIC' => 'Printable version', 'VIEW_NEXT_TOPIC' => 'View next topic', 'VIEW_PREVIOUS_TOPIC' => 'View previous topic', - 'VIEW_RESULTS' => 'View Results', - 'No_newer_topics' => 'There are no newer topics in this forum', - 'No_older_topics' => 'There are no older topics in this forum', - 'Topic_post_not_exist' => 'The topic or post you requested does not exist', - 'No_posts_topic' => 'No posts exist for this topic', - 'POST_BELOW_KARMA' => 'This post was made by user %s whose karma is below your desired minimum. To display this post click %sHERE%s.', + 'NO_NEWER_TOPICS' => 'There are no newer topics in this forum', + 'NO_OLDER_TOPICS' => 'There are no older topics in this forum', + 'POST_IGNORE' => 'This post was made by %s who is on your ignore list. To display this post click %sHERE%s.', + 'POST_BELOW_KARMA' => 'This post was made by %1$s whose karma rating of %2$d is below your desired minimum. To display this post click %3$sHERE%4$s.', + 'POST_ENCODING' => 'This post was made in a character set different to that being used here. Some text may display incorrectly. To view this post in its proper encoding click %sHERE%s.', 'DISPLAY_POSTS' => 'Display posts from previous', 'ALL_POSTS' => 'All Posts', + 'BACK_TO_TOP' => 'Back to top', - 'READ_PROFILE' => 'View users profile', - 'SEND_EMAIL' => 'Send email', - 'VISIT_WEBSITE' => 'Visit posters website', + 'READ_PROFILE' => 'Profile', + 'SEND_EMAIL' => 'Email', + 'VISIT_WEBSITE' => 'WWW', 'ICQ_STATUS' => 'ICQ Status', - 'EDIT_DELETE_POST' => 'Edit/Delete this post', - 'VIEW_IP' => 'View IP of poster', - 'DELETE_POST' => 'Delete this post', + 'EDIT_POST' => 'Edit', + 'VIEW_IP' => 'IP', + 'DELETE_POST' => 'Delete', 'DELETE_POST_WARN' => 'Once deleted the post cannot be recovered', 'wrote' => 'wrote', 'Quote' => 'Quote', 'Code' => 'Code', - 'Edited_time_total' => 'Last edited by %s on %s, edited %d time in total', - 'Edited_times_total' => 'Last edited by %s on %s, edited %d times in total', + 'EDITED_TIME_TOTAL' => 'Last edited by %1$s on %2$s, edited %3$d time in total', + 'EDITED_TIMES_TOTAL' => 'Last edited by %1$s on %2$s, edited %3$d times in total', + 'QUICK_MOD' => 'Quick-mod tools', 'LOCK_TOPIC' => 'Lock topic', 'UNLOCK_TOPIC' => 'Unlock topic', @@ -254,17 +288,15 @@ $lang = array_merge($lang, array( 'DELETE_TOPIC' => 'Delete topic', 'SPLIT_TOPIC' => 'Split topic', 'MERGE_TOPIC' => 'Merge topic', + 'Stop_watching_topic' => 'Stop watching this topic', 'Start_watching_topic' => 'Watch this topic for replies', 'No_longer_watching_topic' => 'You are no longer watching this topic', 'You_are_watching_topic' => 'You are now watching this topic', - 'Rate_topic' => 'Rate this topic', - 'Very_poor' => 'Very Poor', - 'Quite_poor' => 'Quite Poor', - 'Unrated' => 'Unrated', - 'Quite_good' => 'Quite Good', - 'Very_good' => 'Very Good', + 'Total_votes' => 'Total Votes', + 'VIEW_RESULTS' => 'View Results', + 'MESSAGE_BODY' => 'Message body', 'MESSAGE_BODY_EXPLAIN' => 'Enter your message here, it may contain no more than %d characters.', @@ -278,6 +310,7 @@ $lang = array_merge($lang, array( 'EDIT_POST' => 'Edit post', 'OPTIONS' => 'Options', 'POST_NORMAL' => 'Normal', + 'CONFIRM_DELETE' => 'Are you sure you want to delete this post?', 'Confirm_delete_poll' => 'Are you sure you want to delete this poll?', 'Cannot_edit_time' => 'You can no longer edit or delete that post', @@ -293,16 +326,18 @@ $lang = array_merge($lang, array( 'No_post_id' => 'No post ID was specified', 'No_topic_id' => 'You must select a topic to reply to', 'No_valid_mode' => 'You can only post, reply edit or quote messages, please return and try again', - 'User_cannot_post' => 'You cannot post in this forum', - 'User_cannot_reply' => 'You cannot reply in this forum', - 'User_cannot_quote' => 'You cannot quote posts in this forum', - 'User_cannot_edit' => 'You cannot edit posts in this forum', - 'User_cannot_delete' => 'You cannot delete posts in this forum', + + 'USER_CANNOT_POST' => 'You cannot post in this forum', + 'USER_CANNOT_REPLY' => 'You cannot reply in this forum', + 'USER_CANNOT_QUOTE' => 'You cannot quote posts in this forum', + 'USER_CANNOT_EDIT' => 'You cannot edit posts in this forum', + 'USER_CANNOT_DELETE' => 'You cannot delete posts in this forum', + 'CANNOT_DELETE_REPLIED' => 'Sorry but you may not delete posts that have been replied to', + 'CANNOT_DELETE_POLL' => 'Sorry but you cannot delete an active poll', + 'EDIT_OWN_POSTS' => 'Sorry but you can only edit your own posts', + 'DELETE_OWN_POSTS' => 'Sorry but you can only delete your own posts', + 'No_such_post' => 'There is no such post, please return and try again', - 'Edit_own_posts' => 'Sorry but you can only edit your own posts', - 'Delete_own_posts' => 'Sorry but you can only delete your own posts', - 'Cannot_delete_replied' => 'Sorry but you may not delete posts that have been replied to', - 'Cannot_delete_poll' => 'Sorry but you cannot delete an active poll', 'Empty_poll_title' => 'You must enter a title for your poll', 'Too_few_poll_options' => 'You must enter at least two poll options', 'Too_many_poll_options' => 'You have tried to enter too many poll options', @@ -328,16 +363,16 @@ $lang = array_merge($lang, array( 'DISABLE_BBCODE' => 'Disable BBCode', 'DISABLE_SMILIES' => 'Disable Smilies', 'DISABLE_MAGIC_URL' => 'Do not automatically parse URLs', - 'HTML_is_ON' => 'HTML is ON', - 'HTML_is_OFF' => 'HTML is OFF', - 'BBCode_is_ON' => '%sBBCode%s is ON', - 'BBCode_is_OFF' => '%sBBCode%s is OFF', - 'Smilies_are_ON'=> 'Smilies are ON', - 'Smilies_are_OFF'=> 'Smilies are OFF', - 'Images_are_ON' => '[img] is ON', - 'Images_are_OFF'=> '[img] is OFF', - 'Flash_is_ON' => '[flash] is ON', - 'Flash_is_OFF' => '[flash] is ON', + 'HTML_IS_ON' => 'HTML is ON', + 'HTML_IS_OFF' => 'HTML is OFF', + 'BBCODE_IS_ON' => '%sBBCode%s is ON', + 'BBCODE_IS_OFF' => '%sBBCode%s is OFF', + 'SMILIES_ARE_ON'=> 'Smilies are ON', + 'SMILIES_ARE_OFF'=> 'Smilies are OFF', + 'IMAGES_ARE_ON' => '[img] is ON', + 'IMAGES_ARE_OFF'=> '[img] is OFF', + 'FLASH_IS_ON' => '[flash] is ON', + 'FLASH_IS_OFF' => '[flash] is ON', 'ATTACH_SIG' => 'Attach a signature (signatures can be altered via the UCP)', 'NOTIFY_REPLY' => 'Send me an email when a reply is posted', 'SAVE' => 'Save', @@ -372,6 +407,7 @@ $lang = array_merge($lang, array( 'CLOSE_WINDOW' => 'Close Window', 'Topic_reply_notification' => 'Topic Reply Notification', + 'User_control_panel' => 'User Control Panel', 'UCP_Main' => 'Control Panel', 'UCP_Profile' => 'Profile Settings', @@ -434,6 +470,8 @@ $lang = array_merge($lang, array( 'Sentbox_size' => 'Your Sentbox is %d%% full', 'Savebox_size' => 'Your Savebox is %d%% full', 'Click_view_privmsg' => 'Click %sHere%s to visit your Inbox', + + 'Viewing_user_profile' => 'Viewing profile :: %s', 'About_user' => 'All about %s', 'Preferences' => 'Preferences', @@ -543,6 +581,7 @@ $lang = array_merge($lang, array( 'AGREE' => 'I agree to these terms', 'CONFIRM_CODE' => 'Confirmation code', 'CONFIRM_CODE_EXPLAIN' => 'Enter the code exactly as you see it in the image', + 'Wrong_activation' => 'The activation key you supplied does not match any in the database', 'Send_password' => 'Send me a new password', @@ -641,6 +680,8 @@ $lang = array_merge($lang, array( 'Subscribe' => 'Subscribe', 'Unsubscribe' => 'Unsubscribe', 'View_Information' => 'View Information', + + 'Search_query' => 'Search Query', 'Search_options' => 'Search Options', 'Search_keywords' => 'Search for Keywords', @@ -670,6 +711,8 @@ $lang = array_merge($lang, array( 'No_search_match' => 'No topics or posts met your search criteria', 'Found_search_match' => 'Search found %d match', 'Found_search_matches' => 'Search found %d matches', + + 'Sorry_auth_announce' => 'Sorry but only %s can post announcements in this forum', 'Sorry_auth_sticky' => 'Sorry but only %s can post sticky messages in this forum', 'Sorry_auth_read' => 'Sorry but only %s can read topics in this forum', @@ -685,7 +728,8 @@ $lang = array_merge($lang, array( 'Auth_Administrators' => 'administrators', 'Not_Moderator' => 'You are not a moderator of this forum', 'Not_Authorised' => 'Not Authorised', - 'You_been_banned' => 'You have been banned from this forum
Please contact the %sboard administrator%s for more information', + + 'Reg_users_zero_online' => 'There are 0 Registered users and ', 'Reg_users_online' => 'There are %d Registered users and ', 'Reg_user_online' => 'There is %d Registered user and ', @@ -710,6 +754,7 @@ $lang = array_merge($lang, array( 'Viewing_priv_msgs' => 'Viewing Private Messages', 'Viewing_FAQ' => 'Viewing FAQ', + 'MOD_CP' => 'Moderator Control Panel', 'MOD_CP_EXPLAIN' => 'Using the form below you can perform mass moderation operations on this forum. You can lock, unlock, move or delete any number of topics.', 'SELECT' => 'Select', diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 56e6fa2c6f..53ef269ddc 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -24,39 +24,45 @@ $phpbb_root_path = './'; include($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'common.'.$phpEx); + // Start initial var setup -$mark_read = (!empty($_GET['mark'])) ? $_GET['mark'] : ''; $forum_id = (!empty($_GET['f'])) ? intval($_GET['f']) : 0; $start = (isset($_GET['start'])) ? intval($_GET['start']) : 0; -$sort_key = (!empty($_POST['sort_key'])) ? $_POST['sort_key']{0} : 't'; -$sort_dir = (!empty($_POST['sort_dir'])) ? $_POST['sort_dir']{0} : 'd'; -// End initial var setup +$mark_read = (!empty($_GET['mark'])) ? $_GET['mark'] : ''; +$sort_days = (!empty($_REQUEST['sort_days'])) ? intval($_REQUEST['sort_days']) : 0; +$sort_key = (!empty($_REQUEST['sort_key'])) ? $_REQUEST['sort_key'] : 't'; +$sort_dir = (!empty($_REQUEST['sort_dir'])) ? $_REQUEST['sort_dir'] : 'd'; + // Start session //$user->fetch_data(array()); $user->start(); + // Check if the user has actually sent a forum ID with his/her request // If not give them a nice error page. if (!$forum_id) { - trigger_error('Forum_not_exist'); + trigger_error('NO_FORUM'); } + +// Grab appropriate forum data if ($user->data['user_id'] == ANONYMOUS) { - $sql = 'SELECT * FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $forum_id; + $sql = 'SELECT * + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $forum_id; } else { switch (SQL_LAYER) { - //TODO case 'oracle': - break; + //TODO + break; default: - /* $sql = 'SELECT f.*, tw.topics_list, fw.notify_status FROM ' . FORUMS_TABLE . ' f @@ -64,28 +70,36 @@ else LEFT JOIN " . FORUMS_WATCH_TABLE . ' fw ON fw.user_id = ' . $user->data['user_id'] . ' AND f.forum_id = fw.forum_id WHERE f.forum_id = ' . $forum_id; */ - $sql = 'SELECT f.*, fw.notify_status, lr.lastread_time, lr.lastread_type - FROM ' . FORUMS_TABLE . ' f - LEFT JOIN '.LASTREAD_TABLE.' lr ON ( - lr.user_id = '.$user->data['user_id'].' - AND lr.forum_id = '.-$forum_id.') - LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON ( - fw.user_id = ' . $user->data['user_id'] . ' - AND f.forum_id = fw.forum_id) + $sql = 'SELECT f.*, fw.notify_status + FROM (' . FORUMS_TABLE . ' f + LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON fw.forum_id = f.forum_id + AND fw.user_id = ' . $user->data['user_id'] . ') WHERE f.forum_id = ' . $forum_id; + // UNION if necessary? +/* $sql = "SELECT * + FROM " . FORUMS_TABLE . " + WHERE forum_id = $forum_id + UNION + SELECT notify_status, NULL, NULL, ... + FROM " . FORUMS_WATCH_TABLE . " + WHERE forum_id = $forum_id + AND user_id = " . $user->data['user_id'];*/ } } $result = $db->sql_query($sql); if (!$forum_data = $db->sql_fetchrow($result)) { - trigger_error('Forum_not_exist'); + trigger_error('NO_FORUM'); } +$db->sql_freeresult($result); + // Configure style, language, etc. $user->setup(false, $forum_data['forum_style']); $auth->acl($user->data, $forum_id); -// Auth check + +// Permissions check if (!$auth->acl_gets('f_read', 'm_', 'a_', $forum_id)) { if ($user->data['user_id'] == ANONYMOUS) @@ -93,17 +107,17 @@ if (!$auth->acl_gets('f_read', 'm_', 'a_', $forum_id)) redirect("login.$phpEx$SID&redirect=viewforum.$phpEx&f=$forum_id" . ((isset($start)) ? "&start=$start" : '')); } - trigger_error('Sorry_auth_read'); + trigger_error('SORRY_AUTH_READ'); } -// End of auth check + // Build navigation links generate_forum_nav($forum_data); -// Moderators -$forum_moderators = array(); // Do we have subforums? +$moderators = array(); + if ($forum_data['left_id'] != $forum_data['right_id'] - 1) { include($phpbb_root_path . 'includes/functions_display.' . $phpEx); @@ -112,9 +126,10 @@ if ($forum_data['left_id'] != $forum_data['right_id'] - 1) else { $template->assign_var('S_HAS_SUBFORUM', FALSE); - get_moderators($forum_moderators, $forum_id); + get_moderators($moderators, $forum_id); } + // Output forum listing if it is postable if ($forum_data['forum_postable']) { @@ -130,12 +145,12 @@ if ($forum_data['forum_postable']) ); } - $message = $user->lang['Topics_marked_read'] . '

' . sprintf($user->lang['Click_return_forum'], '', ' '); + $message = $user->lang['TOPICS_MARKED_READ'] . '

' . sprintf($user->lang['RETURN_FORUM'], '', ' '); trigger_error($message); } - // End handle marking posts - // Do the forum Prune + + // Do the forum Prune - cron type job ... if ($config['prune_enable'] && $auth->acl_get('a_')) { if ($forum_data['prune_next'] < time() && $forum_data['prune_enable']) @@ -144,36 +159,36 @@ if ($forum_data['forum_postable']) auto_prune($forum_id); } } - // End of forum prune + // Forum rules, subscription info and word censors - $s_watching_forum = ''; - $s_watching_forum_img = ''; + $s_watching_forum = $s_watching_forum_img = ''; $notify_status = (isset($forum_data['notify_status'])) ? $forum_data['notify_status'] : NULL; watch_topic_forum('forum', $s_watching_forum, $s_watching_forum_img, $user->data['user_id'], $forum_id, $notify_status); $s_forum_rules = ''; - get_forum_rules('forum', $s_forum_rules, $forum_id); + gen_forum_rules('forum', $forum_id); - // Grab censored words $censors = array(); obtain_word_list($censors); - - // Topic ordering options - $previous_days = array(0 => $user->lang['All_Topics'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']); - $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->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'); + $limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']); - $sort_days = $topic_days = ''; - if (isset($_POST['sort'])) + $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); + $sort_by_sql = array('a' => 't.topic_last_poster_name', 't' => 't.topic_last_post_id', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views'); + + gen_sort_selects($limit_days, $sort_by_text, $s_limit_days, $s_sort_key, $s_sort_dir); + + + // Limit topics to certain time frame, obtain correct topic count + $topic_days = ''; + if (isset($_REQUEST['sort'])) { - if (!empty($_POST['sort_days'])) + if ($sort_days) { - $sort_days = intval($_POST['sort_days']); - $min_topic_time = time() - ( $sort_days * 86400 ); + $min_topic_time = time() - ($sort_days * 86400); // ref type on as rows as topics ... also not great $sql = "SELECT COUNT(topic_id) AS forum_topics @@ -197,43 +212,20 @@ if ($forum_data['forum_postable']) $limit_topics_time = ''; } - $sort_order = $sort_by[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); - - $select_sort_days = ''; - - $select_sort = ''; - - $select_sort_dir = ''; - - - - $post_alt = (intval($forum_data['forum_status']) == ITEM_LOCKED) ? 'Forum_locked' : 'Post_new_topic'; - + // Select the sort order + $sort_order_sql = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); // Basic pagewide vars - $template->assign_vars(array( - 'S_IS_POSTABLE' => TRUE, - 'POST_IMG' => (intval($forum_data['forum_status']) == ITEM_LOCKED) ? $user->img('post_locked', $post_alt) : $user->img('post_new', $post_alt), - 'PAGINATION' => generate_pagination("viewforum.$phpEx$SID&f=$forum_id&topicdays=$topic_days", $topics_count, $config['topics_per_page'], $start), - 'PAGE_NUMBER' => sprintf($user->lang['PAGE_OF'], (floor( $start / $config['topics_per_page'] ) + 1), ceil( $topics_count / $config['topics_per_page'] )), - 'MOD_CP' => ($auth->acl_gets('m_', 'a_', $forum_id)) ? sprintf($user->lang['MCP'], '', '') : '', - 'MODERATORS' => (!empty($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : $user->lang['NONE'], + $post_alt = (intval($forum_data['forum_status']) == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'POST_NEW_TOPIC'; + $template->assign_vars(array( + 'PAGINATION' => generate_pagination("viewforum.$phpEx$SID&f=$forum_id", $topics_count, $config['topics_per_page'], $start), + 'PAGE_NUMBER' => on_page($topics_count, $config['topics_per_page'], $start), + 'MOD_CP' => ($auth->acl_gets('m_', 'a_', $forum_id)) ? sprintf($user->lang['MCP'], '', '') : '', + 'MODERATORS' => (!empty($moderators[$forum_id])) ? implode(', ', $moderators[$forum_id]) : $user->lang['NONE'], + + 'POST_IMG' => (intval($forum_data['forum_status']) == ITEM_LOCKED) ? $user->img('post_locked', $post_alt) : $user->img('post_new', $post_alt), 'FOLDER_IMG' => $user->img('folder', 'NO_NEW_POSTS'), 'FOLDER_NEW_IMG' => $user->img('folder_new', 'NEW_POSTS'), 'FOLDER_HOT_IMG' => $user->img('folder_hot', 'NO_NEW_POSTS_HOT'), @@ -243,80 +235,68 @@ if ($forum_data['forum_postable']) 'FOLDER_STICKY_IMG' => $user->img('folder_sticky', 'POST_STICKY'), 'FOLDER_STICKY_NEW_IMG' => $user->img('folder_sticky_new', 'POST_STICKY'), 'FOLDER_ANNOUNCE_IMG' => $user->img('folder_announce', 'POST_ANNOUNCEMENT'), - 'FOLDER_ANNOUNCE_NEW_IMG' => $user->img('folder_announce_new', 'POST_ANNOUNCEMENT'), + 'FOLDER_ANNOUNCE_NEW_IMG'=> $user->img('folder_announce_new', 'POST_ANNOUNCEMENT'), - 'L_NO_TOPICS' => ( $forum_data['forum_status'] == ITEM_LOCKED ) ? $user->lang['Forum_locked'] : $user->lang['No_topics_post_one'], + 'L_NO_TOPICS' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['FORUM_LOCKED'] : $user->lang['NO_TOPICS'], + 'S_IS_POSTABLE' => TRUE, + 'S_SELECT_SORT_DIR' => $s_sort_dir, + 'S_SELECT_SORT_KEY' => $s_sort_key, + 'S_SELECT_SORT_DAYS'=> $s_limit_days, 'S_TOPIC_ICONS' => ($forum_data['enable_icons']) ? true : false, - '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 . '&f=' . $forum_id . "&start=$start", 'U_POST_NEW_TOPIC' => 'posting.' . $phpEx . $SID . '&mode=post&f=' . $forum_id, - 'U_VIEW_MODERATORS' => 'memberslist.' . $phpEx . $SID . '&mode=moderators&f=' . $forum_id, 'U_MARK_READ' => 'viewforum.' . $phpEx . $SID . '&f=' . $forum_id . '&mark=topics') ); - // Grab icons $icons = array(); obtain_icons($icons); - - // Grab all the basic data. If we're not on page 1 we also grab any - // announcements that may exist. + // Grab all topic data $total_topics = 0; $topics_list = ''; - $topic_rowset = array(); + $row_ary = array(); - if (empty($forum_data['topics_list'])) - { - $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, lr.lastread_time, lr.lastread_type - FROM " . TOPICS_TABLE . " t - LEFT JOIN " . LASTREAD_TABLE . " lr ON ( - lr.user_id = " . $user->data['user_id'] . " - AND t.topic_id=lr.topic_id) - , " . USERS_TABLE . " u, " . USERS_TABLE . " u2 - WHERE t.forum_id = $forum_id +// if (empty($forum_data['topics_list'])) +// { + $sql = 'SELECT t.*, lr.lastread_time, lr.lastread_type + FROM (' . TOPICS_TABLE . ' t + LEFT JOIN ' . LASTREAD_TABLE . ' lr ON lr.topic_id = t.topic_id + AND lr.user_id = ' . $user->data['user_id'] . ") + WHERE t.forum_id = $forum_id AND t.topic_type = " . POST_ANNOUNCE . " - AND u.user_id = t.topic_poster - AND u2.user_id = t.topic_last_poster_id - ORDER BY $sort_order + ORDER BY $sort_order_sql LIMIT " . $config['topics_per_page']; $result = $db->sql_query($sql); - while( $row = $db->sql_fetchrow($result) ) + while($row = $db->sql_fetchrow($result)) { - $topics_list .= '.' . str_pad(base_convert($row['topic_id'], 10, 36), 5, '0', STR_PAD_LEFT); - $topic_rowset[] = $row; +// $topics_list .= '.' . str_pad(base_convert($row['topic_id'], 10, 36), 5, '0', STR_PAD_LEFT); + $row_ary[] = $row; $total_topics++; } $db->sql_freeresult($result); - $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, lr.lastread_time, lr.lastread_type - FROM " . TOPICS_TABLE . " t - LEFT JOIN " . LASTREAD_TABLE . " lr ON ( - lr.user_id = " . $user->data['user_id'] . " - AND t.topic_id=lr.topic_id) - , " . USERS_TABLE . " u, " . USERS_TABLE . " u2 - WHERE t.forum_id = $forum_id - AND t.topic_approved = 1 - AND u.user_id = t.topic_poster - AND u2.user_id = t.topic_last_poster_id + $sql = 'SELECT t.*, lr.lastread_time, lr.lastread_type + FROM (' . TOPICS_TABLE . ' t + LEFT JOIN ' . LASTREAD_TABLE . ' lr ON lr.topic_id = t.topic_id + AND lr.user_id = ' . $user->data['user_id'] . ") + WHERE t.forum_id = $forum_id + AND t.topic_approved = 1 $limit_topics_time - ORDER BY t.topic_type DESC, $sort_order + ORDER BY t.topic_type DESC, $sort_order_sql LIMIT $start, " . $config['topics_per_page']; - } +/* } else { -/* + $topic_ids = array(); - preg_match_all('/.{5,5}/', $forum_data['topics_list'], $m); + preg_match_all('/.{5,5}/', $forum_data['topics_list'], $m);// explode('.' ? foreach ($m[0] as $topic_id) { $topic_ids[] = base_convert($topic_id, 36, 10); @@ -328,45 +308,41 @@ if ($forum_data['forum_postable']) AND u.user_id = t.topic_poster AND u2.user_id = t.topic_last_poster_id ORDER BY $sort_order"; -*/ - } - + }*/ $result = $db->sql_query($sql); - while( $row = $db->sql_fetchrow($result) ) + + while($row = $db->sql_fetchrow($result)) { - $topics_list .= str_pad(base_convert($row['topic_id'], 10, 36), 5, '0', STR_PAD_LEFT); - $topic_rowset[] = $row; +// $topics_list .= str_pad(base_convert($row['topic_id'], 10, 36), 5, '0', STR_PAD_LEFT); + $row_ary[] = $row; $total_topics++; } $db->sql_freeresult($result); +/* if (empty($forum_data['topics_list']) && !empty($topics_list)) { -// $sql = 'INSERT INTO ' . TOPICS_PREFETCH_TABLE . " (forum_id, start, sort_key, sort_dir, topics_list) -// VALUES ($forum_id, $start, '$sort_key', '$sort_dir', '$topics_list')"; -// $db->sql_query($sql); + $sql = 'INSERT INTO ' . TOPICS_PREFETCH_TABLE . " (forum_id, start, sort_key, sort_dir, topics_list) + VALUES ($forum_id, $start, '$sort_key', '$sort_dir', '$topics_list')"; + $db->sql_query($sql); } - - +*/ // Okay, lets dump out the page ... if ($total_topics) { $i = 0; - foreach ($topic_rowset as $topic_row) + foreach ($row_ary as $row) { - $topic_id = $topic_row['topic_id']; - $replies = $topic_row['topic_replies']; - - $topic_title = (!empty($censors)) ? preg_replace($censors['match'], $censors['replace'], $topic_row['topic_title']) : $topic_row['topic_title']; + $topic_id = $row['topic_id']; // Type and folder $topic_type = ''; - if ($topic_row['topic_status'] == ITEM_MOVED) + if ($row['topic_status'] == ITEM_MOVED) { - $topic_type = $user->lang['Topic_Moved'] . ' '; - $topic_id = $topic_row['topic_moved_id']; + $topic_type = $user->lang['TOPIC_MOVED'] . ' '; + $topic_id = $row['topic_moved_id']; $folder_image = 'folder'; $folder_alt = 'Topic_Moved'; @@ -374,22 +350,25 @@ if ($forum_data['forum_postable']) } else { - switch ($topic_row['topic_type']) + switch ($row['topic_type']) { case POST_ANNOUNCE: - $topic_type = $user->lang['Topic_Announcement'] . ' '; + $topic_type = $user->lang['TOPIC_ANNOUNCEMENT'] . ' '; $folder = 'folder_announce'; $folder_new = 'folder_announce_new'; break; + case POST_STICKY: - $topic_type = $user->lang['Topic_Sticky'] . ' '; + $topic_type = $user->lang['TOPIC_STICKY'] . ' '; $folder = 'folder_sticky'; $folder_new = 'folder_sticky_new'; break; + case ITEM_LOCKED: $folder = 'folder_locked'; $folder_new = 'folder_locked_new'; break; + default: if ($replies >= intval($config['hot_threshold'])) { @@ -405,34 +384,38 @@ if ($forum_data['forum_postable']) } $unread_topic = true; - if ($user->data['user_id'] != ANONYMOUS - && - ( $topic_row['topic_last_post_time'] <= $topic_row['lastread_time'] - || $topic_row['topic_last_post_time'] < (time()-$config['lastread']) - || $topic_row['topic_last_post_time'] < $forum_row['lastread_time'] - ) - ) + if ($user->data['user_id'] != ANONYMOUS && + ($row['topic_last_post_time'] <= $row['lastread_time'] || + $row['topic_last_post_time'] < (time() - $config['lastread']) || + $row['topic_last_post_time'] < $forum_row['lastread_time']) + ) { $unread_topic = false; } - $newest_post_img = ($unread_topic) ? '' . $user->img('goto_post_newest', 'View_newest_post') . ' ' : ''; - $folder_img = ($unread_topic) ? $folder_new : $folder; - $folder_alt = ($unread_topic) ? 'New_posts' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'Topic_locked' : 'No_new_posts'); - if ($topic_row['lastread_type'] == LASTREAD_POSTED) + $newest_post_img = ($unread_topic) ? '' . $user->img('goto_post_newest', 'VIEW_NEWEST_POST') . ' ' : ''; + $folder_img = ($unread_topic) ? $folder_new : $folder; + $folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS'); + + + if ($row['lastread_type'] == LASTREAD_POSTED) { $folder_img .= '_posted'; } } - if (intval($topic_row['poll_start'])) + + if (intval($row['poll_start'])) { $topic_type .= $user->lang['Topic_Poll'] . ' '; } - // Goto message - if (($replies + 1 ) > intval($config['posts_per_page'])) + + // Goto message generation + $replies = $row['topic_replies']; + + if (($replies + 1) > intval($config['posts_per_page'])) { $total_pages = ceil(($replies + 1) / intval($config['posts_per_page'])); $goto_page = ' [ ' . $user->img('goto_post', 'GOTO_PAGE') . $user->lang['GOTO_PAGE'] . ': '; @@ -460,43 +443,45 @@ if ($forum_data['forum_postable']) $goto_page = ''; } + // Generate all the URIs ... $view_topic_url = 'viewtopic.' . $phpEx . $SID . '&f=' . $forum_id . '&t=' . $topic_id; - $topic_author = ($topic_row['user_id'] != ANONYMOUS) ? '' : ''; - $topic_author .= ($topic_row['user_id'] != ANONYMOUS) ? $topic_row['username'] : (($topic_row['topic_first_poster_name'] != '') ? $topic_row['topic_first_poster_name'] : $user->lang['GUEST']); + $last_post_img = '' . $user->img('goto_post_latest', 'VIEW_LATEST_POST') . ''; - $topic_author .= ($topic_row['user_id'] != ANONYMOUS) ? '' : ''; + $topic_author = ($row['topic_poster'] != ANONYMOUS) ? '' : ''; + $topic_author .= ($row['topic_poster'] != ANONYMOUS) ? $row['topic_first_poster_name'] : (($row['topic_first_poster_name'] != '') ? $row['topic_first_poster_name'] : $user->lang['GUEST']); + $topic_author .= ($row['topic_poster'] != ANONYMOUS) ? '' : ''; - $first_post_time = $user->format_date($topic_row['topic_time'], $config['board_timezone']); + $last_post_author = ($row['topic_last_poster_id'] == ANONYMOUS) ? (($row['topic_last_poster_name'] != '') ? $row['topic_last_poster_name'] . ' ' : $user->lang['GUEST'] . ' ') : '' . $row['topic_last_poster_name'] . ''; - $last_post_time = $user->format_date($topic_row['topic_last_post_time']); + $first_post_time = $user->format_date($row['topic_time'], $config['board_timezone']); - $last_post_author = ($topic_row['id2'] == ANONYMOUS) ? (($topic_row['topic_last_poster_name'] != '') ? $topic_row['topic_last_poster_name'] . ' ' : $user->lang['GUEST'] . ' ') : '' . $topic_row['user2'] . ''; + $last_post_time = $user->format_date($row['topic_last_post_time']); - $last_post_url = '' . $user->img('goto_post_latest', 'VIEW_LATEST_POST') . ''; // Send vars to template $template->assign_block_vars('topicrow', array( 'FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, - 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_AUTHOR' => $topic_author, - 'NEWEST_POST_IMG' => $newest_post_img, 'FIRST_POST_TIME' => $first_post_time, 'LAST_POST_TIME' => $last_post_time, 'LAST_POST_AUTHOR' => $last_post_author, - 'LAST_POST_IMG' => $last_post_url, - 'GOTO_PAGE' => $goto_page, - 'REPLIES' => $topic_row['topic_replies'], - 'VIEWS' => $topic_row['topic_views'], - 'TOPIC_TITLE' => $topic_title, + 'GOTO_PAGE' => $goto_page, + 'REPLIES' => $row['topic_replies'], + 'VIEWS' => $row['topic_views'], + 'TOPIC_TITLE' => (!empty($censors)) ? preg_replace($censors['match'], $censors['replace'], $row['topic_title']) : $row['topic_title'], 'TOPIC_TYPE' => $topic_type, - 'TOPIC_ICON' => (!empty($icons[$topic_row['icon_id']]) ) ? '' : '', + + 'LAST_POST_IMG' => $last_post_img, + 'NEWEST_POST_IMG' => $newest_post_img, + 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), + 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? '' : '', 'S_ROW_COUNT' => $i, - 'S_TOPIC_TYPE' => $topic_type, - 'S_USER_POSTED' => ($topic_row['lastread_type'] == LASTREAD_POSTED) ? true : false, + 'S_TOPIC_TYPE' => $row['topic_type'], + 'S_USER_POSTED' => ($row['lastread_type'] == LASTREAD_POSTED) ? true : false, 'U_VIEW_TOPIC' => $view_topic_url) ); @@ -505,31 +490,33 @@ if ($forum_data['forum_postable']) } } + if ($user->data['user_id'] != ANONYMOUS) { // $mark_topics isn't set as of now //setcookie($config['cookie_name'] . '_t', serialize($mark_topics), 0, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']); } - - } + // Mozilla navigation links $nav_links['up'] = array( 'url' => 'index.' . $phpEx . $SID, - 'title' => sprintf($user->lang['Forum_Index'], $config['sitename']) + 'title' => sprintf($user->lang['FORUM_INDEX'], $config['sitename']) ); -// Dump out the page header and load viewforum template -$page_title = $user->lang['View_forum'] . ' - ' . $forum_data['forum_name']; +// Dump out the page header and load viewforum template +$page_title = $user->lang['VIEW_FORUM'] . ' - ' . $forum_data['forum_name']; include($phpbb_root_path . 'includes/page_header.'.$phpEx); + $template->set_filenames(array( 'body' => 'viewforum_body.html') ); make_jumpbox("viewforum.$phpEx$SID", $forum_id); + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); ?> \ No newline at end of file