/** * 插入/新增一个管理员执行页面 * @author 陈晓东 */ public function insertAction() { /** * 记录日志 */ $log = "插入/新增一个管理员执行页面\n\nServerIp:\n" . $this->request->getServer('SERVER_ADDR') . "\n\nGET:\n" . var_export($_GET, true) . "\n\nPOST:\n" . var_export($_POST, true); $this->oLogManager->push('log', $log); $PermissionCheck = $this->manager->checkMenuPermission("AddManager"); if ($PermissionCheck['return']) { $name = trim($this->request->name); $password = trim($this->request->password); $confirm = trim($this->request->confirm); $menu_group_id = $this->request->menu_group_id; //用户组 $data_groups = $this->request->data_groups ? implode(',', $this->request->data_groups) : 0; $is_partner = $this->request->is_partner; $nowtime = date("Y:m:d H:i:s"); $bind['name'] = $name; $bind['password'] = md5($password); $bind['menu_group_id'] = $menu_group_id; $bind['data_groups'] = $data_groups; $bind['is_partner'] = $is_partner; $bind['last_login'] = $nowtime; $bind['last_active'] = $nowtime; $bind['reg_date'] = $nowtime; $bind['reg_ip'] = $this->request->getIp(); $bind['reset_password'] = 1; //验证 if (empty($name)) { $response = array('errno' => 4, 'message' => "用户名不能为空,请修正后再次提交"); echo json_encode($response); return false; } if ($password != $confirm) { $response = array('errno' => 1, 'message' => "密码两次输入不一致,请确认后再次提交"); echo json_encode($response); return false; } if (strlen($password) < 6 || strlen($password) > 18) { $response = array('errno' => 3, 'message' => "密码不能少于6位或大于18位,请修正后再次提交"); echo json_encode($response); return false; } $Widget_Manager = new Widget_Manager(); if ($Widget_Manager->nameExists($name)) { $response = array('errno' => 2, 'message' => "用户名已存在,请修正后再次提交"); echo json_encode($response); return false; } //插入 $insert = $Widget_Manager->insert($bind); if (!$insert) { $response = array('errno' => 9, 'message' => "添加用户失败,请修正后再次提交"); } else { $response = array('errno' => 0, 'message' => "添加管理员成功", 'goto' => $this->sign); } echo json_encode($response); return true; } else { $home = $this->sign; include $this->tpl('403'); } }