Пример #1
0
 function pic_indexid($content, $aid)
 {
     if (empty($content)) {
         return;
     }
     $content = stripslashes($content);
     preg_match_all("/<img.*?src\\s*=[\"|'](.*?)[\"|']/is", $content, $match);
     $array = array_unique($match[1]);
     $uri = parse_url(iCMS_FS_URL);
     $fArray = array();
     $fpArray = array();
     foreach ($array as $key => $value) {
         $value = trim($value);
         if (stripos($value, $uri['host']) !== false) {
             $filepath = iFS::fp($value, '-http');
             if ($filepath) {
                 $filename = basename($filepath);
                 $filename = substr($filename, 0, 32);
                 $faid = articleTable::filedata_value($filename);
                 empty($faid) && articleTable::filedata_update_indexid($aid, $filename);
             }
         }
     }
 }
Пример #2
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);
 }
Пример #3
0
 public function article($id, $page = 1, $tpl = true)
 {
     $article = iDB::row("SELECT * FROM `#iCMS@__article` WHERE id='" . (int) $id . "' AND `status` ='1' LIMIT 1;", ARRAY_A);
     $article or iPHP::throw404('运行出错!找不到文章: <b>ID:' . $id . '</b>', 10001);
     if ($article['url']) {
         if (iPHP::$iTPL_MODE == "html") {
             return false;
         } else {
             $this->API_hits($id);
             iPHP::gotourl($article['url']);
         }
     }
     if (iCMS_ARTICLE_DATA === "TEXT") {
         iPHP::app('article.table');
         $article_data = articleTable::get_text($id);
     } else {
         $article && ($article_data = iDB::row("SELECT body,subtitle FROM `#iCMS@__article_data` WHERE aid='" . (int) $id . "' LIMIT 1;", ARRAY_A));
     }
     $vars = array('tags' => true, 'user' => true, 'meta' => true, 'prev_next' => true, 'category_lite' => false);
     $article = $this->value($article, $article_data, $vars, $page, $tpl);
     unset($article_data);
     if ($article === false) {
         return false;
     }
     if ($tpl) {
         iCMS::hooks('enable_comment', true);
         $article_tpl = empty($article['tpl']) ? $article['category']['contentTPL'] : $article['tpl'];
         strstr($tpl, '.htm') && ($article_tpl = $tpl);
         iPHP::assign('category', $article['category']);
         unset($article['category']);
         iPHP::assign('article', $article);
         $html = iPHP::view($article_tpl, 'article');
         if (iPHP::$iTPL_MODE == "html") {
             return array($html, $article);
         }
     } else {
         return $article;
     }
 }