本文整理汇总了PHP中phpbb_get_banned_user_ids函数的典型用法代码示例。如果您正苦于以下问题:PHP phpbb_get_banned_user_ids函数的具体用法?PHP phpbb_get_banned_user_ids怎么用?PHP phpbb_get_banned_user_ids使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phpbb_get_banned_user_ids函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notify_using_messenger
/**
* Notify using phpBB messenger
*
* @param int $notify_method Notify method for messenger (e.g. NOTIFY_IM)
* @param string $template_dir_prefix Base directory to prepend to the email template name
*
* @return null
*/
protected function notify_using_messenger($notify_method, $template_dir_prefix = '')
{
if (empty($this->queue)) {
return;
}
// Load all users we want to notify (we need their email address)
$user_ids = $users = array();
foreach ($this->queue as $notification) {
$user_ids[] = $notification->user_id;
}
// We do not send emails to banned users
if (!function_exists('phpbb_get_banned_user_ids')) {
include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
}
$banned_users = phpbb_get_banned_user_ids($user_ids);
// Load all the users we need
$this->user_loader->load_users($user_ids);
// Load the messenger
if (!class_exists('messenger')) {
include $this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext;
}
$messenger = new \messenger();
// Time to go through the queue and send emails
/** @var \phpbb\notification\type\type_interface $notification */
foreach ($this->queue as $notification) {
if ($notification->get_email_template() === false) {
continue;
}
$user = $this->user_loader->get_user($notification->user_id);
if ($user['user_type'] == USER_IGNORE || $user['user_type'] == USER_INACTIVE && $user['user_inactive_reason'] == INACTIVE_MANUAL || in_array($notification->user_id, $banned_users)) {
continue;
}
$messenger->template($notification->get_email_template(), $user['user_lang'], '', $template_dir_prefix);
$messenger->set_addresses($user);
$messenger->assign_vars(array_merge(array('USERNAME' => $user['username'], 'U_NOTIFICATION_SETTINGS' => generate_board_url() . '/ucp.' . $this->php_ext . '?i=ucp_notifications&mode=notification_options'), $notification->get_email_template_variables()));
$messenger->send($notify_method);
}
// Save the queue in the messenger class (has to be called or these emails could be lost?)
$messenger->save_queue();
// We're done, empty the queue
$this->empty_queue();
}
示例2: notify
public function notify()
{
$template_dir_prefix = '';
if (!$this->global_available()) {
return;
}
if (empty($this->queue)) {
return;
}
// Load all users we want to notify (we need their email address)
$user_ids = $users = array();
foreach ($this->queue as $notification) {
$user_ids[] = $notification->user_id;
}
// We do not send whatsapp to banned users
if (!function_exists('phpbb_get_banned_user_ids')) {
include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
}
$banned_users = phpbb_get_banned_user_ids($user_ids);
// Load all the users we need
$this->user_loader->load_users($user_ids);
global $config, $phpbb_container;
$wa = $phpbb_container->get('tas2580.mobilenotifier.src.helper');
// Time to go through the queue and send emails
foreach ($this->queue as $notification) {
if ($notification->get_email_template() === false) {
continue;
}
$user = $this->user_loader->get_user($notification->user_id);
if ($user['user_type'] == USER_IGNORE || in_array($notification->user_id, $banned_users)) {
continue;
}
$this->template($template_dir_prefix . $notification->get_email_template(), $user['user_lang']);
$this->assign_vars(array_merge(array('USERNAME' => $user['username'], 'SITENAME' => htmlspecialchars_decode($config['sitename']), 'U_NOTIFICATION_SETTINGS' => generate_board_url() . '/ucp.' . $this->php_ext . '?i=ucp_notifications'), $notification->get_email_template_variables()));
$this->msg = trim($this->template->assign_display('body'));
// Lets send the Whatsapp
$wa->send($user['user_whatsapp'], $this->msg);
}
$this->empty_queue();
}
示例3: empty
} else {
if ($has_unapproved_attachments && !$topic_data['topic_attachment']) {
// Topic has only unapproved attachments but we have the right to see and download them
$topic_data['topic_attachment'] = 1;
}
}
}
} else {
$display_notice = true;
}
}
// Get the list of users who can receive private messages
$can_receive_pm_list = $auth->acl_get_list(array_keys($user_cache), 'u_readpm');
$can_receive_pm_list = empty($can_receive_pm_list) || !isset($can_receive_pm_list[0]['u_readpm']) ? array() : $can_receive_pm_list[0]['u_readpm'];
// Get the list of permanently banned users
$permanently_banned_users = phpbb_get_banned_user_ids(array_keys($user_cache), false);
$i_total = sizeof($rowset) - 1;
$prev_post_id = '';
$template->assign_vars(array('S_HAS_ATTACHMENTS' => $topic_data['topic_attachment'], 'S_NUM_POSTS' => sizeof($post_list)));
/**
* Event to modify the post, poster and attachment data before assigning the posts
*
* @event core.viewtopic_modify_post_data
* @var int forum_id Forum ID
* @var int topic_id Topic ID
* @var array topic_data Array with topic data
* @var array post_list Array with post_ids we are going to display
* @var array rowset Array with post_id => post data
* @var array user_cache Array with prepared user data
* @var int start Pagination information
* @var int sort_days Display posts of previous x days
示例4: handle_message_list_actions
//.........这里部分代码省略.........
if ($username_list) {
$usernames = array_merge($usernames, explode("\n", $username_list));
}
// If add to or add bcc not pressed, users could still have usernames listed they want to add...
if (!$add_to && !$add_bcc && (sizeof($group_list) || sizeof($usernames))) {
$add_to = true;
global $refresh, $submit, $preview;
$refresh = true;
$submit = false;
// Preview is only true if there was also a message entered
if (request_var('message', '')) {
$preview = true;
}
}
// Add User/Group [TO]
if ($add_to || $add_bcc) {
$type = $add_to ? 'to' : 'bcc';
if (sizeof($group_list)) {
foreach ($group_list as $group_id) {
$address_list['g'][$group_id] = $type;
}
}
// User ID's to add...
$user_id_ary = array();
// Reveal the correct user_ids
if (sizeof($usernames)) {
$user_id_ary = array();
user_get_id_name($user_id_ary, $usernames, array(USER_NORMAL, USER_FOUNDER, USER_INACTIVE));
// If there are users not existing, we will at least print a notice...
if (!sizeof($user_id_ary)) {
$error[] = $user->lang['PM_NO_USERS'];
}
}
// Add Friends if specified
$friend_list = array_keys($request->variable('add_' . $type, array(0)));
$user_id_ary = array_merge($user_id_ary, $friend_list);
foreach ($user_id_ary as $user_id) {
if ($user_id == ANONYMOUS) {
continue;
}
$address_list['u'][$user_id] = $type;
}
}
// Check for disallowed recipients
if (!empty($address_list['u'])) {
$can_ignore_allow_pm = $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_');
// Administrator deactivated users check and we need to check their
// PM status (do they want to receive PM's?)
// Only check PM status if not a moderator or admin, since they
// are allowed to override this user setting
$sql = 'SELECT user_id, user_allow_pm
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', array_keys($address_list['u'])) . '
AND (
(user_type = ' . USER_INACTIVE . '
AND user_inactive_reason = ' . INACTIVE_MANUAL . ')
' . ($can_ignore_allow_pm ? '' : ' OR user_allow_pm = 0') . '
)';
$result = $db->sql_query($sql);
$removed_no_pm = $removed_no_permission = false;
while ($row = $db->sql_fetchrow($result)) {
if (!$can_ignore_allow_pm && !$row['user_allow_pm']) {
$removed_no_pm = true;
} else {
$removed_no_permission = true;
}
unset($address_list['u'][$row['user_id']]);
}
$db->sql_freeresult($result);
// print a notice about users not being added who do not want to receive pms
if ($removed_no_pm) {
$error[] = $user->lang['PM_USERS_REMOVED_NO_PM'];
}
// print a notice about users not being added who do not have permission to receive PMs
if ($removed_no_permission) {
$error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION'];
}
if (!sizeof(array_keys($address_list['u']))) {
return;
}
// Check if users have permission to read PMs
$can_read = $auth->acl_get_list(array_keys($address_list['u']), 'u_readpm');
$can_read = empty($can_read) || !isset($can_read[0]['u_readpm']) ? array() : $can_read[0]['u_readpm'];
$cannot_read_list = array_diff(array_keys($address_list['u']), $can_read);
if (!empty($cannot_read_list)) {
foreach ($cannot_read_list as $cannot_read) {
unset($address_list['u'][$cannot_read]);
}
$error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION'];
}
// Check if users are banned
$banned_user_list = phpbb_get_banned_user_ids(array_keys($address_list['u']), false);
if (!empty($banned_user_list)) {
foreach ($banned_user_list as $banned_user) {
unset($address_list['u'][$banned_user]);
}
$error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION'];
}
}
}
示例5: pm_notification
/**
* PM Notification
*/
function pm_notification($mode, $author, $recipients, $subject, $message, $msg_id)
{
global $db, $user, $config, $phpbb_root_path, $phpEx, $auth;
$subject = censor_text($subject);
// Exclude guests, current user and banned users from notifications
unset($recipients[ANONYMOUS], $recipients[$user->data['user_id']]);
if (!sizeof($recipients)) {
return;
}
if (!function_exists('phpbb_get_banned_user_ids')) {
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
}
$banned_users = phpbb_get_banned_user_ids(array_keys($recipients));
$recipients = array_diff(array_keys($recipients), $banned_users);
if (!sizeof($recipients)) {
return;
}
$sql = 'SELECT user_id, username, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $recipients);
$result = $db->sql_query($sql);
$msg_list_ary = array();
while ($row = $db->sql_fetchrow($result)) {
if ($row['user_notify_pm'] == 1 && trim($row['user_email'])) {
$msg_list_ary[] = array('method' => $row['user_notify_type'], 'email' => $row['user_email'], 'jabber' => $row['user_jabber'], 'name' => $row['username'], 'lang' => $row['user_lang']);
}
}
$db->sql_freeresult($result);
if (!sizeof($msg_list_ary)) {
return;
}
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger();
foreach ($msg_list_ary as $pos => $addr) {
$messenger->template('privmsg_notify', $addr['lang']);
$messenger->to($addr['email'], $addr['name']);
$messenger->im($addr['jabber'], $addr['name']);
$messenger->assign_vars(array('SUBJECT' => htmlspecialchars_decode($subject), 'AUTHOR_NAME' => htmlspecialchars_decode($author), 'USERNAME' => htmlspecialchars_decode($addr['name']), 'U_INBOX' => generate_board_url() . "/ucp.{$phpEx}?i=pm&folder=inbox", 'U_VIEW_MESSAGE' => generate_board_url() . "/ucp.{$phpEx}?i=pm&mode=view&p={$msg_id}"));
$messenger->send($addr['method']);
}
unset($msg_list_ary);
$messenger->save_queue();
unset($messenger);
}
示例6: user_notification
/**
* User Notification
*/
function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id, $author_name = '')
{
global $db, $user, $config, $phpbb_root_path, $phpEx, $auth;
$topic_notification = $mode == 'reply' || $mode == 'quote' ? true : false;
$forum_notification = $mode == 'post' ? true : false;
if (!$topic_notification && !$forum_notification) {
trigger_error('NO_MODE');
}
if ($topic_notification && !$config['allow_topic_notify'] || $forum_notification && !$config['allow_forum_notify']) {
return;
}
$topic_title = $topic_notification ? $topic_title : $subject;
$topic_title = censor_text($topic_title);
// Exclude guests, current user and banned users from notifications
if (!function_exists('phpbb_get_banned_user_ids')) {
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
}
$sql_ignore_users = phpbb_get_banned_user_ids();
$sql_ignore_users[ANONYMOUS] = ANONYMOUS;
$sql_ignore_users[$user->data['user_id']] = $user->data['user_id'];
$notify_rows = array();
// -- get forum_userids || topic_userids
$sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber
FROM ' . ($topic_notification ? TOPICS_WATCH_TABLE : FORUMS_WATCH_TABLE) . ' w, ' . USERS_TABLE . ' u
WHERE w.' . ($topic_notification ? 'topic_id' : 'forum_id') . ' = ' . ($topic_notification ? $topic_id : $forum_id) . '
AND ' . $db->sql_in_set('w.user_id', $sql_ignore_users, true) . '
AND w.notify_status = ' . NOTIFY_YES . '
AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
AND u.user_id = w.user_id';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$notify_user_id = (int) $row['user_id'];
$notify_rows[$notify_user_id] = array('user_id' => $notify_user_id, 'username' => $row['username'], 'user_email' => $row['user_email'], 'user_jabber' => $row['user_jabber'], 'user_lang' => $row['user_lang'], 'notify_type' => $topic_notification ? 'topic' : 'forum', 'template' => $topic_notification ? 'topic_notify' : 'newtopic_notify', 'method' => $row['user_notify_type'], 'allowed' => false);
// Add users who have been already notified to ignore list
$sql_ignore_users[$notify_user_id] = $notify_user_id;
}
$db->sql_freeresult($result);
// forum notification is sent to those not already receiving topic notifications
if ($topic_notification) {
$sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber
FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " u\n\t\t\tWHERE fw.forum_id = {$forum_id}\n\t\t\t\tAND " . $db->sql_in_set('fw.user_id', $sql_ignore_users, true) . '
AND fw.notify_status = ' . NOTIFY_YES . '
AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
AND u.user_id = fw.user_id';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$notify_user_id = (int) $row['user_id'];
$notify_rows[$notify_user_id] = array('user_id' => $notify_user_id, 'username' => $row['username'], 'user_email' => $row['user_email'], 'user_jabber' => $row['user_jabber'], 'user_lang' => $row['user_lang'], 'notify_type' => 'forum', 'template' => 'forum_notify', 'method' => $row['user_notify_type'], 'allowed' => false);
}
$db->sql_freeresult($result);
}
if (!sizeof($notify_rows)) {
return;
}
// Make sure users are allowed to read the forum
foreach ($auth->acl_get_list(array_keys($notify_rows), 'f_read', $forum_id) as $forum_id => $forum_ary) {
foreach ($forum_ary as $auth_option => $user_ary) {
foreach ($user_ary as $user_id) {
$notify_rows[$user_id]['allowed'] = true;
}
}
}
// Now, we have to do a little step before really sending, we need to distinguish our users a little bit. ;)
$msg_users = $delete_ids = $update_notification = array();
foreach ($notify_rows as $user_id => $row) {
if (!$row['allowed'] || !trim($row['user_email'])) {
$delete_ids[$row['notify_type']][] = $row['user_id'];
} else {
$msg_users[] = $row;
$update_notification[$row['notify_type']][] = $row['user_id'];
/*
* We also update the forums watch table for this user when we are
* sending out a topic notification to prevent sending out another
* notification in case this user is also subscribed to the forum
* this topic was posted in.
* Since an UPDATE query is used, this has no effect on users only
* subscribed to the topic (i.e. no row is created) and should not
* be a performance issue.
*/
if ($row['notify_type'] === 'topic') {
$update_notification['forum'][] = $row['user_id'];
}
}
}
unset($notify_rows);
// Now, we are able to really send out notifications
if (sizeof($msg_users)) {
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger();
$msg_list_ary = array();
foreach ($msg_users as $row) {
$pos = !isset($msg_list_ary[$row['template']]) ? 0 : sizeof($msg_list_ary[$row['template']]);
$msg_list_ary[$row['template']][$pos]['method'] = $row['method'];
$msg_list_ary[$row['template']][$pos]['email'] = $row['user_email'];
$msg_list_ary[$row['template']][$pos]['jabber'] = $row['user_jabber'];
$msg_list_ary[$row['template']][$pos]['name'] = $row['username'];
$msg_list_ary[$row['template']][$pos]['lang'] = $row['user_lang'];
//.........这里部分代码省略.........
示例7: phpbb_show_profile
/**
* Prepare profile data
*/
function phpbb_show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false, $check_can_receive_pm = true)
{
global $config, $auth, $user, $phpEx, $phpbb_root_path, $phpbb_dispatcher;
$username = $data['username'];
$user_id = $data['user_id'];
$user_rank_data = phpbb_get_user_rank($data, $user_id == ANONYMOUS ? false : $data['user_posts']);
if (!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail') || $auth->acl_get('a_user')) {
$email = $config['board_email_form'] && $config['email_enable'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=email&u=' . $user_id) : ($config['board_hide_emails'] && !$auth->acl_get('a_user') ? '' : 'mailto:' . $data['user_email']);
} else {
$email = '';
}
if ($config['load_onlinetrack']) {
$update_time = $config['load_online_time'] * 60;
$online = time() - $update_time < $data['session_time'] && (isset($data['session_viewonline']) && $data['session_viewonline'] || $auth->acl_get('u_viewonline')) ? true : false;
} else {
$online = false;
}
if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline')) {
$last_active = !empty($data['session_time']) ? $data['session_time'] : $data['user_lastvisit'];
} else {
$last_active = '';
}
$age = '';
if ($config['allow_birthdays'] && $data['user_birthday']) {
list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday']));
if ($bday_year) {
$now = $user->create_datetime();
$now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset());
$diff = $now['mon'] - $bday_month;
if ($diff == 0) {
$diff = $now['mday'] - $bday_day < 0 ? 1 : 0;
} else {
$diff = $diff < 0 ? 1 : 0;
}
$age = max(0, (int) ($now['year'] - $bday_year - $diff));
}
}
if (!function_exists('phpbb_get_banned_user_ids')) {
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
}
// Can this user receive a Private Message?
$can_receive_pm = $check_can_receive_pm && ($data['user_type'] != USER_IGNORE && ($data['user_type'] != USER_INACTIVE || $data['user_inactive_reason'] != INACTIVE_MANUAL) && sizeof($auth->acl_get_list($user_id, 'u_readpm')) && !sizeof(phpbb_get_banned_user_ids($user_id, false)) && ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_') || $data['user_allow_pm']));
// Dump it out to the template
$template_data = array('AGE' => $age, 'RANK_TITLE' => $user_rank_data['title'], 'JOINED' => $user->format_date($data['user_regdate']), 'LAST_ACTIVE' => empty($last_active) ? ' - ' : $user->format_date($last_active), 'POSTS' => $data['user_posts'] ? $data['user_posts'] : 0, 'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0, 'USERNAME_FULL' => get_username_string('full', $user_id, $username, $data['user_colour']), 'USERNAME' => get_username_string('username', $user_id, $username, $data['user_colour']), 'USER_COLOR' => get_username_string('colour', $user_id, $username, $data['user_colour']), 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $data['user_colour']), 'A_USERNAME' => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])), 'AVATAR_IMG' => phpbb_get_user_avatar($data), 'ONLINE_IMG' => !$config['load_onlinetrack'] ? '' : ($online ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), 'S_ONLINE' => $config['load_onlinetrack'] && $online ? true : false, 'RANK_IMG' => $user_rank_data['img'], 'RANK_IMG_SRC' => $user_rank_data['img_src'], 'S_JABBER_ENABLED' => $config['jab_enable'] ? true : false, 'S_WARNINGS' => $auth->acl_getf_global('m_') || $auth->acl_get('m_warn') ? true : false, 'U_SEARCH_USER' => $auth->acl_get('u_search') ? append_sid("{$phpbb_root_path}search.{$phpEx}", "author_id={$user_id}&sr=posts") : '', 'U_NOTES' => $user_notes_enabled && $auth->acl_getf_global('m_') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '', 'U_WARN' => $warn_user_enabled && $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '', 'U_PM' => $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&mode=compose&u=' . $user_id) : '', 'U_EMAIL' => $email, 'U_JABBER' => $data['user_jabber'] && $auth->acl_get('u_sendim') ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=contact&action=jabber&u=' . $user_id) : '', 'USER_JABBER' => $config['jab_enable'] ? $data['user_jabber'] : '', 'USER_JABBER_IMG' => $config['jab_enable'] && $data['user_jabber'] ? $user->img('icon_contact_jabber', $data['user_jabber']) : '', 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $username), 'L_CONTACT_USER' => $user->lang('CONTACT_USER', $username), 'L_VIEWING_PROFILE' => $user->lang('VIEWING_PROFILE', $username));
/**
* Preparing a user's data before displaying it in profile and memberlist
*
* @event core.memberlist_prepare_profile_data
* @var array data Array with user's data
* @var array template_data Template array with user's data
* @since 3.1.0-a1
*/
$vars = array('data', 'template_data');
extract($phpbb_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars)));
return $template_data;
}
示例8: do_ban_hammer_stuff
public function do_ban_hammer_stuff($event)
{
$this->data = $event['member'];
$this->user_id = (int) $this->data['user_id'];
$curl_exists = function_exists('curl_init') ? true : false;
$admin_mod_array = $this->admin_mod_array();
/**
* Split these up and give error messages? Later maybe.
*/
if (!$this->auth->acl_get('m_ban') || $this->data['user_type'] == USER_FOUNDER && $this->user->data['user_type'] != USER_FOUNDER || $this->user_id == $this->user->data['user_id'] || in_array($this->data['user_id'], $admin_mod_array)) {
// Nothing to see here, move on.
// Only let founders be banned by other founders.
// And don't allow them to ban them selves
return;
}
$this->user->add_lang_ext('phpbbmodders/banhammer', 'banhammer_lang');
// Check if this user already is banned.
if (!function_exists('phpbb_get_banned_user_ids')) {
include $this->root_path . 'includes/functions_user.' . $this->php_ext;
}
$banned = phpbb_get_banned_user_ids(array($this->user_id));
if (!empty($banned)) {
$bh_result = $this->request->variable('bh_res', '');
if (!empty($bh_result)) {
if ($bh_result == 'success') {
$bh_message = $this->user->lang['BANNED_SUCCESS'];
} else {
// One or more actions failed.
$message_ary = explode('+', urldecode($bh_result));
$bh_message = $this->user->lang['BANNED_ERROR'];
foreach ($message_ary as $error) {
$bh_message .= '<br />' . $this->user->lang[$error];
}
}
$this->template->assign_vars(array('BH_STYLE' => ($bh_result == 'success' ? 'green' : '#a92c2c') . '; color: white;"', 'BH_MESSAGE' => $bh_message));
} else {
// It's enough to ban them once.
$this->template->assign_var('BH_MESSAGE', $this->user->lang['BH_BANNED']);
}
return;
}
// Get Ban Hammer settings
$sql = 'SELECT * FROM ' . CONFIG_TEXT_TABLE . "\n\t\t\t\tWHERE config_name = 'banhammer_settings'";
$result = $this->db->sql_query($sql);
$settings = $this->db->sql_fetchfield('config_value');
$this->db->sql_freeresult($result);
$settings = unserialize($settings);
if ($settings['group_id']) {
// Get group name for banned users, if any.
$sql = 'SELECT group_id, group_name FROM ' . GROUPS_TABLE . '
WHERE group_id = ' . (int) $settings['group_id'];
$result = $this->db->sql_query($sql);
$group_name = $this->db->sql_fetchfield('group_name');
$this->db->sql_freeresult($result);
if (empty($group_name)) {
$settings['group_id'] = 0;
}
}
if (!$this->request->is_set('bh') || $this->request->is_set('bh') && $this->request->is_set('confirm_key') && !confirm_box(true)) {
$params = array('mode' => 'viewprofile', 'u' => $this->user_id, 'bh' => 1);
$this->template->assign_vars(array('BH_BAN_EMAIL' => $settings['ban_email'], 'BH_BAN_IP' => $settings['ban_ip'], 'BH_DEL_AVATAR' => $settings['del_avatar'], 'BH_DEL_PRIVMSGS' => $settings['del_privmsgs'], 'BH_DEL_POSTS' => $settings['del_posts'], 'BH_DEL_PROFILE' => $settings['del_profile'], 'BH_DEL_SIGNATURE' => $settings['del_signature'], 'L_BH_MOVE_GROUP' => !empty($group_name) ? sprintf($this->user->lang['BH_MOVE_GROUP'], $group_name) : '', 'S_BH_SFS' => !empty($settings['sfs_api_key']) && $curl_exists ? true : false, 'S_SHOW_BH' => true, 'U_HAMMERBAN' => append_sid($this->root_path . 'memberlist.' . $this->php_ext, $params)));
return;
}
// Time to ban a user. But are you sure?
if (!confirm_box(true)) {
$hidden_fields = array('ban_email' => $this->request->variable('ban_email', 0), 'ban_ip' => $this->request->variable('ban_ip', 0), 'bh_reason' => $this->request->variable('bh_reason', '', true), 'bh_reason_user' => $this->request->variable('bh_reason_user', '', true), 'del_avatar' => $this->request->variable('del_avatar', 0), 'del_privmsgs' => $this->request->variable('del_privmsgs', 0), 'del_posts' => $this->request->variable('del_posts', 0), 'del_profile' => $this->request->variable('del_profile', 0), 'del_signature' => $this->request->variable('del_signature', 0), 'mode' => 'viewprofile', 'move_group' => $this->request->variable('move_group', 0), 'sfs_report' => $this->request->variable('sfs_report', 0));
$message = sprintf($this->user->lang['SURE_BAN'], $this->data['username']) . '<br /><br />';
$message .= $this->user->lang['THIS_WILL'] . '' . $this->user->lang['COLON'] . '<br />' . $this->user->lang['BH_BAN_USER'] . '<br />';
$message .= $hidden_fields['ban_email'] ? $this->user->lang['BH_BAN_EMAIL'] . '<br />' : '';
$message .= $hidden_fields['ban_ip'] ? $this->user->lang['BH_BAN_IP'] . '<br />' : '';
$message .= $hidden_fields['bh_reason'] ? sprintf($this->user->lang['BH_REASON'], $hidden_fields['bh_reason']) . '<br />' : '';
$message .= $hidden_fields['bh_reason_user'] ? sprintf($this->user->lang['BH_REASON_USER'], $hidden_fields['bh_reason_user']) . '<br />' : '';
$message .= $hidden_fields['del_avatar'] ? $this->user->lang['BH_DEL_AVATAR'] . '<br />' : '';
$message .= $hidden_fields['del_privmsgs'] ? $this->user->lang['BH_DEL_PRIVMSGS'] . '<br />' : '';
$message .= $hidden_fields['del_posts'] ? $this->user->lang['BH_DEL_POSTS'] . '<br />' : '';
$message .= $hidden_fields['del_profile'] ? $this->user->lang['BH_DEL_PROFILE'] . '<br />' : '';
$message .= $hidden_fields['del_signature'] ? $this->user->lang['BH_DEL_SIGNATURE'] . '<br />' : '';
$message .= !empty($group_name) && $hidden_fields['move_group'] ? sprintf($this->user->lang['BH_MOVE_GROUP'], $group_name) . '<br />' : '';
$message .= $hidden_fields['sfs_report'] && $curl_exists ? $this->user->lang['BH_SUBMIT_SFS'] . '<br />' : '';
confirm_box(false, $message, build_hidden_fields($hidden_fields));
}
// We have a user to ban.
$error = array();
// Any reason for this ban?
$bh_reason = $this->request->variable('bh_reason', '', true);
$bh_reason_user = $this->request->variable('bh_reason_user', '', true);
// The username is the user so it's always banned.
$success = user_ban('user', $this->data['username'], 0, '', false, $bh_reason, $bh_reason_user);
if (!$success) {
$error[] = 'ERROR_BAN_USER';
}
if ($this->request->variable('ban_email', 0)) {
$success = user_ban('email', $this->data['user_email'], 0, '', false, $bh_reason, $bh_reason_user);
if (!$success) {
$error[] = 'ERROR_BAN_EMAIL';
}
}
if ($this->request->variable('ban_ip', 0) && !empty($this->data['user_ip'])) {
$success = user_ban('ip', $this->data['user_ip'], 0, '', false, $bh_reason, $bh_reason_user);
if (!$success) {
//.........这里部分代码省略.........
示例9: add_sender
private function add_sender($action)
{
include_once $this->phpbb_root_path . 'includes/ucp/ucp_pm_compose.' . $this->php_ext;
include_once $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
$this->user->add_lang(array('viewtopic'));
$this->user->add_lang(array('ucp'));
if (!$this->auth->acl_get('u_sendpm')) {
$this->error[] = array('error' => $this->user->lang['NO_AUTH_SEND_MESSAGE']);
return;
}
add_form_key('ucp_pm_compose');
// Grab only parameters needed here
$this->address_list = $this->request->variable('address_list', array('' => array(0 => '')));
//already exist recipients don't need to check permission
$this->user_list = array();
$usernames = array();
$username_list = $this->request->variable('username_list', '', true);
$message = '';
#region AddUsers
if ($username_list) {
$usernames = array_unique(explode("\n", $username_list));
if (sizeof($usernames)) {
$user_id_ary = array();
user_get_id_name($user_id_ary, $usernames, array(USER_NORMAL, USER_FOUNDER, USER_INACTIVE));
$this->user_list = $this->get_user_list($usernames);
if (sizeof($this->user_list) < sizeof($usernames)) {
//find non-existing users
foreach ($usernames as $username) {
if (!$this->is_user_exists($username, $this->user_list)) {
$message .= sprintf($this->user->lang['NO_SUCH_USER'] . '<br />', $username);
}
}
}
if (sizeof($this->user_list)) {
// Now, make sure that new users not exist in address_list ;)
foreach ($this->user_list as $key => $user) {
if (isset($this->address_list['u'][$user['user_id']])) {
//user already recipient (don't need add and check it)
$message .= sprintf($this->user->lang['PMAJAX_USER_ALREADY_RECIPIENT'] . '<br />', $user['username']);
$user_id_ary = array_diff($user_id_ary, array($user['user_id']));
//remove ids of duplicate recipients
unset($this->user_list[$key]);
}
}
if (sizeof($user_id_ary)) {
// Check for disallowed recipients
$can_ignore_allow_pm = $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_');
// Administrator deactivated users check and we need to check their
// PM status (do they want to receive PM's?)
// Only check PM status if not a moderator or admin, since they
// are allowed to override this user setting
$sql = 'SELECT user_id, username, user_allow_pm
FROM ' . USERS_TABLE . '
WHERE ' . $this->db->sql_in_set('user_id', $user_id_ary) . '
AND (
(user_type = ' . USER_INACTIVE . '
AND user_inactive_reason = ' . INACTIVE_MANUAL . ')
' . ($can_ignore_allow_pm ? '' : ' OR user_allow_pm = 0') . '
)';
$result = $this->db->sql_query($sql);
$removed_no_pm = $removed_no_permission = false;
while ($row = $this->db->sql_fetchrow($result)) {
if (!$can_ignore_allow_pm && !$row['user_allow_pm']) {
$username = $this->remove_user_from_user_list($row['user_id']);
$message .= sprintf($this->user->lang['PMAJAX_USER_REMOVED_NO_PM'] . '<br />', $username);
} else {
$username = $this->remove_user_from_user_list($row['user_id']);
$message .= sprintf($this->user->lang['PMAJAX_USER_REMOVED_NO_PERMISSION'] . '<br />', $username);
}
$user_id_ary = array_diff($user_id_ary, array($row['user_id']));
//remove id for this user
}
$this->db->sql_freeresult($result);
}
//sizeof($user_id_ary))
if (sizeof($user_id_ary)) {
// Check if users have permission to read PMs
$can_read = $this->auth->acl_get_list($user_id_ary, 'u_readpm');
$can_read = empty($can_read) || !isset($can_read[0]['u_readpm']) ? array() : $can_read[0]['u_readpm'];
$cannot_read_list = array_diff($user_id_ary, $can_read);
if (!empty($cannot_read_list)) {
foreach ($cannot_read_list as $cannot_read) {
$username = $this->remove_user_from_user_list($cannot_read);
$user_id_ary = array_diff($user_id_ary, $cannot_read);
//remove id for this user
$message .= sprintf($this->user->lang['PMAJAX_USER_REMOVED_NO_PERMISSION'] . '<br />', $username);
}
}
}
if (sizeof($user_id_ary)) {
// Check if users are banned
$banned_user_list = phpbb_get_banned_user_ids($user_id_ary, false);
if (!empty($banned_user_list)) {
foreach ($banned_user_list as $banned_user) {
$username = $this->remove_user_from_user_list($banned_user);
$user_id_ary = array_diff($user_id_ary, $cannot_read);
//remove id for this user
$message .= sprintf($this->user->lang['PMAJAX_USER_REMOVED_NO_PERMISSION'] . '<br />', $username);
}
}
//.........这里部分代码省略.........