function submit_f() { $oldpass = $this->get("oldpass"); if (!$oldpass) { error(P_Lang('管理员密码验证不能为空'), $this->url("me", "setting"), "error"); } $rs = $this->model('admin')->get_one($_SESSION["admin_id"]); if (!password_check($oldpass, $rs["pass"])) { error(P_Lang("管理员密码不正确"), $this->url("me", "setting"), "error"); } $name = $this->get('name'); $array = array('email' => $this->get('email')); $update_login = false; $admin = $this->model('admin')->get_one($_SESSION['admin_id'], 'id'); $tip = P_Lang('信息修改成功'); if ($name && $name != $admin['account']) { //修改管理员账号 $check = $this->model('admin')->check_account($name, $_SESSION['admin_id']); if ($check) { error(P_Lang('管理员账号已经存在,请重新设置'), $this->url('me', 'setting'), 'error'); } $array['account'] = $name; $update_login = true; $tip = P_Lang('管理员账号信息变更成功,请重新登录'); } $newpass = $this->get("newpass"); if ($newpass) { $chkpass = $this->get("chkpass"); if ($newpass != $chkpass) { error(P_Lang("两次输入的新密码不一致"), $this->url("me", "setting"), "error"); } $array['pass'] = password_create($newpass); $tip = P_Lang('密码修改成功,请下次登录后使用新密码登录!'); } $array['fullname'] = $this->get('fullname'); $array['close_tip'] = $this->get('close_tip'); $this->model('admin')->save($array, $_SESSION['admin_id']); if ($update_login) { error($tip, $this->url('logout'), 'ok'); } else { $info = $this->model('admin')->get_one($_SESSION['admin_id'], 'id'); $_SESSION['admin_rs'] = $info; $html = '<input type="button" value=" ' . P_Lang('确定') . ' " class="submit" onclick="$.dialog.close();" />'; error_open($tip, "ok", $html); } }
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 save_f() { $id = $this->get("id", "int"); if ($id && $id == $_SESSION["admin_id"]) { error(P_Lang('您不能操作自己的信息'), $this->url("admin"), "error"); } if ($id) { if (!$this->popedom["modify"]) { error(P_Lang('您没有权限执行此操作'), '', 'error'); } } else { if (!$this->popedom["add"]) { error(P_Lang('您没有权限执行此操作'), '', 'error'); } } $account = $this->get("account"); if (!$account) { error(P_Lang('账号不能为空'), $this->url("admin", "set", "id=" . $id), "error"); } $check_str = $this->check_account($account, $id); if ($check_str != "ok") { error($check_str, $this->url("admin", "set", "id=" . $id), "error"); } $array = array(); $array["account"] = $account; $pass = $this->get("pass"); if (!$pass && !$id) { error(P_Lang('密码不能为空'), $this->url("admin", "set", "id=" . $id), "error"); } if ($pass) { if (strlen($pass) < 4) { error(P_Lang('密码长度不能少于4位'), $this->url("admin", "set", "id=" . $id), "error"); } $array["pass"] = password_create($pass); } $array['email'] = $this->get("email"); if ($this->popedom["status"]) { $array["status"] = $this->get("status", "int"); } $if_system = $this->get("if_system", "int"); if (!$_SESSION["admin_rs"]["if_system"]) { $if_system = 0; } $array["if_system"] = $if_system; $is_edit = false; if ($id) { $st = $this->model('admin')->save($array, $id); if (!$st) { error(P_Lang('管理员信息更新失败,请检查'), $this->url("admin", "set", "id=" . $id), "error"); } $is_edit = true; } else { $id = $this->model('admin')->save($array); if (!$id) { error(P_Lang('管理员信息添加失败,请检查'), $this->url("admin", "set"), "error"); } } $this->model('admin')->clear_popedom($id); if (!$if_system) { $popedom = $this->get("popedom"); if ($popedom) { $popedom = array_unique($popedom); $this->model('admin')->save_popedom($popedom, $id); } } $tip = $is_edit ? P_Lang('管理员信息编辑成功') : P_Lang('管理员账号添加成功'); error($tip, $this->url("admin"), "ok"); }
function setok_f() { $id = $this->get("id", "int"); $array = array(); $array["user"] = $this->get("user"); $array['avatar'] = $this->get('avatar'); $array['email'] = $this->get('email'); $array['mobile'] = $this->get('mobile'); $pass = $this->get("pass"); if ($pass) { $array["pass"] = password_create($pass); } else { if (!$id) { $array["pass"] = password_create("123456"); } } $popedom_id = $id ? 'modify' : 'add'; if (!$this->popedom[$popedom_id]) { error(P_Lang('您没有权限执行此操作'), '', 'error'); } $array["group_id"] = $this->get("group_id", "int"); if ($this->popedom["status"]) { $array["status"] = $this->get("status", "int"); } $regtime = $this->get("regtime", "time"); if (!$regtime) { $regtime = $this->time; } $array["regtime"] = $regtime; //存储扩展表信息 $insert_id = $this->model('user')->save($array, $id); //读取扩展字段 $ext_list = $this->model('user')->fields_all(); $tmplist = array(); $tmplist["id"] = $insert_id; foreach ($ext_list ? $ext_list : array() as $key => $value) { $val = ext_value($value); if ($value["ext"]) { $ext = unserialize($value["ext"]); foreach ($ext as $k => $v) { $value[$k] = $v; } } if ($value["form_type"] == "password") { $content = $rs[$value["identifier"]] ? $rs[$value["identifier"]] : $value["content"]; $val = ext_password_format($val, $content, $value["password_type"]); } $tmplist[$value["identifier"]] = $val; } $this->model('user')->save_ext($tmplist); $note = $id ? P_Lang('会员编辑成功') : P_Lang('新会员添加成功'); error($note, $this->url("user"), "ok"); }
public function repass_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']); } $code = $this->get('code'); if (!$code) { $this->json(P_Lang('确认码不能为空')); } $time = intval(substr($code, -10)); if ($this->time - $time > 24 * 60 * 60) { $this->json(P_Lang('验证串已过期或无效')); } $user = $this->get('user'); if (!$user) { $this->json(P_Lang('会员账号不能为空')); } $rs = $this->model('user')->chk_name($user); if (!$rs) { $this->json(P_Lang('会员账号不存在')); } if (!$rs['status']) { $this->json(P_Lang('会员账号审核中,暂时不能使用取回密码功能')); } if ($rs['status'] == '2') { $this->json(P_Lang('会员账号被管理员锁定,不能使用取回密码功能,请联系管理员')); } if ($rs['code'] != $code) { $this->json(P_Lang('验证串不一致')); } $email = $this->get('email'); if (!$email) { $this->json(P_Lang('邮箱不能为空')); } if ($rs['email'] != $email) { $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('两次输入的密码不一致')); } $pass = password_create($newpass); $this->model('user')->update_password($pass, $rs['id']); $this->json(true); }
public function passwd_f() { $oldpass = $this->get("oldpass"); if (!$oldpass) { $this->json(P_Lang('旧密码不能为空')); } $newpass = $this->get("newpass"); $chkpass = $this->get("chkpass"); if (!$newpass || !$chkpass) { $this->json(P_Lang('新密码不能为空')); } if ($newpass != $chkpass) { $this->json(P_Lang('新旧密码不一致')); } $user = $this->model('user')->get_one($this->u_id, false); if (!password_check($oldpass, $user["pass"])) { $this->json(P_Lang('旧密码输入错误')); } if ($oldpass == $newpass) { $this->json(P_Lang('新旧密码不能一样')); } $password = password_create($newpass); $this->model('user')->update_password($password, $this->u_id); if (!$this->is_client) { $this->model('user')->update_session($this->u_id); } $this->json(true); }