mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-18 17:28:56 +00:00
Email via memberslist
git-svn-id: file:///svn/phpbb/trunk@3625 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
58e755b906
commit
d15b81a8a3
1 changed files with 369 additions and 235 deletions
|
@ -79,9 +79,239 @@ while ($row = $db->sql_fetchrow($result))
|
|||
$db->sql_freeresult($result);
|
||||
|
||||
|
||||
if ($mode != 'viewprofile')
|
||||
switch ($mode)
|
||||
{
|
||||
// Memberlist sorting
|
||||
case 'viewprofile':
|
||||
// Display a profile
|
||||
$page_title = sprintf($user->lang['VIEWING_PROFILE'], $row['username']);
|
||||
$template_html = 'memberlist_view.html';
|
||||
|
||||
if ($user_id == ANONYMOUS)
|
||||
{
|
||||
trigger_error($user->lang['NO_USER']);
|
||||
}
|
||||
|
||||
// Do the SQL thang
|
||||
$sql = "SELECT username, user_id, user_viewemail, user_posts, user_regdate, user_rank, user_from, user_occ, user_interests, user_website, user_email, user_icq, user_aim, user_yim, user_msnm, user_avatar, user_avatar_type, user_allowavatar, user_lastvisit
|
||||
FROM " . USERS_TABLE . "
|
||||
WHERE user_id = $user_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if (!($row = $db->sql_fetchrow($result)))
|
||||
{
|
||||
trigger_error($user->lang['NO_USER']);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "SELECT COUNT(p.post_id) AS num_posts
|
||||
FROM " . POSTS_TABLE . " p, " . FORUMS_TABLE . " f
|
||||
WHERE p.poster_id = $user_id
|
||||
AND f.forum_id = p.forum_id
|
||||
AND f.enable_post_count = 1";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$num_real_posts = min($row['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
|
||||
AND f.forum_id = p.forum_id
|
||||
AND f.enable_post_count = 1
|
||||
GROUP BY f.forum_id, f.forum_name
|
||||
ORDER BY num_posts DESC
|
||||
LIMIT 1";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$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
|
||||
AND t.topic_id = p.topic_id
|
||||
AND f.forum_id = t.forum_id
|
||||
AND f.enable_post_count = 1
|
||||
GROUP BY t.topic_id, t.topic_title
|
||||
ORDER BY num_posts DESC
|
||||
LIMIT 1";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$active_t_row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Do the relevant calculations
|
||||
$memberdays = max(1, round((time() - $row['user_regdate']) / 86400));
|
||||
$posts_per_day = $row['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 = '';
|
||||
if (!empty($active_f_row['num_posts']))
|
||||
{
|
||||
$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;
|
||||
}
|
||||
unset($active_f_row);
|
||||
|
||||
$active_t_name = $active_t_id = $active_t_count = $active_t_pct = '';
|
||||
if (!empty($active_t_row['num_posts']))
|
||||
{
|
||||
$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;
|
||||
}
|
||||
unset($active_t_row);
|
||||
|
||||
$template->assign_vars(show_profile($row));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'USER_PROFILE' => sprintf($user->lang['VIEWING_PROFILE'], $row['username']),
|
||||
|
||||
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
|
||||
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
|
||||
'ACTIVE_FORUM' => $active_f_name,
|
||||
'ACTIVE_FORUM_POSTS'=> ($active_f_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count),
|
||||
'ACTIVE_FORUM_PCT' => sprintf($user->lang['POST_PCT'], $active_f_pct),
|
||||
'ACTIVE_TOPIC' => $active_t_name,
|
||||
'ACTIVE_TOPIC_POSTS'=> ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count),
|
||||
'ACTIVE_TOPIC_PCT' => sprintf($user->lang['POST_PCT'], $active_t_pct),
|
||||
|
||||
'OCCUPATION' => (!empty($row['user_occ'])) ? $row['user_occ'] : '',
|
||||
'INTERESTS' => (!empty($row['user_interests'])) ? $row['user_interests'] : '',
|
||||
|
||||
'U_ACTIVE_FORUM' => "viewforum.$phpEx$SID&f=$active_f_id",
|
||||
'U_ACTIVE_TOPIC' => "viewtopic.$phpEx$SID&t=$active_t_id",)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'email':
|
||||
// Send an email
|
||||
$page_title = $user->lang['SEND_EMAIL'];
|
||||
$template_html = 'memberlist_email.html';
|
||||
|
||||
if ($user_id == ANONYMOUS)
|
||||
{
|
||||
trigger_error($user->lang['NO_USER']);
|
||||
}
|
||||
|
||||
if (empty($config['board_email_form']) || empty($config['email_enable']) || !$auth->acl_gets('u_sendemail', 'a_'))
|
||||
{
|
||||
trigger_error($user->lang['NO_EMAIL']);
|
||||
}
|
||||
|
||||
// Get the appropriate username, etc.
|
||||
$sql = "SELECT username, user_email, user_viewemail, user_lang
|
||||
FROM " . USERS_TABLE . "
|
||||
WHERE user_id = $user_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if (!($row = $db->sql_fetchrow($result)))
|
||||
{
|
||||
trigger_error($$user->lang['NO_USER']);
|
||||
}
|
||||
|
||||
// Can we send email to this user?
|
||||
if (empty($row['user_viewemail']) && !$auth->acl_get('a_'))
|
||||
{
|
||||
trigger_error($user->lang['NO_EMAIL']);
|
||||
}
|
||||
|
||||
// Are we trying to abuse the facility?
|
||||
if (time() - $user->data['user_emailtime'] < $config['flood_interval'])
|
||||
{
|
||||
trigger_error($lang['FLOOD_EMAIL_LIMIT']);
|
||||
}
|
||||
|
||||
$username = $row['username'];
|
||||
$user_email = $row['user_email'];
|
||||
$user_lang = $row['user_lang'];
|
||||
|
||||
// User has submitted a message, handle it
|
||||
if (isset($_POST['submit']))
|
||||
{
|
||||
$error = FALSE;
|
||||
|
||||
if (!empty($_POST['subject']))
|
||||
{
|
||||
$subject = trim(stripslashes($_POST['subject']));
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = TRUE;
|
||||
$error_msg = (!empty($error_msg)) ? $error_msg . '<br />' . $lang['EMPTY_SUBJECT_EMAIL'] : $lang['EMPTY_SUBJECT_EMAIL'];
|
||||
}
|
||||
|
||||
if (!empty($_POST['message']))
|
||||
{
|
||||
$message = trim(stripslashes($_POST['message']));
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = TRUE;
|
||||
$error_msg = (!empty($error_msg)) ? $error_msg . '<br />' . $lang['EMPTY_MESSAGE_EMAIL'] : $lang['EMPTY_MESSAGE_EMAIL'];
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$sql = "UPDATE " . USERS_TABLE . "
|
||||
SET user_emailtime = " . time() . "
|
||||
WHERE user_id = " . $user->data['user_id'];
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
|
||||
$emailer = new emailer($config['smtp_delivery']);
|
||||
|
||||
$email_headers = 'From: ' . $user->data['user_email'] . "\n";
|
||||
if (!empty($_POST['cc_email']))
|
||||
{
|
||||
$email_headers .= "Cc: " . $user->data['user_email'] . "\n";
|
||||
}
|
||||
$email_headers .= 'Return-Path: ' . $user->data['user_email'] . "\n";
|
||||
$email_headers .= 'X-AntiAbuse: Board servername - ' . $server_name . "\n";
|
||||
$email_headers .= 'X-AntiAbuse: User_id - ' . $user->data['user_id'] . "\n";
|
||||
$email_headers .= 'X-AntiAbuse: Username - ' . $user->data['username'] . "\n";
|
||||
$email_headers .= 'X-AntiAbuse: User IP - ' . $user->ip . "\r\n";
|
||||
|
||||
$emailer->use_template('profile_send_email', $user_lang);
|
||||
$emailer->email_address($user_email);
|
||||
$emailer->set_subject($subject);
|
||||
$emailer->extra_headers($email_headers);
|
||||
|
||||
$emailer->assign_vars(array(
|
||||
'SITENAME' => $config['sitename'],
|
||||
'BOARD_EMAIL' => $config['board_email'],
|
||||
'FROM_USERNAME' => $userdata['username'],
|
||||
'TO_USERNAME' => $username,
|
||||
'MESSAGE' => $message)
|
||||
);
|
||||
$emailer->send();
|
||||
$emailer->reset();
|
||||
|
||||
$template->assign_vars(array(
|
||||
'META' => '<meta http-equiv="refresh" content="3;url=' . "index.$phpEx$SID" . '">')
|
||||
);
|
||||
|
||||
trigger_error($lang['EMAIL_SENT'] . '<br /><br />' . sprintf($lang['RETURN_INDEX'], '<a href="' . "index.$phpEx$SID" . '">', '</a>'));
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'USERNAME' => $username,
|
||||
'ERROR_MESSAGE' => (!empty($error_msg)) ? $error_msg : '',
|
||||
|
||||
'S_POST_ACTION' => "memberlist.$phpEx$SID&mode=email&u=$user_id")
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
// The basic memberlist
|
||||
$page_title = $user->lang['MEMBERLIST'];
|
||||
$template_html = 'memberlist_body.html';
|
||||
|
||||
// Sorting
|
||||
$sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT'], 'e' => $user->lang['SORT_EMAIL'], 'f' => $user->lang['WEBSITE'], 'g' => $user->lang['ICQ'], 'h' => $user->lang['AIM'], 'i' => $user->lang['MSNM'], 'j' => $user->lang['YIM'], 'k' => $user->lang['SORT_LAST_ACTIVE']);
|
||||
$sort_key_sql = array('a' => 'username', 'b' => 'user_from', 'c' => 'user_regdate', 'd' => 'user_posts', 'e' => 'user_email', 'f' => 'user_website', 'g' => 'user_icq', 'h' => 'user_aim', 'i' => 'user_msnm', 'j' => 'user_yim', 'k' => 'user_lastvisit');
|
||||
|
||||
|
@ -103,9 +333,6 @@ if ($mode != 'viewprofile')
|
|||
}
|
||||
$s_sort_dir .= '</select>';
|
||||
|
||||
|
||||
|
||||
|
||||
// Additional sorting options for user search
|
||||
$where_sql = '';
|
||||
if ($mode == 'searchuser')
|
||||
|
@ -223,7 +450,6 @@ if ($mode != 'viewprofile')
|
|||
$sql = "SELECT username, user_id, user_viewemail, user_posts, user_regdate, user_rank, user_from, user_website, user_email, user_icq, user_aim, user_yim, user_msnm, user_avatar, user_avatar_type, user_allowavatar, user_lastvisit
|
||||
FROM " . USERS_TABLE . "
|
||||
WHERE user_id <> " . ANONYMOUS . "
|
||||
$where_sql
|
||||
ORDER BY $order_by
|
||||
LIMIT $start, " . $config['topics_per_page'];
|
||||
$result = $db->sql_query($sql);
|
||||
|
@ -269,106 +495,13 @@ if ($mode != 'viewprofile')
|
|||
'S_MODE_ACTION' => "memberlist.$phpEx$SID&mode=$mode&form=$form")
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($user_id == ANONYMOUS)
|
||||
{
|
||||
trigger_error($user->lang['NO_USER']);
|
||||
}
|
||||
|
||||
|
||||
// Do the SQL thang
|
||||
$sql = "SELECT username, user_id, user_viewemail, user_posts, user_regdate, user_rank, user_from, user_occ, user_interests, user_website, user_email, user_icq, user_aim, user_yim, user_msnm, user_avatar, user_avatar_type, user_allowavatar, user_lastvisit
|
||||
FROM " . USERS_TABLE . "
|
||||
WHERE user_id = $user_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if (!($row = $db->sql_fetchrow($result)))
|
||||
{
|
||||
trigger_error($user->lang['NO_USER']);
|
||||
}
|
||||
$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
|
||||
AND f.forum_id = p.forum_id
|
||||
AND f.enable_post_count = 1
|
||||
GROUP BY f.forum_id, f.forum_name
|
||||
ORDER BY num_posts DESC
|
||||
LIMIT 1";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$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
|
||||
AND t.topic_id = p.topic_id
|
||||
AND f.forum_id = t.forum_id
|
||||
AND f.enable_post_count = 1
|
||||
GROUP BY t.topic_id, t.topic_title
|
||||
ORDER BY num_posts DESC
|
||||
LIMIT 1";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$active_t_row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Do the relevant calculations
|
||||
$memberdays = max(1, round((time() - $row['user_regdate'] ) / 86400));
|
||||
$posts_per_day = $row['user_posts'] / $memberdays;
|
||||
$percentage = ($config['num_posts']) ? min(100, ($row['user_posts'] / $config['num_posts']) * 100) : 0;
|
||||
|
||||
$active_f_name = $active_f_id = $active_f_count = $active_f_pct = '';
|
||||
if (!empty($active_f_row['num_posts']))
|
||||
{
|
||||
$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;
|
||||
}
|
||||
unset($active_f_row);
|
||||
|
||||
$active_t_name = $active_t_id = $active_t_count = $active_t_pct = '';
|
||||
if (!empty($active_t_row['num_posts']))
|
||||
{
|
||||
$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;
|
||||
}
|
||||
unset($active_t_row);
|
||||
|
||||
$template->assign_vars(show_profile($row));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'USER_PROFILE' => sprintf($user->lang['VIEWING_PROFILE'], $row['username']),
|
||||
|
||||
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
|
||||
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
|
||||
'ACTIVE_FORUM' => $active_f_name,
|
||||
'ACTIVE_FORUM_POSTS'=> ($active_f_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count),
|
||||
'ACTIVE_FORUM_PCT' => sprintf($user->lang['POST_PCT'], $active_f_pct),
|
||||
'ACTIVE_TOPIC' => $active_t_name,
|
||||
'ACTIVE_TOPIC_POSTS'=> ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count),
|
||||
'ACTIVE_TOPIC_PCT' => sprintf($user->lang['POST_PCT'], $active_t_pct),
|
||||
|
||||
'OCCUPATION' => (!empty($row['user_occ'])) ? $row['user_occ'] : '',
|
||||
'INTERESTS' => (!empty($row['user_interests'])) ? $row['user_interests'] : '',
|
||||
|
||||
'U_ACTIVE_FORUM' => "viewforum.$phpEx$SID&f=$active_f_id",
|
||||
'U_ACTIVE_TOPIC' => "viewtopic.$phpEx$SID&t=$active_t_id",)
|
||||
);
|
||||
}
|
||||
|
||||
// Output the page
|
||||
$page_title = ($mode != 'viewprofile') ? $user->lang['MEMBERLIST'] : sprintf($user->lang['VIEWING_PROFILE'], $row['username']);
|
||||
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
|
||||
|
||||
$template->set_filenames(array(
|
||||
'body' => ($mode != 'viewprofile') ? 'memberlist_body.html' : 'memberlist_view.html')
|
||||
'body' => $template_html)
|
||||
);
|
||||
make_jumpbox('viewforum.'.$phpEx);
|
||||
|
||||
|
@ -380,7 +513,7 @@ include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
|||
//
|
||||
function show_profile($data)
|
||||
{
|
||||
global $config, $auth, $template, $user, $phpEx;
|
||||
global $config, $auth, $template, $user, $SID, $phpEx;
|
||||
global $ranksrow;
|
||||
|
||||
$username = $data['username'];
|
||||
|
@ -425,8 +558,7 @@ function show_profile($data)
|
|||
|
||||
if (!empty($data['user_viewemail']) || $auth->acl_get('a_'))
|
||||
{
|
||||
$email_uri = ($config['board_email_form']) ? "ucp.$phpEx$SID&mode=email&u=" . $user_id : 'mailto:' . $row['user_email'];
|
||||
|
||||
$email_uri = (!empty($config['board_email_form'])) ? "memberlist.$phpEx$SID&mode=email&u=" . $user_id : 'mailto:' . $row['user_email'];
|
||||
$email_img = '<a href="' . $email_uri . '">' . $user->img('icon_email', $user->lang['EMAIL']) . '</a>';
|
||||
$email = '<a href="' . $email_uri . '">' . $user->lang['EMAIL'] . '</a>';
|
||||
}
|
||||
|
@ -474,6 +606,8 @@ function show_profile($data)
|
|||
$search_img = '<a href="' . $temp_url . '">' . $user->img('icon_search', $user->lang['SEARCH']) . '</a>';
|
||||
$search = '<a href="' . $temp_url . '">' . $user->lang['SEARCH'] . '</a>';
|
||||
|
||||
$last_visit = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit'];
|
||||
|
||||
$template_vars = array(
|
||||
'USERNAME' => $username,
|
||||
'ONLINE_IMG' => ($data['user_lastvisit'] >= time() - 600) ? 'yes' : 'no',
|
||||
|
@ -483,7 +617,7 @@ function show_profile($data)
|
|||
'RANK_IMG' => $rank_img,
|
||||
|
||||
'JOINED' => $user->format_date($data['user_regdate'], $user->lang['DATE_FORMAT']),
|
||||
'VISITED' => $user->format_date($data['user_lastvisit'], $user->lang['DATE_FORMAT']),
|
||||
'VISITED' => $user->format_date($last_visit, $user->lang['DATE_FORMAT']),
|
||||
'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0,
|
||||
|
||||
'PM_IMG' => $pm_img,
|
||||
|
|
Loading…
Add table
Reference in a new issue