📄 tools.php
字号:
krsort($exportlog);
reset($exportlog);
$exportinfo = '<h5>数据备份信息</h5><table><caption> 数据库文件夹</caption><tr><th>备份项目</th><th>版本</th><th>时间</th><th>类型</th><th>查看</th><th>操作</th></tr>';
foreach($exportlog as $dateline => $info) {
$info['dateline'] = is_int($dateline) ? gmdate("Y-m-d H:i", $dateline + 8*3600) : '未知';
switch($info['type']) {
case 'full':
$info['type'] = '全部备份';
break;
case 'standard':
$info['type'] = '标准备份(推荐)';
break;
case 'mini':
$info['type'] = '最小备份';
break;
case 'custom':
$info['type'] = '自定义备份';
break;
}
$info['volume'] = $info['method'] == 'multivol' ? $info['volume'] : '';
$info['method'] = $info['method'] == 'multivol' ? '多卷' : 'shell';
$info['url'] = str_replace(".sql", '', str_replace("-$info[volume].sql", '', substr(strrchr($info['filename'], "/"), 1)));
$exportinfo .= "<tr>\n".
"<td>".$info['url']."</td>\n".
"<td>$info[version]</td>\n".
"<td>$info[dateline]</td>\n".
"<td>$info[type]</td>\n";
if($info['bakentry']){
$exportinfo .= "<td><a href=\"?action=all_restore&bakdirname=".$info['url']."\">查看</a></td>\n".
"<td><a href=\"?action=all_restore&file=$info[bakentry]&importsubmit=yes\">[全部导入]</a></td>\n</tr>\n";
} else {
$exportinfo .= "<td><a href=\"?action=all_restore&filedirname=".$info['url']."\">查看</a></td>\n".
"<td><a href=\"?action=all_restore&file=$info[filename]&importsubmit=yes\">[全部导入]</a></td>\n</tr>\n";
}
}
$exportinfo .= '</table>';
echo $exportinfo;
unset($exportlog);
unset($exportinfo);
echo "<br>";
//查看目录里的备份文件列表,一级目录下
if(!empty($filedirname)){
$exportlog = array();
if(is_dir(TOOLS_ROOT.'./'.$backdirarray[$whereis])) {
$dir = dir(TOOLS_ROOT.'./'.$backdirarray[$whereis]);
while($entry = $dir->read()) {
$entry = "./".$backdirarray[$whereis]."/$entry";
if(is_file($entry) && preg_match("/\.sql/i", $entry) && preg_match("/$filedirname/i", $entry)) {
$filesize = filesize($entry);
@$fp = fopen($entry, 'rb');
@$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", fgets($fp, 256))));
@fclose ($fp);
$exportlog[$identify[0]] = array( 'version' => $identify[1],
'type' => $identify[2],
'method' => $identify[3],
'volume' => $identify[4],
'filename' => $entry,
'size' => $filesize);
}
}
$dir->close();
} else {
}
krsort($exportlog);
reset($exportlog);
$exportinfo = '<table>
<caption> 数据库文件列表</caption>
<tr>
<th>文件名</th><th>版本</th>
<th>时间</th><th>类型</thd>
<th>大小</th><td>方式</th>
<th>卷号</th><th>操作</th></tr>';
foreach($exportlog as $dateline => $info) {
$info['dateline'] = is_int($dateline) ? gmdate("Y-m-d H:i", $dateline + 8*3600) : '未知';
switch($info['type']) {
case 'full':
$info['type'] = '全部备份';
break;
case 'standard':
$info['type'] = '标准备份(推荐)';
break;
case 'mini':
$info['type'] = '最小备份';
break;
case 'custom':
$info['type'] = '自定义备份';
break;
}
$info['volume'] = $info['method'] == 'multivol' ? $info['volume'] : '';
$info['method'] = $info['method'] == 'multivol' ? '多卷' : 'shell';
$exportinfo .= "<tr>\n".
"<td><a href=\"$info[filename]\" name=\"".substr(strrchr($info['filename'], "/"), 1)."\">".substr(strrchr($info['filename'], "/"), 1)."</a></td>\n".
"<td>$info[version]</td>\n".
"<td>$info[dateline]</td>\n".
"<td>$info[type]</td>\n".
"<td>".get_real_size($info[size])."</td>\n".
"<td>$info[method]</td>\n".
"<td>$info[volume]</td>\n".
"<td><a href=\"?action=all_restore&file=$info[filename]&importsubmit=yes&auto=off\">[导入]</a></td>\n</tr>\n";
}
$exportinfo .= '</table>';
echo $exportinfo;
}
// 查看目录里的备份文件列表, 二级目录下,其中二级目录是随机产生的
if(!empty($bakdirname)){
$exportlog = array();
$filedirname = TOOLS_ROOT.'./'.$backdirarray[$whereis].'/'.$bakdirname;
if(is_dir($filedirname)) {
$dir = dir($filedirname);
while($entry = $dir->read()) {
$entry = $filedirname.'/'.$entry;
if(is_file($entry) && preg_match("/\.sql/i", $entry)) {
$filesize = filesize($entry);
@$fp = fopen($entry, 'rb');
@$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", fgets($fp, 256))));
@fclose ($fp);
$exportlog[$identify[0]] = array(
'version' => $identify[1],
'type' => $identify[2],
'method' => $identify[3],
'volume' => $identify[4],
'filename' => $entry,
'size' => $filesize);
}
}
$dir->close();
}
krsort($exportlog);
reset($exportlog);
$exportinfo = '<table>
<caption> 数据库文件列表</caption>
<tr>
<th>文件名</th><th>版本</th>
<th>时间</th><th>类型</th>
<th>大小</th><th>方式</th>
<th>卷号</th><th>操作</th></tr>';
foreach($exportlog as $dateline => $info) {
$info['dateline'] = is_int($dateline) ? gmdate("Y-m-d H:i", $dateline + 8*3600) : '未知';
switch($info['type']) {
case 'full':
$info['type'] = '全部备份';
break;
case 'standard':
$info['type'] = '标准备份(推荐)';
break;
case 'mini':
$info['type'] = '最小备份';
break;
case 'custom':
$info['type'] = '自定义备份';
break;
}
$info['volume'] = $info['method'] == 'multivol' ? $info['volume'] : '';
$info['method'] = $info['method'] == 'multivol' ? '多卷' : 'shell';
$exportinfo .= "<tr>\n".
"<td><a href=\"$info[filename]\" name=\"".substr(strrchr($info['filename'], "/"), 1)."\">".substr(strrchr($info['filename'], "/"), 1)."</a></td>\n".
"<td>$info[version]</td>\n".
"<td>$info[dateline]</td>\n".
"<td>$info[type]</td>\n".
"<td>".get_real_size($info[size])."</td>\n".
"<td>$info[method]</td>\n".
"<td>$info[volume]</td>\n".
"<td><a href=\"?action=all_restore&file=$info[filename]&importsubmit=yes&auto=off\">[导入]</a></td>\n</tr>\n";
}
$exportinfo .= '</table>';
echo $exportinfo;
}
echo "<br>";
cexit("");
}
} elseif ($action == 'uc_dz_deletepms') {//清理短消息
htmlheader();
if($dz_version > 600){
errorpage('<ul><li>Discuz!6.0.0以上版本的论坛请把tools工具箱放在UCenter目录下执行才能使用此功能</li><li>Discuz!6.0.0及其之前的版本可以直接放在Discuz!程序目录下执行使用此功能</li>','','');
exit;
}
echo '<h4>清理短消息 </h4>';
echo "<div class=\"specialdiv\">操作提示:<ul><li>清理短消息前一定要备份数据库,包括论坛的数据库和UCenter的数据库</li><li>使用本程序清理短消息是直接清理的,对于造成的短消息数据丢失本程序不负任何责任</li></ul></div>";
if($step == 'search'){
$sqladd = '';
if($suid){//发送者的uid
$sqladd .= $sqladd? ' and msgfromid='.$suid : 'msgfromid='.$suid;
}
if($tuid){//接收者的uid
$sqladd .= $sqladd? ' and msgtoid='.$tuid :'msgtoid='.$tuid;
}
if($starttime){//开始的时间
$starttime = strtotime($starttime);
$sqladd .= $sqladd? ' and dateline>'.$starttime : 'dateline>'.$starttime;
}
if($endtime){//结束的时间
$endtime = strtotime($endtime);
$sqladd .= $sqladd? ' and dateline<'.$endtime : 'dateline<'.$endtime;
}
if($notdeletenew){//删除未读短消息
}else{
$sqladd .= $sqladd?' and new=0':'new=0';
}
if(!$sqladd){
errorpage('必须填写筛选短消息的条件','','');
}
$sql = "select count(*) from {$tablepre}pms ".($sqladd?"where ".$sqladd:'');
$query = mysql_query($sql);
$deletenums = mysql_result($query, 0);
echo $deletenums."条短消息等待删除";
echo '<form action="tools.php?action=uc_dz_deletepms&step=delete" method="post" >';
echo '<input type="hidden" name="sqladd" value="'.$sqladd.'" />';
echo '<input type="submit" />';
echo '</form>';
htmlfooter();
exit;
}elseif($step == 'delete'){
if(!$sqladd){
errorpage('参数不正确');
htmlfooter();
}
$sql = "delete from {$tablepre}pms ".($sqladd?"where ".$sqladd:'');
$query = mysql_query($sql);
$deletednums = mysql_affected_rows();
echo "<table><tr><th>提示信息</th></tr><tr><td>清理短消息成功,共清理掉 $deletednums 短消息</td></tr></table>";
htmlfooter();
exit;
}else{
?>
<style>
.calendar_expire, .calendar_expire a:link, .calendar_expire a:visited {color: #999999;}.calendar_default, .calendar_default a:link, .calendar_default a:visited {color: #000000;}.calendar_checked, .calendar_checked a:link, .calendar_checked a:visited {color: #FF0000;}.calendar_today, .calendar_today a:link, .calendar_today a:visited {color: #00BB00;}.calendar_header td{ padding:5px;}#calendar_year {display: none;line-height: 130%;background: #FFFFFF;position: absolute;z-index: 10;}#calendar_year .col {float: left;background: #FFFFFF;margin-left: 1px;border: 1px solid #86B9D6;padding: 4px;}#calendar_month {display: none;background: #FFFFFF;line-height: 130%;border: 1px solid #86B9D6;padding: 4px;position: absolute;z-index: 11;}.calheader {height:35px;background: #E8F3FD;color:#FFF;font-size:14px;font-weight:bold;text-align:left;}.tableborder {background: #E8F3FD;border: 1px solid #E0E0E0;border-collapse:collapse;margin: 0;padding: 0; width:220px;}.category {color: #92A05A;background-color: #FFFFD9;margin: 0;padding: 0;}.category td {border-bottom: 1px solid #E0E0E0;}#calendar td { font-weight: bold;}
</style>
<script type="text/JavaScript">
var today = new Date();
function $(id) {
return document.getElementById(id);
}
var userAgent = navigator.userAgent.toLowerCase();
var is_webtv = userAgent.indexOf('webtv') != -1;
var is_kon = userAgent.indexOf('konqueror') != -1;
var is_mac = userAgent.indexOf('mac') != -1;
var is_saf = userAgent.indexOf('applewebkit') != -1 || navigator.vendor == 'Apple Computer, Inc.';
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko' && !is_saf) && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ns = userAgent.indexOf('compatible') == -1 && userAgent.indexOf('mozilla') != -1 && !is_opera && !is_webtv && !is_saf;
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera && !is_saf && !is_webtv) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);
var controlid = null;
var currdate = null;
var startdate = null;
var enddate = null;
var yy = null;
var mm = null;
var hh = null;
var ii = null;
var currday = null;
var addtime = false;
var today = new Date();
var lastcheckedyear = false;
var lastcheckedmonth = false;
function getposition(obj) {
var r = new Array();
r['x'] = obj.offsetLeft;
r['y'] = obj.offsetTop;
while(obj = obj.offsetParent) {
r['x'] += obj.offsetLeft;
r['y'] += obj.offsetTop;
}
return r;
}
function loadcalendar() {
s = '';
s += '<div id="calendar" style="display:none; position:absolute; margin: 0;padding: 0;z-index:100;" onclick="doane(event)">';
s += '<div><table class="tableborder" cellspacing="0" cellpadding="0" width="100%" style="text-align: center">';
s += '<tr align="center" class="calheader"><td class="calheader"><a href="###" onclick="refreshcalendar(yy, mm-1)" title="上一月">《</a></td><td colspan="5" style="text-align: center" class="calheader"><a href="###" onclick="showdiv(\'year\');doane(event)" title="点击选择年份" id="year"></a> - <a id="month" title="点击选择月份" href="###" onclick="showdiv(\'month\');doane(event)"></a></td><td class="calheader"><A href="###" onclick="refreshcalendar(yy, mm+1)" title="下一月">》</A></td></tr>';
s += '<tr class="category calendar_header"><td>日</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td></tr>';
for(var i = 0; i < 6; i++) {
s += '<tr class="altbg2">';
for(var j = 1; j <= 7; j++)
s += "<td id=d" + (i * 7 + j) + " height=\"19\">0</td>";
s += "</tr>";
}
s += '<tr id="hourminute"><td colspan="7" align="center"><input class="textinput" style="width:30px;" type="text" size="1" value="" id="hour" onKeyUp=\'this.value=this.value > 23 ? 23 : zerofill(this.value);controlid.value=controlid.value.replace(/\\d+(\:\\d+)/ig, this.value+"$1")\'> 点 <input class="textinput" style="width:30px;" type="text" size="1" value="" id="minute" onKeyUp=\'this.value=this.value > 59 ? 59 : zerofill(this.value);controlid.value=controlid.value.replace(/(\\d+\:)\\d+/ig, "$1"+this.value)\'> 分</td></tr>';
s += '</table></div></div>';
s += '<div id="calendar_year" onclick="doane(event)" style="display: none"><div class="col">';
for(var k = 1930; k <= 2019; k++) {
s += k != 1930 && k % 10 == 0 ? '</div><div class="col">' : '';
s += '<a href="###" onclick="refreshcalendar(' + k + ', mm);$(\'calendar_year\').style.display=\'none\'"><span' + (today.getFullYear() == k ? ' class="calendar_today"' : '') + ' id="calendar_year_' + k + '">' + k + '</span></a><br />';
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -