private function __action_manage_publish() { $aid = (int) $_POST['id']; $cid = (int) $_POST['cid']; $_cid = (int) $_POST['_cid']; $ucid = (int) $_POST['ucid']; $_ucid = (int) $_POST['_ucid']; $mobile = (int) $_POST['mobile']; $title = iS::escapeStr($_POST['title']); $source = iS::escapeStr($_POST['source']); $keywords = iS::escapeStr($_POST['keywords']); $description = iS::escapeStr($_POST['description']); $creative = (int) $_POST['creative']; $userid = user::$userid; $author = user::$nickname; $editor = user::$nickname; if (iCMS::$config['user']['post']['seccode']) { $seccode = iS::escapeStr($_POST['seccode']); iPHP::seccode($seccode, true) or iPHP::alert('iCMS:seccode:error'); } if (iCMS::$config['user']['post']['interval']) { $last_postime = iDB::value("\n SELECT MAX(postime)\n FROM `#iCMS@__article`\n WHERE userid='" . user::$userid . "'"); if ($_SERVER['REQUEST_TIME'] - $last_postime < iCMS::$config['user']['post']['interval']) { iPHP::alert('user:publish:interval'); } } if ($mobile) { $_POST['body'] = ubb2html($_POST['body']); $_POST['body'] = trim($_POST['body']); } $body = iPHP::cleanHtml($_POST['body']); empty($title) && iPHP::alert('标题不能为空!'); empty($cid) && iPHP::alert('请选择所属栏目!'); empty($body) && iPHP::alert('文章内容不能为空!'); $fwd = iCMS::filter($title); $fwd && iPHP::alert('user:publish:filter_title'); $fwd = iCMS::filter($description); $fwd && iPHP::alert('user:publish:filter_desc'); $fwd = iCMS::filter($body); $fwd && iPHP::alert('user:publish:filter_body'); $articleApp = iPHP::app("admincp.article.app"); if (empty($description)) { $description = $articleApp->autodesc($body); } $pubdate = time(); $postype = "0"; $category = iCache::get('iCMS/category/' . $cid); $status = $category['isexamine'] ? 3 : 1; iPHP::import(iPHP_APP_CORE . '/iMAP.class.php'); iPHP::app('article.table'); $fields = articleTable::fields($aid); $data_fields = articleTable::data_fields($aid); if (empty($aid)) { $postime = $pubdate; $chapter = $hits = $good = $bad = $comments = 0; $data = compact($fields); $aid = articleTable::insert($data); $article_data = compact($data_fields); articleTable::data_insert($article_data); map::init('category', iCMS_APP_ARTICLE); map::add($cid, $aid); iDB::query("UPDATE `#iCMS@__user_category` SET `count` = count+1 WHERE `cid` = '{$ucid}' AND `uid`='" . user::$userid . "' AND `appid`='" . iCMS_APP_ARTICLE . "';"); user::update_count(user::$userid, 1, 'article'); $lang = array('1' => 'user:article:add_success', '3' => 'user:article:add_examine'); } else { if (articleTable::update(compact($fields), array('id' => $aid, 'userid' => user::$userid))) { articleTable::data_update(compact($data_fields), array('aid' => $aid)); } map::init('category', iCMS_APP_ARTICLE); map::diff($cid, $_cid, $aid); if ($ucid != $_ucid) { iDB::query("UPDATE `#iCMS@__user_category` SET `count` = count+1 WHERE `cid` = '{$ucid}' AND `uid`='" . user::$userid . "' AND `appid`='" . iCMS_APP_ARTICLE . "';"); iDB::query("UPDATE `#iCMS@__user_category` SET `count` = count-1 WHERE `cid` = '{$_ucid}' AND `uid`='" . user::$userid . " AND `count`>0' AND `appid`='" . iCMS_APP_ARTICLE . "';"); } $lang = array('1' => 'user:article:update_success', '3' => 'user:article:update_examine'); } $url = iPHP::router('/user/article', iPHP_ROUTER_REWRITE); iPHP::success($lang[$status], 'url:' . $url); }
function do_save($callback = false) { $aid = (int) $_POST['aid']; $cid = (int) $_POST['cid']; $userid = (int) $_POST['userid']; $scid = implode(',', (array) $_POST['scid']); $pid = implode(',', (array) $_POST['pid']); $status = (int) $_POST['status']; $chapter = (int) $_POST['chapter']; $ordernum = _int($_POST['ordernum']); $_cid = iS::escapeStr($_POST['_cid']); $_pid = iS::escapeStr($_POST['_pid']); $_scid = iS::escapeStr($_POST['_scid']); $_tags = iS::escapeStr($_POST['_tags']); $title = iS::escapeStr($_POST['title']); $stitle = iS::escapeStr($_POST['stitle']); $pic = iS::escapeStr($_POST['pic']); $mpic = iS::escapeStr($_POST['mpic']); $spic = iS::escapeStr($_POST['spic']); $source = iS::escapeStr($_POST['source']); $author = iS::escapeStr($_POST['author']); $editor = iS::escapeStr($_POST['editor']); $description = iS::escapeStr($_POST['description']); $keywords = iS::escapeStr($_POST['keywords']); $tags = str_replace(',', ',', iS::escapeStr($_POST['tags'])); $clink = iS::escapeStr($_POST['clink']); $url = iS::escapeStr($_POST['url']); $tpl = iS::escapeStr($_POST['tpl']); $metadata = iS::escapeStr($_POST['metadata']); $metadata = $metadata ? addslashes(serialize($metadata)) : ''; $body = (array) $_POST['body']; $creative = (int) $_POST['creative']; iACP::CP($cid, $aid ? 'ce' : 'ca', 'alert'); empty($_POST['pubdate']) && ($_POST['pubdate'] = get_date(0, 'Y-m-d H:i:s')); $pubdate = iPHP::str2time($_POST['pubdate']); $weight = _int($_POST['weight']); $postype = $_POST['postype'] ? $_POST['postype'] : 0; $ischapter = isset($_POST['ischapter']) ? 1 : 0; isset($_POST['inbox']) && ($status = "0"); $tags && ($tags = preg_replace('/<[\\/\\!]*?[^<>]*?>/is', '', $tags)); empty($title) && iPHP::alert('标题不能为空!'); empty($cid) && iPHP::alert('请选择所属栏目'); empty($body) && empty($url) && iPHP::alert('文章内容不能为空!'); $userid or $userid = iMember::$userid; iFS::$userid = $userid; if (empty($aid) && iCMS::$config['publish']['repeatitle']) { articleTable::check_title($title) && iPHP::alert('该标题的文章已经存在!请检查是否重复'); } if (strstr($this->category[$cid]['contentRule'], '{LINK}') !== false) { empty($clink) && ($clink = strtolower(pinyin($title))); if (empty($aid) && $clink) { articleTable::check_clink($clink) && iPHP::alert('该文章自定义链接已经存在!请检查是否重复'); } } if (empty($description) && empty($url)) { $description = $this->autodesc($body); } stripos($pic, 'http://') === false or $pic = iFS::http($pic); stripos($mpic, 'http://') === false or $mpic = iFS::http($mpic); stripos($spic, 'http://') === false or $spic = iFS::http($spic); $haspic = empty($pic) ? 0 : 1; $SELFURL = __SELF__ . $_POST['REFERER']; if (empty($_POST['REFERER']) || strstr($_POST['REFERER'], '=save')) { $SELFURL = __SELF__ . '?app=article&do=manage'; } $editor or $editor = empty(iMember::$data->nickname) ? iMember::$data->username : iMember::$data->nickname; // if($aid && $ischapter){ // $this->article_data($body,$aid); // iDB::query("UPDATE `#iCMS@__article` SET `chapter`=chapter+1 WHERE `id` = '$aid'"); // iPHP::success('章节添加完成!','url:'.$SELFURL); // } iPHP::import(iPHP_APP_CORE . '/iMAP.class.php'); $picdata = ''; $ucid = 0; $fields = articleTable::fields($aid); if (empty($aid)) { $postime = $pubdate; $hits = 0; $good = $bad = $comments = 0; $ischapter && ($chapter = 1); $mobile = 0; $aid = articleTable::insert(compact($fields)); if ($this->callback['primary']) { $PCB = $this->callback['primary']; $handler = $PCB[0]; $params = (array) $PCB[1] + array('indexid' => $aid); if (is_callable($handler)) { call_user_func_array($handler, $params); } } if ($tags) { iPHP::app('tag.class', 'static'); tag::add($tags, $userid, $aid, $cid); //articleTable::update(compact('tags'),array('id'=>$aid)); } map::init('prop', $this->appid); $pid && map::add($pid, $aid); map::init('category', $this->appid); map::add($cid, $aid); $scid && map::add($scid, $aid); $tagArray && tag::map_iid($tagArray, $aid); $url or $this->article_data($body, $aid, $haspic); $this->categoryApp->update_count_one($cid); $article_url = iURL::get('article', array(array('id' => $aid, 'url' => $url, 'cid' => $cid, 'pubdate' => $pubdate), $this->category[$cid]))->href; if ($status && iCMS::$config['api']['baidu']['sitemap']['sync']) { baidu_ping($article_url); } if ($callback) { return array("code" => $callback, 'indexid' => $aid); } $moreBtn = array(array("text" => "查看该文章", "target" => '_blank', "url" => $article_url, "o" => 'target="_blank"'), array("text" => "编辑该文章", "url" => APP_URI . "&do=add&id=" . $aid), array("text" => "继续添加文章", "url" => APP_URI . "&do=add&cid=" . $cid), array("text" => "返回文章列表", "url" => $SELFURL), array("text" => "查看网站首页", "url" => iCMS_URL, "target" => '_blank')); iPHP::$dialog['lock'] = true; iPHP::dialog('success:#:check:#:文章添加完成!<br />10秒后返回文章列表', 'url:' . $SELFURL, 10, $moreBtn); } else { if ($tags) { iPHP::app('tag.class', 'static'); tag::diff($tags, $_tags, iMember::$userid, $aid, $cid); } $picdata = $this->picdata($pic, $mpic, $spic); articleTable::update(compact($fields), array('id' => $aid)); if ($this->callback['primary']) { $PCB = $this->callback['primary']; $handler = $PCB[0]; $params = (array) $PCB[1] + array('indexid' => $aid); if (is_callable($handler)) { call_user_func_array($handler, $params); } } map::init('prop', $this->appid); map::diff($pid, $_pid, $aid); map::init('category', $this->appid); map::diff($cid, $_cid, $aid); map::diff($scid, $_scid, $aid); $url or $this->article_data($body, $aid, $haspic); //$ischapter && $this->chapter_count($aid); if ($_cid != $cid) { $this->categoryApp->update_count_one($_cid, '-'); $this->categoryApp->update_count_one($cid); } if ($callback) { return array("code" => $callback, 'indexid' => $aid); } // if(!strstr($this->category[$cid]['contentRule'],'{PHP}')&&!$this->category[$cid]['url']&&$this->category[$cid]['mode']=="1" && $status) { // $htmlApp = iACP::app('html'); // $htmlApp->Article($aid); // } iPHP::success('文章编辑完成!<br />3秒后返回文章列表', 'url:' . $SELFURL); } }