当前位置: 首页>>代码示例>>PHP>>正文


PHP messenger::anti_abuse_headers方法代码示例

本文整理汇总了PHP中messenger::anti_abuse_headers方法的典型用法代码示例。如果您正苦于以下问题:PHP messenger::anti_abuse_headers方法的具体用法?PHP messenger::anti_abuse_headers怎么用?PHP messenger::anti_abuse_headers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在messenger的用法示例。


在下文中一共展示了messenger::anti_abuse_headers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: main

    function main($id, $mode)
    {
        global $config, $phpbb_root_path, $phpEx;
        global $db, $user, $auth, $template, $phpbb_container;
        if (!$config['allow_password_reset']) {
            trigger_error($user->lang('UCP_PASSWORD_RESET_DISABLED', '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'));
        }
        $username = request_var('username', '', true);
        $email = strtolower(request_var('email', ''));
        $submit = isset($_POST['submit']) ? true : false;
        if ($submit) {
            $sql = 'SELECT user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason
				FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "'\n\t\t\t\t\tAND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
            $result = $db->sql_query($sql);
            $user_row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if (!$user_row) {
                trigger_error('NO_EMAIL_USER');
            }
            if ($user_row['user_type'] == USER_IGNORE) {
                trigger_error('NO_USER');
            }
            if ($user_row['user_type'] == USER_INACTIVE) {
                if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL) {
                    trigger_error('ACCOUNT_DEACTIVATED');
                } else {
                    trigger_error('ACCOUNT_NOT_ACTIVATED');
                }
            }
            // Check users permissions
            $auth2 = new \phpbb\auth\auth();
            $auth2->acl($user_row);
            if (!$auth2->acl_get('u_chgpasswd')) {
                trigger_error('NO_AUTH_PASSWORD_REMINDER');
            }
            $server_url = generate_board_url();
            // Make password at least 8 characters long, make it longer if admin wants to.
            // gen_rand_string() however has a limit of 12 or 13.
            $user_password = gen_rand_string_friendly(max(8, mt_rand((int) $config['min_pass_chars'], (int) $config['max_pass_chars'])));
            // For the activation key a random length between 6 and 10 will do.
            $user_actkey = gen_rand_string(mt_rand(6, 10));
            // Instantiate passwords manager
            $passwords_manager = $phpbb_container->get('passwords.manager');
            $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\tSET user_newpasswd = '" . $db->sql_escape($passwords_manager->hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "'\n\t\t\t\tWHERE user_id = " . $user_row['user_id'];
            $db->sql_query($sql);
            include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
            $messenger = new messenger(false);
            $messenger->template('user_activate_passwd', $user_row['user_lang']);
            $messenger->set_addresses($user_row);
            $messenger->anti_abuse_headers($config, $user);
            $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user_row['username']), 'PASSWORD' => htmlspecialchars_decode($user_password), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_row['user_id']}&k={$user_actkey}"));
            $messenger->send($user_row['user_notify_type']);
            meta_refresh(3, append_sid("{$phpbb_root_path}index.{$phpEx}"));
            $message = $user->lang['PASSWORD_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.{$phpEx}") . '">', '</a>');
            trigger_error($message);
        }
        $template->assign_vars(array('USERNAME' => $username, 'EMAIL' => $email, 'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=sendpassword')));
        $this->tpl_name = 'ucp_remind';
        $this->page_title = 'UCP_REMIND';
    }
开发者ID:Tarendai,项目名称:spring-website,代码行数:60,代码来源:ucp_remind.php

示例2: main

    function main($id, $mode)
    {
        global $cache, $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
        global $request, $phpbb_container, $phpbb_log, $phpbb_dispatcher;
        $user->add_lang('posting');
        $submit = $request->variable('submit', false, false, \phpbb\request\request_interface::POST);
        $delete = $request->variable('delete', false, false, \phpbb\request\request_interface::POST);
        $error = $data = array();
        $s_hidden_fields = '';
        switch ($mode) {
            case 'reg_details':
                $data = array('username' => $request->variable('username', $user->data['username'], true), 'email' => strtolower($request->variable('email', $user->data['user_email'])), 'new_password' => $request->variable('new_password', '', true), 'cur_password' => $request->variable('cur_password', '', true), 'password_confirm' => $request->variable('password_confirm', '', true));
                /**
                 * Modify user registration data on editing account settings in UCP
                 *
                 * @event core.ucp_profile_reg_details_data
                 * @var	array	data		Array with current or updated user registration data
                 * @var	bool	submit		Flag indicating if submit button has been pressed
                 * @since 3.1.4-RC1
                 */
                $vars = array('data', 'submit');
                extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_data', compact($vars)));
                add_form_key('ucp_reg_details');
                if ($submit) {
                    // Do not check cur_password, it is the old one.
                    $check_ary = array('new_password' => array(array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), array('password')), 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), 'email' => array(array('string', false, 6, 60), array('user_email')));
                    if ($auth->acl_get('u_chgname') && $config['allow_namechange']) {
                        $check_ary['username'] = array(array('string', false, $config['min_name_chars'], $config['max_name_chars']), array('username'));
                    }
                    $error = validate_data($data, $check_ary);
                    if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && $data['password_confirm'] != $data['new_password']) {
                        $error[] = $data['password_confirm'] ? 'NEW_PASSWORD_ERROR' : 'NEW_PASSWORD_CONFIRM_EMPTY';
                    }
                    // Instantiate passwords manager
                    /* @var $passwords_manager \phpbb\passwords\manager */
                    $passwords_manager = $phpbb_container->get('passwords.manager');
                    // Only check the new password against the previous password if there have been no errors
                    if (!sizeof($error) && $auth->acl_get('u_chgpasswd') && $data['new_password'] && $passwords_manager->check($data['new_password'], $user->data['user_password'])) {
                        $error[] = 'SAME_PASSWORD_ERROR';
                    }
                    if (!$passwords_manager->check($data['cur_password'], $user->data['user_password'])) {
                        $error[] = $data['cur_password'] ? 'CUR_PASSWORD_ERROR' : 'CUR_PASSWORD_EMPTY';
                    }
                    if (!check_form_key('ucp_reg_details')) {
                        $error[] = 'FORM_INVALID';
                    }
                    /**
                     * Validate user data on editing registration data in UCP
                     *
                     * @event core.ucp_profile_reg_details_validate
                     * @var	array	data			Array with user profile data
                     * @var	bool	submit			Flag indicating if submit button has been pressed
                     * @var array	error			Array of any generated errors
                     * @since 3.1.4-RC1
                     */
                    $vars = array('data', 'submit', 'error');
                    extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_validate', compact($vars)));
                    if (!sizeof($error)) {
                        $sql_ary = array('username' => $auth->acl_get('u_chgname') && $config['allow_namechange'] ? $data['username'] : $user->data['username'], 'username_clean' => $auth->acl_get('u_chgname') && $config['allow_namechange'] ? utf8_clean_string($data['username']) : $user->data['username_clean'], 'user_email' => $auth->acl_get('u_chgemail') ? $data['email'] : $user->data['user_email'], 'user_email_hash' => $auth->acl_get('u_chgemail') ? phpbb_email_hash($data['email']) : $user->data['user_email_hash'], 'user_password' => $auth->acl_get('u_chgpasswd') && $data['new_password'] ? $passwords_manager->hash($data['new_password']) : $user->data['user_password'], 'user_passchg' => $auth->acl_get('u_chgpasswd') && $data['new_password'] ? time() : 0);
                        if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username']) {
                            $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_NAME', false, array('reportee_id' => $user->data['user_id'], $user->data['username'], $data['username']));
                        }
                        if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && !$passwords_manager->check($data['new_password'], $user->data['user_password'])) {
                            $user->reset_login_keys();
                            $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_NEW_PASSWORD', false, array('reportee_id' => $user->data['user_id'], $user->data['username']));
                        }
                        if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email']) {
                            $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_EMAIL', false, array('reportee_id' => $user->data['user_id'], $user->data['username'], $data['user_email'], $data['email']));
                        }
                        $message = 'PROFILE_UPDATED';
                        if ($auth->acl_get('u_chgemail') && $config['email_enable'] && $data['email'] != $user->data['user_email'] && $user->data['user_type'] != USER_FOUNDER && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN)) {
                            $message = $config['require_activation'] == USER_ACTIVATION_SELF ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN';
                            include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                            $server_url = generate_board_url();
                            $user_actkey = gen_rand_string(mt_rand(6, 10));
                            $messenger = new messenger(false);
                            $template_file = $config['require_activation'] == USER_ACTIVATION_ADMIN ? 'user_activate_inactive' : 'user_activate';
                            $messenger->template($template_file, $user->data['user_lang']);
                            $messenger->to($data['email'], $data['username']);
                            $messenger->anti_abuse_headers($config, $user);
                            $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($data['username']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user->data['user_id']}&k={$user_actkey}"));
                            $messenger->send(NOTIFY_EMAIL);
                            if ($config['require_activation'] == USER_ACTIVATION_ADMIN) {
                                // Grab an array of user_id's with a_user permissions ... these users can activate a user
                                $admin_ary = $auth->acl_get_list(false, 'a_user', false);
                                $admin_ary = !empty($admin_ary[0]['a_user']) ? $admin_ary[0]['a_user'] : array();
                                // Also include founders
                                $where_sql = ' WHERE user_type = ' . USER_FOUNDER;
                                if (sizeof($admin_ary)) {
                                    $where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary);
                                }
                                $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
									FROM ' . USERS_TABLE . ' ' . $where_sql;
                                $result = $db->sql_query($sql);
                                while ($row = $db->sql_fetchrow($result)) {
                                    $messenger->template('admin_activate', $row['user_lang']);
                                    $messenger->set_addresses($row);
                                    $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($data['username']), 'U_USER_DETAILS' => "{$server_url}/memberlist.{$phpEx}?mode=viewprofile&u={$user->data['user_id']}", 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user->data['user_id']}&k={$user_actkey}"));
                                    $messenger->send($row['user_notify_type']);
                                }
//.........这里部分代码省略.........
开发者ID:hgchen,项目名称:phpbb,代码行数:101,代码来源:ucp_profile.php

示例3:

 /**
  * User notify function
  */
 function user_notify($email_template, $user_row, $assign_vars_array, $template_path = '', $use_queue = false)
 {
     global $phpbb_root_path, $phpEx, $user, $config;
     include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
     $messenger = new \messenger($use_queue);
     $messenger->template($email_template, $user_row['user_lang'], $template_path);
     $messenger->set_addresses($user_row);
     $messenger->anti_abuse_headers($config, $user);
     $messenger->assign_vars($assign_vars_array);
     $messenger->send($user_row['user_notify_type']);
     return true;
 }
开发者ID:Galixte,项目名称:advanced_warnings,代码行数:15,代码来源:warnings_module.php

示例4: send_activation_email

 /**
  * Send account activation email
  *
  * @param int   $user_id The new user's id
  * @return null
  */
 protected function send_activation_email($user_id)
 {
     switch ($this->config['require_activation']) {
         case USER_ACTIVATION_SELF:
             $email_template = 'user_welcome_inactive';
             $user_actkey = gen_rand_string(mt_rand(6, 10));
             break;
         case USER_ACTIVATION_ADMIN:
             $email_template = 'admin_welcome_inactive';
             $user_actkey = gen_rand_string(mt_rand(6, 10));
             break;
         default:
             $email_template = 'user_welcome';
             $user_actkey = '';
             break;
     }
     if (!class_exists('messenger')) {
         require $this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext;
     }
     $messenger = new \messenger(false);
     $messenger->template($email_template, $this->user->lang_name);
     $messenger->to($this->data['email'], $this->data['username']);
     $messenger->anti_abuse_headers($this->config, $this->user);
     $messenger->assign_vars(array('WELCOME_MSG' => htmlspecialchars_decode($this->language->lang('WELCOME_SUBJECT', $this->config['sitename'])), 'USERNAME' => htmlspecialchars_decode($this->data['username']), 'PASSWORD' => htmlspecialchars_decode($this->data['new_password']), 'U_ACTIVATE' => generate_board_url() . "/ucp.{$this->php_ext}?mode=activate&u={$user_id}&k={$user_actkey}"));
     $messenger->send(NOTIFY_EMAIL);
 }
开发者ID:phpbb,项目名称:phpbb-core,代码行数:32,代码来源:add.php

示例5: main

    function main($id, $mode)
    {
        global $config, $phpbb_root_path, $phpEx;
        global $db, $user, $auth, $template, $phpbb_container, $phpbb_dispatcher;
        $user_id = request_var('u', 0);
        $key = request_var('k', '');
        $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason
			FROM ' . USERS_TABLE . "\n\t\t\tWHERE user_id = {$user_id}";
        $result = $db->sql_query($sql);
        $user_row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if (!$user_row) {
            trigger_error('NO_USER');
        }
        if ($user_row['user_type'] != USER_INACTIVE && !$user_row['user_newpasswd']) {
            meta_refresh(3, append_sid("{$phpbb_root_path}index.{$phpEx}"));
            trigger_error('ALREADY_ACTIVATED');
        }
        if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL || $user_row['user_actkey'] !== $key) {
            trigger_error('WRONG_ACTIVATION');
        }
        // Do not allow activating by non administrators when admin activation is on
        // Only activation type the user should be able to do is INACTIVE_REMIND
        // or activate a new password which is not an activation state :@
        if (!$user_row['user_newpasswd'] && $user_row['user_inactive_reason'] != INACTIVE_REMIND && $config['require_activation'] == USER_ACTIVATION_ADMIN && !$auth->acl_get('a_user')) {
            if (!$user->data['is_registered']) {
                login_box('', $user->lang['NO_AUTH_OPERATION']);
            }
            trigger_error('NO_AUTH_OPERATION');
        }
        $update_password = $user_row['user_newpasswd'] ? true : false;
        if ($update_password) {
            $sql_ary = array('user_actkey' => '', 'user_password' => $user_row['user_newpasswd'], 'user_newpasswd' => '', 'user_login_attempts' => 0);
            $sql = 'UPDATE ' . USERS_TABLE . '
				SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
				WHERE user_id = ' . $user_row['user_id'];
            $db->sql_query($sql);
            add_log('user', $user_row['user_id'], 'LOG_USER_NEW_PASSWORD', $user_row['username']);
        }
        if (!$update_password) {
            include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
            user_active_flip('activate', $user_row['user_id']);
            $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\tSET user_actkey = ''\n\t\t\t\tWHERE user_id = {$user_row['user_id']}";
            $db->sql_query($sql);
            // Create the correct logs
            add_log('user', $user_row['user_id'], 'LOG_USER_ACTIVE_USER');
            if ($auth->acl_get('a_user')) {
                add_log('admin', 'LOG_USER_ACTIVE', $user_row['username']);
            }
        }
        if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !$update_password) {
            $phpbb_notifications = $phpbb_container->get('notification_manager');
            $phpbb_notifications->delete_notifications('notification.type.admin_activate_user', $user_row['user_id']);
            include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
            $messenger = new messenger(false);
            $messenger->template('admin_welcome_activated', $user_row['user_lang']);
            $messenger->set_addresses($user_row);
            $messenger->anti_abuse_headers($config, $user);
            $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user_row['username'])));
            $messenger->send($user_row['user_notify_type']);
            $message = 'ACCOUNT_ACTIVE_ADMIN';
        } else {
            if (!$update_password) {
                $message = $user_row['user_inactive_reason'] == INACTIVE_PROFILE ? 'ACCOUNT_ACTIVE_PROFILE' : 'ACCOUNT_ACTIVE';
            } else {
                $message = 'PASSWORD_ACTIVATED';
            }
        }
        /**
         * This event can be used to modify data after user account's activation
         *
         * @event core.ucp_activate_after
         * @var	array	user_row	Array with some user data
         * @var	string	message		Language string of the message that will be displayed to the user
         * @since 3.1.6-RC1
         */
        $vars = array('user_row', 'message');
        extract($phpbb_dispatcher->trigger_event('core.ucp_activate_after', compact($vars)));
        meta_refresh(3, append_sid("{$phpbb_root_path}index.{$phpEx}"));
        trigger_error($user->lang[$message]);
    }
开发者ID:WarriorMachines,项目名称:warriormachines-phpbb,代码行数:81,代码来源:ucp_activate.php

示例6: main


//.........这里部分代码省略.........
                $user_row = array('username' => $data['username'], 'user_password' => phpbb_hash($data['new_password']), 'user_email' => $data['email'], 'group_id' => (int) $group_id, 'user_timezone' => (double) $data['tz'], 'user_dst' => $is_dst, 'user_lang' => $data['lang'], 'user_type' => $user_type, 'user_actkey' => $user_actkey, 'user_ip' => $user->ip, 'user_regdate' => time(), 'user_inactive_reason' => $user_inactive_reason, 'user_inactive_time' => $user_inactive_time);
                if ($config['new_member_post_limit']) {
                    $user_row['user_new'] = 1;
                }
                // Register user...
                $user_id = user_add($user_row, $cp_data);
                // This should not happen, because the required variables are listed above...
                if ($user_id === false) {
                    trigger_error('NO_USER', E_USER_ERROR);
                }
                // Okay, captcha, your job is done.
                if ($config['enable_confirm'] && isset($captcha)) {
                    $captcha->reset();
                }
                if ($coppa && $config['email_enable']) {
                    $message = $user->lang['ACCOUNT_COPPA'];
                    $email_template = 'coppa_welcome_inactive';
                } else {
                    if ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) {
                        $message = $user->lang['ACCOUNT_INACTIVE'];
                        $email_template = 'user_welcome_inactive';
                    } else {
                        if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable']) {
                            $message = $user->lang['ACCOUNT_INACTIVE_ADMIN'];
                            $email_template = 'admin_welcome_inactive';
                        } else {
                            $message = $user->lang['ACCOUNT_ADDED'];
                            $email_template = 'user_welcome';
                        }
                    }
                }
                if ($config['email_enable']) {
                    include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                    $messenger = new messenger(false);
                    $messenger->template($email_template, $data['lang']);
                    $messenger->to($data['email'], $data['username']);
                    $messenger->anti_abuse_headers($config, $user);
                    $messenger->assign_vars(array('WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), 'USERNAME' => htmlspecialchars_decode($data['username']), 'PASSWORD' => htmlspecialchars_decode($data['new_password']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_id}&k={$user_actkey}"));
                    if ($coppa) {
                        $messenger->assign_vars(array('FAX_INFO' => $config['coppa_fax'], 'MAIL_INFO' => $config['coppa_mail'], 'EMAIL_ADDRESS' => $data['email']));
                    }
                    $messenger->send(NOTIFY_EMAIL);
                    if ($config['require_activation'] == USER_ACTIVATION_ADMIN) {
                        // Grab an array of user_id's with a_user permissions ... these users can activate a user
                        $admin_ary = $auth->acl_get_list(false, 'a_user', false);
                        $admin_ary = !empty($admin_ary[0]['a_user']) ? $admin_ary[0]['a_user'] : array();
                        // Also include founders
                        $where_sql = ' WHERE user_type = ' . USER_FOUNDER;
                        if (sizeof($admin_ary)) {
                            $where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary);
                        }
                        $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
							FROM ' . USERS_TABLE . ' ' . $where_sql;
                        $result = $db->sql_query($sql);
                        while ($row = $db->sql_fetchrow($result)) {
                            $messenger->template('admin_activate', $row['user_lang']);
                            $messenger->to($row['user_email'], $row['username']);
                            $messenger->im($row['user_jabber'], $row['username']);
                            $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($data['username']), 'U_USER_DETAILS' => "{$server_url}/memberlist.{$phpEx}?mode=viewprofile&u={$user_id}", 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_id}&k={$user_actkey}"));
                            $messenger->send($row['user_notify_type']);
                        }
                        $db->sql_freeresult($result);
                    }
                }
                $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.{$phpEx}") . '">', '</a>');
                trigger_error($message);
            }
        }
        $s_hidden_fields = array('agreed' => 'true', 'change_lang' => 0);
        if ($config['coppa_enable']) {
            $s_hidden_fields['coppa'] = $coppa;
        }
        if ($config['enable_confirm']) {
            $s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields());
        }
        $s_hidden_fields = build_hidden_fields($s_hidden_fields);
        $confirm_image = '';
        // Visual Confirmation - Show images
        if ($config['enable_confirm']) {
            $template->assign_vars(array('CAPTCHA_TEMPLATE' => $captcha->get_template()));
        }
        //
        $l_reg_cond = '';
        switch ($config['require_activation']) {
            case USER_ACTIVATION_SELF:
                $l_reg_cond = $user->lang['UCP_EMAIL_ACTIVATE'];
                break;
            case USER_ACTIVATION_ADMIN:
                $l_reg_cond = $user->lang['UCP_ADMIN_ACTIVATE'];
                break;
        }
        $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'USERNAME' => $data['username'], 'PASSWORD' => $data['new_password'], 'PASSWORD_CONFIRM' => $data['password_confirm'], 'EMAIL' => $data['email'], 'EMAIL_CONFIRM' => $data['email_confirm'], 'L_REG_COND' => $l_reg_cond, 'L_USERNAME_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), 'L_PASSWORD_EXPLAIN' => sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']), 'S_LANG_OPTIONS' => language_select($data['lang']), 'S_TZ_OPTIONS' => tz_select($data['tz']), 'S_CONFIRM_REFRESH' => $config['enable_confirm'] && $config['confirm_refresh'] ? true : false, 'S_REGISTRATION' => true, 'S_COPPA' => $coppa, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register')));
        //
        $user->profile_fields = array();
        // Generate profile fields -> Template Block Variable profile_fields
        $cp->generate_profile_fields('register', $user->get_iso_lang_id());
        //
        $this->tpl_name = 'ucp_register';
        $this->page_title = 'UCP_REGISTRATION';
    }
开发者ID:tuxmania87,项目名称:GalaxyAdventures,代码行数:101,代码来源:ucp_register.php

示例7: user_justification_activate

 /**
  * Activate user
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 private function user_justification_activate()
 {
     $user = $this->data;
     if (!function_exists('user_active_flip')) {
         include $this->root_path . 'includes/functions_user.' . $this->php_ext;
     }
     if (!class_exists('messenger')) {
         include $this->root_path . 'includes/functions_messenger.' . $this->php_ext;
     }
     user_active_flip('activate', $user['user_id']);
     $messenger = new \messenger(false);
     $messenger->template('admin_welcome_activated', $user['user_lang']);
     $messenger->to($user['user_email'], $user['username']);
     $messenger->anti_abuse_headers($this->config, $this->user);
     $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user['username'])));
     $messenger->send(NOTIFY_EMAIL);
     $messenger->save_queue();
     $this->log->add('user', $this->user->data['user_id'], $this->user->ip, 'LOG_USER_ACTIVE', time(), array($user['username']));
 }
开发者ID:alhitary,项目名称:phpBB-3.1-activation-justification,代码行数:26,代码来源:listener.php

示例8: main

    function main($id, $mode)
    {
        global $config, $phpbb_root_path, $phpEx;
        global $db, $user, $auth, $template;
        $username = request_var('username', '', true);
        $email = strtolower(request_var('email', ''));
        $submit = isset($_POST['submit']) ? true : false;
        add_form_key('ucp_resend');
        if ($submit) {
            if (!check_form_key('ucp_resend')) {
                trigger_error('FORM_INVALID');
            }
            $sql = 'SELECT user_id, group_id, username, user_email, user_type, user_lang, user_actkey, user_inactive_reason
				FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "'\n\t\t\t\t\tAND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
            $result = $db->sql_query($sql);
            $user_row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if (!$user_row) {
                trigger_error('NO_EMAIL_USER');
            }
            if ($user_row['user_type'] == USER_IGNORE) {
                trigger_error('NO_USER');
            }
            if (!$user_row['user_actkey'] && $user_row['user_type'] != USER_INACTIVE) {
                trigger_error('ACCOUNT_ALREADY_ACTIVATED');
            }
            if (!$user_row['user_actkey'] || $user_row['user_type'] == USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_MANUAL) {
                trigger_error('ACCOUNT_DEACTIVATED');
            }
            // Determine coppa status on group (REGISTERED(_COPPA))
            $sql = 'SELECT group_name, group_type
				FROM ' . GROUPS_TABLE . '
				WHERE group_id = ' . $user_row['group_id'];
            $result = $db->sql_query($sql);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if (!$row) {
                trigger_error('NO_GROUP');
            }
            $coppa = $row['group_name'] == 'REGISTERED_COPPA' && $row['group_type'] == GROUP_SPECIAL ? true : false;
            include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
            $messenger = new messenger(false);
            if ($config['require_activation'] == USER_ACTIVATION_SELF || $coppa) {
                $messenger->template($coppa ? 'coppa_resend_inactive' : 'user_resend_inactive', $user_row['user_lang']);
                $messenger->set_addresses($user_row);
                $messenger->anti_abuse_headers($config, $user);
                $messenger->assign_vars(array('WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), 'USERNAME' => htmlspecialchars_decode($user_row['username']), 'U_ACTIVATE' => generate_board_url() . "/ucp.{$phpEx}?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}"));
                if ($coppa) {
                    $messenger->assign_vars(array('FAX_INFO' => $config['coppa_fax'], 'MAIL_INFO' => $config['coppa_mail'], 'EMAIL_ADDRESS' => $user_row['user_email']));
                }
                $messenger->send(NOTIFY_EMAIL);
            }
            if ($config['require_activation'] == USER_ACTIVATION_ADMIN) {
                // Grab an array of user_id's with a_user permissions ... these users can activate a user
                $admin_ary = $auth->acl_get_list(false, 'a_user', false);
                $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
					FROM ' . USERS_TABLE . '
					WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']);
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    $messenger->template('admin_activate', $row['user_lang']);
                    $messenger->set_addresses($row);
                    $messenger->anti_abuse_headers($config, $user);
                    $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user_row['username']), 'U_USER_DETAILS' => generate_board_url() . "/memberlist.{$phpEx}?mode=viewprofile&u={$user_row['user_id']}", 'U_ACTIVATE' => generate_board_url() . "/ucp.{$phpEx}?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}"));
                    $messenger->send($row['user_notify_type']);
                }
                $db->sql_freeresult($result);
            }
            meta_refresh(3, append_sid("{$phpbb_root_path}index.{$phpEx}"));
            $message = $config['require_activation'] == USER_ACTIVATION_ADMIN ? $user->lang['ACTIVATION_EMAIL_SENT_ADMIN'] : $user->lang['ACTIVATION_EMAIL_SENT'];
            $message .= '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.{$phpEx}") . '">', '</a>');
            trigger_error($message);
        }
        $template->assign_vars(array('USERNAME' => $username, 'EMAIL' => $email, 'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=resend_act')));
        $this->tpl_name = 'ucp_resend';
        $this->page_title = 'UCP_RESEND';
    }
开发者ID:WarriorMachines,项目名称:warriormachines-phpbb,代码行数:77,代码来源:ucp_resend.php

示例9: send_notification

 /**
  * Send account activation notification to user
  *
  * @param array           $user_row The user data array
  * @param InputInterface  $input    The input stream used to get the options
  * @return null
  */
 protected function send_notification($user_row, InputInterface $input)
 {
     $this->notifications->delete_notifications('notification.type.admin_activate_user', $user_row['user_id']);
     if ($input->getOption('send-email')) {
         if (!class_exists('messenger')) {
             require $this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext;
         }
         $messenger = new \messenger(false);
         $messenger->template('admin_welcome_activated', $user_row['user_lang']);
         $messenger->set_addresses($user_row);
         $messenger->anti_abuse_headers($this->config, $this->user);
         $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user_row['username'])));
         $messenger->send(NOTIFY_EMAIL);
     }
 }
开发者ID:phpbb,项目名称:phpbb-core,代码行数:22,代码来源:activate.php

示例10: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->user->session_begin();
     $this->user->setup('common');
     if ($this->config['email_enable']) {
         include $this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext;
         // functions_messenger.php uses config to determine language paths
         // Remove when able
         global $config;
         $config = $this->config;
         $messenger = new \messenger(false);
         $messenger->template('installed', $this->install_config->get('user_language', 'en'));
         $messenger->to($this->config['board_email'], $this->install_config->get('admin_name'));
         $messenger->anti_abuse_headers($this->config, $this->user);
         $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($this->install_config->get('admin_name')), 'PASSWORD' => htmlspecialchars_decode($this->install_config->get('admin_passwd'))));
         $messenger->send(NOTIFY_EMAIL);
     }
     // Login admin
     // Ugly but works
     $this->auth->login($this->install_config->get('admin_name'), $this->install_config->get('admin_passwd'), false, true, true);
     $this->iohandler->set_cookie($this->config['cookie_name'] . '_sid', $this->user->session_id);
     $this->iohandler->set_cookie($this->config['cookie_name'] . '_u', $this->user->cookie_data['u']);
     $this->iohandler->set_cookie($this->config['cookie_name'] . '_k', $this->user->cookie_data['k']);
     // Create log
     $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_INSTALL_INSTALLED', false, array($this->config['version']));
     // Remove install_lock
     @unlink($this->phpbb_root_path . 'cache/install_lock');
 }
开发者ID:007durgesh219,项目名称:phpbb,代码行数:31,代码来源:notify_user.php

示例11:

					$messenger->template($email_tpl, $row['email_lang']);
					$messenger->replyto($user->data['user_email']);
					$messenger->to($row['email'], $row['name']);

					if ($user_id)
					{
						$messenger->subject(htmlspecialchars_decode($subject));
						$messenger->im($row['user_jabber'], $row['username']);
						$notify_type = $row['user_notify_type'];
					}
					else
					{
						$notify_type = NOTIFY_EMAIL;
					}

					$messenger->anti_abuse_headers($config, $user);

					$messenger->assign_vars(array(
						'BOARD_CONTACT'	=> $config['board_contact'],
						'TO_USERNAME'	=> htmlspecialchars_decode($row['to_name']),
						'FROM_USERNAME'	=> htmlspecialchars_decode($user->data['username']),
						'MESSAGE'		=> htmlspecialchars_decode($message))
					);

					if ($topic_id)
					{
						$messenger->assign_vars(array(
							'TOPIC_NAME'	=> htmlspecialchars_decode($row['topic_title']),
							'U_TOPIC'		=> generate_board_url() . "/viewtopic.$phpEx?f=" . $row['forum_id'] . "&t=$topic_id")
						);
					}
开发者ID:gonzo1247,项目名称:hitman_roa,代码行数:31,代码来源:memberlist.php

示例12: regUser

 /**
  * Регистрация пользователя в БД users
  * @return mixed
  */
 protected function regUser()
 {
     $u_data = $this->u_data;
     $config = $this->config;
     $user = $this->user;
     $root_path = $this->root_path;
     $php_ext = $this->php_ext;
     global $phpbb_container;
     $u_data["verified_email"] = isset($u_data["verified_email"]) ? $u_data["verified_email"] : -1;
     if ($config['require_activation'] == USER_ACTIVATION_DISABLE || ($config['require_activation'] == USER_ACTIVATION_SELF && $u_data["verified_email"] == -1 || $config['require_activation'] == USER_ACTIVATION_ADMIN) && !$config['email_enable']) {
         $this->sendMessage(array('title' => $this->user->lang['ULOGIN_REG_ERROR'], 'msg' => $user->lang['UCP_REGISTER_DISABLE'], 'type' => 'error'));
         return false;
     }
     // DNSBL check
     if ($config['check_dnsbl']) {
         if (($dnsbl = $user->check_dnsbl('register')) !== false) {
             $this->sendMessage(array('title' => $this->user->lang['ULOGIN_REG_ERROR'], 'msg' => sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]), 'type' => 'error'));
             return false;
         }
     }
     $group_id = $this->model->getGroupId();
     if (($config['require_activation'] == USER_ACTIVATION_SELF && $u_data["verified_email"] == -1 || $config['require_activation'] == USER_ACTIVATION_ADMIN) && $config['email_enable']) {
         $user_type = USER_INACTIVE;
         $user_actkey = gen_rand_string(mt_rand(6, 10));
         $user_inactive_reason = INACTIVE_REGISTER;
         $user_inactive_time = time();
     } else {
         $user_type = USER_NORMAL;
         $user_actkey = '';
         $user_inactive_reason = 0;
         $user_inactive_time = 0;
     }
     // Instantiate passwords manager
     $passwords_manager = $phpbb_container->get('passwords.manager');
     $login = $this->generateNickname(isset($u_data['first_name']) ? $u_data['first_name'] : '', isset($u_data['last_name']) ? $u_data['last_name'] : '', isset($u_data['nickname']) ? $u_data['nickname'] : '', isset($u_data['bdate']) ? $u_data['bdate'] : '');
     $password = md5($u_data['identity'] . time() . rand());
     $password = substr($password, 0, 12);
     $user_row = array('username' => $login, 'user_password' => $passwords_manager->hash($password), 'user_email' => $u_data['email'], 'user_birthday' => isset($u_data['bdate']) ? date('d-m-Y', strtotime($u_data['bdate'])) : '', 'group_id' => (int) $group_id, 'user_timezone' => $this->config['board_timezone'], 'user_lang' => basename($user->lang_name), 'user_ip' => $user->ip, 'user_regdate' => time(), 'user_type' => $user_type, 'user_actkey' => $user_actkey, 'user_inactive_reason' => $user_inactive_reason, 'user_inactive_time' => $user_inactive_time);
     if ($config['new_member_post_limit']) {
         $user_row['user_new'] = 1;
     }
     // Register user...
     include_once $root_path . 'includes/functions_user.' . $php_ext;
     $user_id = user_add($user_row);
     // This should not happen, because the required variables are listed above...
     if ($user_id === false) {
         $this->sendMessage(array('title' => $this->user->lang['ULOGIN_REG_ERROR'], 'msg' => $this->user->lang['ULOGIN_REG_ERROR_TEXT'], 'type' => 'error'));
         return false;
     }
     // Adds a user to the specified group
     include_once $root_path . 'includes/functions_convert.' . $php_ext;
     add_user_group($config['ulogin_group_id'], $user_id);
     if ($config['require_activation'] == USER_ACTIVATION_SELF && $u_data["verified_email"] == -1 && $config['email_enable']) {
         $message = $user->lang['ACCOUNT_INACTIVE'];
         $email_template = 'user_welcome_inactive';
     } else {
         if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable']) {
             $message = $user->lang['ACCOUNT_INACTIVE_ADMIN'];
             $email_template = 'admin_welcome_inactive';
         } else {
             $message = $user->lang['ACCOUNT_ADDED'];
             $email_template = 'user_welcome';
         }
     }
     if ($config['email_enable']) {
         include_once $root_path . 'includes/functions_messenger.' . $php_ext;
         $messenger = new \messenger(false);
         $template_lang = basename($user->lang_name);
         $template_path = dirname(dirname(__FILE__)) . '/language/';
         $template_path .= $template_lang . '/email';
         if (!file_exists($template_path . '/' . $email_template . '.txt')) {
             $template_lang = 'en';
             $template_path = dirname(dirname(__FILE__)) . '/language/';
             $template_path .= $template_lang . '/email';
         }
         $messenger->template($email_template, $template_lang, $template_path);
         $messenger->to($u_data['email'], $login);
         $messenger->anti_abuse_headers($config, $user);
         $server_url = generate_board_url();
         $messenger->assign_vars(array('WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), 'USERNAME' => htmlspecialchars_decode($login), 'PASSWORD' => htmlspecialchars_decode($password), 'U_ACTIVATE' => "{$server_url}/ucp.{$php_ext}?mode=activate&u={$user_id}&k={$user_actkey}"));
         $messenger->send(NOTIFY_EMAIL);
     }
     if ($config['require_activation'] == USER_ACTIVATION_ADMIN) {
         $phpbb_notifications = $phpbb_container->get('notification_manager');
         $phpbb_notifications->add_notifications('notification.type.admin_activate_user', array('user_id' => $user_id, 'user_actkey' => $user_row['user_actkey'], 'user_regdate' => $user_row['user_regdate']));
     }
     if ($user_type == USER_INACTIVE) {
         $this->sendMessage(array('title' => "", 'msg' => $message, 'type' => 'success'));
         return false;
     }
     return $user_id;
 }
开发者ID:mike-a-b,项目名称:crossfit,代码行数:96,代码来源:main.php

示例13: main


//.........这里部分代码省略.........
								include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);

								$server_url = generate_board_url();

								$user_actkey = gen_rand_string(mt_rand(6, 10));
								$email_template = ($user_row['user_type'] == USER_NORMAL) ? 'user_reactivate_account' : 'user_resend_inactive';

								if ($user_row['user_type'] == USER_NORMAL)
								{
									user_active_flip('deactivate', $user_id, INACTIVE_REMIND);

									$sql = 'UPDATE ' . USERS_TABLE . "
										SET user_actkey = '" . $db->sql_escape($user_actkey) . "'
										WHERE user_id = $user_id";
									$db->sql_query($sql);
								}
								else
								{
									// Grabbing the last confirm key - we only send a reminder
									$sql = 'SELECT user_actkey
										FROM ' . USERS_TABLE . '
										WHERE user_id = ' . $user_id;
									$result = $db->sql_query($sql);
									$user_actkey = (string) $db->sql_fetchfield('user_actkey');
									$db->sql_freeresult($result);
								}

								$messenger = new messenger(false);

								$messenger->template($email_template, $user_row['user_lang']);

								$messenger->to($user_row['user_email'], $user_row['username']);

								$messenger->anti_abuse_headers($config, $user);

								$messenger->assign_vars(array(
									'WELCOME_MSG'	=> htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])),
									'USERNAME'		=> htmlspecialchars_decode($user_row['username']),
									'U_ACTIVATE'	=> "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey")
								);

								$messenger->send(NOTIFY_EMAIL);

								add_log('admin', 'LOG_USER_REACTIVATE', $user_row['username']);
								add_log('user', $user_id, 'LOG_USER_REACTIVATE_USER');

								trigger_error($user->lang['FORCE_REACTIVATION_SUCCESS'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
							}

						break;

						case 'active':

							if ($user_id == $user->data['user_id'])
							{
								// It is only deactivation since the user is already activated (else he would not have reached this page)
								trigger_error($user->lang['CANNOT_DEACTIVATE_YOURSELF'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
							}

							if (!check_form_key($form_name))
							{
								trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
							}

							if ($user_row['user_type'] == USER_FOUNDER)
							{
开发者ID:gonzo1247,项目名称:hitman_roa,代码行数:67,代码来源:acp_users.php

示例14: send_notifications

    /**
     * Send Notifications
     *
     * Using this function:
     * Call this function when you know the Object type, object id, and the email
     * template name.
     * Sample usage:
     *
     * <code>
     *
     * $object_type = SOME_OBJECT_CONSTANT_TYPE;
     * $obhect)id = 242974;
     *
     * titania_subscriptions::send_notifications($object_type, $object_id, 'mod_subscribe', array(
     * 		'OBJECT_NAME'	=> 'Some MOD',
     * ));
     *
     * </code>
     *
     * The vars parameter will be used in the messanger assign vars, which will act
     * as the common vars when sending out the notifications. Data such as the MOD's
     * or Style's name should go here, what action was taken, etc. The usernaeme and
     * emails of the recepiants will be personalised by the function. Ensure the
     * email template has the {USERNAME} var present.
     *
     * @param $exclude_user User_id of the one who posted the item to exclude them from the sending
     *
     */
    public function send_notifications($object_type, $object_id, $email_tpl, $vars, $exclude_user = false)
    {
        $sql = 'SELECT w.watch_user_id, w.watch_type, u.user_id, u.username, u.user_email, u.user_lang
			FROM ' . $this->watch_table . ' w, ' . $this->users_table . ' u
			WHERE w.watch_user_id = u.user_id ';
        if (is_array($object_type) || is_array($object_id)) {
            // Both needs to be arrays if one is and they need to have the same number of elements.
            if (!is_array($object_type) || !is_array($object_id) || sizeof($object_type) != sizeof($object_id)) {
                return;
            }
            $sql_objects = '';
            foreach ($object_type as $key => $value) {
                $sql_objects .= ($sql_objects == '' ? '' : ' OR ') . '(w.watch_object_type = ' . (int) $value . '
							AND w.watch_object_id = ' . (int) $object_id[$key] . ')';
            }
            $sql .= 'AND (' . $sql_objects . ')';
            unset($sql_objects);
        } else {
            $sql .= 'AND w.watch_object_type = ' . (int) $object_type . '
						AND w.watch_object_id = ' . (int) $object_id;
        }
        $sql .= $exclude_user ? ' AND w.watch_user_id <> ' . (int) $exclude_user : '';
        $result = $this->db->sql_query($sql);
        // Throw everything here
        $user_data = array();
        while ($row = $this->db->sql_fetchrow($result)) {
            // Use user_id for the keys to not send duplicates.
            $user_data[$row['user_id']] = array('username' => $row['username'], 'user_email' => $row['user_email'], 'user_lang' => $row['user_lang'], 'watch_type' => $row['watch_type']);
        }
        $this->db->sql_freeresult($result);
        // No one subscribed? We're done.
        if (empty($user_data)) {
            return;
        }
        $messenger = null;
        // Send to each user
        // Add a new case statment for each subscription type
        foreach ($user_data as $data) {
            /*
             * Switch between the types.
             * ------------------------------------------
             * When adding a type, the final message will
             * be stored in $message, and the subject is
             * stored in $vars['SUBJECT'].
             */
            switch ($data['watch_type']) {
                case self::EMAIL:
                    if ($messenger === null) {
                        // Only make the object if we need it
                        if (!class_exists('\\messenger')) {
                            require $this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext;
                        }
                        $messenger = new \messenger();
                    }
                    $messenger->anti_abuse_headers($this->config, $this->user);
                    $messenger->template('@phpbb_titania/' . $email_tpl, $data['user_lang']);
                    $messenger->to($data['user_email'], $data['username']);
                    $messenger->assign_vars(array_merge($vars, array('USERNAME' => $data['username'])));
                    $messenger->send();
                    $messenger->save_queue();
                    break;
            }
        }
        return;
    }
开发者ID:Sajaki,项目名称:customisation-db,代码行数:93,代码来源:subscriptions.php

示例15: main


//.........这里部分代码省略.........
                    if (!isset($_REQUEST['mail_banned_flag'])) {
                        $sql_ary['WHERE'] .= ' AND (b.ban_id IS NULL
						        OR b.ban_exclude = 1)';
                        $sql_ary['LEFT_JOIN'] = array(array('FROM' => array(BANLIST_TABLE => 'b'), 'ON' => 'u.user_id = b.ban_userid'));
                    }
                    $sql = $db->sql_build_query('SELECT', $sql_ary);
                }
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                if (!$row) {
                    $db->sql_freeresult($result);
                    trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                $i = $j = 0;
                // Send with BCC
                // Maximum number of bcc recipients
                $max_chunk_size = (int) $config['email_max_chunk_size'];
                $email_list = array();
                $old_lang = $row['user_lang'];
                $old_notify_type = $row['user_notify_type'];
                do {
                    if ($row['user_notify_type'] == NOTIFY_EMAIL && $row['user_email'] || $row['user_notify_type'] == NOTIFY_IM && $row['user_jabber'] || $row['user_notify_type'] == NOTIFY_BOTH && ($row['user_email'] || $row['user_jabber'])) {
                        if ($i == $max_chunk_size || $row['user_lang'] != $old_lang || $row['user_notify_type'] != $old_notify_type) {
                            $i = 0;
                            if (sizeof($email_list)) {
                                $j++;
                            }
                            $old_lang = $row['user_lang'];
                            $old_notify_type = $row['user_notify_type'];
                        }
                        $email_list[$j][$i]['lang'] = $row['user_lang'];
                        $email_list[$j][$i]['method'] = $row['user_notify_type'];
                        $email_list[$j][$i]['email'] = $row['user_email'];
                        $email_list[$j][$i]['name'] = $row['username'];
                        $email_list[$j][$i]['jabber'] = $row['user_jabber'];
                        $i++;
                    }
                } while ($row = $db->sql_fetchrow($result));
                $db->sql_freeresult($result);
                // Send the messages
                include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
                $messenger = new messenger($use_queue);
                $errored = false;
                for ($i = 0, $size = sizeof($email_list); $i < $size; $i++) {
                    $used_lang = $email_list[$i][0]['lang'];
                    $used_method = $email_list[$i][0]['method'];
                    for ($j = 0, $list_size = sizeof($email_list[$i]); $j < $list_size; $j++) {
                        $email_row = $email_list[$i][$j];
                        $messenger->{sizeof($email_list[$i]) == 1 ? 'to' : 'bcc'}($email_row['email'], $email_row['name']);
                        $messenger->im($email_row['jabber'], $email_row['name']);
                    }
                    $messenger->template('admin_send_email', $used_lang);
                    $messenger->anti_abuse_headers($config, $user);
                    $messenger->subject(htmlspecialchars_decode($subject));
                    $messenger->set_mail_priority($priority);
                    $messenger->assign_vars(array('CONTACT_EMAIL' => $config['board_contact'], 'MESSAGE' => htmlspecialchars_decode($message)));
                    if (!$messenger->send($used_method)) {
                        $errored = true;
                    }
                }
                unset($email_list);
                $messenger->save_queue();
                if ($usernames) {
                    $usernames = explode("\n", $usernames);
                    add_log('admin', 'LOG_MASS_EMAIL', implode(', ', utf8_normalize_nfc($usernames)));
                } else {
                    if ($group_id) {
                        $group_name = get_group_name($group_id);
                    } else {
                        // Not great but the logging routine doesn't cope well with localising on the fly
                        $group_name = $user->lang['ALL_USERS'];
                    }
                    add_log('admin', 'LOG_MASS_EMAIL', $group_name);
                }
                if (!$errored) {
                    $message = $use_queue ? $user->lang['EMAIL_SENT_QUEUE'] : $user->lang['EMAIL_SENT'];
                    trigger_error($message . adm_back_link($this->u_action));
                } else {
                    $message = sprintf($user->lang['EMAIL_SEND_ERROR'], '<a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=logs&amp;mode=critical') . '">', '</a>');
                    trigger_error($message . adm_back_link($this->u_action), E_USER_WARNING);
                }
            }
        }
        // Exclude bots and guests...
        $sql = 'SELECT group_id
			FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_name IN ('BOTS', 'GUESTS')";
        $result = $db->sql_query($sql);
        $exclude = array();
        while ($row = $db->sql_fetchrow($result)) {
            $exclude[] = $row['group_id'];
        }
        $db->sql_freeresult($result);
        $select_list = '<option value="0"' . (!$group_id ? ' selected="selected"' : '') . '>' . $user->lang['ALL_USERS'] . '</option>';
        $select_list .= group_select_options($group_id, $exclude);
        $s_priority_options = '<option value="' . MAIL_LOW_PRIORITY . '">' . $user->lang['MAIL_LOW_PRIORITY'] . '</option>';
        $s_priority_options .= '<option value="' . MAIL_NORMAL_PRIORITY . '" selected="selected">' . $user->lang['MAIL_NORMAL_PRIORITY'] . '</option>';
        $s_priority_options .= '<option value="' . MAIL_HIGH_PRIORITY . '">' . $user->lang['MAIL_HIGH_PRIORITY'] . '</option>';
        $template->assign_vars(array('S_WARNING' => sizeof($error) ? true : false, 'WARNING_MSG' => sizeof($error) ? implode('<br />', $error) : '', 'U_ACTION' => $this->u_action, 'S_GROUP_OPTIONS' => $select_list, 'USERNAMES' => $usernames, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&amp;form=acp_email&amp;field=usernames'), 'SUBJECT' => $subject, 'MESSAGE' => $message, 'S_PRIORITY_OPTIONS' => $s_priority_options));
    }
开发者ID:eyumay,项目名称:ju.ejhs,代码行数:101,代码来源:acp_email.php


注:本文中的messenger::anti_abuse_headers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。