function article_replace($articleid, $arr) { $article = article_read($articleid); if ($article) { $r = article_update($articleid, $arr); } else { $arr['articleid'] = $articleid; $r = article_create($arr); } return $r; }
!$subject and message(2, '请填写标题'); !$message and message(3, '请填写内容'); $arr = array('cateid' => $cateid, 'subject' => $subject, 'brief' => $brief, 'message' => $message, 'cover' => $cover, 'update_date' => $time, 'seo_title' => $seo_title, 'seo_keywords' => $seo_keywords, 'seo_description' => $seo_description); $r = article_update($articleid, $arr); $r !== FALSE ? message(0, '更新成功') : message(11, '更新失败'); } } elseif ($action == 'delete') { if ($method != 'POST') { message(-1, 'Method Error.'); } $articleid = param('articleid', 0); $state = article_delete($articleid); $state ? message(0, '删除成功') : message(11, '删除失败'); } elseif ($action == 'read') { $articleid = param(2, 0); $article = article_read($articleid); include "./admin/view/article_read.htm"; } elseif ($action == 'upload') { $upfile = param('upfile', '', FALSE); empty($upfile) and message(-1, 'upfile 数据为空'); $json = xn_json_decode($upfile); empty($json) and message(-1, '数据有问题: json 为空'); $name = $json['name']; $width = $json['width']; $height = $json['height']; $data = base64_decode($json['data']); $size = strlen($data); $types = (include './conf/attach.conf.php'); $allowtypes = $types['all']; $filename = $uid . '_' . attach_safe_name($name, $allowtypes); $dir = date('ymd', $time) . '/';