Exemplo n.º 1
0
 public function value($tag)
 {
     $categoryApp = iPHP::app("category");
     if ($tag['cid']) {
         $category = $categoryApp->category($tag['cid'], false);
         $tag['category'] = $categoryApp->get_lite($category);
     }
     if ($tag['tcid']) {
         $tag_category = $categoryApp->category($tag['tcid'], false);
         $tag['tag_category'] = $categoryApp->get_lite($tag_category);
     }
     $tag['iurl'] = iURL::get('tag', array($tag, $category, $tag_category));
     $tag['url'] or $tag['url'] = $tag['iurl']->href;
     $tag['link'] = '<a href="' . $tag['url'] . '" class="tag" target="_blank">' . $tag['name'] . '</a>';
     if ($category['mode'] && stripos($tag['url'], '.php?') === false) {
         iCMS::set_html_url($tag['iurl']);
     }
     $tag['metadata'] && ($tag['meta'] = json_decode($tag['metadata']));
     $tag['related'] && ($tag['relArray'] = explode(',', $tag['related']));
     $tag['appid'] = iCMS_APP_TAG;
     $tag['pic'] = get_pic($tag['pic']);
     $tag['bpic'] = get_pic($tag['bpic']);
     $tag['mpic'] = get_pic($tag['mpic']);
     $tag['spic'] = get_pic($tag['spic']);
     return $tag;
 }
Exemplo n.º 2
0
 public static function cache($value = 0, $field = 'id')
 {
     $rs = self::data($value, $field);
     $_count = count($rs);
     for ($i = 0; $i < $_count; $i++) {
         $C = iCache::get('iCMS/category/' . $rs[$i]['cid']);
         $TC = iCache::get('iCMS/category/' . $rs[$i]['tcid']);
         $rs[$i]['iurl'] = iURL::get('tag', array($rs[$i], $C, $TC));
         $rs[$i]['url'] = $rs[$i]['iurl']->href;
         $tkey = self::tkey($rs[$i]['cid']);
         iCache::set($tkey, $rs[$i], 0);
     }
 }
Exemplo n.º 3
0
 public static function init()
 {
     self::$config = iPHP::config();
     iURL::init(self::$config['router']);
     define('iCMS_DIR', self::$config['router']['DIR']);
     define('iCMS_URL', self::$config['router']['URL']);
     define('iCMS_PUBLIC_URL', self::$config['router']['public_url']);
     define('iCMS_FS_URL', self::$config['FS']['url']);
     define('iCMS_REWRITE', iPHP_ROUTER_REWRITE);
     define('iCMS_API', iCMS_PUBLIC_URL . '/api.php');
     define('iCMS_UI', iCMS_DIR . 'app/ui/common');
     define('iCMS_UI_URL', iCMS_URL . '/app/ui/common');
     define('iCMS_API_URL', iCMS_API . '?app=');
     self::assign_site();
 }
Exemplo n.º 4
0
 public function index($a = null)
 {
     $index_name = $a[1] ? $a[1] : iCMS::$config['template']['index_name'];
     $index_tpl = $a[0] ? $a[0] : iCMS::$config['template']['index'];
     $index_name or $index_name = 'index';
     $iurl = iURL::get('index', array('urlRule' => $index_name . iCMS::$config['router']['html_ext']));
     if (iCMS::$config['template']['index_mode'] && iPHP_DEVICE == "desktop") {
         iCMS::gotohtml($iurl->path, $iurl->href);
     }
     if (iPHP::$iTPL_MODE == "html" || iCMS::$config['template']['index_rewrite']) {
         iCMS::set_html_url($iurl);
     }
     $html = iPHP::view($index_tpl);
     if (iPHP::$iTPL_MODE == "html") {
         return array($html, $iurl);
     }
 }
Exemplo n.º 5
0
 public function __construct($appid = iCMS_APP_ARTICLE)
 {
     $this->appid = $appid;
     $sql = "WHERE `appid`='{$this->appid}'";
     $this->appid === 'all' && ($sql = '');
     $rs = iDB::all("SELECT * FROM `#iCMS@__category` {$sql} ORDER BY `ordernum` , `cid` ASC");
     foreach ((array) $rs as $C) {
         $C['iurl'] = iURL::get('category', $C);
         $this->_array[$C['rootid']][$C['cid']] = $C;
         $this->rootid[$C['rootid']][$C['cid']] = $C['cid'];
         $this->category[$C['cid']] = $C;
         $this->parent[$C['cid']] = $C['rootid'];
     }
     foreach ((array) $this->_array as $rootid => $_array) {
         uasort($_array, "order_num");
         $this->_array[$rootid] = $_array;
     }
 }
Exemplo n.º 6
0
 public static function init()
 {
     self::config();
     iFS::init(self::$config['FS'], self::$config['watermark'], 'filedata');
     iCache::init(self::$config['cache']);
     iURL::init(self::$config['router']);
     iPHP::iTemplate();
     iPHP_DEBUG && (iDB::$show_errors = true);
     iPHP_TPL_DEBUG && iPHP::clear_compiled_tpl();
     define('iCMS_DIR', self::$config['router']['DIR']);
     define('iCMS_URL', self::$config['router']['URL']);
     define('iCMS_PUBLIC_URL', self::$config['router']['public_url']);
     define('iCMS_USER_URL', self::$config['router']['user_url']);
     define('iCMS_FS_URL', self::$config['FS']['url']);
     define('iCMS_REWRITE', self::$config['router']['rewrite']);
     define('iCMS_API', iCMS_PUBLIC_URL . '/api.php');
     define('iCMS_UI', iCMS_DIR . 'app/ui/common');
     define('iCMS_UI_URL', iCMS_URL . '/app/ui/common');
     self::$apps = self::$config['apps'];
     self::assign_site();
 }
Exemplo n.º 7
0
 function listbtn($rs)
 {
     $a = '<a href="' . iURL::get('category', $rs)->href . '" class="btn btn-small"><i class="fa fa-link"></i> 访问</a> ';
     iACP::CP($rs['cid'], 'ca') && ($a .= '<a href="' . __ADMINCP__ . '=' . $this->_app . '&do=add&' . $this->_app_cid . '=' . $rs['cid'] . '" class="btn btn-small"><i class="fa fa-edit"></i> 添加' . $this->_app_name . '</a> ');
     iACP::CP($rs['cid'], 'cs') && ($a .= '<a href="' . __ADMINCP__ . '=' . $this->_app . '&' . $this->_app_cid . '=' . $rs['cid'] . '&sub=on" class="btn btn-small"><i class="fa fa-list-alt"></i> ' . $this->_app_name . '管理</a> ');
     return $a;
 }
Exemplo n.º 8
0
            <th>排序</th>
            <th>标签</th>
            <th>栏目</th>
            <th>分类</th>
            <th>属性</th>
            <th style="width:28px;">使用</th>
            <th class="span2">最后更新时间</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          <?php 
for ($i = 0; $i < $_count; $i++) {
    $C = $this->categoryApp->category[$rs[$i]['cid']];
    $TC = $this->tagcategory->category[$rs[$i]['tcid']];
    $iurl = iURL::get('tag', array($rs[$i], $C, $TC));
    $rs[$i]['url'] = $iurl->href;
    ?>
          <tr id="tr<?php 
    echo $rs[$i]['id'];
    ?>
">
            <td><input type="checkbox" name="id[]" value="<?php 
    echo $rs[$i]['id'];
    ?>
" /></td>
            <td><?php 
    echo $rs[$i]['id'];
    ?>
</td>
            <td class="ordernum"><input type="text" name="ordernum[<?php 
Exemplo n.º 9
0
              <th class="span1">ID</th>
              <th>标题</th>
              <th class="span2">日期</th>
              <th style="width:80px;">栏目</th>
              <th style="width:60px;">编辑</th>
              <th class="span1">点/评</th>
              <th style="width:120px;">操作</th>
            </tr>
          </thead>
          <tbody>
            <?php 
if ($rs) {
    foreach ($rs as $key => $value) {
        $ourl = $value['url'];
        $C = $this->category[$value['cid']];
        $iurl = iURL::get('article', array($value, $C));
        empty($ourl) && ($htmlurl = $iurl->path);
        $value['url'] = $iurl->href;
        ?>
            <tr id="id<?php 
        echo $value['id'];
        ?>
">
              <td><input type="checkbox" name="id[]" value="<?php 
        echo $value['id'];
        ?>
" /></td>
              <td>
                <?php 
        echo $value['id'];
        ?>
Exemplo n.º 10
0
 public function get_lite($C)
 {
     $C['iurl'] or $C['iurl'] = (array) iURL::get('category', $C);
     $category = array();
     $category['name'] = $C['name'];
     $category['description'] = $C['description'];
     $category['subname'] = $C['subname'];
     $category['sname'] = $C['subname'];
     // $category['pic']         = $C['pic'];
     $category['navArray'] = $this->get_nav($C);
     $category['url'] = $C['iurl']['href'];
     $category['link'] = "<a href='{$C['url']}'>{$C['name']}</a>";
     $category['pic'] = is_array($C['pic']) ? $C['pic'] : get_pic($C['pic']);
     $category['mpic'] = is_array($C['mpic']) ? $C['mpic'] : get_pic($C['mpic']);
     $category['spic'] = is_array($C['spic']) ? $C['spic'] : get_pic($C['spic']);
     if ($C['rootid']) {
         $_parent = iCache::get('iCMS/category/' . $C['rootid']);
         $category['parent'] = $this->get_lite($_parent);
         unset($_parent);
     }
     $category['nav'] = '';
     krsort($category['navArray']);
     if ($category['navArray']) {
         foreach ($category['navArray'] as $key => $value) {
             $category['nav'] .= "<li><a href='{$value['href']}'>{$value['name']}</a><span class=\"divider\">" . iPHP::lang('iCMS:navTag') . "</span></li>";
         }
     }
     return $category;
 }
Exemplo n.º 11
0
 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);
     }
 }
Exemplo n.º 12
0
function category_list($vars)
{
    $appid = isset($vars['appid']) ? (int) $vars['appid'] : iCMS_APP_ARTICLE;
    $row = isset($vars['row']) ? (int) $vars['row'] : "100";
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : "-1";
    $status = isset($vars['status']) ? (int) $vars['status'] : "1";
    $where_sql = " WHERE `appid`='{$appid}' AND `status`='{$status}'";
    $resource = array();
    isset($vars['mode']) && ($where_sql .= " AND `mode` = '{$vars['mode']}'");
    if (stripos($vars['cid'], ',') !== false) {
        $vars['cid'] = explode(',', $vars['cid']);
    }
    if (stripos($vars['cid!'], ',') !== false) {
        $vars['cid!'] = explode(',', $vars['cid!']);
    }
    isset($vars['cid']) && !isset($vars['stype']) && ($where_sql .= iPHP::where($vars['cid'], 'cid'));
    isset($vars['cid!']) && ($where_sql .= iPHP::where($vars['cid!'], 'cid', 'not'));
    switch ($vars['stype']) {
        case "top":
            $vars['cid'] && ($where_sql .= iPHP::where($vars['cid'], 'cid'));
            $where_sql .= " AND rootid='0'";
            break;
        case "sub":
            $vars['cid'] && ($where_sql .= iPHP::where($vars['cid'], 'rootid'));
            break;
            // case "subtop":
            // 	$vars['cid'] && $where_sql.= iPHP::where($vars['cid'],'cid');
            // break;
        // case "subtop":
        // 	$vars['cid'] && $where_sql.= iPHP::where($vars['cid'],'cid');
        // break;
        case "suball":
            $where_sql .= iPHP::where(iCMS::get_category_ids($vars['cid'], false), 'cid');
            break;
        case "self":
            $parent = iCache::get('iCMS/category/parent', $vars['cid']);
            $where_sql .= " AND `rootid`='{$parent}'";
            break;
    }
    if (isset($vars['pids'])) {
        iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
        map::init('prop', iCMS_APP_CATEGORY);
        $where_sql .= map::exists($vars['pids'], '`#iCMS@__category`.cid');
        //主表小 map表大
        //		$map_where=map::where($vars['pids']); //主表大 map表大
        //		$map_ids    = map::ids($vars['pid']);
        //		$map_sql    = map::sql($vars['pid']); //map 表小的用 in
        //		$where_sql.=" AND `pid` = '{$vars['pid']}'";
        //if(empty($map_ids)) return $resource;
        //$where_sql.=" AND `cid` IN ($map_ids)";
        //$where_sql.=" AND `cid` IN ($map_sql)";
    }
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/category/' . md5($where_sql);
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $rootid_array = iCache::get('iCMS/category/rootid');
        $resource = iDB::all("SELECT * FROM `#iCMS@__category` {$where_sql} ORDER BY `ordernum`,`cid` ASC LIMIT {$row}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        if ($resource) {
            foreach ($resource as $key => $value) {
                $value['child'] = $rootid_array[$value['cid']] ? true : false;
                $value['url'] = iURL::get('category', $value)->href;
                $value['link'] = "<a href='{$value['url']}'>{$value['name']}</a>";
                if ($value['metadata']) {
                    $mdArray = array();
                    $_metadata = unserialize($value['metadata']);
                    foreach ((array) $_metadata as $mkey => $md) {
                        $mdArray[$mkey] = $md;
                    }
                    $value['metadata'] = $mdArray;
                    unset($_metadata);
                }
                unset($value['contentprop']);
                $resource[$key] = $value;
            }
        }
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Exemplo n.º 13
0
 public function value($article, $art_data = "", $vars = array(), $page = 1, $tpl = false)
 {
     $article['appid'] = iCMS_APP_ARTICLE;
     $categoryApp = iPHP::app("category");
     $category = $categoryApp->category($article['cid'], false);
     if ($tpl) {
         $category or iPHP::throw404('运行出错!找不到该文章的栏目缓存<b>cid:' . $article['cid'] . '</b> 请更新栏目缓存或者确认栏目是否存在', 10002);
     } else {
         if (empty($category)) {
             return false;
         }
     }
     if ($category['status'] == 0) {
         return false;
     }
     if (iPHP::$iTPL_MODE == "html" && $tpl && (strstr($category['contentRule'], '{PHP}') || $category['outurl'] || $category['mode'] == "0")) {
         return false;
     }
     $_iurlArray = array($article, $category);
     $article['iurl'] = iURL::get('article', $_iurlArray, $page);
     $article['url'] = $article['iurl']->href;
     $article['link'] = "<a href='{$article['url']}'>{$article['title']}</a>";
     $tpl && $category['mode'] == '1' && iCMS::gotohtml($article['iurl']->path, $article['iurl']->href);
     if ($vars['category_lite']) {
         $article['category'] = $categoryApp->get_lite($category);
     } else {
         $article['category'] = $category;
     }
     $this->taoke = false;
     if ($art_data) {
         $pageurl = $article['iurl']->pageurl;
         // if(strpos($art_data['body'], '#--iCMS.ArticleData--#')!==false){
         //     iPHP::app('article.table');
         //     $art_data['body'] = articleTable::get_text($article['id']);
         // }
         $art_data['body'] = $this->ubb($art_data['body']);
         preg_match_all("/<img.*?src\\s*=[\"|'|\\s]*(http:\\/\\/.*?\\.(gif|jpg|jpeg|bmp|png)).*?>/is", $art_data['body'], $pic_array);
         $p_array = array_unique($pic_array[1]);
         if ($p_array) {
             foreach ($p_array as $key => $_pic) {
                 $article['pics'][$key] = trim($_pic);
             }
         }
         if (strpos($art_data['body'], '#--iCMS.Markdown--#') !== false) {
             $art_data['body'] = iPHP::Markdown($art_data['body']);
         }
         $body = explode('#--iCMS.PageBreak--#', $art_data['body']);
         $count = count($body);
         $total = $count + intval(iCMS::$config['article']['pageno_incr']);
         $article['body'] = $this->keywords($body[intval($page - 1)]);
         $article['body'] = $this->taoke($article['body']);
         $article['subtitle'] = $art_data['subtitle'];
         $article['taoke'] = $this->taoke;
         unset($art_data);
         if ($total > 1) {
             $flag = 0;
             $num_nav = '';
             for ($i = $page - 3; $i <= $page - 1; $i++) {
                 if ($i < 1) {
                     continue;
                 }
                 $num_nav .= "<a href='" . iPHP::p2num($pageurl, $i) . "' target='_self'>{$i}</a>";
                 $flag++;
             }
             $num_nav .= '<span class="current">' . $page . '</span>';
             for ($i = $page + 1; $i <= $total; $i++) {
                 $num_nav .= "<a href='" . iPHP::p2num($pageurl, $i) . "' target='_self'>{$i}</a>";
                 $flag++;
                 if ($flag == 6) {
                     break;
                 }
             }
             $index_nav = '<a href="' . $article['url'] . '" class="first" target="_self">' . iPHP::lang('iCMS:page:index') . '</a>';
             $prev_url = iPHP::p2num($pageurl, $page - 1 > 1 ? $page - 1 : 1);
             $prev_nav = '<a href="' . $prev_url . '" class="prev" target="_self">' . iPHP::lang('iCMS:page:prev') . '</a>';
             $next_url = iPHP::p2num($pageurl, $total - $page > 0 ? $page + 1 : $page);
             $next_nav = '<a href="' . $next_url . '" class="next" target="_self">' . iPHP::lang('iCMS:page:next') . '</a>';
             $end_nav = '<a href="' . iPHP::p2num($pageurl, $total) . '" class="end" target="_self">共' . $total . '页</a>';
             $text_nav = $index_nav . $prev_nav . '<span class="current">第' . $page . '页</span>' . $next_nav . $end_nav;
             $pagenav = $index_nav . $prev_nav . $num_nav . $next_nav . $end_nav;
         }
         $article['page'] = array('total' => $total, 'count' => $count, 'current' => $page, 'num' => $num_nav, 'text' => $text_nav, 'nav' => $pagenav, 'prev' => $prev_url, 'next' => $next_url, 'pageurl' => $pageurl, 'last' => $page == $count ? true : false, 'end' => $page == $total ? true : false);
         unset($index_nav, $prev_nav, $num_nav, $next_nav, $end_nav, $pagenav);
         //var_dump($page,$total,$count);
         if ($pic_array[0]) {
             $img_array = array_unique($pic_array[0]);
             foreach ($img_array as $key => $img) {
                 $img = str_replace('<img', '<img title="' . $article['title'] . '" alt="' . $article['title'] . '"', $img);
                 if (iCMS::$config['article']['pic_center']) {
                     $img_replace[$key] = '<p align="center">' . $img . '</p>';
                 } else {
                     $img_replace[$key] = $img;
                 }
                 if (iCMS::$config['article']['pic_next'] && $count > 1) {
                     $clicknext = '<a href="' . $next_url . '"><b>' . iPHP::lang('iCMS:article:clicknext') . '</b></a>';
                     $clickimg = '<a href="' . $next_url . '" title="' . $article['title'] . '" class="img">' . $img . '</a>';
                     if (iCMS::$config['article']['pic_center']) {
                         $img_replace[$key] = '<p align="center">' . $clicknext . '</p>';
                         $img_replace[$key] .= '<p align="center">' . $clickimg . '</p>';
                     } else {
                         $img_replace[$key] = '<p>' . $clicknext . '</p>';
                         $img_replace[$key] .= '<p>' . $clickimg . '</p>';
                     }
                 }
             }
             $article['body'] = str_replace($img_array, $img_replace, $article['body']);
         }
     }
     if ($vars['prev_next'] && iCMS::$config['article']['prev_next']) {
         //上一篇
         $prev_cache = iPHP_DEVICE . '/article/' . $article['id'] . '/prev';
         $prev_array = iCache::get($prev_cache);
         if (empty($prev_array)) {
             $prev_array = array('empty' => true, 'title' => iPHP::lang('iCMS:article:first'), 'pic' => array(), 'url' => 'javascript:;');
             $prevrs = iDB::row("SELECT * FROM `#iCMS@__article` WHERE `id` < '{$article['id']}' AND `cid`='{$article['cid']}' AND `status`='1' order by id DESC LIMIT 1;");
             if ($prevrs) {
                 $prev_array = array('empty' => false, 'title' => $prevrs->title, 'pic' => get_pic($prevrs->pic), 'url' => iURL::get('article', array((array) $prevrs, $category))->href);
             }
             iCache::set($prev_cache, $prev_array);
         }
         $article['prev'] = $prev_array;
         //下一篇
         $next_cache = iPHP_DEVICE . '/article/' . $article['id'] . '/next';
         $next_array = iCache::get($next_cache);
         if (empty($next_array)) {
             $next_array = array('empty' => true, 'title' => iPHP::lang('iCMS:article:last'), 'pic' => array(), 'url' => 'javascript:;');
             $nextrs = iDB::row("SELECT * FROM `#iCMS@__article` WHERE `id` > '{$article['id']}'  and `cid`='{$article['cid']}' AND `status`='1' order by id ASC LIMIT 1;");
             if ($nextrs) {
                 $next_array = array('empty' => false, 'title' => $nextrs->title, 'pic' => get_pic($nextrs->pic), 'url' => iURL::get('article', array((array) $nextrs, $category))->href);
             }
             iCache::set($next_cache, $next_array);
         }
         $article['next'] = $next_array;
     }
     if ($vars['tags']) {
         $article['tags_fname'] = $category['name'];
         if ($article['tags']) {
             $tagApp = iPHP::app("tag");
             $tagArray = $tagApp->get_array($article['tags']);
             $article['tag_array'] = array();
             foreach ((array) $tagArray as $tk => $tag) {
                 $article['tag_array'][$tk]['name'] = $tag['name'];
                 $article['tag_array'][$tk]['url'] = $tag['url'];
                 $article['tag_array'][$tk]['link'] = $tag['link'];
                 $article['tags_link'] .= $tag['link'];
                 $tag_name_array[] = $tag['name'];
             }
             $tag_name_array && ($article['tags_fname'] = $tag_name_array[0]);
             unset($tagApp, $tagArray, $tag_name_array);
         }
     }
     if ($vars['meta']) {
         if ($article['metadata']) {
             $article['meta'] = unserialize($article['metadata']);
             unset($article['metadata']);
         }
     }
     if ($vars['user']) {
         iPHP::app('user.class', 'static');
         if ($article['postype']) {
             $article['user'] = user::empty_info($article['userid'], '#' . $article['editor']);
         } else {
             $article['user'] = user::info($article['userid'], $article['author']);
         }
     }
     if (strstr($article['source'], '||')) {
         list($s_name, $s_url) = explode('||', $article['source']);
         $article['source'] = '<a href="' . $s_url . '" target="_blank">' . $s_name . '</a>';
     }
     if (strstr($article['author'], '||')) {
         list($a_name, $a_url) = explode('||', $article['author']);
         $article['author'] = '<a href="' . $a_url . '" target="_blank">' . $a_name . '</a>';
     }
     $article['hits'] = array('script' => iCMS_API . '?app=article&do=hits&cid=' . $article['cid'] . '&id=' . $article['id'], 'count' => $article['hits'], 'today' => $article['hits_today'], 'yday' => $article['hits_yday'], 'week' => $article['hits_week'], 'month' => $article['hits_month']);
     $article['comment'] = array('url' => iCMS_API . "?app=article&do=comment&appid={$article['appid']}&iid={$article['id']}&cid={$article['cid']}", 'count' => $article['comments']);
     if ($article['picdata']) {
         $picdata = unserialize($article['picdata']);
     }
     unset($article['picdata']);
     $article['pic'] = get_pic($article['pic'], $picdata['b'], get_twh($vars['btw'], $vars['bth']));
     $article['mpic'] = get_pic($article['mpic'], $picdata['m'], get_twh($vars['mtw'], $vars['mth']));
     $article['spic'] = get_pic($article['spic'], $picdata['s'], get_twh($vars['stw'], $vars['sth']));
     $article['param'] = array("appid" => $article['appid'], "iid" => $article['id'], "cid" => $article['cid'], "suid" => $article['userid'], "title" => $article['title'], "url" => $article['url']);
     return $article;
 }
Exemplo n.º 14
0
 public function value($article, $art_data = "", $vars = array(), $page = 1, $tpl = false)
 {
     $article['appid'] = iCMS_APP_ARTICLE;
     $categoryApp = iPHP::app("category");
     $category = $categoryApp->category($article['cid'], false);
     if ($tpl) {
         $category or iPHP::throw404('运行出错!找不到该文章的栏目缓存<b>cid:' . $article['cid'] . '</b> 请更新栏目缓存或者确认栏目是否存在', 10002);
     } else {
         if (empty($category)) {
             return false;
         }
     }
     if ($category['status'] == 0) {
         return false;
     }
     if (iPHP::$iTPL_MODE == "html" && $tpl && (strstr($category['contentRule'], '{PHP}') || $category['outurl'] || $category['mode'] == "0")) {
         return false;
     }
     $_iurlArray = array($article, $category);
     $article['iurl'] = iURL::get('article', $_iurlArray, $page);
     $article['url'] = $article['iurl']->href;
     $article['link'] = "<a href='{$article['url']}'>{$article['title']}</a>";
     $tpl && $category['mode'] == '1' && iCMS::gotohtml($article['iurl']->path, $article['iurl']->href);
     if ($vars['category_lite']) {
         $article['category'] = $categoryApp->get_lite($category);
     } else {
         $article['category'] = $category;
     }
     $this->taoke = false;
     if ($art_data) {
         $pkey = intval($page - 1);
         $pageurl = $article['iurl']->pageurl;
         if ($article['chapter']) {
             $chapterArray = $art_data;
             $count = count($chapterArray);
             $adid = $chapterArray[$pkey]['id'];
             $art_data = iDB::row("SELECT body,subtitle FROM `#iCMS@__article_data` WHERE aid='" . (int) $article['id'] . "' AND id='" . (int) $adid . "' LIMIT 1;", ARRAY_A);
         }
         $art_data['body'] = $this->ubb($art_data['body']);
         preg_match_all("/<img.*?src\\s*=[\"|'|\\s]*(http:\\/\\/.*?\\.(gif|jpg|jpeg|bmp|png)).*?>/is", $art_data['body'], $pic_array);
         $p_array = array_unique($pic_array[1]);
         if ($p_array) {
             foreach ($p_array as $key => $_pic) {
                 $article['pics'][$key] = trim($_pic);
             }
         }
         if (substr($art_data['body'], 0, 19) == '#--iCMS.Markdown--#') {
             // $art_data['body']    = iPHP::Markdown($art_data['body']);
             $art_data['body'] = substr($art_data['body'], 19);
             $article['markdown'] = ture;
         }
         if ($article['chapter']) {
             $article['body'] = $art_data['body'];
         } else {
             $body = explode('#--iCMS.PageBreak--#', $art_data['body']);
             $count = count($body);
             $article['body'] = $body[$pkey];
         }
         $total = $count + intval(iCMS::$config['article']['pageno_incr']);
         $article['body'] = $this->keywords($article['body']);
         $article['body'] = $this->taoke($article['body']);
         $article['taoke'] = $this->taoke;
         $article['subtitle'] = $art_data['subtitle'];
         unset($body, $art_data);
         $pageArray = array();
         if ($total > 1) {
             iPHP::loadClass("Pages");
             $_GLOBALS_iPage = $GLOBALS['iPage'];
             $category['mode'] && iCMS::set_html_url($article['iurl']);
             $pageconf = array('page_name' => 'p', 'url' => $pageurl, 'total' => $total, 'perpage' => 1, 'nowindex' => (int) $_GET['p'], 'lang' => iPHP::lang(iPHP_APP . ':page'));
             if ($article['chapter']) {
                 foreach ((array) $chapterArray as $key => $value) {
                     $pageconf['titles'][$key + 1] = $value['subtitle'];
                 }
             }
             $iPages = new iPages($pageconf);
             unset($GLOBALS['iPage']);
             $GLOBALS['iPage'] = $_GLOBALS_iPage;
             unset($_GLOBALS_iPage);
             $pageArray['list'] = $iPages->list_page();
             $pageArray['index'] = $iPages->first_page('array');
             $pageArray['prev'] = $iPages->prev_page('array');
             $pageArray['next'] = $iPages->next_page('array');
             $pageArray['endof'] = $iPages->last_page('array');
             $pagenav = $iPages->show(0);
             $pagetext = $iPages->show(10);
         }
         $article['page'] = array('pn' => $page, 'total' => $total, 'count' => $count, 'current' => $page, 'nav' => $pagenav, 'pageurl' => $pageurl, 'text' => $pagetext, 'PAGES' => $iPages, 'args' => iS::escapeStr($_GET['pageargs']), 'first' => $page == "1" ? true : false, 'last' => $page == $count ? true : false, 'end' => $page == $total ? true : false) + $pageArray;
         $next_url = $pageArray['next']['url'];
         unset($pagenav, $pagetext, $iPages, $pageArray);
         if ($pic_array[0]) {
             $img_array = array_unique($pic_array[0]);
             foreach ($img_array as $key => $img) {
                 $img = str_replace('<img', '<img title="' . $article['title'] . '" alt="' . $article['title'] . '"', $img);
                 if (iCMS::$config['article']['pic_center']) {
                     $img_replace[$key] = '<p align="center">' . $img . '</p>';
                 } else {
                     $img_replace[$key] = $img;
                 }
                 if (iCMS::$config['article']['pic_next'] && $count > 1) {
                     $clicknext = '<a href="' . $next_url . '"><b>' . iPHP::lang('iCMS:article:clicknext') . '</b></a>';
                     $clickimg = '<a href="' . $next_url . '" title="' . $article['title'] . '" class="img">' . $img . '</a>';
                     if (iCMS::$config['article']['pic_center']) {
                         $img_replace[$key] = '<p align="center">' . $clicknext . '</p>';
                         $img_replace[$key] .= '<p align="center">' . $clickimg . '</p>';
                     } else {
                         $img_replace[$key] = '<p>' . $clicknext . '</p>';
                         $img_replace[$key] .= '<p>' . $clickimg . '</p>';
                     }
                 }
             }
             $article['body'] = str_replace($img_array, $img_replace, $article['body']);
         }
     }
     if ($vars['tags']) {
         $article['tags_fname'] = $category['name'];
         if ($article['tags']) {
             $tagApp = iPHP::app("tag");
             $tagArray = $tagApp->get_array($article['tags']);
             $article['tag_array'] = array();
             foreach ((array) $tagArray as $tk => $tag) {
                 $article['tag_array'][$tk] = $tag;
                 $article['tags_link'] .= $tag['link'];
                 $tag_name_array[] = $tag['name'];
             }
             $tag_name_array && ($article['tags_fname'] = $tag_name_array[0]);
             unset($tagApp, $tagArray, $tag_name_array);
         }
     }
     if ($vars['meta']) {
         if ($article['metadata']) {
             $article['meta'] = unserialize($article['metadata']);
             unset($article['metadata']);
         }
     }
     if ($vars['user']) {
         iPHP::app('user.class', 'static');
         if ($article['postype']) {
             $article['user'] = user::empty_info($article['userid'], '#' . $article['editor']);
         } else {
             $article['user'] = user::info($article['userid'], $article['author']);
         }
     }
     if (strstr($article['source'], '||')) {
         list($s_name, $s_url) = explode('||', $article['source']);
         $article['source'] = '<a href="' . $s_url . '" target="_blank">' . $s_name . '</a>';
     }
     if (strstr($article['author'], '||')) {
         list($a_name, $a_url) = explode('||', $article['author']);
         $article['author'] = '<a href="' . $a_url . '" target="_blank">' . $a_name . '</a>';
     }
     $article['hits'] = array('script' => iCMS_API . '?app=article&do=hits&cid=' . $article['cid'] . '&id=' . $article['id'], 'count' => $article['hits'], 'today' => $article['hits_today'], 'yday' => $article['hits_yday'], 'week' => $article['hits_week'], 'month' => $article['hits_month']);
     $article['comment'] = array('url' => iCMS_API . "?app=article&do=comment&appid={$article['appid']}&iid={$article['id']}&cid={$article['cid']}", 'count' => $article['comments']);
     if ($article['picdata']) {
         $picdata = unserialize($article['picdata']);
     }
     unset($article['picdata']);
     $article['pic'] = get_pic($article['pic'], $picdata['b'], get_twh($vars['btw'], $vars['bth']));
     $article['mpic'] = get_pic($article['mpic'], $picdata['m'], get_twh($vars['mtw'], $vars['mth']));
     $article['spic'] = get_pic($article['spic'], $picdata['s'], get_twh($vars['stw'], $vars['sth']));
     $article['param'] = array("appid" => $article['appid'], "iid" => $article['id'], "cid" => $article['cid'], "suid" => $article['userid'], "title" => $article['title'], "url" => $article['url']);
     return $article;
 }
Exemplo n.º 15
0
 public static function get($uri, $a = array())
 {
     $i = new stdClass();
     $sURL = self::$config['URL'];
     $html_dir = self::$config['html_dir'];
     $router = self::$config['router'];
     $category = array();
     $array = $a;
     $PRI = $router[$uri]['PRI'];
     $rule = $router[$uri]['rule'];
     switch ($rule) {
         case '0':
             $i->href = $array['url'];
             $url = $array['urlRule'];
             break;
         case '1':
             $category = $array;
             $i->href = $category['url'];
             $url = $category['mode'] ? $category['categoryRule'] : '{PHP}';
             $category['password'] && $category['mode'] == "1" && ($url = '{PHP}');
             if ($url == '{PHP}') {
                 $document_uri = $uri . '.php?';
                 $category['categoryURI'] && ($document_uri = $category['categoryURI'] . '.php?');
                 $document_uri .= $PRI . '=' . $category[$PRI];
             }
             break;
         case '2':
             $array = (array) $a[0];
             $category = (array) $a[1];
             $i->href = $array['url'];
             $url = $category['mode'] ? $category['contentRule'] : '{PHP}';
             $category['password'] && $category['mode'] == "1" && ($url = '{PHP}');
             if ($url == '{PHP}') {
                 $document_uri = $uri . '.php?';
                 $document_uri .= $PRI . '=' . $array[$PRI];
                 $i->pageurl = $document_uri . '&p={P}';
                 strpos($i->pageurl, 'http://') === false && ($i->pageurl = rtrim($sURL, '/') . '/' . $i->pageurl);
             }
             break;
         case '3':
             $array = (array) $a[0];
             $category = (array) $a[1];
             $_category = (array) $a[2];
             $html_dir = self::$config['tag_dir'];
             $sURL = self::$config['tag_url'];
             $i->href = $array['url'];
             //$a       = array_merge_recursive((array)$a[0],$category);
             $url = $category['urlRule'];
             $_category['urlRule'] && ($url = $_category['urlRule']);
             $url or $url = self::$config['tag_rule'];
             if ($url == '{PHP}') {
                 $document_uri = $uri . '.php?';
                 $document_uri .= $PRI . '=' . $array[$PRI];
             }
             break;
         default:
             $url = $array['urlRule'];
     }
     if ($url == '{PHP}') {
         strpos($document_uri, 'http://') === false && ($document_uri = rtrim($sURL, '/') . '/' . $document_uri);
         $i->href = $document_uri;
     }
     if ($i->href) {
         return $i;
     }
     if (strpos($url, '{PHP}') === false) {
         self::$uriArray = array($array, $category, (array) $_category);
         strpos($url, '{') === false or $url = preg_replace_callback("/\\{(.*?)\\}/", '__iurl_rule__', $url);
         $i->path = rtrim(iFS::path(iPATH . $html_dir . $url), '/');
         if (strpos($html_dir, '..') === false) {
             $i->href = rtrim($sURL, '/') . '/' . ltrim(iFS::path($html_dir . $url), '/');
         } else {
             $i->href = rtrim($sURL, '/') . '/' . ltrim(iFS::path($url), '/');
         }
         $pathA = pathinfo($i->path);
         //            if(in_array($uri,array('article','content'))) {
         //                $i->path    = FS::path($Curl->dmdir.'/'.$url);
         //                $i->href    = FS::path($Curl->domain.'/'.$url);
         //            }
         $i->hdir = pathinfo($i->href, PATHINFO_DIRNAME);
         $i->dir = $pathA['dirname'];
         $i->file = $pathA['basename'];
         $i->name = $pathA['filename'];
         $i->ext = '.' . $pathA['extension'];
         $i->name or $i->name = $i->file;
         //var_dump($GLOBALS['page']);
         //var_dump($i);
         //var_dump($pathA);
         if (empty($i->file) || substr($url, -1) == '/' || empty($pathA['extension'])) {
             $i->name = 'index';
             $i->ext = self::$config['html_ext'];
             $category['htmlext'] && ($i->ext = $category['htmlext']);
             $i->file = $i->name . $i->ext;
             $i->path = $i->path . '/' . $i->file;
             $i->dir = dirname($i->path);
             $i->hdir = dirname($i->href . '/' . $i->file);
         }
         //var_dump($i);
         if (strpos($i->file, '{P}') === false) {
             $i->pfile = $i->name . "_{P}" . $i->ext;
         } else {
             $i->pfile = $i->file;
         }
         if ($rule == '0' || strpos($url, 'http://') !== false) {
             $hi = new stdClass();
             $hi->href = $url;
             $hi->ext = $i->ext;
             $hi->pageurl = $hi->href . '/' . $i->pfile;
             return $hi;
         }
         //var_dump($i);
         //exit;
         if ($rule == '1') {
             $m = self::domain($array['cid']);
             if ($m->domain) {
                 $i->href = str_replace($i->hdir, $m->dmpath, $i->href);
                 $i->hdir = $m->dmpath;
                 $__dir__ = $i->dir . '/' . $m->pdir;
                 $i->path = str_replace($i->dir, $__dir__, $i->path);
                 $i->dir = $__dir__;
                 $i->dmdir = iFS::path(iPATH . $html_dir . '/' . $m->pd);
                 $bits = parse_url($i->href);
                 $i->domain = $bits['scheme'] . '://' . $bits['host'];
             } else {
                 $i->dmdir = iFS::path(iPATH . $html_dir);
                 $i->domain = $sURL;
             }
             if (strpos($array['domain'], 'http://') !== false) {
                 $i->href = $array['domain'];
             }
         }
         $i->pageurl = $i->hdir . '/' . $i->pfile;
         $i->pagepath = $i->dir . '/' . $i->pfile;
         $i->href = str_replace('{P}', 1, $i->href);
         $i->path = str_replace('{P}', 1, $i->path);
         $i->file = str_replace('{P}', 1, $i->file);
         $i->name = str_replace('{P}', 1, $i->name);
         //var_dump($i);
         //exit;
     }
     return $i;
 }
Exemplo n.º 16
0
function article_next($vars)
{
    // if($vars['param']){
    //     $vars+= $vars['param'];
    //     unset($vars['param']);
    // }
    empty($vars['order']) && ($vars['order'] = 'n');
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : -1;
    if (isset($vars['cid'])) {
        $sql = " AND `cid`='{$vars['cid']}' ";
    }
    if ($vars['order'] == 'p') {
        $sql .= " AND `id` < '{$vars['id']}' ORDER BY id DESC LIMIT 1";
    } else {
        if ($vars['order'] == 'n') {
            $sql .= " AND `id` > '{$vars['id']}' ORDER BY id ASC LIMIT 1";
        }
    }
    $hash = md5($sql);
    if ($vars['cache']) {
        $cache = iPHP_DEVICE . '/article/' . $hash;
        $array = iCache::get($cache);
    }
    if (empty($array)) {
        $rs = iDB::row("SELECT * FROM `#iCMS@__article` WHERE `status`='1' {$sql}");
        if ($rs) {
            $category = iCache::get('iCMS/category/' . $rs->cid);
            $array = array('title' => $rs->title, 'pic' => get_pic($rs->pic), 'url' => iURL::get('article', array((array) $rs, $category))->href);
        }
        iCache::set($cache, $array, $cache_time);
    }
    return $array;
}