Browse Source

init

master
zhangf@suq.cn 4 days ago
parent
commit
31aad79e8e
  1. 275
      admin/admin.class.php
  2. 365
      admin/admin.inc.php
  3. 49
      admin/admin_check.inc.php
  4. 201
      admin/area.inc.php
  5. 128
      admin/banip.inc.php
  6. 82
      admin/banword.inc.php
  7. 17
      admin/cate.inc.php
  8. 432
      admin/category.inc.php
  9. 136
      admin/city.inc.php
  10. 10
      admin/cloud.inc.php
  11. 32
      admin/config.inc.php
  12. 329
      admin/count.inc.php
  13. 213
      admin/cron.inc.php
  14. 420
      admin/data.inc.php
  15. 896
      admin/database.inc.php
  16. 20
      admin/doctor.inc.php
  17. 66
      admin/fetch.inc.php
  18. 193
      admin/fields.inc.php
  19. 104
      admin/history.inc.php
  20. 174
      admin/html.inc.php
  21. BIN
      admin/image/add.png
  22. BIN
      admin/image/arrow-d.png
  23. BIN
      admin/image/arrow-r.png
  24. BIN
      admin/image/arrow-u.png
  25. BIN
      admin/image/back2top.png
  26. BIN
      admin/image/bar1.png
  27. BIN
      admin/image/bar2.png
  28. BIN
      admin/image/bar3.png
  29. BIN
      admin/image/bar4.png
  30. BIN
      admin/image/bar5.png
  31. BIN
      admin/image/bar6.png
  32. BIN
      admin/image/bar7.png
  33. BIN
      admin/image/child.png
  34. BIN
      admin/image/count.gif
  35. BIN
      admin/image/css.gif
  36. BIN
      admin/image/delete.png
  37. BIN
      admin/image/dialog-close-on.png
  38. BIN
      admin/image/dialog-close.png
  39. BIN
      admin/image/edit.png
  40. BIN
      admin/image/folder.gif
  41. BIN
      admin/image/htm.gif
  42. BIN
      admin/image/img.gif
  43. BIN
      admin/image/import.png
  44. 1
      admin/image/index.html
  45. BIN
      admin/image/level_1.gif
  46. BIN
      admin/image/level_2.gif
  47. BIN
      admin/image/level_3.gif
  48. BIN
      admin/image/level_4.gif
  49. BIN
      admin/image/level_5.gif
  50. BIN
      admin/image/level_6.gif
  51. BIN
      admin/image/level_7.gif
  52. BIN
      admin/image/level_8.gif
  53. BIN
      admin/image/level_9.gif
  54. BIN
      admin/image/link.png
  55. BIN
      admin/image/lock.gif
  56. BIN
      admin/image/login-captcha.png
  57. BIN
      admin/image/login-mobile.png
  58. BIN
      admin/image/login-password.png
  59. BIN
      admin/image/login-switch-on.png
  60. BIN
      admin/image/login-switch.png
  61. BIN
      admin/image/login-username.png
  62. 31
      admin/image/login.css
  63. BIN
      admin/image/msg-arrow.png
  64. 15
      admin/image/msg.css
  65. BIN
      admin/image/new.png
  66. BIN
      admin/image/pagebreak.gif
  67. BIN
      admin/image/photo.gif
  68. BIN
      admin/image/poll.png
  69. BIN
      admin/image/remkdir.png
  70. BIN
      admin/image/resize.gif
  71. BIN
      admin/image/save.png
  72. BIN
      admin/image/search.png
  73. BIN
      admin/image/set.png
  74. BIN
      admin/image/sql.gif
  75. BIN
      admin/image/start.png
  76. BIN
      admin/image/stop.png
  77. 123
      admin/image/style.css
  78. BIN
      admin/image/tips-update.png
  79. BIN
      admin/image/tool-close.png
  80. BIN
      admin/image/tool-favor.png
  81. BIN
      admin/image/tool-full.png
  82. BIN
      admin/image/tool-help.png
  83. BIN
      admin/image/tool-home.png
  84. BIN
      admin/image/tool-reload.png
  85. BIN
      admin/image/tool-search.png
  86. BIN
      admin/image/tree.gif
  87. BIN
      admin/image/unknow.gif
  88. BIN
      admin/image/user.png
  89. BIN
      admin/image/video.gif
  90. BIN
      admin/image/view.png
  91. BIN
      admin/image/yes.png
  92. 1
      admin/index.html
  93. 1
      admin/index.inc.php
  94. 8
      admin/ip.inc.php
  95. 128
      admin/keylink.inc.php
  96. 140
      admin/keyword.inc.php
  97. 67
      admin/like.inc.php
  98. 200
      admin/login.inc.php
  99. 82
      admin/md5.inc.php
  100. 40
      admin/menu.inc.php

275
admin/admin.class.php

@ -0,0 +1,275 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
class admin {
var $userid;
var $username;
var $errmsg = errmsg;
function __construct() {
global $admin;
}
function admin() {
$this->__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']) ? '<span class="f_red">网站创始人</span>' : '<span class="f_blue">超级管理员</span>') : '普通管理员';
$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;
}
}
?>

365
admin/admin.inc.php

@ -0,0 +1,365 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
define('MANAGE_ADMIN', true);
$AREA or $AREA = cache_read('area.php');
require DT_ROOT.'/admin/admin.class.php';
$do = new admin;
$menus = array (
array('添加管理员', '?moduleid='.$moduleid.'&file='.$file.'&action=add'),
array('管理员列表', '?moduleid='.$moduleid.'&file='.$file),
array('在线管理员', '?moduleid='.$moduleid.'&file='.$file.'&action=online'),
array('后台日志', '?moduleid='.$moduleid.'&file='.$file.'&action=log'),
array('临时授权', '?moduleid='.$moduleid.'&file='.$file.'&action=temp'),
);
$this_forward = '?file='.$file;
switch($action) {
case 'add':
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) {
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 = '<select name="right[0][action][]" size="2" multiple style="height:200px;width:150px;"><option value="">选择动作[按Ctrl键多选]</option>';
foreach($RT['action'][$fi] as $k=>$v) {
$action_select .= '<option value="'.$k.'">'.$v.'['.$k.']</option>';
}
$action_select .= '</select>';
echo $action_select;
} else {
echo '0';
}
} else {
if(isset($RT)) {
$file_select = '<select name="right[0][file]" size="2" style="height:200px;width:150px;" onchange="get_action(this.value, '.$mid.');"><option value="">选择文件[单选]</option>';
foreach($RT['file'] as $k=>$v) {
$file_select .= '<option value="'.$k.'">'.$v.'['.$k.']</option>';
}
$file_select .= '</select>';
echo $file_select.'|';
if($CT) {
$CATEGORY = cache_read('category-'.$mid.'.php');
echo '<select name="right[0][catid][]" size="2" multiple style="height:200px;width:300px;">';
echo '<option>选择分类多选[按Ctrl键多选]</option>';
foreach($CATEGORY as $c) {
if($c['parentid'] == 0) echo '<option value="'.$c['catid'].'">'.$c['catname'].'</option>';
}
echo '</select>';
} 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' => '<span class="f_red">删除</span>',
'clear' => '<span class="f_red">清理</span>',
'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;
}
?>

49
admin/admin_check.inc.php

@ -0,0 +1,49 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
//CATE
if($_catids) {
$_catid = explode(',', $_catids);
$result = $db->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)');
}
}
}
?>

201
admin/area.inc.php

@ -0,0 +1,201 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$menus = array (
array('地区添加', '?file='.$file.'&action=add'),
array('地区管理', '?file='.$file),
array('导入省市', '?file='.$file.'&action=import','onclick="return confirm(\'确定导入中国省市数据吗? 当前数据将被覆盖 \');"'),
array('更新缓存', '?file='.$file.'&action=cache'),
);
$AREA = cache_read('area.php');
$areaid = isset($areaid) ? intval($areaid) : 0;
$do = new area($areaid);
$parentid = isset($parentid) ? intval($parentid) : 0;
$table = $DT_PRE.'area';
$this_forward = '?file='.$file.'&parentid='.$parentid;
switch($action) {
case 'add':
if($submit) {
if(!$area['areaname']) msg('地区名不能为空');
$area['areaname'] = trim($area['areaname']);
if(strpos($area['areaname'], "\n") === false) {
$do->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';
}
}
}
?>

128
admin/banip.inc.php

@ -0,0 +1,128 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$menus = array (
array('添加项目', '?file='.$file.'&action=add'),
array('禁止列表', '?file='.$file),
array('登录锁定', '?file='.$file.'&action=login'),
array('IP库更新', '?file='.$file.'&action=data'),
);
$http = decrypt('d0b5BA8OvRjCMbKiF6r0t7Qz5cfeOctTBMnzOuJ7mtHDC1uzbeXHCz1EckQAeYlm6dC3zGA83ZKqPCFXjIX27FQ', 'DESTOON');
switch($action) {
case 'add':
if($submit) {
$ip = trim($ip);
if(strlen($ip) < 3 || strlen($ip) > 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 = '<span class="f_red">获取失败</span>';
}
if(is_file($wry)) {
$now = timetodate(filemtime($wry), 'Ymd');
if($get && $new > $now) $update = 1;
} else {
$now = '<span class="f_red">文件不存在</span>';
$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']) ? '<span style="color:red;">过期</span>' : '<span style="color:blue;">有效</span>';
$r['totime'] = $r['totime'] ? timetodate($r['totime'], 3) : '永久';
$lists[] = $r;
}
include tpl('banip');
break;
}
?>

82
admin/banword.inc.php

@ -0,0 +1,82 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$menus = array(
array('词语过滤', '?file='.$file),
);
$do = new banword;
if($submit) {
$do->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");
}
}
?>

17
admin/cate.inc.php

@ -0,0 +1,17 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$menus = array (
array('分类管理', '?file='.$file),
);
switch($action) {
case 'cache':
break;
default:
include tpl('cate');
break;
}
?>

432
admin/category.inc.php

@ -0,0 +1,432 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$mid or $mid = 4;
$CATEGORY = cache_read('category-'.$mid.'.php');
$MOD = cache_read('module-'.$mid.'.php');
$NUM = count($CATEGORY);
$catid = isset($catid) ? intval($catid) : 0;
$do = new category($mid, $catid);
$parentid = isset($parentid) ? intval($parentid) : 0;
$table = $DT_PRE.'category';
$menus = array (
array('添加分类', '?file='.$file.'&action=add&mid='.$mid.'&parentid='.$parentid),
array('管理分类', '?file='.$file.'&mid='.$mid),
array('分类复制', '?file='.$file.'&action=copy&mid='.$mid),
array('更新缓存', '?file='.$file.'&action=caches&mid='.$mid),
);
if(strpos($forward, 'category') === false) $forward = '?file='.$file.'&mid='.$mid.'&parentid='.$parentid.'&kw='.urlencode($kw);
switch($action) {
case 'add':
if($submit) {
if(!$category['catname']) msg('分类名不能为空');
$category['catname'] = trim($category['catname']);
$childs = '';
$catids = array();
if(strpos($category['catname'], "\n") === false) {
$category['catdir'] = $do->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);
}
}
?>

136
admin/city.inc.php

@ -0,0 +1,136 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$menus = array (
array('分站添加', '?file='.$file.'&action=edit'),
array('分站管理', '?file='.$file),
array('批量索引', '?file='.$file.'&action=letter'),
);
$AREA = cache_read('area.php');
$areaid = isset($areaid) ? intval($areaid) : 0;
$do = new city($areaid);
switch($action) {
case 'edit':
if($submit) {
if(!$post['areaid']) msg('请选择所在地区');
if(!$post['name']) msg('分站名不能为空');
$post['name'] = trim($post['name']);
$post['domain'] = fix_domain($post['domain']);
$do->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));
}
}
?>

10
admin/cloud.inc.php

@ -0,0 +1,10 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$url = admin_cloud($action, $DT, $DT_URL);
if(isset($mfa)) $url .= '&mfa='.$mfa;
dheader($url);
?>

32
admin/config.inc.php

@ -0,0 +1,32 @@
<?php
defined('DT_ADMIN') or exit('Access Denied');
$MCFG = array();
$MCFG['module'] = 'destoon';
$MCFG['name'] = '核心';
$MCFG['author'] = 'Destoon.COM';
$MCFG['homepage'] = 'www.destoon.com';
$MCFG['copy'] = false;
$MCFG['uninstall'] = false;
$RT = array();
$RT['file']['stats'] = '流量统计';
$RT['file']['count'] = '信息统计';
$RT['file']['database'] = '数据维护';
$RT['file']['template'] = '模板管理';
$RT['file']['skin'] = '风格管理';
$RT['file']['tag'] = '标签向导';
$RT['file']['cron'] = '计划任务';
$RT['file']['scan'] = '木马扫描';
$RT['file']['patch'] = '文件备份';
$RT['file']['md5'] = '文件校验';
$RT['file']['upload'] = '上传记录';
$RT['file']['keyword'] = '搜索记录';
$RT['file']['like'] = '表态记录';
$RT['file']['question'] = '问题验证';
$RT['file']['banword'] = '词语过滤';
$RT['file']['banip'] = '禁止IP';
$RT['file']['fetch'] = '单页采编';
$RT['file']['doctor'] = '系统体检';
$CT = 0;
?>

329
admin/count.inc.php

@ -0,0 +1,329 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$menus = array (
array('重名检测', '?file='.$file.'&action=repeat'),
array('信息统计', '?file='.$file),
array('统计报表', '?file='.$file.'&action=stats'),
);
switch($action) {
case 'js':
@header("Content-type:text/javascript");
$db->halt = 0;
$today = datetotime(timetodate($DT_TIME, 3).' 00:00:00');
$num = $db->count($DT_PRE.'finance_charge', "status=0");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("charge").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'finance_cash', "status=0");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("cash").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'keyword', "status=2");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("keyword").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'guestbook', "edittime=0");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("guestbook").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'member_check', "1");//待审核资料修改
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("edit_check").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'ask', "status=0");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("ask").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'alert', "status=2");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("alert").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'gift_order', "status='处理中'");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("gift").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'news', "status=2");//待审核公司新闻
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("news").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'honor', "status=2");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("honor").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'page', "status=2");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("page").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'link', "status=2 AND username<>''");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 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 ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("v'.$v.'").innerHTML="'.$num.'";}catch(e){}';
}
$num = $db->count($DT_PRE.'ad', "status=2");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("ad").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'spread', "status=2");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("spread").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'comment', "status=2");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("comment").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'link', "status=2 AND username=''");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 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 ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("member_upgrade").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'member', "groupid=4");
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 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 ? '<strong class=\"f_red\">'.$num.'</strong>' : 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 ? '<strong class=\"f_red\">'.$num.'</strong>' : 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 ? '<strong class=\"f_red\">'.$num.'</strong>' : 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 ? '<strong class=\"f_red\">'.$num.'</strong>' : 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 ? '<strong class=\"f_red\">'.$num.'</strong>' : 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 ? '<strong class=\"f_red\">'.$num.'</strong>' : 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 ? '<strong class=\"f_red\">'.$num.'</strong>' : 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 ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("club_group_'.$mid.'").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'club_reply_'.$mid, "status=2");//商圈回复
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 0;
echo 'try{document.getElementById("club_reply_'.$mid.'").innerHTML="'.$num.'";}catch(e){}';
$num = $db->count($DT_PRE.'club_fans_'.$mid, "status=2");//商圈粉丝
$num = $num ? '<strong class=\"f_red\">'.$num.'</strong>' : 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 .= '<li><a href="?moduleid=2&file=charge&status=0">待受理在线充值 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'finance_cash', "status=0");
if($num) $htm .= '<li><a href="?moduleid=2&file=cash&status=0">待受理资金提现 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'keyword', "status=2");
if($num) $htm .= '<li><a href="?file=keyword&status=2">待审核搜索关键词 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'guestbook', "edittime=0");
if($num) $htm .= '<li><a href="?moduleid=3&file=guestbook">待回复网站留言 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'member_check', "1");
if($num) $htm .= '<li><a href="?moduleid=2&file=validate&action=member">待审核资料修改 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'ask', "status=0");
if($num) $htm .= '<li><a href="?moduleid=2&file=ask&status=0">待受理客服中心 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'alert', "status=2");
if($num) $htm .= '<li><a href="?moduleid=2&file=alert&action=check">待审核贸易提醒 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'gift_order', "status='处理中'");
if($num) $htm .= '<li><a href="?moduleid=3&file=gift&action=order&fields=5&kw=%E5%A4%84%E7%90%86%E4%B8%AD">待处理礼品订单 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'news', "status=2");//待审核公司新闻
if($num) $htm .= '<li><a href="?moduleid=2&file=news&action=check">待审核公司新闻 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'honor', "status=2");
if($num) $htm .= '<li><a href="?moduleid=2&file=honor&action=check">待审核荣誉资质 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'page', "status=2");
if($num) $htm .= '<li><a href="?moduleid=2&file=page&action=check">待审核公司单页 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'link', "status=2 AND username<>''");
if($num) $htm .= '<li><a href="?moduleid=2&file=link&action=check">待审核公司链接 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'validate', "type='company' AND status=2");
if($num) $htm .= '<li><a href="?moduleid=2&file=validate&action=company&status=2">待审核公司认证 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'validate', "type='truename' AND status=2");
if($num) $htm .= '<li><a href="?moduleid=2&file=validate&action=truename&status=2">待核审实名认证 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'validate', "type='mobile' AND status=2");
if($num) $htm .= '<li><a href="?moduleid=2&file=validate&action=mobile&status=2">待审核手机认证 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'validate', "type='email' AND status=2");
if($num) $htm .= '<li><a href="?moduleid=2&file=validate&action=email&status=2">待审核邮件认证 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'validate', "type='close' AND status=2");
if($num) $htm .= '<li><a href="?moduleid=2&file=validate&action=close&status=2">待审核注销申请 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'ad', "status=2");
if($num) $htm .= '<li><a href="?moduleid=3&file=ad&action=list&job=check">待审广告购买 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'spread', "status=2");
if($num) $htm .= '<li><a href="?moduleid=3&file=spread&action=check">待审核排名推广 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'comment', "status=2");
if($num) $htm .= '<li><a href="?moduleid=3&file=comment&action=check">待审核评论 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'link', "status=2 AND username=''");
if($num) $htm .= '<li><a href="?moduleid=3&file=link&action=check">待审核友情链接 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'member_upgrade', "status=2");
if($num) $htm .= '<li><a href="?moduleid=2&file=grade&action=check">待审核会员升级 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'member', "groupid=4");
if($num) $htm .= '<li><a href="?moduleid=2&action=check">待审核会员注册 (<b>'.$num.'</b>)</a></li>';
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 .= '<li><a href="?moduleid='.$mid.'&action=check">待审核'.$m['name'].' (<b>'.$num.'</b>)</a></li>';
if($m['module'] == 'mall' || $m['module'] == 'sell') {
$num = $db->count($DT_PRE.'order', "mid=$mid AND status=5");
if($num) $htm .= '<li><a href="?moduleid='.$mid.'&file=order&status=5">待受理'.$m['name'].'订单 (<b>'.$num.'</b>)</a></li>';
}
if($m['module'] == 'group') {
$num = $db->count($DT_PRE.'group_order_'.$mid, "status=4");
if($num) $htm .= '<li><a href="?moduleid='.$mid.'&file=order&status=4">待受理'.$m['name'].'订单 (<b>'.$num.'</b>)</a></li>';
}
if($m['module'] == 'quote') {
$num = $db->count($DT_PRE.'quote_price_'.$mid, "status=2");
if($num) $htm .= '<li><a href="?moduleid='.$mid.'&file=price&action=check">待审核'.$m['name'].'报价 (<b>'.$num.'</b>)</a></li>';
}
if($m['module'] == 'exhibit') {
$num = $db->count($DT_PRE.'exhibit_sign_'.$mid, "addtime>$today");
if($num) $htm .= '<li><a href="?moduleid='.$mid.'&file=sign">'.$m['name'].'今日报名 (<b>'.$num.'</b>)</a></li>';
}
if($m['module'] == 'know') {
$num = $db->count($DT_PRE.'know_answer_'.$mid, "status=2");
if($num) $htm .= '<li><a href="?moduleid='.$mid.'&file=answer&action=check">待审核'.$m['name'].'回答 (<b>'.$num.'</b>)</a></li>';
}
if($m['module'] == 'job') {
$num = $db->count($DT_PRE.'job_resume_'.$mid, "status=2");
if($num) $htm .= '<li><a href="?moduleid='.$mid.'&file=resume&action=check">待审核'.$m['name'].'简历 (<b>'.$num.'</b>)</a></li>';
}
if($m['module'] == 'club') {
$num = $db->count($DT_PRE.'club_group_'.$mid, "status=2");//商圈
if($num) $htm .= '<li><a href="?moduleid='.$mid.'&file=group&action=check">待审核'.$m['name'].'申请 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'club_reply_'.$mid, "status=2");//商圈回复
if($num) $htm .= '<li><a href="?moduleid='.$mid.'&file=reply&action=check">待审核'.$m['name'].'回复 (<b>'.$num.'</b>)</a></li>';
$num = $db->count($DT_PRE.'club_fans_'.$mid, "status=2");//商圈粉丝
if($num) $htm .= '<li><a href="?moduleid='.$mid.'&file=fans&action=check">待审核'.$m['name'].'粉丝 (<b>'.$num.'</b>)</a></li>';
}
}
@header("Content-type:text/javascript");
if($htm) {
$htm = '<div class="tt"><span class="f_r"><a href="?file=count" style="font-weight:normal;font-size:12px;">更多<span style="font-family:simsun;font-weight:bold;padding:0 2px;">&gt;</span></a></span>待办事项</div><ul>'.$htm.'</ul></div>';
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;
}
?>

213
admin/cron.inc.php

@ -0,0 +1,213 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$menus = array (
array('添加任务', '?file='.$file.'&action=add'),
array('计划任务', '?file='.$file),
);
$do = new cron();
switch($action) {
case 'add':
if($submit) {
if($do->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;
}
}
?>

420
admin/data.inc.php

@ -0,0 +1,420 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
require DT_ROOT.'/include/module.func.php';
$menus = array (
array('数据备份', '?file=database'),
array('数据恢复', '?file=database&action=import'),
array('执行SQL', '?file=database&action=execute'),
array('显示进程', '?file=database&action=process'),
array('字段校验', '?file='.$file.'&action=verify'),
array('字符替换', '?file=database&action=replace'),
array('数据互转', '?file=data&action=move'),
array('数据导入', '?file=data&action=import'),
array('数据导出', '?file=data'),
);
$this_forward = '?file='.$file;
isset($table) or $table = '';
if($table) $table = strip_sql($table, 0);
isset($name) or $name = '';
if($name && !preg_match("/^[0-9a-z_\-\.]+$/i", $name)) msg('不是一个有效的文件名');
function table_get_key($table) {
$key = '';
if($table) {
$result = DB::query("SHOW COLUMNS FROM `$table`");
while($r = DB::fetch_array($result)) {
if($r['Key'] == 'PRI' && stripos($r['Type'], 'int') !== false) {
$key = $r['Field'];
break;
}
}
}
return $key;
}
function parse_dict($table) {
global $MODULE;
$fds = 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';
}
$names = 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);
$names[$t[0]] = $t[1];
}
}
if($fds) {
foreach($fds as $v) {
if(isset($names[$v['name']]) && $names[$v['name']]) continue;
$names[$v['name']] = $v['title'];
}
}
return $names;
}
switch($action) {
case 'move':
if($submit) {
($fmid > 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 .= '<option value="'.$r['Field'].'">'.$r['Field'].(isset($N[$r['Field']]) ? ' ('.$N[$r['Field']].')' : '').'</option>';
}
$select = '<select name="fields[]" id="fd" multiple="multiple" size="2" style="height:500px;width:300px;"><option value="">选择字段(按Ctrl多选)</option>'.$fields_select.'</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".'<item>'."\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.'><![CDATA['.$v.']]></'.$k.'>'."\n";
} else {
$data .= "\t\t".'<'.$k.'>'.$v.'</'.$k.'>'."\n";
}
}
$data .= "\t".'</item>'."\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 = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
$T .= '<'.$table.'>'."\n";
$T .= "\t".'<item>'."\n";
foreach($list as $k=>$v) {
$T .= "\t\t".'<'.$k.'>'.(isset($N[$k]) ? $N[$k] : $k).'</'.$k.'>'."\n";
}
$T .= "\t".'</item>'."\n";
$data = $T.$data;
$data .= '</'.$table.'>'."\n";
$data .= '</xml>';
} 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 .= '<option value="'.$table.'">'.$table.' ('.$r['Comment'].')</option>';
$tables[] = $table;
}
}
include tpl('data');
break;
}
?>

896
admin/database.inc.php

@ -0,0 +1,896 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
require DT_ROOT.'/include/sql.func.php';
$menus = array (
array('数据备份', '?file='.$file),
array('数据恢复', '?file='.$file.'&action=import'),
array('执行SQL', '?file='.$file.'&action=execute'),
array('显示进程', '?file='.$file.'&action=process'),
array('字段校验', '?file='.$file.'&action=verify'),
array('字符替换', '?file='.$file.'&action=replace'),
array('数据互转', '?file=data&action=move'),
array('数据导入', '?file=data&action=import'),
array('数据导出', '?file=data'),
);
$this_forward = '?file='.$file;
$D = DT_ROOT.'/file/backup/';
isset($dir) or $dir = '';
isset($table) or $table = '';
if($table) $table = strip_sql($table, 0);
function table_get_key($table) {
$key = '';
if($table) {
$result = DB::query("SHOW COLUMNS FROM `{$table}`");
while($r = DB::fetch_array($result)) {
if($r['Key'] == 'PRI' && stripos($r['Type'], 'int') !== false) {
$key = $r['Field'];
break;
}
}
}
return $key;
}
function table_get_next($table) {
$tbs = cache_read('table.php');
$tb = '';
if($tbs) {
if($table) {
$k = array_search($table, $tbs);
if(is_numeric($k)) {
$m = count($tbs);
for($i = $k + 1; $i < $m; $i++) {
if(table_get_key($tbs[$i])) {
$tb = $tbs[$i];
break;
}
}
}
} else {
$tb = $tbs[0];
}
}
return $tb;
}
function table_get_default() {
$V = array();
$tmp = file_get(DT_ROOT.'/file/setting/table.php');
$tmp or msg('配置文件不存在,请上传 file/setting/table.php');
if(substr($tmp, 0, 13) == '<?php exit;?>') $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('为了数据安全,此操作必须先在<a href="?file=setting">网站设置</a>里临时关闭网站');
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('为了数据安全,此操作必须先在<a href="?file=setting">网站设置</a>里临时关闭网站');
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<br/>$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.'&note='.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.'&note='.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']] = '<span class="f_blue">自定义字段</span>';
}
}
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] = '<span class="f_red" title="应为 '.cutstr($V[$k], '', ' ').'">类型错误</span>';
} else {
$R[$k] = '<span class="f_green"><img src="admin/image/yes.png" title="校验一致" align="absmiddle"/> 通过</span>';
}
unset($V[$k]);
} else {
$R[$k] = '<span class="f_orange" title="如果是自行添加的字段,可忽略">多余字段</span>';
}
}
} else {
foreach($F as $k=>$v) {
$R[$k] = '<span class="f_gray" title="非系统表,无法校验">未知</span>';
}
}
}
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 .= '<option value="'.$r['Field'].'">'.$r['Field'].(isset($N[$r['Field']]) ? ' ('.$N[$r['Field']].')' : '').'</option>';
}
echo '<select name="post[fields]" id="fd"><option value="">选择字段</option>'.$fields_select.'</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 .= '<option value="'.$table.'">'.$table.' ('.$r['Comment'].')</option>';
$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 .= '<option value="'.$tmp.'">'.$tmp.'</option>';
}
}
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('分卷 <strong>#'.$fileid++.'</strong> 替换成功 程序将自动继续...'.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('由于数据结构存在差异,备份数据不可以跨版本导入<br/>备份版本:V'.$v.'<br/>当前系统:V'.DT_VERSION);
}
sql_execute($sql);
$prog = $tid ? progress(1, $fileid, $tid) : '';
msg('分卷 <strong>#'.$fileid++.'</strong> 导入成功 程序将自动继续...'.$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('分卷 <strong>#'.$fileid++.'</strong> 备份成功.. 程序将自动继续...'.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;
}
?>

20
admin/doctor.inc.php

@ -0,0 +1,20 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$menus = array (
array('系统体检', '?file='.$file),
array('MySQL进程', 'javascript:Dwidget(\'?file=database&action=process\', \'MySQL进程\');'),
array('PHP信息', '?file='.$file.'&action=phpinfo', ' target="_blank"'),
);
if($CFG['cache'] == 'memcache' || $CFG['session'] == 'memcache') $menus[] = array('Memcache', '?file='.$file.'&action=memcache', ' target="_blank"');
if($action == 'phpinfo') {
phpinfo();
} else if($action == 'memcache') {
dheader(DT_PATH.'api/memcache.php');
} else {
include tpl('doctor');
}
?>

66
admin/fetch.inc.php

@ -0,0 +1,66 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$menus = array (
array('添加规则', '?file='.$file.'&action=add'),
array('采编规则', '?file='.$file),
);
switch($action) {
case 'add':
if($submit) {
if(!$domain) msg('请输入采编域名');
if(strpos($content, '[content]') === false) msg('请输入内容规则');
$db->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 = '<div class="content">[content]</div>';
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;
}
?>

193
admin/fields.inc.php

@ -0,0 +1,193 @@
<?php
defined('DT_ADMIN') or exit('Access Denied');
$tb = isset($tb) ? strip_sql(trim($tb), 0) : '';
$tb or msg();
$len = strlen($DT_PRE);
if(substr($tb, 0, $len) == $DT_PRE) $tb = substr($tb, $len);
$do = new fields();
$do->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;
}
}
?>

104
admin/history.inc.php

@ -0,0 +1,104 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$itemid or msg('记录不存在');
$cache = DT_ROOT.'/file/history/'.$mid.'/'.($action ? $action.'-' : '').$itemid.'.php';
if($mid > 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 = '<img src="'.$v.'" onerror="this.src=\''.DT_SKIN.'image/nopic100.gif\'" onclick="_preview(this.src);" class="c_p"/>';
if(is_url($o)) $o = '<img src="'.$o.'" onerror="this.src=\''.DT_SKIN.'image/nopic100.gif\'" onclick="_preview(this.src);" class="c_p"/>';
} else if($k == 'thumbs') {
if($v) {
$t = '';
foreach(explode('|', $v) as $s) {
if(is_url($s)) $t .= '<img src="'.$s.'" onerror="this.src=\''.DT_SKIN.'image/nopic100.gif\'" onclick="_preview(this.src);" class="c_p" style="float:left;margin:0 10px 10px 0;"/>';
}
$v = $t;
}
if($o) {
$t = '';
foreach(explode('|', $o) as $s) {
if(is_url($s)) $t .= '<img src="'.$s.'" onerror="this.src=\''.DT_SKIN.'image/nopic100.gif\'" onclick="_preview(this.src);" class="c_p" style="float:left;margin:0 10px 10px 0;"/>';
}
$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 = '<a href="'.$v.'" target="_blank" class="t">'.$v.'</a>';
if(is_url($o)) $o = '<a href="'.$o.'" target="_blank" class="t">'.$o.'</a>';
}
$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');
?>

174
admin/html.inc.php

@ -0,0 +1,174 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$menus = array (
array('更新数据', '?file='.$file),
array('网站首页', DT_PATH, ' target="_blank"'),
);
switch($action) {
case 'cache':
cache_clear_tag(1);
//cache_clear_sql(0);
cache_clear('php', 'dir', 'tpl');
cache_clear('cat');
cache_category();
cache_clear('area');
cache_area();
msg('缓存更新成功', '?file='.$file.'&action=module');
break;
case 'all':
dmsg('全站更新成功', '?file='.$file);
break;
case 'index':
tohtml('index');
msg('网站首页生成成功', '?file='.$file.'&action=all');
break;
case 'back':
$moduleids = 0;
unset($MODULE[1]);
unset($MODULE[2]);
$KEYS = array_keys($MODULE);
foreach($KEYS as $k => $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;
}
?>

BIN
admin/image/add.png

After

Width: 16  |  Height: 16  |  Size: 3.6 KiB

BIN
admin/image/arrow-d.png

After

Width: 32  |  Height: 16  |  Size: 2.8 KiB

BIN
admin/image/arrow-r.png

After

Width: 4  |  Height: 7  |  Size: 2.8 KiB

BIN
admin/image/arrow-u.png

After

Width: 32  |  Height: 16  |  Size: 2.8 KiB

BIN
admin/image/back2top.png

After

Width: 76  |  Height: 38  |  Size: 3.3 KiB

BIN
admin/image/bar1.png

After

Width: 16  |  Height: 16  |  Size: 2.8 KiB

BIN
admin/image/bar2.png

After

Width: 16  |  Height: 16  |  Size: 2.8 KiB

BIN
admin/image/bar3.png

After

Width: 16  |  Height: 16  |  Size: 2.8 KiB

BIN
admin/image/bar4.png

After

Width: 16  |  Height: 16  |  Size: 2.8 KiB

BIN
admin/image/bar5.png

After

Width: 16  |  Height: 16  |  Size: 2.8 KiB

BIN
admin/image/bar6.png

After

Width: 16  |  Height: 16  |  Size: 2.8 KiB

BIN
admin/image/bar7.png

After

Width: 16  |  Height: 16  |  Size: 2.8 KiB

BIN
admin/image/child.png

After

Width: 16  |  Height: 16  |  Size: 283 B

BIN
admin/image/count.gif

After

Width: 10  |  Height: 10  |  Size: 310 B

BIN
admin/image/css.gif

After

Width: 16  |  Height: 16  |  Size: 594 B

BIN
admin/image/delete.png

After

Width: 16  |  Height: 16  |  Size: 311 B

BIN
admin/image/dialog-close-on.png

After

Width: 16  |  Height: 16  |  Size: 168 B

BIN
admin/image/dialog-close.png

After

Width: 16  |  Height: 16  |  Size: 177 B

BIN
admin/image/edit.png

After

Width: 16  |  Height: 16  |  Size: 451 B

BIN
admin/image/folder.gif

After

Width: 16  |  Height: 14  |  Size: 345 B

BIN
admin/image/htm.gif

After

Width: 16  |  Height: 16  |  Size: 599 B

BIN
admin/image/img.gif

After

Width: 10  |  Height: 10  |  Size: 520 B

BIN
admin/image/import.png

After

Width: 16  |  Height: 16  |  Size: 310 B

1
admin/image/index.html

@ -0,0 +1 @@
<meta http-equiv="refresh" content="0;url=../">

BIN
admin/image/level_1.gif

After

Width: 12  |  Height: 13  |  Size: 142 B

BIN
admin/image/level_2.gif

After

Width: 12  |  Height: 13  |  Size: 141 B

BIN
admin/image/level_3.gif

After

Width: 12  |  Height: 13  |  Size: 142 B

BIN
admin/image/level_4.gif

After

Width: 12  |  Height: 13  |  Size: 141 B

BIN
admin/image/level_5.gif

After

Width: 12  |  Height: 13  |  Size: 140 B

BIN
admin/image/level_6.gif

After

Width: 12  |  Height: 13  |  Size: 142 B

BIN
admin/image/level_7.gif

After

Width: 12  |  Height: 13  |  Size: 140 B

BIN
admin/image/level_8.gif

After

Width: 12  |  Height: 13  |  Size: 144 B

BIN
admin/image/level_9.gif

After

Width: 12  |  Height: 13  |  Size: 143 B

BIN
admin/image/link.png

After

Width: 16  |  Height: 16  |  Size: 2.9 KiB

BIN
admin/image/lock.gif

After

Width: 11  |  Height: 12  |  Size: 322 B

BIN
admin/image/login-captcha.png

After

Width: 16  |  Height: 16  |  Size: 450 B

BIN
admin/image/login-mobile.png

After

Width: 16  |  Height: 16  |  Size: 2.8 KiB

BIN
admin/image/login-password.png

After

Width: 16  |  Height: 16  |  Size: 343 B

BIN
admin/image/login-switch-on.png

After

Width: 17  |  Height: 16  |  Size: 428 B

BIN
admin/image/login-switch.png

After

Width: 17  |  Height: 16  |  Size: 470 B

BIN
admin/image/login-username.png

After

Width: 16  |  Height: 16  |  Size: 384 B

31
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;}

BIN
admin/image/msg-arrow.png

After

Width: 16  |  Height: 16  |  Size: 2.9 KiB

15
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;}

BIN
admin/image/new.png

After

Width: 16  |  Height: 16  |  Size: 294 B

BIN
admin/image/pagebreak.gif

After

Width: 16  |  Height: 15  |  Size: 240 B

BIN
admin/image/photo.gif

After

Width: 16  |  Height: 16  |  Size: 621 B

BIN
admin/image/poll.png

After

Width: 18  |  Height: 18  |  Size: 3.8 KiB

BIN
admin/image/remkdir.png

After

Width: 16  |  Height: 16  |  Size: 552 B

BIN
admin/image/resize.gif

After

Width: 11  |  Height: 11  |  Size: 84 B

BIN
admin/image/save.png

After

Width: 16  |  Height: 16  |  Size: 385 B

BIN
admin/image/search.png

After

Width: 20  |  Height: 20  |  Size: 3.5 KiB

BIN
admin/image/set.png

After

Width: 16  |  Height: 16  |  Size: 345 B

BIN
admin/image/sql.gif

After

Width: 16  |  Height: 16  |  Size: 625 B

BIN
admin/image/start.png

After

Width: 16  |  Height: 16  |  Size: 245 B

BIN
admin/image/stop.png

After

Width: 16  |  Height: 16  |  Size: 449 B

123
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;}

BIN
admin/image/tips-update.png

After

Width: 32  |  Height: 32  |  Size: 550 B

BIN
admin/image/tool-close.png

After

Width: 16  |  Height: 16  |  Size: 177 B

BIN
admin/image/tool-favor.png

After

Width: 16  |  Height: 16  |  Size: 2.8 KiB

BIN
admin/image/tool-full.png

After

Width: 16  |  Height: 16  |  Size: 2.9 KiB

BIN
admin/image/tool-help.png

After

Width: 16  |  Height: 16  |  Size: 332 B

BIN
admin/image/tool-home.png

After

Width: 16  |  Height: 16  |  Size: 2.9 KiB

BIN
admin/image/tool-reload.png

After

Width: 16  |  Height: 16  |  Size: 422 B

BIN
admin/image/tool-search.png

After

Width: 16  |  Height: 16  |  Size: 386 B

BIN
admin/image/tree.gif

After

Width: 20  |  Height: 20  |  Size: 79 B

BIN
admin/image/unknow.gif

After

Width: 16  |  Height: 16  |  Size: 225 B

BIN
admin/image/user.png

After

Width: 16  |  Height: 16  |  Size: 401 B

BIN
admin/image/video.gif

After

Width: 80  |  Height: 80  |  Size: 1.4 KiB

BIN
admin/image/view.png

After

Width: 16  |  Height: 16  |  Size: 885 B

BIN
admin/image/yes.png

After

Width: 16  |  Height: 16  |  Size: 3.0 KiB

1
admin/index.html

@ -0,0 +1 @@
<meta http-equiv="refresh" content="0;url=../admin.php">

1
admin/index.inc.php

@ -0,0 +1 @@
<?php defined('DT_ADMIN') or exit('Access Denied'); $menus = array ( array('&#31995;&#32479;&#39318;&#39029;', '?action=dashboard', 'target="_blank" title="&#26032;&#24320;&#21518;&#21488;&#31383;&#21475;"'), array('&#20462;&#25913;&#23494;&#30721;', '?action=password'), array('&#21830;&#21153;&#20013;&#24515;', $MODULE[2]['linkurl'], 'target="_blank"'), array('&#32593;&#31449;&#39318;&#39029;', DT_PATH, 'target="_blank"'), array('&#23433;&#20840;&#36864;&#20986;', "javascript:Dconfirm('".base64_decode('56Gu5a6a6KaB6YCA5Ye6566h55CG5ZCO5Y+w5ZCXPw==')."', '?action=logout');"), ); if($_admin > 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-'); ?>

8
admin/ip.inc.php

@ -0,0 +1,8 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
include tpl('ip');
?>

128
admin/keylink.inc.php

@ -0,0 +1,128 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
isset($item) or msg();
$menus = array(
array('关联链接', '?file='.$file.'&item='.$item),
);
$do = new keylink;
$do->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;
}
}
?>

140
admin/keyword.inc.php

@ -0,0 +1,140 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$menus = array (
array('已启用', '?file='.$file),
array('待审核', '?file='.$file.'&status=2'),
array('会员记录', '?file='.$file.'&action=record'),
);
$status = isset($status) ? intval($status) : 3;
$do = new keyword;
switch($action) {
case 'letter':
if(!$word) exit('');
exit(gb2py($word));
break;
case 'clear':
$time = $DT_TODAY - 60*86400;
$db->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");
}
}
?>

67
admin/like.inc.php

@ -0,0 +1,67 @@
<?php
defined('DT_ADMIN') or exit('Access Denied');
$menus = array (
array('表态记录', '?file='.$file),
);
switch($action) {
case 'clear':
$time = $DT_TODAY - 60*86400;
$db->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;
}
?>

200
admin/login.inc.php

@ -0,0 +1,200 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$forward or $forward = '?action=dashboard';
$logout = $MODULE[2]['linkurl'].'logout.php?forward='.urlencode(DT_PATH);
if($_destoon_admin && $_userid && $_destoon_admin == $_userid) {dheader($forward);}
if($DT['admin_area']) {
$AA = explode("|", trim($DT['admin_area']));
$A = ip2area($DT_IP);
$pass = false;
foreach($AA as $v) {
if(strpos($A, $v) !== false) { $pass = true; break; }
}
if(!$pass) {dalert('未被允许的地区', $logout);}
}
$LOCK = cache_read(DT_IP.'.php', 'ban');
if($LOCK && DT_TIME - $LOCK['time'] < 3600 && $LOCK['times'] >= 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');
?>

82
admin/md5.inc.php

@ -0,0 +1,82 @@
<?php
/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$menus = array (
array('文件备份', '?file=patch'),
array('木马扫描', '?file=scan'),
array('文件校验', '?file=md5'),
);
$sys = array('admin', 'api', 'include', 'lang', 'module', 'template', 'mobile');
$fbs = array('file');
switch($action) {
case 'delete':
preg_match("/^[0-9]{4}[\-]{1}[0-9]{2}[\-]{1}[0-9]{2}[\s]{1}[0-9]{2}[\.]{1}[0-9]{2}$/", $mirror) or msg('请选择镜像文件');
file_del(DT_ROOT.'/file/md5/'.$mirror.'.php');
dmsg('删除成功', '?file='.$file);
break;
case 'add':
$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));
}
$data = '<?php exit;?>';
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;
}
?>

40
admin/menu.inc.php

@ -0,0 +1,40 @@
<?php
defined('DT_ADMIN') or exit('Access Denied');
$menu = array(
array('流量统计', '?file=stats'),
array('信息统计', '?file=count'),
array('数据维护', '?file=database'),
array('文件维护', '?file=patch'),
array('标签模板', '?file=template'),
array('计划任务', '?file=cron'),
array('上传记录', '?file=upload'),
array('搜索记录', '?file=keyword'),
array('表态记录', '?file=like'),
array('问题验证', '?file=question'),
array('词语过滤', '?file=banword'),
array('禁止访问', '?file=banip'),
array('单页采编', '?file=fetch'),
array('编辑助手', '?file=word'),
array('系统体检', '?file=doctor'),
);
if(!$_founder) unset($menu[0],$menu[1],$menu[3]);
$menu_help = array(
array('使用协议', '?file=cloud&action=license'),
array('在线文档', '?file=cloud&action=doc'),
array('技术支持', '?file=cloud&action=support'),
array('应用商店', '?file=cloud&action=store'),
array('用户论坛', '?file=cloud&action=bbs'),
array('信息反馈', '?file=cloud&action=feedback'),
array('检查更新', '?file=cloud&action=update'),
array('关于软件', '?file=cloud&action=about'),
);
$menu_system = array(
array('网站设置', '?file=setting'),
array('模块管理', '?file=module'),
array('更新数据', '?file=html'),
array('分类管理', '?file=cate'),
array('地区管理', '?file=area'),
array('城市分站', '?file=city'),
array('管理员设置', '?file=admin'),
);
?>

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save