aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/functions_user.php33
-rw-r--r--phpBB/includes/ucp/ucp_activate.php2
-rw-r--r--phpBB/includes/ucp/ucp_confirm.php4
-rw-r--r--phpBB/includes/ucp/ucp_main.php104
-rw-r--r--phpBB/includes/ucp/ucp_prefs.php33
-rw-r--r--phpBB/includes/ucp/ucp_profile.php41
-rw-r--r--phpBB/includes/ucp/ucp_register.php4
-rw-r--r--phpBB/includes/ucp/ucp_remind.php4
-rw-r--r--phpBB/includes/ucp/ucp_zebra.php198
9 files changed, 260 insertions, 163 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index f12bf21627..bf2eb2c4dd 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -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));
diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php
index 9198a1c06e..da43668294 100644
--- a/phpBB/includes/ucp/ucp_activate.php
+++ b/phpBB/includes/ucp/ucp_activate.php
@@ -11,7 +11,7 @@
//
// -------------------------------------------------------------
-class ucp_activate extends ucp
+class ucp_activate extends module
{
function main($module_id)
{
diff --git a/phpBB/includes/ucp/ucp_confirm.php b/phpBB/includes/ucp/ucp_confirm.php
index 11939dfb8e..2d44fc943a 100644
--- a/phpBB/includes/ucp/ucp_confirm.php
+++ b/phpBB/includes/ucp/ucp_confirm.php
@@ -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;
diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php
index ddf5b907b9..ccaf4beca7 100644
--- a/phpBB/includes/ucp/ucp_main.php
+++ b/phpBB/includes/ucp/ucp_main.php
@@ -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;
}
}
diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php
index 61ca31a31c..d368188f01 100644
--- a/phpBB/includes/ucp/ucp_prefs.php
+++ b/phpBB/includes/ucp/ucp_prefs.php
@@ -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');
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index f28c0a214a..8457b50bda 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -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');
diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php
index 9414d27681..83dde01154 100644
--- a/phpBB/includes/ucp/ucp_register.php
+++ b/phpBB/includes/ucp/ucp_register.php
@@ -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;
diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php
index 90cb3a1cbc..9f5a19bb58 100644
--- a/phpBB/includes/ucp/ucp_remind.php
+++ b/phpBB/includes/ucp/ucp_remind.php
@@ -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;
diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php
index b5a4051390..5627537d80 100644
--- a/phpBB/includes/ucp/ucp_zebra.php
+++ b/phpBB/includes/ucp/ucp_zebra.php
@@ -1,32 +1,178 @@
<?php
-/***************************************************************************
- * usercp_profile.php
- * -------------------
- * begin : Saturday, Feb 21, 2003
- * copyright : (C) 2001 The phpBB Group
- * email : support@phpbb.com
- *
- * $Id$
- *
- *
- ***************************************************************************/
-
-/***************************************************************************
- *
- * 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
+// -------------------------------------------------------------
+//
+// $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 ]
+//
+// -------------------------------------------------------------
+
+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');
+
+
}
}