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() { 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']); } $id = $this->get('id', 'system'); if (!$id) { $this->json(P_Lang('未绑定相应的项目')); } $project_rs = $this->call->phpok('_project', 'phpok=' . $id); if (!$project_rs || !$project_rs['status']) { $this->json(P_Lang('项目信息不存在或未启用')); } if (!$project_rs['module']) { $this->json(P_Lang('此项目没有表单功能')); } if (!$this->model('popedom')->check($project_rs['id'], $this->user_groupid, 'post')) { $this->json(P_Lang('您没有权限执行此操作')); } $array = array(); $array["title"] = $this->get("title"); if (!$array['title']) { $tip = $project_rs['alias_title'] ? $project_rs['alias_title'] : P_Lang('主题'); $this->json($tip . ' ' . P_Lang("不能为空")); } $tid = $this->get('tid', 'int'); $array["status"] = $this->model('popedom')->val($project_rs['id'], $this->user_groupid, 'post1'); $array["hidden"] = 0; $array["module_id"] = $project_rs["module"]; $array["project_id"] = $project_rs["id"]; $array["site_id"] = $project_rs["site_id"]; $array["cate_id"] = $this->get("cate_id", "int"); $array['user_id'] = $_SESSION['user_id'] ? $_SESSION['user_id'] : 0; if ($tid) { $get_result = $this->model('list')->save($array, $tid); if (!$get_result) { $this->json(P_Lang('编辑失败,请联系管理员')); } if ($array["cate_id"]) { $ext_cate = $this->get('ext_cate_id'); if (!$ext_cate) { $ext_cate = array($array["cate_id"]); } $this->model('list')->save_ext_cate($tid, $ext_cate); } } else { $array["dateline"] = $this->time; $insert_id = $this->model('list')->save($array); if (!$insert_id) { $this->json(P_Lang('添加失败,请联系管理')); } if ($array["cate_id"]) { $ext_cate = $this->get('ext_cate_id'); if (!$ext_cate) { $ext_cate = array($array["cate_id"]); } $this->model('list')->save_ext_cate($insert_id, $ext_cate); } } $ext_list = $this->model('module')->fields_all($project_rs["module"]); if (!$ext_list) { $ext_list = array(); } $tmplist = false; if (!$tid) { $tmplist["id"] = $insert_id; } $tmplist["site_id"] = $project_rs["site_id"]; $tmplist["project_id"] = $project_rs["id"]; $tmplist["cate_id"] = $array["cate_id"]; foreach ($ext_list 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"]); } if ($val) { $tmplist[$value["identifier"]] = $val; } } if ($tid) { $this->model('list')->update_ext($tmplist, $project_rs['module'], $tid); $this->json(P_Lang('内容编辑成功'), true); } $this->model('list')->save_ext($tmplist, $project_rs["module"]); if ($project_rs['etpl_admin']) { $email_rs = $this->model('email')->get_identifier($project_rs['etpl_admin'], $this->site['id']); $email = $this->model('admin')->get_mail(); if ($email_rs && $email) { $tmp = array_merge($tmplist, $array); $tmp['id'] = $insert_id; $this->assign('rs', $tmp); $this->assign('page_rs', $project_rs); $this->assign('user', $_SESSION['user_rs']); $title = $this->fetch($email_rs["title"], "content"); $content = $this->fetch($email_rs["content"], "content"); $this->lib('email')->send_admin($title, $content, $email); } } if ($project_rs['etpl_user']) { $email_rs = $this->model('email')->get_identifier($project_rs['etpl_admin'], $this->site['id']); $email = $this->get('email'); if (!$email && $_SESSION['user_id']) { $user_rs = $this->model('user')->get_one($_SESSION['user_id']); if ($user_rs) { $email = $user_rs['email']; } } if ($email && $email_rs) { $tmp = array_merge($tmplist, $array); $tmp['id'] = $insert_id; $this->assign('rs', $tmp); $this->assign('page_rs', $project_rs); $this->assign('user', $_SESSION['user_rs']); $title = $this->fetch($email_rs["title"], "content"); $content = $this->fetch($email_rs["content"], "content"); $this->lib('email')->send_admin($title, $content, $email); } } $this->json(true); }
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"); }
function ext_save($myid, $is_add = false, $save_id = "") { if ($is_add) { $tmplist = $_SESSION[$myid]; if (!$tmplist) { return false; } foreach ($tmplist as $key => $value) { $val = ext_value($value); $array = array(); $array["module"] = $save_id ? $save_id : $myid; $array["title"] = $value['title']; $array["identifier"] = $value['identifier']; $array["field_type"] = $value['field_type']; $array["note"] = $value['note']; $array["form_type"] = $value['form_type']; $array["form_style"] = $value["form_style"]; $array["format"] = $value["format"]; $array["content"] = $value["content"]; $array["taxis"] = $value["taxis"]; $array["ext"] = $value["ext"]; if ($value["ext"] && $value["content"] && $val) { $tmp = is_string($value['ext']) ? unserialize($value["ext"]) : $value['ext']; if ($value["form_type"] == "password") { $val = ext_password_format($val, $value["content"], $tmp["password_type"]); } $array["ext"] = serialize($tmp); } $insert_id = $GLOBALS['app']->model("ext")->save($array); $GLOBALS['app']->model("ext")->extc_save($val, $insert_id); } $_SESSION[$myid] = ""; } else { $tmplist = $GLOBALS['app']->model("ext")->ext_all($myid); if (!$tmplist) { return false; } foreach ($tmplist as $key => $value) { $val = ext_value($value); if ($value["form_type"] == "password") { $tmp = $value["ext"] ? unserialize($value["ext"]) : ""; if (!$tmp) { $tmp = array(); $tmp["password_type"] = "default"; } $val = ext_password_format($val, $value["content"], $tmp["password_type"]); } $GLOBALS['app']->model("ext")->extc_save($val, $value["id"]); } } return true; }
function ajax_save_f() { $id = $this->get("id"); $chk_rs = $this->check($id); if ($chk_rs["status"] != "ok") { $this->json($chk_rs["info"]); } $p_rs = $chk_rs["info"]; $m_rs = $this->model('module')->get_one($p_rs["module"]); $title = $this->get("title"); if (!$title) { $note = $p_rs["alias_title"] ? $p_rs["alias_title"] : P_Lang('主题'); $this->json($note . P_Lang('不能为空')); } //唯一性验证 $_chk = $this->get("_chk"); if ($_chk) { if ($_chk == 'title') { $sql = "SELECT id FROM " . $this->db->prefix . "list WHERE project_id='" . $p_rs['id'] . "' AND site_id='" . $p_rs['site_id'] . "'"; $sql .= " AND title='" . $title . "' AND module_id='" . $p_rs['module'] . "' LIMIT 1"; } else { $tmp = $this->get($_chk); if (!$tmp) { $this->json(P_Lang('验证不通过,必填项目不能为空')); } $sql = "SELECT id FROM " . $this->db->prefix . "list_" . $p_rs["module"] . " WHERE project_id='" . $p_rs['id'] . "' "; $sql .= "AND site_id='" . $p_rs['site_id'] . "' AND " . $_chk . "='" . $tmp . "' LIMIT 1"; } $chk = $this->db->get_one($sql); if ($chk) { $this->json(P_Lang('验证不通过,信息已存在')); } } $array = array(); $array["title"] = $title; $array["dateline"] = $this->system_time; $array["status"] = 0; $array["hidden"] = 0; $array["module_id"] = $p_rs["module"]; $array["project_id"] = $p_rs["id"]; $array["site_id"] = $p_rs["site_id"]; $array["cate_id"] = $this->get("cate_id", "int"); $insert_id = $this->model('list')->save($array); if (!$insert_id) { $this->json(P_Lang('数据存储失败,请联系管理')); } $ext_list = $this->model('module')->fields_all($p_rs["module"]); $tmplist = array(); $tmplist["id"] = $insert_id; $tmplist["site_id"] = $p_rs["site_id"]; $tmplist["project_id"] = $p_rs["id"]; $tmplist["cate_id"] = $array["cate_id"]; if ($ext_list) { foreach ($ext_list 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('list')->save_ext($tmplist, $p_rs["module"]); //存储扩展字段 $identifier = "content-" . $insert_id; $i_array = array(); $i_array["id"] = $insert_id; $i_array["site_id"] = $p_rs["site_id"]; $i_array["phpok"] = $identifier; $i_array["type_id"] = "content"; $this->model('id')->save($i_array); $this->json(P_Lang('添加成功'), true); }