Пример #1
0
 public function del_cahce($cid = null)
 {
     if (empty($cid)) {
         return;
     }
     iCache::delete('iCMS/category/' . $cid);
 }
Пример #2
0
 /**
  * Given the hash, this function will remove it from the cache.
  *
  * @param string $hash
  *  The user defined hash of the data
  * @param string $namespace
  *  Delete multiple items by a namespace
  * @return boolean
  */
 public function delete($hash = null, $namespace = null)
 {
     if ($this->cacheProvider instanceof iNamespacedCache) {
         return $this->cacheProvider->delete($hash, $namespace);
     }
     return $this->cacheProvider->delete($hash);
 }
Пример #3
0
 function get_array($cache = false)
 {
     $rs = iDB::all("SELECT * FROM `#iCMS@__menu` ORDER BY `ordernum` , `id` ASC");
     $this->menu_array = array();
     $this->root_array = array();
     $this->parent = array();
     $this->menu_uri = array();
     $this->child_array = array();
     foreach ((array) $rs as $M) {
         $this->menu_array[$M['id']] = $M;
         $this->root_array[$M['rootid']][$M['id']] = $M;
         $this->parent[$M['id']] = $M['rootid'];
         $M['app'] != 'separator' && ($this->child_array[$M['rootid']][$M['id']] = $M['id']);
         if (!$this->menu_uri[$M['app']][$M['href']]) {
             $this->menu_uri[$M['app']][$M['href']] = $M['id'];
         }
         $this->menu_uri[$M['app']]['#'] = $M['rootid'];
     }
     foreach ((array) $this->root_array as $rid => $array) {
         uasort($array, "order_num");
         $this->root_array[$rid] = $array;
     }
     if ($cache) {
         iCache::set('iCMS/iMenu/menu_array', $this->menu_array, 0);
         iCache::set('iCMS/iMenu/root_array', $this->root_array, 0);
         iCache::set('iCMS/iMenu/child_array', $this->child_array, 0);
         iCache::set('iCMS/iMenu/parent', $this->parent, 0);
         iCache::set('iCMS/iMenu/menu_uri', $this->menu_uri, 0);
     }
 }
Пример #4
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");
 }
Пример #5
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;
}
Пример #6
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;
 }
Пример #7
0
 function cache()
 {
     $filter = $this->setting->get(0, 'word.filter');
     $disable = $this->setting->get(0, 'word.disable');
     foreach ((array) $filter as $k => $val) {
         $filterArray[$k] = implode("=", (array) $val);
     }
     iCache::set('iCMS/word.filter', $filter, 0);
     iCache::set('iCMS/word.disable', $filterArray, 0);
 }
Пример #8
0
 function getAllCache()
 {
     $cache = iCache::sysCache();
     $this->menu_array = $cache->get('iCMS/iMenu/menu_array');
     $this->root_array = $cache->get('iCMS/iMenu/root_array');
     $this->child_array = $cache->get('iCMS/iMenu/child_array');
     $this->parent = $cache->get('iCMS/iMenu/parent');
     $this->menu_uri = $cache->get('iCMS/iMenu/menu_uri');
     // iCache::destroy();
 }
Пример #9
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;
}
Пример #10
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;
}
Пример #11
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;
 }
Пример #12
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;
}
Пример #13
0
 function do_save()
 {
     $appid = $this->appid;
     $cid = (int) $_POST['cid'];
     $rootid = (int) $_POST['rootid'];
     $status = (int) $_POST['status'];
     $isucshow = (int) $_POST['isucshow'];
     $issend = (int) $_POST['issend'];
     $isexamine = (int) $_POST['isexamine'];
     $ordernum = (int) $_POST['ordernum'];
     $mode = (int) $_POST['mode'];
     $pid = implode(',', (array) $_POST['pid']);
     $_pid = iS::escapeStr($_POST['_pid']);
     $_rootid_hash = iS::escapeStr($_POST['_rootid_hash']);
     $name = iS::escapeStr($_POST['name']);
     $subname = iS::escapeStr($_POST['subname']);
     $domain = iS::escapeStr($_POST['domain']);
     $htmlext = iS::escapeStr($_POST['htmlext']);
     $url = iS::escapeStr($_POST['url']);
     $password = iS::escapeStr($_POST['password']);
     $pic = iS::escapeStr($_POST['pic']);
     $mpic = iS::escapeStr($_POST['mpic']);
     $spic = iS::escapeStr($_POST['spic']);
     $dir = iS::escapeStr($_POST['dir']);
     $title = iS::escapeStr($_POST['title']);
     $keywords = iS::escapeStr($_POST['keywords']);
     $description = iS::escapeStr($_POST['description']);
     $categoryURI = iS::escapeStr($_POST['categoryURI']);
     $categoryRule = iS::escapeStr($_POST['categoryRule']);
     $contentRule = iS::escapeStr($_POST['contentRule']);
     $urlRule = iS::escapeStr($_POST['urlRule']);
     $indexTPL = iS::escapeStr($_POST['indexTPL']);
     $listTPL = iS::escapeStr($_POST['listTPL']);
     $contentTPL = iS::escapeStr($_POST['contentTPL']);
     $metadata = iS::escapeStr($_POST['metadata']);
     $contentprop = iS::escapeStr($_POST['contentprop']);
     $body = $_POST['body'];
     $hasbody = (int) $_POST['hasbody'];
     $hasbody or $hasbody = $body ? 1 : 0;
     if ($_rootid_hash) {
         $_rootid = authcode($_rootid_hash);
         if ($rootid != $_rootid) {
             iPHP::alert('非法数据提交!');
         } else {
             iACP::CP($_rootid, 'a', 'alert');
             exit;
         }
     }
     $cid && $cid == $rootid && iPHP::alert('不能以自身做为上级' . $this->category_name);
     empty($name) && iPHP::alert($this->category_name . '名称不能为空!');
     if ($metadata) {
         $md = array();
         foreach ($metadata['key'] as $_mk => $_mval) {
             !preg_match("/[a-zA-Z0-9_\\-]/", $_mval) && iPHP::alert($this->category_name . '附加属性名称只能由英文字母、数字或_-组成(不支持中文)');
             $md[$_mval] = $metadata['value'][$_mk];
         }
         $metadata = addslashes(serialize($md));
     }
     if ($contentprop) {
         $ca = array();
         foreach ($contentprop['key'] as $_cak => $_caval) {
             $_caval or $_caval = strtolower(pinyin($contentprop['name'][$_cak]));
             !preg_match("/[a-zA-Z0-9_\\-]/", $_caval) && iPHP::alert('内容附加属性字段只能由英文字母、数字或_-组成(不支持中文)');
             $ca[$_caval] = $contentprop['name'][$_cak];
         }
         $contentprop = addslashes(serialize($ca));
     }
     if ($mode == "2") {
         if (strpos($categoryRule, '{CDIR}') === FALSE && strpos($categoryRule, '{CID}') === FALSE && strpos($categoryRule, '{0xCID}') === FALSE) {
             iPHP::alert('伪静态模式下版块URL规则<hr />必需要有<br />{CDIR}版块目录<br />或者<br />{CID},{0xCID}版块ID');
         }
         if (strpos($contentRule, '{ID}') === FALSE && strpos($contentRule, '{0xID}') === FALSE && strpos($contentRule, '{LINK}') === FALSE) {
             iPHP::alert('伪静态模式下内容URL规则<hr />必需要有<br />{ID}' . $this->_app_name . 'ID <br />或者<br />{0xID}' . $this->_app_name . 'ID补零<br />或者<br />{LINK}' . $this->_app_name . '自定义链接');
         }
     }
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     map::init('prop', iCMS_APP_CATEGORY);
     $fields = array('rootid', 'appid', 'ordernum', 'name', 'subname', 'password', 'title', 'keywords', 'description', 'dir', 'mode', 'domain', 'url', 'pic', 'mpic', 'spic', 'htmlext', 'categoryURI', 'categoryRule', 'contentRule', 'urlRule', 'indexTPL', 'listTPL', 'contentTPL', 'metadata', 'contentprop', 'hasbody', 'pid', 'isexamine', 'issend', 'isucshow', 'status');
     $data = compact($fields);
     if (empty($cid)) {
         iACP::CP($rootid, 'a', 'alert');
         $nameArray = explode("\n", $name);
         $_count = count($nameArray);
         foreach ($nameArray as $nkey => $_name) {
             $_name = trim($_name);
             if (empty($_name)) {
                 continue;
             }
             if ($_count == "1") {
                 if (empty($dir) && empty($url)) {
                     $dir = strtolower(pinyin($_name));
                 }
             } else {
                 empty($url) && ($dir = strtolower(pinyin($_name)));
             }
             $this->check_dir($dir, $appid, $url);
             $data['name'] = $_name;
             $data['dir'] = $dir;
             $data['userid'] = iMember::$userid;
             $data['creator'] = iMember::$nickname;
             $data['createtime'] = time();
             $data['count'] = '0';
             $data['comments'] = '0';
             $cid = iDB::insert('category', $data);
             $pid && map::add($pid, $cid);
             $this->cache(false, $this->appid);
             $this->cahce_one($cid);
         }
         $msg = $this->category_name . "添加完成!";
     } else {
         if (empty($dir) && empty($url)) {
             $dir = strtolower(pinyin($name));
         }
         iACP::CP($cid, 'e', 'alert');
         $this->check_dir($dir, $appid, $url, $cid);
         $data['dir'] = $dir;
         iDB::update('category', $data, array('cid' => $cid));
         map::diff($pid, $_pid, $cid);
         $this->cahce_one($cid);
         $msg = $this->category_name . "编辑完成!";
     }
     $hasbody && iCache::set('iCMS/category/' . $cid . '.body', $body, 0);
     iPHP::success($msg, 'url:' . $this->category_uri);
 }
Пример #14
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;
}
Пример #15
0
 public static function del($tags, $field = 'name', $iid = 0)
 {
     $tagArray = explode(",", $tags);
     $iid && ($sql = "AND `iid`='{$iid}'");
     foreach ($tagArray as $k => $v) {
         $tagA = iDB::row("SELECT * FROM `#iCMS@__tags` WHERE `{$field}`='{$v}' LIMIT 1;");
         $tRS = iDB::all("SELECT `iid` FROM `#iCMS@__tags_map` WHERE `node`='{$tagA->id}' AND `appid`='" . TAG_APPID . "' {$sql}");
         foreach ((array) $tRS as $TL) {
             $idA[] = $TL['iid'];
         }
         // if($idA){
         // 	iPHP::appClass('model',"break");
         // 	$table	= model::table(TAG_APPID);
         // 	$ids	= implode(',',$idA);
         // 	iDB::query("UPDATE `#iCMS@__$table` SET `tags`=REPLACE(tags, '$tagA->name,',''),`tags`=REPLACE(tags, ',$tagA->name','') WHERE id IN($ids)");
         // }
         iDB::query("DELETE FROM `#iCMS@__tags`  WHERE `{$field}`='{$v}'");
         iDB::query("DELETE FROM `#iCMS@__tags_map` WHERE `node`='{$tagA->id}' AND `appid`='" . TAG_APPID . "' {$sql}");
         $ckey = self::tkey($tagA->cid);
         iCache::delete($ckey);
     }
 }
Пример #16
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;
 }
Пример #17
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;
}
Пример #18
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;
 }
Пример #19
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;
}
Пример #20
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;
}
Пример #21
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;
 }
Пример #22
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;
 }
Пример #23
0
 function cache()
 {
     $rs = iDB::all("SELECT * FROM `#iCMS@__keywords` ORDER BY CHAR_LENGTH(`keyword`) DESC");
     iCache::set('iCMS/keywords', $rs, 0);
 }
Пример #24
0
 public static function destroy()
 {
     self::$link = null;
 }
Пример #25
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;
}
Пример #26
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));
     }
 }
Пример #27
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;
 }
Пример #28
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;
}
Пример #29
0
 function cache($id = null)
 {
     $id && ($sql = " AND `id`='{$id}'");
     $rs = iDB::all("SELECT * FROM `#iCMS@__marker` WHERE `status`='1' {$sql} ");
     foreach ((array) $rs as $row) {
         iCache::set('marker/' . $row['key'], $row['data'], 0);
     }
 }
Пример #30
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;
 }