示例#1
0
 function article_data($bodyArray, $aid = 0, $haspic = 0)
 {
     $id = (int) $_POST['adid'];
     $subtitle = iS::escapeStr($_POST['subtitle']);
     $body = implode('#--iCMS.PageBreak--#', $bodyArray);
     $body = preg_replace(array('/<script.+?<\\/script>/is', '/<form.+?<\\/form>/is'), '', $body);
     isset($_POST['dellink']) && ($body = preg_replace("/<a[^>].*?>(.*?)<\\/a>/si", "\\1", $body));
     iCMS::$config['publish']['autoformat'] && ($body = autoformat($body));
     articleTable::$ID = $aid;
     $fields = articleTable::data_fields($id);
     $data = compact($fields);
     if ($id) {
         articleTable::data_update($data, compact('id'));
     } else {
         $id = articleTable::data_insert($data);
     }
     if ($this->callback['data']) {
         $DCB = $this->callback['data'];
         $handler = $DCB[0];
         $params = (array) $DCB[1];
         if (is_callable($handler)) {
             call_user_func_array($handler, $params);
         }
     }
     $_POST['isredirect'] && (iFS::$redirect = true);
     $_POST['iswatermark'] && (iFS::$watermark = false);
     if (isset($_POST['remote'])) {
         $body = $this->remotepic($body, true, $aid);
         $body = $this->remotepic($body, true, $aid);
         $body = $this->remotepic($body, true, $aid);
         if ($body && $id) {
             articleTable::data_update(array('body' => $body), compact('id'));
         }
     }
     if (isset($_POST['autopic']) && empty($haspic)) {
         $picurl = $this->remotepic($body, 'autopic', $aid);
         $this->pic($picurl, $aid);
     }
     $this->pic_indexid($body, $aid);
 }
示例#2
0
文件: user.app.php 项目: sunhk25/iCMS
 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);
 }
示例#3
0
 function body($body, $subtitle, $aid = 0, $id = 0, &$haspic = 0)
 {
     $body = preg_replace(array('/<script.+?<\\/script>/is', '/<form.+?<\\/form>/is'), '', $body);
     isset($_POST['dellink']) && ($body = preg_replace("/<a[^>].*?>(.*?)<\\/a>/si", "\\1", $body));
     if (isset($_POST['markdown'])) {
         $body = '#--iCMS.Markdown--#' . $body;
     } else {
         iCMS::$config['publish']['autoformat'] && ($body = addslashes(autoformat($body)));
     }
     articleTable::$ID = $aid;
     $fields = articleTable::data_fields($id);
     $data = compact($fields);
     if ($id) {
         articleTable::data_update($data, compact('id'));
     } else {
         $id = articleTable::data_insert($data);
     }
     $_POST['isredirect'] && (iFS::$redirect = true);
     $_POST['iswatermark'] && (iFS::$watermark = false);
     if (isset($_POST['remote'])) {
         $body = $this->remotepic($body, true, $aid);
         $body = $this->remotepic($body, true, $aid);
         $body = $this->remotepic($body, true, $aid);
         if ($body && $id) {
             articleTable::data_update(array('body' => $body), compact('id'));
         }
     }
     if (isset($_POST['autopic']) && empty($haspic)) {
         if ($picurl = $this->remotepic($body, 'autopic', $aid)) {
             $this->pic($picurl, $aid);
             $haspic = true;
         }
     }
     $this->pic_indexid($body, $aid);
 }