Example #1
0
 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);
 }