/** * 编辑文章 * By:0x584A * Date:2015年9月21日 12:54:46 */ public function editartice() { $aid = intval($_REQUEST['aid']); // 标题 $data['a_title'] = trim($_REQUEST['title']); // 发布时间 $data['a_time'] = $_SERVER['REQUEST_TIME']; // 内容 $data['a_content'] = htmlspecialchars(addslashes($_REQUEST['content'])); // 分类 $data['s_id'] = intval($_REQUEST['typeid']); // 发布人昵称 $data['a_username'] = $_SESSION['adminuser']['u_name']; // 是否选择热门 $data['a_hot'] = isset($_REQUEST['is_hot']) ? 1 : 0; // 额外关键字 $data['a_keywords'] = trim($_REQUEST['keywords']); // 缩略图片 $data['a_thumb_img'] = trim($_REQUEST['img']); // 验证 if (empty($data['a_title']) || empty($data['a_content']) || empty($data['a_content']) || $data['s_id'] < 1) { $this->error('index.php?c=index&a=editartice&editid=' . $aid, '修改文章中存在为空的数据,请认真填写...'); } if (!empty($_FILES['articleimage'])) { // 载入文件上传白名单 $mime = $GLOBALS['config']['admin_goods_upload_mime']; // 上传图片并判断 if ($imgfile = Uploads::uploadsfile($_FILES['articleimage'], UPLOADS_DIR, $mime)) { // 制作缩略图 if ($thumbname = Images::makeThumb(UPLOADS_DIR . "/" . $imgfile, UPLOADS_DIR)) { // 成功 $data['a_thumb_img'] = $thumbname; $logs = new LogsModel(); $logs->insertOne($_SESSION['adminuser']['u_name'] . "上传头像成功:{$thumbname}"); } else { // 失败写入到系统日志中 $logs = new LogsModel(); $logs->insertOne($_SESSION['adminuser']['u_name'] . "上传头像失败:<font style='color:red'>{$imgfile}</b></font>"); } } } // 实例化 $article = new ArticeModel(); if ($article->updateArtice($data, $aid)) { $logs = new LogsModel(); $logs->insertOne($_SESSION['adminuser']['u_name'] . "修改文章【" . $data['a_title'] . "】成功"); $this->success('index.php?c=index&a=listartice', '修改成功...'); } else { $logs = new LogsModel(); $logs->insertOne($_SESSION['adminuser']['u_name'] . "修改文章" . $data['a_title'] . "<font style='color:red'>失败</font>"); $this->error('index.php?c=index&a=editartice&editid=' . $aid, '修改失败,请联系管理员...'); } }