示例#1
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;
}
示例#2
0
 function do_iCMS($appid = 0)
 {
     iPHP::import(iPHP_APP_CORE . '/iAPP.class.php');
     $this->categoryApp = iACP::app('category', 'all');
     $this->category = $this->categoryApp->category;
     $sql = "WHERE 1=1";
     if ($appid || $_GET['appid']) {
         $_GET['appid'] && ($appid = (int) $_GET['appid']);
         $sql .= " AND `appid`='{$appid}'";
     }
     $_GET['iid'] && ($sql .= " AND `iid`='" . (int) $_GET['iid'] . "'");
     isset($_GET['status']) && ($sql .= " AND `status`='" . $_GET['status'] . "'");
     if ($_GET['cid']) {
         $cid = (int) $_GET['cid'];
         if (isset($_GET['sub'])) {
             $cids = $this->categoryApp->get_ids($cid, true);
             array_push($cids, $cid);
             $sql .= " AND cid IN(" . implode(',', $cids) . ")";
         } else {
             $sql .= " AND cid ='{$cid}'";
         }
     }
     $_GET['userid'] && ($sql .= " AND `userid`='" . (int) $_GET['userid'] . "'");
     $_GET['ip'] && ($sql .= " AND `ip`='" . $_GET['ip'] . "'");
     if ($_GET['keywords']) {
         $sql .= "  AND CONCAT(username,title) REGEXP '{$_GET['keywords']}'";
     }
     $maxperpage = $_GET['perpage'] > 0 ? (int) $_GET['perpage'] : 20;
     $total = iPHP::total(false, "SELECT count(*) FROM `#iCMS@__comment` {$sql}", "G");
     iPHP::pagenav($total, $maxperpage, "条评论");
     $rs = iDB::all("SELECT * FROM `#iCMS@__comment` {$sql} order by id DESC LIMIT " . iPHP::$offset . " , {$maxperpage}");
     $_count = count($rs);
     include iACP::view("comment.manage");
 }
示例#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
 public function cache($one = false, $appid = null)
 {
     $rs = iDB::all("SELECT * FROM `#iCMS@__category` ORDER BY `ordernum` , `cid` ASC");
     foreach ((array) $rs as $C) {
         $C = $this->C($C);
         $one && $this->cahce_one($C);
         $appidArray[$C['appid']] = $C['appid'];
         $parent[$C['cid']] = $C['rootid'];
         $dir2cid[$C['dir']] = $C['cid'];
         $rootid[$C['rootid']][$C['cid']] = $C['cid'];
         $C['status'] or $hidden[] = $C['cid'];
         $cache[$C['appid']][$C['cid']] = $C;
         $array[$C['appid']][$C['rootid']][$C['cid']] = $C;
     }
     if ($appid === null) {
         foreach ((array) $appidArray as $_appid) {
             iCache::set('iCMS/category.' . $_appid . '/cache', $cache[$_appid], 0);
             iCache::set('iCMS/category.' . $_appid . '/array', $array[$_appid], 0);
         }
     } else {
         iCache::set('iCMS/category.' . $appid . '/cache', $cache[$appid], 0);
         iCache::set('iCMS/category.' . $appid . '/array', $array[$appid], 0);
     }
     iCache::set('iCMS/category/rootid', $rootid, 0);
     iCache::set('iCMS/category/parent', $parent, 0);
     iCache::set('iCMS/category/dir2cid', $dir2cid, 0);
     iCache::set('iCMS/category/hidden', $hidden, 0);
 }
示例#5
0
 public static function ids($nodes = 0)
 {
     if (empty($nodes)) {
         return false;
     }
     $sql = self::sql($nodes);
     $all = iDB::all($ids . 'Limit 10000');
     return iCMS::get_ids($all, 'iid');
 }
示例#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;
}
示例#7
0
 function do_iCMS()
 {
     if ($_GET['keywords']) {
         $sql = " WHERE `search` like '%{$_GET['keywords']}%'";
     }
     $orderby = $_GET['orderby'] ? $_GET['orderby'] : "id DESC";
     $maxperpage = $_GET['perpage'] > 0 ? (int) $_GET['perpage'] : 20;
     $total = iPHP::total(false, "SELECT count(*) FROM `#iCMS@__search_log` {$sql}", "G");
     iPHP::pagenav($total, $maxperpage, "条记录");
     $rs = iDB::all("SELECT * FROM `#iCMS@__search_log` {$sql} order by {$orderby} LIMIT " . iPHP::$offset . " , {$maxperpage}");
     $_count = count($rs);
     include iACP::view("search.manage");
 }
示例#8
0
 public static function get_rand_ids($table, $where = null, $limit = '10', $primary = 'id')
 {
     $whereSQL = $where ? "{$where} AND `{$table}`.`{$primary}` >= rand_id" : ' WHERE `{$table}`.`{$primary}` >= rand_id';
     // $limitNum = rand(2,10);
     // $prelimit = ceil($limit/rand(2,10));
     $randSQL = "\n            SELECT `{$table}`.`{$primary}` FROM `{$table}`\n            JOIN (SELECT\n                  ROUND(RAND() * (\n                      (SELECT MAX(`{$table}`.`{$primary}`) FROM `{$table}`) -\n                      (SELECT MIN(`{$table}`.`{$primary}`) FROM `{$table}`)\n                    ) + (SELECT MIN(`{$table}`.`{$primary}`) FROM `{$table}`)\n                 ) AS rand_id) RAND_DATA\n            {$whereSQL}\n            LIMIT {$limit};\n        ";
     $randIdsArray = iDB::all($randSQL);
     // $randIdsArray = null;
     // for ($i=0; $i <=$prelimit; $i++) {
     //     $randIdsArray[$i] = array('id'=>iDB::value($randSQL));
     //     echo iDB::$last_query;
     // }
     return $randIdsArray;
 }
示例#9
0
 function do_iCMS()
 {
     if ($_GET['keywords']) {
         $sql = " WHERE CONCAT(name,url) REGEXP '{$_GET['keywords']}'";
     }
     if ($_GET['cid']) {
         $sql = " WHERE `cid` = '{$_GET['cid']}'";
     }
     $orderby = $_GET['orderby'] ? $_GET['orderby'] : "id DESC";
     $maxperpage = $_GET['perpage'] > 0 ? (int) $_GET['perpage'] : 20;
     $total = iPHP::total(false, "SELECT count(*) FROM `#iCMS@__links` {$sql}", "G");
     iPHP::pagenav($total, $maxperpage, "个网站");
     $rs = iDB::all("SELECT * FROM `#iCMS@__links` {$sql} order by {$orderby} LIMIT " . iPHP::$offset . " , {$maxperpage}");
     $_count = count($rs);
     include iACP::view("links.manage");
 }
示例#10
0
 function do_iCMS()
 {
     if ($_GET['job']) {
         require_once iPHP_APP_CORE . '/iJob.class.php';
         $job = new JOB();
     }
     $sql = "WHERE 1=1";
     //isset($this->type)	&& $sql.=" AND `type`='$this->type'";
     $_GET['gid'] && ($sql .= " AND `gid`='{$_GET['gid']}'");
     $orderby = $_GET['orderby'] ? $_GET['orderby'] : "uid DESC";
     $maxperpage = $_GET['perpage'] > 0 ? (int) $_GET['perpage'] : 20;
     $total = iPHP::total(false, "SELECT count(*) FROM `#iCMS@__members` {$sql}", "G");
     iPHP::pagenav($total, $maxperpage, "个用户");
     $rs = iDB::all("SELECT * FROM `#iCMS@__members` {$sql} order by {$orderby} LIMIT " . iPHP::$offset . " , {$maxperpage}");
     $_count = count($rs);
     include iACP::view("account.manage");
 }
示例#11
0
 public static function follow($uid = 0, $fuid = 0)
 {
     if ($uid === 'all') {
         //all fans
         $rs = iDB::all("SELECT `uid`,`name` FROM `#iCMS@__user_follow` where `fuid`='{$fuid}'");
     }
     if ($fuid === 'all') {
         // all follow
         $rs = iDB::all("SELECT `fuid` AS `uid`,`fname` AS `name` FROM `#iCMS@__user_follow` where `uid`='{$uid}'");
     }
     if (isset($rs)) {
         foreach ((array) $rs as $key => $value) {
             $follow[$value['uid']] = $value['name'];
         }
         return $follow;
     }
     $fuid = iDB::row("SELECT `fuid` FROM `#iCMS@__user_follow` where `uid`='{$uid}' and `fuid`='{$fuid}' limit 1");
     return $fuid ? $fuid : false;
 }
示例#12
0
文件: tags.app.php 项目: World3D/iCMS
 function do_manage()
 {
     $sql = " where 1=1";
     $cid = (int) $_GET['cid'];
     $tcid = (int) $_GET['tcid'];
     $pid = (int) $_GET['pid'];
     $_GET['keywords'] && ($sql .= " AND CONCAT(name,seotitle,subtitle,keywords,description) REGEXP '{$_GET['keywords']}'");
     $sql .= $this->categoryApp->search_sql($cid);
     $sql .= $this->tagcategory->search_sql($tcid, 'tcid');
     isset($_GET['pic']) && ($sql .= " AND `haspic` ='" . ($_GET['pic'] ? 1 : 0) . "'");
     if (isset($_GET['pid']) && $pid != '-1') {
         $uri_array['pid'] = $pid;
         if ($_GET['pid'] == 0) {
             $sql .= " AND `pid`=''";
         } else {
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('prop', $this->appid);
             $map_where = map::where($pid);
         }
     }
     if ($map_where) {
         $map_sql = iCMS::map_sql($map_where);
         $sql = ",({$map_sql}) map {$sql} AND `id` = map.`iid`";
     }
     $orderby = $_GET['orderby'] ? $_GET['orderby'] : "id DESC";
     $maxperpage = $_GET['perpage'] > 0 ? (int) $_GET['perpage'] : 20;
     $total = iPHP::total(false, "SELECT count(*) FROM `#iCMS@__tags` {$sql}", "G");
     iPHP::pagenav($total, $maxperpage, "个标签");
     $limit = 'LIMIT ' . iPHP::$offset . ',' . $maxperpage;
     if ($map_sql || iPHP::$offset) {
         $ids_array = iDB::all("\n                SELECT `id` FROM `#iCMS@__tags` {$sql}\n                ORDER BY {$orderby} {$limit}\n            ");
         //iDB::debug(1);
         $ids = iCMS::get_ids($ids_array);
         $ids = $ids ? $ids : '0';
         $sql = "WHERE `id` IN({$ids})";
         $limit = '';
     }
     $rs = iDB::all("SELECT * FROM `#iCMS@__tags` {$sql} ORDER BY {$orderby} {$limit}");
     $_count = count($rs);
     include iACP::view("tags.manage");
 }
示例#13
0
 public static function cache()
 {
     $rs = iDB::all("SELECT `id`,`name`,`title`,`table`,`field` FROM `#iCMS@__app`");
     foreach ((array) $rs as $a) {
         $tb_array = json_decode($a['table']);
         $table = array('name' => '#iCMS@__' . $tb_array[0][0], 'primary' => $tb_array[0][1]);
         if ($tb_array[1]) {
             $table['join'] = '#iCMS@__' . $tb_array[1][0];
             $table['on'] = $tb_array[1][1];
         }
         $a['table'] = $table;
         $app_id_array[$a['id']] = $a;
         $app_name_array[$a['name']] = $a;
         iCache::delete('iCMS/app/' . $a['id']);
         iCache::set('iCMS/app/' . $a['id'], $a, 0);
         iCache::delete('iCMS/app/' . $a['name']);
         iCache::set('iCMS/app/' . $a['name'], $a, 0);
     }
     iCache::set('iCMS/app/cache_id', $app_id_array, 0);
     iCache::set('iCMS/app/cache_name', $app_name_array, 0);
 }
示例#14
0
文件: home.app.php 项目: sunhk25/iCMS
 function do_iCMS()
 {
     //数据统计
     $rs = iDB::all("SHOW FULL TABLES FROM `" . iPHP_DB_NAME . "` WHERE table_type = 'BASE TABLE';");
     foreach ($rs as $k => $val) {
         if (strstr(iPHP_DB_PREFIX, $val['Tables_in_' . iPHP_DB_NAME]) === false) {
             $iTable[] = strtoupper($val['Tables_in_' . iPHP_DB_NAME]);
         } else {
             $oTable[] = $val['Tables_in_' . iPHP_DB_NAME];
         }
     }
     $content_datasize = 0;
     $tables = iDB::all("SHOW TABLE STATUS");
     $_count = count($tables);
     for ($i = 0; $i < $_count; $i++) {
         $tableName = strtoupper($tables[$i]['Name']);
         if (in_array($tableName, $iTable)) {
             $datasize += $tables[$i]['Data_length'];
             $indexsize += $tables[$i]['Index_length'];
             if (stristr(strtoupper(iPHP_DB_PREFIX . "article," . iPHP_DB_PREFIX . "category," . iPHP_DB_PREFIX . "comment," . iPHP_DB_PREFIX . "article_data"), $tableName)) {
                 $content_datasize += $tables[$i]['Data_length'] + $tables[$i]['Index_length'];
             }
         }
     }
     $acc = iDB::value("SELECT count(*) FROM `#iCMS@__category` WHERE `appid`='" . iCMS_APP_ARTICLE . "'");
     $tac = iDB::value("SELECT count(*) FROM `#iCMS@__category` WHERE `appid`='" . iCMS_APP_TAG . "'");
     $pac = iDB::value("SELECT count(*) FROM `#iCMS@__category` WHERE `appid`='" . iCMS_APP_PUSH . "'");
     $ac = iDB::value("SELECT count(*) FROM `#iCMS@__article`");
     $ac0 = iDB::value("SELECT count(*) FROM `#iCMS@__article` WHERE `status`='0'");
     $ac2 = iDB::value("SELECT count(*) FROM `#iCMS@__article` WHERE `status`='2'");
     $ctc = iDB::value("SELECT count(*) FROM `#iCMS@__comment`");
     $tc = iDB::value("SELECT count(*) FROM `#iCMS@__tags`");
     $kc = iDB::value("SELECT count(*) FROM `#iCMS@__keywords`");
     $pc = iDB::value("SELECT count(*) FROM `#iCMS@__push`");
     $uc = iDB::value("SELECT count(*) FROM `#iCMS@__user`");
     $fdc = iDB::value("SELECT count(*) FROM `#iCMS@__filedata`");
     $lc = iDB::value("SELECT count(*) FROM `#iCMS@__links`");
     include iACP::view("home");
 }
示例#15
0
 function count_post($userid)
 {
     $rs = iDB::all("SELECT `postime`,`status` FROM #iCMS@__article where `userid`='" . $userid . "'");
     $this->total = count($rs);
     $this->today['count'] = $this->yesterday['count'] = $this->month['count'] = $this->pmonth['count'] = 0;
     $this->day_count_post = array();
     $this->count0post = 0;
     foreach ((array) $rs as $key => $a) {
         $this->day_count_post[date('Y-m-j', $a['postime'])]++;
         if ($a['status'] != "1") {
             $this->count0post++;
         }
         if ($a['status'] == "1") {
             $this->count_time_post($a['postime'], $this->today['start'], $this->today['end'], $this->today['count']);
             $this->count_time_post($a['postime'], $this->yesterday['start'], $this->yesterday['end'], $this->yesterday['count']);
             $this->count_time_post($a['postime'], $this->month['start'], $this->month['end'], $this->month['count']);
             $this->count_time_post($a['postime'], $this->pmonth['start'], $this->pmonth['end'], $this->pmonth['count']);
         } else {
             $this->count_time_post($a['postime'], $this->today['start'], $this->today['end'], $this->today['count0']);
         }
     }
 }
示例#16
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;
}
示例#17
0
文件: tag.func.php 项目: Junred/iCMS
/**
 * @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;
}
示例#18
0
 public static function select_filedata_indexid($indexid = '', $fields = 'filename`,`path`,`ext')
 {
     return iDB::all("SELECT `{$fields}` FROM `#iCMS@__filedata` WHERE `indexid`='{$indexid}'");
 }
示例#19
0
文件: html.app.php 项目: World3D/iCMS
 function do_createArticle($aid = null)
 {
     $category = $this->PG['cid'];
     $startime = $this->PG['startime'];
     $endtime = $this->PG['endtime'];
     $startid = $this->PG['startid'];
     $endid = $this->PG['endid'];
     $perpage = (int) $this->PG['perpage'];
     $offset = (int) $this->PG['offset'];
     $orderby = $this->PG['orderby'];
     $whereSQL = "WHERE `status` ='1'";
     $aid === null && ($aid = $this->PG['aid']);
     if ($aid) {
         $title = self::Article($aid);
         iPHP::success($title . '<hr />生成静态完成!');
     }
     $category[0] == 'all' && ($category = $this->get_category(iCMS_APP_ARTICLE));
     if ($category) {
         $cids = implode(',', (array) $category);
         $whereSQL .= " AND `cid` IN({$cids})";
     }
     $startime && ($whereSQL .= " AND `pubdate`>=UNIX_TIMESTAMP('{$startime} 00:00:00')");
     $endtime && ($whereSQL .= " AND `pubdate`<=UNIX_TIMESTAMP('{$endtime} 23:59:59')");
     $startid && ($whereSQL .= " AND `id`>='{$startid}'");
     $endid && ($whereSQL .= " AND `id`<='{$endid}'");
     $perpage or $perpage = $this->CP;
     $orderby or $orderby = "id DESC";
     $total = iPHP::total(false, "SELECT count(*) FROM `#iCMS@__article` {$whereSQL}", "G");
     $looptimes = ceil($total / $perpage);
     $offset = $this->page * $perpage;
     $rs = iDB::all("SELECT `id` FROM `#iCMS@__article` {$whereSQL} order by {$orderby} LIMIT {$offset},{$perpage}");
     $_count = count($rs);
     $msg = "共<span class='label label-info'>{$total}</span>篇文章,将分成<span class='label label-info'>{$looptimes}</span>次完成<hr />开始执行第<span class='label label-info'>" . ($this->page + 1) . "</span>次生成,共<span class='label label-info'>{$_count}</span>篇<hr />";
     for ($i = 0; $i < $_count; $i++) {
         self::Article($rs[$i]['id']);
         $msg .= '<span class="label label-success">' . $rs[$i]['id'] . ' <i class="fa fa-check"></i></span> ';
     }
     $GLOBALS['page']++;
     $use_time = iPHP::timer_stop();
     $msg .= "<hr />用时<span class='label label-info'>{$use_time}</span>秒";
     $query["total_num"] = $total;
     $query["alltime"] = $this->alltime + $use_time;
     $loopurl = $this->loopurl($looptimes, $query);
     if ($loopurl) {
         $moreBtn = array(array("id" => "btn_stop", "text" => "停止", "url" => APP_URI . "&do=article"), array("id" => "btn_next", "text" => "继续", "src" => $loopurl, "next" => true));
         $dtime = 1;
         $all_time = $looptimes * $use_time + $looptimes + 1;
         $msg .= "<hr />预计全部生成还需要<span class='label label-info'>{$all_time}</span>秒";
     } else {
         $moreBtn = array(array("id" => "btn_next", "text" => "完成", "url" => APP_URI . "&do=article"));
         $dtime = 5;
         $msg .= "<hr />已全部生成完成<hr />总共用时<span class='label label-info'>" . $query["alltime"] . "</span>秒";
     }
     $updateMsg = $this->page ? true : false;
     iPHP::dialog($msg, $loopurl ? "src:" . $loopurl : '', $dtime, $moreBtn, $updateMsg);
 }
示例#20
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;
}
示例#21
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;
}
示例#22
0
 function recount()
 {
     $rs = iDB::all("SELECT `cid` FROM `#iCMS@__category` where `appid`='{$this->appid}'");
     foreach ((array) $rs as $key => $value) {
         $this->update_count($value['cid']);
     }
 }
示例#23
0
 function do_project()
 {
     $categoryApp = iACP::app('category', iCMS_APP_ARTICLE);
     $category = $categoryApp->category;
     $sql = "where 1=1";
     if ($_GET['keywords']) {
         $sql .= " and `name` REGEXP '{$_GET['keywords']}'";
     }
     $sql .= $categoryApp->search_sql($this->cid);
     if ($_GET['rid']) {
         $sql .= " AND `rid` ='" . (int) $_GET['rid'] . "'";
     }
     if ($_GET['auto']) {
         $sql .= " AND `auto` ='1'";
     }
     if ($_GET['poid']) {
         $sql .= " AND `poid` ='" . (int) $_GET['poid'] . "'";
     }
     $ruleArray = $this->rule_opt(0, 'array');
     $postArray = $this->post_opt(0, 'array');
     $orderby = $_GET['orderby'] ? $_GET['orderby'] : "id DESC";
     $maxperpage = $_GET['perpage'] > 0 ? (int) $_GET['perpage'] : 20;
     $total = iPHP::total(false, "SELECT count(*) FROM `#iCMS@__spider_project` {$sql}", "G");
     iPHP::pagenav($total, $maxperpage, "个方案");
     $rs = iDB::all("SELECT * FROM `#iCMS@__spider_project` {$sql} order by {$orderby} LIMIT " . iPHP::$offset . " , {$maxperpage}");
     $_count = count($rs);
     include iACP::view("spider.project");
 }
示例#24
0
function user_inbox($vars = null)
{
    $maxperpage = 30;
    $where_sql = "WHERE `status` ='1'";
    if ($_GET['user']) {
        if ($_GET['user'] == "10000") {
            $where_sql .= " AND `userid`='10000' AND `friend` IN ('" . user::$userid . "','0')";
        } else {
            $friend = (int) $_GET['user'];
            $where_sql .= " AND `userid`='" . user::$userid . "' AND `friend`='" . $friend . "'";
        }
        $group_sql = '';
        $p_fields = 'COUNT(*)';
        $s_fields = '*';
        iPHP::assign("msg_count", false);
    } else {
        //	 	$where_sql.= " AND (`userid`='".user::$userid."' OR (`userid`='10000' AND `friend`='0'))";
        $where_sql .= " AND `userid`='" . user::$userid . "'";
        $group_sql = ' GROUP BY `friend` DESC';
        $p_fields = 'COUNT(DISTINCT id)';
        $s_fields = 'max(id) AS id ,COUNT(id) AS msg_count,`userid`, `friend`, `send_uid`, `send_name`, `receiv_uid`, `receiv_name`, `content`, `type`, `sendtime`, `readtime`';
        iPHP::assign("msg_count", true);
    }
    $offset = 0;
    $total = iPHP::total($md5, "SELECT {$p_fields} FROM `#iCMS@__message` {$where_sql} {$group_sql}", 'nocache');
    iPHP::assign("msgs_total", $total);
    $multi = iCMS::page(array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:list'), 'nowindex' => $GLOBALS['page']));
    $offset = $multi->offset;
    $resource = iDB::all("SELECT {$s_fields} FROM `#iCMS@__message` {$where_sql} {$group_sql} ORDER BY `id` DESC LIMIT {$offset},{$maxperpage}");
    iPHP_SQL_DEBUG && iDB::debug(1);
    $msg_type_map = array('0' => '系统信息', '1' => '私信', '2' => '提醒', '3' => '留言');
    if ($resource) {
        foreach ($resource as $key => $value) {
            $value['sender'] = user::info($value['send_uid'], $value['send_name']);
            $value['receiver'] = user::info($value['receiv_uid'], $value['receiv_name']);
            $value['label'] = $msg_type_map[$value['type']];
            if ($value['userid'] == $value['send_uid']) {
                $value['is_sender'] = true;
                $value['user'] = $value['receiver'];
            }
            if ($value['userid'] == $value['receiv_uid']) {
                $value['is_sender'] = false;
                $value['user'] = $value['sender'];
            }
            $value['url'] = iPHP::router(array('/user/inbox/{uid}', $value['user']['uid']), iPHP_ROUTER_REWRITE);
            $resource[$key] = $value;
        }
    }
    return $resource;
}
示例#25
0
文件: push.app.php 项目: World3D/iCMS
 function do_manage($doType = null)
 {
     $cid = (int) $_GET['cid'];
     $sql = " where ";
     switch ($doType) {
         //status:[0:草稿][1:正常][2:回收][3:审核][4:不合格]
         case 'inbox':
             //草稿
             $sql .= "`status` ='0'";
             // if(iMember::$data->gid!=1){
             // 	$sql.=" AND `userid`='".iMember::$userid."'";
             // }
             $position = "草稿";
             break;
         case 'trash':
             //回收站
             $sql .= "`status` ='2'";
             $position = "回收站";
             break;
         case 'examine':
             //审核
             $sql .= "`status` ='3'";
             $position = "已审核";
             break;
         case 'off':
             //未通过
             $sql .= "`status` ='4'";
             $position = "未通过";
             break;
         default:
             $sql .= " `status` ='1'";
             $cid && ($position = $this->category[$cid]['name']);
     }
     if ($_GET['keywords']) {
         $sql .= " AND CONCAT(title,title2,title3) REGEXP '{$_GET['keywords']}'";
     }
     $sql .= $this->categoryApp->search_sql($cid);
     isset($_GET['nopic']) && ($sql .= " AND `haspic` ='0'");
     $_GET['starttime'] && ($sql .= " and `addtime`>=UNIX_TIMESTAMP('" . $_GET['starttime'] . " 00:00:00')");
     $_GET['endtime'] && ($sql .= " and `addtime`<=UNIX_TIMESTAMP('" . $_GET['endtime'] . " 23:59:59')");
     isset($_GET['userid']) && ($uri .= '&userid=' . (int) $_GET['userid']);
     isset($_GET['keyword']) && ($uri .= '&keyword=' . $_GET['keyword']);
     isset($_GET['pid']) && ($uri .= '&pid=' . $_GET['pid']);
     isset($_GET['cid']) && ($uri .= '&cid=' . $_GET['cid']);
     isset($_GET['pid']) && $_GET['pid'] != '-1' && ($uri .= '&pid=' . $_GET['at']);
     $orderby = $_GET['orderby'] ? $_GET['orderby'] : "id DESC";
     $maxperpage = $_GET['perpage'] > 0 ? (int) $_GET['perpage'] : 20;
     $total = iPHP::total(false, "SELECT count(*) FROM `#iCMS@__push` {$sql}", "G");
     iPHP::pagenav($total, $maxperpage, "条记录");
     $rs = iDB::all("SELECT * FROM `#iCMS@__push` {$sql} order by {$orderby} LIMIT " . iPHP::$offset . " , {$maxperpage}");
     $_count = count($rs);
     include iACP::view("push.manage");
 }
示例#26
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);
     }
 }
示例#27
0
文件: prop.app.php 项目: sunhk25/iCMS
 function cache()
 {
     $rs = iDB::all("SELECT * FROM `#iCMS@__prop`");
     foreach ((array) $rs as $row) {
         $type_field_id[$row['type'] . '/' . $row['field']][$row['pid']] = $type_field_val[$row['type']][$row['field']][$row['val']] = $row;
     }
     // prop/article/author
     foreach ((array) $type_field_id as $key => $a) {
         iCache::set('iCMS/prop/' . $key, $a, 0);
     }
     // prop/article
     foreach ((array) $type_field_val as $k => $a) {
         iCache::set('iCMS/prop/' . $k, $a, 0);
     }
 }
示例#28
0
 function do_manage($stype = 'normal')
 {
     $cid = (int) $_GET['cid'];
     $pid = $_GET['pid'];
     //$stype OR $stype = iACP::$app_do;
     $stype_map = array('inbox' => '0', 'normal' => '1', 'trash' => '2', 'examine' => '3', 'off' => '4');
     $map_where = array();
     //status:[0:草稿][1:正常][2:回收][3:待审核][4:不合格]
     //postype: [0:用户][1:管理员]
     $stype && ($this->_status = $stype_map[$stype]);
     if (isset($_GET['pt']) && $_GET['pt'] != '') {
         $this->_postype = (int) $_GET['pt'];
     }
     $sql = "WHERE `status`='{$this->_status}'";
     $this->_postype === 'all' or $sql .= " AND `postype`='{$this->_postype}'";
     if (iACP::MP("ARTICLE.VIEW")) {
         $_GET['userid'] && ($sql .= iPHP::where($_GET['userid'], 'userid'));
     } else {
         $sql .= iPHP::where(iMember::$userid, 'userid');
     }
     if (isset($_GET['pid']) && $pid != '-1') {
         $uri_array['pid'] = $pid;
         if (empty($_GET['pid'])) {
             $sql .= " AND `pid`=''";
         } else {
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('prop', $this->appid);
             $map_where += map::where($pid);
         }
     }
     $cp_cids = iACP::CP('__CID__', 'cs');
     //取得所有有权限的栏目ID
     if ($cp_cids) {
         if (is_array($cp_cids)) {
             if ($cid) {
                 array_search($cid, $cp_cids) === false && iACP::permission_msg('栏目[cid:' . $cid . ']', $ret);
             } else {
                 $cids = $cp_cids;
             }
         } else {
             $cids = $cid;
         }
         if ($_GET['sub'] && $cid) {
             $cids = $this->categoryApp->get_ids($cid, true);
             array_push($cids, $cid);
         }
         if ($_GET['scid'] && $cid) {
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('category', $this->appid);
             $map_where += map::where($cids);
         } else {
             $sql .= iPHP::where($cids, 'cid');
         }
     } else {
         $sql .= iPHP::where('-1', 'cid');
     }
     if ($_GET['keywords']) {
         $kws = $_GET['keywords'];
         switch ($_GET['st']) {
             case "title":
                 $sql .= " AND `title` REGEXP '{$kws}'";
                 break;
             case "tag":
                 $sql .= " AND `tags` REGEXP '{$kws}'";
                 break;
             case "source":
                 $sql .= " AND `source` REGEXP '{$kws}'";
                 break;
             case "weight":
                 $sql .= " AND `weight`='{$kws}'";
                 break;
             case "id":
                 $sql .= " AND `id` REGEXP '{$kws}'";
                 break;
             case "tkd":
                 $sql .= " AND CONCAT(title,keywords,description) REGEXP '{$kws}'";
                 break;
         }
     }
     $_GET['title'] && ($sql .= " AND `title` like '%{$_GET['title']}%'");
     $_GET['tag'] && ($sql .= " AND `tags` REGEXP '[[:<:]]" . preg_quote(rawurldecode($_GET['tag']), '/') . "[[:>:]]'");
     $_GET['starttime'] && ($sql .= " AND `pubdate`>='" . iPHP::str2time($_GET['starttime'] . " 00:00:00") . "'");
     $_GET['endtime'] && ($sql .= " AND `pubdate`<='" . iPHP::str2time($_GET['endtime'] . " 23:59:59") . "'");
     isset($_GET['pic']) && ($sql .= " AND `haspic` ='" . ($_GET['pic'] ? 1 : 0) . "'");
     isset($_GET['userid']) && ($uri_array['userid'] = (int) $_GET['userid']);
     isset($_GET['keyword']) && ($uri_array['keyword'] = $_GET['keyword']);
     isset($_GET['tag']) && ($uri_array['tag'] = $_GET['tag']);
     isset($_GET['pt']) && ($uri_array['pt'] = $_GET['pt']);
     isset($_GET['cid']) && ($uri_array['cid'] = $_GET['cid']);
     $uri_array && ($uri = http_build_query($uri_array));
     $orderby = $_GET['orderby'] ? $_GET['orderby'] : "id DESC";
     $maxperpage = $_GET['perpage'] > 0 ? (int) $_GET['perpage'] : 20;
     if ($map_where) {
         $map_sql = iCMS::map_sql($map_where);
         $sql = ",({$map_sql}) map {$sql} AND `id` = map.`iid`";
     }
     $total = iPHP::total(false, articleTable::count_sql($sql), "G");
     iPHP::pagenav($total, $maxperpage, "篇文章");
     $limit = 'LIMIT ' . iPHP::$offset . ',' . $maxperpage;
     if ($map_sql || iPHP::$offset) {
         // if($map_sql){
         $ids_array = iDB::all("\n                    SELECT `id` FROM `#iCMS@__article` {$sql}\n                    ORDER BY {$orderby} {$limit}\n                ");
         //iDB::debug(1);
         $ids = iCMS::get_ids($ids_array);
         $ids = $ids ? $ids : '0';
         $sql = "WHERE `id` IN({$ids})";
         // }else{
         // $sql = ",(
         // SELECT `id` AS aid FROM `#iCMS@__article` {$sql}
         // ORDER BY {$orderby} {$limit}
         // ) AS art WHERE `id` = art.aid ";
         // }
         $limit = '';
     }
     $rs = iDB::all("SELECT * FROM `#iCMS@__article` {$sql} ORDER BY {$orderby} {$limit}");
     //iDB::debug(1);
     $_count = count($rs);
     include iACP::view("article.manage");
 }
示例#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
 function do_iCMS()
 {
     $rs = iDB::all("SELECT * FROM `#iCMS@__group` ORDER BY `type` , `gid` ASC");
     $_count = count($rs);
     include iACP::view("groups.manage");
 }