function inbox_read_base($fields = "*", $condition = "", $get_type = "", $num = "", $by_col = "mess_id", $order = "desc", $cache = "", $cache_key = "") { global $tablePreStr; global $page_num; global $page_total; $uid = get_sess_userid(); $t_scrip = $tablePreStr . "msg_inbox"; $result_rs = array(); $dbo = new dbex(); dbplugin('r'); $by_col = $by_col ? " {$by_col} " : " mess_id "; $order = $order ? $order : "desc"; $get_type = $get_type == 'getRow' ? "getRow" : "getRs"; $sql = " select {$fields} from {$t_scrip} where user_id = {$uid} and mesinit_id!='' {$condition} order by {$by_col} {$order} "; if ($cache == 1 && $cache_key != '') { $key = 'inbox_' . $cache_key . $uid . '_' . $num; $key_mt = 'inbox_' . $cache_key . 'mt_' . $uid . '_' . $num; $result_rs = model_cache($key, $key_mt, $dbo, $sql, $get_type); } if (empty($result_rs)) { $dbo->setPages(20, $page_num); $result_rs = $dbo->{$get_type}($sql); $page_total = $dbo->totalPage; } return $result_rs; }
function plugins_get_all() { global $tablePreStr; global $page_num; global $page_total; $t_plugins = $tablePreStr . "plugins"; $t_plugin_url = $tablePreStr . "plugin_url"; $page_num = $page_num ? $page_num - 1 : 0; $result_rs = array(); $result_rs_total = array(); $dbo = new dbex(); dbplugin('r'); $sql = "select a.*,b.url from {$t_plugins} as a join {$t_plugin_url} as b on (a.name=b.name) where b.layout_id='plugin_app' order by a.id desc"; $key = "plugin/list/id"; $key_mt = "plugin/list/id_mt"; $result_rs_total = model_cache($key, $key_mt, $dbo, $sql); if ($result_rs_total) { $key = $key . '_20_total'; $sql_count = "select count(*) as total_count " . strstr($sql, "from"); //查询总数 $total_row = model_cache($key, $key_mt, $dbo, $sql_count, "getRow"); $result_rs_cut = array_chunk($result_rs_total, 20); $result_rs = $result_rs_cut[$page_num]; $page_total = floor(($total_row['total_count'] - 1) / 20) + 1; //总页数 } else { $dbo->setPages(20, $page_num); $result_rs = $dbo->getRs($sql); $page_total = $dbo->totalPage; } return $result_rs; }
function group_sort_by_self() { global $tablePreStr; $t_group_type = $tablePreStr . "group_type"; $result_rs = array(); $dbo = new dbex(); dbplugin('r'); $sql = "select * from {$t_group_type} order by order_num desc"; $key = "group_sort/list/order_num/0/all"; $key_mt = 'group_sort/list/order_num/0/all_mt'; $result_rs = model_cache($key, $key_mt, $dbo, $sql); if (empty($result_rs)) { $result_rs = $dbo->getRs($sql); } return $result_rs; }
function pals_sort_def() { global $tablePreStr; $t_pals_sort = $tablePreStr . "pals_def_sort"; $result_rs = array(); $dbo = new dbex(); dbplugin('r'); $sql = " select * from {$t_pals_sort} "; $key = "pals_def_sort/list/order_num/0/all"; $key_mt = "pals_def_sort/list/order_num/0/all_mt"; $result_rs = model_cache($key, $key_mt, $dbo, $sql); if (empty($result_rs)) { $result_rs = $dbo->getALL($sql); } return $result_rs; }
function user_recommend_base($fields = "*", $condition = "", $get_type = "", $num = "", $by_col = "rec_order", $order = "asc", $cache = "", $cache_key = "") { global $tablePreStr; $t_recommend = $tablePreStr . "recommend"; $fields_str = ''; $result_rs = array(); $dbo = new dbex(); dbplugin('r'); $by_col = $by_col ? " {$by_col} " : " rec_order "; $order = $order ? $order : "asc"; $get_type = $get_type == 'getRow' ? "getRow" : "getRs"; $sql = " select {$fields} from {$t_recommend} where is_pass = 1 {$condition} order by {$by_col} {$order} "; //缓存机制 $key = 'recommend/list/rec_order/all/0'; $key_mt = 'recommend/list/rec_order/all/0_mt'; $result_rs = model_cache($key, $key_mt, $dbo, $sql, $get_type); if (empty($result_rs)) { $result_rs = $dbo->{$get_type}($sql); } return $result_rs; }
* @license http://www.idreamsoft.cn iDreamSoft * @author coolmoo <*****@*****.**> */ !defined('iPATH') && exit('What are you doing?'); switch ($operation) { case 'post': if ($action == 'cache') { if ($_POST['catalog']) { include_once iPATH . 'include/catalog.class.php'; $catalog = new catalog(); $catalog->cache(); } $_POST['tpl'] && $iCMS->clear_compiled_tpl(); $_POST['keywords'] && keywords_cache(); $_POST['tags'] && tags_cache(); $_POST['model'] && model_cache(); $_POST['field'] && field_cache(); $_POST['config'] && CreateConfigFile(); if ($_POST['Re-Statistics']) { $rs = $iCMS->db->getArray("SELECT id FROM `#iCMS@__catalog` ORDER BY `id` DESC"); $_count = count($rs); for ($i = 0; $i < $_count; $i++) { $c = $iCMS->db->getValue("SELECT count(*) FROM #iCMS@__article where `cid`='" . $rs[$i]['id'] . "' LIMIT 1 "); $iCMS->db->query("UPDATE `#iCMS@__catalog` SET `count` ='{$c}' WHERE `id` ='" . $rs[$i]['id'] . "' LIMIT 1 "); } } redirect("执行完毕!", __SELF__ . '?do=cache'); } break; default: $Admin->MP("menu_cache");
$sql = "CREATE TABLE `" . DB_PREFIX . $table . "_content` (\r\n `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n `cid` INT(10) UNSIGNED NOT NULL DEFAULT '0',\r\n `order` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\r\n `title` VARCHAR(255) NOT NULL DEFAULT '',\r\n `customlink` VARCHAR(255) NOT NULL DEFAULT '',\r\n `editor` VARCHAR(200) NOT NULL DEFAULT '',\r\n `userid` INT(10) UNSIGNED NOT NULL DEFAULT '0', \r\n `tags` VARCHAR(255) NOT NULL DEFAULT '',\r\n `pubdate` INT(10) UNSIGNED NOT NULL DEFAULT '0',\r\n `hits` INT(10) UNSIGNED NOT NULL DEFAULT '0',\r\n `digg` INT(10) UNSIGNED NOT NULL DEFAULT '0',\r\n `comments` INT(10) UNSIGNED NOT NULL DEFAULT '0',\r\n `type` VARCHAR(255) NOT NULL DEFAULT '',\r\n `vlink` VARCHAR(255) NOT NULL DEFAULT '',\r\n `top` SMALLINT(6) NOT NULL DEFAULT '0',\r\n `visible` ENUM('0','1') NOT NULL DEFAULT '1',\r\n `postype` TINYINT(1) NOT NULL DEFAULT '0',\r\n PRIMARY KEY (`id`),\r\n\t\t\t\t KEY `cid` (`visible`,`cid`),\r\n\t\t\t\t KEY `hits` (`visible`,`hits`),\r\n\t\t\t\t KEY `digg` (`visible`,`digg`),\r\n\t\t\t\t KEY `comments` (`visible`,`comments`),\r\n\t\t\t\t KEY `id` (`visible`,`id`),\r\n\t\t\t\t KEY `pubdate` (`visible`,`pubdate`),\r\n\t\t\t\t KEY `customlink` (`visible`,`customlink`)\r\n ) ENGINE=MYISAM DEFAULT CHARSET=" . DB_CHARSET; $iCMS->db->query($sql); model_cache(); redirect("新增模型完成!", __SELF__ . "?do=model&operation=manage", '3'); } else { $oTable = $iCMS->db->getValue("SELECT `table` FROM `#iCMS@__model` where `id` ='{$id}'"); if ($oTable != $table) { $iCMS->db->query("RENAME TABLE `" . DB_PREFIX . $oTable . "_content` TO `" . DB_PREFIX . $table . "_content`"); } $iCMS->db->update('model', compact('name', 'table', 'desc', 'listpage', 'showpage'), array('id' => $id)); model_cache(); redirect("模型编辑完成!", __SELF__ . "?do=model&operation=manage", '3'); } } if ($action == 'order') { $id = (int) $_POST['id']; $field = implode(',', $_POST['order']); $iCMS->db->update('model', compact('field'), compact('id')); model_cache(); redirect("字段排序完成!", __SELF__ . "?do=model&operation=field&mid=" . $id, '3'); } break; default: $Admin->MP("menu_model_manage"); $maxperpage = 20; $total = $iCMS->db->getValue("SELECT count(*) FROM `#iCMS@__model` order by id DESC"); page($total, $maxperpage, "个模型"); $rs = $iCMS->db->getArray("SELECT * FROM `#iCMS@__model` order by id DESC LIMIT {$firstcount},{$maxperpage}"); $_count = count($rs); include iCMS_admincp_tpl("model.manage"); }