diff --git a/admin/admin.class.php b/admin/admin.class.php
new file mode 100644
index 0000000..042194f
--- /dev/null
+++ b/admin/admin.class.php
@@ -0,0 +1,275 @@
+__construct();
+ }
+
+ function is_member($username) {
+ return DB::get_one("SELECT userid FROM ".DT_PRE."member WHERE username='$username'");
+ }
+
+ function count_admin() {
+ $r = DB::get_one("SELECT COUNT(*) AS num FROM ".DT_PRE."member WHERE groupid=1 AND admin=1 ");
+ return $r['num'];
+ }
+
+ function set_admin($username, $admin, $role, $aid) {
+ $username = trim($username);
+ $r = $this->is_member($username);
+ if(!$r) return $this->_('会员不存在');
+ $userid = $r['userid'];
+ if(is_founder($userid)) {
+ $admin = 1;
+ $aid = 0;
+ }
+ if($admin == 1) $aid = 0;
+ DB::query("UPDATE ".DT_PRE."member SET groupid=1,admin=$admin,role='$role',aid=$aid WHERE userid=$userid");
+ DB::query("UPDATE ".DT_PRE."company SET groupid=1 WHERE userid=$userid");
+ return true;
+ }
+
+ function move_admin($username) {
+ $r = $this->get_one($username);
+ if($r && $r['admin'] > 0) {
+ if(is_founder($r['userid'])) return $this->_('创始人不可改变级别');
+ if($r['admin'] == 1 && $this->count_admin() < 2) return $this->_('系统最少需要保留一位超级管理员');
+ $admin = $r['admin'] == 1 ? 2 : 1;
+ DB::query("UPDATE ".DT_PRE."member SET admin=$admin WHERE username='$username'");
+ return true;
+ } else {
+ return $this->_('管理员不存在');
+ }
+ }
+
+ function delete_admin($username) {
+ $r = $this->get_one($username);
+ if($r) {
+ if(is_founder($r['userid'])) return $this->_('创始人不可删除');
+ if($r['admin'] == 1 && $this->count_admin() < 2) return $this->_('系统最少需要保留一位超级管理员');
+ $userid = $r['userid'];
+ $groupid = $r['regid'] ? $r['regid'] : 6;
+ DB::query("UPDATE ".DT_PRE."member SET groupid=$groupid,admin=0,role='',aid=0 WHERE userid=$userid");
+ DB::query("UPDATE ".DT_PRE."company SET groupid=$groupid WHERE userid=$userid");
+ DB::query("DELETE FROM ".DT_PRE."admin WHERE userid=$userid");
+ cache_delete('menu-'.$userid.'.php');
+ cache_delete('right-'.$userid.'.php');
+ return true;
+ } else {
+ return $this->_('会员不存在');
+ }
+ }
+
+ function get_one($user, $type = 1) {
+ $fields = $type ? 'username' : 'userid';
+ return DB::get_one("SELECT * FROM ".DT_PRE."member WHERE `$fields`='$user'");
+ }
+
+ function get_list($condition, $order = 'admin ASC,userid ASC') {
+ global $pages, $page, $pagesize, $offset, $pagesize, $CFG, $sum;
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = DB::get_one("SELECT COUNT(*) AS num FROM ".DT_PRE."member WHERE $condition");
+ $items = $r['num'];
+ }
+ $pages = pages($items, $page, $pagesize);
+ $admins = array();
+ $result = DB::query("SELECT * FROM ".DT_PRE."member WHERE $condition ORDER BY $order LIMIT $offset,$pagesize");
+ while($r = DB::fetch_array($result)) {
+ $r['logintime'] = timetodate($r['logintime'], 5);
+ $r['adminname'] = $r['admin'] == 1 ? (is_founder($r['userid']) ? '网站创始人 ' : '超级管理员 ') : '普通管理员';
+ $admins[] = $r;
+ }
+ return $admins;
+ }
+
+ function get_right($userid) {
+ global $MODULE;
+ $rights = array();
+ $result = DB::query("SELECT * FROM ".DT_PRE."admin WHERE userid=$userid AND url='' ORDER BY moduleid DESC,file DESC,adminid DESC ");
+ while($r = DB::fetch_array($result)) {
+ @include DT_ROOT.'/'.($r['moduleid'] == 1 ? 'admin' : 'module/'.$MODULE[$r['moduleid']]['module'].'/admin').'/config.inc.php';
+ $r['name'] = isset($RT['file'][$r['file']]) ? '('.$RT['file'][$r['file']].')' : '';
+ $r['module'] = '('.$MODULE[$r['moduleid']]['name'].')';
+ $rights[] = $r;
+ }
+ return $rights;
+ }
+
+ function get_menu($userid) {
+ $menus = array();
+ $result = DB::query("SELECT * FROM ".DT_PRE."admin WHERE userid=$userid AND url!='' ORDER BY listorder ASC,adminid ASC ");
+ while($r = DB::fetch_array($result)) {
+ $menus[] = $r;
+ }
+ return $menus;
+ }
+
+ function update($userid, $right, $admin) {
+ if(isset($right[-1])) {
+ $this->add($userid, $right[-1], $admin);
+ unset($right[-1]);
+ $type = 1;//right
+ } else {
+ $type = 0;//menu
+ }
+ $this->add($userid, $right[0], $admin);
+ unset($right[0]);
+ foreach($right as $k=>$v) {
+ if(isset($v['delete'])) {
+ $this->delete($k);
+ unset($right[$k]);
+ }
+ }
+ $this->edit($right, $type);
+ if($admin == 1) DB::query("DELETE FROM ".DT_PRE."admin WHERE userid=$userid AND url=''");
+ $this->cache_right($userid);
+ $this->cache_menu($userid);
+ return true;
+ }
+
+ function add($userid, $right, $admin) {
+ if(isset($right['url'])) {
+ if(!$right['title'] || !$right['url']) return false;
+ $r = DB::get_one("SELECT * FROM ".DT_PRE."admin WHERE userid=$userid AND url='".$right['url']."'");
+ if($r) return false;
+ if($admin == 2 && defined('MANAGE_ADMIN')) {
+ $r = $this->url_right($right['url']);
+ if($r) $this->add($userid, $r, $admin);
+ }
+ } else {
+ $right['moduleid'] = intval($right['moduleid']);
+ if(!$right['moduleid']) return false;
+ $_right = $this->get_right($userid);
+ foreach($_right as $v) {//module admin
+ if($v['file'] == '' && $v['moduleid'] == $right['moduleid']) return false;
+ }
+ if($right['file']) {//file exists
+ foreach($_right as $v) {
+ if($v['file'] == $right['file'] && $v['moduleid'] == $right['moduleid']) return false;
+ }
+ } else {
+ unset($right['action'], $right['catid']);
+ }
+ }
+ $right['userid'] = $userid;
+ $sql1 = $sql2 = '';
+ foreach($right as $k=>$v) {
+ $sql1 .= ','.$k;
+ $sql2 .= ",'$v'";
+ }
+ $sql1 = substr($sql1, 1);
+ $sql2 = substr($sql2, 1);
+ DB::query("INSERT INTO ".DT_PRE."admin ($sql1) VALUES($sql2)");
+ }
+
+ function edit($right, $type = 0) {
+ if($type) {
+ //when module admin, have all rights
+ $moduleids = $adminids = array();
+ foreach($right as $k=>$v) {
+ if(!$v['file']) {
+ $moduleids[] = $v['moduleid'];
+ $adminids[$v['moduleid']] = $k;
+ $right[$k]['action'] = $right[$k]['catid'] = '';
+ }
+ }
+ if($moduleids) {
+ foreach($right as $k=>$v) {
+ if(in_array($v['moduleid'], $moduleids) && !in_array($k, $adminids)) {
+ unset($right[$k]);
+ $this->delete($k);
+ }
+ }
+ }
+ }
+ foreach($right as $key=>$value) {
+ if(isset($value['title'])) {
+ if(!$value['title'] || !$value['url']) continue;
+ } else {
+ $value['moduleid'] = intval($value['moduleid']);
+ if(!$value['moduleid']) continue;
+ }
+ $sql = '';
+ foreach($value as $k=>$v) {
+ $sql .= ",$k='$v'";
+ }
+ $sql = substr($sql, 1);
+ DB::query("UPDATE ".DT_PRE."admin SET $sql WHERE adminid='$key'");
+ }
+ }
+
+ function url_right($url) {
+ if(substr($url, 0, 1) == '?') $url = substr($url, 1);
+ $arr = array();
+ parse_str($url, $arr);
+ $arr['moduleid'] = isset($moduleid) ? $moduleid : 1;
+ $arr['file'] = isset($file) ? $file : 'index';
+ $arr['action'] = isset($action) ? $action : '';
+ return $arr;
+ }
+
+ function cache_right($userid) {
+ $rights = $this->get_right($userid);
+ $right = $moduleids = array();
+ foreach($rights as $v) {//get moduleids
+ isset($moduleids[$v['moduleid']]) or $moduleids[$v['moduleid']] = $v['moduleid'];
+ }
+ foreach($moduleids as $m) {//get rights
+ foreach($rights as $r) {
+ if($r['moduleid'] == $m) {
+ $r['file'] = $r['file'] ? $r['file'] : 'NA';
+ $right[$m][$r['file']]['action'] = $r['action'] ? explode('|', $r['action']) : '';
+ $right[$m][$r['file']]['catid'] = $r['catid'] ? explode('|', $r['catid']) : '';
+ }
+ }
+ }
+ foreach($right as $k=>$v) {
+ if(isset($v['NA'])) $right[$k] = '';
+ }
+ foreach($right as $k=>$v) {
+ if($v) {
+ foreach($v as $i=>$j) {
+ if(!$j['action'] && !$j['catid']) $right[$k][$i] = '';
+ }
+ }
+ }
+ cache_write('right-'.$userid.'.php', $right);
+ }
+
+ function cache_menu($userid) {
+ $menus = $this->get_menu($userid);
+ $menu = $r = array();
+ foreach($menus as $k=>$v) {
+ $r['title'] = $v['title'];
+ $r['style'] = $v['style'];
+ $r['url'] = $v['url'];
+ $menu[] = $r;
+ }
+ cache_write('admin-menu-'.$userid.'.php', $menu);
+ cache_write('menu-'.$userid.'.php', $menu);
+ }
+
+ function delete($adminid) {
+ DB::query("DELETE FROM ".DT_PRE."admin WHERE adminid=$adminid");
+ }
+
+ function _($e) {
+ $this->errmsg = $e;
+ return false;
+ }
+}
+?>
\ No newline at end of file
diff --git a/admin/admin.inc.php b/admin/admin.inc.php
new file mode 100644
index 0000000..8b32467
--- /dev/null
+++ b/admin/admin.inc.php
@@ -0,0 +1,365 @@
+set_admin($username, $admin, $role, $aid)) {
+ $r = $do->get_one($username);
+ $userid = $r['userid'];
+ if($r['admin'] == 2) {
+ foreach($MODULE as $m) {
+ if(isset($roles[$m['moduleid']])) {
+ $right = array();
+ $right['title'] = $m['name'].'管理';
+ $right['url'] = '?moduleid='.$m['moduleid'];
+ $do->add($userid, $right, $admin);
+ }
+ }
+ if(isset($roles['database'])) {
+ $right = array();
+ $right['title'] = '数据库管理';
+ $right['url'] = '?file=database';
+ $do->add($userid, $right, $admin);
+ }
+ if(isset($roles['template'])) {
+ $right = array();
+ $right['title'] = '模板管理';
+ $right['url'] = '?file=template';
+ $do->add($userid, $right, $admin);
+ $right = array();
+ $right['title'] = '风格管理';
+ $right['url'] = '?file=skin';
+ $do->add($userid, $right, $admin);
+ $right = array();
+ $right['title'] = '标签向导';
+ $right['url'] = '?file=tag';
+ $do->add($userid, $right, $admin);
+ }
+ $do->cache_right($userid);
+ $do->cache_menu($userid);
+ }
+ msg('管理员添加成功,下一步请分配权限和管理面板', '?file='.$file.'&id='.$userid.'&tm='.($DT_TIME+5));
+ }
+ msg($do->errmsg);
+ } else {
+ isset($username) or $username = '';
+ include tpl('admin_add');
+ }
+ break;
+ case 'edit':
+ if($submit) {
+ $admin = $admin == 1 ? 1 : 2;
+ if($do->set_admin($username, $admin, $role, $aid)) {
+ $r = $do->get_one($username);
+ $userid = $r['userid'];
+ if($r['admin'] == 2) {
+ $do->cache_right($userid);
+ $do->cache_menu($userid);
+ }
+ dmsg('修改成功', '?file='.$file);
+ }
+ msg($do->errmsg);
+ } else {
+ if(!$userid) msg();
+ $user = $do->get_one($userid, 0);
+ include tpl('admin_edit');
+ }
+ break;
+ case 'temp':
+ $link = '';
+ $link_user = $_username;
+ $link_minute = 60;
+ $link_ip = '';
+ if($submit) {
+ if($_founder) {
+ $username = trim($username);
+ if($username == $_username) {
+ //
+ } else {
+ check_name($username) or msg('用户格式错误');
+ $user = userinfo($username);
+ $user or msg('用户'.$username.'不存在');
+ ($user['groupid'] == 1 && $user['admin'] > 0) or msg('用户'.$username.'非管理员');
+ }
+ $link_user = $username;
+ } else {
+ $link_user = $username = $_username;
+ }
+ $minute = intval($minute);
+ if($minute < 10) $minute = 10;
+ if($minute > 600) $minute = 30;
+ $link_minute = $minute;
+ $ip = trim($ip);
+ $link_ip = $ip;
+ $expiry = $minute*60;
+ $auth = $username.'|'.(DT_TIME + $expiry).'|'.$ip;
+ $link = DT_PATH.basename(get_env('self')).'?file=login&action=temp&auth='.encrypt($auth, DT_KEY.'TMPA', $expiry);
+ if(strpos(get_env('self'), '/admin.php') !== false) $link = '后台地址未修改,暂不支持临时授权';
+ }
+ include tpl('admin_temp');
+ break;
+ case 'delete':
+ if($do->delete_admin($username)) dmsg('撤销成功', $this_forward);
+ msg($do->errmsg);
+ break;
+ case 'right':
+ if(!$userid) msg();
+ $user = $do->get_one($userid, 0);
+ if($submit) {
+ $right[0]['action'] = $right[0]['action'] ? implode('|', $right[0]['action']) : '';
+ $right[0]['catid'] = $right[0]['catid'] ? implode('|', $right[0]['catid']) : '';
+ if($do->update($userid, $right, $user['admin'])) {
+ dmsg('更新成功', '?file='.$file.'&action=right&userid='.$userid);
+ }
+ msg($do->errmsg);
+ } else {
+ $username = $user['username'];
+ $drights = $do->get_right($userid);
+ $dmenus = $do->get_menu($userid);
+ include tpl('admin_right');
+ }
+ break;
+ case 'ajax':
+ @include DT_ROOT.'/'.($mid == 1 ? 'admin' : 'module/'.$MODULE[$mid]['module'].'/admin').'/config.inc.php';
+ if(isset($fi)) {
+ if(isset($RT) && isset($RT['action'][$fi])) {
+ $action_select = '选择动作[按Ctrl键多选] ';
+ foreach($RT['action'][$fi] as $k=>$v) {
+ $action_select .= ''.$v.'['.$k.'] ';
+ }
+ $action_select .= ' ';
+ echo $action_select;
+ } else {
+ echo '0';
+ }
+ } else {
+ if(isset($RT)) {
+ $file_select = '选择文件[单选] ';
+ foreach($RT['file'] as $k=>$v) {
+ $file_select .= ''.$v.'['.$k.'] ';
+ }
+ $file_select .= ' ';
+ echo $file_select.'|';
+ if($CT) {
+ $CATEGORY = cache_read('category-'.$mid.'.php');
+ echo '';
+ echo '选择分类多选[按Ctrl键多选] ';
+ foreach($CATEGORY as $c) {
+ if($c['parentid'] == 0) echo ''.$c['catname'].' ';
+ }
+ echo ' ';
+ } else {
+ echo '0';
+ }
+ } else {
+ echo '0|0';
+ }
+ }
+ break;
+ case 'online':
+ $lastime = $DT_TIME - $DT['online'];
+ $db->query("DELETE FROM {$DT_PRE}admin_online WHERE lasttime<$lastime");
+ $sid = session_id();
+ $lists = array();
+ $result = $db->query("SELECT * FROM {$DT_PRE}admin_online ORDER BY lasttime DESC");
+ while($r = $db->fetch_array($result)) {
+ $r['lasttime'] = timetodate($r['lasttime'], 'H:i:s');
+ $lists[] = $r;
+ }
+ include tpl('admin_online');
+ break;
+ case 'clear':
+ $time = $DT_TODAY - 30*86400;
+ $db->query("DELETE FROM {$DT_PRE}admin_log WHERE logtime<$time");
+ dmsg('清理成功', '?file='.$file.'&action=log');
+ break;
+ case 'log':
+ $F = array(
+ 'index' => '列表',
+ 'setting' => '设置',
+ 'category' => '栏目管理',
+ 'type' => '分类管理',
+ 'keylink' => '关联链接',
+ 'split' => '数据拆分',
+ 'html' => '更新数据',
+ 'mymenu' => '定义面板',
+ 'module' => '模块管理',
+ 'area' => '地区管理',
+ 'admin' => '管理设置',
+ 'database' => '数据维护',
+ 'data' => '数据处理',
+ 'template' => '模板管理',
+ 'tag' => '标签向导',
+ 'skin' => '风格管理',
+ 'md5' => '文件校验',
+ 'scan' => '木马扫描',
+ 'stats' => '流量统计',
+ 'upload' => '上传记录',
+ '404' => '404日志',
+ 'patch' => '文件维护',
+ 'keyword' => '搜索记录',
+ 'question' => '问题验证',
+ 'banword' => '词语过滤',
+ 'repeat' => '重名检测',
+ 'banip' => '禁止IP',
+ 'fetch' => '单页采编',
+ 'word' => '编辑助手',
+ 'doctor' => '系统体检',
+
+ 'contact' => '联系会员',
+ 'group' => '会员组',
+ 'validate' => '资料审核',
+ 'grade' => '会员升级',
+ 'weixin' => '微信管理',
+ 'oauth' => '一键登录',
+
+ 'child' => '子账号',
+ 'stock' => '商品库存',
+ 'honor' => '荣誉资质',
+ 'news' => '公司新闻',
+ 'page' => '公司单页',
+ 'link' => '友情链接',
+ 'style' => '公司模板',
+
+ 'record' => '资金管理',
+ 'credit' => '积分管理',
+ 'sms' => '短信管理',
+ 'charge' => '支付记录',
+ 'cash' => '提现记录',
+ 'pay' => '信息支付',
+ 'award' => '信息打赏',
+ 'promo' => '优惠促销',
+ 'deposit' => '保证金',
+ 'card' => '充值卡',
+
+ 'chat' => '在线交谈',
+ 'message' => '站内信件',
+ 'sendmail' => '电子邮件',
+ 'sendsms' => '手机短信',
+ 'ask' => '客服中心',
+ 'friend' => '会员好友',
+ 'favorite' => '站内收藏',
+ 'address' => '收货地址',
+ 'alert' => '贸易提醒',
+ 'validate' => '资料认证',
+ 'mail' => '邮件订阅',
+ 'loginlog' => '登录日志',
+
+ 'spread' => '排名推广',
+ 'ad' => '广告管理',
+ 'announce' => '公告管理',
+ 'webpage' => '单页管理',
+ 'comment' => '评论管理',
+ 'guestbook' => '留言管理',
+ 'vote' => '投票管理',
+ 'gift' => '积分换礼',
+ 'poll' => '票选管理',
+ 'form' => '表单管理',
+
+ 'expert' => '知道专家',
+ 'answer' => '知道答案',
+ 'product' => '行情产品',
+ 'resume' => '简历',
+ 'price' => '报价',
+ 'order' => '订单管理',
+ );
+ $A = array(
+ 'add' => '添加',
+ 'edit' => '修改',
+ 'delete' => '删除 ',
+ 'clear' => '清理 ',
+ 'check' => '待审核',
+ 'reject' => '未通过',
+ 'expire' => '已过期',
+ 'recycle' => '回收站',
+ 'level' => '级别',
+ 'order' => '排序',
+ 'html' => '更新',
+ 'update' => '更新',
+ 'send' => '发送',
+ 'move' => '移动',
+ );
+ $sfields = array('按条件', '网址', '管理员', 'IP');
+ $dfields = array('qstring', 'qstring', 'username', 'ip');
+ isset($fields) && isset($dfields[$fields]) or $fields = 0;
+ $ip = isset($ip) ? $ip : '';
+ (isset($username) && check_name($username)) or $username = '';
+ (isset($fromdate) && is_time($fromdate)) or $fromdate = '';
+ $fromtime = $fromdate ? datetotime($fromdate) : 0;
+ (isset($todate) && is_time($todate)) or $todate = '';
+ $totime = $todate ? datetotime($todate) : 0;
+
+ $fields_select = dselect($sfields, 'fields', '', $fields);
+
+ $condition = '1';
+ if($keyword) $condition .= match_kw($dfields[$fields], $keyword);
+ if($fromtime) $condition .= " AND logtime>=$fromtime";
+ if($totime) $condition .= " AND logtime<=$totime";
+ if($ip) $condition .= " AND ip='$ip'";
+ if($username) $condition .= " AND username='$username'";
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = $db->get_one("SELECT COUNT(*) AS num FROM {$DT_PRE}admin_log WHERE $condition");
+ $items = $r['num'];
+ }
+ $pages = pages($items, $page, $pagesize);
+ $lists = array();
+ $result = $db->query("SELECT * FROM {$DT_PRE}admin_log WHERE $condition ORDER BY logid DESC LIMIT $offset,$pagesize");
+ while($r = $db->fetch_array($result)) {
+ parse_str($r['qstring'], $t);
+ $m = isset($t['moduleid']) ? $t['moduleid'] : 1;
+ $r['mid'] = $m;
+ $r['module_name'] = $MODULE[$m]['name'];
+ $r['file'] = $f = isset($t['file']) ? $t['file'] : 'index';
+ if(isset($F[$f])) $f = $F[$f];
+ $r['file_name'] = $f;
+ $r['action'] = $a = isset($t['action']) ? $t['action'] : '';
+ if(isset($A[$a])) $a = $A[$a];
+ $r['action_name'] = $a;
+ $i = isset($t['itemid']) ? $t['itemid'] : (isset($t['userid']) ? $t['userid'] : '');
+ $r['itemid'] = $i;
+ $r['logtime'] = timetodate($r['logtime'], 6);
+ $lists[] = $r;
+ }
+ include tpl('admin_log');
+ break;
+ default:
+ $sfields = array('按条件', '用户名', '姓名', '角色');
+ $dfields = array('username', 'username', 'truename', 'role');
+ isset($fields) && isset($dfields[$fields]) or $fields = 0;
+ $sorder = array('结果排序方式', '登录时间降序', '登录时间升序', '登录次数降序', '登录次数升序', '会员ID降序', '会员ID升序');
+ $dorder = array('admin ASC,userid ASC', 'logintime DESC', 'logintime ASC', 'logintimes DESC', 'logintimes ASC', 'userid DESC', 'userid ASC');
+ isset($order) && isset($dorder[$order]) or $order = 0;
+ $type = isset($type) ? intval($type) : 0;
+ $areaid = isset($areaid) ? intval($areaid) : 0;
+
+ $fields_select = dselect($sfields, 'fields', '', $fields);
+ $order_select = dselect($sorder, 'order', '', $order);
+
+ $condition = 'groupid=1 AND admin>0';
+ if($keyword) $condition .= match_kw($dfields[$fields], $keyword);
+ if($type) $condition .= " AND admin=$type";
+ if($areaid) $condition .= ($AREA[$areaid]['child']) ? " AND aid IN (".$AREA[$areaid]['arrchildid'].")" : " AND aid=$areaid";
+ $lists = $do->get_list($condition, $dorder[$order]);
+ include tpl('admin');
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/admin_check.inc.php b/admin/admin_check.inc.php
new file mode 100644
index 0000000..270b9cb
--- /dev/null
+++ b/admin/admin_check.inc.php
@@ -0,0 +1,49 @@
+query("SELECT arrchildid FROM {$DT_PRE}category WHERE catid IN ($_catids)");
+ while($r = $db->fetch_array($result)) {
+ if($r['arrchildid']) $_childs .= ','.$r['arrchildid'];
+ }
+ if($_childs) {
+ $_childs = substr($_childs, 1);
+ $_child = explode(',', $_childs);
+ if($catid && !in_array($catid, $_child)) msg('您无权进行此操作 Error(10)');
+ if(isset($post['catid']) && $post['catid'] && !in_array($post['catid'], $_child)) msg('您无权进行此操作 Error(11)');
+ if($itemid) {
+ if(is_array($itemid)) {
+ foreach($itemid as $_itemid) {
+ item_check($_itemid) or msg('您无权进行此操作 Error(12)');
+ }
+ } else {
+ item_check($itemid) or msg('您无权进行此操作 Error(13)');
+ }
+ }
+ }
+}
+//CITY
+if($_areaids) {
+ if($areaid == 0) {
+ $areaid = $_aid;
+ $ARE = $AREA[$areaid];
+ } else {
+ if(!in_array($areaid, $_areaid)) msg('您无权进行此操作 Error(20)');
+ }
+ if(isset($post['areaid']) && $post['areaid'] && !in_array($post['areaid'], $_areaid)) msg('您无权进行此操作 Error(21)');
+ if($itemid) {
+ if(is_array($itemid)) {
+ foreach($itemid as $_itemid) {
+ city_check($_itemid) or msg('您无权进行此操作 Error(22)');
+ }
+ } else {
+ city_check($itemid) or msg('您无权进行此操作 Error(23)');
+ }
+ }
+}
+?>
\ No newline at end of file
diff --git a/admin/area.inc.php b/admin/area.inc.php
new file mode 100644
index 0000000..bfe19aa
--- /dev/null
+++ b/admin/area.inc.php
@@ -0,0 +1,201 @@
+add($area);
+ } else {
+ $areanames = explode("\n", $area['areaname']);
+ foreach($areanames as $areaname) {
+ $areaname = trim($areaname);
+ if(!$areaname) continue;
+ $area['areaname'] = $areaname;
+ $do->add($area);
+ }
+ }
+ $do->repair();
+ dmsg('添加成功', $this_forward);
+ } else {
+ include tpl('area_add');
+ }
+ break;
+ case 'import':
+ $file = DT_ROOT.'/file/setting/area.sql';
+ is_file($file) or msg('数据文件不存在,请上传程序包内 file/setting/area.sql 文件至 file/setting 目录');
+ require DT_ROOT.'/include/sql.func.php';
+ sql_execute(file_get($file));
+ cache_area();
+ dmsg('导入成功', $this_forward);
+ break;
+ case 'cache':
+ $do->repair();
+ dmsg('更新成功', $forward);
+ break;
+ case 'delete':
+ if($areaid) $areaids = $areaid;
+ $areaids or msg();
+ $do->delete($areaids);
+ dmsg('删除成功', $this_forward);
+ break;
+ case 'update':
+ if(!$area || !is_array($area)) msg();
+ $do->update($area);
+ dmsg('更新成功', $this_forward);
+ break;
+ default:
+ $DAREA = array();
+ $condition = $keyword ? "areaname LIKE '%$keyword%'" : "parentid=$parentid";
+ $result = $db->query("SELECT * FROM {$table} WHERE $condition ORDER BY listorder,areaid");
+ while($r = $db->fetch_array($result)) {
+ $r['childs'] = substr_count($r['arrchildid'], ',');
+ $DAREA[$r['areaid']] = $r;
+ }
+ include tpl('area');
+ break;
+}
+
+class area {
+ var $areaid;
+ var $area = array();
+ var $table;
+
+ function __construct($areaid = 0) {
+ global $AREA;
+ $this->areaid = $areaid;
+ $this->area = $AREA;
+ $this->table = DT_PRE.'area';
+ }
+
+ function area($areaid = 0) {
+ $this->__construct($areaid);
+ }
+
+ function add($area) {
+ if(!is_array($area)) return false;
+ $sql1 = $sql2 = $s = '';
+ foreach($area as $key=>$value) {
+ $sql1 .= $s.$key;
+ $sql2 .= $s."'".$value."'";
+ $s = ',';
+ }
+ DB::query("INSERT INTO {$this->table} ($sql1) VALUES($sql2)");
+ $this->areaid = DB::insert_id();
+ if($area['parentid']) {
+ $area['areaid'] = $this->areaid;
+ $this->area[$this->areaid] = $area;
+ $arrparentid = $this->get_arrparentid($this->areaid);
+ } else {
+ $arrparentid = 0;
+ }
+ DB::query("UPDATE {$this->table} SET arrchildid='$this->areaid',listorder=$this->areaid,arrparentid='$arrparentid' WHERE areaid=$this->areaid");
+ return true;
+ }
+
+ function delete($areaids) {
+ if(is_array($areaids)) {
+ foreach($areaids as $areaid) {
+ if(isset($this->area[$areaid])) {
+ $arrchildid = $this->area[$areaid]['arrchildid'];
+ DB::query("DELETE FROM {$this->table} WHERE areaid IN ($arrchildid)");
+ }
+ }
+ } else {
+ $areaid = $areaids;
+ if(isset($this->area[$areaid])) {
+ $arrchildid = $this->area[$areaid]['arrchildid'];
+ DB::query("DELETE FROM {$this->table} WHERE areaid IN ($arrchildid)");
+ }
+ }
+ $this->repair();
+ return true;
+ }
+
+ function update($area) {
+ if(!is_array($area)) return false;
+ foreach($area as $k=>$v) {
+ if(!$v['areaname']) continue;
+ $v['parentid'] = intval($v['parentid']);
+ if($k == $v['parentid']) continue;
+ if($v['parentid'] > 0 && !isset($this->area[$v['parentid']])) continue;
+ $v['listorder'] = intval($v['listorder']);
+ DB::query("UPDATE {$this->table} SET areaname='$v[areaname]',parentid='$v[parentid]',listorder='$v[listorder]' WHERE areaid=$k");
+ }
+ cache_area();
+ return true;
+ }
+
+ function repair() {
+ $query = DB::query("SELECT * FROM {$this->table} ORDER BY listorder,areaid");
+ $AREA = array();
+ while($r = DB::fetch_array($query)) {
+ $AREA[$r['areaid']] = $r;
+ }
+ $childs = array();
+ foreach($AREA as $areaid => $area) {
+ $arrparentid = $this->get_arrparentid($areaid);
+ DB::query("UPDATE {$this->table} SET arrparentid='$arrparentid' WHERE areaid=$areaid");
+ if($arrparentid) {
+ $arr = explode(',', $arrparentid);
+ foreach($arr as $a) {
+ if($a == 0) continue;
+ isset($childs[$a]) or $childs[$a] = '';
+ $childs[$a] .= ','.$areaid;
+ }
+ }
+ }
+ foreach($AREA as $areaid => $area) {
+ if(isset($childs[$areaid])) {
+ $arrchildid = $areaid.$childs[$areaid];
+ DB::query("UPDATE {$this->table} SET arrchildid='$arrchildid',child=1 WHERE areaid='$areaid'");
+ } else {
+ DB::query("UPDATE {$this->table} SET arrchildid='$areaid',child=0 WHERE areaid='$areaid'");
+ }
+ }
+ cache_area();
+ return true;
+ }
+
+ function get_arrparentid($areaid) {
+ $ARE = get_area($areaid);
+ if($ARE['parentid'] && $ARE['parentid'] != $areaid) {
+ $parents = array();
+ $cid = $areaid;
+ $i = 1;
+ while($i++ < 10) {
+ $ARE = get_area($cid);
+ if($ARE['parentid']) {
+ $parents[] = $cid = $ARE['parentid'];
+ } else {
+ break;
+ }
+ }
+ $parents[] = 0;
+ return implode(',', array_reverse($parents));
+ } else {
+ return '0';
+ }
+ }
+}
+?>
\ No newline at end of file
diff --git a/admin/banip.inc.php b/admin/banip.inc.php
new file mode 100644
index 0000000..1b4e5e1
--- /dev/null
+++ b/admin/banip.inc.php
@@ -0,0 +1,128 @@
+ 50) msg('禁止内容限3-50字符');
+ if($ip == DT_IP) msg('不能禁用自己的IP');
+ //if(!preg_match("/^[0-9]{1,3}\.[0-9\*]{1,3}\.[0-9\*]{1,3}\.[0-9\*]{1,3}$/", $ip)) msg('IP地址或IP段格式错误');
+ $note = dhtmlspecialchars(trim($note));
+ $totime = is_time($totime) ? datetotime($totime) : 0;
+ $db->query("INSERT INTO {$DT_PRE}banip (ip,editor,addtime,totime,note) VALUES ('$ip','$_username','$DT_TIME','$totime','$note')");
+ cache_banip();
+ dmsg('添加成功', '?file='.$file);
+ } else {
+ isset($ip) or $ip = '';
+ $totime = '';
+ include tpl('banip_edit');
+ }
+ break;
+ case 'delete':
+ $itemid or msg('请选择项目');
+ $itemids = is_array($itemid) ? implode(',', $itemid) : $itemid;
+ $db->query("DELETE FROM {$DT_PRE}banip WHERE itemid IN ($itemids)");
+ cache_banip();
+ dmsg('删除成功', '?file='.$file);
+ break;
+ case 'clear':
+ $db->query("DELETE FROM {$DT_PRE}banip WHERE totime>0 and totime<$DT_TIME");
+ cache_banip();
+ dmsg('清空成功', '?file='.$file);
+ break;
+ case 'unban':
+ $ip or msg('IP不能为空');
+ if(is_array($ip)) {
+ foreach($ip as $v) {
+ file_del(DT_CACHE.'/ban/'.$v.'.php');
+ }
+ } else {
+ file_del(DT_CACHE.'/ban/'.$ip.'.php');
+ }
+ dmsg('删除成功', '?file='.$file.'&action=ban');
+ break;
+ case 'down':
+ dheader($http.'wry.rar');
+ break;
+ case 'update':
+ $wry = DT_ROOT.'/file/ipdata/wry.dat';
+ $new = file_get($http.'wry.txt');
+ is_date($new) or msg('无法连接更新服务器');
+ if(is_file($wry)) {
+ $now = timetodate(filemtime($wry), 'Ymd');
+ $new > $now or msg('已是最新版本,无需更新');
+ rename($wry, DT_ROOT.'/file/ipdata/'.$now.'.dat');
+ }
+ file_copy($http.'wry.dat', $wry);
+ is_file($wry) or msg('更新失败,请重试');
+ @touch($wry, datetotime($new));
+ dmsg('更新成功', '?file='.$file.'&action=data');
+ break;
+ case 'data':
+ $wry = DT_ROOT.'/file/ipdata/wry.dat';
+ $new = file_get($http.'wry.txt');
+ $get = 0;
+ $update = 0;
+ if(is_date($new)) {
+ $get = 1;
+ } else {
+ $new = '获取失败 ';
+ }
+ if(is_file($wry)) {
+ $now = timetodate(filemtime($wry), 'Ymd');
+ if($get && $new > $now) $update = 1;
+ } else {
+ $now = '文件不存在 ';
+ $update =1;
+ }
+ include tpl('banip_data');
+ break;
+ case 'login':
+ $ips = glob(DT_CACHE.'/ban/*.php');
+ $lists = array();
+ if($ips) {
+ foreach($ips as $k=>$v) {
+ $lists[$k]['ip'] = basename($v, '.php');
+ $lists[$k]['addtime'] = timetodate(filemtime($v), 5);
+ }
+ }
+ include tpl('banip_login');
+ break;
+ default:
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = $db->get_one("SELECT COUNT(*) AS num FROM {$DT_PRE}banip");
+ $items = $r['num'];
+ }
+ $pages = pages($items, $page, $pagesize);
+ $lists = array();
+ $result = $db->query("SELECT * FROM {$DT_PRE}banip ORDER BY itemid DESC LIMIT $offset,$pagesize");
+ while($r = $db->fetch_array($result)) {
+ if(is_ip($r['ip'])) {
+ $r['type'] = ip2area($r['ip']);
+ } else if(preg_match("/^[0-9]{1,3}\.[0-9\*]{1,3}\.[0-9\*]{1,3}\.[0-9\*]{1,3}$/", $r['ip'])) {
+ $r['type'] = 'IP段';
+ } else {
+ $r['type'] = '客户端';
+ }
+ $r['addtime'] = timetodate($r['addtime'], 5);
+ $r['status'] = ($r['totime'] && $DT_TIME > $r['totime']) ? '过期 ' : '有效 ';
+ $r['totime'] = $r['totime'] ? timetodate($r['totime'], 3) : '永久';
+ $lists[] = $r;
+ }
+ include tpl('banip');
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/banword.inc.php b/admin/banword.inc.php
new file mode 100644
index 0000000..e2bd941
--- /dev/null
+++ b/admin/banword.inc.php
@@ -0,0 +1,82 @@
+update($post);
+ dmsg('保存成功', '?file='.$file.'&item='.$item);
+} else {
+ $condition = "1";
+ if($keyword) $condition .= " AND (replacefrom LIKE '%$keyword%' OR replaceto LIKE '%$keyword%')";
+ $lists = $do->get_list($condition);
+ include tpl('banword');
+}
+
+class banword {
+ var $table;
+
+ function __construct() {
+ $this->table = DT_PRE.'banword';
+ }
+
+ function banword() {
+ $this->__construct();
+ }
+
+ function get_list($condition) {
+ global $pages, $page, $pagesize, $offset, $pagesize;
+ $pages = pages(DB::count($this->table, $condition), $page, $pagesize);
+ $lists = array();
+ $result = DB::query("SELECT * FROM {$this->table} WHERE $condition ORDER BY bid DESC LIMIT $offset,$pagesize");
+ while($r = DB::fetch_array($result)) {
+ $lists[] = $r;
+ }
+ return $lists;
+ }
+
+ function update($post) {
+ $this->add($post[0]);
+ unset($post[0]);
+ foreach($post as $k=>$v) {
+ if(isset($v['delete'])) {
+ $this->delete($k);
+ unset($post[$k]);
+ }
+ }
+ $this->edit($post);
+ cache_banword();
+ }
+
+ function add($post) {
+ if(!$post['replacefrom']) return false;
+ $post['deny'] = in_array($post['deny'], array(0, 1, 2)) ? $post['deny'] : 0;
+ $F = explode("\n", $post['replacefrom']);
+ $T = explode("\n", $post['replaceto']);
+ foreach($F as $k=>$f) {
+ $f = trim($f);
+ if($f) {
+ $t = isset($T[$k]) ? trim($T[$k]) : '';
+ if($f != $t) DB::query("INSERT INTO {$this->table} (replacefrom,replaceto,deny) VALUES('$f','$t','$post[deny]')");
+ }
+ }
+ }
+
+ function edit($post) {
+ foreach($post as $k=>$v) {
+ if(!$v['replacefrom']) continue;
+ $v['deny'] = in_array($v['deny'], array(0, 1, 2)) ? $v['deny'] : 0;
+ if($v['replacefrom'] != $v['replaceto']) DB::query("UPDATE {$this->table} SET replacefrom='$v[replacefrom]',replaceto='$v[replaceto]',deny='$v[deny]' WHERE bid='$k'");
+ }
+ }
+
+ function delete($bid) {
+ DB::query("DELETE FROM {$this->table} WHERE bid=$bid");
+ }
+}
+?>
\ No newline at end of file
diff --git a/admin/cate.inc.php b/admin/cate.inc.php
new file mode 100644
index 0000000..78f9e9c
--- /dev/null
+++ b/admin/cate.inc.php
@@ -0,0 +1,17 @@
+
\ No newline at end of file
diff --git a/admin/category.inc.php b/admin/category.inc.php
new file mode 100644
index 0000000..9a4bb97
--- /dev/null
+++ b/admin/category.inc.php
@@ -0,0 +1,432 @@
+get_catdir($category['catdir']);
+ $do->add($category);
+ $childs .= ','.$do->catid;
+ $catids[] = $do->catid;
+ } else {
+ $catnames = explode("\n", $category['catname']);
+ foreach($catnames as $catname) {
+ $catname = trim($catname);
+ if(!$catname) continue;
+ $category['catname'] = $catname;
+ $category['catdir'] = '';
+ $category['letter'] = '';
+ $category['seo_title'] = '';
+ $category['seo_keywords'] = '';
+ $category['seo_description'] = '';
+ $do->add($category);
+ $childs .= ','.$do->catid;
+ $catids[] = $do->catid;
+ }
+ }
+ if($category['parentid']) {
+ $parents = array();
+ $cid = $category['parentid'];
+ $parents[] = $cid;
+ while(1) {
+ if($CATEGORY[$cid]['parentid']) {
+ $parents[] = $cid = $CATEGORY[$cid]['parentid'];
+ } else {
+ break;
+ }
+ }
+ foreach($parents as $catid) {
+ $arrchildid = $CATEGORY[$catid]['child'] ? $CATEGORY[$catid]['arrchildid'].$childs : $catid.$childs;
+ $db->query("UPDATE {$table} SET child=1,arrchildid='$arrchildid' WHERE catid=$catid");
+ }
+ }
+ foreach($catids as $catid) {
+ $CATEGORY[$catid] = $db->get_one("SELECT * FROM {$table} WHERE catid=$catid");
+ update_category($CATEGORY[$catid]);
+ }
+ $NUM > 500 ? $do->cache() : $do->repair();
+ dmsg('添加成功', '?file='.$file.'&mid='.$mid.'&parentid='.$category['parentid']);
+ } else {
+ include tpl('category_add');
+ }
+ break;
+ case 'edit':
+ $catid or msg();
+ if($submit) {
+ if(!$category['catname']) msg('分类名不能为空');
+ if($category['parentid'] == $catid) msg('上级分类不能与当前分类相同');
+ $do->edit($category);
+ $category['catid'] = $catid;
+ update_category($category);
+ $NUM > 500 ? $do->cache() : $do->repair();
+ dmsg('修改成功', '?file='.$file.'&mid='.$mid.'&parentid='.$category['parentid']);
+ } else {
+ extract($db->get_one("SELECT * FROM {$table} WHERE catid=$catid"));
+ include tpl('category_edit');
+ }
+ break;
+ case 'copy':
+ if($submit) {
+ if(!$fromid) msg('源模块ID不能为空');
+ if(!$save) $db->query("DELETE FROM {$table} WHERE moduleid=$mid");
+ $result = $db->query("SELECT * FROM {$table} WHERE moduleid=$fromid ORDER BY catid");
+ $O = $R = array();
+ while($r = $db->fetch_array($result)) {
+ $O[$r['catid']] = $r['catname'];
+ $sqlk = $sqlv = '';
+ $catid = $r['catid'];
+ unset($r['catid']);
+ $r['moduleid'] = $mid;
+ $r['item'] = $r['property'] = 0;
+ $r = daddslashes($r);
+ foreach($r as $k=>$v) {
+ $sqlk .= ','.$k; $sqlv .= ",'$v'";
+ }
+ $sqlk = substr($sqlk, 1);
+ $sqlv = substr($sqlv, 1);
+ $db->query("INSERT INTO {$table} ($sqlk) VALUES ($sqlv)");
+ $R[$catid] = $db->insert_id();
+ }
+ $result = $db->query("SELECT * FROM {$table} WHERE moduleid='$mid' ORDER BY catid");
+ while($r = $db->fetch_array($result)) {
+ $catid = $r['catid'];
+ $v = $r['parentid'];
+ $parentid = isset($R[$v]) ? $R[$v] : $v;
+ $arrparentid = explode(',', $r['arrparentid']);
+ foreach($arrparentid as $k=>$v) {
+ if(isset($R[$v])) $arrparentid[$k] = $R[$v];
+ }
+ $arrparentid = implode(',', $arrparentid);
+ $arrchildid = explode(',', $r['arrchildid']);
+ foreach($arrchildid as $k=>$v) {
+ if(isset($R[$v])) $arrchildid[$k] = $R[$v];
+ }
+ $arrchildid = implode(',', $arrchildid);
+ $db->query("UPDATE {$table} SET parentid='$parentid',arrparentid='$arrparentid',arrchildid='$arrchildid' WHERE catid=$catid");
+ }
+ $do->repair();
+ msg('分类复制成功', '?file='.$file.'&action=url&&mid='.$mid.'&forward='.urlencode('?file='.$file.'&mid='.$mid));
+ } else {
+ include tpl('category_copy');
+ }
+ break;
+ case 'caches':
+ msg('开始更新统计', "?file=$file&mid=$mid&action=count");
+ break;
+ case 'count':
+ require DT_ROOT.'/include/module.func.php';
+ $tb = get_table($mid);
+ if($MODULE[$mid]['module'] == 'club') $tb = $DT_PRE.'club_group_'.$mid;
+ if(!isset($num)) {
+ $num = 50;
+ }
+ if(!isset($fid)) {
+ $r = $db->get_one("SELECT MIN(catid) AS fid FROM {$table} WHERE moduleid=$mid");
+ $fid = $r['fid'] ? $r['fid'] : 0;
+ }
+ isset($sid) or $sid = $fid;
+ if(!isset($tid)) {
+ $r = $db->get_one("SELECT MAX(catid) AS tid FROM {$table} WHERE moduleid=$mid");
+ $tid = $r['tid'] ? $r['tid'] : 0;
+ }
+ if($fid <= $tid) {
+ $result = $db->query("SELECT catid FROM {$table} WHERE moduleid=$mid AND catid>=$fid ORDER BY catid LIMIT 0,$num");
+ if($db->affected_rows($result)) {
+ while($r = $db->fetch_array($result)) {
+ $catid = $r['catid'];
+ if($mid == 4) {
+ $condition = "groupid>5 and catids like '%,".$catid.",%'";
+ } else {
+ $condition = 'status=3';
+ $condition .= $CATEGORY[$catid]['child'] ? " AND catid IN (".$CATEGORY[$catid]['arrchildid'].")" : " AND catid=$catid";
+ }
+ $item = $db->count($tb, $condition);
+ $db->query("UPDATE {$table} SET item=$item WHERE catid=$catid");
+ }
+ $catid += 1;
+ } else {
+ $catid = $fid + $num;
+ }
+ } else {
+ msg('统计更新成功', "?file=$file&mid=$mid&action=url");
+ }
+ msg('ID从'.$fid.'至'.($catid-1).'更新成功'.progress($sid, $fid, $tid), "?file=$file&mid=$mid&action=$action&sid=$sid&fid=$catid&tid=$tid&num=$num");
+ break;
+ case 'url':
+ foreach($CATEGORY as $c) {
+ update_category($c);
+ }
+ msg('地址更新成功', "?file=$file&mid=$mid&action=letters");
+ break;
+ case 'letters':
+ $update = false;
+ foreach($CATEGORY as $k=>$v) {
+ if(strlen($v['letter']) != 1) {
+ $letter = $do->get_letter($v['catname'], false);
+ if($letter) {
+ $update = true;
+ $letter = substr($letter, 0, 1);
+ $db->query("UPDATE {$table} SET letter='$letter' WHERE catid='$v[catid]'");
+ }
+ }
+ }
+ msg('索引修复成功', "?file=$file&mid=$mid&action=cache");
+ break;
+ case 'cache':
+ $do->repair();
+ dmsg('缓存更新成功', '?file='.$file.'&mid='.$mid);
+ break;
+ case 'delete':
+ if($catid) $catids = $catid;
+ $catids or msg('请选择分类');
+ $do->delete($catids);
+ $NUM > 500 ? $do->cache() : $do->repair();
+ dmsg('删除成功', $forward);
+ break;
+ case 'update':
+ if(!$category || !is_array($category)) msg();
+ $do->update($category);
+ foreach($category as $catid=>$v) {
+ $CATEGORY[$catid] = $db->get_one("SELECT * FROM {$table} WHERE catid=$catid");
+ update_category($CATEGORY[$catid]);
+ }
+ $NUM > 500 ? $do->cache() : $do->repair();
+ dmsg('更新成功', '?file='.$file.'&mid='.$mid.'&parentid='.$parentid);
+ break;
+ case 'letter':
+ isset($catname) or $catname = '';
+ if(!$catname || strpos($catname, "\n") !== false) exit('');
+ exit($do->get_letter($catname, false));
+ break;
+ case 'ckdir':
+ if($do->get_catdir($catdir)) {
+ dialog('目录名可以使用');
+ } else {
+ dialog('目录名不合法或者已经被使用');
+ }
+ break;
+ default:
+ $total = 0;
+ $DTCAT = array();
+ $condition = "moduleid=$mid";
+ $condition .= $keyword ? " AND catname LIKE '%$keyword%'" : " AND parentid=$parentid";
+ $result = $db->query("SELECT * FROM {$table} WHERE $condition ORDER BY listorder,catid");
+ while($r = $db->fetch_array($result)) {
+ $r['childs'] = substr_count($r['arrchildid'], ',');
+ $total += $r['item'];
+ $DTCAT[$r['catid']] = $r;
+ }
+ if(!$DTCAT && !$parentid && !$keyword) msg('暂无分类,请先添加', '?file='.$file.'&mid='.$mid.'&action=add&parentid='.$parentid);
+ include tpl('category');
+ break;
+}
+
+class category {
+ var $moduleid;
+ var $catid;
+ var $category = array();
+ var $table;
+
+ function __construct($moduleid = 1, $catid = 0) {
+ global $CATEGORY;
+ $this->moduleid = $moduleid;
+ $this->catid = $catid;
+ if(!isset($CATEGORY)) $CATEGORY = cache_read('category-'.$this->moduleid.'.php');
+ $this->category = $CATEGORY;
+ $this->table = DT_PRE.'category';
+ }
+
+ function category($moduleid = 1, $catid = 0) {
+ $this->__construct($moduleid, $catid);
+ }
+
+ function add($category) {
+ $category['moduleid'] = $this->moduleid;
+ $category['letter'] = preg_match("/^[a-z]{1}+$/i", $category['letter']) ? strtolower($category['letter']) : '';
+ foreach(array('group_list', 'group_show', 'group_add') as $v) {
+ $category[$v] = isset($category[$v]) ? implode(',', $category[$v]) : '';
+ }
+ $sqlk = $sqlv = '';
+ foreach($category as $k=>$v) {
+ $sqlk .= ','.$k; $sqlv .= ",'$v'";
+ }
+ $sqlk = substr($sqlk, 1);
+ $sqlv = substr($sqlv, 1);
+ DB::query("INSERT INTO {$this->table} ($sqlk) VALUES ($sqlv)");
+ $this->catid = DB::insert_id();
+ if($category['parentid']) {
+ $category['catid'] = $this->catid;
+ $this->category[$this->catid] = $category;
+ $arrparentid = $this->get_arrparentid($this->catid);
+ } else {
+ $arrparentid = 0;
+ }
+ $catdir = $category['catdir'] ? $category['catdir'] : $this->catid;
+ DB::query("UPDATE {$this->table} SET listorder=$this->catid,catdir='$catdir',arrparentid='$arrparentid' WHERE catid=$this->catid");
+ return true;
+ }
+
+ function edit($category) {
+ $category['letter'] = preg_match("/^[a-z]{1}+$/i", $category['letter']) ? strtolower($category['letter']) : '';
+ if($category['parentid']) {
+ $category['catid'] = $this->catid;
+ $this->category[$this->catid] = $category;
+ $category['arrparentid'] = $this->get_arrparentid($this->catid);
+ } else {
+ $category['arrparentid'] = 0;
+ }
+ foreach(array('group_list', 'group_show', 'group_add') as $v) {
+ $category[$v] = isset($category[$v]) ? implode(',', $category[$v]) : '';
+ }
+ $category['linkurl'] = '';
+ $sql = '';
+ foreach($category as $k=>$v) {
+ $sql .= ",$k='$v'";
+ }
+ $sql = substr($sql, 1);
+ DB::query("UPDATE {$this->table} SET $sql WHERE catid=$this->catid");
+ return true;
+ }
+
+ function delete($catids) {
+ if(is_array($catids)) {
+ foreach($catids as $catid) {
+ if(isset($this->category[$catid])) $this->delete($catid);
+ }
+ } else {
+ $catid = $catids;
+ if(isset($this->category[$catid])) {
+ DB::query("DELETE FROM {$this->table} WHERE catid=$catid");
+ $arrchildid = $this->category[$catid]['arrchildid'] ? $this->category[$catid]['arrchildid'] : $catid;
+ DB::query("DELETE FROM {$this->table} WHERE catid IN ($arrchildid)");
+ if($this->moduleid > 4) DB::query("UPDATE ".get_table($this->moduleid)." SET status=0 WHERE catid IN (".$arrchildid.")");
+ }
+ }
+ return true;
+ }
+
+ function update($category) {
+ if(!is_array($category)) return false;
+ foreach($category as $k=>$v) {
+ if(!$v['catname']) continue;
+ $v['parentid'] = intval($v['parentid']);
+ if($k == $v['parentid']) continue;
+ if($v['parentid'] > 0 && !isset($this->category[$v['parentid']])) continue;
+ $v['listorder'] = intval($v['listorder']);
+ $v['level'] = intval($v['level']);
+ $v['letter'] = preg_match("/^[a-z0-9]{1}+$/i", $v['letter']) ? strtolower($v['letter']) : '';
+ $v['catdir'] = $this->get_catdir($v['catdir'], $k);
+ if(!$v['catdir']) $v['catdir'] = $k;
+ DB::query("UPDATE {$this->table} SET catname='$v[catname]',parentid='$v[parentid]',listorder='$v[listorder]',style='$v[style]',level='$v[level]',letter='$v[letter]',catdir='$v[catdir]' WHERE catid=$k ");
+ }
+ return true;
+ }
+
+ function repair() {
+ $query = DB::query("SELECT * FROM {$this->table} WHERE moduleid='$this->moduleid' ORDER BY listorder,catid");
+ $CATEGORY = array();
+ while($r = DB::fetch_array($query)) {
+ $CATEGORY[$r['catid']] = $r;
+ }
+ $childs = array();
+ foreach($CATEGORY as $catid => $category) {
+ $CATEGORY[$catid]['arrparentid'] = $arrparentid = $this->get_arrparentid($catid);
+ $CATEGORY[$catid]['catdir'] = $catdir = preg_match("/^[0-9a-z_\-\/]+$/i", $category['catdir']) ? $category['catdir'] : $catid;
+ $sql = "catdir='$catdir',arrparentid='$arrparentid'";
+ if(!$category['linkurl']) {
+ $CATEGORY[$catid]['linkurl'] = listurl($category);
+ $sql .= ",linkurl='$category[linkurl]'";
+ }
+ DB::query("UPDATE {$this->table} SET $sql WHERE catid=$catid");
+ if($arrparentid) {
+ $arr = explode(',', $arrparentid);
+ foreach($arr as $a) {
+ if($a == 0) continue;
+ isset($childs[$a]) or $childs[$a] = '';
+ $childs[$a] .= ','.$catid;
+ }
+ }
+ }
+ foreach($CATEGORY as $catid => $category) {
+ if(isset($childs[$catid])) {
+ $CATEGORY[$catid]['arrchildid'] = $arrchildid = $catid.$childs[$catid];
+ $CATEGORY[$catid]['child'] = 1;
+ DB::query("UPDATE {$this->table} SET arrchildid='$arrchildid',child=1 WHERE catid='$catid'");
+ } else {
+ $CATEGORY[$catid]['arrchildid'] = $catid;
+ $CATEGORY[$catid]['child'] = 0;
+ DB::query("UPDATE {$this->table} SET arrchildid='$catid',child=0 WHERE catid='$catid'");
+ }
+ }
+ $this->cache($CATEGORY);
+ return true;
+ }
+
+ function get_arrparentid($catid) {
+ $CAT = get_cat($catid);
+ if($CAT['parentid'] && $CAT['parentid'] != $catid) {
+ $parents = array();
+ $cid = $catid;
+ $i = 1;
+ while($i++ < 10) {
+ $CAT = get_cat($cid);
+ if($CAT['parentid']) {
+ $parents[] = $cid = $CAT['parentid'];
+ } else {
+ break;
+ }
+ }
+ $parents[] = 0;
+ return implode(',', array_reverse($parents));
+ } else {
+ return '0';
+ }
+ }
+
+ function get_catdir($catdir, $catid = 0) {
+ if(preg_match("/^[0-9a-z_\-\/]+$/i", $catdir)) {
+ $condition = "catdir='$catdir' AND moduleid='$this->moduleid'";
+ if($catid) $condition .= " AND catid!=$catid";
+ $r = DB::get_one("SELECT catid FROM {$this->table} WHERE $condition");
+ if($r) {
+ return '';
+ } else {
+ return $catdir;
+ }
+ } else {
+ return '';
+ }
+ }
+
+ function get_letter($catname, $letter = true) {
+ return $letter ? strtolower(substr(gb2py($catname), 0, 1)) : str_replace(' ', '', gb2py($catname));
+ }
+
+ function cache($data = array()) {
+ cache_category($this->moduleid, $data);
+ }
+}
+?>
\ No newline at end of file
diff --git a/admin/city.inc.php b/admin/city.inc.php
new file mode 100644
index 0000000..1055361
--- /dev/null
+++ b/admin/city.inc.php
@@ -0,0 +1,136 @@
+edit($post);
+ dmsg('更新成功', $forward);
+ } else {
+ if($areaid) {
+ extract($do->get_one());
+ } else {
+ $areaid = $listorder = 0;
+ $name = $style = $letter = $domain = $iparea = $template = $seo_title = $seo_keywords = $seo_description = '';
+ }
+ include tpl('city_edit');
+ }
+ break;
+ case 'letter':
+ $result = $db->query("SELECT * FROM {$DT_PRE}city WHERE letter=''");
+ while($r = $db->fetch_array($result)) {
+ $letter = $do->letter($r['name']);
+ $db->query("UPDATE {$DT_PRE}city SET letter='$letter' WHERE areaid=$r[areaid]");
+ }
+ dmsg('更新成功', $forward);
+ break;
+ case 'delete':
+ if($areaid) $areaids = $areaid;
+ $areaids or msg();
+ $do->delete($areaids);
+ dmsg('删除成功', '?file='.$file);
+ break;
+ case 'update':
+ foreach($post as $v) {
+ $do->update($v);
+ }
+ dmsg('更新成功', '?file='.$file);
+ break;
+ default:
+ $condition = '1';
+ if($kw) $condition .= " AND (name LIKE '%$keyword%' OR domain LIKE '%$keyword%')";
+ $lists = $do->get_list($condition);
+ include tpl('city');
+ break;
+}
+
+class city {
+ var $areaid;
+ var $table;
+
+ function __construct($areaid = 0) {
+ $this->table = DT_PRE.'city';
+ $this->areaid = $areaid;
+ }
+
+ function city($areaid = 0) {
+ $this->__construct($areaid);
+ }
+
+ function edit($post) {
+ if(!is_array($post)) return false;
+ $post['letter'] or $post['letter'] = $this->letter($post['name']);
+ $sql1 = $sql2 = $s = '';
+ foreach($post as $k=>$v) {
+ $sql1 .= $s.$k;
+ $sql2 .= $s."'".$v."'";
+ $s = ',';
+ }
+ DB::query("REPLACE INTO {$this->table} ($sql1) VALUES ($sql2)");
+ return true;
+ }
+
+ function update($post) {
+ if(!is_array($post)) return false;
+ $areaid = $post['areaid'];
+ if(!$areaid) return false;
+ $post['letter'] or $post['letter'] = $this->letter($post['name']);
+ $post['name'] = trim($post['name']);
+ $post['domain'] = fix_domain($post['domain']);
+ $sql = '';
+ foreach($post as $k=>$v) {
+ $sql .= ",$k='$v'";
+ }
+ $sql = substr($sql, 1);
+ DB::query("UPDATE {$this->table} SET $sql WHERE areaid=$areaid");
+ return true;
+ }
+
+ function get_one() {
+ return DB::get_one("SELECT * FROM {$this->table} WHERE areaid=$this->areaid");
+ }
+
+ function get_list($condition) {
+ global $pages, $page, $pagesize, $offset, $pagesize, $sum;
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = DB::get_one("SELECT COUNT(*) AS num FROM {$this->table} WHERE $condition");
+ $items = $r['num'];
+ }
+ $pages = pages($items, $page, $pagesize);
+ $lists = array();
+ $result = DB::query("SELECT * FROM {$this->table} WHERE $condition ORDER BY letter,listorder LIMIT $offset,$pagesize");
+ while($r = DB::fetch_array($result)) {
+ $r['linkurl'] = DT_PATH.'api/city.php?action=go&forward=&areaid='.$r['areaid'];
+ $lists[] = $r;
+ }
+ return $lists;
+ }
+
+ function delete($areaids) {
+ $areaids = is_array($areaids) ? implode(',', $areaids) : $areaids;
+ DB::query("DELETE FROM {$this->table} WHERE areaid IN ($areaids)");
+ return true;
+ }
+
+ function letter($name) {
+ return strtolower(substr(gb2py($name), 0, 1));
+ }
+}
+?>
\ No newline at end of file
diff --git a/admin/cloud.inc.php b/admin/cloud.inc.php
new file mode 100644
index 0000000..a813549
--- /dev/null
+++ b/admin/cloud.inc.php
@@ -0,0 +1,10 @@
+
\ No newline at end of file
diff --git a/admin/config.inc.php b/admin/config.inc.php
new file mode 100644
index 0000000..aaec0a0
--- /dev/null
+++ b/admin/config.inc.php
@@ -0,0 +1,32 @@
+
\ No newline at end of file
diff --git a/admin/count.inc.php b/admin/count.inc.php
new file mode 100644
index 0000000..2dbc95f
--- /dev/null
+++ b/admin/count.inc.php
@@ -0,0 +1,329 @@
+halt = 0;
+ $today = datetotime(timetodate($DT_TIME, 3).' 00:00:00');
+
+ $num = $db->count($DT_PRE.'finance_charge', "status=0");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("charge").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'finance_cash', "status=0");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("cash").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'keyword', "status=2");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("keyword").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'guestbook', "edittime=0");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("guestbook").innerHTML="'.$num.'";}catch(e){}';
+
+ $num = $db->count($DT_PRE.'member_check', "1");//待审核资料修改
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("edit_check").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'ask', "status=0");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("ask").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'alert', "status=2");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("alert").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'gift_order', "status='处理中'");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("gift").innerHTML="'.$num.'";}catch(e){}';
+
+ $num = $db->count($DT_PRE.'news', "status=2");//待审核公司新闻
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("news").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'honor', "status=2");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("honor").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'page', "status=2");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("page").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'link', "status=2 AND username<>''");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("comlink").innerHTML="'.$num.'";}catch(e){}';
+
+ foreach(array('company', 'truename', 'mobile', 'close') as $v) {
+ $num = $db->count($DT_PRE.'validate', "type='$v' AND status=2");//待审核认证
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("v'.$v.'").innerHTML="'.$num.'";}catch(e){}';
+ }
+
+ $num = $db->count($DT_PRE.'ad', "status=2");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("ad").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'spread', "status=2");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("spread").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'comment', "status=2");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("comment").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'link', "status=2 AND username=''");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("link").innerHTML="'.$num.'";}catch(e){}';
+
+ $num = $db->count($DT_PRE.'member');//会员
+ echo 'try{document.getElementById("member").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'member_upgrade', "status=2");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("member_upgrade").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'member', "groupid=4");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("member_check").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($DT_PRE.'member', "regtime>$today");
+ echo 'try{document.getElementById("member_new").innerHTML="'.$num.'";}catch(e){}';
+
+ foreach($MODULE as $m) {
+ if($m['moduleid'] < 5 || $m['islink']) continue;
+ $mid = $m['moduleid'];
+ $table = get_table($mid);
+ $num = $db->count($table, '1');
+ echo 'try{Dd("m_'.$mid.'").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($table, "status=3");
+ echo 'try{Dd("m_'.$mid.'_1").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($table, "status=2");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{Dd("m_'.$mid.'_2").innerHTML="'.$num.'";}catch(e){}';
+ $num = $db->count($table, "addtime>$today");
+ echo 'try{Dd("m_'.$mid.'_3").innerHTML="'.$num.'";}catch(e){}';
+
+ if($m['module'] == 'mall' || $m['module'] == 'sell') {
+ $num = $db->count($DT_PRE.'order', "mid=$mid");
+ echo 'try{document.getElementById("order_'.$mid.'").innerHTML="'.$num.'";}catch(e){}';
+
+ $num = $db->count($DT_PRE.'order', "mid=$mid AND status=5");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("order_'.$mid.'_5").innerHTML="'.$num.'";}catch(e){}';
+
+ $num = $db->count($DT_PRE.'order', "mid=$mid AND status=4");
+ echo 'try{document.getElementById("order_'.$mid.'_4").innerHTML="'.$num.'";}catch(e){}';
+ }
+
+ if($m['module'] == 'group') {
+ $num = $db->count($DT_PRE.'group_order_'.$mid, "1");
+ echo 'try{document.getElementById("order_'.$mid.'").innerHTML="'.$num.'";}catch(e){}';
+
+ $num = $db->count($DT_PRE.'group_order_'.$mid, "status=4");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("order_'.$mid.'_4").innerHTML="'.$num.'";}catch(e){}';
+
+ $num = $db->count($DT_PRE.'group_order_'.$mid, "status=3");
+ echo 'try{document.getElementById("order_'.$mid.'_3").innerHTML="'.$num.'";}catch(e){}';
+ }
+
+ if($m['module'] == 'quote') {
+ $num = $db->count($DT_PRE.'quote_product_'.$mid, "1");
+ echo 'try{document.getElementById("product_'.$mid.'").innerHTML="'.$num.'";}catch(e){}';
+
+ $num = $db->count($DT_PRE.'quote_price_'.$mid, "1");
+ echo 'try{document.getElementById("price_'.$mid.'").innerHTML="'.$num.'";}catch(e){}';
+
+ $num = $db->count($DT_PRE.'quote_price_'.$mid, "status=2");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("price_'.$mid.'_2").innerHTML="'.$num.'";}catch(e){}';
+ }
+
+ if($m['module'] == 'exhibit') {
+ $num = $db->count($DT_PRE.'exhibit_sign_'.$mid, "1");
+ echo 'try{document.getElementById("sign_'.$mid.'").innerHTML="'.$num.'";}catch(e){}';
+
+ $num = $db->count($DT_PRE.'exhibit_sign_'.$mid, "addtime>$today");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("sign_'.$mid.'_3").innerHTML="'.$num.'";}catch(e){}';
+ }
+
+ if($m['module'] == 'know') {
+ $num = $db->count($DT_PRE.'know_expert_'.$mid, "1");
+ echo 'try{document.getElementById("expert_'.$mid.'").innerHTML="'.$num.'";}catch(e){}';
+
+ $num = $db->count($DT_PRE.'know_answer_'.$mid, "1");
+ echo 'try{document.getElementById("answer_'.$mid.'").innerHTML="'.$num.'";}catch(e){}';
+
+ $num = $db->count($DT_PRE.'know_answer_'.$mid, "status=2");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("answer_'.$mid.'_2").innerHTML="'.$num.'";}catch(e){}';
+ }
+
+ if($m['module'] == 'job') {
+ $table = $DT_PRE.'job_resume_'.$mid;
+ //ALL
+ $num = $db->count($table, '1');
+ echo 'try{Dd("m_'.$mid.'_resume").innerHTML="'.$num.'";}catch(e){}';
+ //PUB
+ $num = $db->count($table, "status=3");
+ echo 'try{Dd("m_'.$mid.'_resume_1").innerHTML="'.$num.'";}catch(e){}';
+ //CHECK
+ $num = $db->count($table, "status=2");
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{Dd("m_'.$mid.'_resume_2").innerHTML="'.$num.'";}catch(e){}';
+ //NEW
+ $num = $db->count($table, "addtime>$today", 30);
+ echo 'try{Dd("m_'.$mid.'_resume_3").innerHTML="'.$num.'";}catch(e){}';
+ }
+
+ if($m['module'] == 'club') {
+ $num = $db->count($DT_PRE.'club_group_'.$mid, "status=2");//商圈
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("club_group_'.$mid.'").innerHTML="'.$num.'";}catch(e){}';
+
+ $num = $db->count($DT_PRE.'club_reply_'.$mid, "status=2");//商圈回复
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("club_reply_'.$mid.'").innerHTML="'.$num.'";}catch(e){}';
+
+ $num = $db->count($DT_PRE.'club_fans_'.$mid, "status=2");//商圈粉丝
+ $num = $num ? ''.$num.' ' : 0;
+ echo 'try{document.getElementById("club_fans_'.$mid.'").innerHTML="'.$num.'";}catch(e){}';
+ }
+ }
+ break;
+ case 'todo':
+ $db->halt = 0;
+ $today = datetotime(timetodate($DT_TIME, 3).' 00:00:00');
+ $htm = '';
+ $num = $db->count($DT_PRE.'finance_charge', "status=0");
+ if($num) $htm .= '
待受理在线充值 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'finance_cash', "status=0");
+ if($num) $htm .= '待受理资金提现 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'keyword', "status=2");
+ if($num) $htm .= '待审核搜索关键词 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'guestbook', "edittime=0");
+ if($num) $htm .= '待回复网站留言 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'member_check', "1");
+ if($num) $htm .= '待审核资料修改 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'ask', "status=0");
+ if($num) $htm .= '待受理客服中心 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'alert', "status=2");
+ if($num) $htm .= '待审核贸易提醒 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'gift_order', "status='处理中'");
+ if($num) $htm .= '待处理礼品订单 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'news', "status=2");//待审核公司新闻
+ if($num) $htm .= '待审核公司新闻 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'honor', "status=2");
+ if($num) $htm .= '待审核荣誉资质 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'page', "status=2");
+ if($num) $htm .= '待审核公司单页 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'link', "status=2 AND username<>''");
+ if($num) $htm .= '待审核公司链接 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'validate', "type='company' AND status=2");
+ if($num) $htm .= '待审核公司认证 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'validate', "type='truename' AND status=2");
+ if($num) $htm .= '待核审实名认证 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'validate', "type='mobile' AND status=2");
+ if($num) $htm .= '待审核手机认证 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'validate', "type='email' AND status=2");
+ if($num) $htm .= '待审核邮件认证 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'validate', "type='close' AND status=2");
+ if($num) $htm .= '待审核注销申请 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'ad', "status=2");
+ if($num) $htm .= '待审广告购买 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'spread', "status=2");
+ if($num) $htm .= '待审核排名推广 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'comment', "status=2");
+ if($num) $htm .= '待审核评论 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'link', "status=2 AND username=''");
+ if($num) $htm .= '待审核友情链接 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'member_upgrade', "status=2");
+ if($num) $htm .= '待审核会员升级 ('.$num.' ) ';
+ $num = $db->count($DT_PRE.'member', "groupid=4");
+ if($num) $htm .= '待审核会员注册 ('.$num.' ) ';
+ foreach($MODULE as $m) {
+ if($m['moduleid'] < 5 || $m['islink']) continue;
+ $mid = $m['moduleid'];
+ $table = get_table($mid);
+ $num = $db->count($table, "status=2");
+ if($num) $htm .= '待审核'.$m['name'].' ('.$num.' ) ';
+
+ if($m['module'] == 'mall' || $m['module'] == 'sell') {
+ $num = $db->count($DT_PRE.'order', "mid=$mid AND status=5");
+ if($num) $htm .= '待受理'.$m['name'].'订单 ('.$num.' ) ';
+ }
+ if($m['module'] == 'group') {
+ $num = $db->count($DT_PRE.'group_order_'.$mid, "status=4");
+ if($num) $htm .= '待受理'.$m['name'].'订单 ('.$num.' ) ';
+ }
+ if($m['module'] == 'quote') {
+ $num = $db->count($DT_PRE.'quote_price_'.$mid, "status=2");
+ if($num) $htm .= '待审核'.$m['name'].'报价 ('.$num.' ) ';
+ }
+ if($m['module'] == 'exhibit') {
+ $num = $db->count($DT_PRE.'exhibit_sign_'.$mid, "addtime>$today");
+ if($num) $htm .= ''.$m['name'].'今日报名 ('.$num.' ) ';
+ }
+ if($m['module'] == 'know') {
+ $num = $db->count($DT_PRE.'know_answer_'.$mid, "status=2");
+ if($num) $htm .= '待审核'.$m['name'].'回答 ('.$num.' ) ';
+ }
+ if($m['module'] == 'job') {
+ $num = $db->count($DT_PRE.'job_resume_'.$mid, "status=2");
+ if($num) $htm .= '待审核'.$m['name'].'简历 ('.$num.' ) ';
+ }
+ if($m['module'] == 'club') {
+ $num = $db->count($DT_PRE.'club_group_'.$mid, "status=2");//商圈
+ if($num) $htm .= '待审核'.$m['name'].'申请 ('.$num.' ) ';
+
+ $num = $db->count($DT_PRE.'club_reply_'.$mid, "status=2");//商圈回复
+ if($num) $htm .= '待审核'.$m['name'].'回复 ('.$num.' ) ';
+
+ $num = $db->count($DT_PRE.'club_fans_'.$mid, "status=2");//商圈粉丝
+ if($num) $htm .= '待审核'.$m['name'].'粉丝 ('.$num.' ) ';
+ }
+ }
+ @header("Content-type:text/javascript");
+ if($htm) {
+ $htm = '';
+ echo 'try{document.getElementById("todo").innerHTML=\''.$htm.'\';document.getElementById("todo").style.display=\'table\';}catch(e){}';
+ }
+ break;
+ case 'repeat':
+ $mid or $mid = 21;
+ $key = isset($key) ? trim($key) : 'title';
+ $num = isset($num) ? intval($num) : 100;
+ $status = isset($status) ? intval($status) : 3;
+ $lists = array();
+ if(isset($ok)) {
+ $submit = 1;
+ $act = '';
+ if($status == 4) $act = 'expire';
+ if($status == 2) $act = 'check';
+ if($status == 1) $act = 'reject';
+ if($status == 0) $act = 'recycle';
+ $condition = "status=$status";
+ if($keyword) $condition .= match_kw($key, $keyword);
+ $result = $db->query("SELECT COUNT(`$key`) AS num,`$key` FROM ".get_table($mid)." WHERE $condition GROUP BY `$key` ORDER BY num DESC LIMIT 0,$num");
+ while($r = $db->fetch_array($result)) {
+ if($r['num'] < 2) continue;
+ $r['kw'] = urlencode($r[$key]);
+ $lists[] = $r;
+ }
+ }
+ include tpl('count_repeat');
+ break;
+ case 'stats':
+ $year = isset($year) ? intval($year) : date('Y', $DT_TIME);
+ $year or $year = date('Y', $DT_TIME);
+ $month = isset($month) ? intval($month) : 0;
+ if($mid == 1 || $mid == 3) $mid = 0;
+ if($mid == 4) $mid = 2;
+ include tpl('count_stats');
+ break;
+ default:
+ $year = isset($year) ? intval($year) : date('Y', $DT_TIME);
+ $year or $year = date('Y', $DT_TIME);
+ $month = isset($month) ? intval($month) : 0;
+ if($mid == 1 || $mid == 3) $mid = 0;
+ if($mid == 4) $mid = 2;
+ include tpl('count');
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/cron.inc.php b/admin/cron.inc.php
new file mode 100644
index 0000000..de06d85
--- /dev/null
+++ b/admin/cron.inc.php
@@ -0,0 +1,213 @@
+pass($post)) {
+ $do->add($post);
+ dmsg('添加成功', $forward);
+ } else {
+ msg($do->errmsg);
+ }
+ } else {
+ $type = $title = $name = $run = $hour = $mint = $status = $note = $n1 = $n2 = $n3 = $v1 = $v2 = $v3 = '';
+ $minute = 30;
+ include tpl('cron_edit');
+ }
+ break;
+ case 'edit':
+ $itemid or msg();
+ $do->itemid = $itemid;
+ $r = $do->get_one();
+ $r or msg('任务不存在');
+ if($r['type']) msg('内置任务不可修改');
+ if($submit) {
+ if($do->pass($post)) {
+ $do->edit($post);
+ dmsg('修改成功', $forward);
+ } else {
+ msg($do->errmsg);
+ }
+ } else {
+ extract($r);
+ $minute = 0;
+ $run = 1;
+ if(strpos($schedule, ',') !== false) {
+ list($hour, $mint) = explode(',', $schedule);
+ } else {
+ $minute = $schedule;
+ $run = 0;
+ }
+ include tpl('cron_edit');
+ }
+ break;
+ case 'delete':
+ $itemid or msg();
+ $do->itemid = $itemid;
+ $r = $do->get_one();
+ $r or msg('任务不存在');
+ if($r['type'] || $itemid < 100) msg('内置任务不可删除');
+ $do->delete();
+ dmsg('删除成功', $forward);
+ break;
+ case 'run':
+ $itemid or msg();
+ $do->itemid = $itemid;
+ $cron = $do->get_one();
+ $cron or msg('任务不存在');
+ $v1 = $cron['v1'];
+ $v2 = $cron['v2'];
+ $v3 = $cron['v3'];
+ include DT_ROOT.'/api/cron/'.$cron['name'].'.inc.php';
+ $nexttime = $do->nexttime($cron['schedule'], $DT_TIME);
+ $db->query("UPDATE {$DT_PRE}cron SET lasttime=$DT_TIME,nexttime=$nexttime WHERE itemid=$itemid");
+ dmsg('运行成功', $forward);
+ break;
+ default:
+ $sfields = array('按条件', '名称', '文件名', '时间表', '备注');
+ $dfields = array('title', 'title', 'name', 'schedule', 'note');
+ isset($fields) && isset($dfields[$fields]) or $fields = 0;
+ $sorder = array('结果排序方式', '上次运行降序', '上次运行升序', '下次运行降序', '下次运行升序', '任务文件降序', '任务文件升序');
+ $dorder = array('itemid DESC', 'lasttime DESC', 'lasttime ASC', 'nexttime DESC', 'nexttime ASC', 'name DESC', 'name ASC');
+ isset($order) && isset($dorder[$order]) or $order = 0;
+
+ $fields_select = dselect($sfields, 'fields', '', $fields);
+ $order_select = dselect($sorder, 'order', '', $order);
+
+ $condition = '1';
+ if($keyword) $condition .= match_kw($dfields[$fields], $keyword);
+ $lists = $do->get_list($condition, $dorder[$order]);
+ include tpl('cron');
+ break;
+}
+
+class cron {
+ var $itemid;
+ var $table;
+ var $errmsg = errmsg;
+
+ function __construct() {
+ $this->table = DT_PRE.'cron';
+ }
+
+ function cron() {
+ $this->__construct();
+ }
+
+ function pass($post) {
+ if(!is_array($post)) return false;
+ if(!$post['title']) return $this->_('请填写任务名称');
+ if(!check_name($post['name']) || !is_file(DT_ROOT.'/api/cron/'.$post['name'].'.inc.php')) return $this->_('请选择脚本文件');
+ if($post['run']) {
+ $hour = intval($post['hour']);
+ if($hour < 0 || $hour > 23) return $this->_('小时必须为0-23');
+ $mint = intval($post['mint']);
+ if($mint < 0 || $hour > 59) return $this->_('分钟必须为0-59');
+ } else {
+ $minute = intval($post['minute']);
+ if($minute < 1) return $this->_('间隔时间至少为1分钟');
+ }
+ return true;
+ }
+
+ function set($post) {
+ if($post['run']) {
+ $post['schedule'] = intval($post['hour']).','.intval($post['mint']);
+ } else {
+ $post['schedule'] = intval($post['minute']);
+ }
+ unset($post['run'], $post['hour'],$post['mint'], $post['minute']);
+ $post['status'] = $post['status'] ? 1 : 0;
+ return $post;
+ }
+
+ function get_one() {
+ return DB::get_one("SELECT * FROM {$this->table} WHERE itemid='$this->itemid'");
+ }
+
+ function get_list($condition = '', $order = 'itemid ASC') {
+ global $MOD, $pages, $page, $pagesize, $offset, $sum;
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = DB::get_one("SELECT COUNT(*) AS num FROM {$this->table} WHERE $condition");
+ $items = $r['num'];
+ }
+ $pages = pages($items, $page, $pagesize);
+ $lists = array();
+ $result = DB::query("SELECT * FROM {$this->table} WHERE $condition ORDER BY $order LIMIT $offset,$pagesize");
+ while($r = DB::fetch_array($result)) {
+ $r['lasttime'] = $r['lasttime'] ? timetodate($r['lasttime'], 6) : 'N/A';
+ $r['nexttime'] = $r['nexttime'] ? timetodate($r['nexttime'], 6) : 'N/A';
+ $r['text'] = $this->time2text($r['schedule']);
+ $lists[] = $r;
+ }
+ return $lists;
+ }
+
+ function add($post) {
+ $post = $this->set($post);
+ $sqlk = $sqlv = '';
+ foreach($post as $k=>$v) {
+ $sqlk .= ','.$k; $sqlv .= ",'$v'";
+ }
+ $sqlk = substr($sqlk, 1);
+ $sqlv = substr($sqlv, 1);
+ DB::query("INSERT INTO {$this->table} ($sqlk) VALUES ($sqlv)");
+ return $this->itemid;
+ }
+
+ function edit($post) {
+ $post = $this->set($post);
+ $sql = '';
+ foreach($post as $k=>$v) {
+ $sql .= ",$k='$v'";
+ }
+ $sql = substr($sql, 1);
+ DB::query("UPDATE {$this->table} SET $sql WHERE itemid=$this->itemid");
+ return true;
+ }
+
+ function delete() {
+ DB::query("DELETE FROM {$this->table} WHERE itemid=$this->itemid");
+ }
+
+ function nexttime($schedule, $time) {
+ if(strpos($schedule, ',') !== false) {
+ list($h, $m) = explode(',', $schedule);
+ $t = datetotime(timetodate($time, 3).' '.($h < 10 ? '0'.$h : $h).':'.($m < 10 ? '0'.$m : $m).':00');
+ return $t > $time ? $t : $t + 86400;
+ } else {
+ $m = intval($schedule);
+ return $time + ($m ? $m : 1800)*60;
+ }
+ }
+
+ function time2text($schedule) {
+ if(strpos($schedule, ',') !== false) {
+ list($h, $m) = explode(',', $schedule);
+ if($h < 10) $h = '0'.$h;
+ if($m < 10) $m = '0'.$m;
+ return '每天'.$h.':'.$m;
+ } else {
+ $m = intval($schedule);
+ return '每'.$m.'分钟';
+ }
+ list($hour, $minute) = explode(',', $schedule);
+ }
+
+ function _($e) {
+ $this->errmsg = $e;
+ return false;
+ }
+}
+?>
\ No newline at end of file
diff --git a/admin/data.inc.php b/admin/data.inc.php
new file mode 100644
index 0000000..ff46d4d
--- /dev/null
+++ b/admin/data.inc.php
@@ -0,0 +1,420 @@
+ 0 && $tmid > 0 && $fmid != $tmid) or msg('来源模块或目标模块设置错误');
+ $catid or msg('请选择新分类');
+ $condition = trim($condition);
+ if(strtolower(substr($condition, 0, 3)) != 'and') $condition = "AND itemid IN ($condition)";
+ $post = array();
+ $post['fmid'] = $fmid;
+ $post['tmid'] = $tmid;
+ $post['condition'] = $condition;
+ $post['catid'] = $catid;
+ $post['delete'] = $delete;
+ $post = dstripslashes($post);
+ cache_write('table-move-'.$_userid.'.php', $post);
+ msg('正在开始转移', '?file='.$file.'&action=move_table');
+ } else {
+ include tpl('data_move');
+ }
+ break;
+ case 'move_table':
+ $post = cache_read('table-move-'.$_userid.'.php');
+ $post or msg('数据配置不存在', '?file='.$file.'&action=move');
+ $fmid = $post['fmid'];
+ $tmid = $post['tmid'];
+ $ftb = get_table($fmid);
+ $ftb_data = get_table($fmid, 1);
+ $ttb = get_table($tmid);
+ $ttb_data = get_table($tmid, 1);
+ $table = $ftb;
+ $id = 'itemid';
+ $condition = $post['condition'];
+ $catid = $post['catid'];
+ $delete = $post['delete'];
+ isset($num) or $num = 1000;
+ if(!isset($fid)) {
+ $r = $db->get_one("SELECT min({$id}) AS fid FROM {$table}");
+ $fid = $r['fid'] ? $r['fid'] : 0;
+ }
+ if(!isset($tid)) {
+ $r = $db->get_one("SELECT max({$id}) AS tid FROM {$table}");
+ $tid = $r['tid'] ? $r['tid'] : 0;
+ }
+ isset($$id) or $$id = 1;
+ $fs = array();
+ $result = $db->query("SHOW COLUMNS FROM `$ttb`");
+ while($r = $db->fetch_array($result)) {
+ $fs[] = $r['Field'];
+ }
+ if($fid <= $tid) {
+ $result = $db->query("SELECT * FROM {$table} WHERE `{$id}`>=$fid {$condition} ORDER BY `{$id}` LIMIT 0,$num");
+ if($db->affected_rows($result)) {
+ while($r = $db->fetch_array($result)) {
+ $$id = $fitemid = $r[$id];
+ unset($r[$id]);
+ $r['catid'] = $catid;
+ $r = daddslashes($r);
+ if(is_file(DT_CACHE.'/'.$fmid.'.part')) $ftb_data = split_table($fmid, $fitemid);
+ $t = $db->get_one("SELECT content FROM {$ftb_data} WHERE itemid=$fitemid");
+ $content = daddslashes($t['content']);
+ $sqlk = $sqlv = '';
+ foreach($r as $k=>$v) {
+ if($fs && !in_array($k, $fs)) continue;
+ $sqlk .= ','.$k; $sqlv .= ",'$v'";
+ }
+ $sqlk = substr($sqlk, 1);
+ $sqlv = substr($sqlv, 1);
+ $db->query("INSERT INTO {$ttb} ($sqlk) VALUES ($sqlv)");
+ $titemid = $db->insert_id();
+ if(is_file(DT_CACHE.'/'.$tmid.'.part')) $ttb_data = split_table($tmid, $titemid);
+ $db->query("INSERT INTO {$ttb_data} (itemid,content) VALUES ('$titemid','$content')");
+ $linkurl = str_replace($fitemid, $titemid, $r['linkurl']);
+ $db->query("UPDATE {$ttb} SET linkurl='$linkurl' WHERE itemid=$titemid");
+ if($delete) {
+ $db->query("UPDATE {$ftb} SET status=0 WHERE itemid=$fitemid");
+ $html = DT_ROOT.'/'.$MODULE[$fmid]['moduledir'].'/'.$r['linkurl'];
+ if(is_file($html)) @unlink($html);
+ }
+ }
+ $$id += 1;
+ } else {
+ $$id = $fid + $num;
+ }
+ } else {
+ cache_delete('table-move-'.$_userid.'.php');
+ msg('转移成功', '?file='.$file.'&action=move');
+ }
+ msg('ID '.$fid.'~'.($$id-1).'转移成功', '?file='.$file.'&action='.$action.'&fid='.$$id.'&tid='.$tid.'&num='.$num);
+ break;
+ case 'save':
+ $table or msg('请选择导入目标表');
+ $name or msg('数据文件不存在');
+ $xlsfile = DT_ROOT.'/file/temp/'.$name.'.xls';
+ is_file($xlsfile) or msg('数据文件不存在');
+ function table_get_fields($table) {
+ $arr = array();
+ $result = DB::query("SHOW COLUMNS FROM `{$table}`");
+ while($r = DB::fetch_array($result)) {
+ $arr[] = $r['Field'];
+ }
+ return $arr;
+ }
+ function table_get_query($fields, $arr) {
+ $sqlk = $sqlv = '';
+ foreach($arr as $k=>$v) {
+ if(!in_array($k, $fields)) continue;
+ $sqlk .= ',`'.$k.'`'; $sqlv .= ",'$v'";
+ }
+ if($sqlk) $sqlk = substr($sqlk, 1);
+ if($sqlv) $sqlv = substr($sqlv, 1);
+ return array($sqlk, $sqlv);
+ }
+ function data_get_name($fields, $lists) {
+ $arr = array();
+ foreach($fields as $k=>$v) {
+ if(isset($lists[$k])) {
+ if(strpos($v, 'time') === false) {
+ $arr[$v] = convert($lists[$k], 'GBK', 'UTF-8');
+ } else {
+ $arr[$v] = is_numeric($lists[$k]) ? $lists[$k] : datetotime($lists[$k]);
+ }
+ }
+ }
+ return $arr;
+ }
+ $type = 'table';
+ $tb = cutstr($table, DT_PRE);
+ $table_data = '';
+ if($tb == 'member') {
+ $type = 'member';
+ $split = is_file(DT_CACHE.'/4.part') ? 1 : 0;
+ $table_member_misc = DT_PRE.'member_misc';
+ $fields_member_misc = table_get_fields($table_member_misc);
+ $table_company = DT_PRE.'company';
+ $fields_company = table_get_fields($table_company);
+ $table_data = DT_PRE.'company_data';
+ $fields_data = table_get_fields($table_data);
+ } else if(substr_count($tb, '_') == 1) {
+ list($mod, $mid) = explode('_', $tb);
+ if(is_numeric($mid) && isset($MODULE[$mid]) && $MODULE[$mid]['module'] == $mod) {
+ $type = 'module';
+ $split = is_file(DT_CACHE.'/'.$mid.'.part') ? 1 : 0;
+ $table_data = get_table($mid, 1);
+ $fields_data = table_get_fields($table_data);
+ }
+ }
+ if($type == 'table') {
+ if($tb == 'news' || $tb == 'page') $table_data = $table.'_data';
+ if(strpos($tb, 'resume_') !== false && strpos($tb, 'resume_data_') === false) $table_data = str_replace('resume_', 'resume_data_', $table);
+ if($table_data) $fields_data = table_get_fields($table_data);
+ }
+ require DT_ROOT.'/api/excel/loader.inc.php';
+ $xls = new ExcelParser(DT_ROOT.'/file/temp/'.$name.'.xls');
+ $arr = $xls->main();
+ isset($arr[1][0]) or msg('未读取到有效数据');
+ $lists = $arr[1][0];
+ $names = $lists[1];
+ $j = 0;
+ $fields = table_get_fields($table);
+ for($i = 2; $i < count($lists); $i++) {
+ if(isset($lists[$i]) && $lists[$i]) {
+ $data = data_get_name($names, $lists[$i]);
+ list($sqlk, $sqlv) = table_get_query($fields, $data);
+ if($sqlk && $sqlv) {
+ $db->query("INSERT INTO {$table} ($sqlk) VALUES ($sqlv)");
+ $id = $db->insert_id();
+ if($id) {
+ $j++;
+ if($type == 'table') {
+ if($table_data) {
+ $data['itemid'] = $id;
+ list($sqlk, $sqlv) = table_get_query($fields_data, $data);
+ if($sqlk && $sqlv) $db->query("INSERT INTO {$table_data} ($sqlk) VALUES ($sqlv)");
+ }
+ } else if($type == 'member') {
+ $data['userid'] = $id;
+
+ list($sqlk, $sqlv) = table_get_query($fields_member_misc, $data);
+ if($sqlk && $sqlv) $db->query("INSERT INTO {$table_member_misc} ($sqlk) VALUES ($sqlv)");
+
+ list($sqlk, $sqlv) = table_get_query($fields_company, $data);
+ if($sqlk && $sqlv) $db->query("INSERT INTO {$table_company} ($sqlk) VALUES ($sqlv)");
+
+ list($sqlk, $sqlv) = table_get_query($fields_data, $data);
+ if($sqlk && $sqlv) {
+ $tb_data = content_table(4, $id, $split, $table_data);
+ $db->query("INSERT INTO {$tb_data} ($sqlk) VALUES ($sqlv)");
+ }
+ } else if($type == 'module') {
+ $data['itemid'] = $id;
+ list($sqlk, $sqlv) = table_get_query($fields_data, $data);
+ if($sqlk && $sqlv) {
+ $tb_data = content_table($mid, $id, $split, $table_data);
+ $db->query("INSERT INTO {$tb_data} ($sqlk) VALUES ($sqlv)");
+ }
+ }
+ }
+ }
+ }
+ }
+ file_del($xlsfile);
+ msg('成功导入'.$j.'条数据', '?file='.$file.'&action=import');
+ break;
+ case 'upload':
+ $table or msg('请选择导入目标表');
+ $_FILES['uploadfile']['size'] or msg('请上传xls数据文件');
+ require DT_ROOT.'/include/upload.class.php';
+ $name = date('YmdHis').mt_rand(10, 99).$_userid;
+ $upload = new upload($_FILES, 'file/temp/', $name.'.xls', 'xls');
+ $upload->adduserid = false;
+ if($upload->save()) {
+ require DT_ROOT.'/api/excel/loader.inc.php';
+ $xls = new ExcelParser(DT_ROOT.'/file/temp/'.$name.'.xls');
+ $arr = $xls->main();
+ isset($arr[1][0]) or msg('未读取到有效数据');
+ $lists = $arr[1][0];
+ $T = $D = array();
+ $T = $lists[0];
+ for($i = 1; $i < 12; $i++) {
+ if(isset($lists[$i]) && $lists[$i]) $D[] = $lists[$i];
+ }
+ $t1 = count($lists) - 2;
+ $t2 = count($D) - 1;
+ include tpl('data_view');
+ } else {
+ msg($upload->errmsg);
+ }
+ break;
+ case 'import':
+ $tables = array();
+ $i = 0;
+ $result = $db->query("SHOW TABLE STATUS FROM `".$CFG['db_name']."`");
+ while($r = $db->fetch_array($result)) {
+ if(preg_match('/^'.$DT_PRE.'/', $r['Name'])) {
+ $tables[$i]['name'] = $r['Name'];
+ $tables[$i]['note'] = $r['Comment'];
+ $i++;
+ }
+ }
+ include tpl('data_import');
+ break;
+ case 'fields':
+ $table or exit;
+ $N = parse_dict($table);
+ $fields_select = '';
+ $result = $db->query("SHOW COLUMNS FROM `$table`");
+ while($r = $db->fetch_array($result)) {
+ $fields_select .= ''.$r['Field'].(isset($N[$r['Field']]) ? ' ('.$N[$r['Field']].')' : '').' ';
+ }
+ $select = '选择字段(按Ctrl多选) '.$fields_select.' ';
+ $key = table_get_key($table);
+ $order = $key ? $key.' DESC' : '';
+ exit(json_encode(array('select' => $select, 'order' => $order)));
+ break;
+ case 'pages':
+ $psize > 0 or $psize = 5000;
+ $total = $db->count($table, '1 '.$condition);
+ $page = ceil(intval($total)/$psize);
+ exit('{"page":"'.$page.'","total":"'.$total.'","ok":"1"}');
+ break;
+ case 'download':
+ $table or msg('请选择数据表');
+ $ismember = strpos($table, 'member') === false ? 0 : 1;
+ isset($fields) or $fields = array();
+ $fields = $fields ? implode(',', $fields) : '*';
+ $condition = '1 '.$condition;
+ if(strpos($condition, DT_PRE) !== false) $condition = '1';
+ if($ismember) $condition .= ' AND groupid>1';
+ if(!$order) {
+ $key = table_get_key($table);
+ if($key) $order = $key.' DESC';
+ }
+ $order = $order ? 'ORDER BY '.$order : '';
+ in_array($ext, array('csv', 'xml', 'json')) or $ext = 'csv';
+ $data = '';
+ $lists = $list = array();
+ $result = $db->query("SELECT {$fields} FROM {$table} WHERE {$condition} {$order} LIMIT $offset,$pagesize");
+ while($r = $db->fetch_array($result)) {
+ if($ismember) {
+ foreach(array('password', 'passsalt', 'payword', 'paysalt') as $v) {
+ if(isset($r[$v])) unset($r[$v]);
+ }
+ }
+ if(!$data) $list = $r;
+ if($ext == 'csv') {
+ foreach($r as $k=>$v) {
+ if(strpos($k, 'time') !== false) $v = timetodate($v, 6);
+ $data .= '"'.$v.'",';
+ }
+ $data .= "\n";
+ } else if($ext == 'xml') {
+ $data .= "\t".'- '."\n";
+ foreach($r as $k=>$v) {
+ if(strpos($k, 'time') !== false) $v = timetodate($v, 6);
+ if(strpos($v, '<') !== false || strpos($v, "\n") !== false) {
+ $data .= "\t\t".'<'.$k.'>'.$k.'>'."\n";
+ } else {
+ $data .= "\t\t".'<'.$k.'>'.$v.''.$k.'>'."\n";
+ }
+ }
+ $data .= "\t".'
'."\n";
+ } else {
+ $data = 'json';
+ foreach($r as $k=>$v) {
+ if(strpos($k, 'time') !== false) $r[$k] = timetodate($v, 6);
+ }
+ $lists[] = $r;
+ }
+ }
+ if($list) {
+ if($ext == 'csv') {
+ $N = parse_dict($table);
+ $T = '';
+ foreach($list as $k=>$v) {
+ $T .= '"'.(isset($N[$k]) ? $N[$k] : $k).'",';
+ }
+ $T .= "\n";
+ foreach($list as $k=>$v) {
+ $T .= '"'.$k.'",';
+ }
+ $data = $T."\n".$data;
+ $data = convert($data, DT_CHARSET, 'GBK');
+ } else if($ext == 'xml') {
+ $N = parse_dict($table);
+ $T = ''."\n";
+ $T .= '<'.$table.'>'."\n";
+ $T .= "\t".'- '."\n";
+ foreach($list as $k=>$v) {
+ $T .= "\t\t".'<'.$k.'>'.(isset($N[$k]) ? $N[$k] : $k).''.$k.'>'."\n";
+ }
+ $T .= "\t".'
'."\n";
+ $data = $T.$data;
+ $data .= ''.$table.'>'."\n";
+ $data .= '';
+ } else {
+ $data = json_encode($lists);
+ }
+ }
+ if($data) file_down('', $table.'_'.$page.'.'.$ext, $data);
+ msg('没有符合条件的数据');
+ break;
+ default:
+ $table_select = '';
+ $tables = array();
+ $result = $db->query("SHOW TABLE STATUS FROM `".$CFG['db_name']."`");
+ while($r = $db->fetch_array($result)) {
+ $table = $r['Name'];
+ if(preg_match("/^".$DT_PRE."/i", $table)) {
+ $table_select .= ''.$table.' ('.$r['Comment'].') ';
+ $tables[] = $table;
+ }
+ }
+ include tpl('data');
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/database.inc.php b/admin/database.inc.php
new file mode 100644
index 0000000..1300a5c
--- /dev/null
+++ b/admin/database.inc.php
@@ -0,0 +1,896 @@
+') $tmp = trim(substr($tmp, 13));
+ foreach(explode('DROP TABLE', $tmp) as $tb) {
+ if(strpos($tb, 'CREATE TABLE') != false) {
+ $table = cutstr($tb, 'CREATE TABLE `', '`');
+ $table = substr($table, strlen(DT_PRE));
+ $table = preg_replace("/_[0-9]{1,}/", '', $table);
+ if($table) {
+ foreach(explode("\n", $tb) as $t) {
+ $t = trim($t);
+ if(substr($t, 0, 1) != '`' || substr($t, -1, 1) != ',') continue;
+ $V[$table][trim(cutstr($t, '`', '`'))] = substr(trim(cutstr($t, '` ')), 0, -1);
+ }
+ }
+ }
+ }
+ return $V;
+}
+function parse_dict($table, $job = '') {
+ global $MODULE;
+ $fds = $names = $notes = array();
+ if(strpos($table, DT_PRE) === false) {
+ $rtable = $table;
+ } else {
+ $rtable = substr($table, strlen(DT_PRE));
+ $fds = cache_read('fields-'.$rtable.'.php');
+ $rtable = preg_replace("/_[0-9]{1,}/", '', $rtable);
+ if(is_numeric($rtable) && isset($MODULE[$rtable])) $rtable = $MODULE[$rtable]['module'].'_data';
+ }
+ if($job == 'table') return $rtable;
+ $file = DT_ROOT.'/file/setting/'.$rtable.'.csv';
+ if($job == 'file') return $file;
+ if(is_file($file)) {
+ $tmp = file_get($file);
+ $arr = explode("\n", $tmp);
+ foreach($arr as $v) {
+ $t = explode(',', $v);
+ $names[$t[0]] = $t[1];
+ $notes[$t[0]] = $t[2];
+ }
+ }
+ if($fds) {
+ foreach($fds as $v) {
+ if(isset($names[$v['name']]) && $names[$v['name']]) continue;
+ $names[$v['name']] = $v['title'];
+ $notes[$v['name']] = '';
+ }
+ }
+ if($job == 'note') return $notes;
+ return $names;
+}
+switch($action) {
+ case 'repair':
+ $DT['close'] or msg('为了数据安全,此操作必须先在网站设置 里临时关闭网站');
+ isset($tables) or msg('请指定数据表');
+ is_array($tables) or $tables = array($tables);
+ count($tables) < 10 or msg('此操作比较耗费服务器资源,请控制在10个表内');
+ foreach($tables as $table) {
+ $table = strip_sql($table, 0);
+ $db->query("REPAIR TABLE `{$table}`");
+ }
+ dmsg('修复成功', $forward);
+ break;
+ case 'optimize':
+ $DT['close'] or msg('为了数据安全,此操作必须先在网站设置 里临时关闭网站');
+ isset($tables) or msg('请指定数据表');
+ is_array($tables) or $tables = array($tables);
+ count($tables) < 10 or msg('此操作比较耗费服务器资源,请控制在10个表内');
+ foreach($tables as $table) {
+ $table = strip_sql($table, 0);
+ $db->query("OPTIMIZE TABLE `{$table}`");
+ }
+ dmsg('优化成功', $forward);
+ break;
+ case 'drop':
+ isset($tables) or msg('请指定数据表');
+ is_array($tables) or $tables = array($tables);
+ foreach($tables as $table) {
+ $table = strip_sql($table, 0);
+ if(strpos($table, $DT_PRE) === false) $db->query("DROP TABLE `{$table}`");
+ }
+ dmsg('删除成功', $forward);
+ break;
+ case 'execute':
+ if(!isset($CFG['executesql']) || !$CFG['executesql']) msg('系统禁止了执行SQL,请FTP修改根目录config.inc.php $CFG[\'executesql\'] = \'0\'; 修改为 $CFG[\'executesql\'] = \'1\';');
+ isset($sql) or $sql = '';
+ $lists = array();
+ if($table) {
+ $sql = "SELECT * FROM ".$table;
+ $submit = 1;
+ }
+ if($submit) {
+ $sql = trim($sql);
+ if(!$sql) {
+ msg('SQL语句为空');
+ } else {
+ $sql = stripslashes($sql);
+ $sql = strip_sql($sql, 0);
+ if(strtoupper(substr($sql, 0, 7)) == 'SELECT ' && strpos($sql, "\n") === false) {
+ if(substr($sql, -1) == ';') $sql = substr($sql, 0, -1);
+ if(stripos($sql, 'LIMIT ') === false) $sql .= " LIMIT 0,$pagesize";
+ $result = $db->query($sql);
+ while($r = $db->fetch_array($result)) {
+ $lists[] = $r;
+ }
+ $fds = parse_dict($table ? $table : $DT_PRE.cutstr($sql, ' '.$DT_PRE, ' '));
+ } else {
+ sql_execute($sql);
+ dmsg('执行成功', '?file='.$file.'&action=execute');
+ }
+ }
+ }
+ include tpl('database_execute');
+ break;
+ case 'process':
+ $i = 0;
+ $lists = $tags = array();
+ $result = $db->query("SHOW FULL PROCESSLIST");
+ while($r = $db->fetch_array($result)) {
+ if($r['db'] == $CFG['db_name']) {
+ $lists[$i++] = $r;
+ } else {
+ $tags[$i++] = $r;
+ }
+ }
+ $lists = $lists + $tags;
+ include tpl('database_process');
+ break;
+ case 'kill':
+ $db->halt = 0;
+ if($itemid) {
+ if(is_array($itemid)) {
+ foreach($itemid as $id) {
+ $db->query("KILL $id");
+ }
+ } else {
+ $db->query("KILL $itemid");
+ }
+ }
+ dmsg('结束成功', '?file='.$file.'&action=process');
+ break;
+ case 'comments':
+ $db->halt = 0;
+ $C = include(DT_ROOT.'/file/setting/comment.php');
+ $C or msg('配置文件不存在,请上传 file/setting/comment.php');
+ foreach($C as $k=>$v) {
+ $sql = "ALTER TABLE `{$DT_PRE}{$k}` COMMENT='{$v}'";
+ $db->query($sql);
+ }
+ foreach($MODULE as $k=>$v) {
+ if(is_file(DT_ROOT.'/file/setting/'.$v['module'].'.csv')) {
+ $sql = "ALTER TABLE `".$DT_PRE.$v['module']."_".$v['moduleid']."` COMMENT='".$v['name']."'";
+ $db->query($sql);
+ $sql = "ALTER TABLE `".$DT_PRE.$v['module']."_data_".$v['moduleid']."` COMMENT='".$v['name']."内容'";
+ $db->query($sql);
+ }
+ }
+ dmsg('重建成功', '?file='.$file);
+ break;
+ case 'comment':
+ $table or msg('Table为空');
+ if($submit) {
+ $name = trim($name);
+ $db->query("ALTER TABLE `{$table}` COMMENT='{$name}'");
+ dmsg('修改成功', '?file='.$file.'&action='.$action.'&table='.$table.'¬e='.urlencode($name));
+ } else {
+ include tpl('database_comment');
+ }
+ break;
+ case 'dict':
+ $table or msg('Table为空');
+ $dict_file = parse_dict($table, 'file');
+ if($submit) {
+ $csv = "";
+ foreach($name as $k=>$v) {
+ $v = str_replace(',', ',', $v);
+ $n = str_replace(',', ',', $note[$k]);
+ $csv .= $k.','.$v.','.$n."\n";
+ }
+ file_put($dict_file, trim($csv));
+ dmsg('更新成功', '?file='.$file.'&action='.$action.'&job='.$job.'&table='.$table.'¬e='.urlencode($nt));
+ } else {
+ $names = parse_dict($table);
+ $notes = parse_dict($table, 'note');
+ $fields = $F = $R = array();
+ $result = $db->query("SHOW COLUMNS FROM `{$table}`");
+ while($r = $db->fetch_array($result)) {
+ $r['Type'] = str_replace(' unsigned', '', $r['Type']);
+ $F[$r['Field']] = $r['Type'];
+ if(isset($names[$r['Field']])) {
+ $r['cn_name'] = $names[$r['Field']];
+ $r['cn_note'] = $notes[$r['Field']];
+ } else {
+ $r['cn_name'] = $r['cn_note'] = '';
+ }
+ $fields[] = $r;
+ }
+ if($job == 'verify') {
+ $rtable = parse_dict($table, 'table');
+ $V = table_get_default();
+ $V = isset($V[$rtable]) ? $V[$rtable] : array();
+ if($V) {
+ //自定义字段移除
+ if(preg_match("/[0-9]{1,}/", $tn) && is_file(DT_CACHE.'/fields-'.$tn.'.php')) {
+ foreach(cache_read('fields-'.$tn.'.php') as $f) {
+ if(isset($F[$f['name']])) unset($F[$f['name']]);
+ $R[$f['name']] = '自定义字段 ';
+ }
+ }
+ foreach($F as $k=>$v) {
+ if(isset($V[$k])) {
+ $v = str_replace(array('longtext', 'mediumtext'), array('text', 'text'), strtolower($v));
+ if(stripos($V[$k], $v) === false) {
+ $R[$k] = '类型错误 ';
+ } else {
+ $R[$k] = ' 通过 ';
+ }
+ unset($V[$k]);
+ } else {
+ $R[$k] = '多余字段 ';
+ }
+ }
+ } else {
+ foreach($F as $k=>$v) {
+ $R[$k] = '未知 ';
+ }
+ }
+ }
+ include tpl('database_dict');
+ }
+ break;
+ case 'export':
+ if(!$table) msg();
+ //$memory_limit = trim(@ini_get('memory_limit'));
+ $sizelimit = 1024*1024;//Max 1G
+ file_down('', $table.'.sql', sql_dumptable($table));
+ break;
+ case 'download':
+ $file_ext = file_ext($filename);
+ $file_ext == 'sql' or msg('只能下载SQL文件');
+ file_down($dir ? $D.$dir.'/'.$filename : $D.$filename);
+ break;
+ case 'view':
+ $file_ext = file_ext($filename);
+ $file_ext == 'sql' or msg('只能查看SQL文件');
+ $file_path = $dir ? $D.$dir.'/'.$filename : $D.$filename;
+ is_file($file_path) or msg('SQL文件不存在');
+ $file_size = round(filesize($file_path)/(1024*1024), 2);
+ $file_size < 20 or msg('文件体积过大,不支持在线查看');
+ $content = file_get($file_path);
+ include tpl('database_view');
+ break;
+ case 'delete':
+ if(!is_array($filenames)) {
+ $tmp = $filenames;
+ $filenames = array();
+ $filenames[0] = $tmp;
+ }
+ foreach($filenames as $filename) {
+ if(file_ext($filename) == 'sql' || substr($filename, -8) == '.sql.php') {
+ file_del($dir ? $D.$dir.'/'.$filename : $D.$filename);
+ } else if(is_dir($D.$filename)) {
+ dir_delete($D.$filename);
+ }
+ }
+ dmsg('删除成功', $forward);
+ break;
+ case 'fields':
+ $table or exit;
+ $N = parse_dict($table);
+ $fields_select = '';
+ $result = $db->query("SHOW COLUMNS FROM `{$table}`");
+ while($r = $db->fetch_array($result)) {
+ $fields_select .= ''.$r['Field'].(isset($N[$r['Field']]) ? ' ('.$N[$r['Field']].')' : '').' ';
+ }
+ echo '选择字段 '.$fields_select.' ';
+ exit;
+ break;
+ case 'replace':
+ if($submit) {
+ $post['table'] = strip_sql($post['table'], 0);
+ $post['key'] = table_get_key($post['table']);
+ $post['num'] = intval($post['num']);
+ $post = dstripslashes($post);
+ cache_write('table-replace.php', $post);
+ if($post['type'] == 1) {
+ if(!$post['from']) msg('请填写查找内容');
+ if($post['table']) {
+ if(!$post['key']) message('表'.$post['table'].'无主键,无法完成操作');
+ if($post['key'] == $post['fields']) msg('无法完成对主键操作,请更换字段');
+ }
+ msg('正在开始替换', '?file='.$file.'&action=replace_table');
+ } else {
+ if(!$post['table'] || !$post['fields']) msg('请选择字段');
+ if(!$post['add']) msg('请填写追加内容');
+ if(!$post['key']) message('表'.$post['table'].'无主键,无法完成操作');
+ if($post['key'] == $post['fields']) msg('无法完成对主键操作,请更换字段');
+ msg('正在开始追加', '?file='.$file.'&action=replace_add');
+ }
+ } else {
+ $table_select = '';
+ $tables = array();
+ $query = $db->query("SHOW TABLE STATUS FROM `".$CFG['db_name']."`");
+ while($r = $db->fetch_array($query)) {
+ $table = $r['Name'];
+ if(preg_match("/^".$DT_PRE."/i", $table)) {
+ $table_select .= ''.$table.' ('.$r['Comment'].') ';
+ $tables[] = $table;
+ }
+ }
+ cache_write('table.php', $tables);
+ $sql_select = '';
+ $sqlfiles = glob($D.'*');
+ if(is_array($sqlfiles)) {
+ $sqlfiles = array_reverse($sqlfiles);
+ foreach($sqlfiles as $id=>$sqlfile) {
+ $tmp = basename($sqlfile);
+ if(is_dir($sqlfile)) $sql_select .= ''.$tmp.' ';
+ }
+ }
+ include tpl('database_replace');
+ }
+ break;
+ case 'replace_table':
+ $post = cache_read('table-replace.php');
+ $post or msg('数据配置不存在', '?file='.$file.'&action=replace');
+ if($post['table']) {
+ $table = $post['table'];
+ $id = $post['key'];
+ } else {
+ if($table) {
+ $id or msg('替换成功', '?file=database&action=replace');
+ } else {
+ $table = DT_PRE.'404';
+ $id = 'itemid';
+ }
+ }
+ $fields = $post['fields'];
+ $fds = $fields ? "`{$id}`,`{$fields}`" : "*";
+ $condition = $post['condition'];
+ $num = $post['num'];
+ $num > 0 or $num = 1000;
+ if(!isset($fid)) {
+ $r = $db->get_one("SELECT min({$id}) AS fid FROM {$table}");
+ $fid = $r['fid'] ? $r['fid'] : 0;
+ }
+ if(!isset($tid)) {
+ $r = $db->get_one("SELECT max({$id}) AS tid FROM {$table}");
+ $tid = $r['tid'] ? $r['tid'] : 0;
+ }
+ isset($$id) or $$id = 1;
+ if($fid <= $tid) {
+ $result = $db->query("SELECT {$fds} FROM {$table} WHERE `{$id}`>=$fid {$condition} ORDER BY `{$id}` LIMIT 0,$num");
+ if($db->affected_rows($result)) {
+ while($r = $db->fetch_array($result)) {
+ $$id = $r[$id];
+ $sql = '';
+ foreach($r as $k=>$v) {
+ if(strpos($v, $post['from']) !== false) {
+ $v = addslashes(str_replace($post['from'], $post['to'], $v));
+ $sql .= ",`$k`='$v'";
+ }
+ }
+ if($sql) {
+ $sql = substr($sql, 1);
+ $db->query("UPDATE {$table} SET {$sql} WHERE `{$id}`={$$id}");
+ }
+ }
+ $$id += 1;
+ } else {
+ $$id = $fid + $num;
+ }
+ } else {
+ if($post['table']) {
+ msg('替换成功', '?file=database&action=replace');
+ } else {
+ $tb = table_get_next($table);
+ if($tb) {
+ $id = table_get_key($tb);
+ msg('表 '.$table.' 替换成功', '?file='.$file.'&action='.$action.'&table='.$tb.'&id='.$id, 0);
+ } else {
+ msg('替换成功', '?file=database&action=replace');
+ }
+ }
+ }
+ msg('ID '.$fid.'~'.($$id-1).'替换成功', '?file='.$file.'&action='.$action.'&table='.$table.'&id='.$id.'&fid='.$$id.'&tid='.$tid.'&num='.$num, 0);
+ break;
+ case 'replace_add':
+ $post = cache_read('table-replace.php');
+ $post or msg('数据缓存不存在', '?file='.$file.'&action=replace');
+ $table = $post['table'];
+ $id = $post['key'];
+ $fields = $post['fields'];
+ $condition = $post['condition'];
+ $num = $post['num'];
+ $num > 0 or $num = 1000;
+ if(!isset($fid)) {
+ $r = $db->get_one("SELECT min({$id}) AS fid FROM {$table}");
+ $fid = $r['fid'] ? $r['fid'] : 0;
+ }
+ if(!isset($tid)) {
+ $r = $db->get_one("SELECT max({$id}) AS tid FROM {$table}");
+ $tid = $r['tid'] ? $r['tid'] : 0;
+ }
+ isset($$id) or $$id = 1;
+ if($fid <= $tid) {
+ $result = $db->query("SELECT `{$id}`,`{$fields}` FROM {$table} WHERE `{$id}`>=$fid {$condition} ORDER BY `{$id}` LIMIT 0,$num ");
+ if($db->affected_rows($result)) {
+ while($r = $db->fetch_array($result)) {
+ $$id = $r[$id];
+ $data = addslashes($post['type'] == 2 ? $post['add'].$r[$fields] : $r[$fields].$post['add']);
+ $db->query("UPDATE {$table} SET `{$fields}`='{$data}' WHERE `{$id}`={$$id}");
+ }
+ $$id += 1;
+ } else {
+ $$id = $fid + $num;
+ }
+ } else {
+ msg('追加成功', '?file='.$file.'&action=replace');
+ }
+ msg('ID '.$fid.'~'.($$id-1).'追加成功', '?file='.$file.'&action='.$action.'&fid='.$$id.'&tid='.$tid.'&num='.$num, 0);
+ break;
+ case 'replace_file':
+ if(!$file_pre) msg('请选择备份系列');
+ if(!$file_from) msg('请请填写查找内容');
+ isset($tid) or $tid = count(glob($D.$file_pre.'/*.sql'));
+ $fileid = isset($fileid) ? $fileid : 1;
+ $filename = $file_pre.'/'.$fileid.'.sql';
+ $dfile = $D.$filename;
+ $file_from = urldecode($file_from);
+ $file_to = urldecode($file_to);
+ if(is_file($dfile)) {
+ $sql = file_get($dfile);
+ $sql = str_replace($file_from, $file_to, $sql);
+ file_put($dfile, $sql);
+ $fid = $fileid;
+ msg('分卷 #'.$fileid++.' 替换成功 程序将自动继续...'.progress(0, $fid, $tid), '?file='.$file.'&action='.$action.'&file_pre='.$file_pre.'&fileid='.$fileid.'&tid='.$tid.'&file_from='.urlencode($file_from).'&file_to='.urlencode($file_to), 0);
+ } else {
+ msg('文件内容替换成功', '?file='.$file.'&action=replace');
+ }
+ break;
+ case 'open':
+ if(!$dir) msg('请选择备份系列');
+ if(!is_dir($D.$dir)) msg('备份系列不存在');
+ $sql = $sqls = array();
+ $sqlfiles = glob($D.$dir.'/*.sql');
+ if(!$sqlfiles) msg('备份系列文件不存在');
+ $tid = count($sqlfiles);
+ foreach($sqlfiles as $id=>$sqlfile) {
+ $tmp = basename($sqlfile);
+ $size = filesize($sqlfile);
+ $sql['filename'] = $tmp;
+ $sql['filesize'] = round($size/(1024*1024), 2);
+ $sql['filesize'] = $sql['filesize'] < 0.01 ? round($size/1024, 2).'K' : $sql['filesize'].'M';
+ $sql['pre'] = $dir;
+ $sql['number'] = str_replace('.sql', '', $tmp);
+ $sql['mtime'] = timetodate(filemtime($sqlfile), 5);
+ $sql['btime'] = substr(str_replace('.', ':', $dir), 0, -3);
+ $sqls[$sql['number']] = $sql;
+ }
+ include tpl('database_open');
+ break;
+ case 'note':
+ if(!$dir) exit('ko');
+ if(!is_dir($D.$dir)) exit('ko');
+ file_put($D.$dir.'/0.txt', strip_tags($note));
+ exit('ok');
+ break;
+ case 'verify':
+ $sfields = array('按条件', '表名', '字段');
+ $sorder = array('结果排序方式', '表名降序', '表名升序', '大小降序', '大小升序', '记录降序', '记录升序', '字段数降序', '字段数升序');
+ $dstatus = array('未知', '异常', '通过');
+ isset($fields) && isset($sfields[$fields]) or $fields = 0;
+ isset($order) && isset($sorder[$order]) or $order = 0;
+ isset($status) && isset($dstatus[$status]) or $status = -1;
+ $fields_select = dselect($sfields, 'fields', '', $fields);
+ $order_select = dselect($sorder, 'order', '', $order);
+ $status_select = dselect($dstatus, 'status', '状态', $status, '', 1, '-1');
+ $dtables = $C = $T = $S = array();
+ $i = 0;
+ $V = table_get_default();
+ $result = $db->query("SHOW TABLES FROM `".$CFG['db_name']."`");
+ while($r = $db->fetch_row($result)) {
+ if(!$r[0]) continue;
+ $T[$r[0]] = $r[0];
+ }
+ if($order < 2) {
+ uksort($T, 'strnatcasecmp');
+ } else if($order == 2) {
+ krsort($T);
+ }
+ $O = array();
+ $result = $db->query("SHOW TABLE STATUS FROM `".$CFG['db_name']."`");
+ while($r = $db->fetch_array($result)) {
+ $S[$r['Name']] = $r;
+ if($order == 3 || $order == 4) {
+ $O[$r['Name']] = $r['Data_length'] + $r['Index_length'];
+ } else if($order == 5 || $order == 6) {
+ $O[$r['Name']] = $r['Rows'];
+ }
+ }
+ if($O) {
+ if($order == 3 || $order == 5) {
+ arsort($O);
+ } else if($order == 4 || $order == 6) {
+ asort($O);
+ }
+ $T = array();
+ foreach($O as $k=>$v) {
+ $T[$k] = $k;
+ }
+ }
+ $cols = array();
+ foreach($T as $t) {
+ $r = $S[$t];
+ $r['Name'] = $t;
+ if($kw) {
+ if($fields == 2) {
+ if(strpos($t, $DT_PRE) === false) continue;
+ $tmp = '';
+ $names = parse_dict($t);
+ foreach($names as $kk => $vv) {
+ $tmp .= ' '.$kk;
+ }
+ if(stripos($tmp, $kw) === false) continue;
+ } else {
+ if(stripos($r['Name'], $kw) === false && stripos($r['Comment'], $kw) === false) continue;
+ }
+ }
+ if(preg_match('/^'.$DT_PRE.'/', $t)) {
+ $verify = 0;
+ $F = array();
+ $result = $db->query("SHOW COLUMNS FROM `$t`");
+ while($rr = $db->fetch_array($result)) {
+ $F[$rr['Field']] = str_replace(' unsigned', '', $rr['Type']);
+ }
+ $tb = $tn = substr($t, strlen($DT_PRE));
+ $tb = preg_replace("/_[0-9]{1,}/", '', $tb);
+ if(is_numeric($tb) && isset($MODULE[$tb])) $tb = $MODULE[$tb]['module'].'_data';
+ if(isset($V[$tb])) {
+ //自定义字段移除
+ if(preg_match("/[0-9]{1,}/", $tn) && is_file(DT_CACHE.'/fields-'.$tn.'.php')) {
+ foreach(cache_read('fields-'.$tn.'.php') as $f) {
+ if(isset($F[$f['name']])) unset($F[$f['name']]);
+ }
+ }
+ if(count($V[$tb]) == count($F)) {
+ $verify = 2;
+ foreach($F as $k=>$v) {
+ if(!isset($V[$tb][$k])) {$verify = 1; break;}
+ $v = str_replace(array('longtext', 'mediumtext'), array('text', 'text'), strtolower($v));
+ if(stripos($V[$tb][$k], $v) === false) {$verify = 1; break;}
+ }
+ } else {
+ $verify = 1;
+ }
+ }
+ if($status > -1 && $verify != $status) continue;
+ $dtables[$i]['verify'] = $verify;
+ $dtables[$i]['cols'] = $cols[$i] = count($F);
+ $dtables[$i]['name'] = $r['Name'];
+ $dtables[$i]['rows'] = $r['Rows'];
+ $dtables[$i]['size'] = round($r['Data_length']/1024/1024, 2);
+ $dtables[$i]['index'] = round($r['Index_length']/1024/1024, 2);
+ $dtables[$i]['tsize'] = round(($r['Data_length']+$r['Index_length'])/1024/1024, 2);
+ $dtables[$i]['auto'] = $r['Auto_increment'];
+ $dtables[$i]['updatetime'] = $r['Update_time'];
+ $dtables[$i]['note'] = $r['Comment'];
+ $dtables[$i]['chip'] = $r['Data_free'];
+ $C[str_replace($DT_PRE, '', $r['Name'])] = $r['Comment'];
+ $i++;
+ }
+ }
+ if($order == 7) {
+ array_multisort($cols, SORT_DESC, $dtables);
+ } else if($order == 8) {
+ array_multisort($cols, SORT_ASC, $dtables);
+ }
+ include tpl('database_verify');
+ break;
+ case 'structure':
+ if(!isset($tables) || !is_array($tables)) msg('请选择需要导出的表');
+ $dumpcharset = $sqlcharset ? $sqlcharset : $CFG['db_charset'];
+ if($db->version() > '4.1') {
+ if($sqlcharset) $db->query("SET NAMES '".$sqlcharset."';\n\n");
+ if($sqlcompat == 'MYSQL40') {
+ $db->query("SET SQL_MODE='MYSQL40'");
+ } else if($sqlcompat == 'MYSQL41') {
+ $db->query("SET SQL_MODE=''");
+ }
+ }
+ $sqldump = "# DESTOON V".DT_VERSION." R".DT_RELEASE." https://www.destoon.com\n# ".timetodate($DT_TIME, 6)."\n# --------------------------------------------------------\n\n\n";
+ foreach($tables as $table) {
+ $table = strip_sql($table, 0);
+ $sqldump .= sql_dumptable($table, 0, 0, 1);
+ }
+ $sqldump = preg_replace("/AUTO_INCREMENT\=([0-9]+)\s/", "", $sqldump);
+ $name = count($tables) == 1 ? $table : 'destoon_'.$action;
+ file_down('', $name.'.sql', $sqldump);
+ break;
+ case 'import':
+ if(isset($import)) {
+ if(isset($filename) && $filename && (file_ext($filename) == 'sql' || substr($filename, -8) == '.sql.php')) {
+ $dfile = $D.$filename;
+ if(!is_file($dfile)) msg('文件不存在,请检查');
+ if(substr($filename, -8) == '.sql.php') {
+ @include $dfile;
+ file_del($dfile);
+ } else {
+ $sql = file_get($dfile);
+ sql_execute($sql);
+ }
+ msg($filename.' 导入成功', '?file='.$file.'&action=import');
+ } else {
+ $fileid = isset($fileid) ? $fileid : 1;
+ $tid = isset($tid) ? intval($tid) : 0;
+ $filename = is_dir($D.$filepre) ? $filepre.'/'.$fileid : $filepre.$fileid;
+ $filename = $D.$filename.'.sql';
+ if(is_file($filename)) {
+ $sql = file_get($filename);
+ if(substr($sql, 0, 11) == '# DESTOON V') {
+ $v = substr($sql, 11, 3);
+ if(DT_VERSION != $v) msg('由于数据结构存在差异,备份数据不可以跨版本导入 备份版本:V'.$v.' 当前系统:V'.DT_VERSION);
+ }
+ sql_execute($sql);
+ $prog = $tid ? progress(1, $fileid, $tid) : '';
+ msg('分卷 #'.$fileid++.' 导入成功 程序将自动继续...'.$prog, '?file='.$file.'&action='.$action.'&filepre='.$filepre.'&fileid='.$fileid.'&tid='.$tid.'&import=1', 0);
+ } else {
+ msg('数据库恢复成功', '?file='.$file.'&action=import');
+ }
+ }
+ } else {
+ $dbak = $dbaks = $dsql = $dsqls = $sql = $sqls = array();
+ $sqlfiles = glob($D.'*');
+ if(is_array($sqlfiles)) {
+ $class = 1;
+ foreach($sqlfiles as $id=>$sqlfile) {
+ $tmp = basename($sqlfile);
+ if(is_dir($sqlfile)) {
+ $dbak['filename'] = $tmp;
+ $size = $number = 0;
+ $ss = glob($D.$tmp.'/*.sql');
+ foreach($ss as $s) {
+ $size += filesize($s);
+ $number++;
+ }
+ $dbak['filesize'] = round($size/(1024*1024), 2);
+ $dbak['filesize'] = $dbak['filesize'] < 0.01 ? round($size/1024, 2).'K' : $dbak['filesize'].'M';
+ $dbak['pre'] = $tmp;
+ $dbak['number'] = $number;
+ $dbak['mtime'] = str_replace('.', ':', substr($tmp, 0, 19));
+ $dbak['btime'] = substr($dbak['mtime'], 0, -3);
+ $dbak['note'] = file_get($D.$tmp.'/0.txt');
+ $dbaks[] = $dbak;
+ } else {
+ if(preg_match("/([a-z0-9_]+_[0-9]{8}_[0-9a-z]{8}_)([0-9]+)\.sql/i", $tmp, $num)) {
+ $size = filesize($sqlfile);
+ $dsql['filename'] = $tmp;
+ $dsql['filesize'] = round($size/(1024*1024), 2);
+ $dsql['note'] = $dsql['filesize'] < 3 ? trim(cutstr(file_get($sqlfile), '#', "\n")) : '';
+ $dsql['filesize'] = $dsql['filesize'] < 0.01 ? round($size/1024, 2).'K' : $dsql['filesize'].'M';
+ $dsql['pre'] = $num[1];
+ $dsql['number'] = $num[2];
+ $dsql['mtime'] = timetodate(filemtime($sqlfile), 5);
+ if(preg_match("/[a-z0-9_]+_([0-9]{4})([0-9]{2})([0-9]{2})_([0-9]{2})([0-9]{2})([0-9a-z]{4})_/i", $num[1], $tm)) {
+ $dsql['btime'] = $tm[1].'-'.$tm[2].'-'.$tm[3].' '.$tm[4].':'.$tm[5];
+ } else {
+ $dsql['btime'] = $dsql['mtime'];
+ }
+ if($dsql['number'] == 1) $class = $class ? 0 : 1;
+ $dsql['class'] = $class;
+ $dsqls[] = $dsql;
+ } else {
+ if(file_ext($tmp) != 'sql' && substr($tmp, -8) != '.sql.php') continue;
+ $size = filesize($sqlfile);
+ $sql['filename'] = $tmp;
+ $sql['filesize'] = round($size/(1024*1024), 2);
+ $sql['note'] = $sql['filesize'] < 3 ? trim(cutstr(file_get($sqlfile), '#', "\n")) : '';
+ $sql['filesize'] = $sql['filesize'] < 0.01 ? round($size/1024, 2).'K' : $sql['filesize'].'M';
+ $sql['mtime'] = timetodate(filemtime($sqlfile), 5);
+ $sqls[] = $sql;
+ }
+ }
+ }
+ }
+ }
+ if($dbaks) $dbaks = array_reverse($dbaks);
+ include tpl('database_import');
+ break;
+ default:
+ if(isset($backup)) {
+ $fileid = isset($fileid) ? intval($fileid) : 1;
+ $sizelimit = $sizelimit ? intval($sizelimit) : 2048;
+ if($fileid == 1 && $tables) {
+ if(!isset($tables) || !is_array($tables)) msg('请选择需要备份的表');
+ $random = timetodate($DT_TIME, 'Y-m-d H.i.s').' '.random(10, 'a-z');
+ $tsize = 0;
+ foreach($tables as $k=>$v) {
+ $v = strip_sql($v, 0);
+ $tables[$k] = $v;
+ $tsize += $sizes[$v];
+ }
+ $tid = ceil($tsize*1024/$sizelimit);
+ if($note) {
+ $note = trim(dhtmlspecialchars(strip_tags($note)));
+ file_put($D.$random.'/0.txt', $note);
+ }
+ cache_write($_username.'_backup.php', $tables);
+ } else {
+ if(!$tables = cache_read($_username.'_backup.php')) msg('请选择需要备份的表');
+ }
+ $dumpcharset = $sqlcharset ? $sqlcharset : $CFG['db_charset'];
+ if($db->version() > '4.1') {
+ if($sqlcharset) $db->query("SET NAMES '".$sqlcharset."';\n\n");
+ if($sqlcompat == 'MYSQL40') {
+ $db->query("SET SQL_MODE='MYSQL40'");
+ } else if($sqlcompat == 'MYSQL41') {
+ $db->query("SET SQL_MODE=''");
+ }
+ }
+ $sqldump = '';
+ $tableid = isset($tableid) ? $tableid - 1 : 0;
+ $startfrom = isset($startfrom) ? intval($startfrom) : 0;
+ $tablenumber = count($tables);
+ for($i = $tableid; $i < $tablenumber && strlen($sqldump) < $sizelimit * 1000; $i++) {
+ $sqldump .= sql_dumptable($tables[$i], $startfrom, strlen($sqldump));
+ $startfrom = 0;
+ }
+ if(trim($sqldump)) {
+ $sqldump = "# DESTOON V".DT_VERSION." R".DT_RELEASE." https://www.destoon.com\n# ".timetodate($DT_TIME, 6)."\n# --------------------------------------------------------\n\n\n".$sqldump;
+ $tableid = $i;
+ $filename = $random.'/'.$fileid.'.sql';
+ file_put($D.$filename, $sqldump);
+ $fid = $fileid;
+ msg('分卷 #'.$fileid++.' 备份成功.. 程序将自动继续...'.progress(0, $fid, $tid), '?file='.$file.'&sizelimit='.$sizelimit.'&sqlcompat='.$sqlcompat.'&sqlcharset='.$sqlcharset.'&tableid='.$tableid.'&fileid='.$fileid.'&fileid='.$fileid.'&tid='.$tid.'&startfrom='.$startrow.'&random='.$random.'&backup=1', 0);
+ } else {
+ cache_delete($_username.'_backup.php');
+ $db->query("DELETE FROM {$DT_PRE}setting WHERE item='destoon' AND item_key='backtime'");
+ $db->query("INSERT INTO {$DT_PRE}setting (item,item_key,item_value) VALUES('destoon','backtime','$DT_TIME')");
+ msg('数据库备份成功', '?file='.$file.'&action=import');
+ }
+ } else {
+ $sfields = array('按条件', '表名', '字段');
+ $sorder = array('结果排序方式', '表名降序', '表名升序', '大小降序', '大小升序', '记录降序', '记录升序');
+ isset($fields) && isset($sfields[$fields]) or $fields = 0;
+ isset($order) && isset($sorder[$order]) or $order = 0;
+ $fields_select = dselect($sfields, 'fields', '', $fields);
+ $order_select = dselect($sorder, 'order', '', $order);
+ $dtables = $tables = $C = $T = $S = array();
+ $i = $j = $dtotalsize = $totalsize = 0;
+ $result = $db->query("SHOW TABLES FROM `".$CFG['db_name']."`");
+ while($r = $db->fetch_row($result)) {
+ if(!$r[0]) continue;
+ $T[$r[0]] = $r[0];
+ }
+ if($order < 2) {
+ uksort($T, 'strnatcasecmp');
+ } else if($order == 2) {
+ krsort($T);
+ }
+ $O = array();
+ $result = $db->query("SHOW TABLE STATUS FROM `".$CFG['db_name']."`");
+ while($r = $db->fetch_array($result)) {
+ $S[$r['Name']] = $r;
+ if($order == 3 || $order == 4) {
+ $O[$r['Name']] = $r['Data_length'] + $r['Index_length'];
+ } else if($order == 5 || $order == 6) {
+ $O[$r['Name']] = $r['Rows'];
+ }
+ }
+ if($O) {
+ if($order == 3 || $order == 5) {
+ arsort($O);
+ } else if($order == 4 || $order == 6) {
+ asort($O);
+ }
+ $T = array();
+ foreach($O as $k=>$v) {
+ $T[$k] = $k;
+ }
+ }
+ foreach($T as $t) {
+ $r = $S[$t];
+ $r['Name'] = $t;
+ if($kw) {
+ if($fields == 2) {
+ if(strpos($t, $DT_PRE) === false) continue;
+ $tmp = '';
+ $names = parse_dict($t);
+ foreach($names as $kk => $vv) {
+ $tmp .= ' '.$kk;
+ }
+ if(stripos($tmp, $kw) === false) continue;
+ } else {
+ if(stripos($r['Name'], $kw) === false && stripos($r['Comment'], $kw) === false) continue;
+ }
+ }
+ if(strpos($r['Comment'], 'is marked as crashed and should be repaired') !== false) {
+ $r['Comment'] = '';
+ $db->query("REPAIR TABLE `{$t}`");
+ }
+ if(preg_match('/^'.$DT_PRE.'/', $t)) {
+ $dtables[$i]['name'] = $r['Name'];
+ $dtables[$i]['rows'] = $r['Rows'];
+ $dtables[$i]['size'] = round($r['Data_length']/1024/1024, 2);
+ $dtables[$i]['index'] = round($r['Index_length']/1024/1024, 2);
+ $dtables[$i]['tsize'] = round(($r['Data_length']+$r['Index_length'])/1024/1024, 2);
+ $dtables[$i]['auto'] = $r['Auto_increment'];
+ $dtables[$i]['updatetime'] = $r['Update_time'];
+ $dtables[$i]['note'] = $r['Comment'];
+ $dtables[$i]['chip'] = $r['Data_free'];
+ $dtotalsize += $r['Data_length']+$r['Index_length'];
+ $C[str_replace($DT_PRE, '', $r['Name'])] = $r['Comment'];
+ $i++;
+ } else {
+ $tables[$j]['name'] = $r['Name'];
+ $tables[$j]['rows'] = $r['Rows'];
+ $tables[$j]['size'] = round($r['Data_length']/1024/1024, 2);
+ $tables[$j]['index'] = round($r['Index_length']/1024/1024, 2);
+ $tables[$j]['tsize'] = round(($r['Data_length']+$r['Index_length'])/1024/1024, 2);
+ $tables[$j]['auto'] = $r['Auto_increment'];
+ $tables[$j]['updatetime'] = $r['Update_time'];
+ $tables[$j]['note'] = $r['Comment'];
+ $tables[$j]['chip'] = $r['Data_free'];
+ $totalsize += $r['Data_length']+$r['Index_length'];
+ $j++;
+ }
+ }
+ //cache_write('comment.php', $C);
+ $dtotalsize = round($dtotalsize/1024/1024, 2);
+ $totalsize = round($totalsize/1024/1024, 2);
+ include tpl('database');
+ }
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/doctor.inc.php b/admin/doctor.inc.php
new file mode 100644
index 0000000..8b2741d
--- /dev/null
+++ b/admin/doctor.inc.php
@@ -0,0 +1,20 @@
+
\ No newline at end of file
diff --git a/admin/fetch.inc.php b/admin/fetch.inc.php
new file mode 100644
index 0000000..0989def
--- /dev/null
+++ b/admin/fetch.inc.php
@@ -0,0 +1,66 @@
+query("INSERT INTO {$DT_PRE}fetch (sitename,domain,encode,title,content,editor,edittime) VALUES ('$sitename','$domain','$encode','$title','$content','$_username','$DT_TIME')");
+ dmsg('添加成功', $forward);
+ } else {
+ $domain = $sitename = $title = '';
+ $encode = strtolower(DT_CHARSET);
+ $content = '[content]
';
+ include tpl('fetch_edit');
+ }
+ break;
+ case 'edit':
+ $itemid or msg('请选择规则');
+ if($submit) {
+ if(!$domain) msg('请输入采编域名');
+ if(strpos($content, '[content]') === false) msg('请输入内容规则');
+ $db->query("UPDATE {$DT_PRE}fetch SET sitename='$sitename',domain='$domain',encode='$encode',title='$title',content='$content',editor='$_username',edittime='$DT_TIME' WHERE itemid=$itemid");
+ dmsg('修改成功', $forward);
+ } else {
+ extract($db->get_one("SELECT * FROM {$DT_PRE}fetch WHERE itemid=$itemid"));
+ include tpl('fetch_edit');
+ }
+ break;
+ case 'delete':
+ $itemid or msg('请选择规则');
+ $ids = is_array($itemid) ? implode(',', $itemid) : $itemid;
+ $db->query("DELETE FROM {$DT_PRE}fetch WHERE itemid IN ($ids)");
+ dmsg('删除成功', $forward);
+ break;
+ default:
+ $sfields = array('按条件', '域名', '网站', '编辑');
+ $dfields = array('domain', 'domain', 'sitename', 'username');
+ isset($fields) && isset($dfields[$fields]) or $fields = 0;
+ $fields_select = dselect($sfields, 'fields', '', $fields);
+ $condition = '1';
+ if($keyword) $condition .= match_kw($dfields[$fields], $keyword);
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = $db->get_one("SELECT COUNT(*) AS num FROM {$DT_PRE}fetch WHERE $condition");
+ $items = $r['num'];
+ }
+ $pages = pages($items, $page, $pagesize);
+ $lists = array();
+ $result = $db->query("SELECT * FROM {$DT_PRE}fetch WHERE $condition ORDER BY itemid DESC LIMIT $offset,$pagesize");
+ while($r = $db->fetch_array($result)) {
+ $r['edittime'] = timetodate($r['edittime'], 5);
+ $lists[] = $r;
+ }
+ include tpl('fetch');
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/fields.inc.php b/admin/fields.inc.php
new file mode 100644
index 0000000..103a3ba
--- /dev/null
+++ b/admin/fields.inc.php
@@ -0,0 +1,193 @@
+tb = $tb;
+$menus = array (
+ array('添加字段', '?file='.$file.'&tb='.$tb.'&action=add'),
+ array('字段列表', '?file='.$file.'&tb='.$tb),
+);
+$this_forward = '?moduleid='.$moduleid.'&file='.$file.'&tb='.$tb;
+switch($action) {
+ case 'add':
+ if($submit) {
+ if($do->pass($post)) {
+ $do->add($post);
+ dmsg('添加成功', $this_forward);
+ } else {
+ msg($do->errmsg);
+ }
+ } else {
+ include tpl('fields_add');
+ }
+ break;
+ case 'edit':
+ $itemid or msg();
+ $do->itemid = $itemid;
+ if($submit) {
+ if($do->pass($post)) {
+ $do->edit($post);
+ dmsg('修改成功', $this_forward);
+ } else {
+ msg($do->errmsg);
+ }
+ } else {
+ extract($do->get_one());
+ include tpl('fields_edit');
+ }
+ break;
+ case 'update':
+ $do->update($post);
+ dmsg('更新成功', $this_forward);
+ break;
+ default:
+ $lists = $do->get_list("tb='$tb'");
+ cache_fields($tb);
+ include tpl('fields');
+ break;
+}
+
+class fields {
+ var $itemid;
+ var $tb;
+ var $table;
+ var $errmsg = errmsg;
+
+ function __construct() {
+ $this->table = DT_PRE.'fields';
+ }
+
+ function fields() {
+ $this->__construct();
+ }
+
+ function pass($post) {
+ if(!is_array($post)) return false;
+ if(!$post['name']) return $this->_('请填写字段');
+ if(!preg_match("/^[a-z0-9]+$/", $post['name'])) return $this->_('字段名只能为小写字母和数字的组合');
+ if(!$post['title']) return $this->_('请填写字段名称');
+ if(in_array($post['html'], array('select', 'radio', 'checkbox'))) {
+ if(!$post['option_value']) return $this->_('请填写选项值');
+ if(strpos($post['option_value'], '|') === false) return $this->_('请填写正确的选项值');
+ }
+ return true;
+ }
+
+ function set($post) {
+ if(!in_array($post['html'], array('select', 'radio', 'checkbox'))) {
+ $post['option_value'] = '';
+ }
+ $post['length'] = intval($post['length']);
+ if($post['html'] == 'textarea') {
+ if($post['type'] != 'varchar' && $post['type'] != 'text') $post['type'] = 'text';
+ } else if($post['html'] == 'checkbox' || $post['html'] == 'thumb' || $post['html'] == 'file') {
+ $post['type'] = 'varchar';
+ $post['length'] = 255;
+ } else if($post['html'] == 'editor') {
+ $post['type'] = 'text';
+ } else if($post['html'] == 'area') {
+ $post['type'] = 'int';
+ $post['length'] = 10;
+ }
+ return $post;
+ }
+
+ function get_one() {
+ return DB::get_one("SELECT * FROM {$this->table} WHERE itemid='$this->itemid'");
+ }
+
+ function get_list($condition = '', $order = 'listorder ASC,itemid ASC') {
+ global $MOD, $pages, $page, $pagesize, $offset, $sum;
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = DB::get_one("SELECT COUNT(*) AS num FROM {$this->table} WHERE $condition");
+ $items = $r['num'];
+ }
+ $pages = pages($items, $page, $pagesize);
+ $lists = array();
+ $result = DB::query("SELECT * FROM {$this->table} WHERE $condition ORDER BY $order LIMIT $offset,$pagesize");
+ while($r = DB::fetch_array($result)) {
+ $lists[] = $r;
+ }
+ return $lists;
+ }
+
+ function add($post) {
+ $post = $this->set($post);
+ $length = 0;
+ if($post['type'] == 'varchar') {
+ $length = min($post['length'], 255);
+ } else if($post['type'] == 'int') {
+ $length = min($post['length'], 10);
+ }
+ $type = strtoupper($post['type']);
+ if($length) $type .= "($length)";
+ $name = '`'.$post['name'].'`';
+ DB::query("ALTER TABLE ".DT_PRE."{$this->tb} ADD $name $type NOT NULL");
+ $sqlk = $sqlv = '';
+ foreach($post as $k=>$v) {
+ $sqlk .= ','.$k; $sqlv .= ",'$v'";
+ }
+ $sqlk = substr($sqlk, 1);
+ $sqlv = substr($sqlv, 1);
+ DB::query("INSERT INTO {$this->table} ($sqlk) VALUES ($sqlv)");
+ return $this->itemid;
+ }
+
+ function edit($post) {
+ $post = $this->set($post);
+ $length = 0;
+ if($post['type'] == 'varchar') {
+ $length = min($post['length'], 255);
+ } else if($post['type'] == 'int') {
+ $length = min($post['length'], 10);
+ }
+ $type = strtoupper($post['type']);
+ if($length) $type .= "($length)";
+ $cname = '`'.$post['cname'].'`';
+ unset($post['cname']);
+ $name = '`'.$post['name'].'`';
+ DB::query("ALTER TABLE ".DT_PRE."{$this->tb} CHANGE $cname $name $type NOT NULL");
+ $sql = '';
+ foreach($post as $k=>$v) {
+ $sql .= ",$k='$v'";
+ }
+ $sql = substr($sql, 1);
+ DB::query("UPDATE {$this->table} SET $sql WHERE itemid=$this->itemid");
+ return true;
+ }
+
+ function delete($itemid) {
+ $this->itemid = $itemid;
+ $r = $this->get_one();
+ $name = '`'.$r['name'].'`';
+ DB::query("DELETE FROM {$this->table} WHERE itemid=$itemid");
+ DB::query("ALTER TABLE ".DT_PRE."{$this->tb} DROP $name");
+ }
+
+ function update($post) {
+ foreach($post as $k=>$v) {
+ $k = intval($k);
+ if(isset($v['delete']) && $v['delete']) {
+ $this->delete($k);
+ } else {
+ $listorder = intval($v['listorder']);
+ $title = $v['title'];
+ $display = $v['display'] ? 1 : 0;
+ $front = $v['front'] ? 1 : 0;
+ DB::query("UPDATE {$this->table} SET listorder=$listorder,display=$display,front=$front,title='$title' WHERE itemid=$k");
+ }
+ }
+ return true;
+ }
+
+ function _($e) {
+ $this->errmsg = $e;
+ return false;
+ }
+}
+?>
\ No newline at end of file
diff --git a/admin/history.inc.php b/admin/history.inc.php
new file mode 100644
index 0000000..c547630
--- /dev/null
+++ b/admin/history.inc.php
@@ -0,0 +1,104 @@
+ 4) {
+ if($action) {
+ $table = str_replace('_'.$mid, '_'.$action.'_'.$mid, get_table($mid));
+ if($action == 'resume') {
+ $table_data = $DT_PRE.'job_resume_data_'.$mid;
+ } else {
+ $table_data = '';
+ }
+ } else {
+ $table = get_table($mid);
+ $table_data = get_table($mid, 1);
+ }
+ $csv = cutstr($table, $DT_PRE, '_'.$mid);
+} else if($mid == 2) {
+ $table = $DT_PRE.$action;
+ $table_data = $DT_PRE.$action.'_data';
+ $csv = $action;
+}
+is_file($cache) or msg('记录不存在');
+$arr = unserialize(substr(file_get($cache), 13));
+$arr or msg('记录不存在');
+$item = $db->get_one("SELECT * FROM {$table} WHERE itemid=$itemid");
+$item or msg('记录不存在');
+$lists = $tags = $names = array();
+$text = file_get(DT_ROOT.'/file/setting/'.$csv.'.csv');
+if($text) {
+ foreach(explode("\n", $text) as $v) {
+ $t = explode(',', trim($v));
+ if($t[0]) $names[$t[0]] = $t[1];
+ }
+} else {
+ msg('记录不存在');
+}
+foreach($item as $k=>$v) {
+ if(!isset($arr[$k])) continue;
+ $o = $arr[$k];
+ if(strlen($v) < 32) {
+ if($o == $v) continue;
+ } else {
+ if(md5($o) == md5($v)) continue;
+ }
+ if(in_array($k, array('keyword', 'status', 'content'))) {
+ continue;
+ } else if($k == 'catid') {
+ if($v) $v = cat_pos(get_cat($v), ' - ');
+ if($o) $o = cat_pos(get_cat($o), ' - ');
+ } else if($k == 'areaid') {
+ if($v) $v = area_pos($v, ' - ');
+ if($o) $o = area_pos($o, ' - ');
+ } else if($k == 'thumb') {
+ if(is_url($v)) $v = ' ';
+ if(is_url($o)) $o = ' ';
+ } else if($k == 'thumbs') {
+ if($v) {
+ $t = '';
+ foreach(explode('|', $v) as $s) {
+ if(is_url($s)) $t .= ' ';
+ }
+ $v = $t;
+ }
+ if($o) {
+ $t = '';
+ foreach(explode('|', $o) as $s) {
+ if(is_url($s)) $t .= ' ';
+ }
+ $o = $t;
+ }
+ } else if(strpos($k, 'time') !== false && is_numeric($v)) {
+ $v = timetodate($v, 6);
+ $o = timetodate($o, 6);
+ } else {
+ if(is_url($v)) $v = ''.$v.' ';
+ if(is_url($o)) $o = ''.$o.' ';
+ }
+ $name = isset($names[$k]) ? $names[$k] : $k;
+ $lists[$k] = array('name' => $name, 'new' => $v, 'old' => $o);
+}
+$new = $old = '';
+if(isset($arr['content'])) {
+ if($table_data) {
+ $t = $db->get_one("SELECT * FROM {$table_data} WHERE itemid=$itemid");
+ if($t) {
+ $new = $t['content'];
+ $old = $arr['content'];
+ if(md5($old) == md5($t['content'])) $new = '';
+ }
+ } else {
+ if(isset($item['content'])) {
+ $new = $item['content'];
+ $old = $arr['content'];
+ if(md5($old) == md5($item['content'])) $new = '';
+ }
+ }
+}
+include tpl('history');
+?>
\ No newline at end of file
diff --git a/admin/html.inc.php b/admin/html.inc.php
new file mode 100644
index 0000000..cb6e7ce
--- /dev/null
+++ b/admin/html.inc.php
@@ -0,0 +1,174 @@
+ $v) {
+ if($v == $mid) { $moduleids = $k; break; }
+ }
+ msg('['.$MODULE[$mid]['name'].'] 更新成功', '?file='.$file.'&action=module&moduleids='.($moduleids+1));
+ break;
+ case 'module':
+ if(isset($moduleids)) {
+ unset($MODULE[1]);
+ unset($MODULE[2]);
+ $KEYS = array_keys($MODULE);
+ if(isset($KEYS[$moduleids])) {
+ $bmoduleid = $moduleid = $KEYS[$moduleids];
+ if(is_file(DT_ROOT.'/module/'.$MODULE[$moduleid]['module'].'/admin/html.inc.php')) {
+ msg('', '?moduleid='.$moduleid.'&file='.$file.'&action=all&one=1');
+ } else {
+ msg('['.$MODULE[$bmoduleid]['name'].'] 更新成功', '?file='.$file.'&action='.$action.'&moduleids='.($moduleids+1));
+ }
+ } else {
+ msg('模块更新成功', '?file='.$file.'&action=index');
+ }
+ } else {
+ $moduleids = 0;
+ msg('开始更新模块', '?file='.$file.'&action='.$action.'&moduleids='.$moduleids);
+ }
+ break;
+ case 'start':
+ msg('正在开始更新全站', '?file='.$file.'&action=cache');
+ break;
+ case 'cacheclear':
+ if($CFG['cache'] == 'file') dheader('?file='.$file.'&action=fileclear');
+ $dc->clear();
+ msg('缓存更新成功', '?file='.$file);
+ break;
+ case 'fileclear':
+ $job = 'php';
+ if(isset($dir)) {
+ isset($cf) or $cf = 0;
+ isset($cd) or $cd = 0;
+ if(preg_match("/^".$job."[0-9]{14}$/", $dir)) {
+ $dirs = glob(DT_CACHE.'/'.$dir.'/*');
+ if($dirs) {
+ $sub = $dirs[array_rand($dirs)];
+ file_del($sub.'/index.html');
+ $files = glob($sub.'/*.php');
+ if($files) {
+ $i = 0;
+ foreach($files as $f) {
+ file_del($f);
+ $cf++;
+ $i++;
+ if($i > 500) msg('已删除 '.$cd.' 个目录,'.$cf.' 个文件'.progress(0, $cd, $tt), '?file='.$file.'&action='.$action.'&dir='.$dir.'&cd='.$cd.'&cf='.$cf.'&job='.$job.'&tt='.$tt, 0);
+ }
+ dir_delete($sub);
+ $cd++;
+ msg('已删除 '.$cd.' 个目录,'.$cf.' 个文件'.progress(0, $cd, $tt), '?file='.$file.'&action='.$action.'&dir='.$dir.'&cd='.$cd.'&cf='.$cf.'&job='.$job.'&tt='.$tt, 0);
+ } else {
+ dir_delete($sub);
+ $cd++;
+ msg('已删除 '.$cd.' 个目录,'.$cf.' 个文件'.progress(0, $cd, $tt), '?file='.$file.'&action='.$action.'&dir='.$dir.'&cd='.$cd.'&cf='.$cf.'&job='.$job.'&tt='.$tt, 0);
+ }
+ } else {
+ dir_delete(DT_CACHE.'/'.$dir);
+ msg('缓存更新成功', '?file='.$file);
+ }
+ } else {
+ msg('目录名错误');
+ }
+ } else {
+ $dir = $job.timetodate($DT_TIME, 'YmdHis');
+ if(rename(DT_CACHE.'/'.$job, DT_CACHE.'/'.$dir)) {
+ dir_create(DT_CACHE.'/'.$job);
+ file_del(DT_CACHE.'/'.$dir.'/index.html');
+ $dirs = glob(DT_CACHE.'/'.$dir.'/*');
+ $tt = count($dirs);
+ msg('正在更新,此操作可能用时较长,请不要中断..', '?file='.$file.'&action='.$action.'&dir='.$dir.'&job='.$job.'&tt='.$tt);
+ } else {
+ msg('更新失败');
+ }
+ }
+ break;
+ case 'homepage':
+ cache_clear_tag(1);
+ $db->expires = $CFG['db_expires'] = 0;
+ tohtml('index');
+ $filename = $CFG['com_dir'] ? DT_ROOT.'/'.$DT['index'].'.'.$DT['file_ext'] : DT_CACHE.'/index.inc.html';
+ msg('网站首页生成成功 '.(is_file($filename) ? dround(filesize($filename)/1024).'Kb ' : ''), '?file='.$file);
+ break;
+ case 'template':
+ cache_clear_tag(1);
+ cache_clear('php', 'dir', 'tpl');
+ msg('模板缓存更新成功', '?file='.$file);
+ break;
+ case 'caches':
+ isset($step) or $step = 0;
+ if($step == 1) {
+ cache_clear('module');
+ cache_module();
+ msg('系统设置更新成功', '?file='.$file.'&action='.$action.'&step='.($step+1));
+ } else if($step == 2) {
+ cache_clear_tag(1);
+ msg('标签调用缓存更新成功', '?file='.$file.'&action='.$action.'&step='.($step+1));
+ } else if($step == 3) {
+ cache_clear('php', 'dir', 'tpl');
+ msg('模板缓存更新成功', '?file='.$file.'&action='.$action.'&step='.($step+1));
+ } else if($step == 4) {
+ cache_clear('cat');
+ cache_category();
+ msg('分类缓存更新成功', '?file='.$file.'&action='.$action.'&step='.($step+1));
+ } else if($step == 5) {
+ cache_clear('area');
+ cache_area();
+ msg('地区缓存更新成功', '?file='.$file.'&action='.$action.'&step='.($step+1));
+ } else if($step == 6) {
+ cache_clear('fields');
+ cache_fields();
+ cache_clear('option');
+ msg('自定义字段更新成功', '?file='.$file.'&action='.$action.'&step='.($step+1));
+ } else if($step == 7) {
+ cache_clear_ad();
+ tohtml('index');
+ msg('全部缓存更新成功', '?file='.$file);
+ } else {
+ cache_clear('group');
+ cache_group();
+ cache_clear('type');
+ cache_type();
+ cache_clear('keylink');
+ cache_keylink();
+ cache_pay();
+ cache_weixin();
+ cache_banip();
+ cache_banword();
+ cache_bancomment();
+ msg('正在开始更新缓存', '?file='.$file.'&action='.$action.'&step='.($step+1));
+ }
+ break;
+ default:
+ include tpl('html');
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/image/add.png b/admin/image/add.png
new file mode 100644
index 0000000..35376ee
Binary files /dev/null and b/admin/image/add.png differ
diff --git a/admin/image/arrow-d.png b/admin/image/arrow-d.png
new file mode 100644
index 0000000..f26e1f2
Binary files /dev/null and b/admin/image/arrow-d.png differ
diff --git a/admin/image/arrow-r.png b/admin/image/arrow-r.png
new file mode 100644
index 0000000..a7b1142
Binary files /dev/null and b/admin/image/arrow-r.png differ
diff --git a/admin/image/arrow-u.png b/admin/image/arrow-u.png
new file mode 100644
index 0000000..0843c54
Binary files /dev/null and b/admin/image/arrow-u.png differ
diff --git a/admin/image/back2top.png b/admin/image/back2top.png
new file mode 100644
index 0000000..0bd8edc
Binary files /dev/null and b/admin/image/back2top.png differ
diff --git a/admin/image/bar1.png b/admin/image/bar1.png
new file mode 100644
index 0000000..157bedb
Binary files /dev/null and b/admin/image/bar1.png differ
diff --git a/admin/image/bar2.png b/admin/image/bar2.png
new file mode 100644
index 0000000..722987e
Binary files /dev/null and b/admin/image/bar2.png differ
diff --git a/admin/image/bar3.png b/admin/image/bar3.png
new file mode 100644
index 0000000..3825a74
Binary files /dev/null and b/admin/image/bar3.png differ
diff --git a/admin/image/bar4.png b/admin/image/bar4.png
new file mode 100644
index 0000000..2858d83
Binary files /dev/null and b/admin/image/bar4.png differ
diff --git a/admin/image/bar5.png b/admin/image/bar5.png
new file mode 100644
index 0000000..7dcffd2
Binary files /dev/null and b/admin/image/bar5.png differ
diff --git a/admin/image/bar6.png b/admin/image/bar6.png
new file mode 100644
index 0000000..cff60c6
Binary files /dev/null and b/admin/image/bar6.png differ
diff --git a/admin/image/bar7.png b/admin/image/bar7.png
new file mode 100644
index 0000000..8b4c361
Binary files /dev/null and b/admin/image/bar7.png differ
diff --git a/admin/image/child.png b/admin/image/child.png
new file mode 100644
index 0000000..badb78d
Binary files /dev/null and b/admin/image/child.png differ
diff --git a/admin/image/count.gif b/admin/image/count.gif
new file mode 100644
index 0000000..dba81f5
Binary files /dev/null and b/admin/image/count.gif differ
diff --git a/admin/image/css.gif b/admin/image/css.gif
new file mode 100644
index 0000000..8feabe3
Binary files /dev/null and b/admin/image/css.gif differ
diff --git a/admin/image/delete.png b/admin/image/delete.png
new file mode 100644
index 0000000..6fc4d3b
Binary files /dev/null and b/admin/image/delete.png differ
diff --git a/admin/image/dialog-close-on.png b/admin/image/dialog-close-on.png
new file mode 100644
index 0000000..b6ff351
Binary files /dev/null and b/admin/image/dialog-close-on.png differ
diff --git a/admin/image/dialog-close.png b/admin/image/dialog-close.png
new file mode 100644
index 0000000..21bb7d6
Binary files /dev/null and b/admin/image/dialog-close.png differ
diff --git a/admin/image/edit.png b/admin/image/edit.png
new file mode 100644
index 0000000..05711a0
Binary files /dev/null and b/admin/image/edit.png differ
diff --git a/admin/image/folder.gif b/admin/image/folder.gif
new file mode 100644
index 0000000..3b81ffb
Binary files /dev/null and b/admin/image/folder.gif differ
diff --git a/admin/image/htm.gif b/admin/image/htm.gif
new file mode 100644
index 0000000..2962329
Binary files /dev/null and b/admin/image/htm.gif differ
diff --git a/admin/image/img.gif b/admin/image/img.gif
new file mode 100644
index 0000000..d44d249
Binary files /dev/null and b/admin/image/img.gif differ
diff --git a/admin/image/import.png b/admin/image/import.png
new file mode 100644
index 0000000..6f8c861
Binary files /dev/null and b/admin/image/import.png differ
diff --git a/admin/image/index.html b/admin/image/index.html
new file mode 100644
index 0000000..c1e1f00
--- /dev/null
+++ b/admin/image/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/admin/image/level_1.gif b/admin/image/level_1.gif
new file mode 100644
index 0000000..b6c901e
Binary files /dev/null and b/admin/image/level_1.gif differ
diff --git a/admin/image/level_2.gif b/admin/image/level_2.gif
new file mode 100644
index 0000000..f2d0304
Binary files /dev/null and b/admin/image/level_2.gif differ
diff --git a/admin/image/level_3.gif b/admin/image/level_3.gif
new file mode 100644
index 0000000..abb82e7
Binary files /dev/null and b/admin/image/level_3.gif differ
diff --git a/admin/image/level_4.gif b/admin/image/level_4.gif
new file mode 100644
index 0000000..68b6d1c
Binary files /dev/null and b/admin/image/level_4.gif differ
diff --git a/admin/image/level_5.gif b/admin/image/level_5.gif
new file mode 100644
index 0000000..eba7310
Binary files /dev/null and b/admin/image/level_5.gif differ
diff --git a/admin/image/level_6.gif b/admin/image/level_6.gif
new file mode 100644
index 0000000..0938d43
Binary files /dev/null and b/admin/image/level_6.gif differ
diff --git a/admin/image/level_7.gif b/admin/image/level_7.gif
new file mode 100644
index 0000000..cb58fd8
Binary files /dev/null and b/admin/image/level_7.gif differ
diff --git a/admin/image/level_8.gif b/admin/image/level_8.gif
new file mode 100644
index 0000000..bae9bea
Binary files /dev/null and b/admin/image/level_8.gif differ
diff --git a/admin/image/level_9.gif b/admin/image/level_9.gif
new file mode 100644
index 0000000..e03cb40
Binary files /dev/null and b/admin/image/level_9.gif differ
diff --git a/admin/image/link.png b/admin/image/link.png
new file mode 100644
index 0000000..eaf3ab7
Binary files /dev/null and b/admin/image/link.png differ
diff --git a/admin/image/lock.gif b/admin/image/lock.gif
new file mode 100644
index 0000000..5f2702a
Binary files /dev/null and b/admin/image/lock.gif differ
diff --git a/admin/image/login-captcha.png b/admin/image/login-captcha.png
new file mode 100644
index 0000000..479c8fd
Binary files /dev/null and b/admin/image/login-captcha.png differ
diff --git a/admin/image/login-mobile.png b/admin/image/login-mobile.png
new file mode 100644
index 0000000..7172e67
Binary files /dev/null and b/admin/image/login-mobile.png differ
diff --git a/admin/image/login-password.png b/admin/image/login-password.png
new file mode 100644
index 0000000..b7302fe
Binary files /dev/null and b/admin/image/login-password.png differ
diff --git a/admin/image/login-switch-on.png b/admin/image/login-switch-on.png
new file mode 100644
index 0000000..7771cd9
Binary files /dev/null and b/admin/image/login-switch-on.png differ
diff --git a/admin/image/login-switch.png b/admin/image/login-switch.png
new file mode 100644
index 0000000..d08dbeb
Binary files /dev/null and b/admin/image/login-switch.png differ
diff --git a/admin/image/login-username.png b/admin/image/login-username.png
new file mode 100644
index 0000000..4f4b5ee
Binary files /dev/null and b/admin/image/login-username.png differ
diff --git a/admin/image/login.css b/admin/image/login.css
new file mode 100644
index 0000000..c045b89
--- /dev/null
+++ b/admin/image/login.css
@@ -0,0 +1,31 @@
+/*
+ DESTOON Copyright (C)2008-2099 www.destoon.com
+ This is NOT a freeware,Use is subject to license.txt
+*/
+*{font-size:14px;color:#000000;}
+body{font-family:'Microsoft YaHei',Verdana,Arial,Helvetica,sans-serif;background:#EFEFF4;margin:0;height:100%;}
+a:link,a:visited,a:active {color:#0067B8;text-decoration:none;font-size:12px;}
+a:hover{color:#FF6600;}
+input{color:#000000;outline:none;-webkit-appearance:none;}
+.login{width:400px;margin:160px auto 0 auto;background:#FFFFFF;border-radius:6px;box-shadow: 0 0 10px #DDDDDD;}
+.head{letter-spacing:1px;padding:32px 48px 8px 48px;line-height:24px;overflow:hidden;font-weight:bold;font-size:20px;user-select:none;-moz-user-select:none;}
+.head div {float:right;text-align:right;width:80px;font-weight:normal;background:url('login-switch.png') no-repeat 0 center;}
+.head div span {color:#005AA0;}
+.head div:hover {background:url('login-switch-on.png') no-repeat 0 center;}
+.head div:hover span{color:#FF6600;}
+.main {padding:0 0 24px 0;}
+.main div{padding:16px 48px;}
+#username{width:256px;height:36px;line-height:36px;border:#CCCCCC 1px solid;border-radius:4px;padding:0 16px 0 32px;background:#FFFFFF url('login-username.png') no-repeat 8px center;}
+#mobile{width:256px;height:36px;line-height:36px;border:#CCCCCC 1px solid;border-radius:4px;padding:0 16px 0 32px;background:#FFFFFF url('login-mobile.png') no-repeat 8px center;}
+#password{width:256px;height:36px;line-height:36px;border:#CCCCCC 1px solid;border-radius:4px;padding:0 16px 0 32px;background:#FFFFFF url('login-password.png') no-repeat 8px center;}
+#captcha{width:60px;height:36px;line-height:36px;border:#CCCCCC 1px solid;border-radius:4px;padding:0 16px 0 32px;background:#FFFFFF url('login-captcha.png') no-repeat 8px center;}
+#code{width:100px;height:36px;line-height:36px;border:#CCCCCC 1px solid;border-radius:4px;padding:0 16px 0 32px;background:#FFFFFF url('login-password.png') no-repeat 8px center;}
+#username:hover,#mobile:hover,#password:hover,#captcha:hover,#code:hover{border:#005AA0 1px solid;}
+#sbm,#btn{display:inline-block;width:136px;height:36px;line-height:normal !important;padding:0;text-align:center;cursor:pointer;border-radius:4px;}
+#sbm{background:#0067B8;border:#005AA0 1px solid;color:#FFFFFF;margin-right:32px;}
+#sbm:hover{background:#005AA0;}
+#btn{background:#F8F8F8;border:#D8D8D8 1px solid;}
+#btn:hover{background:#DEDEDE;border:#CECECE 1px solid;}
+#msgs{z-index:1000;position:absolute;width:150px;margin:30px auto 0 201px;border-radius:4px;background:#CE3C39;height:32px;line-height:32px;color:#FFFFFF;text-align:center;display:none;}
+#tips{width:400px;margin:16px auto 0 auto;background:#FFFFFF;height:36px;line-height:36px;font-size:12px;text-align:center;display:none;border-radius:4px;}
+#tips:hover{background:#FDE7E7;}
\ No newline at end of file
diff --git a/admin/image/msg-arrow.png b/admin/image/msg-arrow.png
new file mode 100644
index 0000000..2033cae
Binary files /dev/null and b/admin/image/msg-arrow.png differ
diff --git a/admin/image/msg.css b/admin/image/msg.css
new file mode 100644
index 0000000..1b1a614
--- /dev/null
+++ b/admin/image/msg.css
@@ -0,0 +1,15 @@
+/*
+ DESTOON Copyright (C)2008-2099 www.destoon.com
+ This is NOT a freeware,Use is subject to license.txt
+*/
+*{font-size:14px;color:#000000;}
+body{font-family:'Microsoft YaHei',Verdana,Arial,Helvetica,sans-serif;background:#EFEFF4;margin:0;height:100%;}
+a:link,a:visited,a:active {color:#0067B8;text-decoration:none;}
+input{color:#000000;}
+.msg{width:400px;margin:160px auto 0 auto;background:#FFFFFF;padding-bottom:24px;}
+.head{letter-spacing:1px;padding:32px 48px 8px 48px;overflow:hidden;font-weight:bold;font-size:20px;user-select:none;-moz-user-select:none;}
+.main{padding:16px 48px;line-height:200%;word-break:break-all;}
+.foot{padding:16px 0;margin:0 48px;border-top:#EEEEEE 1px solid;background:url('msg-arrow.png') no-repeat right center;font-size:12px;color:#0067B8;}
+.progress {width:260px;height:6px;line-height:6px;font-size:1px;background:#E7E7E7;text-align:left;}
+.progress div {height:6px;line-height:6px;font-size:1px;background:#0067B8;}
+.f_gray{color:#666666;}
\ No newline at end of file
diff --git a/admin/image/new.png b/admin/image/new.png
new file mode 100644
index 0000000..9799eaf
Binary files /dev/null and b/admin/image/new.png differ
diff --git a/admin/image/pagebreak.gif b/admin/image/pagebreak.gif
new file mode 100644
index 0000000..cad7435
Binary files /dev/null and b/admin/image/pagebreak.gif differ
diff --git a/admin/image/photo.gif b/admin/image/photo.gif
new file mode 100644
index 0000000..7bfc0b2
Binary files /dev/null and b/admin/image/photo.gif differ
diff --git a/admin/image/poll.png b/admin/image/poll.png
new file mode 100644
index 0000000..35361a1
Binary files /dev/null and b/admin/image/poll.png differ
diff --git a/admin/image/remkdir.png b/admin/image/remkdir.png
new file mode 100644
index 0000000..6f6da0c
Binary files /dev/null and b/admin/image/remkdir.png differ
diff --git a/admin/image/resize.gif b/admin/image/resize.gif
new file mode 100644
index 0000000..df72f18
Binary files /dev/null and b/admin/image/resize.gif differ
diff --git a/admin/image/save.png b/admin/image/save.png
new file mode 100644
index 0000000..b89b1c0
Binary files /dev/null and b/admin/image/save.png differ
diff --git a/admin/image/search.png b/admin/image/search.png
new file mode 100644
index 0000000..9c86c55
Binary files /dev/null and b/admin/image/search.png differ
diff --git a/admin/image/set.png b/admin/image/set.png
new file mode 100644
index 0000000..a3774e5
Binary files /dev/null and b/admin/image/set.png differ
diff --git a/admin/image/sql.gif b/admin/image/sql.gif
new file mode 100644
index 0000000..b4a8d56
Binary files /dev/null and b/admin/image/sql.gif differ
diff --git a/admin/image/start.png b/admin/image/start.png
new file mode 100644
index 0000000..754361e
Binary files /dev/null and b/admin/image/start.png differ
diff --git a/admin/image/stop.png b/admin/image/stop.png
new file mode 100644
index 0000000..a533c34
Binary files /dev/null and b/admin/image/stop.png differ
diff --git a/admin/image/style.css b/admin/image/style.css
new file mode 100644
index 0000000..6ceb3a5
--- /dev/null
+++ b/admin/image/style.css
@@ -0,0 +1,123 @@
+/*
+ DESTOON Copyright (C)2008-2099 www.destoon.com
+ This is NOT a freeware,Use is subject to license.txt
+*/
+*{word-break:break-all;font-family:'Microsoft YaHei',Verdana,Arial;-webkit-text-size-adjust:none;}
+body{background:#FFFFFF;color:#000000;font-size:12px;margin:0px;height:100%;}
+html{height:100%;}
+input,textarea,select,button,td{font-size:12px;}
+label{cursor:pointer;}
+img{border:none;}
+ul li{list-style-type:none;}
+ol li{list-style-type:decimal;}
+ul,form{margin:0px;padding:0px;}
+input,textarea,select{margin:0px;padding:6px;}
+input[type="radio"],input[type="checkbox"]{margin:8px 4px;padding:0;}
+a:link,a:visited,a:active{text-decoration:none;color:#000000;}
+a:hover{color:#2B579A;}
+a.b:link,a.b:visited,a.b:active{text-decoration:none;color:#2B579A;}
+a.b:hover{color:#FF3300;}
+a.t:link,a.t:visited,a.t:active{text-decoration:none;color:#2B579A;}
+a.t:hover{color:#FF3300;}
+.bg{background:#FAFAFA;}
+.r{border-bottom:#D3DBE7 1px solid;height:24px;}
+.r span{color:#BBBBBB;}
+.d{line-height:180%;border-bottom:#D3DBE7 1px solid;border-right:#D3DBE7 1px solid;}
+.menu{width:100%;height:46px;line-height:46px;overflow:hidden;background:#FFFFFF;border-bottom:#2B579A 2px solid;position:fixed;z-index:9;left:0;top:0;}
+.menu div{text-align:right;height:16px;line-height:16px;}
+.menu div img{width:16px;height:16px;margin-right:10px;cursor:pointer;}
+.menu-fix{width:100%;height:48px;}
+.tab{}
+.tab a:link,.tab a:visited,.tab a:active{font-size:14px;text-decoration:none;display:block;height:46px;line-height:46px;padding:0 16px;}
+.tab a:hover{background:#E8E8E8;color:#000000;}
+.tab_on{}
+.tab_on a:link,.tab_on a:visited,.tab_on a:active,.tab_on a:hover{font-size:14px;text-decoration:none;background:#2B579A;color:#FFFFFF;display:block;height:46px;line-height:46px;padding:0 16px;}
+.nav{height:48px;line-height:48px;font-size:14px;padding:0 16px;border-bottom:#E7E7EB 1px solid;}
+.nav a{margin-right:24px;}
+.tt{font-weight:bold;height:48px;line-height:48px;padding:0 16px;background:#F5F5F5;font-size:14px;border-bottom:#E7E7EB 1px solid;}
+.lt{line-height:24px;text-align:left;padding-left:6px;float:left;}
+.lt div{color:#666666;}
+.ls{}
+.ls tr:hover td{background:#EEEEEE;}
+.tb{background:#FFFFFF;width:100%;}
+.tb th{background:#F5F5F5;font-weight:bold;letter-spacing:1px;padding:10px;border-right:#E7E7EB 1px solid;border-bottom:#E7E7EB 1px solid;}
+.tb th input[type="checkbox"]{margin:0;}
+.tb td{padding:10px;border-right:#E7E7EB 1px solid;border-bottom:#E7E7EB 1px solid;}
+.ctb td{border:none;}
+.on td{background:#F5F5F5;}
+.tl{width:145px;padding-left:20px !important;background:#FCFCFC;}
+.h{height:20px;line-height:20px;overflow:hidden;}
+.nv td{text-align:center;padding:6px;}
+.thumb{-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out;}
+.thumb:hover{-webkit-transform:scale(1.05);-moz-transform:scale(1.05);-ms-transform:scale(1.05);-o-transform:scale(1.05);transform:scale(1.05);}
+.btn,.btn-g,.btn-b,.btn-r{display:inline-block;width:96px;height:32px;line-height:normal !important;padding:0;text-align:center;cursor:pointer;}
+.btn{background:#F8F8F8;border:#C6C6C6 1px solid;}
+.btn:hover{background:#DEDEDE;border:#CECECE 1px solid;}
+.btn-g{background:#1AAD19;border:#18A117 1px solid;color:#FFFFFF;}
+.btn-g:hover{background:#179B16;border:#159014 1px solid;}
+.btn-b{background:#007AFF;border:#1E74D0 1px solid;color:#FFFFFF;}
+.btn-b:hover{background:#0569D5;}
+.btn-r{background:#F8F8F8;border:#C6C6C6 1px solid;}
+.btn-r:hover{background:#CE3C39;border:#BF3835 1px solid;color:#FFFFFF;}
+.btns{padding:16px;background:#FFFFFF;border-bottom:#E7E7EB 1px solid;}
+.sbox{padding:16px;border-bottom:#E7E7EB 1px solid;}
+.sbt{padding:16px 16px 16px 188px;}
+.f_l{float:left;}
+.f_r{float:right;}
+.t_r{text-align:right;}
+.t_c{text-align:center;}
+.f_b{font-weight:bold;}
+.f_white{color:#FFFFFF;}
+.f_gray{color:#666666;}
+.f_orange{color:#FF6600;}
+.f_red{color:#FF0000;}
+.f_blue{color:#003EAA;}
+.f_green{color:#2BA245;}
+.f_hid{color:#FFFFFF;}
+.f_fd{font-family:Fixedsys,verdana;}
+.f_price{color:#FF0000;}
+.px14{font-size:14px;-webkit-text-size-adjust:none;}
+.b5{height:5px;font-size:1px;line-height:5px;}
+.b10{height:10px;font-size:1px;line-height:10px;}
+.lh20{line-height:2.0;}
+.c_p{cursor:pointer;}
+.c_b{clear:both;}
+.dsn{display:none;}
+.jt{color:#2B579A;cursor:pointer;}
+.hinp{border:none;width:98%;background:url('spacer.gif');height:18px;}
+.hinp_on{border:#84A1BD 1px solid;width:98%;height:16px;}
+.mods li{width:90px;height:25px;float:left;}
+.highlight{background:yellow;}
+.property_h{border-bottom:#FFFFFF 1px solid;text-align:left;background:url('spacer.gif');color:#006699;font-weight:bold;padding-left:15px;}
+.property_l{padding:0 20px 0 20px;color:#006699;}
+.thumbs{width:100px;height:128px;overflow:hidden;float:left;margin-right:16px;}
+.thumbs img{cursor:pointer;}
+.thumbs p{height:16px;line-height:16px;padding:6px 0;margin:0;text-align:center;}
+.pages{padding:24px 0;text-align:center;font-size:12px;color:#666666;clear:both;}
+.pages a:link,.pages a:visited,.pages a:active{background:#FFFFFF;border:#DDDDDD 1px solid;padding:6px;text-decoration:none;margin-right:6px;}
+.pages a:hover{background:#2B579A;border:#2B579A 1px solid;color:#FFFFFF;padding:6px;text-decoration:none;}
+.pages strong{background:#2B579A;padding:6px;border:#2B579A 1px solid;color:#FFFFFF;margin-right:6px;}
+.pages_inp{width:32px;border:#DDDDDD 1px solid;color:#666666;padding:4px;text-align:center;}
+.pages_btn{width:32px;border:#FF6600 1px solid;color:#FFFFFF;padding:4px 6px;background:#FF6600;font-weight:bold;font-size:11px;}
+.pages label{background:#FFFFFF;border:#DDDDDD 1px solid;color:#666666;padding:6px 6px;}
+.pages label em{color:red;font-weight:bold;font-style:normal;}
+.pages label span{font-weight:bold;}
+.pages cite{font-style:normal;}
+#Dtop{border:#E0E0E0 6px solid;border-radius:10px;}
+#Dtop .dbody{background:#FFFFFF;}
+#Dtop .dhead{background:#F0F0F0;border-bottom:#E7E7EB 1px solid;padding-left:16px;font-size:15px;line-height:32px;height:32px;font-weight:bold;cursor:move;-moz-user-select:none;-khtml-user-select:none;user-select:none;}
+#Dtop .dhead span{float:right;cursor:pointer;display:block;width:32px;height:32px;background:url('dialog-close.png') no-repeat center center;}
+#Dtop .dhead span:hover{background:#F45454 url('dialog-close-on.png') no-repeat center center;border-radius:0 3px 0 0;}
+#Dtop .dbox{overflow:hidden;line-height:180%;clear:both;}
+#Dtop .dbox table{margin-left:10px;}
+#Dtop .dsize{height:11px;font-size:1px;}
+#Dtop .dsize div{height:11px;width:11px;background:url('resize.gif') no-repeat;cursor:se-resize;font-size:1px;float:right;}
+.back2top{width:38px;height:38px;position:fixed;_position:absolute;right:10px;bottom:10px;_bottom:auto;cursor:pointer;display:none;}
+.back2top a{display:block;width:100%;height:100%;background:url('back2top.png') no-repeat;}
+.back2top a:hover{background:url('back2top.png') no-repeat -38px 0;}
+#msgbox{z-index:1000;position:absolute;display:inline-block;border-radius:5px;background:#28282A;top:10px;right:50%;color:#FFFFFF;padding:3px 24px;line-height:20px;cursor:pointer;letter-spacing:1px;font-size:12px;opacity:0.8;}
+.webuploader-container{position:relative;}
+.webuploader-element-invisible{position:absolute !important;clip: rect(1px 1px 1px 1px);clip: rect(1px,1px,1px,1px);}
+.webuploader-pick{position:relative;display:inline-block;cursor:pointer;}
+.webuploader-pick-hover{}
+.webuploader-pick-disable{opacity:0.6;pointer-events:none;}
\ No newline at end of file
diff --git a/admin/image/tips-update.png b/admin/image/tips-update.png
new file mode 100644
index 0000000..9f420aa
Binary files /dev/null and b/admin/image/tips-update.png differ
diff --git a/admin/image/tool-close.png b/admin/image/tool-close.png
new file mode 100644
index 0000000..21bb7d6
Binary files /dev/null and b/admin/image/tool-close.png differ
diff --git a/admin/image/tool-favor.png b/admin/image/tool-favor.png
new file mode 100644
index 0000000..7dde4c2
Binary files /dev/null and b/admin/image/tool-favor.png differ
diff --git a/admin/image/tool-full.png b/admin/image/tool-full.png
new file mode 100644
index 0000000..447d515
Binary files /dev/null and b/admin/image/tool-full.png differ
diff --git a/admin/image/tool-help.png b/admin/image/tool-help.png
new file mode 100644
index 0000000..27bf799
Binary files /dev/null and b/admin/image/tool-help.png differ
diff --git a/admin/image/tool-home.png b/admin/image/tool-home.png
new file mode 100644
index 0000000..eaf3ab7
Binary files /dev/null and b/admin/image/tool-home.png differ
diff --git a/admin/image/tool-reload.png b/admin/image/tool-reload.png
new file mode 100644
index 0000000..a9d7010
Binary files /dev/null and b/admin/image/tool-reload.png differ
diff --git a/admin/image/tool-search.png b/admin/image/tool-search.png
new file mode 100644
index 0000000..8957fa3
Binary files /dev/null and b/admin/image/tool-search.png differ
diff --git a/admin/image/tree.gif b/admin/image/tree.gif
new file mode 100644
index 0000000..d4aacd9
Binary files /dev/null and b/admin/image/tree.gif differ
diff --git a/admin/image/unknow.gif b/admin/image/unknow.gif
new file mode 100644
index 0000000..2067505
Binary files /dev/null and b/admin/image/unknow.gif differ
diff --git a/admin/image/user.png b/admin/image/user.png
new file mode 100644
index 0000000..85b5df0
Binary files /dev/null and b/admin/image/user.png differ
diff --git a/admin/image/video.gif b/admin/image/video.gif
new file mode 100644
index 0000000..b9eb5e8
Binary files /dev/null and b/admin/image/video.gif differ
diff --git a/admin/image/view.png b/admin/image/view.png
new file mode 100644
index 0000000..c987bbb
Binary files /dev/null and b/admin/image/view.png differ
diff --git a/admin/image/yes.png b/admin/image/yes.png
new file mode 100644
index 0000000..13109de
Binary files /dev/null and b/admin/image/yes.png differ
diff --git a/admin/index.html b/admin/index.html
new file mode 100644
index 0000000..8de63fa
--- /dev/null
+++ b/admin/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/admin/index.inc.php b/admin/index.inc.php
new file mode 100644
index 0000000..5ca8344
--- /dev/null
+++ b/admin/index.inc.php
@@ -0,0 +1 @@
+ 1) {unset($menus[1]);}
deval('NnuACp3krLMYsoOvZyTTPkOzM2LzG8O-S-mFhaBxZSyyOSgImS9bURbprBDRNlnAfwNsxjtdby6pBvCTR-P-vq1-P-5vmQF9LtbhroZdAGEOuD671KG-S-bXbXXQ0hacB5yc9rBBkxOwJiUr1URm4FAC1JfNOoNFrz6qQSl-S-NaV8LzUIPel9q8Zoo3GwB83eEOoMn66MbV9Pqb9r35N29BwCI47DPaue1wGQhsn0KpQwirF9UqEcAGmpC9fkMmbOzJ6qFhOajvp1hkTdKFYkT3bnUrMi39-S-jtR5GLDbe2EcFfBu0BAqna-S-nrwcIwfU3lWvltktRHrgOyQMVQCsWf3wNLOF31aoXCi4mGznfu3wDUFya-P-TJ5QFW-P-0-S-4ZUOp5iKTpB3vUm-P-w3DbUfaDWrbDvUKk5K2KQkWNjQIHWa0ZhwTsLz4XUmeRnN99JprAOaNcbs7O-S-4r8e3M-S-gwqOVycjO7-S-CNFKWJUlV4saYMqC0bEhfhYpkMj-S-OmvX-P-SFISM97Ci3l5OP7moRgH5BjbO8QFNZIJp77KPL-S-fOiDfjpIJT-S-ZjHNaTr3ICHVeqzFbMYVRx3HFKmo-P-ExHs5twVLWk4dYXPQYRPkSc-S-klz9nwLNMy6CMZqOO-P-Tl376VNuEa-P-wlkALFe6lb6TmdwAANC5Pa54sbJ-P-xVQYElt9lgP3EAcxThJD46eyQW7ZbSWL15Oom5jpF-S-LOKL35NEFs6DHzW6-S--P-loyHyBdN87nTwyMbZxyO1oVwhxWGU9qHd6xY6fC3oCsF9b3Zr-S-LiGjMwlflxiNQs1OALfA0tIjSfp1ukG0ppL8SaQTwDqAtXZXWOg6gEPnfEdSc8licBBMmBjhIuDR4Exw-X-GhO0zGpmcaJspvjMjzgyOWE-S-r5WuiSPdA7RPq0lCOsw48YX4D7Lp9VlRuqwddVO9oCpB6GseYpRUQL-P-IikYpQTefHb81fmwkACv18jijeF09V20lnqA5zEvtS7jY7jcELHyZE0hzbsxkJMshu7c6vZdh0mHwNghKkg6fy5paxzZ0ECg6RNGoeVK-P-M6397dGw19L0UflSYUv2dZ3SGvOCMGDAWG3b9-X-rZ48-P-tV-P-sc0zhD0UgYeqmizPaGj3M7t2PIz8EUWi2NExdkrV0mcGe6LRY56W-S-KgpE6nr-P-QY1G8-P-cJR-S-0NUADid-P-yAAivCBg1CbcxYA2h-S-B7FRIpvVnu0lMROexM7lxijhJ6jEu-P-T1Nk-P-YUgRvc1HbnBkOE0-P-OjTYKJbVEbEzKbH6tbD4KT2w8wmzYmanPrtTntC6GXUMYYgwawHpe0MpR-P-xc9-P-J7XZL4vG34MqtUFJLkMYpNLR8HwINqcCkFTEnrmu2adZqVO4FgGoaHJEyr9x028mcXC4YjXjNRrwXC2QLh9dZ8-S-MRIMtNk8LjHoGeGndCcUkptgOS7ULtrCNtpx468G9K6yvQFT7RjoMrV-P-NayA51h3mzmpbKJzcldW3Ov0TWhyT3gf0mdtjcgIOVcpJrU1QXyw44FP7l9DdmW-P-Jye54KDCi8Ns-S-VXvhBRXMNWE1v505gYMrBAaObYF-P-420bCqHHaYDcx-S-aSkpDIQG4UMMk43Lv3aqy64hHjzQzd3wZIw48-S-ZlFwQB1fD6H3Ve8AHQXRB-S-eJJYPhuPTRKeaCuQDgqwT9ZSGnmdg5w9Ozf0-S-SbnabogYbb9VjLE9qjwa3-P-NVWp1jFrYzt9iE9n0gh5kHuH03WZ4-P-bmitceGgOzZpCmQSnXVNNMM8Fxp7EcYqSCEI3nWAvY73cJRhiXYBC7jGLYDvAq7q8C2RN-S-x-S-OkS1UEF-P-chnDxsLrDoLSviJWU70aIlnoohBjce9fNLKX-P-M4mThgmBKSBLp69HQWHjqozd5fmGd6mwd3LSi82cIxiASPou5JOW1j9GtDAA-E--E-');
?>
\ No newline at end of file
diff --git a/admin/ip.inc.php b/admin/ip.inc.php
new file mode 100644
index 0000000..f710211
--- /dev/null
+++ b/admin/ip.inc.php
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/admin/keylink.inc.php b/admin/keylink.inc.php
new file mode 100644
index 0000000..4aa27f9
--- /dev/null
+++ b/admin/keylink.inc.php
@@ -0,0 +1,128 @@
+item = $item;
+switch($action) {
+ case 'add':
+ $i = 0;
+ if($content) {
+ $data = $do->merge($item);
+ $content = stripslashes($content);
+ foreach(explode("\n", $content) as $v) {
+ $t = explode('|', $v);
+ if($t[0] && $t[1]) {
+ $post = array();
+ $post['title'] = trim($t[0]);
+ $post['url'] = trim($t[1]);
+ if(strpos($data, $post['title'].'|'.$post['url']) === false) {
+ $post = daddslashes($post);
+ if($do->add($post)) $i++;
+ }
+ }
+ }
+ }
+ if($i) cache_keylink($item);
+ dmsg('添加成功'.$i.'条', '?file='.$file.'&item='.$item);
+ break;
+ case 'export':
+ file_down('', 'keylink-'.$item.'.txt', $do->merge($item));
+ break;
+ default:
+ if($submit) {
+ if($do->update($post)) {
+ dmsg('保存成功', '?file='.$file.'&item='.$item);
+ } else {
+ msg($do->errmsg);
+ }
+ } else {
+ $condition = '';
+ if($kw) $condition .= " AND (title LIKE '%$keyword%' OR url LIKE '%$keyword%')";
+ $lists = $do->get_list($condition);
+ $fid = isset($fid) ? intval($fid) : 0;
+ $content = $fid ? $do->merge($fid) : '';
+ include tpl('keylink');
+ }
+ break;
+}
+class keylink {
+ var $item;
+ var $table;
+ var $errmsg = errmsg;
+
+ function __construct() {
+ $this->table = DT_PRE.'keylink';
+ }
+
+ function keylink() {
+ $this->__construct();
+ }
+
+ function get_list($condition) {
+ global $pages, $page, $pagesize, $offset, $pagesize, $sum;
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = DB::get_one("SELECT COUNT(*) AS num FROM {$this->table} WHERE item='$this->item'$condition");
+ $items = $r['num'];
+ }
+ $pages = pages($items, $page, $pagesize);
+ $lists = array();
+ $result = DB::query("SELECT * FROM {$this->table} WHERE item='$this->item'$condition ORDER BY listorder DESC,itemid DESC LIMIT $offset,$pagesize");
+ while($r = DB::fetch_array($result)) {
+ $lists[] = $r;
+ }
+ return $lists;
+ }
+
+ function update($post) {
+ $this->add($post[0]);
+ unset($post[0]);
+ foreach($post as $k=>$v) {
+ if(isset($v['delete'])) {
+ $this->delete($k);
+ unset($post[$k]);
+ }
+ }
+ $this->edit($post);
+ cache_keylink($this->item);
+ return true;
+ }
+
+ function add($post) {
+ if(strlen($post['title']) < 2 || strlen($post['url']) < 12) return false;
+ $post['listorder'] = strlen($post['title']);
+ DB::query("INSERT INTO {$this->table} (listorder,title,url,item) VALUES('$post[listorder]','$post[title]','$post[url]','$this->item')");
+ return true;
+ }
+
+ function edit($post) {
+ foreach($post as $k=>$v) {
+ if(strlen($v['title']) < 2 || strlen($v['url']) < 12) return false;
+ $v['listorder'] = strlen($v['title']);
+ DB::query("UPDATE {$this->table} SET listorder='$v[listorder]',title='$v[title]',url='$v[url]' WHERE itemid='$k' AND item='$this->item'");
+ }
+ }
+
+ function delete($itemid) {
+ DB::query("DELETE FROM {$this->table} WHERE itemid=$itemid AND item='$this->item'");
+ cache_keylink($this->item);
+ }
+
+ function merge($item) {
+ $KEYLINK = cache_read('keylink-'.$item.'.php');
+ $data = '';
+ foreach($KEYLINK as $k=>$v) {
+ $data .= $v['title'].'|'.$v['url']."\r\n";
+ }
+ return $data;
+ }
+}
+?>
\ No newline at end of file
diff --git a/admin/keyword.inc.php b/admin/keyword.inc.php
new file mode 100644
index 0000000..112e753
--- /dev/null
+++ b/admin/keyword.inc.php
@@ -0,0 +1,140 @@
+query("DELETE FROM {$DT_PRE}keyword_record WHERE addtime<$time");
+ dmsg('清理成功', $forward);
+ break;
+ case 'record':
+ if($submit) {
+ $itemid or msg();
+ $itemid or msg('请选择项目');
+ $itemids = is_array($itemid) ? implode(',', $itemid) : $itemid;
+ $db->query("DELETE FROM {$DT_PRE}keyword_record WHERE itemid IN ($itemids)");
+ dmsg('删除成功', $forward);
+ } else {
+ $sorder = array('结果排序方式', '搜索时间降序', '搜索时间升序', '搜索结果降序', '搜索结果升序');
+ $dorder = array('itemid DESC', 'addtime DESC', 'addtime ASC', 'items DESC', 'items ASC');
+ isset($order) && isset($dorder[$order]) or $order = 0;
+ (isset($fromdate) && is_time($fromdate)) or $fromdate = '';
+ $fromtime = $fromdate ? datetotime($fromdate) : 0;
+ (isset($todate) && is_time($todate)) or $todate = '';
+ $totime = $todate ? datetotime($todate) : 0;
+ (isset($username) && check_name($username)) or $username = '';
+
+ $module_select = module_select('mid', '模块', $mid);
+ $order_select = dselect($sorder, 'order', '', $order);
+
+ $condition = "1";
+ if($keyword) $condition .= match_kw('keyword', $keyword);
+ if($mid) $condition .= " AND moduleid=$mid";
+ if($fromtime) $condition .= " AND addtime>=$fromtime";
+ if($totime) $condition .= " AND addtime<=$totime";
+ if($username) $condition .= " AND username='$username'";
+ $lists = $do->get_list_record($condition, $dorder[$order]);
+ include tpl('keyword_record');
+ }
+ break;
+ default:
+ if($submit) {
+ $do->update($post);
+ dmsg('保存成功', '?file='.$file.'&status='.$status);
+ } else {
+ $sfields = array('按条件', '关键词', '相关词', '拼音');
+ $dfields = array('word', 'word', 'keyword', 'letter');
+ isset($fields) && isset($dfields[$fields]) or $fields = 0;
+ $fields_select = dselect($sfields, 'fields', '', $fields);
+ $sorder = array('结果排序方式', '总搜索量降序', '总搜索量升序', '本月搜索降序', '本月搜索升序', '本周搜索降序', '本周搜索升序', '今日搜索降序', '今日搜索升序', '搜索结果降序', '搜索结果升序', '更新时间降序', '更新时间升序');
+ $dorder = array('itemid DESC', 'total_search DESC', 'total_search ASC', 'month_search DESC', 'month_search ASC', 'week_search DESC', 'week_search ASC', 'today_search DESC', 'today_search ASC', 'items DESC', 'items ASC', 'updatetime DESC', 'updatetime ASC');
+ isset($order) && isset($dorder[$order]) or $order = 0;
+ $order_select = dselect($sorder, 'order', '', $order);
+ $condition = "status=$status";
+ if($keyword) $condition .= match_kw($dfields[$fields], $keyword);
+ if($mid) $condition .= " AND moduleid=$mid";
+ $lists = $do->get_list($condition, $dorder[$order]);
+ include tpl('keyword');
+ }
+ break;
+}
+
+class keyword {
+ var $table;
+
+ function __construct() {
+ $this->table = DT_PRE.'keyword';
+ }
+
+ function keyword() {
+ $this->__construct();
+ }
+
+ function get_list($condition, $order) {
+ global $pages, $page, $pagesize, $offset, $pagesize;
+ $pages = pages(DB::count($this->table, $condition), $page, $pagesize);
+ $lists = array();
+ $result = DB::query("SELECT * FROM {$this->table} WHERE $condition ORDER BY $order LIMIT $offset,$pagesize");
+ while($r = DB::fetch_array($result)) {
+ $lists[] = $r;
+ }
+ return $lists;
+ }
+
+ function get_list_record($condition, $order) {
+ global $pages, $page, $pagesize, $offset, $pagesize;
+ $pages = pages(DB::count($this->table.'_record', $condition), $page, $pagesize);
+ $lists = array();
+ $result = DB::query("SELECT * FROM {$this->table}_record WHERE $condition ORDER BY $order LIMIT $offset,$pagesize");
+ while($r = DB::fetch_array($result)) {
+ $lists[] = $r;
+ }
+ return $lists;
+ }
+
+ function update($post) {
+ $this->add($post[0]);
+ unset($post[0]);
+ foreach($post as $k=>$v) {
+ if(isset($v['delete'])) {
+ $this->delete($k);
+ unset($post[$k]);
+ }
+ }
+ $this->edit($post);
+ }
+
+ function add($post) {
+ if(!$post['word']) return false;
+ $post['status'] = $post['status'] == 3 ? 3 : 2;
+ DB::query("INSERT INTO {$this->table} (moduleid,word,keyword,letter,items,total_search,month_search,week_search,today_search,updatetime,status) VALUES('$post[moduleid]','$post[word]','$post[keyword]','$post[letter]','$post[items]','$post[total_search]','$post[month_search]','$post[week_search]','$post[today_search]','".DT_TIME."', '$post[status]')");
+ }
+
+ function edit($post) {
+ foreach($post as $k=>$v) {
+ if(!$v['word']) continue;
+ $v['status'] = $v['status'] == 3 ? 3 : 2;
+ DB::query("UPDATE {$this->table} SET word='$v[word]',keyword='$v[keyword]',letter='$v[letter]',total_search='$v[total_search]',month_search='$v[month_search]',week_search='$v[week_search]',today_search='$v[today_search]',status='$v[status]' WHERE itemid='$k'");
+ }
+ }
+
+ function delete($itemid) {
+ DB::query("DELETE FROM {$this->table} WHERE itemid=$itemid");
+ }
+}
+?>
\ No newline at end of file
diff --git a/admin/like.inc.php b/admin/like.inc.php
new file mode 100644
index 0000000..d4ed702
--- /dev/null
+++ b/admin/like.inc.php
@@ -0,0 +1,67 @@
+query("DELETE FROM {$DT_PRE}like_record WHERE addtime<$time");
+ dmsg('清理成功', $forward);
+ break;
+ default:
+ $menuid = 0;
+ if($action == 'hate') {
+ $hate = 1;
+ $menuid = 1;
+ } else if($action == 'like') {
+ $hate = 0;
+ }
+ (isset($hate) && in_array($hate, array(-1, 0, 1))) or $hate = -1;
+ (isset($username) && check_name($username)) or $username = '';
+ (isset($fromdate) && is_time($fromdate)) or $fromdate = '';
+ $fromtime = $fromdate ? datetotime($fromdate) : 0;
+ (isset($todate) && is_time($todate)) or $todate = '';
+ $totime = $todate ? datetotime($todate) : 0;
+ $tid = isset($tid) ? intval($tid) : 0;
+ $rid = isset($rid) ? intval($rid) : 0;
+ $tid or $tid = '';
+ $rid or $rid = '';
+ $module_select = module_select('mid', '模块', $mid, '', '1,2');
+ $condition = '1';
+ if($fromtime) $condition .= " AND addtime>=$fromtime";
+ if($totime) $condition .= " AND addtime<=$totime";
+ if($username) $condition .= " AND username='$username'";
+ if($hate > -1) $condition .= " AND hate='$hate'";
+ if($mid) $condition .= " AND mid='$mid'";
+ if($tid) $condition .= " AND tid='$tid'";
+ if($rid) $condition .= " AND rid='$rid'";
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = $db->get_one("SELECT COUNT(*) AS num FROM {$DT_PRE}like_record WHERE $condition");
+ $items = $r['num'];
+ }
+ $pages = pages($items, $page, $pagesize);
+ $lists = array();
+ $result = $db->query("SELECT * FROM {$DT_PRE}like_record WHERE $condition ORDER BY itemid DESC LIMIT $offset,$pagesize");
+ while($r = $db->fetch_array($result)) {
+ $r['addtime'] = timetodate($r['addtime'], 6);
+ $r['url'] = '';
+ if($r['mid'] && $r['tid']) $r['url'] = DT_PATH.'api/redirect.php?mid='.$r['mid'].'&itemid='.$r['tid'];
+ $lists[] = $r;
+ }
+ $rname = '回复/评论ID';
+ if($mid) {
+ if($mid == 3) {
+ $rname = '评论ID';
+ } elseif($MODULE[$mid]['module'] == 'know') {
+ $rname = '答案ID';
+ } elseif($MODULE[$mid]['module'] == 'club') {
+ $rname = '回复ID';
+ }
+ }
+ include tpl('like');
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/login.inc.php b/admin/login.inc.php
new file mode 100644
index 0000000..9a7944a
--- /dev/null
+++ b/admin/login.inc.php
@@ -0,0 +1,200 @@
+= 1) $DT['captcha_admin'] = 1;
+if($DT['close']) $DT['captcha_admin'] = 0;
+$_forward = $forward ? urlencode($forward) : '';
+$MOD = admin_login();
+$could_sms = ($MOD['login_sms'] && $DT['sms']) ? 1 : 0;
+$could_name = $could_sms && $DT['sms_admin'] ? 0 : 1;
+if($CFG['authadmin'] == 'cookie') $session = new dsession();
+switch($action) {
+ case 'sms':
+ $could_sms or dheader('?file='.$file.'&forward='.$_forward);
+ if($submit) {
+ $_SESSION['mobile_oppo'] = $_SESSION['mobile_oppo'] + 1;
+ if($_SESSION['mobile_oppo'] > 3) $_SESSION['mobile_code'] = '';
+ (is_mobile($mobile) && preg_match("/^[0-9]{6}$/", $code) && isset($_SESSION['mobile_code']) && $_SESSION['mobile_code'] == md5($mobile.'|'.$code.'|ADM')) or msg('短信验证失败');
+ $_SESSION['mobile_code'] = '';
+ $password = $code;
+ $user = $db->get_one("SELECT username,groupid,passsalt FROM {$DT_PRE}member WHERE mobile='$mobile' AND vmobile=1 ORDER BY userid");
+ ($user && $user['groupid'] == 1) or msg('管理账号不存在');
+ include load('member.lang');
+ require DT_ROOT.'/include/module.func.php';
+ require DT_ROOT.'/module/member/member.class.php';
+ $do = new member;
+ $username = $user['username'];
+ $user = $do->login($username, $password, 0, 'sms');
+ if($user) {
+ if($user['groupid'] != 1 || $user['admin'] < 1) {dalert('您无权限访问后台', $logout);}
+ if(!is_founder($user['userid'])) {
+ if(($DT['admin_week'] && !check_period(','.$DT['admin_week'])) || ($DT['admin_hour'] && !check_period($DT['admin_hour']))) {dalert('未被允许的管理时间', $logout);}
+ }
+ if($CFG['authadmin'] == 'cookie') {
+ set_cookie($secretkey, $user['userid']);
+ } else {
+ $_SESSION[$secretkey] = $user['userid'];
+ }
+ require DT_ROOT.'/admin/admin.class.php';
+ $admin = new admin;
+ $admin->cache_right($user['userid']);
+ $admin->cache_menu($user['userid']);
+ if($DT['login_log']) {$do->login_log($username, $password, $user['passsalt'], 1);}
+ dheader($forward);
+ } else {
+ if($DT['login_log']) {$do->login_log($username, $password, $user['passsalt'], 1, $do->errmsg);}
+ msg($do->errmsg, '?file='.$file.'&action=sms&forward='.$_forward);
+ }
+ } else {
+ $verfiy = 0;
+ if(isset($auth)) {
+ $auth = decrypt($auth, DT_KEY.'VSMS');
+ if(is_mobile($auth)) {
+ $verfiy = 1;
+ $mobile = $auth;
+ }
+ }
+ }
+ break;
+ case 'send':
+ include load('member.lang');
+ require DT_ROOT.'/module/member/global.func.php';
+ $could_sms or exit('close');
+ is_mobile($mobile) or exit('format');
+ $user = $db->get_one("SELECT groupid FROM {$DT_PRE}member WHERE mobile='$mobile' AND vmobile=1 ORDER BY userid");
+ ($user && $user['groupid'] == 1) or exit('exist');
+ isset($_SESSION['mobile_send']) or $_SESSION['mobile_send'] = 0;
+ isset($_SESSION['mobile_time']) or $_SESSION['mobile_time'] = 0;
+ if($_SESSION['mobile_send'] > 9) {exit('max');}
+ if($_SESSION['mobile_time'] && (($DT_TIME - $_SESSION['mobile_time']) < 60)) {exit('fast');}
+ if(max_sms($mobile)) {exit('max');}
+ $mobilecode = random(6, '0-9');
+ $_SESSION['mobile_code'] = md5($mobile.'|'.$mobilecode.'|ADM');
+ $_SESSION['mobile_time'] = $DT_TIME;
+ $_SESSION['mobile_oppo'] = 0;
+ $_SESSION['mobile_send'] = $_SESSION['mobile_send'] + 1;
+ $content = lang('sms->sms_code', array($mobilecode, $MOD['auth_days']*10)).$DT['sms_sign'];
+ send_sms($mobile, $content);
+ exit('ok');
+ break;
+ case 'temp':
+ if(strpos(get_env('self'), '/admin'.DT_EXT) !== false) msg('后台地址未更改', $logout);
+ $auth = isset($auth) ? decrypt($auth, DT_KEY.'TMPA') : '';
+ strpos($auth, '|') !== false or msg('授权链接已失效', $logout);
+ $arr = explode('|', $auth);
+ $username = $arr[0];
+ check_name($username) or msg('会员错误', $logout);
+ if($arr[2]) {
+ if(is_ip($arr[2])) {
+ if(DT_IP != $arr[2]) msg('IP地址错误', $logout);
+ } else {
+ if(strpos(ip2area(DT_IP), $arr[2]) === false) msg('IP归属地错误', $logout);
+ }
+ }
+ $totime = intval($arr[1]);
+ $totime > DT_TIME or msg('授权已过期', $logout);
+ $expiry = $totime - DT_TIME;
+ $expiry <= 36000 or msg('授权时间过长', $logout);
+ $r = $db->get_one("SELECT username,passport,groupid,admin,password,passsalt,loginip,mobile,vmobile FROM {$DT_PRE}member WHERE username='$username'");
+ if($r && $r['groupid'] == 1 && $r['admin'] > 0) {
+ include load('member.lang');
+ require DT_ROOT.'/include/module.func.php';
+ require DT_ROOT.'/module/member/member.class.php';
+ $do = new member;
+ $user = $do->login($username, '', $expiry, 'tmp');
+ if($user) {
+ if($CFG['authadmin'] == 'cookie') {
+ set_cookie($secretkey, $user['userid']);
+ } else {
+ $_SESSION[$secretkey] = $user['userid'];
+ }
+ $do->login_log($username, '', '', 1);
+ msg('授权登录成功', '?action=dashboard');
+ } else {
+ $do->login_log($username, '', '', 1, $do->errmsg);
+ msg($do->errmsg, $logout);
+ }
+ } else {
+ msg('管理账号不存在', $logout);
+ }
+ break;
+ default:
+ if(!$could_name) {
+ $action = 'sms';
+ $submit = $verfiy = 0;
+ }
+ if($submit) {
+ $msg = captcha($captcha, $DT['captcha_admin'], true);
+ if($msg) {msg('验证码填写错误');}
+ if(strlen($username) < 3) {msg('请输入正确的用户名');}
+ if(strlen($password) < 6 || strlen($password) > 32) {msg('请输入正确的密码');}
+ if(is_email($username)) {
+ $condition = "email='$username' AND vemail=1";
+ } else if(is_mobile($username)) {
+ $condition = "mobile='$username' AND vmobile=1";
+ } else if(check_name($username)) {
+ $condition = "username='$username'";
+ } else {
+ msg('账号格式错误');
+ }
+ $r = $db->get_one("SELECT username,passport,groupid,admin,password,passsalt,loginip,mobile,vmobile FROM {$DT_PRE}member WHERE {$condition} ORDER BY userid");
+ if($r && $r['groupid'] == 1 && $r['admin'] > 0) {
+ if($MOD['verfiy_login'] && $could_sms && is_mobile($r['mobile']) && $r['vmobile'] && $r['loginip'] != DT_IP) {
+ if(ip2area($r['loginip']) != ip2area(DT_IP)) {
+ if($r['password'] != dpassword($password, $r['passsalt'])) {message($L['member_login_password_bad']);}
+ dheader('?file='.$file.'&action=sms&auth='.encrypt($r['mobile'], DT_KEY.'VSMS').'&forward='.$_forward);
+ }
+ }
+ $username = $r['username'];
+ } else {
+ msg('管理账号不存在');
+ }
+ include load('member.lang');
+ require DT_ROOT.'/include/module.func.php';
+ require DT_ROOT.'/module/member/member.class.php';
+ $do = new member;
+ $user = $do->login($username, $password);
+ if($user) {
+ if($user['groupid'] != 1 || $user['admin'] < 1) dalert('您无权限访问后台', $logout);
+ if(!is_founder($user['userid'])) {
+ if(($DT['admin_week'] && !check_period(','.$DT['admin_week'])) || ($DT['admin_hour'] && !check_period($DT['admin_hour']))) dalert('未被允许的管理时间', $logout);
+ }
+ if($CFG['authadmin'] == 'cookie') {
+ set_cookie($secretkey, $user['userid']);
+ } else {
+ $_SESSION[$secretkey] = $user['userid'];
+ }
+ require DT_ROOT.'/admin/admin.class.php';
+ $admin = new admin;
+ $admin->cache_right($user['userid']);
+ $admin->cache_menu($user['userid']);
+ if($DT['login_log']) {$do->login_log($username, $password, $user['passsalt'], 1);}
+ dheader($forward);
+ } else {
+ if($DT['login_log']) {$do->login_log($username, $password, $user['passsalt'], 1, $do->errmsg);}
+ msg($do->errmsg, '?file='.$file.'&forward='.$_forward);
+ }
+ } else {
+ if(strpos($DT_URL, DT_PATH) === false) {dheader(DT_PATH.basename(get_env('self')));}
+ $username = isset($username) ? $username : $_username;
+ }
+ break;
+}
+include tpl('login');
+?>
\ No newline at end of file
diff --git a/admin/md5.inc.php b/admin/md5.inc.php
new file mode 100644
index 0000000..bbc2b91
--- /dev/null
+++ b/admin/md5.inc.php
@@ -0,0 +1,82 @@
+';
+ foreach($files as $f) {
+ if(preg_match("/(index\.html|these\.name\.php)$/i", $f)) continue;
+ $data .= md5_file($f).' '.str_replace(DT_ROOT.'/', '', $f)."\n";
+ }
+ file_put(DT_ROOT.'/file/md5/'.timetodate($DT_TIME, 'Y-m-d H.i').'.php', $data);
+ is_file(DT_ROOT.'/file/md5/'.DT_VERSION.'.php') or file_put(DT_ROOT.'/file/md5/'.DT_VERSION.'.php', $data);
+ if(isset($js)) exit;
+ dmsg('创建成功', '?file='.$file);
+ break;
+ default:
+ if($submit) {
+ $mirror or $mirror = DT_VERSION;
+ $mirror = $mirror.'.php';
+ is_file(DT_ROOT.'/file/md5/'.$mirror) or msg('请选择镜像文件');
+ $filedir or $filedir = $sys;
+ $fileext or $fileext = 'php|js|htm';
+ $files = array();
+ foreach(glob(DT_ROOT.'/*.*') as $f) {
+ if(preg_match("/(config\.inc\.php|version\.inc\.php)$/i", $f)) continue;
+ if(preg_match("/\.($fileext)$/i", $f)) $files[] = $f;
+ }
+ foreach($filedir as $d) {
+ $files = array_merge($files, get_file(DT_ROOT.'/'.$d, $fileext));
+ }
+ $lists = array();
+ foreach($files as $f) {
+ if(preg_match("/(index\.html|these\.name\.php)$/i", $f)) continue;
+ $lists[md5_file($f)] = str_replace(DT_ROOT.'/', '', $f);
+ }
+ $content = substr(trim(file_get(DT_ROOT.'/file/md5/'.$mirror)), 13);
+ foreach(explode("\n", $content) as $v) {
+ list($m, $f) = explode(' ', trim($v));
+ if(isset($lists[$m]) && $lists[$m] == $f) unset($lists[$m]);
+ }
+ } else {
+ is_file(DT_ROOT.'/file/md5/'.DT_VERSION.'.php') or msg('正在创建镜像文件..', '?file='.$file.'&action=add');
+ $files = glob(DT_ROOT.'/*');
+ $dirs = $rfiles = array();
+ foreach($files as $f) {
+ if(is_file($f)) {
+ $rfiles[] = basename($f);
+ } else {
+ $dirs[] = basename($f);
+ }
+ }
+ $mfiles = glob(DT_ROOT.'/file/md5/*.php');
+ }
+ include tpl('md5');
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/menu.inc.php b/admin/menu.inc.php
new file mode 100644
index 0000000..deaa6a6
--- /dev/null
+++ b/admin/menu.inc.php
@@ -0,0 +1,40 @@
+
\ No newline at end of file
diff --git a/admin/mobile.inc.php b/admin/mobile.inc.php
new file mode 100644
index 0000000..de03b7f
--- /dev/null
+++ b/admin/mobile.inc.php
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/admin/module.inc.php b/admin/module.inc.php
new file mode 100644
index 0000000..d4a7ebb
--- /dev/null
+++ b/admin/module.inc.php
@@ -0,0 +1,242 @@
+$v) {
+ if(is_file($v.'/admin/config.inc.php')) {
+ include $v.'/admin/config.inc.php';
+ $sysmodules[$MCFG['module']] = $MCFG;
+ }
+ }
+ return $sysmodules;
+}
+switch($action) {
+ case 'add':
+ if($submit) {
+ if(!$post['name']) msg('请填写模块名称');
+ if($post['islink']) {
+ if(!$post['linkurl']) msg('请填写链接地址');
+ } else {
+ $dir = $post['moduledir'];
+ $module = $post['module'];
+ if(!$module) msg('请选择所属模型');
+ $module_cfg = DT_ROOT.'/module/'.$module.'/admin/config.inc.php';
+ if(!is_file($module_cfg)) msg('此模型无法安装,请检查');
+ include $module_cfg;
+ if($MCFG['uninstall'] == false) msg('此模型无法安装,请检查');
+ if($MCFG['copy'] == false) {
+ $r = $db->get_one("SELECT moduleid FROM {$DT_PRE}module WHERE module='$module' AND islink=0");
+ if($r) msg('此模型已经安装过,请检查');
+ }
+ if(!$dir) msg('请填写安装目录');
+ if(!preg_match("/^[0-9a-z_-]+$/i", $dir)) msg('目录名不合法,请更换一个再试');
+ $r = $db->get_one("SELECT moduleid FROM {$DT_PRE}module WHERE moduledir='$dir' AND islink=0");
+ if($r) msg('此目录名已经被其他模块使用,请更换一个再试');
+ $sysdirs = array('ad', 'admin', 'announce', 'api', 'archiver', 'comment', 'feed', 'file', 'gift', 'guestbook', 'include', 'install', 'lang', 'link', 'module', 'poll', 'sitemap', 'skin', 'spread', 'template', 'upgrade', 'vote', 'mobile', 'form');
+ if(in_array($dir, $sysdirs)) msg('安装目录与系统目录冲突,请更换安装目录');
+ if(!dir_create(DT_ROOT.'/'.$dir.'/')) msg('无法创建'.$dir.'目录,请检查PHP是否有创建权限或手动创建');
+ if(!is_write(DT_ROOT.'/'.$dir.'/')) msg('目录'.$dir.'无法写入,请设置此目录可写权限');
+ if(!file_put(DT_ROOT.'/'.$dir.'/config.inc.php', "DESTOON")) msg('目录'.$dir.'无法写入,请设置此目录可写权限');
+ }
+ if($post['domain']) $post['domain'] = fix_domain($post['domain']);
+ if($post['mobile']) $post['mobile'] = fix_domain($post['mobile']);
+ $post['linkurl'] = $post['islink'] ? $post['linkurl'] : ($post['domain'] ? $post['domain'] : linkurl($post['moduledir']."/"));
+ if($post['islink']) $post['module'] = 'destoon';
+ $post['installtime'] = $DT_TIME;
+ if($MCFG['moduleid']) {
+ $db->query("DELETE FROM {$DT_PRE}module WHERE moduleid=".$MCFG['moduleid']);
+ $post['moduleid'] = $MCFG['moduleid'];
+ }
+ $sql1 = $sql2 = $s = "";
+ foreach($post as $key=>$value) {
+ $sql1 .= $s.$key;
+ $sql2 .= $s."'".$value."'";
+ $s = ",";
+ }
+ $db->query("INSERT INTO {$DT_PRE}module ($sql1) VALUES ($sql2)");
+ $moduleid = $db->insert_id();
+ $db->query("UPDATE {$DT_PRE}module SET listorder=$moduleid WHERE moduleid=$moduleid");
+ if($post['islink']) {
+ } else {
+ $module = $post['module'];
+ $dir = $post['moduledir'];
+ $modulename = $post['name'];
+ file_put(DT_ROOT.'/'.$dir.'/config.inc.php', "");
+ @include DT_ROOT.'/module/'.$module.'/admin/install.inc.php';
+ }
+ cache_module();
+ dmsg('模块添加成功', $this_forward);
+ } else {
+ $imodules = array();
+ $result = $db->query("SELECT module FROM {$DT_PRE}module");
+ while($r = $db->fetch_array($result)) {
+ $imodules[$r['module']] = $r['module'];
+ }
+ $modules = get_modules();
+ $module_select = '请选择 ';
+ foreach($modules as $k=>$v) {
+ if($v['copy'] == false) {
+ if(in_array($v['module'], $imodules)) continue;
+ }
+ $module_select .= ''.$v['name'].' ';
+ }
+ $module_select .= ' ';
+ include tpl('module_add');
+ }
+ break;
+ case 'edit':
+ if(!$modid) msg('模块ID不能为空');
+ if($modid == 1 || $modid == 3) msg('系统模型,不可修改');
+ $r = $db->get_one("SELECT * FROM {$DT_PRE}module WHERE moduleid='$modid'");
+ if(!$r) msg('模块不存在');
+ extract($r);
+ if($submit) {
+ if(!$post['name']) msg('请填写模块名称');
+ if($islink) {
+ if(!$post['linkurl']) msg('请填写链接地址');
+ } else {
+ if($modid == 4) $post['moduledir'] = 'company';
+ if(!$post['moduledir']) msg('请填写安装目录');
+ if(!preg_match("/^[0-9a-z_-]+$/i", $post['moduledir'])) msg('目录名不合法,请更换一个再试');
+ $sysdirs = array('ad', 'admin', 'announce', 'api', 'archiver', 'comment', 'feed', 'file', 'gift', 'guestbook', 'include', 'install', 'lang', 'link', 'module', 'poll', 'sitemap', 'skin', 'spread', 'template', 'upgrade', 'vote', 'mobile', 'form');
+ if(in_array($post['moduledir'], $sysdirs)) msg('安装目录与系统目录冲突,请更换安装目录');
+ $r = $db->get_one("SELECT moduleid FROM {$DT_PRE}module WHERE moduledir='$post[moduledir]' AND moduleid!=$modid");
+ if($r) msg('此目录名已经被其他模块使用,请更换一个再试');
+ if($post['domain']) $post['domain'] = fix_domain($post['domain']);
+ if($post['mobile']) $post['mobile'] = fix_domain($post['mobile']);
+ $post['linkurl'] = $post['domain'] ? $post['domain'] : linkurl($post['moduledir']."/");
+ }
+ $sql = $s = "";
+ foreach($post as $key=>$value) {
+ $sql .= $s.$key."='".$value."'";
+ $s = ",";
+ }
+ $db->query("UPDATE {$DT_PRE}module SET $sql WHERE moduleid=$modid");
+ if(!$islink && $moduledir != $post['moduledir']) {
+ rename(DT_ROOT.'/'.$moduledir, DT_ROOT.'/'.$post['moduledir']) or msg('无法重命名目录'.$moduledir.'为'.$post['moduledir'].',请手动修改');
+ rename(DT_ROOT.'/mobile/'.$moduledir, DT_ROOT.'/mobile/'.$post['moduledir']);
+ }
+ cache_module();
+ dmsg('模块修改成功', $this_forward);
+ } else {
+ @include DT_ROOT.'/module/'.$module.'/admin/config.inc.php';
+ $modulename = isset($MCFG['name']) ? $MCFG['name'] : '';
+ include tpl('module_edit');
+ }
+ break;
+ case 'delete':
+ if(!$modid) msg('模块ID不能为空');
+ if($modid < 5) msg('系统模型不可删除');
+ #if($modid < 23) dheader('?file='.$file.'&action=disable&value=1&modid='.$modid);
+ $r = $db->get_one("SELECT * FROM {$DT_PRE}module WHERE moduleid='$modid'");
+ if(!$r) msg('此模块不存在');
+ if(!$r['islink']) {
+ $moduleid = $r['moduleid'];
+ $module = $r['module'];
+ $dir = $r['moduledir'];
+ $module_cfg = DT_ROOT.'/module/'.$module.'/admin/config.inc.php';
+ if(!is_file($module_cfg)) msg('此模型不可卸载,请检查');
+ include $module_cfg;
+ if($MCFG['uninstall'] == false) msg('此模型不可卸载,请检查');
+ @include DT_ROOT.'/module/'.$module.'/admin/uninstall.inc.php';
+ $result = $db->query("SHOW TABLES FROM `".$CFG['db_name']."`");
+ while($r = $db->fetch_row($result)) {
+ $tb = $r[0];
+ $pt = str_replace($DT_PRE.$moduleid.'_', '', $tb);
+ if(is_numeric($pt)) $db->query("DROP TABLE IF EXISTS `".$tb."`");
+ }
+ $db->query("DELETE FROM `".$DT_PRE."category` WHERE moduleid=$moduleid");
+ $db->query("DELETE FROM `".$DT_PRE."keylink` WHERE item=$moduleid");
+ $db->query("DELETE FROM `".$DT_PRE."setting` WHERE item=$moduleid");
+ $tb = str_replace($DT_PRE, '', get_table($moduleid));
+ $db->query("DELETE FROM `".$DT_PRE."fields` WHERE tb='$tb'");
+ dir_delete(DT_ROOT.'/'.$dir);
+ dir_delete(DT_ROOT.'/mobile/'.$dir);
+ }
+ $db->query("DELETE FROM {$DT_PRE}module WHERE moduleid='$modid'");
+ cache_module();
+ dmsg('模块删除成功', $this_forward);
+ break;
+ case 'remkdir':
+ if(!$modid) msg('模块ID不能为空');
+ $r = $db->get_one("SELECT * FROM {$DT_PRE}module WHERE moduleid='$modid'");
+ $remkdir = DT_ROOT.'/module/'.$r['module'].'/admin/remkdir.inc.php';
+ if(is_file($remkdir)) {
+ $moduleid = $r['moduleid'];
+ $module = $r['module'];
+ $dir = $r['moduledir'];
+ if(!dir_create(DT_ROOT.'/'.$dir)) msg('无法创建'.$dir.'目录,请检查PHP是否有创建权限或手动创建');
+ if(!file_put(DT_ROOT.'/'.$dir.'/ajax.php', "DESTOON TEST")) msg('目录'.$dir.'无法写入,如果是Linux/Unix服务器,请设置此目录可写权限');
+ file_del(DT_ROOT.'/'.$dir.'/config.inc.php');
+ file_copy(DT_ROOT.'/api/ajax.php', DT_ROOT.'/'.$dir.'/ajax.php');
+ file_copy(DT_ROOT.'/api/ajax.php', DT_ROOT.'/mobile/'.$dir.'/ajax.php');
+ include $remkdir;
+ cache_module();
+ dmsg('目录重建成功', '?file='.$file);
+ } else {
+ msg('此模型无需重建目录', '?file='.$file);
+ }
+ break;
+ case 'disable':
+ if(!$modid) msg('模块ID不能为空');
+ if($modid < 5) msg('系统模型不可禁用');
+ $value = $value ? 1 : 0;
+ $db->query("UPDATE {$DT_PRE}module SET disabled='$value' WHERE moduleid=$modid");
+ cache_module();
+ dmsg('模块状态已经修改', $this_forward);
+ break;
+ case 'order':
+ foreach($listorder as $k=>$v) {
+ $k = intval($k);
+ $v = intval($v);
+ $db->query("UPDATE {$DT_PRE}module SET listorder='$v' WHERE moduleid=$k");
+ }
+ cache_module();
+ dmsg('更新成功', $this_forward);
+ break;
+ case 'cache':
+ cache_module();
+ dmsg('更新成功', $forward);
+ break;
+ case 'ckdir':
+ if(!preg_match("/^[0-9a-z_-]+$/i", $moduledir)) dialog('不是一个合法的目录名,请更换一个再试');
+ $r = $db->get_one("SELECT moduleid FROM {$DT_PRE}module WHERE moduledir='$moduledir'");
+ if($r || is_dir(DT_ROOT.'/'.$moduledir.'/')) dialog('该目录名已经被使用,请更换一个再试');
+ dialog('目录名可以使用');
+ break;
+ case 'sys':
+ $sysmodules = get_modules();
+ include tpl('module_sys');
+ break;
+ default:
+ $sysmodules = get_modules();
+ $modules = $_modules = array();
+ $result = $db->query("SELECT * FROM {$DT_PRE}module ORDER BY listorder ASC,moduleid DESC");
+ while($r = $db->fetch_array($result)) {
+ if($r['moduleid'] == 1) continue;
+ $r['installdate'] = timetodate($r['installtime'], 3);
+ $r['modulename'] = isset($sysmodules[$r['module']]) ? $sysmodules[$r['module']]['name'] : '外链 ';
+ if($r['disabled']) {
+ $_modules[] = $r;
+ } else {
+ $modules[] = $r;
+ }
+ }
+ include tpl('module');
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/mymenu.inc.php b/admin/mymenu.inc.php
new file mode 100644
index 0000000..df56c60
--- /dev/null
+++ b/admin/mymenu.inc.php
@@ -0,0 +1,30 @@
+update($_userid, $right, $_admin)) dmsg('保存成功', '?file='.$file.'&itemid='.$itemid.'&update=1');
+ msg($do->errmsg);
+} else {
+ $dmenus = $do->get_menu($_userid);
+ if(isset($title)) {
+ //
+ } else {
+ $title = '';
+ }
+ if(isset($url)) {
+ $pos = strpos($url, '?');
+ if($pos !== false) $url = substr($url, $pos);
+ } else {
+ $url = '';
+ }
+ include tpl('mymenu');
+}
+?>
\ No newline at end of file
diff --git a/admin/patch.inc.php b/admin/patch.inc.php
new file mode 100644
index 0000000..5063ee6
--- /dev/null
+++ b/admin/patch.inc.php
@@ -0,0 +1,143 @@
+pid='.$pid);
+ exit;
+} else {
+ if($submit) {
+ is_time($fd) or msg('开始时间设置错误');
+ $ft = datetotime($fd);
+ is_time($td) or msg('结束时间设置错误');
+ $tt = datetotime($td);
+ $tt >= $ft or msg('时间范围设置错误');
+
+ isset($filedir) or $filedir = $sys;
+ $fileext or $fileext = $ext;
+ $lists = array();
+ if($type) {
+ $files = isset($files) ? trim($files) : '';
+ foreach(explode("\n", $files) as $f) {
+ $f = trim($f);
+ $f = str_replace("\\", '/', $f);
+ if(strpos($f, '..') !== false || strpos($f, ':') !== false) continue;
+ if(substr($f, 0, 1) == '/') continue;
+ if(!is_file(DT_ROOT.'/'.$f) && !is_dir(DT_ROOT.'/'.$f)) continue;
+ $lists[] = DT_ROOT.'/'.$f;
+ }
+ $ft = $tt = $DT_TIME;
+ } else {
+ $files = array();
+ foreach(glob(DT_ROOT.'/*.*') as $f) {
+ if(is_dir($f)) continue;
+ if(in_array(basename($f), array('config.inc.php', 'index.html', 'baidunews.xml', 'sitemaps.xml'))) continue;
+ $files[] = $f;
+ }
+ foreach($filedir as $d) {
+ if($d == 'file') {
+ $files = array_merge($files, get_file(DT_ROOT.'/'.$d.'/script', $fileext));
+ $files = array_merge($files, get_file(DT_ROOT.'/'.$d.'/image', $fileext));
+ $files = array_merge($files, get_file(DT_ROOT.'/'.$d.'/config', $fileext));
+ $files = array_merge($files, get_file(DT_ROOT.'/'.$d.'/setting', $fileext));
+ } else {
+ $files = array_merge($files, get_file(DT_ROOT.'/'.$d, $fileext));
+ }
+ }
+ foreach($files as $f) {
+ if(in_array($f, array(DT_ROOT.'/file/script/config.js'))) continue;
+ $n = basename($f);
+ if(file_ext($n) == 'js') {
+ if(in_array(substr($n, 0, 1), array('A', '0'))) continue;
+ }
+ $t = filemtime($f);
+ if($t >= $ft && $t <= $tt) {
+ $lists[] = $f;
+ }
+ }
+ }
+ $find = count($lists);
+ if($find) {
+ $dir = DT_ROOT.'/file/patch/'.timetodate($ft, 'Y-m-d H.i').'~'.timetodate($tt, 'Y-m-d H.i').'/';
+ if(!is_dir($dir)) dir_delete($dir);
+ if($note) {
+ $note = trim(dhtmlspecialchars(strip_tags($note)));
+ file_put($dir.'file/temp/note.txt', $note);
+ }
+ foreach($lists as $f) {
+ if(is_file($f)) {
+ file_copy($f, $dir.str_replace(DT_ROOT.'/', '', $f));
+ @touch($dir.str_replace(DT_ROOT.'/', '', $f), filemtime($f));
+ } else if(is_dir($f)) {
+ dir_copy($f, $dir.str_replace(DT_ROOT.'/', '', $f));
+ }
+ }
+ cache_write('patch.php', array($td));
+ msg('备份成功 '.$find.' 个文件或目录,已保存于file/patch', '?file='.$file, 5);
+ }
+ msg('没有符合条件的文件');
+ } else {
+ $files = glob(DT_ROOT.'/*');
+ $dirs = $rfiles = $baks = $ups = array();
+ foreach($files as $f) {
+ $bn = basename($f);
+ if(is_file($f)) {
+ $rfiles[] = $bn;
+ } else {
+ $dirs[] = $bn;
+ }
+ }
+ $fd = substr(DT_RELEASE, 0, 4).'-'.substr(DT_RELEASE, 4, 2).'-'.substr(DT_RELEASE, 6, 2).' 00:00:00';
+ $tt = cache_read('patch.php');
+ if($tt && is_time($tt[0])) $fd = $tt[0];
+ $td = timetodate($DT_TIME, 6);
+ $files = glob(DT_ROOT.'/file/patch/*');
+ foreach($files as $f) {
+ if(is_dir($f)) {
+ $n = basename($f);
+ if(preg_match("/^[0-9\.\-\s~]{33}$/", $n)) {
+ $r = array();
+ $r['file'] = $n;
+ $r['num'] = count(get_file($f));
+ $r['time'] = timetodate(filemtime($f), 5);
+ $r['note'] = file_get($f.'/file/temp/note.txt');
+ $baks[] = $r;
+ }
+ }
+ }
+ $date1 = timetodate($DT_TIME, 3);
+ $date2 = timetodate($DT_TIME - 86400, 3);
+ $date3 = timetodate($DT_TIME - 86400*2, 3);
+ $date4 = timetodate($DT_TIME - 86400*(intval(timetodate($DT_TIME, 'N'))-1), 3);
+ $date5 = timetodate($DT_TIME, 'Y-m').'-01';
+ }
+ include tpl('patch');
+}
+?>
\ No newline at end of file
diff --git a/admin/property.inc.php b/admin/property.inc.php
new file mode 100644
index 0000000..601c0a4
--- /dev/null
+++ b/admin/property.inc.php
@@ -0,0 +1,207 @@
+catid = $catid;
+switch($action) {
+ case 'add':
+ if($submit) {
+ if($do->pass($post)) {
+ $do->add($post);
+ dmsg('添加成功', '?file='.$file.'&catid='.$catid);
+ } else {
+ msg($do->errmsg);
+ }
+ } else {
+ $type = 2;
+ $required = $search = 0;
+ $name = $value = $extend = '';
+ include tpl('property_edit');
+ }
+ break;
+ case 'edit':
+ $oid or msg();
+ $do->oid = $oid;
+ if($submit) {
+ if($do->pass($post)) {
+ $do->edit($post);
+ dmsg('修改成功', $forward);
+ } else {
+ msg($do->errmsg);
+ }
+ } else {
+ extract($do->get_one($oid));
+ include tpl('property_edit');
+ }
+ break;
+ case 'copy':
+ $_id = $mid ? $mid : $CAT['moduleid'];
+ if($submit) {
+ if($type) {
+ $fromid = intval($fromid);
+ $fromid or msg('请选择来源分类');
+ $fromid != $catid or msg('来源分类不能与当前分类相同');
+ $id = $fromid;
+ $type = 1;
+ } else {
+ $pid = intval($pid);
+ $pid or msg('请填写属性ID');
+ $id = $pid;
+ $type = 0;
+ }
+ $name = $name ? 1 : 0;
+ if($do->copy($id, $type, $name)) {
+ dmsg('属性复制成功', '?file='.$file.'&catid='.$catid);
+ } else {
+ msg($do->errmsg);
+ }
+ } else {
+ include tpl('property_copy');
+ }
+ break;
+ case 'update':
+ $do->update($post);
+ dmsg('更新成功', $forward);
+ break;
+ default:
+ $lists = $do->get_list();
+ include tpl('property');
+ break;
+}
+class property {
+ var $oid;
+ var $catid;
+ var $table;
+ var $errmsg = errmsg;
+
+ function __construct() {
+ $this->table = DT_PRE.'category_option';
+ }
+
+ function property() {
+ $this->__construct();
+ }
+
+ function pass($post) {
+ if(!is_array($post)) return false;
+ if(!$post['name']) return $this->_('请填写属性名称');
+ if($post['type'] == 3) {
+ if(!$post['value']) return $this->_('请填写备选值');
+ if(strpos($post['value'], '|') === false) return $this->_('最少需要设定2个备选值');
+ }
+ return true;
+ }
+
+ function set($post) {
+ $post['value'] = trim($post['value']);
+ if($post['type'] < 2) $post['search'] = 0;
+ return $post;
+ }
+
+ function add($post) {
+ $post = $this->set($post);
+ $sqlk = $sqlv = '';
+ foreach($post as $k=>$v) {
+ $sqlk .= ','.$k; $sqlv .= ",'$v'";
+ }
+ $sqlk = substr($sqlk, 1);
+ $sqlv = substr($sqlv, 1);
+ DB::query("INSERT INTO {$this->table} ($sqlk) VALUES ($sqlv)");
+ return true;
+ }
+
+ function edit($post) {
+ $post = $this->set($post);
+ $sql = '';
+ foreach($post as $k=>$v) {
+ $sql .= ",$k='$v'";
+ }
+ $sql = substr($sql, 1);
+ DB::query("UPDATE {$this->table} SET $sql WHERE oid=$this->oid");
+ return true;
+ }
+
+ function copy($id, $type, $name) {
+ $i = 0;
+ $condition = $type ? "catid=$id" : "oid=$id";
+ $result = DB::query("SELECT * FROM {$this->table} WHERE {$condition}");
+ while($r = DB::fetch_array($result)) {
+ if($name) {
+ $n = daddslashes($r['name']);
+ $t = DB::get_one("SELECT * FROM {$this->table} WHERE catid=$this->catid AND name='$n'");
+ if($t) {
+ if($type) continue;
+ return $this->_('属性名称 ['.$r['name'].'] 已存在');
+ }
+ }
+ unset($r['oid']);
+ $r['catid'] = $this->catid;
+ $post = daddslashes($r);
+ $sqlk = $sqlv = '';
+ foreach($post as $k=>$v) {
+ $sqlk .= ','.$k; $sqlv .= ",'$v'";
+ }
+ $sqlk = substr($sqlk, 1);
+ $sqlv = substr($sqlv, 1);
+ DB::query("INSERT INTO {$this->table} ($sqlk) VALUES ($sqlv)");
+ $i++;
+ }
+ if($i) return true;
+ return $this->_('属性参数不存在或存在同名');
+ }
+
+ function get_one() {
+ return DB::get_one("SELECT * FROM {$this->table} WHERE oid=$this->oid");
+ }
+
+ function update($post) {
+ foreach($post as $k=>$v) {
+ $k = intval($k);
+ if(isset($v['delete']) && $v['delete']) {
+ DB::query("DELETE FROM {$this->table} WHERE oid=$k");
+ } else {
+ $listorder = intval($v['listorder']);
+ $value = $v['value'];
+ $name = $v['name'];
+ $required = $v['required'] ? 1 : 0;
+ DB::query("UPDATE {$this->table} SET listorder=$listorder,required=$required,value='$value',name='$name' WHERE oid=$k");
+ }
+ }
+ return true;
+ }
+
+ function get_list() {
+ global $pages, $page, $pagesize, $offset, $pagesize, $CAT, $sum;
+ $condition = "catid=$this->catid";
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = DB::get_one("SELECT COUNT(*) AS num FROM {$this->table} WHERE $condition");
+ $items = $r['num'];
+ }
+ if($items != $CAT['property']) DB::query("UPDATE ".DT_PRE."category SET property=$r[num] WHERE catid=$this->catid");
+ $pages = pages($items, $page, $pagesize);
+ $lists = array();
+ $result = DB::query("SELECT * FROM {$this->table} WHERE $condition ORDER BY listorder ASC,oid ASC LIMIT $offset,$pagesize");
+ while($r = DB::fetch_array($result)) {
+ $lists[] = $r;
+ }
+ return $lists;
+ }
+
+ function _($e) {
+ $this->errmsg = $e;
+ return false;
+ }
+}
+?>
\ No newline at end of file
diff --git a/admin/question.inc.php b/admin/question.inc.php
new file mode 100644
index 0000000..a51ada8
--- /dev/null
+++ b/admin/question.inc.php
@@ -0,0 +1,80 @@
+update($post);
+ dmsg('保存成功', '?file='.$file);
+} else {
+ $condition = "1";
+ if($kw) $condition .= " AND (question LIKE '%$keyword%' OR answer LIKE '%$keyword%')";
+ $lists = $do->get_list($condition);
+ include tpl('question');
+}
+
+class question {
+ var $table;
+
+ function __construct() {
+ $this->table = DT_PRE.'question';
+ }
+
+ function question() {
+ $this->__construct();
+ }
+
+ function get_list($condition) {
+ global $pages, $page, $pagesize, $offset, $pagesize;
+ $pages = pages(DB::count($this->table, $condition), $page, $pagesize);
+ $lists = array();
+ $result = DB::query("SELECT * FROM {$this->table} WHERE $condition ORDER BY qid DESC LIMIT $offset,$pagesize");
+ while($r = DB::fetch_array($result)) {
+ $lists[] = $r;
+ }
+ return $lists;
+ }
+
+ function update($post) {
+ $this->add($post[0]);
+ unset($post[0]);
+ foreach($post as $k=>$v) {
+ if(isset($v['delete'])) {
+ $this->delete($k);
+ unset($post[$k]);
+ }
+ }
+ $this->edit($post);
+ return true;
+ }
+
+ function add($post) {
+ if(!$post['question'] || !$post['answer']) return false;
+ $Q = explode("\n", $post['question']);
+ $A = explode("\n", $post['answer']);
+ foreach($Q as $k=>$q) {
+ $q = trim($q);
+ if($q) {
+ $a = isset($A[$k]) ? trim($A[$k]) : '';
+ if($q && $a) DB::query("INSERT INTO {$this->table} (question,answer) VALUES('$q','$a')");
+ }
+ }
+ }
+
+ function edit($post) {
+ foreach($post as $k=>$v) {
+ if(!$v['question'] || !$v['answer']) continue;
+ DB::query("UPDATE {$this->table} SET question='$v[question]',answer='$v[answer]' WHERE qid='$k'");
+ }
+ }
+
+ function delete($qid) {
+ DB::query("DELETE FROM {$this->table} WHERE qid=$qid");
+ }
+}
+?>
\ No newline at end of file
diff --git a/admin/scan.inc.php b/admin/scan.inc.php
new file mode 100644
index 0000000..d9984d2
--- /dev/null
+++ b/admin/scan.inc.php
@@ -0,0 +1,179 @@
+ 1,
+ 'baidunews.xml' => 1,
+ 'config.inc.php' => 1,
+ 'index.html' => 1,
+ 'admin/admin.inc.php' => 1,
+ 'admin/area.inc.php' => 1,
+ 'admin/config.inc.php' => 1,
+ 'admin/data.inc.php' => 2,
+ 'admin/database.inc.php' => 1,
+ 'admin/index.inc.php' => 3,
+ 'admin/log.inc.php' => 1,
+ 'admin/md5.inc.php' => 1,
+ 'admin/menu.inc.php' => 1,
+ 'admin/patch.inc.php' => 1,
+ 'admin/setting.inc.php' => 1,
+ 'admin/scan.inc.php' => 3,
+ 'admin/tag.inc.php' => 1,
+ 'admin/unzip.class.php' => 2,
+ 'admin/update.inc.php' => 1,
+ 'admin/template.inc.php' => 1,
+ 'admin/template/count.tpl.php' => 1,
+ 'admin/template/left.tpl.php' => 1,
+ 'admin/template/msg.tpl.php' => 1,
+ 'admin/template/scan.tpl.php' => 1,
+ 'admin/template/setting.tpl.php' => 1,
+ 'admin/template/tag_preview.tpl.php' => 1,
+ 'api/memcache.php' => 3,
+ 'api/avatar/upload.php' => 1,
+ 'api/barcode/BCGBarcode.php' => 1,
+ 'api/barcode/BCGColor.php' => 1,
+ 'api/barcode/BCGDrawPNG.php' => 1,
+ 'api/barcode/BCGcode39.barcode.php' => 1,
+ 'api/excel/data.class.php' => 1,
+ 'api/excel/debug.class.php' => 1,
+ 'api/excel/parser.class.php' => 3,
+ 'api/map/51ditu/mark.php' => 1,
+ 'api/oauth/baidu/callback.php' => 1,
+ 'api/oauth/netease/callback.php' => 1,
+ 'api/oauth/qq/callback.php' => 1,
+ 'api/oauth/qq/index.php' => 1,
+ 'api/oauth/qq/post.php' => 1,
+ 'api/oauth/qq/qzone.php' => 1,
+ 'api/qrcode.png.php' => 3,
+ 'api/pay/kq99bill/notify.php' => 1,
+ 'api/pay/paypal/notify.php' => 1,
+ 'api/pay/paypal/send.inc.php' => 1,
+ 'api/pay/yeepay/send.inc.php' => 1,
+ 'include/cache_shmop.class.php' => 1,
+ 'include/captcha.class.php' => 1,
+ 'include/client.func.php' => 1,
+ 'include/content.class.php' => 1,
+ 'include/db_pdo.class.php' => 1,
+ 'include/mobile.func.php' => 1,
+ 'include/fields.func.php' => 1,
+ 'include/file.func.php' => 1,
+ 'include/global.func.php' => 3,
+ 'include/ip.class.php' => 1,
+ 'include/post.func.php' => 2,
+ 'include/safe.func.php' => 2,
+ 'include/seo.inc.php' => 1,
+ 'include/session_apc.class.php' => 1,
+ 'include/session_eaccelerator.class.php' => 1,
+ 'include/session_file.class.php' => 1,
+ 'include/session_memcache.class.php' => 1,
+ 'include/session_mysql.class.php' => 1,
+ 'include/session_redis.class.php' => 1,
+ 'include/session_shmop.class.php' => 1,
+ 'include/session_wincache.class.php' => 1,
+ 'include/session_xcache.class.php' => 1,
+ 'include/sql.func.php' => 1,
+ 'include/template.func.php' => 1,
+ 'install/index.php' => 1,
+ 'mobile/common.inc.php' => 1,
+ 'module/brand/admin/install.inc.php' => 1,
+ 'module/buy/admin/install.inc.php' => 1,
+ 'module/club/admin/install.inc.php' => 1,
+ 'module/down/admin/install.inc.php' => 1,
+ 'module/exhibit/admin/install.inc.php' => 1,
+ 'module/group/admin/install.inc.php' => 1,
+ 'module/group/admin/template/order_stats.tpl.php' => 1,
+ 'module/job/admin/install.inc.php' => 1,
+ 'module/know/admin/install.inc.php' => 1,
+ 'module/mall/admin/install.inc.php' => 1,
+ 'module/mall/admin/template/order_stats.tpl.php' => 1,
+ 'module/member/avatar.inc.php' => 1,
+ 'module/member/admin/promo.inc.php' => 1,
+ 'module/member/admin/sendmail.inc.php' => 1,
+ 'module/member/admin/sendsms.inc.php' => 1,
+ 'module/member/admin/template/cash_stats.tpl.php' => 1,
+ 'module/member/admin/template/charge_stats.tpl.php' => 1,
+ 'module/member/admin/template/pay_stats.tpl.php' => 1,
+ 'module/member/admin/template/weixin_chat.tpl.php' => 2,
+ 'module/member/message.inc.php' => 1,
+ 'module/photo/admin/install.inc.php' => 1,
+ 'module/quote/admin/install.inc.php' => 1,
+ 'module/quote/price.inc.php' => 1,
+ 'module/sell/admin/install.inc.php' => 1,
+ 'module/special/admin/install.inc.php' => 1,
+ 'module/special/type.inc.php' => 1,
+ 'module/video/admin/install.inc.php' => 1,
+ 'upgrade/config.inc.php' => 1,
+ 'upgrade/index.php' => 1,
+ 'mobile/index.php' => 1,
+ );
+ isset($filedir) or $filedir = array();
+ $fileext or $fileext = $bd_ext;
+ $code or $code = $bd_code;
+ $codenum or $codenum = 1;
+ $code = str_replace('\|', '|', preg_quote(stripslashes($code)));
+ $code = convert($code, DT_CHARSET, $charset);
+ $files = array();
+ foreach(glob(DT_ROOT.'/*.*') as $f) {
+ $files[] = $f;
+ }
+ foreach($filedir as $d) {
+ $files = array_merge($files, get_file(DT_ROOT.'/'.$d, $fileext));
+ }
+ $lists = $mirror = array();
+ if(is_file(DT_ROOT.'/file/md5/'.DT_VERSION.'.php')) {
+ $content = substr(trim(file_get(DT_ROOT.'/file/md5/'.DT_VERSION.'.php')), 13);
+ foreach(explode("\n", $content) as $v) {
+ list($m, $f) = explode(' ', trim($v));
+ $mirror[$m] = $f;
+ }
+ }
+ foreach($files as $f) {
+ if(strpos($f, '/api/pay/') !== false) continue;
+ if(strpos($f, '/api/app/') !== false) continue;
+ $content = file_get($f);
+ if(preg_match_all('/('.$code.')/i', $content, $m)) {
+ $r = $c = array();
+ foreach($m[1] as $v) {
+ in_array($v, $c) or $c[] = $v;
+ }
+ $r['num'] = count($c);
+ if($r['num'] < $codenum && strpos($content, 'Zend') === false) continue;
+ $r['file'] = str_replace(DT_ROOT.'/', '', $f);
+ if($mirror && in_array($r['file'], $mirror)) {
+ if(md5_file($f) == array_search($r['file'], $mirror)) continue;
+ }
+ if(isset($W[$r['file']]) && $W[$r['file']] == $r['num']) continue;
+ $r['code'] = convert(implode(',', $c), $charset, DT_CHARSET);
+ $lists[] = $r;
+ }
+ }
+ $find = count($lists);
+} else {
+ $files = glob(DT_ROOT.'/*');
+ $dirs = $rfiles = array();
+ foreach($files as $f) {
+ $bn = basename($f);
+ if(is_file($f)) {
+ $rfiles[] = $bn;
+ } else {
+ if($bn == 'file') continue;
+ $dirs[] = $bn;
+ }
+ }
+ $code = $bd_code;
+ $fileext = $bd_ext;
+}
+include tpl('scan');
+?>
\ No newline at end of file
diff --git a/admin/search.inc.php b/admin/search.inc.php
new file mode 100644
index 0000000..58f11a2
--- /dev/null
+++ b/admin/search.inc.php
@@ -0,0 +1,85 @@
+$v) {
+ if($v['islink'] || $k == 1) continue;
+ $menu = array();
+ $moduleid = $k;
+ $name = $v['name'];
+ include DT_ROOT.'/module/'.$v['module'].'/admin/menu.inc.php';
+ $name = $moduleid == 3 ? '扩展功能' : $name.'管理';
+ foreach($menu as $m) {
+ if(strpos($m[0], $kw) !== false) {
+ $m[0] = ($moduleid > 2 ? '功能模块 - ' : '').$name.' - '.$m[0];
+ $files[] = $m;
+ }
+ }
+ }
+ foreach($menu_finance as $m) {
+ if(strpos($m[0], $kw) !== false) {
+ $m[0] = '会员管理 - 财务管理 - '.$m[0];
+ $files[] = $m;
+ }
+ }
+ foreach($menu_relate as $m) {
+ if(strpos($m[0], $kw) !== false) {
+ $m[0] = '会员管理 - 会员相关 - '.$m[0];
+ $files[] = $m;
+ }
+ }
+ $moduleid = $mid;
+ $content = file_get_contents(DT_ROOT.'/admin/template/setting.tpl.php');
+ if(preg_match_all('/('.$kw.')/i', $content, $m)) {
+ $lists[1]['num'] = count($m[1]);
+ $lists[1]['name'] = '系统维护 - 网站设置';
+ }
+ foreach($MODULE as $k=>$v) {
+ if($v['islink'] || $k == 1) continue;
+ $content = file_get_contents(DT_ROOT.'/module/'.$v['module'].'/admin/template/setting.tpl.php');
+ if(preg_match_all('/('.$kw.')/i', $content, $m)) {
+ $lists[$k]['num'] = count($m[1]);
+ $lists[$k]['name'] = '功能模块 - '.($k == 3 ? '扩展功能' : $v['name'].'管理').' - 模块设置';
+ }
+ }
+ $content = file_get_contents(DT_ROOT.'/module/member/admin/template/group_edit.tpl.php');
+ if(preg_match_all('/('.$kw.')/i', $content, $m)) {
+ foreach(cache_read('group.php') as $m) {
+ $_m = array();
+ $_m[0] = '会员管理 - 会员组管理 - '.$m['groupname'];
+ $_m[1] = '?moduleid=2&file=group&action=edit&groupid='.$m['groupid'].'&kw='.$ukw;
+ $files[] = $_m;
+ }
+ }
+ foreach(cache_read('menu-'.$_userid.'.php') as $m) {
+ if(strpos($m['title'], $kw) !== false) {
+ $_m = array();
+ $_m[0] = '我的面板 - '.$m['title'];
+ $_m[1] = $m['url'];
+ $files[] = $_m;
+ }
+ }
+}
+include tpl('search');
+?>
\ No newline at end of file
diff --git a/admin/setting.inc.php b/admin/setting.inc.php
new file mode 100644
index 0000000..2b2a97f
--- /dev/null
+++ b/admin/setting.inc.php
@@ -0,0 +1,153 @@
+connected) dialog('FTP无法连接,请检查设置');
+ if(!$ftp->dftp_chdir()) dialog('FTP无法进入远程存储目录,请检查远程存储目录');
+ dialog('FTP设置正常,可以使用');
+ break;
+ case 'mail':
+ define('TESTMAIL', true);
+ if(strpos($smtp_pass, '***') !== false) $smtp_pass = $DT['smtp_pass'];
+ $DT['mail_type'] = $mail_type;
+ $DT['smtp_host'] = $smtp_host;
+ $DT['smtp_port'] = $smtp_port;
+ $DT['smtp_auth'] = $smtp_auth;
+ $DT['smtp_user'] = $smtp_user;
+ $DT['smtp_pass'] = $smtp_pass;
+ $DT['mail_sender'] = $mail_sender;
+ $DT['mail_name'] = $mail_name;
+ $DT['mail_delimiter'] = $mail_delimiter;
+ $DT['mail_sign'] = '';
+ if($mail_type == 'sc') {
+ $subject = '来自SendCloud的第一封邮件!';
+ $body = '你太棒了!你已成功的从SendCloud发送了一封测试邮件,接下来快登录前台去完善账户信息吧!';
+ } else {
+ $subject = $DT['sitename'].'邮件发送测试';
+ $body = '恭喜!您的站点['.$DT['sitename'].']邮件发送设置成功! ------------------------------------Send By DESTOON Mail Tester ';
+ }
+ if(send_mail($testemail, $subject, $body)) dialog('邮件已发送至'.$testemail.',请注意查收', $mail_sender);
+ dialog('邮件发送失败,请检查设置');
+ break;
+ case 'static':
+ if($itemid) {
+ foreach(array(DT_ROOT.'/file/flash/', DT_ROOT.'/file/image/', DT_ROOT.'/file/script/', DT_ROOT.'/skin/'.$CFG['skin'].'/', DT_ROOT.'/'.$MODULE[2]['moduledir'].'/image/', DT_ROOT.'/'.$MODULE[4]['moduledir'].'/skin/', DT_ROOT.'/'.$MODULE[4]['moduledir'].'/image/') as $d) {
+ $s = str_replace(DT_ROOT, DT_ROOT.'/file/static', $d);
+ dir_copy($d, $s);
+ }
+ foreach(array(DT_ROOT.'/favicon.ico', DT_ROOT.'/lang/'.DT_LANG.'/lang.js') as $d) {
+ $s = str_replace(DT_ROOT, DT_ROOT.'/file/static', $d);
+ file_copy($d, $s);
+ }
+ }
+ include tpl('static');
+ break;
+ case 'cache':
+ if($job && $job != $CFG['cache']) {
+ $class = DT_ROOT.'/include/cache_'.$job.'.class.php';
+ if(is_file($class)) {
+ cache_write('cache.test.php', str_replace('dcache', 'tcache', file_get($class)));
+ require DT_CACHE.'/cache.test.php';
+ $dc = new tcache();
+ $dc->pre = $CFG['cache_pre'];
+ $CFG['cache'] = $job;
+ }
+ }
+ $dc->set('destoon', 'com', 3600);
+ $pass = $dc->get('destoon') == 'com' ? 1 : 0;
+ dialog('测试结果:'.($pass ? '
成功 ' : '
失败 ').' 缓存类型:'.$CFG['cache'].'
如果类型不正确,请先保存设置再测试
');
+ break;
+ case 'html':
+ tohtml('index');
+ $dc->get('destoon') == 'com' or dalert('缓存类型'.$CFG['cache'].'测试失败,'.($CFG['cache'] == 'file' ? '请检查file目录是否可写' : '请立即更换'), '?moduleid='.$moduleid.'&file='.$file.'&tab=2');
+ dmsg('设置保存成功', '?moduleid='.$moduleid.'&file='.$file.'&tab='.$tab);
+ break;
+ default:
+ $tab = isset($tab) ? intval($tab) : 0;
+ $all = isset($all) ? intval($all) : 0;
+ if($submit) {
+ foreach($setting as $k=>$v) {
+ if(strpos($k, 'seo_') === false) continue;
+ seo_check($v) or msg('SEO信息包含非法字符');
+ }
+ if(strpos($setting['remote_url'], 'file/upload') !== false) msg('FTP远程访问URL不能包含file/upload');
+ if($setting['safe_domain']) {
+ $setting['safe_domain'] = str_replace('http://', '', $setting['safe_domain']);
+ if(substr($setting['safe_domain'], 0, 4) == 'www.') $setting['safe_domain'] = substr($setting['safe_domain'], 4);
+ }
+ $setting['gano'] = $setting['wano'] ? cutstr($setting['wano'], '备', '号') : '';
+ if(substr($config['url'], -1) != '/') $config['url'] = $config['url'].'/';
+ if($config['cookie_domain'] && substr($config['cookie_domain'], 0, 1) != '.') $config['cookie_domain'] = '.'.$config['cookie_domain'];
+ if($config['cookie_domain'] != $CFG['cookie_domain']) $config['cookie_pre'] = 'D'.random(2).'_';
+ in_array($setting['file_ext'], array('html', 'htm', 'shtml', 'shtm')) or $setting['file_ext'] = 'html';
+ if(!is_numeric($config['cloud_uid']) || strlen($config['cloud_key']) != 16) $setting['sms'] = $setting['cloud_express'] = 0;
+ $config['cloud_key'] = pass_decode($config['cloud_key'], DT_CLOUD_KEY);
+ $setting['smtp_pass'] = pass_decode($setting['smtp_pass'], $DT['smtp_pass']);
+ $setting['ftp_pass'] = pass_decode($setting['ftp_pass'], $DT['ftp_pass']);
+ $setting['trade_pw'] = pass_decode($setting['trade_pw'], $DT['trade_pw']);
+ $setting['admin_week'] = is_array($setting['admin_week']) ? implode(',', $setting['admin_week']) : '';
+ $setting['check_week'] = is_array($setting['check_week']) ? implode(',', $setting['check_week']) : '';
+ if($setting['logo'] != $DT['logo']) clear_upload($setting['logo'], $_userid, 'setting');
+ $setting['thumb_max'] = intval($setting['thumb_max']);
+ if($setting['thumb_max'] > 99 || $setting['thumb_max'] < 5) $setting['thumb_max'] = 10;
+ if(!is_write(DT_ROOT.'/config.inc.php')) msg('根目录config.inc.php无法写入,请设置可写权限');
+ $tmp = file_get(DT_ROOT.'/config.inc.php');
+ foreach($config as $k=>$v) {
+ $tmp = preg_replace("/[$]CFG\['$k'\]\s*\=\s*[\"'].*?[\"']/is", "\$CFG['$k'] = '$v'", $tmp);
+ }
+ file_put(DT_ROOT.'/config.inc.php', $tmp);
+ update_setting($moduleid, $setting);
+ cache_module(1);
+ cache_module();
+ file_put(DT_ROOT.'/file/avatar/remote.html', $setting['ftp_remote'] && $setting['remote_url'] ? $setting['remote_url'] : 'URL');
+ $filename = DT_ROOT.'/'.$setting['index'].'.'.$setting['file_ext'];
+ if(!$setting['index_html'] && $setting['file_ext'] != 'php') file_del($filename);
+ $pdir = DT_ROOT.'/'.$MODULE[2]['moduledir'].'/';
+ $mdir = DT_ROOT.'/mobile/'.$MODULE[2]['moduledir'].'/';
+ if($setting['file_register'] != $old_file_register) {
+ @rename($pdir.$old_file_register, $pdir.$setting['file_register']);
+ @rename($mdir.$old_file_register, $mdir.$setting['file_register']);
+ }
+ if($setting['file_login'] != $old_file_login) {
+ @rename($pdir.$old_file_login, $pdir.$setting['file_login']);
+ @rename($mdir.$old_file_login, $mdir.$setting['file_login']);
+ }
+ if($setting['file_my'] != $old_file_my) {
+ @rename($pdir.$old_file_my, $pdir.$setting['file_my']);
+ @rename($mdir.$old_file_my, $mdir.$setting['file_my']);
+ }
+ $dc->set('destoon', 'com', 3600);
+ dheader('?moduleid='.$moduleid.'&file='.$file.'&action=html&tab='.$tab);
+ } else {
+ include DT_ROOT.'/config.inc.php';
+ extract(dhtmlspecialchars($CFG));
+ extract(dhtmlspecialchars($DT));
+ $W = array('天', '一', '二', '三', '四', '五', '六');
+ $smtp_pass = pass_encode($smtp_pass);
+ $ftp_pass = pass_encode($ftp_pass);
+ $trade_pw = pass_encode($trade_pw);
+ $cloud_key = pass_encode($cloud_key);
+ $sms_url = base64_decode('aHR0cHM6Ly93d3cuZGVzdG9vbi5jb20vc21zLnBocD9hY3Rpb249Z2V0JnVpZD0=').DT_CLOUD_UID.'&key='.md5(DT_CLOUD_KEY.'|'.DT_CLOUD_UID);
+ if($kw) {
+ $all = 1;
+ ob_start();
+ }
+ include tpl('setting', $module);
+ if($kw) {
+ $data = $content = ob_get_contents();
+ ob_clean();
+ $data = preg_replace('\'(?!((<.*?)|(]*?)>)|([^>]*?)|([^>]*?))\'si', ''.$kw.' ', $data);
+ $data = preg_replace('//', '', $data, 1);
+ echo $data ? $data : $content;
+ }
+ }
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/skin.inc.php b/admin/skin.inc.php
new file mode 100644
index 0000000..e58a3bd
--- /dev/null
+++ b/admin/skin.inc.php
@@ -0,0 +1,115 @@
+$CFG[\'edittpl\'] = \'0\'; 修改为 $CFG[\'edittpl\'] = \'1\';');
+$menus = array (
+ array('新建样式', '?file=skin&action=add'),
+ array('模板管理', '?file=template'),
+ array('风格管理', '?file=skin'),
+ array('标签向导', '?file=tag'),
+);
+$this_forward = '?file='.$file;
+$skin = get_cookie('skin');
+$skin = check_name($skin) ? $skin : $CFG['skin'];
+$skin_root = DT_ROOT.'/skin/'.$skin.'/';
+is_dir($skin_root) or dir_create($skin_root);
+$skin_path = 'skin/'.$skin.'/';
+isset($fileid) or $fileid = '';
+isset($bakid) or $bakid = '';
+if($fileid && !preg_match("/^[0-9a-z_\-]+$/", $fileid)) msg('文件格式错误');
+
+switch($action) {
+ case 'add':
+ if($submit) {
+ if(!$fileid) msg('文件名不能为空');
+ if(!$content) msg('风格内容不能为空');
+ $dfile = $skin_root.$fileid.'.css';
+ if(isset($nowrite) && is_file($dfile)) msg('文件已经存在');
+ file_put($dfile, strip_sql(stripslashes($content), 0));
+ dmsg('风格添加成功', $this_forward);
+ } else {
+ include tpl('skin_add');
+ }
+ break;
+ case 'edit':
+ if(!$fileid) msg('文件名不能为空');
+ if($submit) {
+ if(!$dfileid) msg('Invalid Request');
+ if(!$content) msg('风格内容不能为空');
+ $dfile = $skin_root.$dfileid.'.css';
+ $nfile = $skin_root.$fileid.'.css';
+ if(isset($backup)) {
+ $i = 0;
+ while(++$i) {
+ $bakfile = $skin_root.$dfileid.'.'.$i.'.bak';
+ if(!is_file($bakfile)) {
+ file_copy($dfile, $bakfile);
+ break;
+ }
+ }
+ }
+ file_put($nfile, strip_sql(stripslashes($content), 0));
+ if($dfileid != $fileid) file_del($dfile);
+ dmsg('风格修改成功', $forward);
+ } else {
+ if(!is_write($skin_root.$fileid.'.css')) msg($fileid.'.css不可写,请将其属性设置为可写');
+ $content = file_get($skin_root.$fileid.'.css');
+ include tpl('skin_edit');
+ }
+ break;
+ case 'import':
+ if(!$fileid) msg('文件名不能为空');
+ if(!$bakid) msg('Invalid Request');
+ if(file_copy($skin_root.$fileid.'.'.$bakid.'.bak', $skin_root.$fileid.'.css')) dmsg('备份文件恢复成功', $this_forward);
+ dmsg('备份文件恢复失败');
+ break;
+ case 'download':
+ if(!$fileid) msg('文件名不能为空');
+ $file_ext = $bakid ? '.'.$bakid.'.bak' : '.css';
+ file_down($skin_root.$fileid.$file_ext);
+ break;
+ case 'delete':
+ if(!$fileid) msg('文件名不能为空');
+ $file_ext = $bakid ? '.'.$bakid.'.bak' : '.css';
+ file_del($skin_root.$fileid.$file_ext);
+ dmsg('文件删除成功', $this_forward);
+ break;
+ case 'change':
+ $to = check_name($to) ? $to : '';
+ if($to && is_dir(DT_ROOT.'/skin/'.$to.'/')) {
+ if($to == $CFG['skin']) $to = '';
+ set_cookie('skin', $to);
+ }
+ dmsg('切换成功', $this_forward);
+ break;
+ default:
+ $files = $skins = $baks = array();
+ $files = glob($skin_root.'*.*');
+ if(!$files) msg('风格文件不存在,请先创建', "?file=$file&action=add");
+ foreach($files as $k=>$v) {
+ $filename = str_replace($skin_root, '', $v);
+ if(preg_match("/^[0-9a-z_-]+\.css$/", $filename)) {
+ $fileid = str_replace('.css', '', $filename);
+ $skins[$fileid]['fileid'] = $fileid;
+ $skins[$fileid]['filename'] = $filename;
+ $skins[$fileid]['filesize'] = round(filesize($v)/1024, 2);
+ $skins[$fileid]['mtime'] = date('Y-m-d H:i', filemtime($v));
+ } else if(preg_match("/^([0-9a-z_-]+)\.([0-9]+)\.bak$/", $filename, $m)) {
+ $fileid = str_replace('.bak', '', $filename);
+ $baks[$fileid]['fileid'] = $fileid;
+ $baks[$fileid]['filename'] = $filename;
+ $baks[$fileid]['filesize'] = round(filesize($v)/1024, 2);
+ $baks[$fileid]['number'] = $m[2];
+ $baks[$fileid]['type'] = $m[1];
+ $baks[$fileid]['mtime'] = date('Y-m-d H:i', filemtime($v));
+ }
+ }
+ if($skins) ksort($skins);
+ if($baks) ksort($baks);
+ include tpl('skin');
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/split.inc.php b/admin/split.inc.php
new file mode 100644
index 0000000..8f5978f
--- /dev/null
+++ b/admin/split.inc.php
@@ -0,0 +1,106 @@
+ 3 or msg();
+$fd = $mid == 4 ? 'userid' : 'itemid';
+$table = get_table($mid);
+$table_data = get_table($mid, 1);
+function table_exists($table) {
+ $result = DB::query("SHOW COLUMNS FROM `$table`");
+ while($r = DB::fetch_array($result)) {
+ if($r) return true;
+ }
+ return false;
+}
+if($action == 'merge') {
+ isset($num) or $num = 5000;
+ if(!isset($fid)) {
+ table_exists($table_data) or msg('表'.$table_data.'不存在,请手动创建后再合并');
+ $r = $db->get_one("SELECT MIN(`$fd`) AS fid FROM {$table}");
+ $fid = $r['fid'] ? $r['fid'] : 0;
+ }
+ isset($sid) or $sid = $fid;
+ if(!isset($tid)) {
+ $r = $db->get_one("SELECT MAX(`$fd`) AS tid FROM {$table}");
+ $tid = $r['tid'] ? $r['tid'] : 0;
+ $part = split_id($tid);
+ for($i = 1; $i <= $part; $i++) {
+ split_content($mid, $i);
+ }
+ }
+ if($fid <= $tid) {
+ $result = $db->query("SELECT `$fd` FROM {$table} WHERE `$fd`>=$fid ORDER BY `$fd` LIMIT 0,$num");
+ if($db->affected_rows($result)) {
+ while($r = $db->fetch_array($result)) {
+ $itemid = $r[$fd];
+ $t = $db->get_one("SELECT content FROM ".split_table($mid, $itemid)." WHERE `$fd`=$itemid");
+ if($t) {
+ $content = addslashes($t['content']);
+ $db->query("REPLACE INTO {$table_data} ($fd,content) VALUES ('$itemid','$content')");
+ } else {
+ $t = $db->get_one("SELECT `$fd` FROM {$table_data} WHERE `$fd`=$itemid");
+ if(!$t) $db->query("REPLACE INTO {$table_data} ($fd,content) VALUES ('$itemid','')");
+ }
+ }
+ $itemid += 1;
+ } else {
+ $itemid = $fid + $num;
+ }
+ } else {
+ $db->halt = 0;
+ $part = split_id($tid);
+ for($i = 1; $i < $part+3; $i++) {
+ $tb = $DT_PRE.$mid.'_'.$i;
+ $db->query("DROP TABLE IF EXISTS `{$tb}`");
+ }
+ msg($MODULE[$mid]['name'].'内容合并成功,请保存模块设置');
+ }
+ msg('ID从'.$fid.'至'.($itemid-1).'合并成功'.progress($sid, $fid, $tid), "?mid=$mid&file=$file&action=$action&sid=$sid&fid=$itemid&tid=$tid&num=$num");
+} else if($action == 'split') {
+ isset($num) or $num = 5000;
+ if(!isset($fid)) {
+ table_exists($table_data) or msg('表'.$table_data.'不存在,请检查是否已经做过分表');
+ $r = $db->get_one("SELECT MIN(`$fd`) AS fid FROM {$table}");
+ $fid = $r['fid'] ? $r['fid'] : 0;
+ }
+ isset($sid) or $sid = $fid;
+ if(!isset($tid)) {
+ $r = $db->get_one("SELECT MAX(`$fd`) AS tid FROM {$table}");
+ $tid = $r['tid'] ? $r['tid'] : 0;
+ $part = split_id($tid);
+ for($i = 1; $i < $part+2; $i++) {
+ split_content($mid, $i);
+ }
+ }
+ if($fid <= $tid) {
+ $result = $db->query("SELECT `$fd` FROM {$table} WHERE `$fd`>=$fid ORDER BY `$fd` LIMIT 0,$num");
+ if($db->affected_rows($result)) {
+ while($r = $db->fetch_array($result)) {
+ $itemid = $r[$fd];
+ $t = $db->get_one("SELECT content FROM {$table_data} WHERE `$fd`=$itemid");
+ if($t) {
+ $content = addslashes($t['content']);
+ $db->query("REPLACE INTO ".split_table($mid, $itemid)." ($fd,content) VALUES ('$itemid','$content')");
+ } else {
+ $t = $db->get_one("SELECT `$fd` FROM ".split_table($mid, $itemid)." WHERE `$fd`=$itemid");
+ if(!$t) $db->query("REPLACE INTO ".split_table($mid, $itemid)." ($fd,content) VALUES ('$itemid','')");
+ }
+ }
+ $itemid += 1;
+ } else {
+ $itemid = $fid + $num;
+ }
+ } else {
+ $table_back = $table_data.'_'.timetodate($DT_TIME, 'Ymd');
+ $db->query("RENAME TABLE `{$table_data}` TO `{$table_back}`");
+ msg($MODULE[$mid]['name'].'内容拆分成功,请保存模块设置');
+ }
+ msg('ID从'.$fid.'至'.($itemid-1).'拆分成功'.progress($sid, $fid, $tid), "?mid=$mid&file=$file&action=$action&sid=$sid&fid=$itemid&tid=$tid&num=$num");
+} else {
+ $split = isset($split) && $split ? 1 : 0;
+ include tpl('split');
+}
+?>
\ No newline at end of file
diff --git a/admin/stats.inc.php b/admin/stats.inc.php
new file mode 100644
index 0000000..893a62b
--- /dev/null
+++ b/admin/stats.inc.php
@@ -0,0 +1,334 @@
+query("DELETE FROM {$DT_PRE}stats_pv WHERE addtime<$time");
+ dmsg('清理成功', '?file='.$file.'&action=pv');
+ break;
+ case 'clear_uv':
+ $time = $DT_TODAY - 365*86400;
+ $db->query("DELETE FROM {$DT_PRE}stats_uv WHERE addtime<$time");
+ dmsg('清理成功', '?file='.$file.'&action=uv');
+ break;
+ case 'clear':
+ $time = $DT_TODAY - 30*86400;
+ $db->query("DELETE FROM {$DT_PRE}404 WHERE addtime<$time");
+ dmsg('清理成功', '?file='.$file.'&action=404');
+ break;
+ case '404':
+ $sfields = array('按条件', '网址', '来源', '搜索引擎', '会员', 'IP', '客户端', '操作系统', '浏览器');
+ $dfields = array('url', 'url', 'refer', 'robot', 'username', 'ip', 'ua', 'os', 'bs');
+ isset($fields) && isset($dfields[$fields]) or $fields = 0;
+ $ip = isset($ip) ? $ip : '';
+ $os = isset($os) ? $os : '';
+ $bs = isset($bs) ? $bs : '';
+ $pc = isset($pc) ? intval($pc) : -1;
+ $robot = isset($robot) ? $robot : '';
+ (isset($username) && check_name($username)) or $username = '';
+ (isset($fromdate) && is_time($fromdate)) or $fromdate = '';
+ $fromtime = $fromdate ? datetotime($fromdate) : 0;
+ (isset($todate) && is_time($todate)) or $todate = '';
+ $totime = $todate ? datetotime($todate) : 0;
+ $fields_select = dselect($sfields, 'fields', '', $fields);
+ $condition = '1';
+ if($keyword) $condition .= match_kw($dfields[$fields], $keyword);
+ if($fromtime) $condition .= " AND addtime>=$fromtime";
+ if($totime) $condition .= " AND addtime<=$totime";
+ if($ip) $condition .= " AND ip='$ip'";
+ if($os) $condition .= " AND os='$os'";
+ if($bs) $condition .= " AND bs='$bs'";
+ if($robot) $condition .= $robot == 'all' ? " AND robot<>''" : " AND robot='$robot'";
+ if($pc > -1) $condition .= " AND pc=$pc";
+ if($username) $condition .= " AND username='$username'";
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = $db->get_one("SELECT COUNT(*) AS num FROM {$DT_PRE}404 WHERE $condition");
+ $items = $r['num'];
+ }
+ $pages = pages($items, $page, $pagesize);
+ $lists = $areas = array();
+ $result = $db->query("SELECT * FROM {$DT_PRE}404 WHERE $condition ORDER BY itemid DESC LIMIT $offset,$pagesize");
+ while($r = $db->fetch_array($result)) {
+ if(isset($areas[$r['ip']])) {
+ $r['area'] = $areas[$r['ip']];
+ } else {
+ $r['area'] = $areas[$r['ip']] = ip2area($r['ip']);
+ }
+ $r['addtime'] = timetodate($r['addtime'], 6);
+ $lists[] = $r;
+ }
+ include tpl('stats_404');
+ break;
+ case 'online':
+ $sfields = array('按条件', '会员名', '会员ID');
+ $dfields = array('username', 'username', 'userid');
+ isset($fields) && isset($dfields[$fields]) or $fields = 0;
+ $sorder = array('结果排序方式', '访问时间降序', '访问时间升序', '会员ID降序', '会员ID升序');
+ $dorder = array('lasttime DESC', 'lasttime DESC', 'lasttime ASC', 'userid DESC', 'userid ASC');
+ isset($order) && isset($dorder[$order]) or $order = 0;
+ $online = isset($online) ? intval($online) : 2;
+
+ $fields_select = dselect($sfields, 'fields', '', $fields);
+ $order_select = dselect($sorder, 'order', '', $order);
+
+ $condition = '1';
+ if($keyword) $condition .= " AND $dfields[$fields]='$kw'";
+ if($mid) $condition .= " AND moduleid=$mid";
+ if($online < 2) $condition .= " AND online=$online";
+ $lastime = $DT_TIME - $DT['online'];
+ $db->query("DELETE FROM {$DT_PRE}online WHERE lasttime<$lastime");
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = $db->get_one("SELECT COUNT(*) AS num FROM {$DT_PRE}online WHERE $condition");
+ $items = $r['num'];
+ }
+ $pages = pages($items, $page, $pagesize);
+ $lists = array();
+ $result = $db->query("SELECT * FROM {$DT_PRE}online WHERE $condition ORDER BY $dorder[$order] LIMIT $offset,$pagesize");
+ while($r = $db->fetch_array($result)) {
+ $r['lasttime'] = timetodate($r['lasttime'], 'H:i:s');
+ $lists[] = $r;
+ }
+ include tpl('stats_online');
+ break;
+ case 'update':
+ require DT_ROOT.'/include/client.func.php';
+ $table = $DT_PRE.'stats_uv';
+ if(!isset($fid)) {
+ $r = $db->get_one("SELECT min(itemid) AS fid FROM {$table}");
+ $fid = $r['fid'] ? $r['fid'] : 0;
+ }
+ if(!isset($tid)) {
+ $r = $db->get_one("SELECT max(itemid) AS tid FROM {$table}");
+ $tid = $r['tid'] ? $r['tid'] : 0;
+ }
+ isset($num) or $num = 100;
+ $itemid or $itemid = 1;
+ if($fid <= $tid) {
+ $result = $db->query("SELECT * FROM {$table} WHERE itemid>=$fid ORDER BY itemid LIMIT 0,$num ");
+ if($db->affected_rows($result)) {
+ while($r = $db->fetch_array($result)) {
+ $itemid = $r['itemid'];
+ $sql = '';
+ /*
+ $area = ip2area($r['ip']);
+ if($area && $area != $r['area']) $sql .= "area='".addslashes($area)."',";
+
+ $country = area_parse($area, 'country');
+ if($country && $country != $r['country']) $sql .= "country='".addslashes($country)."',";
+
+ $province = area_parse($area, 'province');
+ if($province && $province != $r['province']) $sql .= "province='".addslashes($province)."',";
+
+ $city = area_parse($area, 'city');
+ if($city && $city != $r['city']) $sql .= "city='".addslashes($city)."',";
+
+ $network = area_parse($area, 'network');
+ if($network && $network != $r['network']) $sql .= "network='".addslashes($network)."',";
+ */
+
+ $os = get_os($r['ua']);
+ if($os && $os != $r['os']) $sql .= "os='".$os."',";
+
+ $bs = get_bs($r['ua']);
+ if($bs && $bs != $r['bs']) $sql .= "bs='".$bs."',";
+
+ $bd = get_bd($r['ua']);
+ if($bd && $bd != $r['bd']) $sql .= "bd='".$bd."',";
+
+ if($sql) {
+ $sql = substr($sql, 0, -1);
+ $db->query("UPDATE {$table} SET {$sql} WHERE itemid=$itemid");
+ }
+ }
+ $itemid += 1;
+ } else {
+ $itemid = $fid + $num;
+ }
+ } else {
+ msg("更新成功", '?file='.$file.'&action=uv');
+ }
+ msg('ID从'.$fid.'至'.($itemid-1).'转换成功', "?file=$file&action=$action&fid=$itemid&tid=$tid&num=$num", 0);
+ break;
+ case 'report':
+ $job or $job = 'pvs';
+ include tpl('stats_report');
+ break;
+ case 'pv':
+ $sfields = array('按条件', '网址', '来源', '来源域名', '搜索引擎', '会员', '所属商家', 'IP');
+ $dfields = array('url', 'url', 'refer', 'domain', 'robot', 'username', 'homepage', 'ip');
+ isset($fields) && isset($dfields[$fields]) or $fields = 0;
+ $dorder = array('sid DESC', 'addtime DESC', 'addtime ASC');
+ isset($order) && isset($dorder[$order]) or $order = 0;
+ isset($robot) or $robot = '';
+ isset($url) or $url = '';
+ isset($refer) or $refer = '';
+ isset($domain) or $domain = '';
+ $pc = isset($pc) ? intval($pc) : -1;
+ $islink = isset($islink) ? intval($islink) : -1;
+ (isset($fromdate) && is_time($fromdate)) or $fromdate = '';
+ $fromtime = $fromdate ? datetotime($fromdate) : 0;
+ (isset($todate) && is_time($todate)) or $todate = '';
+ $totime = $todate ? datetotime($todate) : 0;
+ $catid or $catid = '';
+ $itemid or $itemid = '';
+
+ $fields_select = dselect($sfields, 'fields', '', $fields);
+ $module_select = module_select('mid', '模块', $mid);
+
+ $condition = '1';
+ if($keyword) $condition .= match_kw($dfields[$fields], $keyword);
+ if($fromtime) $condition .= " AND addtime>=$fromtime";
+ if($totime) $condition .= " AND addtime<=$totime";
+ if($mid) $condition .= " AND mid=$mid";
+ if($catid) $condition .= ($CAT['child']) ? " AND catid IN (".$CAT['arrchildid'].")" : " AND catid=$catid";
+ if($itemid) $condition .= " AND itemid=$itemid";
+ if($url) $condition .= " AND url='$url'";
+ if($refer) $condition .= " AND refer='$refer'";
+ if($domain) $condition .= " AND domain='$domain'";
+ if($robot) $condition .= $robot == 'all' ? " AND robot<>''" : " AND robot='$robot'";
+ if($pc > -1) $condition .= " AND pc=$pc";
+ if($islink > -1) $condition .= $islink ? " AND domain<>''" : " AND domain=''";
+ foreach($dfields as $v) {
+ if(in_array($v, array('url', 'robot'))) continue;
+ isset($$v) or $$v = '';
+ if($$v) $condition .= " AND $v='".$$v."'";
+ }
+
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = $db->get_one("SELECT COUNT(*) AS num FROM {$DT_PRE}stats_pv WHERE $condition");
+ $items = $r['num'];
+ }
+ $pages = pages($items, $page, $pagesize);
+ $lists = $areas = array();
+ $result = $db->query("SELECT * FROM {$DT_PRE}stats_pv WHERE $condition ORDER BY $dorder[$order] LIMIT $offset,$pagesize");
+ while($r = $db->fetch_array($result)) {
+ if(isset($areas[$r['ip']])) {
+ $r['area'] = $areas[$r['ip']];
+ } else {
+ $r['area'] = $areas[$r['ip']] = ip2area($r['ip']);
+ }
+ $r['addtime'] = timetodate($r['addtime'], 6);
+ if($r['refer'] && strpos($r['refer'], '://') === false) $r['refer'] = DT_PATH.($r['refer'] == '/' ? '' : $r['refer']);
+ if(strpos($r['url'], '://') === false) $r['url'] = DT_PATH.$r['url'];
+ $lists[] = $r;
+ }
+ include tpl('stats_pv');
+ break;
+ case 'uv':
+ $sfields = array('按条件', '搜索引擎', 'IP', '地区', '国家', '省份', '城市', '网络', '客户端', '操作系统', '设备品牌', '浏览器', '分辨率');
+ $dfields = array('ua', 'robot', 'ip', 'area', 'country', 'province', 'city', 'network', 'ua', 'os', 'bd', 'bs', 'screen');
+ isset($fields) && isset($dfields[$fields]) or $fields = 0;
+ $dorder = array('itemid DESC', 'addtime DESC', 'addtime ASC');
+ isset($order) && isset($dorder[$order]) or $order = 0;
+ $pc = isset($pc) ? intval($pc) : -1;
+ (isset($fromdate) && is_time($fromdate)) or $fromdate = '';
+ $fromtime = $fromdate ? datetotime($fromdate) : 0;
+ (isset($todate) && is_time($todate)) or $todate = '';
+ $totime = $todate ? datetotime($todate) : 0;
+ isset($robot) or $robot = '';
+
+ $fields_select = dselect($sfields, 'fields', '', $fields);
+
+ $condition = '1';
+ if($keyword) $condition .= match_kw($dfields[$fields], $keyword);
+ if($fromtime) $condition .= " AND addtime>=$fromtime";
+ if($totime) $condition .= " AND addtime<=$totime";
+ if($pc > -1) $condition .= " AND pc=$pc";
+ if($robot) $condition .= $robot == 'all' ? " AND robot<>''" : " AND robot='$robot'";
+ foreach($dfields as $v) {
+ if(in_array($v, array('robot'))) continue;
+ isset($$v) or $$v = '';
+ if($$v) $condition .= " AND $v='".$$v."'";
+ }
+
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = $db->get_one("SELECT COUNT(*) AS num FROM {$DT_PRE}stats_uv WHERE $condition");
+ $items = $r['num'];
+ }
+ $pages = pages($items, $page, $pagesize);
+ $lists = $areas = array();
+ $result = $db->query("SELECT * FROM {$DT_PRE}stats_uv WHERE $condition ORDER BY $dorder[$order] LIMIT $offset,$pagesize");
+ while($r = $db->fetch_array($result)) {
+ if(!$r['screen']) {
+ $r['screen'] = $dc->get('sn-'.md5($r['ip'].$DT_TODAY.strip_sql($r['ua'], 0)));
+ if($r['screen']) $db->query("UPDATE {$DT_PRE}stats_uv SET screen='$r[screen]' WHERE itemid=$r[itemid]");
+ }
+ $r['location'] = $r['province'] ? ''.$r['province'].' '.($r['city'] == $r['province'] ? '' : ' '.$r['city'].' ') : ''.$r['country'].' '.$r['city'].' ';
+ $r['addtime'] = timetodate($r['addtime'], 6);
+ $lists[] = $r;
+ }
+ include tpl('stats_uv');
+ break;
+ default:
+ $W = array('天', '一', '二', '三', '四', '五', '六');
+ $sorder = array('排序方式', '总UV降序', '总UV升序', '电脑UV降序', '电脑UV升序', '手机Uv降序', '手机UV升序', '总IP降序', '总IP升序', '电脑IP降序', '电脑IP升序', '手机IP降序', '手机IP升序', '总PV降序', '总PV升序', '电脑PV降序', '电脑PV升序', '手机PV降序', '手机PV升序', '爬虫PV降序', '爬虫PV升序', '电脑爬虫PV降序', '电脑爬虫PV升序', '手机爬虫PV降序', '手机爬虫PV升序', '日期降序', '日期升序');
+ $dorder = array('id DESC', 'uv DESC', 'uv ASC', 'uv_pc DESC', 'uv_pc ASC', 'uv_mb DESC', 'uv_mb ASC', 'ip DESC', 'ip ASC', 'ip_pc DESC', 'ip_pc ASC', 'ip_mb DESC', 'ip_mb ASC', 'pv DESC', 'pv ASC', 'pv_pc DESC', 'pv_pc ASC', 'pv_mb DESC', 'pv_mb ASC', 'rb DESC', 'rb ASC', 'rb_pc DESC', 'rb_pc ASC', 'rb_mb DESC', 'rb_mb ASC', 'id DESC', 'id ASC');
+ isset($order) && isset($dorder[$order]) or $order = 0;
+
+ isset($fromdate) or $fromdate = '';
+ $fromtime = is_date($fromdate) ? str_replace('-', '', $fromdate) : '';
+ isset($todate) or $todate = '';
+ $totime = is_date($todate) ? str_replace('-', '', $todate) : '';
+ (isset($username) && check_name($username)) or $username = '';
+
+ $order_select = dselect($sorder, 'order', '', $order);
+
+ if($username) {
+ $condition = "username='$username'";
+ $table = $DT_PRE.'stats_user';
+ } else {
+ $condition = '1';
+ $table = $DT_PRE.'stats';
+ }
+ if($fromtime) $condition .= " AND id>=$fromtime";
+ if($totime) $condition .= " AND id<=$totime";
+ if($page > 1 && $sum) {
+ $items = $sum;
+ } else {
+ $r = $db->get_one("SELECT COUNT(*) AS num FROM {$table} WHERE $condition");
+ $items = $r['num'];
+ }
+ $pages = pages($items, $page, $pagesize);
+ $lists = array();
+ $d0 = timetodate(DT_TIME, 3);
+ $d1 = timetodate(DT_TIME - 86400, 3);
+ $d2 = timetodate(DT_TIME - 86400*2, 3);
+ $result = $db->query("SELECT * FROM {$table} WHERE $condition ORDER BY $dorder[$order] LIMIT $offset,$pagesize");
+ while($r = $db->fetch_array($result)) {
+ $r['time'] = datetotime($r['id']);
+ $r['date'] = timetodate($r['time'], 3);
+ $r['week'] = '星期'.$W[date('w', $r['time'])];
+ if($r['date'] == $d0) {
+ $r['week'] = '今日';
+ } elseif($r['date'] == $d1) {
+ $r['week'] = '昨日';
+ } elseif($r['date'] == $d2) {
+ $r['week'] = '前日';
+ }
+ $i++;
+ $lists[] = $r;
+ }
+ include tpl('stats');
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/tag.inc.php b/admin/tag.inc.php
new file mode 100644
index 0000000..147134b
--- /dev/null
+++ b/admin/tag.inc.php
@@ -0,0 +1,146 @@
+ 3) {
+ $table = get_table($mid);
+ $note = urlencode($MODULE[$mid]['name']);
+ } else {
+ $table = $DT_PRE.$tb;
+ $note = '';
+ }
+ dheader('?file='.$file.'&action=dict&table='.$table.'¬e='.$note);
+ break;
+ case 'dict':
+ (isset($table) && $table) or exit;
+ $table = strip_sql($table, 0);
+ if(strpos($table, $DT_PRE) === false) {
+ $rtable = $table;
+ } else {
+ $rtable = substr($table, strlen($DT_PRE));
+ $rtable = preg_replace("/_[0-9]{1,}/", '', $rtable);
+ }
+ if($submit) {
+ $csv = '';
+ foreach($name as $k=>$v) {
+ $v = str_replace(',', ',', $v);
+ $n = str_replace(',', ',', $note[$k]);
+ $csv .= $k.','.$v.','.$n."\n";
+ }
+ file_put(DT_ROOT.'/file/setting/'.$rtable.'.csv', trim($csv));
+ dmsg('更新成功', '?file='.$file.'&action='.$action.'&table='.$table.'¬e='.urlencode($nt));
+ } else {
+ $fields = $csv = array();
+ if(is_file(DT_ROOT.'/file/setting/'.$rtable.'.csv')) {
+ $tmp = file_get(DT_ROOT.'/file/setting/'.$rtable.'.csv');
+ $arr = explode("\n", $tmp);
+ foreach($arr as $v) {
+ $t = explode(',', $v);
+ $csv[$t[0]]['name'] = $t[1];
+ $csv[$t[0]]['note'] = $t[2];
+ }
+ }
+ $result = $db->query("SHOW COLUMNS FROM `$table`");
+ while($r = $db->fetch_array($result)) {
+ $r['Type'] = str_replace(' unsigned', '', $r['Type']);
+ if(isset($csv[$r['Field']])) {
+ $r['cn_name'] = $csv[$r['Field']]['name'];
+ $r['cn_note'] = $csv[$r['Field']]['note'];
+ } else {
+ $r['cn_name'] = $r['cn_note'] = '';
+ //if(isset($names[$r['Field']])) $r['cn_name'] = $names[$r['Field']];
+ }
+ $fields[] = $r;
+ }
+ include tpl('tag_dict');
+ }
+ break;
+ case 'preview':
+ $db->halt = 0;
+ $destoon_task = '';
+ if($tag_css) $tag_css = stripslashes($tag_css);
+ if($tag_html_s) $tag_html_s = stripslashes($tag_html_s);
+ if($tag_html_e) $tag_html_e = stripslashes($tag_html_e);
+ if($tag_code) $tag_code = stripslashes($tag_code);
+ $code_eval = $code_call = $code_html = '';
+ if($tag_css) $code_eval .= ''."\n";
+ if($tag_html_s) $code_eval .= $tag_html_s."\n";
+ $code_call = $code_eval;
+ $code_call .= $tag_code."\n";
+ $tag_code = str_replace('', '', $tag_code);
+ if(strpos($tag_code, '",') !== false) {
+ $tag_code = str_replace(', '.$tag_expires.')', ', -1)', $tag_code);
+ } else {
+ $tag_code = str_replace('")', '", -1)', $tag_code);
+ }
+ $tag_code .= ';';
+ $tag_pass = 1;
+ if(substr($tag_code, 0, 5) != 'tag("') $tag_pass = 0;
+ if(substr($tag_code, -7) != '", -1);') $tag_pass = 0;
+ $tag_safe = substr($tag_code, 5, -7);
+ foreach(array('(', '`', ',', ';') as $v) {
+ if(strpos($tag_safe, $v) !== false) {
+ $tag_pass = 0;
+ break;
+ }
+ }
+ $tag_pass or msg('标签内容包含不安全写法,禁止在线预览');
+ $tag_md5 = md5($tag_safe);
+ $tag_js = '';
+ ob_start();
+ eval($tag_code);
+ $contents = ob_get_contents();
+ ob_clean();
+ $code_eval .= $contents."\n";
+ if($tag_html_e) {
+ $code_eval .= $tag_html_e;
+ $code_call .= $tag_html_e;
+ }
+ $t = str_replace('",', '&debug=1",', $tag_code);
+ ob_start();
+ eval($t);
+ $td = ob_get_contents();
+ ob_clean();
+ $t = explode(' ', $td);
+ $tag_debug = "参数:".$t[0]."\n语句:".$t[1];
+ $head_title = '标签预览';
+ include tpl('tag_preview');
+ break;
+ default:
+ $table_select = $all_select = '';
+ $out = array('ad', 'ad_place', 'admin', 'alert', 'area', 'ask' ,'category', 'favorite', 'finance_cash', 'finance_charge', 'finance_record', 'finance_trade', 'friend', 'group', 'guestbook', 'keylink', 'log', 'mail', 'mail_list', 'message', 'module', 'session', 'style', 'type', 'vip');
+ $query = $db->query("SHOW TABLE STATUS FROM `".$CFG['db_name']."`");
+ while($r = $db->fetch_row($query)) {
+ $table = $r[0];
+ $alltable = preg_match("/^".$DT_PRE."/i", $table) ? substr($table, strlen($DT_PRE)) : $table.'&prefix=';
+ $all_select .= ''.$table.' ';
+ if(substr($table, -5) == '_data' || strpos($table, '_data_') !== false) continue;
+ if(preg_match("/^".$DT_PRE."/i", $table)) {
+ $table = substr($table, strlen($DT_PRE));
+ if(in_array($table, $out)) continue;
+ $s = $db->get_one("SHOW TABLE STATUS FROM `".$CFG['db_name']."` LIKE '".$r[0]."'");
+ $table_select .= ''.($s['Comment'] ? $s['Comment'] : $table).' ';
+ }
+ }
+ $mid or $mid = '';
+ include tpl('tag');
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/template.inc.php b/admin/template.inc.php
new file mode 100644
index 0000000..21b9e5c
--- /dev/null
+++ b/admin/template.inc.php
@@ -0,0 +1,189 @@
+$CFG[\'edittpl\'] = \'0\'; 修改为 $CFG[\'edittpl\'] = \'1\';');
+isset($dir) or $dir = '';
+$menus = array (
+ array('新建模板', '?file='.$file.'&action=add&dir='.$dir),
+ array('模板管理', '?file='.$file),
+ array('风格管理', '?file=skin'),
+ array('标签向导', '?file=tag'),
+);
+isset($bakid) or $bakid = '';
+isset($fileid) or $fileid = '';
+$this_forward = '?file='.$file.'&dir='.$dir;
+$tpl = get_cookie('tpl');
+$tpl = check_name($tpl) ? $tpl : $CFG['template'];
+$template_root = DT_ROOT.'/template/'.$tpl.'/'.$dir;
+$template_path = 'template/'.$tpl.'/'.$dir;
+@include $template_root.'/these.name.php';
+
+function template_name($fileid = '', $name = '') {
+ global $template_root, $names;
+ isset($names) or $names = array();
+ if($fileid && $name) $names[$fileid] = $name;
+ foreach($names as $k => $v) {
+ if(!is_file($template_root.'/'.$k.'.htm') && !is_dir($template_root.'/'.$k)) unset($names[$k]);
+ }
+ if($names) ksort($names);
+ file_put($template_root.'/these.name.php', "");
+}
+
+function template_safe($content, $edit = 0) {
+ $content = stripslashes($content);
+ $content = strip_sql($content, 0);
+ if($edit > 1) return $content;
+ if(preg_match_all("/script([^>]+)>/i", $content, $matches)) {
+ foreach($matches[1] as $m) {
+ $m = strtolower($m);
+ if(strpos($m, 'language') !== false || strpos($m, 'php') !== false) msg('模板内容包含不安全写法,禁止在线修改或预览 如需忽略此提示,请修改根目录config.inc.php $CFG[\'edittpl\'] = \'1\'; 修改为 $CFG[\'edittpl\'] = \'2\';');
+ }
+ }
+ if(preg_match("/(\<\?|\{php|file\(|eval|copy|file_put|file_get|fopen|fwrite|fread)/i", $content)) msg('模板内容包含不安全写法,禁止在线修改或预览 如需忽略此提示,请修改根目录config.inc.php $CFG[\'edittpl\'] = \'1\'; 修改为 $CFG[\'edittpl\'] = \'2\';');
+ return $content;
+}
+
+switch($action) {
+ case 'add':
+ if($submit) {
+ if(!preg_match("/^[a-z0-9_\-]+$/", $fileid)) msg('文件名只能为小写字母、数字、中划线、下划线');
+ if(substr($fileid, -1) == '-') msg('文件名不能以 - 符号结尾');
+ if(substr_count($fileid, '-') > 1) msg('文件名只能包含一个 - 符号');
+ if(!$name) $name = $fileid;
+ $template = $template_root.'/'.$fileid.'.htm';
+ if(isset($nowrite) && is_file($template)) msg('文件已经存在');
+ file_put($template, template_safe($content, $CFG['edittpl']));
+ if($name != $fileid) template_name($fileid, $name);
+ dmsg('创建成功', $this_forward);
+ } else {
+ $content = '';
+ if(isset($type)) $content = dhtmlspecialchars(file_get($template_root.'/'.$type.'.htm'));
+ include tpl('template_add');
+ }
+ break;
+ case 'edit':
+ if($submit) {
+ $dfileid or msg();
+ if(!preg_match("/^[a-z0-9_\-]+$/", $fileid)) msg('文件名只能为小写字母、数字、中划线、下划线');
+ if(substr($fileid, -1) == '-') msg('文件名不能以 - 符号结尾');
+ if(substr_count($fileid, '-') > 1) msg('文件名只能包含一个 - 符号');
+ if(!$name) $name = $fileid;
+ $dfile = $template_root.'/'.$dfileid.'.htm';
+ $nfile = $template_root.'/'.$fileid.'.htm';
+ if(isset($backup)) {
+ $i = 0;
+ while(++$i) {
+ $bakfile = $template_root.'/'.$dfileid.'.'.$i.'.bak';
+ if(!is_file($bakfile)) {
+ file_copy($dfile, $bakfile);
+ break;
+ }
+ }
+ }
+ file_put($nfile, template_safe($content, $CFG['edittpl']));
+ if($dfileid != $fileid) file_del($dfile);
+ if($name != $fileid) template_name($fileid, $name);
+ dmsg('修改成功', '?file='.$file.'&action='.$action.'&fileid='.$fileid.'&dir='.$dir);
+ } else {
+ $fileid or msg();
+ if(!is_write($template_root.'/'.$fileid.'.htm')) msg($fileid.'.htm不可写,请将其属性设置为可写');
+ if($dir) $template_path = $template_path.'/';
+ $name = (isset($names[$fileid]) && $names[$fileid]) ? $names[$fileid] : $fileid;
+ $content = dhtmlspecialchars(file_get($template_root.'/'.$fileid.'.htm'));
+ include tpl('template_edit');
+ }
+ break;
+ case 'preview':
+ $db->halt = 0;
+ require_once DT_ROOT.'/include/template.func.php';
+ $tpl_content = template_safe($content, $CFG['edittpl']);
+ unset($content);
+ $tpl_content = template_parse($tpl_content);
+ cache_write('_preview.tpl.php', $tpl_content, 'tpl');
+ $module = $dir ? $dir : 'destoon';
+ $head_title = '模板预览';
+ include DT_CACHE.'/tpl/_preview.tpl.php';
+ exit();
+ break;
+ case 'import':
+ $fileid or msg();
+ $bakid or msg();
+ if(file_copy($template_root.'/'.$fileid.'.'.$bakid.'.bak', $template_root.'/'.$fileid.'.htm')) dmsg('恢复成功', $this_forward);
+ msg('备份文件恢复失败');
+ break;
+ case 'template_name':
+ $fileid or exit('0');
+ $name or exit('0');
+ template_name($fileid, $name);
+ exit('1');
+ break;
+ case 'download':
+ $fileid or msg();
+ $file_ext = $bakid ? '.'.$bakid.'.bak' : '.htm';
+ file_down($template_root.'/'.$fileid.$file_ext);
+ break;
+ case 'delete':
+ $fileid or msg();
+ $file_ext = $bakid ? '.'.$bakid.'.bak' : '.htm';
+ file_del($template_root.'/'.$fileid.$file_ext);
+ if(!$bakid) template_name();
+ dmsg('删除成功', $this_forward);
+ break;
+ case 'cache':
+ cache_clear('php', 'dir', 'tpl');
+ dmsg('更新成功', $this_forward);
+ break;
+ case 'change':
+ $to = check_name($to) ? $to : '';
+ if($to && is_dir(DT_ROOT.'/template/'.$to.'/')) {
+ if($to == $CFG['template']) $to = '';
+ set_cookie('tpl', $to);
+ }
+ dmsg('切换成功', $this_forward);
+ break;
+ default:
+ $dirs = $files = $templates = $baks = array();
+ if(substr($template_root, -1) != '/') $template_root .= '/';
+ $files = glob($template_root.'*');
+ if(!$files) msg('模板文件不存在,请先创建', "?file=$file&action=add&dir=$dir");
+ foreach($files as $k=>$v) {
+ if(is_dir($v)) {
+ $dirid = basename($v);
+ $dirs[$dirid]['dirname'] = $dirid;
+ $dirs[$dirid]['name'] = (isset($names[$dirid]) && $names[$dirid]) ? $names[$dirid] : $dirid;
+ $dirs[$dirid]['mtime'] = timetodate(filemtime($v), 5);
+ $dirs[$dirid]['mod'] = substr(base_convert(fileperms($v), 10, 8), -4);
+ } else {
+ $filename = str_replace($template_root, '', $v);
+ if(preg_match("/^[0-9a-z_-]+\.htm$/", $filename)) {
+ $fileid = str_replace('.htm', '', $filename);
+ $templates[$fileid]['fileid'] = $fileid;
+ $templates[$fileid]['filename'] = $filename;
+ $templates[$fileid]['filesize'] = round(filesize($v)/1024, 2);
+ $templates[$fileid]['name'] = (isset($names[$fileid]) && $names[$fileid]) ? $names[$fileid] : $fileid;
+ $tmp = strpos($filename, '-');
+ $templates[$fileid]['type'] = $tmp ? substr($filename, 0, $tmp) : $fileid;
+ $templates[$fileid]['mtime'] = timetodate(filemtime($v), 5);
+ $templates[$fileid]['mod'] = substr(base_convert(fileperms($v), 10, 8), -4);
+ } else if(preg_match("/^([0-9a-z_-]+)\.([0-9]+)\.bak$/", $filename, $m)) {
+ $fileid = str_replace('.bak', '', $filename);
+ $baks[$fileid]['fileid'] = $fileid;
+ $baks[$fileid]['filename'] = $filename;
+ $baks[$fileid]['filesize'] = round(filesize($v)/1024, 2);
+ $baks[$fileid]['number'] = $m[2];
+ $baks[$fileid]['type'] = $m[1];
+ $baks[$fileid]['mtime'] = timetodate(filemtime($v), 5);
+ $baks[$fileid]['mod'] = substr(base_convert(fileperms($v), 10, 8), -4);
+ }
+ }
+ }
+ if($dirs) ksort($dirs);
+ if($templates) ksort($templates);
+ if($baks) ksort($baks);
+ include tpl('template');
+ break;
+}
+?>
\ No newline at end of file
diff --git a/admin/template/admin.tpl.php b/admin/template/admin.tpl.php
new file mode 100644
index 0000000..bc0bf9b
--- /dev/null
+++ b/admin/template/admin.tpl.php
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/admin_edit.tpl.php b/admin/template/admin_edit.tpl.php
new file mode 100644
index 0000000..134f438
--- /dev/null
+++ b/admin/template/admin_edit.tpl.php
@@ -0,0 +1,38 @@
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/admin_log.tpl.php b/admin/template/admin_log.tpl.php
new file mode 100644
index 0000000..6a56c2c
--- /dev/null
+++ b/admin/template/admin_log.tpl.php
@@ -0,0 +1,47 @@
+
+
+
+
+
+'.$pages.'' : '';?>
+
+
\ No newline at end of file
diff --git a/admin/template/admin_online.tpl.php b/admin/template/admin_online.tpl.php
new file mode 100644
index 0000000..f2f0af4
--- /dev/null
+++ b/admin/template/admin_online.tpl.php
@@ -0,0 +1,29 @@
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/admin_right.tpl.php b/admin/template/admin_right.tpl.php
new file mode 100644
index 0000000..edca2d3
--- /dev/null
+++ b/admin/template/admin_right.tpl.php
@@ -0,0 +1,200 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/admin_temp.tpl.php b/admin/template/admin_temp.tpl.php
new file mode 100644
index 0000000..4be0ff0
--- /dev/null
+++ b/admin/template/admin_temp.tpl.php
@@ -0,0 +1,52 @@
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/area.tpl.php b/admin/template/area.tpl.php
new file mode 100644
index 0000000..8b6e1c8
--- /dev/null
+++ b/admin/template/area.tpl.php
@@ -0,0 +1,83 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/area_add.tpl.php b/admin/template/area_add.tpl.php
new file mode 100644
index 0000000..de8304b
--- /dev/null
+++ b/admin/template/area_add.tpl.php
@@ -0,0 +1,35 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/banip.tpl.php b/admin/template/banip.tpl.php
new file mode 100644
index 0000000..1f20a42
--- /dev/null
+++ b/admin/template/banip.tpl.php
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+'.$pages.'' : '';?>
+
+
\ No newline at end of file
diff --git a/admin/template/banip_data.tpl.php b/admin/template/banip_data.tpl.php
new file mode 100644
index 0000000..46618ac
--- /dev/null
+++ b/admin/template/banip_data.tpl.php
@@ -0,0 +1,33 @@
+
+
+
+库文件
+更新时间
+最新版本
+
+在线更新
+
+手动下载
+
+
+
+file/ipdata/wry.dat
+
+
+
+
+立即更新
+
+暂无更新
+
+
+立即下载
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/banip_edit.tpl.php b/admin/template/banip_edit.tpl.php
new file mode 100644
index 0000000..82daa9f
--- /dev/null
+++ b/admin/template/banip_edit.tpl.php
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/banip_login.tpl.php b/admin/template/banip_login.tpl.php
new file mode 100644
index 0000000..4b2d299
--- /dev/null
+++ b/admin/template/banip_login.tpl.php
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/banword.tpl.php b/admin/template/banword.tpl.php
new file mode 100644
index 0000000..014fa61
--- /dev/null
+++ b/admin/template/banword.tpl.php
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/cate.tpl.php b/admin/template/cate.tpl.php
new file mode 100644
index 0000000..3653580
--- /dev/null
+++ b/admin/template/cate.tpl.php
@@ -0,0 +1,29 @@
+
+
+
+模块
+分类数量
+添加分类
+管理分类
+
+
+$v) {
+ if($v['islink'] || $v['moduleid'] < 4) continue;
+ $v['num'] = $db->count($DT_PRE.'category', "moduleid=".$v['moduleid']);
+?>
+
+
+
+添加分类
+管理分类
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/category.tpl.php b/admin/template/category.tpl.php
new file mode 100644
index 0000000..9d4f902
--- /dev/null
+++ b/admin/template/category.tpl.php
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+分类总数:
+当前目录:
+
+
+
+
+
+
+
+快捷操作
+
+
+
+注意事项
+
+
+ 如果进行了修改 或删除 分类操作,为了保证操作速度,系统不自动修复结构。请在管理完成 或操作失败 时,点更新缓存以修复分类结构至最新
+ 删除分类 会将分类下的信息移至回收站,分类本身可以修改名称和上级分类,没有特殊情况不建议直接删除分类
+ 修改上级ID可以快速修改分类的上级分类,改变分类结构
+
+ 对于模块,一级分类为行业,二级分类为职位
+
+
+ 对于模块,建议只添加一级分类
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/category_add.tpl.php b/admin/template/category_add.tpl.php
new file mode 100644
index 0000000..2d03607
--- /dev/null
+++ b/admin/template/category_add.tpl.php
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/category_copy.tpl.php b/admin/template/category_copy.tpl.php
new file mode 100644
index 0000000..ce8fe89
--- /dev/null
+++ b/admin/template/category_copy.tpl.php
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/category_edit.tpl.php b/admin/template/category_edit.tpl.php
new file mode 100644
index 0000000..a4c5d0d
--- /dev/null
+++ b/admin/template/category_edit.tpl.php
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/city.tpl.php b/admin/template/city.tpl.php
new file mode 100644
index 0000000..248fef3
--- /dev/null
+++ b/admin/template/city.tpl.php
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+'.$pages.'' : '';?>
+
+
\ No newline at end of file
diff --git a/admin/template/city_edit.tpl.php b/admin/template/city_edit.tpl.php
new file mode 100644
index 0000000..3e5dd4f
--- /dev/null
+++ b/admin/template/city_edit.tpl.php
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/count.tpl.php b/admin/template/count.tpl.php
new file mode 100644
index 0000000..01cc3e7
--- /dev/null
+++ b/admin/template/count.tpl.php
@@ -0,0 +1,193 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/count_repeat.tpl.php b/admin/template/count_repeat.tpl.php
new file mode 100644
index 0000000..fcade6c
--- /dev/null
+++ b/admin/template/count_repeat.tpl.php
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+名称
+重复次数
+查看
+
+$v) {?>
+
+
+
+
+
+
+
+
+ - 指定范围没有检测到重复信息 [重新检测]
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/count_stats.tpl.php b/admin/template/count_stats.tpl.php
new file mode 100644
index 0000000..55d3144
--- /dev/null
+++ b/admin/template/count_stats.tpl.php
@@ -0,0 +1,135 @@
+
+
+
+
+
+
+
+
+>
+
+
+
+选择年
+= 2000; $i--) { ?>
+>年
+
+
+
+选择月
+
+>月
+
+
+
+
+
+
+
+ 1) { $xd .= ','; $yd .= ','; }
+ $f = datetotime($ym.'-'.$i.' 00:00:00');
+ $t = datetotime($ym.'-'.$i.' 23:59:59');
+ $r = $db->get_one("SELECT COUNT(*) AS num FROM {$tb} WHERE `$fd`>=$f AND `$fd`<=$t");
+ $xd .= "'".$i."日'";
+ $yd .= $r['num'];
+ }
+?>
+
+
+
+ 1) { $xd .= ','; $yd .= ','; }
+ $f = datetotime($ym.'-'.$i.'-1 00:00:00');
+ $d = date('t', $f);
+ $t = datetotime($ym.'-'.$i.'-'.$d.' 23:59:59');
+ $r = $db->get_one("SELECT COUNT(*) AS num FROM {$tb} WHERE `$fd`>=$f AND `$fd`<=$t");
+ $xd .= "'".$i."月'";
+ $yd .= $r['num'];
+ }
+?>
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/cron.tpl.php b/admin/template/cron.tpl.php
new file mode 100644
index 0000000..a97ddac
--- /dev/null
+++ b/admin/template/cron.tpl.php
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+'.$pages.'' : '';?>
+
+
\ No newline at end of file
diff --git a/admin/template/cron_edit.tpl.php b/admin/template/cron_edit.tpl.php
new file mode 100644
index 0000000..5632840
--- /dev/null
+++ b/admin/template/cron_edit.tpl.php
@@ -0,0 +1,130 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/data.tpl.php b/admin/template/data.tpl.php
new file mode 100644
index 0000000..f27ebd1
--- /dev/null
+++ b/admin/template/data.tpl.php
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/data_import.tpl.php b/admin/template/data_import.tpl.php
new file mode 100644
index 0000000..55e67b4
--- /dev/null
+++ b/admin/template/data_import.tpl.php
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/data_move.tpl.php b/admin/template/data_move.tpl.php
new file mode 100644
index 0000000..5496f0f
--- /dev/null
+++ b/admin/template/data_move.tpl.php
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/data_view.tpl.php b/admin/template/data_view.tpl.php
new file mode 100644
index 0000000..afef77f
--- /dev/null
+++ b/admin/template/data_view.tpl.php
@@ -0,0 +1,43 @@
+
+
+
+$v) { ?>
+
+
+
+
+
+
+
+
+
+
+
+导入数据
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/database.tpl.php b/admin/template/database.tpl.php
new file mode 100644
index 0000000..3034417
--- /dev/null
+++ b/admin/template/database.tpl.php
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
+
+共 个表 / M 备份选中
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/database_comment.tpl.php b/admin/template/database_comment.tpl.php
new file mode 100644
index 0000000..0539d5f
--- /dev/null
+++ b/admin/template/database_comment.tpl.php
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/database_dict.tpl.php b/admin/template/database_dict.tpl.php
new file mode 100644
index 0000000..b37a58e
--- /dev/null
+++ b/admin/template/database_dict.tpl.php
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/database_execute.tpl.php b/admin/template/database_execute.tpl.php
new file mode 100644
index 0000000..1a9b2d5
--- /dev/null
+++ b/admin/template/database_execute.tpl.php
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+$v) {?>
+
+
+
+
+
+$v) {?>
+
+
+
+
+$v) {?>
+
+$vv) {?>
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/database_import.tpl.php b/admin/template/database_import.tpl.php
new file mode 100644
index 0000000..0882ff0
--- /dev/null
+++ b/admin/template/database_import.tpl.php
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/database_open.tpl.php b/admin/template/database_open.tpl.php
new file mode 100644
index 0000000..72a3993
--- /dev/null
+++ b/admin/template/database_open.tpl.php
@@ -0,0 +1,27 @@
+
+
+
+文件名称
+文件大小(M)
+修改时间
+分卷
+操作
+
+
+
+
+
+
+
+
+导入 | 下载
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/database_process.tpl.php b/admin/template/database_process.tpl.php
new file mode 100644
index 0000000..c6a8969
--- /dev/null
+++ b/admin/template/database_process.tpl.php
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/database_replace.tpl.php b/admin/template/database_replace.tpl.php
new file mode 100644
index 0000000..80c3cb1
--- /dev/null
+++ b/admin/template/database_replace.tpl.php
@@ -0,0 +1,127 @@
+
+
+
+
+备份内容替换
+
+
+
+
+
+
+数据内容替换
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/database_verify.tpl.php b/admin/template/database_verify.tpl.php
new file mode 100644
index 0000000..ea41bb5
--- /dev/null
+++ b/admin/template/database_verify.tpl.php
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+表名
+注释
+字段数
+记录数
+校验结果
+详情
+
+$v) {?>
+
+
+
+
+
+
+
+异常';
+} else {
+ echo '未知 ';
+}
+?>
+
+
+
+
+
+$v) {?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/template/dialog.tpl.php b/admin/template/dialog.tpl.php
new file mode 100644
index 0000000..64fac96
--- /dev/null
+++ b/admin/template/dialog.tpl.php
@@ -0,0 +1,29 @@
+
+
+
+
+
+提示信息
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+