Various, typically posting related updates

git-svn-id: file:///svn/phpbb/trunk@2997 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2002-11-01 12:23:08 +00:00
parent 1a67029fcd
commit 6fa38a1181
9 changed files with 313 additions and 334 deletions

View file

@ -434,7 +434,7 @@ function bbencode_first_pass_pda($text, $uid, $open_tag, $close_tag, $close_tag_
// We have an opening tag.
// Push its position, the text we matched, and its index in the open_tag array on to the stack, and then keep going to the right.
$match = array("pos" => $curr_pos, "tag" => $which_start_tag, "index" => $start_tag_index);
bbcode_array_push($stack, $match);
array_push($stack, $match);
//
// Rather than just increment $curr_pos
// Set it to the ending of the tag we just found
@ -456,7 +456,7 @@ function bbencode_first_pass_pda($text, $uid, $open_tag, $close_tag, $close_tag_
// There exists a starting tag.
$curr_nesting_depth = sizeof($stack);
// We need to do 2 replacements now.
$match = bbcode_array_pop($stack);
$match = array_pop($stack);
$start_index = $match['pos'];
$start_tag = $match['tag'];
$start_length = strlen($start_tag);
@ -522,9 +522,9 @@ function bbencode_first_pass_pda($text, $uid, $open_tag, $close_tag, $close_tag_
// otherwise, we go back to the start.
if (sizeof($stack) > 0)
{
$match = bbcode_array_pop($stack);
$match = array_pop($stack);
$curr_pos = $match['pos'];
bbcode_array_push($stack, $match);
array_push($stack, $match);
++$curr_pos;
}
else
@ -642,21 +642,6 @@ function make_clickable($text)
return($ret);
}
/**
* Nathan Codding - Feb 6, 2001
* Reverses the effects of make_clickable(), for use in editpost.
* - Does not distinguish between "www.xxxx.yyyy" and "http://aaaa.bbbb" type URLs.
*
*/
function undo_make_clickable($text)
{
$text = preg_replace("#<!-- BBCode auto-link start --><a href=\"(.*?)\" target=\"_blank\">.*?</a><!-- BBCode auto-link end -->#i", "\\1", $text);
$text = preg_replace("#<!-- BBcode auto-mailto start --><a href=\"mailto:(.*?)\">.*?</a><!-- BBCode auto-mailto end -->#i", "\\1", $text);
return $text;
}
/**
* Nathan Codding - August 24, 2000.
* Takes a string, and does the reverse of the PHP standard function
@ -696,44 +681,6 @@ function escape_slashes($input)
return $output;
}
/**
* This function does exactly what the PHP4 function array_push() does
* however, to keep phpBB compatable with PHP 3 we had to come up with our own
* method of doing it.
*/
function bbcode_array_push(&$stack, $value)
{
$stack[] = $value;
return(sizeof($stack));
}
/**
* This function does exactly what the PHP4 function array_pop() does
* however, to keep phpBB compatable with PHP 3 we had to come up with our own
* method of doing it.
*/
function bbcode_array_pop(&$stack)
{
$arrSize = count($stack);
$x = 1;
while(list($key, $val) = each($stack))
{
if($x < count($stack))
{
$tmpArr[] = $val;
}
else
{
$return_val = $val;
}
$x++;
}
$stack = $tmpArr;
return($return_val);
}
//
// Smilies code ... would this be better tagged on to the end of bbcode.php?
// Probably so and I'll move it before B2

View file

@ -75,7 +75,7 @@ function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $incl
return $rows;
}
function forum_nav_links(&$forum_id, &$forum_name)
function forum_nav_links(&$forum_id, &$forum_data)
{
global $SID, $template, $phpEx, $auth;
@ -104,8 +104,6 @@ function forum_nav_links(&$forum_id, &$forum_name)
$branch_root_id = 0;
$forum_data = $row;
$type = 'child';
$forum_name = $row['forum_name'];
}
}
else
@ -845,6 +843,15 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
break;
case E_USER_NOTICE:
if (empty($user->session_id))
{
$user->start();
}
if (empty($user->lang))
{
$user->setup();
}
$msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text;
if (!defined('HEADER_INC'))

View file

@ -146,7 +146,7 @@ class session
}
// Garbage collection ... remove old sessions updating user information
// if necessary. It means (potentially) 22 queries but only infrequently
// if necessary. It means (potentially) 11 queries but only infrequently
if ($current_time - $config['session_gc'] > $config['session_last_gc'])
{
$this->gc($current_time);
@ -218,7 +218,7 @@ class session
$this->set_cookie('sid', $this->session_id, 0);
$SID = '?sid=' . $this->session_id;
if ( $this->data['user_id'] )
if ($this->data['user_id'] != ANONYMOUS)
{
// Events ... ?
// do_events('days');
@ -409,7 +409,7 @@ class user extends session
}
*/
// Set up style
$style = ( $style ) ? $style : ( ( !$config['override_user_style'] && $this->data['user_id'] ) ? $this->data['user_style'] : $config['default_style'] );
$style = ($style) ? $style : ((!$config['override_user_style'] && $this->data['user_id'] != ANONYMOUS) ? $this->data['user_style'] : $config['default_style']);
$sql = "SELECT t.template_path, t.poll_length, t.pm_box_length, c.css_data, c.css_external, i.*
FROM " . STYLES_TABLE . " s, " . STYLES_TPL_TABLE . " t, " . STYLES_CSS_TABLE . " c, " . STYLES_IMAGE_TABLE . " i
@ -442,7 +442,6 @@ class user extends session
$lang_dates[$match] = $replace;
}
}
$format = (!$format) ? $this->date_format : $format;
return strtr(@gmdate($format, $gmepoch + $this->timezone + $this->dst), $lang_dates);
}
@ -456,7 +455,6 @@ class user extends session
$width = ($width) ? 'width="' . $width . '" ' : '';
$imgs[$img] = '<img src=' . str_replace('{LANG}', $this->img_lang, $this->theme[$img]) . '" ' . $width . 'alt="' . $this->lang[$alt] . '" title="' . $this->lang[$alt] . '" />';
}
return $imgs[$img];
}
}
@ -469,7 +467,7 @@ class auth
var $acl = array();
var $acl_options = array();
function acl(&$userdata, $forum_id = false)
function acl(&$userdata)
{
global $db, $acl_options;
@ -477,15 +475,11 @@ class auth
if (!$this->founder = $userdata['user_founder'])
{
// $mtime = explode(' ', microtime());
// $starttime = $mtime[1] + $mtime[0];
if (empty($userdata['user_permissions']))
{
$this->acl_cache($userdata);
}
// This is preliminary and can no doubt be improved
$global_chars = ceil(sizeof($this->acl_options['global']) / 8);
$local_chars = ceil(sizeof($this->acl_options['local']) / 8) + 2;
$globals = substr($userdata['user_permissions'], 0, $global_chars);
@ -510,9 +504,6 @@ class auth
unset($forums);
}
// $mtime = explode(' ', microtime());
// echo $mtime[1] + $mtime[0] - $starttime . " :: ";
return;
}
@ -532,10 +523,34 @@ class auth
$acl_cache[$forum_id][$option] |= substr($this->acl['local'][$forum_id], $this->acl_options['local'][$option], 1);
}
}
return ($this->founder) ? true : $acl_cache[$forum_id][$option];
}
function acl_gets()
{
if ($this->founder)
{
return true;
}
$arguments = func_get_args();
$forum_id = array_pop($arguments);
if (!is_int($forum_id))
{
$arguments[] = $forum_id;
$forum_id = false;
}
$acl = 0;
foreach ($arguments as $option)
{
$acl |= $this->acl_get($option, $forum_id);
}
return $acl;
}
// Cache data
function acl_cache(&$userdata)
{

View file

@ -58,7 +58,7 @@ switch ($mode)
trigger_error($user->lang['No_forum_id']);
}
$sql = 'SELECT forum_id, post_count_inc
$sql = 'SELECT forum_id, forum_status, post_count_inc
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . intval($f);
break;
@ -69,7 +69,7 @@ switch ($mode)
trigger_error($user->lang['No_topic_id']);
}
$sql = 'SELECT t.*, f.post_count_inc
$sql = 'SELECT t.*, f.forum_status, f.post_count_inc
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f
WHERE t.topic_id = ' . intval($t) . '
AND f.forum_id = t.forum_id';
@ -83,7 +83,7 @@ switch ($mode)
trigger_error($user->lang['No_post_id']);
}
$sql = 'SELECT t.*, p.*, pt.*, f.post_count_inc
$sql = 'SELECT t.*, p.*, pt.*, f.forum_status, f.post_count_inc
FROM ' . POSTS_TABLE . ' p, ' . POSTS_TEXT_TABLE . ' pt, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f
WHERE p.post_id = ' . intval($p) . '
AND t.topic_id = p.topic_id
@ -142,17 +142,21 @@ if ($mode == 'edit' && !empty($poll_start))
// POST INFO
// ---------
// Basic mode related permission check
if (!$auth->acl_get('f_' . $mode, $forum_id))
{
trigger_error($user->lang['User_cannot_' . $mode]);
}
// Forum/Topic locked?
if ((intval($forum_status) == ITEM_LOCKED || intval($topic_status) == ITEM_LOCKED) && !$auth->acl_gets('m_', 'a_', $forum_id))
{
$message = (intval($forum_status) == FORUM_LOCKED) ? 'Forum_locked' : 'Topic_locked';
trigger_error($user->lang[$message]);
}
// Can we edit this post?
if (($mode == 'edit' || $mode == 'delete') && !empty($config['edit_time']) && $post_time < time() - $config['edit_time'] && !$auth->acl_get('m_', $forum_id) && !$auth->acl_get('a_'))
if (($mode == 'edit' || $mode == 'delete') && !empty($config['edit_time']) && $post_time < time() - $config['edit_time'] && !$auth->acl_gets('m_', 'a_', $forum_id))
{
trigger_error($user->lang['Cannot_edit_time']);
}
@ -556,20 +560,20 @@ if ($row = $db->sql_fetchrow($result))
$topic_type_toggle = '';
if ($mode == 'post' || $mode == 'edit')
{
if ( $auth->acl_get('f_sticky', $forum_id) )
if ($auth->acl_gets('f_sticky', 'm_sticky', 'a_', intval($forum_id)))
{
$topic_type_toggle .= '<input type="radio" name="type" value="' . POST_STICKY . '"';
if ($topic_type == POST_STICKY)
if (intval($topic_type) == POST_STICKY)
{
$topic_type_toggle .= ' checked="checked"';
}
$topic_type_toggle .= ' /> ' . $user->lang['Post_Sticky'] . '&nbsp;&nbsp;';
}
if ( $auth->acl_get('f_announce', $forum_id) )
if ($auth->acl_gets('f_announce', 'm_announce', 'a_', intval($forum_id)))
{
$topic_type_toggle .= '<input type="radio" name="type" value="' . POST_ANNOUNCE . '"';
if ($topic_type == POST_ANNOUNCE)
if (intval($topic_type) == POST_ANNOUNCE)
{
$topic_type_toggle .= ' checked="checked"';
}
@ -578,7 +582,7 @@ if ($mode == 'post' || $mode == 'edit')
if ($topic_type_toggle != '')
{
$topic_type_toggle = $user->lang['Post_topic_as'] . ': <input type="radio" name="type" value="' . POST_NORMAL .'"' . ( ($topic_type == POST_NORMAL) ? ' checked="checked"' : '' ) . ' /> ' . $user->lang['Post_Normal'] . '&nbsp;&nbsp;' . $topic_type_toggle;
$topic_type_toggle = $user->lang['Post_topic_as'] . ': <input type="radio" name="type" value="' . POST_NORMAL .'"' . ((intval($topic_type) == POST_NORMAL) ? ' checked="checked"' : '') . ' /> ' . $user->lang['Post_Normal'] . '&nbsp;&nbsp;' . $topic_type_toggle;
}
}
@ -616,11 +620,11 @@ switch ($mode)
}
// Nav links for forum
forum_nav_links($forum_id, $forum_name);
forum_nav_links($forum_id, $forum_data);
// Start assigning vars for main posting page ...
$template->assign_vars(array(
'FORUM_NAME' => $forum_name,
'FORUM_NAME' => $forum_data['forum_name'],
'TOPIC_TITLE' => ($mode != 'post') ? $topic_title : '',
'USERNAME' => $post_username,
'SUBJECT' => (!empty($topic_title)) ? $topic_title : $post_subject,
@ -677,9 +681,9 @@ $template->assign_vars(array(
'L_FONT_LARGE' => $user->lang['font_large'],
'L_FONT_HUGE' => $user->lang['font_huge'],
'U_VIEW_FORUM' => "viewforum.$phpEx$SID&amp;f=$forum_id",
'U_VIEWTOPIC' => ($mode != 'post') ? "viewtopic.$phpEx$SID&amp;t=$topic_id" : '',
'U_REVIEW_TOPIC' => ($mode != 'post') ? "posting.$phpEx$SID&amp;mmode=topicreview&amp;t=$topic_id" : '',
'U_VIEW_FORUM' => "viewforum.$phpEx$SID&amp;f=" . intval($forum_id),
'U_VIEWTOPIC' => ($mode != 'post') ? "viewtopic.$phpEx$SID&amp;t=" . intval($topic_id) : '',
'U_REVIEW_TOPIC' => ($mode != 'post') ? "posting.$phpEx$SID&amp;mmode=topicreview&amp;t=" . intval($topic_id) : '',
'U_VIEW_MODERATORS' => 'memberslist.' . $phpEx . $SID . '&amp;mode=moderators&amp;f=' . intval($forum_id),
'S_SHOW_TOPIC_ICONS' => $s_topic_icons,
@ -697,7 +701,7 @@ $template->assign_vars(array(
'S_SMILIES_ALLOWED' => $smilies_status,
'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id)) ? true : false,
'S_NOTIFY_ALLOWED' => ($user->data['user_id'] != ANONYMOUS) ? true : false,
'S_DELETE_ALLOWED' => ($mode = 'edit' && (($post_id == $topic_last_post_id && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', intval($forum_id))) || $auth->acl_get('m_delete', intval($forum_id)) || $auth->acl_get('a_'))) ? true : false,
'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $topic_last_post_id && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', intval($forum_id))) || $auth->acl_gets('m_delete', 'a_', intval($forum_id)))) ? true : false,
'S_TYPE_TOGGLE' => $topic_type_toggle,
'S_TOPIC_ID' => intval($topic_id),
@ -705,11 +709,11 @@ $template->assign_vars(array(
);
// Poll entry
if ((($mode == 'post' || ($mode == 'edit' && intval($post_id) == intval($topic_first_post_id) && empty($poll_last_vote))) && $auth->acl_get('f_poll', intval($forum_id))) || $auth->acl_get('a_'))
if ((($mode == 'post' || ($mode == 'edit' && intval($post_id) == intval($topic_first_post_id) && empty($poll_last_vote))) && $auth->acl_get('f_poll', intval($forum_id))) || $auth->acl_gets('m_edit', 'a_', $forum_id))
{
$template->assign_vars(array(
'S_SHOW_POLL_BOX' => true,
'S_POLL_DELETE' => ($mode = 'edit' && !empty($poll_options) && ((empty($poll_last_vote) && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', intval($forum_id))) || $auth->acl_get('m_delete', intval($forum_id)) || $auth->acl_get('a_'))) ? true : false,
'S_POLL_DELETE' => ($mode = 'edit' && !empty($poll_options) && ((empty($poll_last_vote) && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', intval($forum_id))) || $auth->acl_gets('m_delete', 'a_', intval($forum_id)))) ? true : false,
'L_ADD_A_POLL' => $user->lang['Add_poll'],
'L_ADD_POLL_EXPLAIN' => $user->lang['Add_poll_explain'],
@ -731,7 +735,7 @@ if ((($mode == 'post' || ($mode == 'edit' && intval($post_id) == intval($topic_f
}
// Attachment entry
if ( $auth->acl_get('f_attach', $forum_id) )
if ($auth->acl_gets('f_attach', 'm_edit', 'a_', $forum_id))
{
$template->assign_vars(array(
'S_SHOW_ATTACH_BOX' => true,

View file

@ -32,7 +32,7 @@ include($phpbb_root_path . 'includes/functions_posting.'.$phpEx);
//
if (!empty($config['privmsg_disable']))
{
message_die(MESSAGE, 'PM_disabled');
trigger_error('PM_disabled');
}
$html_entities_match = array('#&#', '#<#', '#>#');

View file

@ -4,6 +4,8 @@
http://www.subBlue.com
*/
/* Protected classes used internally -DO NOT REMOVE!- */
span.hilit {color:red;font-weight:bold}
/* General page style. The scroll bar colours only visible in IE5.5+ */
body {

View file

@ -34,7 +34,7 @@
</table></td>
</tr>
<tr>
<td align="center"><input type="submit" name="submit" value="{L_SUBMIT_VOTE}" class="liteoption" /></td>
<td align="center"><input type="submit" name="castvote" value="{L_SUBMIT_VOTE}" class="liteoption" /></td>
</tr>
<tr>
<td align="center"><span class="gensmall"><b><a href="{U_VIEW_RESULTS}" class="gensmall">{L_VIEW_RESULTS}</a></b></span></td>

View file

@ -61,12 +61,12 @@ $user->start();
// If not give them a nice error page.
if (empty($forum_id))
{
message_die(MESSAGE, 'Forum_not_exist');
trigger_error('Forum_not_exist');
}
if (!$forum_branch = get_forum_branch($forum_id))
{
message_die(MESSAGE, 'Forum_not_exist');
trigger_error('Forum_not_exist');
}
// Configure style, language, etc.
@ -74,9 +74,9 @@ $user->setup(false, $forum_branch['forum_style']);
$auth->acl($user->data, $forum_id);
// Auth check
if (!$auth->acl_get('f_read', $forum_id))
if (!$auth->acl_gets('f_read', 'm_', 'a_', $forum_id))
{
if ( !$user->data['user_id'] )
if (!$user->data['user_id'] != ANONYMOUS)
{
redirect("login.$phpEx$SID&redirect=viewforum.$phpEx&f=$forum_id" . ((isset($start)) ? "&start=$start" : ''));
}
@ -86,10 +86,11 @@ if (!$auth->acl_get('f_read', $forum_id))
// End of auth check
// Build subforums list if applicable
//$forum_data = array();
//$s_has_subforums = forum_nav_links($forum_id, $forum_data);
$type = 'parent';
$forum_rows = array();
$s_has_subforums = FALSE;
foreach ($forum_branch as $row)
{
if ($type == 'parent')
@ -161,7 +162,7 @@ $mark_forums = ( isset($_COOKIE[$config['cookie_name'] . '_f']) ) ? unserialize(
// Handle marking posts
if ($mark_read == 'topics')
{
if ( $user->data['user_id'] )
if ($user->data['user_id'] != ANONYMOUS)
{
$mark_forums[$forum_id] = time();
@ -178,7 +179,7 @@ if ( $mark_read == 'topics' )
// End handle marking posts
// Do the forum Prune
if ( $auth->acl_get('m_prune', $forum_id) && $config['prune_enable'] )
if ($auth->acl_gets('m_prune', 'a_', $forum_id) && $config['prune_enable'])
{
if ($forum_data['prune_next'] < time() && $forum_data['prune_enable'])
{
@ -265,16 +266,16 @@ $select_sort_dir = '<select name="sort_dir">';
$select_sort_dir .= ($sort_dir == 'a') ? '<option value="a" selected="selected">' . $user->lang['Ascending'] . '</option><option value="d">' . $user->lang['Descending'] . '</option>' : '<option value="a">' . $user->lang['Ascending'] . '</option><option value="d" selected="selected">' . $user->lang['Descending'] . '</option>';
$select_sort_dir .= '</select>';
$post_alt = ( $forum_data['forum_status'] == FORUM_LOCKED ) ? 'Forum_locked' : 'Post_new_topic';
$post_alt = (intval($forum_data['forum_status']) == ITEM_LOCKED) ? 'Forum_locked' : 'Post_new_topic';
// Basic pagewide vars
$template->assign_vars(array(
'FORUM_ID' => $forum_id,
'FORUM_NAME' => $forum_data['forum_name'],
'POST_IMG' => ( $forum_data['forum_status'] == FORUM_LOCKED ) ? $user->img('post_locked', $post_alt) : $user->img('post_new', $post_alt),
'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&amp;f=$forum_id&amp;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_get('a_') || $auth->acl_get('m_', $forum_id) ) ? sprintf($user->lang['MCP'], '<a href="modcp.' . $phpEx . $SID . '&amp;f=' . $forum_id . '">', '</a>') : '',
'MOD_CP' => ($auth->acl_gets('m_', 'a_', $forum_id)) ? sprintf($user->lang['MCP'], '<a href="modcp.' . $phpEx . $SID . '&amp;f=' . $forum_id . '">', '</a>') : '',
'FOLDER_IMG' => $user->img('folder', 'No_new_posts'),
'FOLDER_NEW_IMG' => $user->img('folder_new', 'New_posts'),
@ -428,12 +429,12 @@ if ( $total_topics )
$folder = 'folder_sticky';
$folder_new = 'folder_sticky_new';
break;
case TOPIC_LOCKED:
case ITEM_LOCKED:
$folder = 'folder_locked';
$folder_new = 'folder_locked_new';
break;
default:
if ( $replies >= $config['hot_threshold'] )
if ($replies >= intval($config['hot_threshold']))
{
$folder = 'folder_hot';
$folder_new = 'folder_hot_new';
@ -447,37 +448,39 @@ if ( $total_topics )
}
$unread_topic = false;
if ( $user->data['user_id'] && $topic_rowset[$i]['topic_last_post_time'] > $user->data['user_lastvisit'] )
if ($user->data['user_id'] && $topic_rowset[$i]['topic_last_post_time'] > $user->data['session_last_visit'])
{
$unread_topic = true;
}
$newest_post_img = ($unread_topic) ? '<a href="viewtopic.' . $phpEx . $SID . '&amp;t=' . $topic_id . '&amp;view=newest">' . $user->img('goto_post_newest', 'View_newest_post') . '</a> ' : '';
$folder_img = ($unread_topic) ? $folder_new : $folder;
$folder_alt = ( $unread_topic ) ? 'New_posts' : ( ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? 'Topic_locked' : 'No_new_posts' );
$folder_alt = ($unread_topic) ? 'New_posts' : (($topic_rowset[$i]['topic_status'] == ITEM_LOCKED) ? 'Topic_locked' : 'No_new_posts');
}
if ( $topic_rowset[$i]['topic_vote'] )
if (intval($topic_rowset[$i]['poll_start']))
{
$topic_type .= $user->lang['Topic_Poll'] . ' ';
}
$replies = $topic_rowset[$i]['topic_replies'];
// Goto message
if ( ( $replies + 1 ) > $config['posts_per_page'] )
if (($replies + 1 ) > intval($config['posts_per_page']))
{
$total_pages = ceil( ( $replies + 1 ) / $config['posts_per_page'] );
$goto_page = ' [ <img src=' . $theme['goto_post'] . ' alt="' . $user->lang['Goto_page'] . '" title="' . $user->lang['Goto_page'] . '" />' . $user->lang['Goto_page'] . ': ';
$total_pages = ceil(($replies + 1) / intval($config['posts_per_page']));
$goto_page = ' [ ' . $user->img('goto_post', 'Goto_page') . $user->lang['Goto_page'] . ': ';
$times = 1;
for($j = 0; $j < $replies + 1; $j += $config['posts_per_page'])
for($j = 0; $j < $replies + 1; $j += intval($config['posts_per_page']))
{
$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;
$j += ( $total_pages - 4 ) * $config['posts_per_page'];
$j += ($total_pages - 4) * intval($config['posts_per_page']);
}
else if ($times < $total_pages)
{
@ -498,19 +501,17 @@ if ( $total_topics )
$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]['topic_first_poster_name'] != '') ? $topic_rowset[$i]['topic_first_poster_name'] : $user->lang['Guest']);
$topic_author .= ( $topic_rowset[$i]['user_id'] ) ? '</a>' : '';
$topic_author .= ($topic_rowset[$i]['user_id'] != ANONYMOUS) ? '</a>' : '';
$first_post_time = $user->format_date($topic_rowset[$i]['topic_time'], $config['board_timezone']);
$last_post_time = $user->format_date($topic_rowset[$i]['topic_last_post_time']);
$last_post_author = ( !$topic_rowset[$i]['id2'] ) ? ( ( $topic_rowset[$i]['topic_last_poster_name'] != '' ) ? $topic_rowset[$i]['topic_last_poster_name'] . ' ' : $user->lang['Guest'] . ' ' ) : '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $topic_rowset[$i]['topic_last_poster_id'] . '">' . $topic_rowset[$i]['user2'] . '</a>';
$last_post_author = ($topic_rowset[$i]['id2'] == ANONYMOUS) ? (($topic_rowset[$i]['topic_last_poster_name'] != '') ? $topic_rowset[$i]['topic_last_poster_name'] . ' ' : $user->lang['Guest'] . ' ') : '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $topic_rowset[$i]['topic_last_poster_id'] . '">' . $topic_rowset[$i]['user2'] . '</a>';
$last_post_url = '<a href="viewtopic.' . $phpEx . $SID . '&amp;f=' . $forum_id . '&amp;p=' . $topic_rowset[$i]['topic_last_post_id'] . '#' . $topic_rowset[$i]['topic_last_post_id'] . '">' . $user->img('goto_post_latest', 'View_latest_post') . '</a>';
//
// Send vars to template
//
$template->assign_block_vars('topicrow', array(
'FORUM_ID' => $forum_id,
'TOPIC_ID' => $topic_id,
@ -527,6 +528,8 @@ if ( $total_topics )
'TOPIC_TITLE' => (count($orig_word)) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'],
'TOPIC_TYPE' => $topic_type,
'TOPIC_ICON' => (!empty($topic_rowset[$i]['topic_icon']) ) ? '<img src="' . $config['icons_path'] . '/' . $topic_icons[$topic_rowset[$i]['topic_icon']]['img'] . '" width="' . $topic_icons[$topic_rowset[$i]['topic_icon']]['width'] . '" height="' . $topic_icons[$topic_rowset[$i]['topic_icon']]['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'] . '" />' : '',
'S_ROW_COUNT' => $i,

View file

@ -40,9 +40,11 @@ if (isset($_GET['view']) && empty($post_id))
{
if ($_GET['view'] == 'newest')
{
if (isset($_COOKIE[$config['cookie_name'] . '_sid']))
if (!empty($_COOKIE[$config['cookie_name'] . '_sid']) || !empty($_GET['sid']))
{
$session_id = $_COOKIE[$config['cookie_name'] . '_sid'];
$session_id = (!empty($_COOKIE[$config['cookie_name'] . '_sid'])) ? $_COOKIE[$config['cookie_name'] . '_sid'] : $_GET['sid'];
$SID = '?sid=' . ((!empty($_GET['sid'])) ? $session_id : '');
if ($session_id)
{
@ -59,7 +61,7 @@ if (isset($_GET['view']) && empty($post_id))
if (!($row = $db->sql_fetchrow($result)))
{
message_die(MESSAGE, 'No_new_posts_last_visit');
trigger_error('No_new_posts_last_visit');
}
$post_id = $row['post_id'];
@ -67,7 +69,7 @@ if (isset($_GET['view']) && empty($post_id))
}
}
redirect("index.$phpEx$SID");
redirect("index.$phpEx");
}
else if ($_GET['view'] == 'next' || $_GET['view'] == 'previous')
{
@ -86,7 +88,7 @@ if (isset($_GET['view']) && empty($post_id))
if (!($row = $db->sql_fetchrow($result)))
{
$message = ($_GET['view'] == 'next') ? 'No_newer_topics' : 'No_older_topics';
message_die(MESSAGE, $message);
trigger_error($message);
}
else
{
@ -151,12 +153,12 @@ if (!(extract($db->sql_fetchrow($result))))
}
// Configure style, language, etc.
$user->setup(false, $forum_style);
$auth->acl($user->data, $forum_id);
$user->setup(false, intval($forum_style));
$auth->acl($user->data, intval($forum_id));
// End configure
// Start auth check
if (!$auth->acl_get('f_read', $forum_id))
if (!$auth->acl_gets('f_read', 'm_', 'a_', intval($forum_id)))
{
if ($user->data['user_id'] == ANONYMOUS)
{
@ -295,7 +297,7 @@ if (isset($_GET['highlight']))
{
if (trim($word) != '')
{
$highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '([\w]+)?', preg_quote($word, '#'));
$highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', preg_quote($word, '#'));
}
}
unset($words);
@ -306,11 +308,11 @@ $s_forum_rules = '';
get_forum_rules('topic', $s_forum_rules, $forum_id);
$topic_mod = '';
$topic_mod .= ( $auth->acl_get('m_lock', $forum_id) ) ? ( ( $topic_status == TOPIC_UNLOCKED ) ? '<option value="lock">' . $user->lang['Lock_topic'] . '</option>' : '<option value="unlock">' . $user->lang['Unlock_topic'] . '</option>' ) : '';
$topic_mod .= ( $auth->acl_get('m_delete', $forum_id) ) ? '<option value="delete">' . $user->lang['Delete_topic'] . '</option>' : '';
$topic_mod .= ( $auth->acl_get('m_move', $forum_id) ) ? '<option value="move">' . $user->lang['Move_topic'] . '</option>' : '';
$topic_mod .= ( $auth->acl_get('m_split', $forum_id) ) ? '<option value="split">' . $user->lang['Split_topic'] . '</option>' : '';
$topic_mod .= ( $auth->acl_get('m_merge', $forum_id) ) ? '<option value="merge">' . $user->lang['Merge_topic'] . '</option>' : '';
$topic_mod .= ($auth->acl_gets('m_lock', 'a_', $forum_id)) ? ((intval($topic_status) == TOPIC_UNLOCKED) ? '<option value="lock">' . $user->lang['Lock_topic'] . '</option>' : '<option value="unlock">' . $user->lang['Unlock_topic'] . '</option>') : '';
$topic_mod .= ($auth->acl_gets('m_delete', 'a_', $forum_id)) ? '<option value="delete">' . $user->lang['Delete_topic'] . '</option>' : '';
$topic_mod .= ($auth->acl_gets('m_move', 'a_', $forum_id)) ? '<option value="move">' . $user->lang['Move_topic'] . '</option>' : '';
$topic_mod .= ($auth->acl_gets('m_split', 'a_', $forum_id)) ? '<option value="split">' . $user->lang['Split_topic'] . '</option>' : '';
$topic_mod .= ($auth->acl_gets('m_merge', 'a_', $forum_id)) ? '<option value="merge">' . $user->lang['Merge_topic'] . '</option>' : '';
// If we've got a hightlight set pass it on to pagination.
$pagination = ($highlight_match) ? generate_pagination("viewtopic.$phpEx$SID&amp;t=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order&amp;highlight=" . $_GET['highlight'], $topic_replies, $config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx$SID&amp;t=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order", $topic_replies, $config['posts_per_page'], $start);
@ -323,8 +325,8 @@ $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_status == FORUM_LOCKED || $topic_status == TOPIC_LOCKED ) ? $user->img('reply_locked', $user->lang['Topic_locked']) : $user->img('reply_new', $user->lang['Reply_to_topic']);
$post_img = ( $forum_status == FORUM_LOCKED ) ? $user->img('post_locked', $user->lang['Forum_locked']) : $user->img('post_new', $user->lang['Post_new_topic']);
$reply_img = ($forum_status == ITEM_LOCKED || $topic_status == ITEM_LOCKED) ? $user->img('reply_locked', $user->lang['Topic_locked']) : $user->img('reply_new', $user->lang['Reply_to_topic']);
$post_img = ($forum_status == ITEM_LOCKED) ? $user->img('post_locked', $user->lang['Forum_locked']) : $user->img('post_new', $user->lang['Post_new_topic']);
// Set a cookie for this topic
if ($user->data['user_id'] != ANONYMOUS)
@ -354,7 +356,7 @@ $template->assign_vars(array(
'TOPIC_TITLE' => $topic_title,
'PAGINATION' => $pagination,
'PAGE_NUMBER' => sprintf($user->lang['Page_of'], ( floor( $start / $config['posts_per_page'] ) + 1 ), ceil( $topic_replies / $config['posts_per_page'] )),
'MOD_CP' => ( $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id) ) ? sprintf($user->lang['MCP'], '<a href="modcp.' . $phpEx . $SID . '&amp;f=' . $forum_id . '">', '</a>') : '',
'MOD_CP' => ($auth->acl_gets('m_', 'a_', $forum_id)) ? sprintf($user->lang['MCP'], '<a href="modcp.' . $phpEx . $SID . '&amp;f=' . $forum_id . '">', '</a>') : '',
'POST_IMG' => $post_img,
'REPLY_IMG' => $reply_img,
@ -434,7 +436,7 @@ if (!empty($poll_start))
$voted_id = ($row = $db->sql_fetchrow($result)) ? $row['poll_option_id'] : false;
$db->sql_freeresult($result);
$display_results = ($voted_id || ($poll_length != 0 && $poll_start + $poll_length < time()) || $_GET['vote'] == 'viewresult' || !$auth->acl_get('f_vote', $forum_id) || $topic_status == TOPIC_LOCKED) ? true : false;
$display_results = ($voted_id || ($poll_length != 0 && $poll_start + $poll_length < time()) || $_GET['vote'] == 'viewresult' || !$auth->acl_gets('f_vote', 'm_', 'a_', $forum_id) || $topic_status == ITEM_LOCKED || $forum_status == ITEM_LOCKED) ? true : false;
$poll_total = 0;
foreach ($poll_info as $poll_option)
@ -479,6 +481,7 @@ if (!empty($poll_start))
// Container for user details, only process once
$poster_details = array();
$i = 0;
// Go ahead and pull all data for this topic
$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
@ -508,7 +511,7 @@ if ($row = $db->sql_fetchrow($result))
$poster_details[$poster_id]['joined'] = ($row['user_id']) ? $user->lang['Joined'] . ': ' . $user->format_date($row['user_regdate'], $user->lang['DATE_FORMAT']) : '';
}
if ( !isset($poster_details[$poster_id]['avatar']) )
if (isset($poster_details[$poster_id]['avatar']))
{
if ($row['user_avatar_type'] && $poster_id && $row['user_allowavatar'])
{
@ -577,7 +580,7 @@ if ($row = $db->sql_fetchrow($result))
if (!empty($row['user_viewemail']) || $auth->acl_get('m_', $forum_id))
{
$email_uri = ( $config['board_email_form'] ) ? "profile.$phpEx$SID&amp;mode=email&amp;u=" . $poster_id : 'mailto:' . $row['user_email'];
$email_uri = ($config['board_email_form'] && $config['email_enable']) ? "profile.$phpEx$SID&amp;mode=email&amp;u=" . $poster_id : 'mailto:' . $row['user_email'];
$poster_details[$poster_id]['email_img'] = '<a href="' . $email_uri . '">' . $user->img('icon_email', $user->lang['Send_email']) . '</a>';
$poster_details[$poster_id]['email'] = '<a href="' . $email_uri . '">' . $user->lang['Send_email'] . '</a>';
@ -653,7 +656,7 @@ if ($row = $db->sql_fetchrow($result))
$quote_img = '<a href="' . $temp_url . '">' . $user->img('icon_quote', $user->lang['Reply_with_quote']) . '</a>';
$quote = '<a href="' . $temp_url . '">' . $user->lang['Reply_with_quote'] . '</a>';
if ( ( $user->data['user_id'] == $poster_id && $auth->acl_get('f_edit', $forum_id) ) || $auth->acl_get('m_edit', $forum_id) || $auth->acl_get('a_') )
if (($user->data['user_id'] == $poster_id && $auth->acl_get('f_edit', $forum_id)) || $auth->acl_gets('m_edit', 'a_', $forum_id))
{
$temp_url = "posting.$phpEx$SID&amp;mode=edit&amp;f=" . $row['forum_id'] . "&amp;p=" . $row['post_id'];
$edit_img = '<a href="' . $temp_url . '">' . $user->img('icon_edit', $user->lang['Edit_delete_post']) . '</a>';
@ -665,7 +668,7 @@ if ($row = $db->sql_fetchrow($result))
$edit = '';
}
if ( $auth->acl_get('m_ip', $forum_id) )
if ($auth->acl_gets('m_ip', 'a_', $forum_id))
{
$temp_url = "modcp.$phpEx$SID&amp;mode=ip&amp;p=" . $row['post_id'] . "&amp;t=" . $topic_id;
$ip_img = '<a href="' . $temp_url . '">' . $user->img('icon_ip', $user->lang['View_IP']) . '</a>';
@ -677,7 +680,7 @@ if ($row = $db->sql_fetchrow($result))
$ip = '';
}
if ( ( $user->data['user_id'] == $poster_id && $auth->acl_get('f_delete', $forum_id) && $forum_topic_data['topic_last_post_id'] == $row['post_id'] ) || $auth->acl_get('m_delete', $forum_id) )
if (($user->data['user_id'] == $poster_id && $auth->acl_get('f_delete', $forum_id) && $forum_topic_data['topic_last_post_id'] == $row['post_id']) || $auth->acl_gets('m_delete', 'a_', $forum_id))
{
$temp_url = "posting.$phpEx$SID&amp;mode=delete&amp;p=" . $row['post_id'];
$delpost_img = '<a href="' . $temp_url . '">' . $user->img('icon_delete', $user->lang['Delete_post']) . '</a>';
@ -710,21 +713,6 @@ if ($row = $db->sql_fetchrow($result))
// $message = ( $auth->acl_get('f_bbcode', $forum_id) ) ? bbencode_second_pass($message, $bbcode_uid, $auth->acl_get('f_img', $forum_id)) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
}
// Highlight active words (primarily for search)
/* if ($highlight_match)
{
// This was shamelessly 'borrowed' from volker at multiartstudio dot de
// via php.net's annotated manual
$message = substr(preg_replace('#(\>(((?>[^><]+)|(?R))*)\<)#ie', "preg_replace('/(?>($highlight_match)+)/i','<span style=\"color:red\">\\1</span>', '\\0')", '>' . $message . '<'), 1, -1);
}
*/
// Replace naughty words
if (count($orig_word))
{
$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
$message = preg_replace($orig_word, $replacement_word, $message);
}
// If we allow users to disable display of emoticons
// we'll need an appropriate check and preg_replace here
if ($row['enable_smilies'])
@ -732,12 +720,27 @@ if ($row = $db->sql_fetchrow($result))
$message = str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $message);
}
// Highlight active words (primarily for search)
if ($highlight_match)
{
// This was shamelessly 'borrowed' from volker at multiartstudio dot de
// via php.net's annotated manual
$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $highlight_match . ")\b#i', '<span class=\"hilit\">\\\\1</span>', '\\0')", '>' . $message . '<'), 1, -1));
}
// Replace naughty words such as farty pants
if (count($orig_word))
{
$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
$message = preg_replace($orig_word, $replacement_word, $message);
}
$message = nl2br($message);
// Editing information
if ($row['post_edit_count'])
if (intval($row['post_edit_count']))
{
$l_edit_time_total = ($row['post_edit_count'] == 1) ? $user->lang['Edited_time_total'] : $user->lang['Edited_times_total'];
$l_edit_time_total = (intval($row['post_edit_count']) == 1) ? $user->lang['Edited_time_total'] : $user->lang['Edited_times_total'];
$l_edited_by = '<br /><br />' . sprintf($l_edit_time_total, $poster, $user->format_date($row['post_edit_time']), $row['post_edit_count']);
}
@ -832,13 +835,11 @@ if ($row = $db->sql_fetchrow($result))
'L_MINI_POST_ALT' => $mini_post_alt,
'S_ROW_COUNT' => $i,
'S_ROW_COUNT' => $i++,
'U_MINI_POST' => $mini_post_url,
'U_POST_ID' => $row['post_id'])
);
$i++;
}
while ($row = $db->sql_fetchrow($result));
}