Exemple #1
0
function favorite_data($vars = null)
{
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10";
    $where_sql = "WHERE 1=1 ";
    isset($vars['userid']) && ($where_sql .= " AND `uid`='" . (int) $vars['userid'] . "' ");
    $vars['fid'] && ($where_sql .= " AND `fid`='" . (int) $vars['fid'] . "' ");
    isset($vars['appid']) && ($where_sql .= " AND `appid`='" . (int) $vars['appid'] . "' ");
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : -1;
    $by = $vars['by'] == "ASC" ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        default:
            $order_sql = " ORDER BY `id` {$by}";
    }
    $md5 = md5($where_sql . $order_sql);
    $offset = 0;
    if ($vars['page']) {
        $total = iPHP::total($md5, "SELECT count(*) FROM `#iCMS@__favorite_data` {$where_sql} ");
        iPHP::assign("fav_data_total", $total);
        $multi = iCMS::page(array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:list'), 'nowindex' => $GLOBALS['page']));
        $offset = $multi->offset;
    }
    if ($vars['cache']) {
        $cache_name = 'favorite_data/' . $md5 . "/" . (int) $GLOBALS['page'];
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $resource = iDB::all("SELECT * FROM `#iCMS@__favorite_data` {$where_sql} {$order_sql} LIMIT {$offset},{$maxperpage}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        // $resource = array();
        // if($rs)foreach ($rs as $key => $value) {
        // }
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Exemple #2
0
 function do_add()
 {
     if ($this->cid) {
         iACP::CP($this->cid, 'e', 'page');
         $rs = iDB::row("SELECT * FROM `#iCMS@__category` WHERE `cid`='{$this->cid}' LIMIT 1;", ARRAY_A);
         $rootid = $rs['rootid'];
         $rs['metadata'] && ($rs['metadata'] = unserialize($rs['metadata']));
         $rs['contentprop'] && ($rs['contentprop'] = unserialize($rs['contentprop']));
         $rs['body'] = iCache::get('iCMS/category/' . $this->cid . '.body');
         $rs['body'] && ($rs['body'] = stripslashes($rs['body']));
     } else {
         $rootid = (int) $_GET['rootid'];
         $rootid && iACP::CP($rootid, 'a', 'page');
     }
     if (empty($rs)) {
         $rs = array('pid' => '0', 'status' => '1', 'isexamine' => '1', 'issend' => '1', 'hasbody' => '2', 'ordernum' => '0', 'mode' => '0', 'htmlext' => iCMS::$config['router']['html_ext'], 'categoryURI' => 'category', 'categoryRule' => '/{CDIR}/index' . iCMS::$config['router']['html_ext'], 'contentRule' => '/{CDIR}/{YYYY}/{MM}{DD}/{ID}' . iCMS::$config['router']['html_ext'], 'indexTPL' => $this->_app_indexTPL, 'listTPL' => $this->_app_listTPL, 'contentTPL' => $this->_app_contentTPL, 'metadata' => '', 'contentprop' => '');
         if ($rootid) {
             $rootRs = iDB::row("SELECT * FROM `#iCMS@__category` WHERE `cid`='" . $rootid . "' LIMIT 1;", ARRAY_A);
             $rs['htmlext'] = $rootRs['htmlext'];
             $rs['categoryRule'] = $rootRs['categoryRule'];
             $rs['contentRule'] = $rootRs['contentRule'];
             $rs['indexTPL'] = $rootRs['indexTPL'];
             $rs['listTPL'] = $rootRs['listTPL'];
             $rs['contentTPL'] = $rootRs['contentTPL'];
         }
     }
     include iACP::view("category.add");
 }
Exemple #3
0
 function do_add()
 {
     $_GET['cid'] && iACP::CP($_GET['cid'], 'ca', 'page');
     //添加权限
     $rs = array();
     if ($this->id) {
         list($rs, $adRs) = articleTable::data($this->id, $this->dataid);
         if ($adRs) {
             $adRs['body'] = htmlspecialchars($adRs['body']);
             $bodyArray = explode('#--iCMS.PageBreak--#', $adRs['body']);
             $bodyCount = count($bodyArray);
         }
         iACP::CP($rs['cid'], 'ce', 'page');
         //编辑权限
     }
     $bodyCount or $bodyCount = 1;
     $cid = empty($rs['cid']) ? (int) $_GET['cid'] : $rs['cid'];
     $cata_option = $this->categoryApp->select('ca', $cid);
     $cid && ($contentprop = unserialize($this->category[$cid]['contentprop']));
     //$metadata          = array_merge((array)$contentprop,(array)$rs['metadata']);
     $rs['pubdate'] = get_date($rs['pubdate'], 'Y-m-d H:i:s');
     $rs['metadata'] && ($rs['metadata'] = unserialize($rs['metadata']));
     if (empty($this->id)) {
         $rs['status'] = "1";
         $rs['postype'] = "1";
         $rs['editor'] = empty(iMember::$data->nickname) ? iMember::$data->username : iMember::$data->nickname;
         $rs['userid'] = iMember::$userid;
     }
     $strpos = strpos(__REF__, '?');
     $REFERER = $strpos === false ? '' : substr(__REF__, $strpos);
     $defArray = iCache::get('iCMS/defaults');
     include iACP::view("article.add");
 }
Exemple #4
0
/**
 * @package iCMS
 * @copyright 2007-2010, iDreamSoft
 * @license http://www.idreamsoft.com iDreamSoft
 * @author coolmoo <*****@*****.**>
 */
function iCMS_link($vars)
{
    $limit = isset($vars['row']) ? (int) $vars['row'] : "100";
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : -1;
    switch ($vars['type']) {
        case "text":
            $sql[] = " `logo`='' ";
            break;
        case "logo":
            $sql[] = " `logo`!='' ";
            break;
    }
    isset($vars['cid']) && ($sql[] = " cid='" . $vars['cid'] . "'");
    $sql && ($where = 'WHERE ' . implode(' AND ', $sql));
    $iscache = true;
    if ($vars['cache'] == false || isset($vars['page'])) {
        $iscache = false;
        $rs = '';
    } else {
        $cacheName = 'links/' . md5($sql);
        $rs = iCache::get($cacheName);
    }
    if (empty($rs)) {
        $rs = iDB::all("SELECT * FROM `#iCMS@__links`{$where} ORDER BY ordernum ASC,id ASC LIMIT 0 , {$limit}");
        $iscache && iCache::set($cacheName, $rs, $cache_time);
    }
    return $rs;
}
Exemple #5
0
 public static function get_label($appid = 0, $key = 'title')
 {
     $array = iCache::get('iCMS/app/cache_id');
     if ($appid) {
         return $array[$appid][$key];
     }
     return $array;
 }
Exemple #6
0
/**
 * @package iCMS
 * @copyright 2007-2010, iDreamSoft
 * @license http://www.idreamsoft.com iDreamSoft
 * @author coolmoo <*****@*****.**>
 * @$Id: push.tpl.php 1392 2013-05-20 12:28:08Z coolmoo $
 */
function push_list($vars)
{
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "100";
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : "-1";
    $where_sql = "WHERE `status`='1'";
    isset($vars['userid']) && ($where_sql .= " AND `userid`='{$vars['userid']}'");
    if (isset($vars['cid!'])) {
        $ncids = explode(',', $vars['cid!']);
        $vars['sub'] && ($ncids += iCMS::get_category_ids($ncids, true));
        $where_sql .= iPHP::where($ncids, 'cid', 'not');
    }
    if (isset($vars['cid'])) {
        $cid = explode(',', $vars['cid']);
        $vars['sub'] && ($cid += iCMS::get_category_ids($cid, true));
        $where_sql .= iPHP::where($cid, 'cid');
    }
    isset($vars['pid']) && ($where_sql .= " AND `type` ='{$vars['pid']}'");
    isset($vars['pic']) && ($where_sql .= " AND `haspic`='1'");
    isset($vars['nopic']) && ($where_sql .= " AND `haspic`='0'");
    isset($vars['startdate']) && ($where_sql .= " AND `addtime`>='" . strtotime($vars['startdate']) . "'");
    isset($vars['enddate']) && ($where_sql .= " AND `addtime`<='" . strtotime($vars['enddate']) . "'");
    $by = $vars['by'] == "ASC" ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        case "id":
            $order_sql = " ORDER BY `id` {$by}";
            break;
        case "addtime":
            $order_sql = " ORDER BY `addtime` {$by}";
            break;
        case "disorder":
            $order_sql = " ORDER BY `ordernum` {$by}";
            break;
        default:
            $order_sql = " ORDER BY `id` DESC";
    }
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/push/' . md5($where_sql);
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $resource = iDB::all("SELECT * FROM `#iCMS@__push` {$where_sql} {$order_sql} LIMIT {$maxperpage}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        if ($resource) {
            foreach ($resource as $key => $value) {
                $value['pic'] && ($value['pic'] = iFS::fp($value['pic'], '+http'));
                $value['pic2'] && ($value['pic2'] = iFS::fp($value['pic2'], '+http'));
                $value['pic2'] && ($value['pic2'] = iFS::fp($value['pic2'], '+http'));
                $value['metadata'] && ($value['metadata'] = unserialize($value['metadata']));
                $resource[$key] = $value;
            }
        }
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Exemple #7
0
/**
 * @package iCMS
 * @copyright 2007-2010, iDreamSoft
 * @license http://www.idreamsoft.com iDreamSoft
 * @author coolmoo <*****@*****.**>
 * @$Id: iCMS.prop.php 179 2013-03-29 03:21:28Z coolmoo $
 */
function iCMS_prop($vars)
{
    $type = $vars['type'];
    $field = $vars['field'];
    $cid = $vars['cid'];
    $pkey = $type . '.' . $field;
    $cid && ($pkey = 'c' . $cid . '.' . $type . '.' . $field);
    $propArray = iCache::get("iCMS/prop/{$pkey}");
    $propArray && sort($propArray);
    $offset = $vars['start'] ? $vars['start'] : 0;
    $vars['row'] && ($propArray = array_slice($propArray, 0, $vars['row']));
    return $propArray;
}
Exemple #8
0
 private static function domain($cid = "0", $akey = 'dir')
 {
     $ii = new stdClass();
     $C = iCache::get('iCMS/category/' . $cid);
     $rootid = $C['rootid'];
     $ii->sdir = $C[$akey];
     if ($rootid && empty($C['domain'])) {
         $dm = self::domain($rootid);
         $ii->pd = $dm->pd;
         $ii->domain = $dm->domain;
         $ii->pdir = $dm->pdir . '/' . $C[$akey];
         $ii->dmpath = $dm->dmpath . '/' . $C[$akey];
     } else {
         $ii->pd = $ii->pdir = $ii->sdir;
         $ii->dmpath = $ii->domain = $C['domain'] ? 'http://' . ltrim($C['domain'], 'http://') : '';
     }
     return $ii;
 }
Exemple #9
0
 function __construct()
 {
     iCache::sysCache();
     $this->menu_array = iCache::get('iCMS/iMenu/menu_array');
     $this->root_array = iCache::get('iCMS/iMenu/root_array');
     $this->child_array = iCache::get('iCMS/iMenu/child_array');
     $this->parent = iCache::get('iCMS/iMenu/parent');
     $this->menu_uri = iCache::get('iCMS/iMenu/menu_uri');
     $app = $_GET['app'] ? $_GET['app'] : 'home';
     $this->app_uri = $this->menu_uri[$app];
     $this->do_uri = $app;
     $_GET['appid'] && ($this->do_uri .= '&appid=' . (int) $_GET['appid']);
     $_GET['do'] && ($this->do_uri .= '&do=' . $_GET['do']);
     $_GET['tab'] && ($this->do_uri .= '&tab=' . $_GET['tab']);
     $this->do_mid = $this->app_uri[$this->do_uri];
     $this->do_mid or $this->do_mid = $this->app_uri[$app];
     $this->do_mid or $this->do_mid = $this->app_uri['#'];
     $this->rootid = $this->rootid($this->do_mid);
     $this->parentid = $this->parent[$this->do_mid];
     $this->menu_array or $this->cache();
 }
Exemple #10
0
/**
 * @package iCMS
 * @copyright 2007-2010, iDreamSoft
 * @license http://www.idreamsoft.com iDreamSoft
 * @author coolmoo <*****@*****.**>
 * @$Id: search.tpl.php 1392 2013-05-20 12:28:08Z coolmoo $
 */
function search_list($vars)
{
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "100";
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : "-1";
    $where_sql = '';
    $by = $vars['by'] == "ASC" ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        case "id":
            $order_sql = " ORDER BY `id` {$by}";
            break;
        case "addtime":
            $order_sql = " ORDER BY `addtime` {$by}";
            break;
        case "times":
            $order_sql = " ORDER BY `times` {$by}";
            break;
        default:
            $order_sql = " ORDER BY `id` DESC";
    }
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/search/' . md5($where_sql . $order_sql);
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $resource = iDB::all("SELECT * FROM `#iCMS@__search_log` {$where_sql} {$order_sql} LIMIT {$maxperpage}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        if ($resource) {
            foreach ($resource as $key => $value) {
                $value['name'] = $value['search'];
                $value['url'] = search_url(array('query' => $value['name'], 'ret' => true));
                $resource[$key] = $value;
            }
        }
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Exemple #11
0
 public static function total($tnkey, $sql, $type = null)
 {
     $tnkey == 'sql.md5' && ($tnkey = md5($sql));
     $tnkey = substr($tnkey, 8, 16);
     $total = (int) $_GET['total_num'];
     if (empty($total) && $type === null && !isset($_GET['total_cahce'])) {
         $total = (int) iCache::get('total/' . $tnkey);
     }
     if (empty($total) || $type === 'nocache' || isset($_GET['total_cahce'])) {
         $total = iDB::value($sql);
         if ($type === null) {
             iCache::set('total/' . $tnkey, $total);
         }
     }
     return $total;
 }
Exemple #12
0
 public function keywords($content)
 {
     if (iCMS::$config['other']['keyword_limit'] == 0) {
         return $content;
     }
     $keywords = iCache::get('iCMS/keywords');
     if ($keywords) {
         foreach ($keywords as $i => $val) {
             if ($val['times'] > 0) {
                 $search[] = $val['keyword'];
                 $replace[] = '<a class="keyword" target="_blank" href="' . $val['url'] . '">' . $val['keyword'] . '</a>';
             }
         }
         return iCMS::str_replace_limit($search, $replace, stripslashes($content), iCMS::$config['other']['keyword_limit']);
     }
     return $content;
 }
Exemple #13
0
function article_search($vars)
{
    if (empty(iCMS::$config['sphinx']['host'])) {
        return array();
    }
    $resource = array();
    $hidden = iCache::get('iCMS/category/hidden');
    $hidden && ($where_sql .= iPHP::where($hidden, 'cid', 'not'));
    $SPH = iCMS::sphinx();
    $SPH->init();
    $SPH->SetArrayResult(true);
    if (isset($vars['weights'])) {
        //weights='title:100,tags:80,keywords:60,name:50'
        $wa = explode(',', $vars['weights']);
        foreach ($wa as $wk => $wv) {
            $waa = explode(':', $wv);
            $FieldWeights[$waa[0]] = $waa[1];
        }
        $FieldWeights or $FieldWeights = array("title" => 100, "tags" => 80, "name" => 60, "keywords" => 40);
        $SPH->SetFieldWeights($FieldWeights);
    }
    $page = (int) $_GET['page'];
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : 10;
    $start = $page && isset($vars['page']) ? ($page - 1) * $maxperpage : 0;
    $SPH->SetMatchMode(SPH_MATCH_EXTENDED);
    if ($vars['mode']) {
        $vars['mode'] == "SPH_MATCH_BOOLEAN" && $SPH->SetMatchMode(SPH_MATCH_BOOLEAN);
        $vars['mode'] == "SPH_MATCH_ANY" && $SPH->SetMatchMode(SPH_MATCH_ANY);
        $vars['mode'] == "SPH_MATCH_PHRASE" && $SPH->SetMatchMode(SPH_MATCH_PHRASE);
        $vars['mode'] == "SPH_MATCH_ALL" && $SPH->SetMatchMode(SPH_MATCH_ALL);
        $vars['mode'] == "SPH_MATCH_EXTENDED" && $SPH->SetMatchMode(SPH_MATCH_EXTENDED);
    }
    isset($vars['userid']) && $SPH->SetFilter('userid', array($vars['userid']));
    isset($vars['postype']) && $SPH->SetFilter('postype', array($vars['postype']));
    if (isset($vars['cid'])) {
        $cids = $vars['sub'] ? iCMS::get_category_ids($vars['cid'], true) : (array) $vars['cid'];
        $cids or $cids = (array) $vars['cid'];
        $cids = array_map("intval", $cids);
        $SPH->SetFilter('cid', $cids);
    }
    if (isset($vars['startdate'])) {
        $startime = strtotime($vars['startdate']);
        $enddate = empty($vars['enddate']) ? time() : strtotime($vars['enddate']);
        $SPH->SetFilterRange('pubdate', $startime, $enddate);
    }
    $SPH->SetLimits($start, $maxperpage, 10000);
    $orderby = '@id DESC, @weight DESC';
    $order_sql = ' order by id DESC';
    $vars['orderby'] && ($orderby = $vars['orderby']);
    $vars['ordersql'] && ($order_sql = ' order by ' . $vars['ordersql']);
    $vars['pic'] && $SPH->SetFilter('haspic', array(1));
    $vars['id!'] && $SPH->SetFilter('@id', array($vars['id!']), true);
    $SPH->setSortMode(SPH_SORT_EXTENDED, $orderby);
    $query = str_replace(',', '|', $vars['q']);
    $vars['acc'] && ($query = '"' . $vars['q'] . '"');
    $vars['@'] && ($query = '@(' . $vars['@'] . ') ' . $query);
    $res = $SPH->Query($query, iCMS::$config['sphinx']['index']);
    if (is_array($res["matches"])) {
        foreach ($res["matches"] as $docinfo) {
            $aid[] = $docinfo['id'];
        }
        $aids = implode(',', (array) $aid);
    }
    if (empty($aids)) {
        return;
    }
    $where_sql = " `id` in({$aids})";
    $offset = 0;
    if ($vars['page']) {
        $total = $res['total'];
        iPHP::assign("article_search_total", $total);
        $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav";
        $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0;
        $multi = iCMS::page(array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:list'), 'nowindex' => $GLOBALS['page']));
        $offset = $multi->offset;
    }
    $resource = iDB::all("SELECT * FROM `#iCMS@__article` WHERE {$where_sql} {$order_sql} LIMIT {$maxperpage}");
    iPHP_SQL_DEBUG && iDB::debug(1);
    $resource = __article_array($vars, $resource);
    return $resource;
}
Exemple #14
0
 function get_category($appid)
 {
     $rs = iCache::get('iCMS/category.' . $appid . '/cache');
     $category = array();
     foreach ((array) $rs as $_cid => $C) {
         $C['status'] && ($category[] = $C['cid']);
     }
     return $category;
 }
Exemple #15
0
function user_follow($vars = null)
{
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "30";
    if ($vars['fuid']) {
        $where_sql = "WHERE `fuid`='" . $vars['fuid'] . "'";
        //fans
    } else {
        $where_sql = "WHERE `uid`='" . $vars['userid'] . "'";
        //follow
    }
    $vars['followed'] && ($follow_data = user::follow($vars['followed'], 'all'));
    $offset = 0;
    $limit = "LIMIT {$maxperpage}";
    if ($vars['page']) {
        $total = iPHP::total('sql.md5', "SELECT count(*) FROM `#iCMS@__user_follow` {$where_sql} {$limit}");
        $multi = iCMS::page(array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:sql'), 'nowindex' => $GLOBALS['page']));
        $offset = $multi->offset;
        $limit = "LIMIT {$offset},{$maxperpage}";
        iPHP::assign("user_follow_total", $total);
    }
    $hash = md5($where_sql . $limit);
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/user_follow/' . $hash;
        $resource = iCache::get($cache_name);
    }
    $resource = iDB::all("SELECT * FROM `#iCMS@__user_follow` {$where_sql} {$limit}");
    iPHP_SQL_DEBUG && iDB::debug(1);
    if ($resource) {
        foreach ($resource as $key => $value) {
            if ($vars['fuid']) {
                $value['avatar'] = user::router($value['uid'], 'avatar');
                $value['url'] = user::router($value['uid'], 'url');
            } else {
                $value['avatar'] = user::router($value['fuid'], 'avatar');
                $value['url'] = user::router($value['fuid'], 'url');
                $value['uid'] = $value['fuid'];
                $value['name'] = $value['fname'];
            }
            $follow_data && ($value['followed'] = $follow_data[$value['uid']] ? 1 : 0);
            $resource[$key] = $value;
        }
    }
    //var_dump($rs);
    return $resource;
}
Exemple #16
0
function comment_list($vars)
{
    if ($vars['display'] && empty($vars['loop'])) {
        if (empty($vars['_display'])) {
            $_vars = iCMS::app_ref(true);
            $vars = array_merge($vars, $_vars);
        }
        return comment_list_display($vars);
    }
    $where_sql = " `status`='1'";
    if (isset($vars['appid'])) {
        $appid = (int) $vars['appid'];
        $where_sql .= " AND `appid`='{$appid}'";
    }
    if (isset($vars['cid!'])) {
        $ncids = explode(',', $vars['cid!']);
        $vars['sub'] && ($ncids += iCMS::get_category_ids($ncids, true));
        $where_sql .= iPHP::where($ncids, 'cid', 'not');
    }
    if (isset($vars['cid'])) {
        $cid = explode(',', $vars['cid']);
        $vars['sub'] && ($cid += iCMS::get_category_ids($cid, true));
        $where_sql .= iPHP::where($cid, 'cid');
    }
    isset($vars['userid']) && ($where_sql .= " AND `userid`='{$vars['userid']}'");
    $vars['pid'] && ($where_sql .= " AND `pid`='" . (int) $vars['pid'] . "'");
    $vars['iid'] && ($where_sql .= " AND `iid`='" . (int) $vars['iid'] . "'");
    $vars['id'] && ($where_sql .= " AND `id`='" . (int) $vars['id'] . "'");
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10";
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : -1;
    $by = $vars['by'] == 'ASC' ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        default:
            $order_sql = " ORDER BY `id` {$by}";
    }
    $md5 = md5($where_sql . $order_sql);
    $offset = 0;
    $limit = "LIMIT {$maxperpage}";
    if ($vars['page']) {
        isset($vars['total_cache']) && ($_GET['total_cahce'] = true);
        $total = iPHP::total($md5, "SELECT count(*) FROM `#iCMS@__comment` WHERE {$where_sql} limit 1");
        $pgconf = array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:comment'), 'ajax' => $vars['page_ajax'] ? 'iCMS.comment.page' : FALSE, 'nowindex' => $GLOBALS['page']);
        if ($vars['display'] == 'iframe' || $vars['page_ajax']) {
            iS::gp('pn', 'GP', 2);
            $pgconf['page_name'] = 'pn';
            $pgconf['nowindex'] = $GLOBALS['pn'];
        }
        isset($vars['total_cache']) && ($pgconf['total_type'] = $vars['total_cache']);
        $multi = iCMS::page($pgconf);
        $offset = $multi->offset;
        $limit = "LIMIT {$offset},{$maxperpage}";
        // if($offset>1000){
        //$where_sql.=" AND `id` >= (SELECT `id` FROM `#iCMS@__comment` WHERE {$where_sql} {$order_sql} LIMIT {$offset},1)";
        //$limit  = "LIMIT {$maxperpage}";
        // }
        iPHP::assign("comment_total", $total);
    }
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/comment/' . $md5 . "/" . (int) $offset;
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $resource = iDB::all("SELECT * FROM `#iCMS@__comment` WHERE {$where_sql} {$order_sql} {$limit}");
        //iDB::debug(1);
        $ln = $GLOBALS['page'] - 1 < 0 ? 0 : $GLOBALS['page'] - 1;
        if ($resource) {
            foreach ($resource as $key => $value) {
                if ($vars['date_format']) {
                    $value['addtime'] = get_date($value['addtime'], $vars['date_format']);
                }
                $value['url'] = iCMS_API . '?app=comment&do=goto&iid=' . $value['iid'] . '&appid=' . $value['appid'] . '&cid=' . $value['cid'];
                $value['lou'] = $total - ($i + $ln * $maxperpage);
                $value['content'] = nl2br($value['content']);
                $value['user'] = user::info($value['userid'], $value['username'], $vars['facesize']);
                $value['reply_uid'] && ($value['reply'] = user::info($value['reply_uid'], $value['reply_name'], $vars['facesize']));
                $value['total'] = $total;
                if ($vars['page']) {
                    $value['page'] = array('total' => $multi->totalpage, 'perpage' => $multi->perpage);
                }
                $value['param'] = array("appid" => iCMS_APP_COMMENT, "id" => $value['id'], "userid" => $value['userid'], "name" => $value['username']);
                $resource[$key] = $value;
            }
        }
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Exemple #17
0
 function get_prop($field, $val = NULL, $out = 'option', $url = "", $type = "")
 {
     $type or $type = iACP::$app_name;
     $propArray = iCache::get("iCMS/prop/{$type}/{$field}");
     $valArray = explode(',', $val);
     foreach ((array) $propArray as $k => $P) {
         if ($out == 'option') {
             $opt .= "<option value='{$P['val']}'" . (array_search($P['val'], $valArray) !== FALSE ? " selected='selected'" : '') . ">{$P['name']}[{$field}='{$P['val']}'] </option>";
         } elseif ($out == 'text') {
             if (array_search($P['val'], $valArray) !== FALSE) {
                 $flag = '<i class="fa fa-flag"></i> ' . $P['name'];
                 $opt .= ($url ? '<a href="' . str_replace('{PID}', $P['val'], $url) . '">' . $flag . '</a>' : $flag) . '<br />';
             }
         }
     }
     // $opt.='</select>';
     return $opt;
 }
Exemple #18
0
 public static function getCache($tid)
 {
     $tkey = self::tkey($tid);
     return iCache::get($tkey);
 }
Exemple #19
0
 public static function get_cache($uid)
 {
     return iCache::get('iCMS:user:' . $uid);
 }
Exemple #20
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;
}
Exemple #21
0
 public static function filter(&$content)
 {
     $cache = iCache::get(array('iCMS/word.filter', 'iCMS/word.disable'));
     $filter = $cache['iCMS/word.filter'];
     //filter过滤
     $disable = $cache['iCMS/word.disable'];
     //disable禁止
     //禁止关键词
     $subject = $content;
     $pattern = '/(~|`|!|@|\\#|\\$|%|\\^|&|\\*|\\(|\\)|\\-|=|_|\\+|\\{|\\}|\\[|\\]|;|:|"|\'|<|>|\\?|\\/|,|\\.|\\s|\\n|。|,|、|;|:|?|!|…|-|·|ˉ|ˇ|¨|‘|“|”|々|~|‖|∶|"|'|`|||〃|〔|〕|〈|〉|《|》|「|」|『|』|.|〖|〗|【|】|(|)|[|]|{|}|°|′|″|$|£|¥|‰|%|℃|¤|¢|○|§|№|☆|★|○|●|◎|◇|◆|□|■|△|▲|※|→|←|↑|↓|〓|#|&|@|^|_|\|№|)*/i';
     $subject = preg_replace($pattern, '', $subject);
     foreach ((array) $disable as $val) {
         $val = trim($val);
         if (strpos($val, '::') !== false) {
             list($tag, $start, $end) = explode('::', $val);
             if ($tag == 'NUM') {
                 $subject = cnum($subject);
                 if (preg_match('/\\d{' . $start . ',' . $end . '}/i', $subject)) {
                     return $val;
                 }
             }
         } else {
             if ($val && preg_match("/" . preg_quote($val, '/') . "/i", $subject)) {
                 return $val;
             }
         }
     }
     //过滤关键词
     foreach ((array) $filter as $k => $val) {
         empty($val[1]) && ($val[1] = '***');
         $val[0] && ($content = preg_replace("/" . preg_quote($val[0], '/') . "/i", $val[1], $content));
     }
 }
Exemple #22
0
/**
 * @package iCMS
 * @copyright 2007-2016, iDreamSoft
 * @license http://www.idreamsoft.com iDreamSoft
 * @author coolmoo <*****@*****.**>
 * @$Id: tag.tpl.php 159 2013-03-23 04:11:53Z coolmoo $
 */
function tag_list($vars)
{
    $where_sql = "WHERE status='1' ";
    $map_where = array();
    if (isset($vars['rootid'])) {
        $where_sql .= " AND `rootid`='" . (int) $vars['rootid'] . "'";
    }
    if (!isset($vars['tcids']) && isset($vars['tcid'])) {
        $where_sql .= iPHP::where($vars['tcid'], 'tcid');
    }
    if (isset($vars['tcids']) && !isset($vars['tcid'])) {
        iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
        map::init('category', iCMS_APP_TAG);
        //$where_sql.= map::exists($vars['tcid'],'`#iCMS@__tags`.id'); //map 表大的用exists
        $map_where += map::where($vars['tcid']);
    }
    if (isset($vars['tcid!'])) {
        $where_sql .= iPHP::where($vars['tcid!'], 'tcid', 'not');
    }
    if (!isset($vars['pids']) && isset($vars['pid'])) {
        $where_sql .= iPHP::where($vars['pid'], 'pid');
    }
    if (isset($vars['pids']) && !isset($vars['pid'])) {
        iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
        map::init('prop', iCMS_APP_TAG);
        //$where_sql.= map::exists($vars['pids'],'`#iCMS@__tags`.id'); //map 表大的用exists
        $map_where += map::where($vars['pids']);
    }
    if (isset($vars['pid!'])) {
        $where_sql .= iPHP::where($vars['pid!'], 'pid', 'not');
    }
    if (!isset($vars['cids']) && isset($vars['cid'])) {
        $cid = explode(',', $vars['cid']);
        $vars['sub'] && ($cid += iCMS::get_category_ids($cid, true));
        $where_sql .= iPHP::where($cid, 'cid');
    }
    if (isset($vars['cids']) && !isset($vars['cid'])) {
        $cids = explode(',', $vars['cids']);
        $vars['sub'] && ($cids += iCMS::get_category_ids($vars['cids'], true));
        if ($cids) {
            iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
            map::init('category', iCMS_APP_TAG);
            $map_where += map::where($cids);
        }
    }
    if (isset($vars['cid!'])) {
        $ncids = explode(',', $vars['cid!']);
        $vars['sub'] && ($ncids += iCMS::get_category_ids($ncids, true));
        $where_sql .= iPHP::where($ncids, 'cid', 'not');
    }
    if (isset($vars['keywords'])) {
        //最好使用 iCMS:tag:search
        if (empty($vars['keywords'])) {
            return;
        }
        if (strpos($vars['keywords'], ',') === false) {
            $vars['keywords'] = str_replace(array('%', '_'), array('\\%', '\\_'), $vars['keywords']);
            $where_sql .= " AND CONCAT(tkey,name,seotitle,keywords) like '%" . addslashes($vars['keywords']) . "%'";
        } else {
            $kws = explode(',', $vars['keywords']);
            foreach ($kws as $kwv) {
                $keywords .= addslashes($kwv) . "|";
            }
            $keywords = substr($keywords, 0, -1);
            $where_sql .= " AND CONCAT(tkey,name,seotitle,keywords) REGEXP '{$keywords}' ";
        }
    }
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10";
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : -1;
    $by = $vars['by'] == 'ASC' ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        case "hot":
            $order_sql = " ORDER BY `count` {$by}";
            break;
        case "new":
            $order_sql = " ORDER BY `id` {$by}";
            break;
        case "order":
            $order_sql = " ORDER BY `ordernum` {$by}";
            break;
            //		case "rand":	$order_sql=" ORDER BY rand() $by";		break;
        //		case "rand":	$order_sql=" ORDER BY rand() $by";		break;
        default:
            $order_sql = " ORDER BY `id` {$by}";
    }
    if ($map_where) {
        $map_sql = iCMS::map_sql($map_where);
        $where_sql = ",({$map_sql}) map {$where_sql} AND `id` = map.`iid`";
    }
    $offset = 0;
    $limit = "LIMIT {$maxperpage}";
    if ($vars['page']) {
        $total = iPHP::total('sql.md5', "SELECT count(*) FROM `#iCMS@__tags` {$where_sql} ");
        iPHP::assign("tags_total", $total);
        $multi = iCMS::page(array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:list'), 'nowindex' => $GLOBALS['page']));
        $offset = $multi->offset;
        $limit = "LIMIT {$offset},{$maxperpage}";
        iPHP::assign("tags_list_total", $total);
    }
    if ($vars['orderby'] == 'rand') {
        $ids_array = iCMS::get_rand_ids('#iCMS@__tags', $where_sql, $maxperpage, 'id');
    }
    $hash = md5($where_sql . $order_sql . $limit);
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/tags/' . $md5 . "/" . (int) $GLOBALS['page'];
        $resource = iCache::get($cache_name);
    }
    if ($map_sql || $offset) {
        if ($vars['cache']) {
            $map_cache_name = iPHP_DEVICE . '/tags_map/' . $hash;
            $ids_array = iCache::get($map_cache_name);
        }
        if (empty($ids_array)) {
            $ids_array = iDB::all("SELECT `id` FROM `#iCMS@__tags` {$where_sql} {$order_sql} {$limit}");
            iPHP_SQL_DEBUG && iDB::debug(1);
            $vars['cache'] && iCache::set($map_cache_name, $ids_array, $cache_time);
        }
        //iDB::debug(1);
    }
    if ($ids_array) {
        $ids = iCMS::get_ids($ids_array);
        $ids = $ids ? $ids : '0';
        $where_sql = "WHERE `#iCMS@__tags`.`id` IN({$ids})";
        $limit = '';
    }
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/tags/' . $hash;
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $resource = iDB::all("SELECT * FROM `#iCMS@__tags` {$where_sql} {$order_sql} {$limit}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        $resource = __tag_array($vars, $resource);
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Exemple #23
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;
}
Exemple #24
0
 public function select($permission = '', $_cid = "0", $cid = "0", $level = 1)
 {
     $array = iCache::get('iCMS/category.' . iCMS_APP_ARTICLE . '/array');
     foreach ((array) $array[$cid] as $root => $C) {
         if ($C['status'] && $C['isucshow'] && $C['issend'] && empty($C['outurl'])) {
             $tag = $level == '1' ? "" : "├ ";
             $selected = $_cid == $C['cid'] ? "selected" : "";
             $text = str_repeat("│ ", $level - 1) . $tag . $C['name'] . "[cid:{$C['cid']}]" . ($C['outurl'] ? "[∞]" : "");
             $C['isexamine'] && ($text .= '[审核]');
             $option .= "<option value='{$C['cid']}' {$selected}>{$text}</option>";
         }
         $array[$C['cid']] && ($option .= $this->select($permission, $_cid, $C['cid'], $level + 1, $url));
     }
     return $option;
 }
Exemple #25
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;
 }