예제 #1
0
function iCMS_link($vars, &$iCMS)
{
    $limit = isset($vars['row']) ? (int) $vars['row'] : "100";
    $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1;
    switch ($vars['type']) {
        case "text":
            $sql[] = " `logo`='' ";
            break;
        case "logo":
            $sql[] = " `logo`!='' ";
            break;
    }
    isset($vars['sortid']) && ($sql[] = " sortid='" . $vars['sortid'] . "'");
    $sql && ($where = 'WHERE ' . implode(' AND ', $sql));
    $iscache = true;
    if ($vars['cache'] == false || isset($vars['page'])) {
        $iscache = false;
        $rs = '';
    } else {
        $cacheName = 'links/' . md5($sql);
        $rs = $iCMS->getCache($cacheName);
    }
    if (empty($rs)) {
        $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__links`{$where} ORDER BY orderNum ASC,id DESC LIMIT 0 , {$limit}");
        $iscache && $iCMS->SetCache($cacheName, $rs, $cacheTime);
    }
    return $rs;
}
예제 #2
0
 function doDefault()
 {
     //数据统计
     $rs = iCMS_DB::getArray("SHOW FULL TABLES FROM `" . DB_NAME . "` WHERE table_type = 'BASE TABLE';");
     foreach ($rs as $k => $val) {
         if (strstr(DB_PREFIX, $val['Tables_in_' . DB_NAME]) === false) {
             $iCMSTable[] = $val['Tables_in_' . DB_NAME];
         } else {
             $oTable[] = $val['Tables_in_' . DB_NAME];
         }
     }
     $content_datasize = 0;
     $tables = iCMS_DB::getArray("SHOW TABLE STATUS");
     $_count = count($tables);
     $tableStr = strtoupper(implode(",", $iCMSTable));
     for ($i = 0; $i < $_count; $i++) {
         $tableName = strtoupper($tables[$i]['Name']);
         if (stristr($tableStr, $tableName)) {
             $datasize += $tables[$i]['Data_length'];
             $indexsize += $tables[$i]['Index_length'];
             if (stristr(strtoupper(DB_PREFIX . "article," . DB_PREFIX . "forum," . DB_PREFIX . "comment," . DB_PREFIX . "article_data"), $tableName)) {
                 $content_datasize += $tables[$i]['Data_length'] + $tables[$i]['Index_length'];
             }
         }
     }
     $c = iCMS_DB::getValue("SELECT count(*) FROM #iCMS@__forum");
     $a = iCMS_DB::getValue("SELECT count(*) FROM #iCMS@__article");
     file_exists(iPATH . 'license.php') && ($license = (include iPATH . 'license.php'));
     include admincp::tpl("home");
 }
예제 #3
0
 function domanage()
 {
     Admin::MP("menu_models_manage");
     $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__model`");
     $_count = count($rs);
     include admincp::tpl();
 }
예제 #4
0
function iCMS_DB($vars, &$iCMS)
{
    if (empty($vars['sql'])) {
        echo $iCMS->language('SQL:empty');
        return false;
    } else {
        if (preg_match("/^\\s*(insert|delete|update|replace) /i", $vars['sql'])) {
            echo $iCMS->language('SQL:IDUR');
            return false;
        }
        if (strstr($vars['sql'], 'members')) {
            echo $iCMS->language('SQL:members');
            return false;
        }
        if (strstr($vars['sql'], 'admin')) {
            echo $iCMS->language('SQL:admin');
            return false;
        }
        $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1;
        $iscache = true;
        if ($vars['cache'] == false || isset($vars['page'])) {
            $iscache = false;
            $rs = '';
        } else {
            $cacheName = 'DB/' . md5($vars['sql']);
            $rs = $iCMS->getCache($cacheName);
        }
        if (empty($rs)) {
            $rs = iCMS_DB::getArray($vars['sql']);
            $iscache && $iCMS->SetCache($cacheName, $rs, $cacheTime);
        }
        return $rs;
    }
}
예제 #5
0
 function doDefault()
 {
     $_configRs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__config`");
     foreach ($_configRs as $_C) {
         $configRs[$_C['name']] = $_C['value'];
     }
     include admincp::tpl("setting");
 }
예제 #6
0
 function dodefault()
 {
     member::MP("menu_search");
     $maxperpage = 20;
     $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__search`") : (int) $_GET['rowNum'];
     page($total, $maxperpage, "个关键字");
     $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__search` order by id DESC LIMIT {$this->firstcount},{$maxperpage}");
     $_count = count($rs);
     include admincp::tpl('search');
 }
예제 #7
0
 function dodefault()
 {
     member::MP(array("menu_index_advertise", "menu_advertise"));
     $maxperpage = 30;
     $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__advertise`") : (int) $_GET['rowNum'];
     page($total, $maxperpage, "个广告");
     $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__advertise` order by id DESC LIMIT {$this->firstcount},{$maxperpage}");
     $_count = count($rs);
     include admincp::tpl("advertise");
 }
예제 #8
0
 function domanage()
 {
     member::MP("menu_user_manage");
     $maxperpage = 20;
     $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__members`") : (int) $_GET['rowNum'];
     page($total, $maxperpage, "位会员");
     $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__members` where `type`='0' order by uid DESC LIMIT {$this->firstcount},{$maxperpage}");
     $_count = count($rs);
     include admincp::tpl('user.manage');
 }
예제 #9
0
 function dodefault()
 {
     Admin::MP(array("menu_index_link", "menu_link"));
     $maxperpage = 60;
     $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__links`") : (int) $_GET['rowNum'];
     page($total, $maxperpage, '个链接');
     $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__links` ORDER BY `logo`, `orderNum` ASC LIMIT {$this->firstcount},{$maxperpage}");
     $_count = count($rs);
     include admincp::tpl('link');
 }
예제 #10
0
function iCMS_tag($vars, &$iCMS)
{
    $whereSQL = " status='1'";
    isset($vars['sortid']) && ($whereSQL .= " AND sortid='" . (int) $vars['sortid'] . "'");
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10";
    $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1;
    $by = $vars['by'] == 'ASC' ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        case "hot":
            $orderSQL = " ORDER BY `count` {$by}";
            break;
        case "new":
            $orderSQL = " ORDER BY `id` {$by}";
            break;
        case "order":
            $orderSQL = " ORDER BY `ordernum` {$by}";
            break;
            //		case "rand":	$orderSQL=" ORDER BY rand() $by";		break;
        //		case "rand":	$orderSQL=" ORDER BY rand() $by";		break;
        default:
            $orderSQL = " ORDER BY `id` {$by}";
    }
    $offset = 0;
    if ($vars['page']) {
        $total = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__tags` WHERE {$whereSQL} {$orderSQL}");
        $iCMS->assign("total", $total);
        $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav";
        $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0;
        $offset = $iCMS->multi(array('total' => $total, 'perpage' => $maxperpage, 'unit' => $iCMS->language('page:tag'), 'nowindex' => $GLOBALS['page'], 'pagenav' => $pagenav, 'pnstyle' => $pnstyle));
    }
    $iscache = true;
    if ($vars['cache'] == false || isset($vars['page'])) {
        $iscache = false;
        $rs = '';
    } else {
        $cacheName = 'tags/' . md5($whereSQL . $orderSQL);
        $rs = $iCMS->getCache($cacheName);
    }
    if (empty($rs)) {
        $frs = $iCMS->getCache('system/forum.cache');
        $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__tags` WHERE {$whereSQL} {$orderSQL} LIMIT {$offset},{$maxperpage}");
        //echo iCMS_DB::$last_query;
        //iCMS_DB::$last_query='explain '.iCMS_DB::$last_query;
        //$explain=iCMS_DB::getRow(iCMS_DB::$last_query);
        //var_dump($explain);
        $_count = count($rs);
        for ($i = 0; $i < $_count; $i++) {
            $rs[$i]['url'] = $iCMS->iurl('tag', array($rs[$i], $frs[$rs[$i]['sortid']]))->href;
            $rs[$i]['link'] = '<a href="' . $rs[$i]['url'] . '" class="tag" target="_self">' . $rs[$i]['name'] . '</a> ';
            $rs[$i]['tags'] .= $rs[$i]['link'];
        }
        $iscache && $iCMS->setCache($cacheName, $rs, $cacheTime);
    }
    return $rs;
}
예제 #11
0
 function domanage()
 {
     member::MP("menu_account_manage");
     include iPATH . 'include/group.class.php';
     $group = new group('a');
     $maxperpage = 20;
     $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__members` where `type`='1'") : (int) $_GET['rowNum'];
     page($total, $maxperpage, "位管理员");
     $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__members` where `type`='1' order by uid DESC LIMIT {$this->firstcount},{$maxperpage}");
     $_count = count($rs);
     include admincp::tpl("account.manage");
 }
예제 #12
0
 function doUpdate()
 {
     include_once iPATH . 'include/forum.class.php';
     if ($_POST['forum']) {
         $forum = new forum();
         $forum->cache();
     }
     if ($_POST['adm']) {
         include_once iPATH . 'admin/advertise.mo.php';
         $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__advertise`", OBJECT);
         $_count = count($rs);
         for ($i = 0; $i < $_count; $i++) {
             adm($rs[$i]);
         }
     }
     $_POST['tpl'] && $this->iCMS->clear_compiled_tpl();
     $_POST['iCMS_list'] && FS::rmdir(iPATH . 'cache/list');
     $_POST['iCMS_forum'] && FS::rmdir(iPATH . 'cache/forum');
     $_POST['iCMS_tag'] && FS::rmdir(iPATH . 'cache/tags');
     if ($_POST['iCMS_ALL']) {
         FS::rmdir(iPATH . 'cache/list');
         FS::rmdir(iPATH . 'cache/forum');
         FS::rmdir(iPATH . 'cache/tags');
     }
     $_POST['keywords'] && keywords_cache();
     $_POST['tags'] && tags_cache();
     if ($_POST['model']) {
         include iPATH . 'include/model.class.php';
         model::cache();
     }
     $_POST['field'] && field_cache();
     $_POST['config'] && CreateConfigFile();
     if ($_POST['Re-Article-Count']) {
         $rs = iCMS_DB::getArray("SELECT fid FROM `#iCMS@__forum`");
         $_count = count($rs);
         for ($i = 0; $i < $_count; $i++) {
             $c = iCMS_DB::getValue("SELECT count(*) FROM #iCMS@__article where `fid`='" . $rs[$i]['fid'] . "' LIMIT 1 ");
             iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` ='{$c}' WHERE `fid` ='" . $rs[$i]['fid'] . "' LIMIT 1 ");
         }
     }
     if ($_POST['Re-Tag-Count']) {
         include_once iPATH . 'include/forum.class.php';
         $rs = iCMS_DB::getArray("SELECT id FROM `#iCMS@__tags`");
         $_count = count($rs);
         for ($i = 0; $i < $_count; $i++) {
             $_count = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__taglist` WHERE `tid`='" . $rs[$i]['id'] . "'");
             iCMS_DB::query("UPDATE `#iCMS@__tags` SET `count` = '{$_count}'  WHERE `id` ='" . $rs[$i]['id'] . "'");
             tags_cache($rs[$i]['id']);
         }
     }
     javascript::dialog("执行完毕!", 'url:1');
 }
예제 #13
0
 function dodefault()
 {
     member::MP("menu_keywords");
     $_GET['keywords'] && ($sql[] = " `keyword` REGEXP '{$_GET['keywords']}'");
     $_GET['replace'] && ($sql[] = " `replace` REGEXP '{$_GET['replace']}'");
     isset($_GET['status']) && $_GET['status'] != '-1' && ($sql[] = " `status`='" . $_GET['status'] . "'");
     $where = $sql ? ' where ' . implode(' AND ', (array) $sql) : '';
     $maxperpage = (int) $_GET['perpage'] > 0 ? $_GET['perpage'] : 20;
     $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__keywords` {$where}") : (int) $_GET['rowNum'];
     page($total, $maxperpage, "个关键字");
     $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__keywords` {$where} order by id DESC LIMIT {$this->firstcount},{$maxperpage}");
     $_count = count($rs);
     include admincp::tpl('keywords');
 }
예제 #14
0
 function dodefault()
 {
     global $firstcount, $pagenav;
     Admin::MP("menu_message");
     $_GET['keywords'] && ($sql[] = " CONCAT(author,email,url,ip) REGEXP '{$_GET['keywords']}'");
     isset($_GET['status']) && ($sql[] = " `status`='" . $_GET['status'] . "'");
     $where = $sql ? ' where ' . implode(' AND ', (array) $sql) : '';
     $maxperpage = (int) $_GET['perpage'] > 0 ? $_GET['perpage'] : 20;
     $total = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__plugins_message` {$where} order by id DESC");
     page($total, $maxperpage, "条留言");
     $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__plugins_message` {$where} order by id DESC LIMIT {$firstcount},{$maxperpage}");
     $_count = count($rs);
     include plugin::acptpl();
 }
예제 #15
0
 function __construct($id = '', $status = "1", $attr = "1")
 {
     global $iCMS;
     $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__forum` ORDER BY `orderNum` , `fid` ASC", ARRAY_A);
     //echo iCMS_DB::$last_query;
     //iCMS_DB::$last_query='explain '.iCMS_DB::$last_query;
     //$explain=iCMS_DB::getRow(iCMS_DB::$last_query);
     //var_dump($explain);
     //exit;
     foreach ((array) $rs as $row) {
         $this->forum[$row['fid']] = $this->_array[$row['rootid']][$row['fid']] = $this->parent[$row['fid']][$row['rootid']] = $row;
         $this->cacheRootId[$row['rootid']][$row['fid']] = $row['fid'];
         $this->cacheParent[$row['fid']] = $row['rootid'];
     }
 }
예제 #16
0
/**
 * @package iCMS
 * @copyright 2007-2010, iDreamSoft
 * @license http://www.idreamsoft.cn iDreamSoft
 * @author coolmoo <*****@*****.**>
 */
function FormArray($mId, $F, $rs = array(), $isUser = false)
{
    //字段定义
    $rst = iCMS_DB::getArray("SELECT * FROM `#iCMS@__field` where (mid='{$mId}' OR mid='0')");
    foreach ($rst as $key => $a) {
        $FA[$a['field']] = $a;
    }
    //遍历传入字段数组
    if ($F) {
        foreach ($F as $key => $field) {
            $HA[$key] = form($FA[$field], $rs, $isUser);
        }
    }
    return $HA;
}
예제 #17
0
function iCMS_plugins_archives($vars, &$iCMS)
{
    $rs = iCMS_DB::getArray("SELECT A.pubdate FROM `#iCMS@__article` AS A,#iCMS@__forum AS F WHERE A.status='1' AND A.fid=F.fid AND F.status='1' ORDER BY pubdate DESC");
    $_count = count($rs);
    for ($i = 0; $i < $_count; $i++) {
        $article[] = get_date($rs[$i]['pubdate'], 'Y-m');
    }
    $arr = array_count_values($article);
    $i = 0;
    foreach ($arr as $key => $val) {
        list($y, $m) = explode('-', $key);
        $archive[$i]['url'] = $y . '_' . $m;
        $archive[$i]['date'] = "{$y}年{$m}月";
        $archive[$i]['count'] = $val;
        $i++;
    }
    $iCMS->value('archive', $archive);
    $iCMS->output('archive', plugin::tpl('archives'));
}
예제 #18
0
 function doDefault()
 {
     Admin::MP(array("menu_index_comment", "menu_comment"));
     include_once iPATH . 'include/model.class.php';
     if ($_GET['st'] == "title") {
         $_GET['keywords'] && ($sql[] = " `title` REGEXP '{$_GET['keywords']}'");
     } else {
         if ($_GET['st'] == "contents") {
             $_GET['keywords'] && ($sql[] = " `contents` REGEXP '{$_GET['keywords']}'");
         }
     }
     $_GET['starttime'] && ($sql[] = " `addtime`>='" . strtotime($_GET['starttime']) . "'");
     $_GET['endtime'] && ($sql[] = " `addtime`<='" . strtotime($_GET['endtime']) . "'");
     $_GET['mid'] && ($sql[] = " `mid`='" . strtotime($_GET['mid']) . "'");
     isset($_GET['status']) && $_GET['status'] != '-1' && ($sql[] = " `status`='" . $_GET['status'] . "'");
     $where = $sql ? ' where ' . implode(' AND ', (array) $sql) : '';
     $maxperpage = (int) $_GET['perpage'] > 0 ? $_GET['perpage'] : 20;
     $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__comment` {$where}") : (int) $_GET['rowNum'];
     page($total, $maxperpage, "条评论");
     $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__comment` {$where} order by id DESC LIMIT {$this->firstcount},{$maxperpage}");
     $_count = count($rs);
     include admincp::tpl('comment');
 }
예제 #19
0
function iCMS_plugins_message($vars, &$iCMS)
{
    if (isset($vars['call'])) {
        if ($vars['call'] == 'form') {
            echo $iCMS->output('form', plugin::tpl('message'));
            exit;
        }
    } else {
        $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "20";
        $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1;
        $offset = 0;
        if ($vars['page']) {
            $total = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__plugins_message` WHERE `status`='0'");
            $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav";
            $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0;
            $offset = $iCMS->multi(array('total' => $total, 'perpage' => $maxperpage, 'unit' => $iCMS->language('page:message'), 'nowindex' => $GLOBALS['page'], 'pagenav' => $pagenav, 'pnstyle' => $pnstyle));
        }
        $iscache = true;
        if ($vars['cache'] == false || isset($vars['page'])) {
            $iscache = false;
            $rs = '';
        } else {
            $cacheName = 'message/cache';
            $rs = $iCMS->getCache($cacheName);
        }
        if (empty($rs)) {
            $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__plugins_message` WHERE `status`='0' order by `id` DESC LIMIT {$offset},{$maxperpage}");
            for ($i = 0; $i < count($rs); $i++) {
                if ($rs[$i]['reply']) {
                    $rs[$i]['reply'] = '<strong>' . $iCMS->language('reply:admin') . '</strong>' . $rs[$i]['reply'];
                }
            }
            $iscache && $iCMS->SetCache($cacheName, $rs, $cacheTime);
        }
        return $rs;
    }
}
예제 #20
0
 function domanage()
 {
     $mid = $_GET['mid'];
     $model = model::data($mid);
     $table = $model['tbn'];
     $forum = new forum();
     $fid = (int) $_GET['fid'];
     $type = $_GET['type'];
     $sql = " where ";
     switch ($type) {
         //postype: [0:用户][1:管理员] status:[0:草稿][1:正常][2:回收]
         case 'draft':
             //草稿
             $sql .= "`status` ='0' AND `postype`='1'";
             $_ptxt = array(0 => '发布', 1 => '转成草稿');
             $position = UI::lang("menu_article_draft");
             break;
         case 'trash':
             //回收站
             $sql .= "`status` ='2'";
             $_ptxt = array(0 => '还原', 1 => '放入回收站');
             $position = UI::lang("menu_article_trash");
             break;
         case 'user':
             //用户
             if ($_GET['act'] == "draft") {
                 $sql .= "`status` ='0'";
                 //用户审核
                 $position = UI::lang("menu_article_user_draft");
             } elseif ($_GET['act'] == "trash") {
                 $sql .= "`status` ='2'";
                 //用户回收站
                 $position = UI::lang("menu_article_user_trash");
             } else {
                 $sql .= "`status` ='1'";
                 $position = UI::lang("menu_article_user_manage");
             }
             $sql .= " AND `postype`='0'";
             $_ptxt = array(0 => '通过审核', 1 => '取消审核');
             break;
         default:
             $sql .= " `status` ='1' AND `postype`='1'";
             $position = '';
             $fid && ($position = $forum->forum[$fid]['name']);
     }
     $position && ($position = "&nbsp;&raquo;&nbsp;" . $position);
     if ($_GET['keywords']) {
         if ($_GET['st'] == "title") {
             $sql .= " AND `title` REGEXP '{$_GET['keywords']}'";
         } else {
             if ($_GET['st'] == "top") {
                 $sql .= " AND `top`='{$_GET['keywords']}'";
             } else {
                 if ($_GET['st'] == "id") {
                     $sql .= " AND `id` REGEXP '{$_GET['keywords']}'";
                 }
             }
         }
     }
     $_GET['title'] && ($sql .= " AND `title` like '%{$_GET['title']}%'");
     $_GET['tag'] && ($sql .= " AND `tags` REGEXP '[[:<:]]" . preg_quote(rawurldecode($_GET['tag']), '/') . "[[:>:]]'");
     isset($_GET['at']) && $_GET['at'] != '-1' && ($sql .= " AND `type` ='" . $_GET['at'] . "'");
     isset($_GET['userid']) && ($sql .= " AND `userid`='" . (int) $_GET['userid'] . "'");
     $fid = member::CP($fid) ? $fid : "0";
     if ($fid) {
         $fidIN = $forum->fid($fid) . $fid;
         if (isset($_GET['sub']) && strstr($fidIN, ',')) {
             $sql .= " AND fid IN(" . $fidIN . ")";
         } else {
             $sql .= " AND fid ='{$fid}'";
         }
         //$sql.=" OR `vlink` REGEXP '[[:<:]]".preg_quote($fid, '/')."[[:>:]]')";
     } else {
         member::$cpower && ($sql .= " AND fid IN(" . implode(',', (array) member::$cpower) . ")");
     }
     $_GET['starttime'] && ($sql .= " and `pubdate`>='" . strtotime($_GET['starttime']) . "'");
     $_GET['endtime'] && ($sql .= " and `pubdate`<='" . strtotime($_GET['endtime']) . "'");
     $act == 'user' && ($uri .= '&act=user');
     $_GET['type'] == 'draft' && ($uri .= '&type=draft');
     isset($_GET['userid']) && ($uri .= '&userid=' . (int) $_GET['userid']);
     isset($_GET['keyword']) && ($uri .= '&keyword=' . $_GET['keyword']);
     isset($_GET['tag']) && ($uri .= '&tag=' . $_GET['tag']);
     $orderby = $_GET['orderby'] ? $_GET['orderby'] : "id DESC";
     $maxperpage = (int) $_GET['perpage'] > 0 ? $_GET['perpage'] : 20;
     $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__{$table}` {$sql}") : (int) $_GET['rowNum'];
     page($total, $maxperpage, "条记录");
     $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__{$table}` {$sql} order by {$orderby} LIMIT {$this->firstcount} , {$maxperpage}");
     $_count = count($rs);
     include admincp::tpl();
 }
예제 #21
0
 function doOptimize()
 {
     empty($_POST['tabledb']) && javascript::alert('请选择表');
     $table = implode(',', $_POST['tabledb']);
     $rs = iCMS_DB::getArray("OPTIMIZE TABLE {$table}");
     $_count = count($rs);
     for ($i = 0; $i < $_count; $i++) {
         $msg .= '表:' . substr(strrchr($rs[$i]['Table'], '.'), 1) . ' 操作:' . $rs[$i]['Op'] . ' 状态:' . $rs[$i]['Msg_text'] . '<br />';
     }
     javascript::dialog($msg . "优化表完成", 'url:1');
 }
예제 #22
0
function CreateConfigFile()
{
    global $iCMS;
    $tmp = iCMS_DB::getArray("SELECT * FROM `#iCMS@__config`");
    $config_data = "<?php\n\t\$config=array(\n";
    for ($i = 0; $i < count($tmp); $i++) {
        $_config .= "\t\t\"" . $tmp[$i]['name'] . "\"=>\"" . $tmp[$i]['value'] . "\",\n";
    }
    $config_data .= substr($_config, 0, -2);
    $config_data .= "\t\n);?>";
    FS::write(iPATH . 'include/site.config.php', $config_data);
}
예제 #23
0
function iCMS_comment($vars, &$iCMS)
{
    if (!$iCMS->config['iscomment']) {
        return false;
    }
    $iCMS->assign('commentInfo', array('indexId' => (int) $iCMS->commentInfo['indexId'], 'sortId' => (int) $iCMS->commentInfo['sortId'], 'title' => $iCMS->commentInfo['title'], 'mId' => $iCMS->commentInfo['mId']));
    if (isset($vars['call'])) {
        if (in_array($vars['call'], array('js', 'frame'))) {
            echo $iCMS->iPrint("iTPL", "comment_show_" . $vars['call']);
        }
    } elseif (isset($vars['loop'])) {
        $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1;
        $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10";
        $whereSQL = "`mid`='{$mid}' and `status`='1'";
        isset($vars['sortid']) && ($whereSQL .= " and `sortId`='" . (int) $vars['sortid'] . "'");
        //    	($iCMS->comment['indexId'] && $vars['type']!='all') && $whereSQL.=" AND `indexId`='".(int)$iCMS->comment['indexId']."'";
        $vars['indexid'] && $vars['type'] != 'all' && ($whereSQL .= " AND `indexId`='" . (int) $vars['indexid'] . "'");
        switch ($vars['orderby']) {
            case "hot":
                $orderSQL = " ORDER BY up+against DESC";
                break;
            case "new":
                $orderSQL = " ORDER BY `addtime` DESC";
                break;
            default:
                $orderSQL = " ORDER BY `id` DESC";
        }
        $total = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__comment` WHERE {$whereSQL}");
        $offset = 0;
        if ($vars['page']) {
            $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav";
            $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0;
            $offset = $iCMS->multi(array('total' => $total, 'perpage' => $maxperpage, 'unit' => $iCMS->language('page:comment'), 'url' => $iCMS->url, 'nowindex' => $GLOBALS['page'], 'pagenav' => $pagenav, 'pnstyle' => $pnstyle));
        }
        $iscache = true;
        if ($vars['cache'] == false || isset($vars['page'])) {
            $iscache = false;
            $rs = '';
        } else {
            $cacheName = 'comment/' . md5($whereSQL . $orderSQL);
            $rs = $iCMS->getCache($cacheName);
        }
        if (empty($rs)) {
            //	include_once(iPATH.'include/ubb.fun.php');
            $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__comment` WHERE {$whereSQL}{$orderSQL} LIMIT {$offset},{$maxperpage}");
            //echo iCMS_DB::$last_query;
            //iCMS_DB::$last_query='explain '.iCMS_DB::$last_query;
            //$explain=iCMS_DB::getRow(iCMS_DB::$last_query);
            //var_dump($explain);
            $_count = count($rs);
            $ln = $GLOBALS['page'] - 1 < 0 ? 0 : $GLOBALS['page'] - 1;
            for ($i = 0; $i < $_count; $i++) {
                $rs[$i]['url'] = $iCMS->config['publicURL'] . '/comment.php?indexId=' . $rs[$i]['indexId'] . '&mId=' . $rs[$i]['mid'] . '&sortId=' . $rs[$i]['sortId'];
                $rs[$i]['lou'] = $total - ($i + $ln * $maxperpage);
                $rs[$i]['content'] = str_replace("\r", '<br />', $rs[$i]['contents']);
                //				$rs[$i]['content']=ubb($rs[$i]['contents']);
                $rs[$i]['contents'] = $rs[$i]['quote'] ? cQuote($rs[$i]['quote']) : '';
                $rs[$i]['contents'] .= $rs[$i]['content'];
                //				if($rs[$i]['reply']){
                //					$reply=explode('||',$rs[$i]['reply']);
                //					$rs[$i]['reply']=$reply[0]=='admin'?'<strong>'.$iCMS->language('reply:admin').'</strong>'.$reply[1]:'<strong>'.$iCMS->language('reply:author').'</strong>'.$reply[1];
                //				}
            }
            $iscache && $iCMS->SetCache($cacheName, $rs, $cacheTime);
        }
        return $rs;
    } else {
        $vars['width'] = is_numeric($vars['width']) ? $vars['width'] . 'px' : $vars['width'];
        $iCMS->append('commentInfo', array('anonymous' => $iCMS->config['anonymous'], 'anonymousname' => $iCMS->config['anonymousname'], 'width' => $vars['width'] ? $vars['width'] : '98%', 'height' => $vars['height'] ? $vars['height'] : '140'), true);
        echo $iCMS->iPrint("iTPL", "comment.form");
    }
}
예제 #24
0
 function data($id = 0, $limit = 0)
 {
     $sql = $id ? "where `id`='{$id}'" : '';
     $limitSQL = $limit ? "LIMIT {$limit} " : '';
     return iCMS_DB::getArray("SELECT * FROM `#iCMS@__tags` {$sql} order by id DESC {$limitSQL}");
 }
예제 #25
0
            mysql_query("CREATE DATABASE `{$database}` " . $DATABASESQL);
        }
        require_once $configfile;
        $installSQL = 'iCMS_SQL.sql';
        !is_readable($installSQL) && exit('数据库文件不存在或者读取失败');
        require_once iPATH . 'include/mysql.class.php';
        //iCMS_DB::$show_errors=true;
        runquery(FS::read($installSQL));
        iCMS_DB::query("INSERT INTO `#iCMS@__members` (`groupid`, `username`, `password`, `nickname`, `gender`, `info`, `power`, `cpower`, `regtime`, `lastip`, `lastlogintime`, `logintimes`, `post`, `type`, `status`) VALUES ('1', '{$admin}', '" . md5($password) . "', '管理员', '0', '', '', '', '" . time() . "', '', '0', '0', '0', '1', '1');");
        iCMS_DB::query("UPDATE `#iCMS@__config` SET `value` = '{$setupURL}' WHERE `name` ='setupURL'");
        iCMS_DB::query("UPDATE `#iCMS@__config` SET `value` = '{$publicURL}' WHERE `name` ='publicURL'");
        iCMS_DB::query("UPDATE `#iCMS@__config` SET `value` = '{$htmlURL}' WHERE `name` ='htmlURL'");
        iCMS_DB::query("UPDATE `#iCMS@__config` SET `value` = '{$uploadURL}' WHERE `name` ='uploadURL'");
        iCMS_DB::query("UPDATE `#iCMS@__config` SET `value` = '{$setupURL}' WHERE `name` ='tagURL'");
        iCMS_DB::query("UPDATE `#iCMS@__config` SET `value` = '{$usercpURL}' WHERE `name` ='usercpURL'");
        $tmp = iCMS_DB::getArray("SELECT * FROM `#iCMS@__config`");
        $config_data = "<?php\n\t\$config=array(\n";
        for ($i = 0; $i < count($tmp); $i++) {
            $_config .= "\t\t\"" . $tmp[$i]['name'] . "\"=>\"" . $tmp[$i]['value'] . "\",\n";
        }
        $config_data .= substr($_config, 0, -2);
        $config_data .= "\t\n);?>";
        FS::write(iPATH . 'include/site.config.php', $config_data);
        FS::write($lockfile, 'iCMS');
        ?>
    </p>
    <p>共创建了<?php 
        echo $tablenum;
        ?>
个数据表.</p>
    <hr size="1" noshade="noshade" />
예제 #26
0
function iCMS_forums($vars, &$iCMS)
{
    if (empty($vars['loop'])) {
        $id = (int) $vars['fid'];
        $_cache = $iCMS->getCache(array('system/forum.cache', 'system/forum.rootid'));
        $rs = $_cache['system/forum.cache'][$id];
        empty($rs) && $iCMS->error('error:page');
        if ($rs['url']) {
            return $iCMS->go($rs['url']);
        }
        $iurl = $iCMS->iurl('forum', $rs);
        $rs['url'] = $iurl->href;
        $rs['link'] = "<a href='{$rs['url']}'>{$rs['name']}</a>";
        $rs['nav'] = $iCMS->shownav($rs['fid']);
        $rs['subid'] = $_cache['system/forum.rootid'][$id];
        $rs['subids'] = implode(',', (array) $rs['subid']);
        return $rs;
    }
    $row = isset($vars['row']) ? (int) $vars['row'] : "100";
    $cacheTime = isset($vars['time']) ? (int) $vars['time'] : "-1";
    $status = isset($vars['status']) ? (int) $vars['status'] : "1";
    $attr = isset($vars['attr']) ? (int) $vars['attr'] : "1";
    $whereSQL = " WHERE `status`='{$status}' AND `attr`='{$attr}'";
    isset($vars['mid']) && ($whereSQL .= " AND `mid` = '{$vars['mid']}'");
    isset($vars['mode']) && ($whereSQL .= " AND `mode` = '{$vars['mode']}'");
    isset($vars['fid']) && !isset($vars['type']) && ($whereSQL .= getSQL($vars['fid'], 'fid'));
    isset($vars['fid!']) && ($whereSQL .= getSQL($vars['fid!'], 'fid', 'not'));
    switch ($vars['type']) {
        case "top":
            $vars['fid'] && ($whereSQL .= getSQL($vars['fid'], 'fid'));
            $whereSQL .= " AND rootid='0'";
            break;
        case "subtop":
            $vars['fid'] && ($whereSQL .= getSQL($vars['fid'], 'fid'));
            break;
        case "sub":
            $whereSQL .= getSQL(getfids($vars['fid']), 'fid');
            break;
        case "subone":
            $whereSQL .= getSQL(getfids($vars['fid'], false), 'fid');
            break;
            //		case "allsub":
            //			$whereSQL.= getSQL(getfids(),'fid');
            //		break;
        //		case "allsub":
        //			$whereSQL.= getSQL(getfids(),'fid');
        //		break;
        case "self":
            $parent = $iCMS->getCache('system/forum.parent', $vars['fid']);
            $whereSQL .= " AND `rootid`='{$parent}'";
            //$whereSQL.=getSQL(getfids($parent,false),'rootid');
            break;
    }
    $iscache = true;
    if ($vars['cache'] == false) {
        $iscache = false;
        $rs = '';
    } else {
        $cacheName = 'forum/' . md5($whereSQL);
        $rs = $iCMS->getCache($cacheName);
    }
    if (empty($rs)) {
        $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__forum`{$whereSQL} ORDER BY `orderNum`,`fid` ASC LIMIT {$row}");
        //echo iCMS_DB::$last_query;
        //iCMS_DB::$last_query='explain '.iCMS_DB::$last_query;
        //$explain=iCMS_DB::getRow(iCMS_DB::$last_query);
        //var_dump($explain);
        $_count = count($rs);
        for ($i = 0; $i < $_count; $i++) {
            $rs[$i]['url'] = $iCMS->iurl('forum', $rs[$i])->href;
            $rs[$i]['link'] = "<a href='{$rs[$i]['url']}'>{$rs[$i]['name']}</a>";
            $rs[$i]['mid'] = $rs[$i]['modelid'];
            if ($rs[$i]['metadata']) {
                $mdArray = array();
                $rs[$i]['metadata'] = unserialize($rs[$i]['metadata']);
                foreach ($rs[$i]['metadata'] as $mdval) {
                    $mdArray[$mdval['key']] = $mdval['value'];
                }
                $rs[$i]['metadata'] = $mdArray;
            }
            unset($rs[$i]['contentAttr']);
        }
        $iscache && $iCMS->setCache($cacheName, $rs, $cacheTime);
    }
    return $rs;
}
예제 #27
0
 function doarticle()
 {
     $forum = new forum();
     $callback = $_GET['callback'];
     $fid = (int) $_GET['fid'];
     $sql = " where ";
     $sql .= $_GET['type'] == 'draft' ? "`status` ='0'" : "`status` ='1'";
     $sql .= $act == 'user' ? " AND `postype`='0'" : " AND `postype`='1'";
     $_GET['keywords'] && ($sql .= " AND CONCAT(title,keywords,description) REGEXP '{$_GET['keywords']}'");
     $fid = member::CP($fid) ? $fid : "0";
     if ($fid) {
         if (isset($_GET['sub'])) {
             $sql .= " AND ( fid IN(" . $forum->fid($fid) . $fid . ")";
         } else {
             $sql .= " AND ( fid ='{$fid}'";
         }
         $sql .= " OR `vlink` REGEXP '[[:<:]]" . preg_quote($fid, '/') . "[[:>:]]')";
     } else {
         member::$cpower && ($sql .= " AND fid IN(" . implode(',', member::$cpower) . ")");
     }
     isset($_GET['keyword']) && ($uri .= '&keyword=' . $_GET['keyword']);
     $maxperpage = 8;
     $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__article` {$sql}") : (int) $_GET['rowNum'];
     page($total, $maxperpage, "篇文章");
     $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__article`{$sql} order by id DESC LIMIT {$this->firstcount} , {$maxperpage}");
     $_count = count($rs);
     include admincp::tpl();
 }
예제 #28
0
      <tr>
        <td colspan="4" align="right" style="width:auto;"><select class="BP"><option value="1">第 1 页</option></select>
          <input type="button" value="新增一页" onClick="newBody();" class="submit"> 或 
<input type="button" value="插入分页" onClick="pagebreak();" class="submit"></td>
      </tr>
      <?php 
}
?>
    </tbody>
    <tbody id="publish" style="display:none;">
      <tr>
        <td class="td40">相关文章:</td>
        <td colspan="2"><select id='related' name="related[]" size='10' style="width:100%" multiple="multiple">
            <?php 
if ($rs['related']) {
    $relRs = iCMS_DB::getArray("SELECT `id`, `title` FROM `#iCMS@__article` WHERE `id`IN (" . $rs['related'] . ")");
    foreach ((array) $relRs as $rel) {
        $relatedArray[$rel['id']] = $rel['title'];
    }
    $relIds = explode(',', $rs['related']);
    foreach ($relIds as $relId) {
        echo '<option value="' . $relId . '">' . $relatedArray[$relId] . '</option>';
    }
}
?>
          </select></td>
        <td><input type="button" onclick="del(this.form.related)" value="删除×" tabindex="13" class="submit"/>
          <br/>
          <br/>
          <input type="button" onclick="moveUp(this.form.related)" value="上移∧" tabindex="13" class="submit"/>
          <br/>
예제 #29
0
 function delArticleTag($tId, $aId = '')
 {
     $sql = '#iCMS@__article.id = `indexId`';
     $aId && ($sql .= " AND #iCMS@__article.id='{$aId}'");
     $tagName = iCMS_DB::getValue("SELECT name FROM #iCMS@__tags WHERE id='{$tId}'");
     $rs = iCMS_DB::getArray("SELECT #iCMS@__article.id,#iCMS@__article.tags FROM `#iCMS@__article`,`#iCMS@__taglist` WHERE {$sql} AND `tid`='" . $tId . "'");
     $_count = count($rs);
     for ($i = 0; $i < $_count; $i++) {
         if ($rs[$i]['tags']) {
             $tagArray = explode(',', $rs[$i]['tags']);
             $key = array_search($tagName, $tagArray);
             unset($tagArray[$key]);
             $tags = implode(',', $tagArray);
             iCMS_DB::query("update `#iCMS@__article` set `tags`='{$tags}' where id='" . $rs[$i]['id'] . "'");
             iCMS_DB::query("DELETE FROM `#iCMS@__taglist` WHERE `tid`='{$tId}' and `indexId`='" . $rs[$i]['id'] . "'");
         }
     }
 }
예제 #30
0
 function doManage()
 {
     $mtime = microtime();
     $mtime = explode(' ', $mtime);
     $time_start = $mtime[1] + $mtime[0];
     Admin::MP(array("menu_article_manage", "menu_article_draft", "menu_article_user_manage", "menu_article_user_draft"));
     $forum = new forum();
     $fid = (int) $_GET['fid'];
     $type = $_GET['type'];
     $sql = " where ";
     switch ($type) {
         //postype: [0:用户][1:管理员][2:回收] status:[0:隐藏][1:正常]
         case 'draft':
             //草稿
             $sql .= "`status` ='0' AND `postype`='1'";
             $_ptxt = array(0 => '发布', 1 => '转成草稿');
             $position = UI::lang("menu_article_draft");
             break;
         case 'trash':
             //回收站
             $sql .= "`status` ='0' AND `postype`='2'";
             $_ptxt = array(0 => '还原', 1 => '放入回收站');
             $position = UI::lang("menu_article_trash");
             break;
         case 'user':
             //用户
             if ($_GET['act'] == "draft") {
                 $sql .= "`status` ='0'";
                 //用户审核
                 $position = UI::lang("menu_article_user_draft");
             } else {
                 $sql .= "`status` ='1'";
                 $position = UI::lang("menu_article_user_manage");
             }
             $sql .= " AND `postype`='0'";
             $_ptxt = array(0 => '通过审核', 1 => '取消审核');
             break;
         default:
             $sql .= " `status` ='1' AND `postype`='1'";
             $position = '';
             $fid && ($position = $forum->forum[$fid]['name']);
     }
     $position && ($position = "&nbsp;&raquo;&nbsp;" . $position);
     if ($_GET['keywords']) {
         if ($_GET['st'] == "title") {
             $sql .= " AND `title` REGEXP '{$_GET['keywords']}'";
         } else {
             if ($_GET['st'] == "top") {
                 $sql .= " AND `top`='{$_GET['keywords']}'";
             } else {
                 if ($_GET['st'] == "id") {
                     $sql .= " AND `id` REGEXP '{$_GET['keywords']}'";
                 } else {
                     if ($_GET['st'] == "tkd") {
                         $sql .= " AND CONCAT(title,keywords,description) REGEXP '{$_GET['keywords']}'";
                     }
                 }
             }
         }
     }
     $_GET['title'] && ($sql .= " AND `title` like '%{$_GET['title']}%'");
     $_GET['tag'] && ($sql .= " AND `tags` REGEXP '[[:<:]]" . preg_quote(rawurldecode($_GET['tag']), '/') . "[[:>:]]'");
     isset($_GET['at']) && $_GET['at'] != '-1' && ($sql .= " AND `type` ='" . $_GET['at'] . "'");
     isset($_GET['userid']) && ($sql .= " AND `userid`='" . (int) $_GET['userid'] . "'");
     $fid = Admin::CP($fid) ? $fid : "0";
     if ($fid) {
         $fidIN = $forum->fid($fid) . $fid;
         if (isset($_GET['sub']) && strstr($fidIN, ',')) {
             $sql .= " AND fid IN(" . $fidIN . ")";
         } else {
             $sql .= " AND fid ='{$fid}'";
         }
         //$sql.=" OR `vlink` REGEXP '[[:<:]]".preg_quote($fid, '/')."[[:>:]]')";
     } else {
         Admin::$cpower && ($sql .= " AND fid IN(" . implode(',', (array) Admin::$cpower) . ")");
     }
     isset($_GET['nopic']) && ($sql .= " AND `isPic` ='0'");
     $_GET['starttime'] && ($sql .= " and `pubdate`>='" . strtotime($_GET['starttime']) . "'");
     $_GET['endtime'] && ($sql .= " and `pubdate`<='" . strtotime($_GET['endtime']) . "'");
     $act == 'user' && ($uri .= '&act=user');
     $_GET['type'] == 'draft' && ($uri .= '&type=draft');
     isset($_GET['userid']) && ($uri .= '&userid=' . (int) $_GET['userid']);
     isset($_GET['keyword']) && ($uri .= '&keyword=' . $_GET['keyword']);
     isset($_GET['tag']) && ($uri .= '&tag=' . $_GET['tag']);
     $orderby = $_GET['orderby'] ? $_GET['orderby'] : "id DESC";
     $maxperpage = (int) $_GET['perpage'] > 0 ? $_GET['perpage'] : 20;
     $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__article` {$sql}") : (int) $_GET['rowNum'];
     page($total, $maxperpage, "篇文章");
     $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__article` {$sql} order by {$orderby} LIMIT {$this->firstcount} , {$maxperpage}");
     //echo iCMS_DB::$last_query;
     //iCMS_DB::last_query='explain '.iCMS_DB::$last_query;
     //$explain=iCMS_DB::getRow(iCMS_DB::last_query);
     //var_dump($explain);
     $_count = count($rs);
     include admincp::tpl("article.manage");
     //		$mtime = microtime();
     //		$mtime = explode(' ', $mtime);
     //		$time_end = $mtime[1] + $mtime[0];
     //		echo  "<h1>".($time_end - $time_start);
 }