public function index_f() { $email = $this->get('email'); if (!$email) { $this->json(P_Lang('Email不能为空')); } $title = $this->get('title'); $content = $this->get('content', 'html'); if (!$content) { $this->json(P_Lang('邮件内容不能为空')); } if (!$title) { $title = phpok_cut($content, 50, '…'); } if (!$this->site['email_server'] || !$this->site['email_account'] || !$this->site['email_pass'] || !$this->site['email']) { $this->json(P_Lang('SMTP未配置好')); } $list = explode(',', $email); foreach ($list as $key => $value) { $value = trim($value); if ($value && phpok_check_email($value)) { $value_name = str_replace(strstr($value, '@'), '', $value); $info = $this->lib('email')->send_mail($value, $title, $content, $value_name); if (!$info) { $this->json($this->lib('email')->error()); } } } $this->json(true); }
function info_f() { $group_rs = $this->model('usergroup')->group_rs($this->u_id); if (!$group_rs) { $this->json(P_Lang('会员组不存在')); } $avatar = $this->get("avatar"); $email = $this->get("email"); if (!$email) { $this->json(P_Lang('未指定邮箱')); } if (!phpok_check_email($email)) { $this->json(P_Lang('邮箱不合法')); } $uid = $this->model('user')->uid_from_email($email, $this->u_id); if ($uid) { $this->json(P_Lang('邮箱已被使用')); } $mobile = $this->get('mobile'); $array = array('avatar' => $avatar, 'email' => $email, 'mobile' => $mobile); $this->model('user')->save($array, $this->u_id); $condition = 'is_edit=1'; if ($group_rs['fields']) { $tmp = explode(",", $group_rs['fields']); $condition .= " AND identifier IN('" . implode("','", $tmp) . "')"; } $ext_list = $this->model('user')->fields_all($condition, "id"); if ($ext_list) { $ext = ""; foreach ($ext_list as $key => $value) { $ext[$value['identifier']] = $this->lib('form')->get($value); } if ($ext) { $this->model('user')->update_ext($ext, $this->u_id); } } if (!$this->is_client) { $this->model('user')->update_session($this->u_id); } $this->json(true); }
public function save_f() { //判断是否是会员 if ($_SESSION['user_id']) { $this->json(P_Lang('您已是本站会员,不能执行这个操作')); } if ($this->config['is_vcode'] && function_exists('imagecreate')) { $code = $this->get('_chkcode'); if (!$code) { $this->json(P_Lang('验证码不能为空')); } $code = md5(strtolower($code)); if ($code != $_SESSION['vcode']) { $this->json(P_Lang('验证码填写不正确')); } unset($_SESSION['vcode']); } //检测会员账号 $user = $this->get("user"); if (!$user) { $this->json(P_Lang('账号不能为空')); } $safelist = array("'", '"', '/', '\\', ';', '.', ')', '('); foreach ($safelist as $key => $value) { if (strpos($user, $value) !== false) { $this->json(P_Lang('会员账号不允许包含字符串:') . $value); } } $chk = $this->model('user')->chk_name($user); if ($chk) { $this->json(P_Lang('会员账号已存用')); } $newpass = $this->get('newpass'); if (!$newpass) { $this->json(P_Lang('密码不能为空')); } $chkpass = $this->get('chkpass'); if (!$chkpass) { $this->json(P_Lang('确认密码不能为空')); } if ($newpass != $chkpass) { $this->json(P_Lang('两次输入的密码不一致')); } $email = $this->get('email'); if (!$email) { $this->json(P_Lang('邮箱不能为空')); } if (!phpok_check_email($email)) { $this->json(P_Lang('邮箱不合法')); } $chk = $this->model('user')->user_email($email); if ($chk) { $this->json(P_Lang('该邮箱已被注册')); } $array = array(); $array["user"] = $user; $array["pass"] = password_create($newpass); $array['email'] = $email; $array['mobile'] = $this->get('mobile'); $group_id = $this->get("group_id", "int"); if ($group_id) { $group_rs = $this->model("usergroup")->get_one($group_id); if (!$group_rs || !$group_rs['status']) { $group_id = 0; } } if (!$group_id) { $group_rs = $this->model('usergroup')->get_default(); if (!$group_rs || !$group_rs["status"]) { $this->json(P_Lang('注册失败,网站未开放注册权限')); } $group_id = $group_rs["id"]; } if (!$group_id) { $this->json(P_Lang('注册失败,网站未开放注册权限')); } if (!$group_rs["is_default"] && !$group_rs["is_open"]) { $this->json(P_Lang('注册失败,网站未开放注册权限')); } $array["group_id"] = $group_id; $array["status"] = $group_rs["register_status"] == '1' ? 1 : 0; $array["regtime"] = $this->time; $uid = $this->model('user')->save($array); if (!$uid) { $this->json(P_Lang('注册失败,请联系管理员')); } $extlist = $this->model('user')->fields_all(); $ext = array(); $ext["id"] = $uid; if ($extlist) { foreach ($extlist as $key => $value) { $ext[$value["identifier"]] = ext_value($value); } } $this->model('user')->save_ext($ext); if ($array['status']) { $rs = $this->model('user')->get_one($uid); $_SESSION["user_id"] = $rs['id']; $_SESSION["user_gid"] = $rs['group_id']; $_SESSION["user_name"] = $rs["user"]; $this->json(P_Lang('注册成功,已自动登录,请稍候…'), true); } if (!$group_rs["tbl_id"] && !$group_rs['register_status']) { $this->json(P_Lang('注册成功,等待管理员验证'), true); } $project = $this->model('project')->get_one($group_rs['tbl_id'], false); if (!$project['module']) { $this->json(P_Lang('注册成功,等待管理员验证'), true); } $code = $this->get('_code'); if (!$code) { $this->json(P_Lang('注册成功,等待管理员验证'), true); } $info = $this->model('list')->get_one_condition("l.title='" . $code . "'", $project['module']); if ($info) { $ext = array('site_id' => $info['site_id'], 'project_id' => $info['project_id']); $ext['account'] = $user; $this->model('list')->update_ext($ext, $project['module'], $info['id']); $this->model('user')->set_status($uid, 1); $this->model('user')->update_session($uid); $rs = $this->model('user')->get_one($uid); $_SESSION["user_id"] = $rs['id']; $_SESSION["user_gid"] = $rs['group_id']; $_SESSION["user_name"] = $rs["user"]; $this->json(P_Lang('注册成功,已自动登录,请稍候…'), true); } $this->json(P_Lang('注册成功,等待管理员验证'), true); }
public function getpass_f() { //判断是否是会员 if ($_SESSION['user_id']) { $this->json(P_Lang('您已是本站会员,不能执行这个操作')); } //检测是否启用验证码 if ($this->config['is_vcode'] && function_exists('imagecreate')) { $code = $this->get('_chkcode'); if (!$code) { $this->json(P_Lang('验证码不能为空')); } $code = md5(strtolower($code)); if ($code != $_SESSION['vcode']) { $this->json(P_Lang('验证码填写不正确')); } unset($_SESSION['vcode']); } $email = $this->get('email'); if (!$email) { $this->json(P_Lang('邮箱不能为空')); } if (!phpok_check_email($email)) { $this->json(P_Lang('邮箱验证不通过')); } $rs = $this->model('user')->user_email($email); if (!$rs) { $this->json(P_Lang('邮箱不存在')); } if (!$rs['status']) { $this->json(P_Lang('会员账号审核中,暂时不能使用取回密码功能')); } if ($rs['status'] == '2') { $this->json(P_Lang('会员账号被管理员锁定,不能使用取回密码功能,请联系管理员')); } if (!$this->site['email_server'] || !$this->site['email_account'] || !$this->site['email_pass']) { $this->json(P_Lang('邮箱取回密码功能未启用,请联系我们的客服')); } $code = str_rand(10) . $this->time; $this->model('user')->update_code($code, $rs['id']); //获取邮件模板ID $email_rs = $this->model('email')->get_identifier('getpass', $this->site['id']); if (!$email_rs) { $this->json(P_Lang('邮件模板为空,请配置邮件模板')); } $link = $this->url('login', 'repass', '_code=' . rawurlencode($code), 'www'); $this->assign('link', $link); $this->assign('email', $email); $this->assign('code', $code); $this->assign('user', $rs); $title = $this->fetch($email_rs["title"], "content"); $content = $this->fetch($email_rs["content"], "content"); //发送邮件 $info = $this->lib('email')->send_mail($email, $title, $content); if (!$info) { $this->json($this->lib('email')->error()); } $this->json(true); }