Change in format of module db data, add zebra, many things probably "damaged goods" for now ... don't panic Mr. Mainwaring, don't panic

git-svn-id: file:///svn/phpbb/trunk@4522 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2003-10-01 17:24:53 +00:00
parent 64177fa87e
commit 860dc47114
14 changed files with 599 additions and 391 deletions

View file

@ -162,6 +162,7 @@ define('ICONS_TABLE', $table_prefix.'icons');
define('LANG_TABLE', $table_prefix.'lang');
define('LOG_TABLE', $table_prefix.'log');
define('MODERATOR_TABLE', $table_prefix.'moderator_cache');
define('MODULES_TABLE', $table_prefix . 'modules');
define('POSTS_TABLE', $table_prefix.'posts');
define('PRIVMSGS_TABLE', $table_prefix.'privmsgs');
define('PRIVMSGS_TEXT_TABLE', $table_prefix.'privmsgs_text');
@ -188,6 +189,7 @@ define('USERS_TABLE', $table_prefix.'users');
define('WORDS_TABLE', $table_prefix.'words');
define('POLL_OPTIONS_TABLE', $table_prefix.'poll_results');
define('POLL_VOTES_TABLE', $table_prefix.'poll_voters');
define('ZEBRA_TABLE', $table_prefix.'zebra');
// Set PHP error handler to ours
set_error_handler('msg_handler');

View file

@ -14,29 +14,6 @@
//
// User functions
//
function request_var($var_name, $default)
{
if (!isset($_REQUEST[$var_name]))
{
return $default;
}
else
{
$var = $_REQUEST[$var_name];
$type = gettype($default);
settype($var, $type);
// Prevent use of  , excess spaces or other html entity forms in profile strings,
// not generally applicable elsewhere
if ($type == 'string')
{
$var = trim(stripslashes(preg_replace(array("#[ \xFF]{2,}#s", "#[\r\n]{2,}#s"), array(' ', "\n"), strtr($var, array_flip(get_html_translation_table(HTML_ENTITIES))))));
}
return $var;
}
}
function validate_data($data, $val_ary)
{
$error = array();
@ -460,14 +437,7 @@ function add_to_group($action, $group_id, $user_id_ary, $username_ary, $colour,
$user_id_ary = array($user_id_ary);
}
$sql_in = array();
foreach ($$which_ary as $v)
{
if ($v = trim($v))
{
$sql_in[] = ($which_ary == 'user_id_ary') ? $v : "'$v'";
}
}
$sql_in = ($which_ary == 'user_id_ary') ? array_map('intval', $$which_ary) : preg_replace('#^[\s]*?(.*?)[\s]*?$#e', "\"'\" . \$db->sql_escape('\\1') . \"'\"", $$which_ary);
unset($$which_ary);
// Grab the user id/username records
@ -539,6 +509,7 @@ function add_to_group($action, $group_id, $user_id_ary, $username_ary, $colour,
break;
case 'mssql':
case 'mssql-odbc':
case 'sqlite':
$sql = 'INSERT INTO ' . USER_GROUP_TABLE . " (user_id, group_id, group_leader)
" . implode(' UNION ALL ', preg_replace('#^([0-9]+)$#', "(\\1, $group_id, $group_leader)", $add_id_ary));

View file

@ -11,7 +11,7 @@
//
// -------------------------------------------------------------
class ucp_activate extends ucp
class ucp_activate extends module
{
function main($module_id)
{

View file

@ -18,9 +18,9 @@
// released or distributed in any way under a licence other
// than the GPL. We will be watching ... ;)
class ucp_confirm extends ucp
class ucp_confirm extends module
{
function main($id)
function ucp_confirm($id, $mode)
{
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;

View file

@ -11,23 +11,13 @@
//
// -------------------------------------------------------------
class ucp_main extends ucp
class ucp_main extends module
{
function main($id)
function ucp_main($id, $mode)
{
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;
$submode = ($_REQUEST['mode']) ? htmlspecialchars($_REQUEST['mode']) : 'front';
// Setup internal subsection display
$submodules['FRONT'] = "i=$id&mode=front";
$submodules['WATCHED'] = "i=$id&mode=watched";
$submodules['DRAFTS'] = "i=$id&mode=drafts";
$this->menu($id, $submodules, $submode);
unset($submodules);
switch ($submode)
switch ($mode)
{
case 'front':
@ -155,23 +145,11 @@ class ucp_main extends ucp
}
$db->sql_freeresult($result);
//TODO
$sql_and = '';
$sql = 'SELECT COUNT(post_id) AS total_posts
FROM ' . POSTS_TABLE . '
WHERE post_time > ' . $user->data['user_lastvisit'] . "
$sql_and";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$user_id = $user->data['user_id'];
// Grab all the relevant data
$sql = "SELECT COUNT(p.post_id) AS num_posts
FROM " . POSTS_TABLE . " p, " . FORUMS_TABLE . " f
WHERE p.poster_id = $user_id
$sql = 'SELECT COUNT(p.post_id) AS num_posts
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f
WHERE p.poster_id = ' . $user->data['user_id'] . "
AND f.forum_id = p.forum_id
$post_count_sql";
$result = $db->sql_query($sql);
@ -179,9 +157,9 @@ class ucp_main extends ucp
$num_real_posts = min($user->data['user_posts'], $db->sql_fetchfield('num_posts', 0, $result));
$db->sql_freeresult($result);
$sql = "SELECT f.forum_id, f.forum_name, COUNT(post_id) AS num_posts
FROM " . POSTS_TABLE . " p, " . FORUMS_TABLE . " f
WHERE p.poster_id = $user_id
$sql = 'SELECT f.forum_id, f.forum_name, COUNT(post_id) AS num_posts
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f
WHERE p.poster_id = ' . $user->data['user_id'] . "
AND f.forum_id = p.forum_id
$post_count_sql
GROUP BY f.forum_id, f.forum_name
@ -191,9 +169,9 @@ class ucp_main extends ucp
$active_f_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$sql = "SELECT t.topic_id, t.topic_title, COUNT(p.post_id) AS num_posts
FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
WHERE p.poster_id = $user_id
$sql = 'SELECT t.topic_id, t.topic_title, COUNT(p.post_id) AS num_posts
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f
WHERE p.poster_id = ' . $user->data['user_id'] . "
AND t.topic_id = p.topic_id
AND f.forum_id = t.forum_id
$post_count_sql
@ -205,8 +183,8 @@ class ucp_main extends ucp
$db->sql_freeresult($result);
// Do the relevant calculations
$memberdays = max(1, round((time() - $row['user_regdate']) / 86400));
$posts_per_day = $row['user_posts'] / $memberdays;
$memberdays = max(1, round((time() - $user->data['user_regdate']) / 86400));
$posts_per_day = $user->data['user_posts'] / $memberdays;
$percentage = ($config['num_posts']) ? min(100, ($num_real_posts / $config['num_posts']) * 100) : 0;
$active_f_name = $active_f_id = $active_f_count = $active_f_pct = '';
@ -215,7 +193,7 @@ class ucp_main extends ucp
$active_f_name = $active_f_row['forum_name'];
$active_f_id = $active_f_row['forum_id'];
$active_f_count = $active_f_row['num_posts'];
$active_f_pct = ($active_f_count / $row['user_posts']) * 100;
$active_f_pct = ($active_f_count / $user->data['user_posts']) * 100;
}
unset($active_f_row);
@ -225,19 +203,18 @@ class ucp_main extends ucp
$active_t_name = $active_t_row['topic_title'];
$active_t_id = $active_t_row['topic_id'];
$active_t_count = $active_t_row['num_posts'];
$active_t_pct = ($active_t_count / $row['user_posts']) * 100;
$active_t_pct = ($active_t_count / $user->data['user_posts']) * 100;
}
unset($active_t_row);
// $template->assign_vars(show_profile($row));
$template->assign_vars(array(
'USER_COLOR' => (!empty($user->data['user_colour'])) ? $user->data['user_colour'] : '',
'RANK_TITLE' => $rank_title,
'KARMA' => (!empty($row['user_karma'])) ? $user->data['user_karma'] : 0,
'KARMA' => $user->lang['KARMA'][$user->data['user_karma']],
'JOINED' => $user->format_date($user->data['user_regdate'], $user->lang['DATE_FORMAT']),
'VISITED' => (empty($last_visit)) ? ' - ' : $user->format_date($last_visit, $user->lang['DATE_FORMAT']),
'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0,
'POSTS' => ($user->data['user_posts']) ? $user->data['user_posts'] : 0,
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
'ACTIVE_FORUM' => $active_f_name,
@ -250,15 +227,17 @@ class ucp_main extends ucp
'OCCUPATION' => (!empty($row['user_occ'])) ? $row['user_occ'] : '',
'INTERESTS' => (!empty($row['user_interests'])) ? $row['user_interests'] : '',
'KARMA_IMG' => '<img src="images/karma' . $user->data['user_karma'] . '.gif" alt="' . $user->lang['KARMA_LEVEL'] . ': ' . $user->lang['KARMA'][$user->data['user_karma']] . '" title="' . $user->lang['KARMA_LEVEL'] . ': ' . $user->lang['KARMA'][$user->data['user_karma']] . '" />',
'S_GROUP_OPTIONS' => $group_options,
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? "search.$phpEx$SID&amp;search_author=" . urlencode($user->data['username']) . "&amp;show_results=posts" : '',
'U_ACTIVE_FORUM' => "viewforum.$phpEx$SID&amp;f=$active_f_id",
'U_ACTIVE_TOPIC' => "viewtopic.$phpEx$SID&amp;t=$active_t_id",)
);
break;
case 'watched':
case 'subscribed':
if ($_POST['unwatch'])
{
@ -540,9 +519,9 @@ class ucp_main extends ucp
AND user_id = " .$user->data['user_id'];
$db->sql_query($sql);
$message = $user->lang['DRAFTS_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode\">", '</a>');
$message = $user->lang['DRAFTS_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode\">", '</a>');
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode");
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode");
trigger_error($message);
}
}
@ -567,9 +546,9 @@ class ucp_main extends ucp
AND user_id = " . $user->data['user_id'];
$db->sql_query($sql);
$message = $user->lang['DRAFT_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode\">", '</a>');
$message = $user->lang['DRAFT_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode\">", '</a>');
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode");
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode");
trigger_error($message);
}
else
@ -654,7 +633,7 @@ class ucp_main extends ucp
'POST_SUBJECT' => ($submit) ? $post_subject : $draft['post_subject'],
'U_VIEW_TOPIC' => $view_topic_url,
'U_VIEW_EDIT' => "ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode&amp;edit=" . $draft['draft_id'],
'U_VIEW_EDIT' => "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode&amp;edit=" . $draft['draft_id'],
'S_ROW_COUNT' => $row_count++,
'S_HIDDEN_FIELDS' => $s_hidden_fields
@ -676,15 +655,34 @@ class ucp_main extends ucp
$template->assign_vars(array(
'L_TITLE' => $user->lang['UCP_' . strtoupper($submode)],
'L_TITLE' => $user->lang['UCP_' . strtoupper($mode)],
'S_DISPLAY_MARK_ALL' => ($submode == 'watched' || ($submode == 'drafts' && !isset($_GET['edit']))) ? true : false,
'S_DISPLAY_' . strtoupper($submode) => true,
'S_DISPLAY_MARK_ALL' => ($mode == 'watched' || ($mode == 'drafts' && !isset($_GET['edit']))) ? true : false,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_UCP_ACTION' => "ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode")
'S_UCP_ACTION' => "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode")
);
$this->display($user->lang['UCP_MAIN'], 'ucp_main.html');
$this->display($user->lang['UCP_MAIN'], 'ucp_main_' . $mode . '.html');
}
function install()
{
}
function uninstall()
{
}
function module()
{
$details = array(
'name' => 'UCP - Main',
'description' => 'Front end for User Control Panel',
'filename' => 'main',
'version' => '1.0.0',
'phpbbversion' => '2.2.0'
);
return $details;
}
}

View file

@ -11,25 +11,16 @@
//
// -------------------------------------------------------------
class ucp_prefs extends ucp
class ucp_prefs extends module
{
function main($id)
function ucp_prefs($id, $mode)
{
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;
$submode = (!empty($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : 'personal';
$submit = (isset($_POST['submit'])) ? true : false;
$error = $data = array();
// Setup internal subsection display
$submodules['PERSONAL'] = "i=$id&amp;mode=personal";
$submodules['VIEW'] = "i=$id&amp;mode=view";
$submodules['POST'] = "i=$id&amp;mode=post";
$this->menu($id, $submodules, $submode);
unset($submodules);
switch($submode)
switch($mode)
{
case 'personal':
@ -84,8 +75,8 @@ class ucp_prefs extends ucp
WHERE user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode");
$message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode\">", '</a>');
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode");
$message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode\">", '</a>');
trigger_error($message);
}
}
@ -191,8 +182,8 @@ class ucp_prefs extends ucp
WHERE user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode");
$message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode\">", '</a>');
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode");
$message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode\">", '</a>');
trigger_error($message);
}
}
@ -294,8 +285,8 @@ class ucp_prefs extends ucp
WHERE user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode");
$message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode\">", '</a>');
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode");
$message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode\">", '</a>');
trigger_error($message);
}
}
@ -334,11 +325,11 @@ class ucp_prefs extends ucp
}
$template->assign_vars(array(
'L_TITLE' => $user->lang['UCP_' . strtoupper($submode)],
'L_TITLE' => $user->lang['UCP_' . strtoupper($mode)],
'S_DISPLAY_' . strtoupper($submode) => true,
'S_DISPLAY_' . strtoupper($mode) => true,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_UCP_ACTION' => "ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode")
'S_UCP_ACTION' => "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode")
);
$this->display($user->lang['UCP_PROFILE'], 'ucp_prefs.html');

View file

@ -11,27 +11,18 @@
//
// -------------------------------------------------------------
class ucp_profile extends ucp
class ucp_profile extends module
{
function main($id)
function ucp_profile($id, $mode)
{
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;
$submode = (isset($_GET['mode'])) ? htmlspecialchars($_GET['mode']) : 'reg_details';
$preview = (isset($_POST['preview'])) ? true : false;
$submit = (isset($_POST['submit'])) ? true : false;
$delete = (isset($_POST['delete'])) ? true : false;
$preview = (!empty($_POST['preview'])) ? true : false;
$submit = (!empty($_POST['submit'])) ? true : false;
$delete = (!empty($_POST['delete'])) ? true : false;
$error = $data = array();
$submodules['REG_DETAILS'] = "i=$id&amp;mode=reg_details";
$submodules['PROFILE_INFO'] = "i=$id&amp;mode=profile_info";
$submodules['SIGNATURE'] = "i=$id&amp;mode=signature";
$submodules['AVATAR'] = "i=$id&amp;mode=avatar";
$this->menu($id, $submodules, $submode);
unset($submodules);
switch ($submode)
switch ($mode)
{
case 'reg_details':
@ -100,8 +91,8 @@ class ucp_profile extends ucp
update_username($user->data['username'], $username);
}
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode");
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode\">", '</a>');
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode");
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode\">", '</a>');
trigger_error($message);
}
}
@ -195,8 +186,8 @@ class ucp_profile extends ucp
WHERE user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode");
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode\">", '</a>');
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode");
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode\">", '</a>');
trigger_error($message);
}
}
@ -294,7 +285,7 @@ class ucp_profile extends ucp
WHERE user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode\">", '</a>');
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode\">", '</a>');
trigger_error($message);
}
}
@ -437,8 +428,8 @@ class ucp_profile extends ucp
}
}
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode");
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode\">", '</a>');
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode");
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode\">", '</a>');
trigger_error($message);
}
@ -489,11 +480,11 @@ class ucp_profile extends ucp
}
$template->assign_vars(array(
'L_TITLE' => $user->lang['UCP_' . strtoupper($submode)],
'L_TITLE' => $user->lang['UCP_' . strtoupper($mode)],
'S_DISPLAY_' . strtoupper($submode) => true,
'S_DISPLAY_' . strtoupper($mode) => true,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_UCP_ACTION' => "ucp.$phpEx$SID&amp;i=$id&amp;mode=$submode")
'S_UCP_ACTION' => "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode")
);
$this->display($user->lang['UCP_PROFILE'], 'ucp_profile.html');

View file

@ -11,9 +11,9 @@
//
// -------------------------------------------------------------
class ucp_register extends ucp
class ucp_register extends module
{
function main($id)
function ucp_register($id, $mode)
{
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;

View file

@ -11,9 +11,9 @@
//
// -------------------------------------------------------------
class ucp_remind extends ucp
class ucp_remind extends module
{
function main($id)
function ucp_remind($id, $mode)
{
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;

View file

@ -1,32 +1,178 @@
<?php
/***************************************************************************
* usercp_profile.php
* -------------------
* begin : Saturday, Feb 21, 2003
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id$
*
*
***************************************************************************/
// -------------------------------------------------------------
//
// $Id$
//
// FILENAME : ucp_zebra.php
// STARTED : Sun Sep 28, 2003
// COPYRIGHT : © 2001, 2003 phpBB Group
// WWW : http://www.phpbb.com/
// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
//
// -------------------------------------------------------------
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
***************************************************************************/
class ucp_zebra extends ucp
class ucp_zebra extends module
{
function main($module_id)
function ucp_zebra($id, $mode)
{
return;
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;
$submit = (!empty($_POST['submit'])) ? true : false;
if ($submit)
{
$var_ary = array(
'usernames' => 0,
'add' => '',
);
foreach ($var_ary as $var => $default)
{
$data[$var] = request_var($var, $default);
}
$var_ary = array(
'add' => array('string', false)
);
$error = validate_data($data, $var_ary);
extract($data);
unset($data);
if ($add)
{
$add = explode("\n", $add);
// Do these name/s exist on a list already? If so, ignore ... we could be
// 'nice' and automatically handle names added to one list present on
// the other (by removing the existing one) ... but I have a feeling this
// may lead to complaints
$sql = 'SELECT z.*, u.username
FROM ' . ZEBRA_TABLE . ' z, ' . USERS_TABLE . ' u
WHERE z.user_id = ' . $user->data['user_id'] . "
AND u.user_id = z.zebra_id";
$result = $db->sql_query($sql);
$friends = $foes = array();
while ($row = $db->sql_fetchrow($result))
{
if ($row['friend'])
{
$friends[] = $row['username'];
}
else
{
$foes[] = $row['username'];
}
}
$db->sql_freeresult($result);
$add = array_diff($add, $friends, $foes, array($user->data['user_id']));
unset($friends);
unset($foes);
$add = implode(', ', preg_replace('#^[\s]*?(.*?)[\s]*?$#e', "\"'\" . \$db->sql_escape('\\1') . \"'\"", $add));
$sql = 'SELECT user_id, user_permissions, user_founder
FROM ' . USERS_TABLE . '
WHERE username IN (' . $add . ')';
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$user_id_ary = array();
do
{
$user_id_ary[] = $row['user_id'];
}
while ($row = $db->sql_fetchrow($result));
// Remove users from foe list if they are admins or moderators
if ($mode == 'foes')
{
// This isn't right ...
$user_id_ary = array_diff($user_id_ary, array_keys(discover_auth($user_id_ary, array('a_', 'm_'))));
}
if (sizeof($user_id_ary))
{
$sql_mode = ($mode == 'friends') ? 'friend' : 'foe';
switch (SQL_LAYER)
{
case 'mysql':
case 'mysql4':
$sql = 'INSERT INTO ' . ZEBRA_TABLE . " (user_id, zebra_id, $sql_mode)
VALUES " . implode(', ', preg_replace('#^([0-9]+)$#', '(' . $user->data['user_id'] . ", \\1, 1)", $user_id_ary));
$db->sql_query($sql);
break;
case 'mssql':
case 'mssql-odbc':
case 'sqlite':
$sql = 'INSERT INTO ' . ZEBRA_TABLE . " (user_id, zebra_id, $sql_mode)
" . implode(' UNION ALL ', preg_replace('#^([0-9]+)$#', '(' . $user->data['user_id'] . ", \\1, 1)", $user_id_ary));
$db->sql_query($sql);
break;
default:
foreach ($user_id_ary as $zebra_id)
{
$sql = 'INSERT INTO ' . ZEBRA_TABLE . " (user_id, zebra_id, $sql_mode)
VALUES (" . $user->data['user_id'] . ", $zebra_id, 1)";
$db->sql_query($sql);
}
break;
}
}
unset($user_id_ary);
}
$db->sql_freeresult($result);
}
else if ($usernames)
{
// Force integer values
$usernames = array_map('intval', $usernames);
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE user_id = ' . $user->data['user_id'] . '
AND zebra_id IN (' . implode(', ', $usernames) . ')';
$db->sql_query($sql);
}
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode");
$message = $user->lang[strtoupper($mode) . '_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode\">", '</a>');
trigger_error($message);
}
$sql_and = ($mode == 'friends') ? 'z.friend = 1' : 'z.foe = 1';
$sql = 'SELECT z.*, u.username
FROM ' . ZEBRA_TABLE . ' z, ' . USERS_TABLE . ' u
WHERE z.user_id = ' . $user->data['user_id'] . "
AND $sql_and
AND u.user_id = z.zebra_id";
$result = $db->sql_query($sql);
$s_username_options = '';
while ($row = $db->sql_fetchrow($result))
{
$s_username_options .= '<option value="' . $row['zebra_id'] . '">' . $row['username'] . '</option>';
}
$db->sql_freeresult($result);
$template->assign_vars(array(
'L_TITLE' => $user->lang['UCP_' . strtoupper($mode)],
'U_SEARCH_USER' => "memberlist.$phpEx$SID&amp;mode=searchuser&amp;form=ucp&amp;field=add",
'S_USERNAME_OPTIONS' => $s_username_options,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_UCP_ACTION' => "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode")
);
$this->display($user->lang['UCP_ZEBRA'], 'ucp_zebra_' . $mode . '.html');
}
}

View file

@ -443,6 +443,7 @@ $lang += array(
'NO_OLDER_TOPICS' => 'There are no older topics in this forum',
'POST_IGNORE' => 'This post was made by <b>%1$s</b> who is on your ignore list. To display this post click %sHERE%s.',
'POST_BELOW_KARMA' => 'This post was made by <b>%1$s</b> whose karma rating of <b>%2$d</b> is below your desired minimum. To display this post click %3$sHERE%4$s.',
'POST_BY_FOE' => 'This post was made by <b>%1$s</b> who is currently on your ignore list. To display this post click %2$sHERE%3$s.',
'POST_ENCODING' => 'This post by <b>%1$s</b> was made in a character set different to yours. To view this post in its proper encoding click %2$sHERE%3$s.',
'DISPLAY_POSTS' => 'Display posts from previous',
'ALL_POSTS' => 'All Posts',
@ -680,6 +681,11 @@ $lang += array(
$lang += array(
'UCP' => 'User Control Panel',
'UCP_OPTIONS' => 'Options',
'FRIENDS' => 'Friends',
'FRIENDS_ONLINE' => 'Online',
'FRIENDS_OFFLINE' => 'Offline',
'NO_FRIENDS_ONLINE' => 'No friends online',
'NO_FRIENDS_OFFLINE'=> 'No friends offline',
'UCP_MAIN' => 'Overview',
@ -694,6 +700,9 @@ $lang += array(
'TOTAL_NO_PM' => '0 private messages in total',
'TOTAL_PM' => '1 private messages in total',
'TOTAL_PMS' => '$d private messages in total',
'YOUR_KARMA' => 'Your Karma level',
'YOUR_WARNINGS' => 'Your Warning level',
'SEARCH_YOUR_POSTS' => 'Show your posts',
'UCP_WATCHED' => 'Watched items',
'WATCHED_FORUMS' => 'Watched Forums',
@ -781,50 +790,6 @@ $lang += array(
'PROFILE_UPDATED' => 'Your profile has been updated.',
'UCP_PREFERENCES' => 'Preferences',
'UCP_PERSONAL' => 'Personal Settings',
'HIDE_ONLINE' => 'Hide my online status',
'NOTIFY_ON_PM' => 'Email me on new private messages',
'POPUP_ON_PM' => 'Pop up window on new private message',
'SHOW_EMAIL' => 'Users can contact me by email',
'ADMIN_EMAIL' => 'Administrators can email me information',
'BOARD_STYLE' => 'My board style',
'BOARD_LANGUAGE' => 'My language',
'BOARD_TIMEZONE' => 'My timezone',
'BOARD_DST' => 'Daylight Saving Time is in effect',
'BOARD_DATE_FORMAT' => 'My date format',
'BOARD_DATE_FORMAT_EXPLAIN' => 'The syntax used is identical to the PHP <a href=\"http://www.php.net/date\" target=\"_other\">date()</a> function',
'UCP_VIEW' => 'Viewing Posts',
'VIEW_IMAGES' => 'Display Images within posts',
'VIEW_FLASH' => 'Display Flash animations',
'VIEW_SMILIES' => 'Display Smileys as images',
'VIEW_SIGS' => 'Display Signatures',
'VIEW_AVATARS' => 'Display Avatars',
'DISABLE_CENSORS' => 'Enable Word censoring',
'MINIMUM_KARMA' => 'Minimum User Karma',
'MINIMUM_KARMA_EXPLAIN'=> 'Posts by users with Karma less than this will be ignored.',
'VIEW_TOPICS_DAYS' => 'Display topics from previous days',
'VIEW_TOPICS_KEY' => 'Display topics ordering by',
'VIEW_TOPICS_DIR' => 'Display topic order direction',
'UCP_POST' => 'Posting Messages',
'DEFAULT_SMILE' => 'Enable smilies by default',
'DEFAULT_HTML' => 'Enable HTML by default',
'DEFAULT_BBCODE' => 'Enable BBCode by default',
'DEFAULT_ADD_SIG' => 'Attach my signature by default',
'DEFAULT_NOTIFY' => 'Notify me upon replies by default',
'PREFERENCES_UPDATED' => 'Your preferences have been updated.',
'UCP_MESSAGING' => 'Messaging',
'UCP_LISTS' => 'Buddy/Ignore',
'REGISTRATION' => 'Registration',
'COPPA_BIRTHDAY' => 'To continue with the registration procedure please tell us when you were born.',
'UCP_COPPA_BEFORE' => 'Before %s',
@ -880,14 +845,6 @@ $lang += array(
'PASSWORD_MISMATCH' => 'The passwords you entered did not match',
'Current_password_mismatch' => 'The current password you supplied does not match that stored in the database',
'Password_long' => 'Your password must be no more than 32 characters',
'Username_taken' => 'Sorry but this username has already been taken',
'Username_invalid' => 'Sorry but this username contains an invalid character such as \'',
'Username_disallowed' => 'Sorry but this username has been disallowed',
'Email_taken' => 'Sorry but that email address is already registered to a user',
'Email_banned' => 'Sorry but this email address has been banned',
'Email_invalid' => 'Sorry but this email address is invalid',
'CONFIRM_CODE_WRONG' => 'The confirmation code you entered was incorrect.',
'TOO_MANY_REGISTERS' => 'You have exceeded the maximum number of registration attempts for this session. Please try again later.',
@ -910,7 +867,71 @@ $lang += array(
'COPPA' => 'Your account has been created but has to be approved, please check your email for details.',
);
// usercp_messaging
// ucp_prefs
$lang += array(
'UCP_PREFS' => 'Preferences',
'UCP_PERSONAL' => 'Personal Settings',
'HIDE_ONLINE' => 'Hide my online status',
'NOTIFY_ON_PM' => 'Email me on new private messages',
'POPUP_ON_PM' => 'Pop up window on new private message',
'SHOW_EMAIL' => 'Users can contact me by email',
'ADMIN_EMAIL' => 'Administrators can email me information',
'BOARD_STYLE' => 'My board style',
'BOARD_LANGUAGE' => 'My language',
'BOARD_TIMEZONE' => 'My timezone',
'BOARD_DST' => 'Daylight Saving Time is in effect',
'BOARD_DATE_FORMAT' => 'My date format',
'BOARD_DATE_FORMAT_EXPLAIN' => 'The syntax used is identical to the PHP <a href=\"http://www.php.net/date\" target=\"_other\">date()</a> function',
'UCP_VIEW' => 'Viewing Posts',
'VIEW_IMAGES' => 'Display Images within posts',
'VIEW_FLASH' => 'Display Flash animations',
'VIEW_SMILIES' => 'Display Smileys as images',
'VIEW_SIGS' => 'Display Signatures',
'VIEW_AVATARS' => 'Display Avatars',
'DISABLE_CENSORS' => 'Enable Word censoring',
'MINIMUM_KARMA' => 'Minimum User Karma',
'MINIMUM_KARMA_EXPLAIN'=> 'Posts by users with Karma less than this will be ignored.',
'VIEW_TOPICS_DAYS' => 'Display topics from previous days',
'VIEW_TOPICS_KEY' => 'Display topics ordering by',
'VIEW_TOPICS_DIR' => 'Display topic order direction',
'UCP_POST' => 'Posting Messages',
'DEFAULT_SMILE' => 'Enable smilies by default',
'DEFAULT_HTML' => 'Enable HTML by default',
'DEFAULT_BBCODE' => 'Enable BBCode by default',
'DEFAULT_ADD_SIG' => 'Attach my signature by default',
'DEFAULT_NOTIFY' => 'Notify me upon replies by default',
'PREFS_UPDATED' => 'Your preferences have been updated.',
);
// ucp_zebra
$lang += array(
'UCP_ZEBRA' => 'Friends and Foes',
'UCP_FRIENDS' => 'Friends',
'UCP_FOES' => 'Foes',
'FRIENDS_EXPLAIN' => 'Friends enable you quick access to members you communicate with frequently. If the template has relevant support any posts made by a friend may be highlighted.',
'YOUR_FRIENDS' => 'Your friends',
'YOUR_FRIENDS_EXPLAIN' => 'To remove usernames select them and click submit',
'ADD_FRIENDS' => 'Add new friends',
'ADD_FRIENDS_EXPLAIN' => 'You may enter several usernames each on a different line',
'NO_FRIENDS' => 'No friends currently defined',
'FOES_EXPLAIN' => 'Foes are users which will be ignored by default. Posts by these users will not be fully visible and personal messages will not be permitted. Please note that you cannot ignore moderators or administrators.',
'YOUR_FOES' => 'Your foes',
'YOUR_FOES_EXPLAIN' => 'To remove usernames select them and click submit',
'ADD_FOES' => 'Add new foes',
'ADD_FOES_EXPLAIN' => 'You may enter several usernames each on a different line',
'NO_FOES' => 'No foes currently defined',
'FRIENDS_UPDATED' => 'Your friends list has been updated successfully',
'FOES_UPDATED' => 'Your foes list has been updated successfully',
);
// ucp_pm
$lang += array(
'Private_Messaging' => 'Private Messaging',
'Unread_message' => 'Unread message',

View file

@ -47,99 +47,186 @@ include($phpbb_root_path . '/includes/functions_user.'.$phpEx);
// ---------
// FUNCTIONS
//
// Handles manipulation of user data. Primary used in registration
// and user profile manipulation
class ucp extends user
class module
{
var $modules = array();
var $error = array();
var $id = 0;
var $type;
var $name;
var $mode;
// Loads a given module (if it isn't already available), instantiates
// a new object, and where appropriate calls the modules init method
function load_module($module_name)
// Private methods, should not be overwritten
function create($module_type, $module_url, $selected_mod = false, $selected_submod = false)
{
if (!class_exists('ucp_' . $module_name))
global $template, $auth, $db, $user;
$sql = 'SELECT module_id, module_title, module_filename, module_subs, module_acl
FROM ' . MODULES_TABLE . "
WHERE module_type = '{$module_type}'
AND module_enabled = 1
ORDER BY module_order ASC";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
// Authorisation is required for the basic module
if ($row['module_acl'])
{
$is_auth = FALSE;
foreach (explode(',', $row['module_acl']) as $auth_option)
{
if ($auth->acl_get($auth_option))
{
$is_auth = TRUE;
break;
}
}
// The user is not authorised to use this module, skip it
if (!$is_auth)
{
continue;
}
}
$selected = ($row['module_filename'] == $selected_mod || $row['module_id'] == $selected_mod || (!$selected_mod && !$i)) ? true : false;
// Get the localised lang string if available, or make up our own otherwise
$template->assign_block_vars($module_type . '_section', array(
'L_TITLE' => (isset($user->lang[strtoupper($module_type) . '_' . $row['module_title']])) ? $user->lang[strtoupper($module_type) . '_' . $row['module_title']] : ucfirst(str_replace('_', ' ', strtolower($row['module_title']))),
'S_SELECTED' => $selected,
'U_TITLE' => $module_url . '&amp;i=' . $row['module_id'])
);
if ($selected)
{
$module_id = $row['module_id'];
$module_name = $row['module_filename'];
if ($row['module_subs'])
{
$j = 0;
$submodules_ary = explode("\n", $row['module_subs']);
foreach ($submodules_ary as $submodule)
{
$submodule = explode(',', trim($submodule));
$submodule_title = array_shift($submodule);
$is_auth = true;
foreach ($submodule as $auth_option)
{
if (!$auth->acl_get($auth_option))
{
$is_auth = false;
}
}
if (!$is_auth)
{
continue;
}
$selected = ($submodule_title == $selected_submod || (!$selected_submod && !$j)) ? true : false;
// Get the localised lang string if available, or make up our own otherwise
$template->assign_block_vars("{$module_type}_section.{$module_type}_subsection", array(
'L_TITLE' => (isset($user->lang[strtoupper($module_type) . '_' . strtoupper($submodule_title)])) ? $user->lang[strtoupper($module_type) . '_' . strtoupper($submodule_title)] : ucfirst(str_replace('_', ' ', strtolower($submodule_title))),
'S_SELECTED' => $selected,
'U_TITLE' => $module_url . '&amp;i=' . $module_id . '&amp;mode=' . $submodule_title
));
if ($selected)
{
$this->mode = $submodule_title;
}
$j++;
}
}
}
$i++;
}
$db->sql_freeresult($result);
if (!$module_id)
{
trigger_error('MODULE_NOT_EXIST');
}
$this->type = $module_type;
$this->id = $module_id;
$this->name = $module_name;
}
function load($type = false, $name = false, $mode = false, $run = true)
{
global $phpbb_root_path, $phpEx;
require_once($phpbb_root_path . 'includes/ucp/ucp_' . $module_name . '.'.$phpEx);
eval('$this->module = new ucp_' . $module_name . '();');
if ($type)
{
$this->type = $type;
}
if ($name)
{
$this->name = $name;
}
if (!class_exists($this->type . '_' . $this->name))
{
require_once($phpbb_root_path . "includes/{$this->type}/{$this->type}_{$this->name}.$phpEx");
if ($run)
{
eval("\$this->module = new {$this->type}_{$this->name}(\$this->id, \$this->mode);");
if (method_exists($this->module, 'init'))
{
$this->module->init();
}
}
}
// This is replaced by the loaded module
function main($module_id = false)
{
return false;
}
// This generates the block template variable for outputting the list
// of submodules, should be called with an associative array of modules
// in the form 'LANG_STRING' => 'LINK'
function menu(&$id, &$module_ary, &$selected_module)
{
global $template, $user, $phpEx, $SID, $s_modules;
foreach ($s_modules as $module_id => $section_data)
{
$template->assign_block_vars('ucp_section', array(
'L_TITLE' => $section_data['title'],
'S_SELECTED'=> $section_data['selected'],
'U_TITLE' => $section_data['url'])
);
if ($module_id == $id)
{
foreach ($module_ary as $section_title => $module_link)
{
$template->assign_block_vars('ucp_section.ucp_subsection', array(
'L_TITLE' => $user->lang['UCP_' . $section_title],
'S_SELECTED'=> ($section_title == strtoupper($selected_module)) ? true : false,
'U_TITLE' => "ucp.$phpEx$SID&amp;$module_link")
);
}
}
}
foreach ($module_ary as $section_title => $module_link)
{
$template->assign_block_vars('ucp_subsection', array(
'L_TITLE' => $user->lang['UCP_' . $section_title],
'S_SELECTED'=> ($section_title == strtoupper($selected_module)) ? true : false,
'U_TITLE' => "ucp.$phpEx$SID&amp;$module_link")
);
}
}
// Displays the appropriate template with the given title
function display(&$page_title, $tpl_name)
function display($page_title, $tpl_name)
{
global $template, $phpEx;
global $template;
page_header($page_title);
$template->set_filenames(array(
'body' => $tpl_name)
);
make_jumpbox('viewforum.'.$phpEx);
page_footer();
}
// Normalises supplied data dependant on required type/length, errors
// on incorrect data
// Public methods to be overwritten by modules
function module()
{
// Module name
// Module filename
// Module description
// Module version
// Module compatibility
return false;
}
function init()
{
return false;
}
function install()
{
return false;
}
function uninstall()
{
return false;
}
}
//
// FUNCTIONS
@ -151,26 +238,23 @@ $user->start();
$auth->acl($user->data);
$user->setup();
$ucp = new module();
// Basic parameter data
$mode = (!empty($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : '';
$module = (!empty($_REQUEST['i'])) ? intval($_REQUEST['i']) : 1;
// Instantiate a new ucp object
$ucp = new ucp();
$mode = (!empty($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : false;
$module = (!empty($_REQUEST['i'])) ? intval($_REQUEST['i']) : false;
// Basic "global" modes
switch ($mode)
{
case 'activate':
$ucp->load_module('activate');
$ucp->module->main();
$ucp->load('ucp', 'activate');
$ucp->module->ucp_activate();
break;
case 'remind':
$ucp->load_module('remind');
$ucp->module->main();
$ucp->load('ucp', 'remind');
$ucp->module->ucp_remind();
break;
case 'register':
@ -179,13 +263,13 @@ switch ($mode)
redirect("index.$phpEx$SID");
}
$ucp->load_module('register');
$ucp->module->main();
$ucp->load('ucp', 'register');
$ucp->module->ucp_register();
break;
case 'confirm':
$ucp->load_module('confirm');
$ucp->module->main();
$ucp->load('ucp', 'confirm');
$ucp->module->ucp_confirm();
break;
case 'login':
@ -222,39 +306,34 @@ $censors = array();
obtain_word_list($censors);
// Grab the other enabled UCP modules
$sql = 'SELECT module_id, module_title, module_filename
FROM ' . UCP_MODULES_TABLE . '
ORDER BY module_order ASC';
// Output listing of friends online
$sql = 'SELECT DISTINCT u.user_id, u.username, MAX(s.session_time) as online_time, MIN(s.session_allow_viewonline) AS viewonline
FROM ((' . ZEBRA_TABLE . ' z
LEFT JOIN ' . SESSIONS_TABLE . ' s ON s.session_user_id = z.zebra_id), ' . USERS_TABLE . ' u)
WHERE z.user_id = ' . $user->data['user_id'] . '
AND z.friend = 1
AND u.user_id = z.zebra_id
GROUP BY z.zebra_id';
$result = $db->sql_query($sql);
$s_modules = array();
$update_time = $config['load_online_time'] * 60;
while ($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('ucp_sections', array(
'SECTION' => $user->lang['UCP_' . $row['module_title']],
$which = (time() - $update_time < $row['online_time']) ? 'online' : 'offline';
'U_SECTION' => "ucp.$phpEx$SID&amp;i=" . $row['module_id'],
$template->assign_block_vars("friends_{$which}", array(
'U_PROFILE' => "memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $row['user_id'],
'S_IS_TAB' => ($row['module_id'] == $module) ? true : false)
'USERNAME' => $row['username'])
);
$s_modules[$row['module_id']]['title'] = $user->lang['UCP_' . $row['module_title']];
$s_modules[$row['module_id']]['url'] = "ucp.$phpEx$SID&amp;i=" . $row['module_id'];
$s_modules[$row['module_id']]['selected'] = ($row['module_id'] == $module) ? true : false;
if ($row['module_id'] == $module)
{
$selected_module = $row['module_filename'];
$selected_id = $row['module_id'];
}
}
$db->sql_freeresult($result);
if ($selected_module)
{
$ucp->load_module($selected_module);
$ucp->module->main($selected_id);
}
// Instantiate module system and generate list of available modules
$ucp->create('ucp', "ucp.$phpEx$SID", $module, $mode);
// Load and execute the relevant module
$ucp->load();
?>

View file

@ -29,7 +29,6 @@ $sort_days = (isset($_REQUEST['st'])) ? max(intval($_REQUEST['st']), 0) : ((!emp
$sort_key = (!empty($_REQUEST['sk'])) ? htmlspecialchars($_REQUEST['sk']) : ((!empty($user->data['user_sortby_type'])) ? $user->data['user_sortby_type'] : 't');
$sort_dir = (!empty($_REQUEST['sd'])) ? htmlspecialchars($_REQUEST['sd']) : ((!empty($user->data['user_sortby_dir'])) ? $user->data['user_sortby_dir'] : 'd');
// 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)
@ -37,7 +36,6 @@ if (!$forum_id)
trigger_error('NO_FORUM');
}
// Grab appropriate forum data
if ($user->data['user_id'] == ANONYMOUS)
{
@ -87,7 +85,6 @@ if (!($forum_data = $db->sql_fetchrow($result)))
}
$db->sql_freeresult($result);
// Is this forum a link? ... User got here either because the
// number of clicks is being tracked or they guessed the id
if ($forum_data['forum_link'])
@ -104,11 +101,9 @@ if ($forum_data['forum_link'])
redirect($forum_data['forum_link']);
}
// Configure style, language, etc.
$user->setup(false, $forum_data['forum_style']);
// Forum is passworded ... check whether access has been granted to this
// user this session, if not show login box
if ($forum_data['forum_password'])
@ -116,9 +111,8 @@ if ($forum_data['forum_password'])
login_forum_box($forum_data);
}
// Permissions check
if (!$auth->acl_gets('f_read', $forum_id))
if (!$auth->acl_get('f_read', $forum_id))
{
if ($user->data['user_id'] != ANONYMOUS)
{
@ -128,11 +122,9 @@ if (!$auth->acl_gets('f_read', $forum_id))
login_box(preg_replace('#.*?([a-z]+?\.' . $phpEx . '.*?)$#i', '\1', htmlspecialchars($_SERVER['REQUEST_URI'])), '', $user->lang['LOGIN_VIEWFORUM']);
}
// Build navigation links
generate_forum_nav($forum_data);
// Do we have subforums?
$moderators = array();
@ -238,9 +230,6 @@ if ($forum_data['forum_type'] == FORUM_POST)
$sql_limit_time = '';
}
// Select the sort order
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
// Basic pagewide vars
$post_alt = ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['FORUM_LOCKED'] : $user->lang['POST_NEW_TOPIC'];
@ -282,7 +271,6 @@ if ($forum_data['forum_type'] == FORUM_POST)
'U_MARK_READ' => "viewforum.$phpEx$SID&amp;f=$forum_id&amp;mark=topics")
);
// Grab icons
$icons = array();
obtain_icons($icons);
@ -302,12 +290,12 @@ if ($forum_data['forum_type'] == FORUM_POST)
$sql_approved = ($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1';
$sql_select = (($config['load_db_lastread'] || $config['load_db_track']) && $user->data['user_id'] != ANONYMOUS) ? ', tt.mark_type, tt.mark_time' : '';
// Obtain announcements
// Obtain announcements ... removed sort ordering, sort by time in all cases
$sql = "SELECT t.* $sql_select
FROM $sql_from
WHERE t.forum_id IN ($forum_id, 0)
AND t.topic_type IN (" . POST_ANNOUNCE . ', ' . POST_GLOBAL . ")
ORDER BY $sql_sort_order";
AND t.topic_type IN (" . POST_ANNOUNCE . ', ' . POST_GLOBAL . ')
ORDER BY t.topic_time DESC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@ -320,7 +308,6 @@ if ($forum_data['forum_type'] == FORUM_POST)
// If the user is trying to reach late pages, start searching from the end
$store_reverse = FALSE;
$sql_limit = $config['topics_per_page'];
if ($start > $topics_count / 2)
{
$store_reverse = TRUE;
@ -330,16 +317,20 @@ if ($forum_data['forum_type'] == FORUM_POST)
$sql_limit = min($config['topics_per_page'], max(1, $topics_count - $start));
}
$sql_sort_order = preg_replace('/(ASC|DESC)/e', "('\$1' == 'ASC') ? 'DESC' : 'ASC'", $sql_sort_order);
// Select the sort order
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC');
$sql_start = max(0, $topics_count - $sql_limit - $start);
}
else
{
// Select the sort order
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
$sql_start = $start;
}
// Obtain other topics
$sql = "SELECT t.* $sql_select
$sql_rownum = (SQL_LAYER != 'oracle') ? '' : ', ROWNUM rnum ';
$sql = "SELECT t.* $sql_select$sql_rownum
FROM $sql_from
WHERE t.forum_id = $forum_id
AND t.topic_type NOT IN (" . POST_ANNOUNCE . ', ' . POST_GLOBAL . ")
@ -355,14 +346,7 @@ if ($forum_data['forum_type'] == FORUM_POST)
}
$db->sql_freeresult($result);
if ($store_reverse)
{
$topic_list = array_merge($announcement_list, array_reverse($topic_list));
}
else
{
$topic_list = array_merge($announcement_list, $topic_list);
}
$topic_list = ($store_reverse) ? array_merge($announcement_list, array_reverse($topic_list)) : array_merge($announcement_list, $topic_list);
// Okay, lets dump out the page ...
if (count($topic_list))

View file

@ -309,31 +309,12 @@ if ($rate)
trigger_error($message);
}
// What is start equal to?
if (!empty($post_id))
{
$start = floor(($prev_posts - 1) / $config['posts_per_page']) * $config['posts_per_page'];
}
// Fill extension informations, if this topic has attachments
$extensions = array();
if ($topic_attachment)
{
obtain_attach_extensions($extensions);
}
// Are we watching this topic?
$s_watching_topic = $s_watching_topic_img = '';
if ($config['email_enable'] && $config['allow_topic_notify'])
{
watch_topic_forum('topic', $s_watching_topic, $s_watching_topic_img, $user->data['user_id'], $topic_id, $notify_status);
}
// Post ordering options
$limit_days = array(0 => $user->lang['ALL_POSTS'], 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']);
@ -369,8 +350,19 @@ else
$limit_posts_time = '';
}
// Select the sort order
$sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
// Fill extension informations, if this topic has attachments
$extensions = array();
if ($topic_attachment)
{
obtain_attach_extensions($extensions);
}
// Are we watching this topic?
$s_watching_topic = $s_watching_topic_img = '';
if ($config['email_enable'] && $config['allow_topic_notify'])
{
watch_topic_forum('topic', $s_watching_topic, $s_watching_topic_img, $user->data['user_id'], $topic_id, $notify_status);
}
// Grab ranks
$ranks = array();
@ -414,7 +406,7 @@ $topic_mod .= ($auth->acl_get('f_announce', $forum_id) && $topic_type != POST_GL
$topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '<option value="viewlogs">' . $user->lang['VIEW_TOPIC_LOGS'] . '</option>' : '';
// If we've got a hightlight set pass it on to pagination.
$pagination_url = "viewtopic.$phpEx$SID&amp;f=$forum_id&amp;t=$topic_id&amp;" . (($highlight_match) ? "&amp;hilit=$highlight" : '');
$pagination_url = "viewtopic.$phpEx$SID&amp;f=$forum_id&amp;t=$topic_id&amp;sk=$sort_key&amp;st=$sort_days&amp;sd=$sort_dir" . (($highlight_match) ? "&amp;hilit=$highlight" : '');
$pagination = generate_pagination($pagination_url, $total_posts, $config['posts_per_page'], $start);
// Grab censored words
@ -659,16 +651,10 @@ if (!empty($poll_start))
unset($voted_id);
}
// Container for user details, only process once
$user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = array();
$has_attachments = $display_notice = FALSE;
$force_encoding = '';
$bbcode_bitfield = $i = $i_total = 0;
// If the user is trying to reach the second half of the topic, fetch it starting from the end
$store_reverse = FALSE;
$limit = $config['posts_per_page'];
if ($start > $total_posts / 2)
{
$store_reverse = TRUE;
@ -678,13 +664,25 @@ if ($start > $total_posts / 2)
$limit = min($config['posts_per_page'], max(1, $total_posts - $start));
}
$sort_order = preg_replace('/(ASC|DESC)/e', "('\$1' == 'ASC') ? 'DESC' : 'ASC'", $sort_order);
$sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC');
$start = max(0, $total_posts - $limit - $start);
}
else
{
// Select the sort order
$sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
}
// Container for user details, only process once
$user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = array();
$has_attachments = $display_notice = FALSE;
$force_encoding = '';
$bbcode_bitfield = $i = $i_total = 0;
// Go ahead and pull all data for this topic
$sql = 'SELECT u.username, u.user_id, u.user_colour, u.user_posts, u.user_from, u.user_karma, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_jabber, u.user_regdate, u.user_msnm, u.user_allow_viewemail, u.user_allow_viewonline, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, p.*
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
$sql = 'SELECT u.username, u.user_id, u.user_colour, u.user_posts, u.user_from, u.user_karma, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_jabber, u.user_regdate, u.user_msnm, u.user_allow_viewemail, u.user_allow_viewonline, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, z.friend, z.foe, p.*
FROM ((' . POSTS_TABLE . ' p
LEFT JOIN ' . ZEBRA_TABLE . ' z ON (z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id)), ' . USERS_TABLE . " u)
WHERE p.topic_id = $topic_id
" . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND p.post_approved = 1') . "
$limit_posts_time
@ -704,7 +702,9 @@ do
$poster_id = $row['poster_id'];
$poster = ($poster_id == ANONYMOUS) ? ((!empty($row['post_username'])) ? $row['post_username'] : $user->lang['GUEST']) : $row['username'];
if ($row['user_karma'] < $user->data['user_min_karma'] && (!$view || $view != 'karma' || $post_id != $row['post_id']))
if (!$view || $view != 'show' || $post_id != $row['post_id'])
{
if ($row['user_karma'] < $user->data['user_min_karma'])
{
$rowset[] = array(
'below_karma' => TRUE,
@ -715,6 +715,17 @@ do
continue;
}
else if ($row['foe'])
{
$rowset[] = array(
'foe' => TRUE,
'post_id' => $row['post_id'],
'poster' => $poster,
);
continue;
}
}
// Does post have an attachment? If so, add it to the list
if ($row['post_attachment'] && $config['allow_attachments'])
@ -749,7 +760,8 @@ do
'bbcode_bitfield' => $row['bbcode_bitfield'],
'enable_html' => $row['enable_html'],
'enable_smilies' => $row['enable_smilies'],
'enable_sig' => $row['enable_sig']
'enable_sig' => $row['enable_sig'],
'friend' => $row['friend'],
));
}
else
@ -774,7 +786,8 @@ do
'bbcode_bitfield' => $row['bbcode_bitfield'],
'enable_html' => $row['enable_html'],
'enable_smilies' => $row['enable_smilies'],
'enable_sig' => $row['enable_sig']
'enable_sig' => $row['enable_sig'],
'friend' => $row['friend'],
);
}
@ -1020,7 +1033,18 @@ foreach ($rowset as $i => $row)
'S_IGNORE_POST' => true,
'S_ROW_COUNT' => $i,
'L_IGNORE_POST' => sprintf($user->lang['POST_BELOW_KARMA'], $row['poster'], $row['user_karma'], "<a href=\"viewtopic.$phpEx$SID&amp;f=$forum_id&amp;p=" . $row['post_id'] . '&amp;view=karma#' . $row['post_id'] . '">', '</a>'))
'L_IGNORE_POST' => sprintf($user->lang['POST_BELOW_KARMA'], $row['poster'], $row['user_karma'], "<a href=\"viewtopic.$phpEx$SID&amp;f=$forum_id&amp;p=" . $row['post_id'] . '&amp;view=show#' . $row['post_id'] . '">', '</a>'))
);
continue;
}
else if ($row['foe'])
{
$template->assign_block_vars('postrow', array(
'S_IGNORE_POST' => true,
'S_ROW_COUNT' => $i,
'L_IGNORE_POST' => sprintf($user->lang['POST_BY_FOE'], $row['poster'], "<a href=\"viewtopic.$phpEx$SID&amp;f=$forum_id&amp;p=" . $row['post_id'] . '&amp;view=show#' . $row['post_id'] . '">', '</a>'))
);
continue;
@ -1169,7 +1193,8 @@ foreach ($rowset as $i => $row)
'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? TRUE : FALSE,
'S_POST_UNAPPROVED' => ($row['post_approved']) ? FALSE : TRUE,
'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_', $forum_id)) ? TRUE : FALSE,
'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'])
'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'],
'S_FRIEND' => ($row['friend']) ? true : false)
);
// Process Attachments for this post