/** * 保存 */ public function saveAction() { $form = new \Admin\Menu\Form\editForm(); $form->start('menuEdit', 'edit'); $data = $this->request()->getData(); //获取数据 $id = $data['id']; unset($data['id']); if ($id) { if (!$this->getRequest()->getMethod() == "POST") { //是否为post方式提交 return $this->notFound(); } $data = checkForm::init($data, $form->_name); $res = db()->Table('common_menu')->upDate($data, array('id' => $id))->done(); if ($res) { return $this->link()->success("admin:menu:index", "更新成功"); } else { return $this->link()->error("未更新或更新失败"); } } else { if (!$this->getRequest()->getMethod() == "POST") { return $this->notFound(); } $data = checkForm::init($data, $form->_name); $res = db()->Table('common_menu')->insert($data)->done(); if ($res) { return $this->link()->success("admin:menu:index", "添加栏目成功"); } else { return $this->link()->error("添加栏目失败"); } } }
public function indexAction() { if (session(C('USER_AUTH_KEY')) && session(C('ADMIN_AUTH_KEY'))) { return $this->link()->success("admin:index:index", "跳转中"); } $view = $this->getView(); if ($this->getRequest()->getMethod() == "POST") { //是否为post方式提交 $username = post("username", "string"); $password = post("password", "string"); $form = new \Member\Login\Form\loginForm(); $form->start('login-form'); $data = array('username' => $username, 'password' => $password); //验证表单 $data = checkForm::init($data, $form->_name); if (!$data) { return false; } $LoginVerifyCode = new \Common\Security\CheckLoginSession(); $randVal = $LoginVerifyCode->getSession(); //验证错误次数 大于5次当日禁止登陆 $ip = $this->getRequest()->getIP(); $loginErrorTodayCount = (int) cache("loginErrorTodayCount" . $username . $ip . date("Y-m-d")); //用于密码输入错误次数 if ($loginErrorTodayCount >= 10) { return $this->link()->error("登录失败,您今天超过10次登陆失败,为了账号安全,我们限制账号当天登陆!"); } //用于验证码 $webConfig = new \Admin\Model\webConfigModel(); $webConfig = $webConfig->getConfig(); if ($webConfig['login_code']) { $checkCode = post("verifycode", "string"); if (md5(strtoupper($checkCode)) !== $randVal) { return $this->link()->error("登录失败, 请输入正确的验证码!"); } } $authInfo = \System\Library\Rbac::authenticate($username); if (empty($authInfo)) { return $this->link()->error("账号不存在或者被禁用"); } else { if ($authInfo['password'] != (string) new \Member\Login\Table\Password($password)) { cache("loginErrorTodayCount" . $username . $ip . date("Y-m-d"), ++$loginErrorTodayCount); return $this->link()->error("账号密码错误!"); } else { $server = $this->getServices(); $server->LoginGmc($authInfo); $redirect = urldecode(get("referer", "string")); return $this->link()->dispatchJump($redirect, 3, "登陆成功", true); } } } return $this->getView()->display(); }
/** * 保存用户信息 */ public function saveAction() { $data = $this->request()->getData(); $memberForm = new \Member\Login\Form\infoForm(); $memberForm->start('info'); $data = checkForm::init($data, $memberForm->_name); $member = $this->getMember(); //生成头像 try { db()->upDate($data, array('id' => $member['id']))->done(); return $this->link()->success("admin:user:profile", "保存成功"); } catch (\Exception $e) { Error::halt($e->getMessage()); exit; } }
/** * 保存基本信息 */ public function saveAction() { $form = new \Admin\Config\Form\configForm(); $form->start('config'); //获取数据 $data = $this->request()->getData(); //没有设置的默认赋值为0 foreach ($form->_check as $k => $v) { $data[$k] = $data[$k] ? $data[$k] : 0; } $data = checkForm::init($data, $form->_name); foreach ($data as $k => $v) { db()->table("config")->upDate(array("option_name" => $k, "option_value" => $v), array("option_name" => $k))->done(); } return $this->link()->success("admin:config:index", "更新成功"); }
public function saveAction() { $form = new \Admin\Hoke\Form\editForm(); //获取表单 $form->start('hookEdit'); $data = $this->request()->getData(); //获取数据 $data = checkForm::init($data, $form->_name); $id = $data['id']; if ($id) { unset($data['id']); $res = db()->table("hook")->upDate($data, array('id' => $id))->done(); } else { $data['crate_time'] = date("Y-m-d H:i:s"); $res = db()->table("hook")->insert($data)->done(); } if ($res) { return $this->link()->success("admin:hook:index", "保存成功"); } else { return $this->link()->error("保存失败"); } }
/** * @return mixed */ public function saveAction() { $form = new \Admin\Article\Form\editForm(); //获取表单 $form->start('articleEdit'); $data = $this->request()->getData(); //获取数据 $data['id'] = post("id", 'int'); $data['title'] = post("title", 'string'); $data['tag'] = post("tag", 'string'); $data['category'] = post("category", 'int'); $data['istop'] = post("istop", 'int'); $data['allow_comment'] = post("allow_comment", 'int'); $data['content'] = post("content", 'html'); $data['excerpt'] = post("excerpt", 'html'); $data = checkForm::init($data, $form->_name); $id = $data['id']; unset($data['id']); $data['time'] = date("Y-m-d H:i:s"); $member = $this->getMember(); $data['member_id'] = $member['id']; //处理日志缩略图(空则取文章第一张,文章没有则取默认图片) if ($_FILES['thumbnail']['name']) { /* 上传文件old //thumbnail不为空 $targetFolder = 'Data/upload/image/article'; // Relative to the root //验证来路合法性 //验证图片合法性 $fstat = $_FILES[\Admin\Config\Type\Images::FILE_OBJ_NAME]; $fileParts = pathinfo($fstat['name']); $type = explode(";", \Admin\Config\Type\Images::FILE_TYPE_EXTS); $types = array(); foreach ($type as $v) { $types[] = str_replace("*.", "", $v); } if (!in_array($fileParts['extension'], $types)) { return $this->link()->error("文章缩略图类型错误!"); } if (round($fstat["size"] / 1024, 2) > \Admin\Config\Type\Images::FILE_SIZE_LIMIT) { return $this->link()->error("文章缩略图超出文件大小!"); } $tempFile = $fstat['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] .$targetFolder; $member = $this->getMember(); //检验目录 $targetDir = rtrim($targetPath, '/') . '/' . $member['id']; if (!file_exists($targetDir)) { mkdir($targetDir,0777,true); } //move_uploaded_file $code = time().rand(0,9999); $targetFile = $targetDir . '/yt_' . md5($member['id'].$code) . "." . $fileParts['extension']; move_uploaded_file($tempFile, $targetFile);*/ $upload = new \Common\Upload\Upload(); // 实例化上传类 // 上传文件 $fileInfo = $upload->upload("image", "thumbnail", "upload"); if (!$fileInfo) { // 上传错误提示错误信息 trace($upload->getError()); } else { // 上传成功 获取上传文件信息 /* * 调试用 * foreach ($info as $file) { echo $file['savepath'] . $file['savename']; }*/ } //保存 $data['thumbnail'] = $fileInfo['thumbnail']['url']; } elseif ($data['content']) { //thumbnail为空 preg_match("<img.*src=[\"](.*?)[\"].*?>", $data['content'], $match); $data['thumbnail'] = "{$match['1']}"; } else { $data['thumbnail'] = ""; } // 处理标签 $tags = !empty($data['tag']) ? preg_split("/[,\\s]|(,)/", $data['tag']) : array(); $tags = array_filter(array_unique($tags)); foreach ($tags as $tagName) { $result = db()->table("article_tag")->getRow(array("tagname" => $tagName))->done(); if (empty($result)) { db()->Table('article_tag')->insert(array("tagname" => $tagName, "gid" => $id))->done(); } else { $gid = $result['gid']; $gids = strpos($gid, $id) ? $gid : $gid . "," . $id; db()->Table('article_tag')->upDate(array("gid" => $gids), array('tagname' => $tagName))->done(); } } unset($data['tag']); //更新 $res = db()->table("article")->upDate($data, array('id' => $id))->done(); if ($res) { return $this->link()->success("admin:article:list", "保存成功"); } else { return $this->link()->error("保存失败"); } }
public function sellerEditSaveAction() { $form = new \Admin\Jutuan\Form\sellerEditForm(); //获取表单 $form->start('sellerEdit'); $data = $this->request()->getData(); //获取数据 $data = checkForm::init($data, $form->_name); $seller_id = $data['seller_id']; unset($data['seller_id']); //更新 $res = db("jutuan")->table("td_seller_info")->upDate($data, array('seller_id' => $seller_id))->done(); if ($res) { return $this->link()->success("admin:jutuan:sellerSync", "更新成功"); } else { return $this->link()->error("更新失败"); } }