/** * 题库管理员密码重置 * from 后台管理员批量导入 */ public function resetpwd() { $hash = $this->input->get('code'); $admin_id = admin_email_hash('decode', $hash, 1800); $admin_id && ($admin = CpUserModel::get_cpuser($admin_id)); if (!$admin) { message('重置链接已失效,请重新提交申请', 'admin/index/login'); } if ($this->input->post('act') == 'submit') { $password = $this->input->post('password'); $newpwd_confirm = $this->input->post('password_confirm'); if (is_string($passwd_msg = is_password($password))) { message($passwd_msg); } if ($password != $newpwd_confirm) { message('您两次输入密码不一致,返回请确认!'); } $this->db->update('admin', array('password' => my_md5($password)), array('admin_id' => $admin_id)); message('您的新密码已设置成功.', 'admin/index/login', 'success'); } else { // 模版 $this->load->view('cpuser/resetpwd', array('hash' => $hash)); } }
/** * @description 批量处理发送邮件 * @param string $mail_data 发送邮件的JSON数据串 */ public function batch_send_email() { if (!$this->check_power('import_cpuser')) { return; } $mail_data = json_decode(urldecode($this->input->post('mail_data'))); $current = intval($this->input->post('current')); if (!is_array($mail_data) || !count($mail_data)) { output_json(CODE_SUCCESS, ''); } // 循环发送邮件 $success_deal = array(); $count_deal = 0; $deal_limit = 5; $email_tpl = C('email_template/import_cpuser_success'); foreach ($mail_data as $k => $row) { $row = (array) $row; $mail = array('admin' => $row, 'hash' => admin_email_hash('encode', $row['admin_id'])); send_email($email_tpl['subject'], $this->load->view($email_tpl['tpl'], $mail, TRUE), $row['email']); $count_deal++; $current++; $success_deal[] = "<p>姓名:" . $row['realname'] . ", 邮箱:" . $row['email'] . ", 角色:" . $row['role_name'] . "</p>"; unset($mail_data[$k]); if ($count_deal >= $deal_limit) { break; } } if (!count($mail_data)) { output_json(CODE_SUCCESS, 'done', array('mail_data' => array(), 'deal_limit' => $deal_limit, 'current' => $current, 'now' => time(), 'success_deal' => implode('', $success_deal))); } output_json(CODE_SUCCESS, '', array('mail_data' => urlencode(json_encode(array_values($mail_data))), 'deal_limit' => $deal_limit, 'current' => $current - 1, 'now' => time(), 'success_deal' => implode('', $success_deal))); }