function m__space_use() { $html = '空间占用情况:<span style=\\"color:red;\\">'; if (!isset($_SESSION['space_size'])) { $_SESSION['space_size'] = num_bitunit(dir_size(dirname(__FILE__) . '/../')); } $html .= $_SESSION['space_size']; $html .= '</span> 空间文件数量:<span style=\\"color:red;\\">'; if (!isset($_SESSION['space_files'])) { $_SESSION['space_files'] = dir_files(dirname(__FILE__) . '/../'); } $html .= $_SESSION['space_files']; $html .= '</span>'; die('{"code":"0","msg":"' . $html . '"}'); }
function File_Act($array, $actall, $inver, $REAL_DIR) { if (($count = count($array)) == 0) { return '请选择文件'; } if ($actall == 'e') { function listfiles($dir = ".", $faisunZIP, $mydir) { $sub_file_num = 0; if (is_file($mydir . "{$dir}")) { if (realpath($faisunZIP->gzfilename) != realpath($mydir . "{$dir}")) { $faisunZIP->addfile(file_get_contents($mydir . $dir), "{$dir}"); return 1; } return 0; } $handle = opendir($mydir . "{$dir}"); while ($file = readdir($handle)) { if ($file == "." || $file == "..") { continue; } if (is_dir($mydir . "{$dir}/{$file}")) { $sub_file_num += listfiles("{$dir}/{$file}", $faisunZIP, $mydir); } else { if (realpath($faisunZIP->gzfilename) != realpath($mydir . "{$dir}/{$file}")) { $faisunZIP->addfile(file_get_contents($mydir . $dir . "/" . $file), "{$dir}/{$file}"); $sub_file_num++; } } } closedir($handle); if (!$sub_file_num) { $faisunZIP->addfile("", "{$dir}/"); } return $sub_file_num; } function num_bitunit($num) { $bitunit = array(' B', ' KB', ' MB', ' GB'); for ($key = 0; $key < count($bitunit); $key++) { if ($num >= pow(2, 10 * $key) - 1) { //1023B 会显示为 1KB $num_bitunit_str = ceil($num / pow(2, 10 * $key) * 100) / 100 . " {$bitunit[$key]}"; } } return $num_bitunit_str; } $mydir = $REAL_DIR . '/'; if (is_array($array)) { $faisunZIP = new PHPzip(); if ($faisunZIP->startfile("{$inver}")) { $filenum = 0; foreach ($array as $file) { $filenum += listfiles($file, $faisunZIP, $mydir); } $faisunZIP->createfile(); return "压缩完成,共添加 {$filenum} 个文件.<br><a href='{$inver}'>点击下载 {$inver} (" . num_bitunit(filesize("{$inver}")) . ")</a>"; } else { return "{$inver} 不能写入,请检查路径或权限是否正确.<br>"; } } else { return "没有选择的文件或目录.<br>"; } } $i = 0; while ($i < $count) { $array[$i] = urldecode($array[$i]); switch ($actall) { case "a": $inver = urldecode($inver); if (!is_dir($inver)) { return '路径错误'; } $filename = array_pop(explode('/', $array[$i])); @copy($array[$i], File_Str($inver . '/' . $filename)); $msg = '复制到' . $inver . '目录'; break; case "b": if (!@unlink($array[$i])) { @chmod($filename, 0666); @unlink($array[$i]); } $msg = '删除'; break; case "c": if (!eregi("^[0-7]{4}\$", $inver)) { return '属性值错误'; } $newmode = base_convert($inver, 8, 10); @chmod($array[$i], $newmode); $msg = '属性修改为' . $inver; break; case "d": @touch($array[$i], strtotime($inver)); $msg = '修改时间为' . $inver; break; } $i++; } return '所选文件' . $msg . '完毕'; }
} natsort($real_list); $match = array(); foreach ($real_list as $file) { if (preg_match('/_([0-9])+\\.sql$/', $file, $match)) { if ($match[1] == 1) { $mark = 1; } else { $mark = 2; } } else { $mark = 0; } $file_size = filesize($path . $file); $info = cls_sql_dump::get_head($path . $file); $list[] = array('name' => $file, 'ver' => $info['ecs_ver'], 'add_time' => $info['date'], 'vol' => $info['vol'], 'file_size' => num_bitunit($file_size), 'mark' => $mark); } } assign_query_info(); $smarty->assign('action_link', array('text' => $_LANG['02_db_manage'], 'href' => 'database.php?act=backup')); $smarty->assign('ur_here', $_LANG['restore']); $smarty->assign('list', $list); $smarty->display('db_restore.htm'); } if ($_REQUEST['act'] == 'dumpsql') { /* 权限判断 */ admin_priv('db_backup'); /* 检查目录权限 */ $path = ROOT_PATH . DATA_DIR . '/sqldata'; $mask = file_mode_info($path); if ($mask === false) {
function dealdata($data) { global $current_size, $tablearr, $writefile_data, $_POST; $current_size += strlen($data); $writefile_data .= $data; if ($current_size >= intval($_POST["filesize"]) * 1024) { $current_size = 0; $writefile_data .= "\r\n?" . ">"; writefile($writefile_data, "w"); $_POST[page] = intval($_POST[page]) + 1; fheader(); echo tablestart("正在从数据库'{$_POST['db_dbname']}'中导出数据……", 500); $str1 = "<br>-= 以下数据表处理完成 =- <div class='borderdiv' style='width:150px;height:100px;overflow:auto;' align=left>"; $finishByte = 0; for (reset($tablearr); list($key, $val) = each($tablearr);) { if ($key < $_POST[tabledumping]) { $str1 .= "√ {$val}<BR>\r\n"; $finishByte += $_POST[fsqltable][$val]; } else { if ($key == $_POST[tabledumping]) { $str1 .= "<a href='#' id='finisheditem'> </a></div>\n\t\t\t\t\t\t<br>-= 以下数据表正待处理 =-\n\t\t\t\t\t\t<div class='borderdiv' style='width:150px;height:100px;overflow:auto;' align=left>\n\t\t\t\t\t\t<font style='color:#FF0000'>→ {$val}</font><br>\r\n"; $finishByte += $_POST[lastinsert] * substr(strstr($_POST[fsqltable][$val], ','), 1); $finish = intval($finishByte / $_POST[totalsize] * 100); } else { $str1 .= "・ {$val}<br>\r\n"; } } } $str1 .= "</div><BR>"; $str2 = tablestart("导出状态", 300); $str2 .= tabledata("共有数据:|" . num_bitunit($_POST[totalsize]) . "", "100|200"); $str2 .= tabledata("现已导出:|" . num_bitunit($finishByte) . ""); $str2 .= tabledata("每页导出:|" . num_bitunit(intval($finishByte / $_POST[page])) . ""); $str2 .= tabledata("导出时间间隔:|{$_POST['nextpgtimeout']} 秒"); $str2 .= tabledata("每页生成数据文件|≥ " . num_bitunit($_POST["filesize"] * 1024) . ""); $str2 .= tabledata("已生成数据文件:|" . ($_POST[page] - 1) . " 个"); $str2 .= tabledata("正在自动进入:|<a href='javascript:myform.submit();'>第 {$_POST['page']} 页</a>"); $str2 .= tabledata("已用时:|" . timeformat(time() - $_POST["StartTime"]) . ""); $str2 .= tabledata("已完成:|{$finish}% "); $str2 .= tabledata("完成进度:|<table width=100% height=12 border=0 cellspacing=1 cellpadding=0 class='tabletitle' align=center><tr><td width='{$finish}%'><div></div></td><td width='" . (100 - $finish) . "%' class='tabledata'><div></div></td></tr></table>"); $str2 .= tableend(); $str2 .= "<B><div id='postingTag'></div></B>"; echo tabledata("{$str1}|{$str2}"); echo tableend(); ffooter(); eval(auto_submit_script()); exit; } }
if ($dodozip->startfile("{$_REQUEST['todir']}{$_REQUEST['zipname']}")) { echo "正在添加压缩文件...<br><br>"; $filenum = 0; foreach ($_REQUEST[dfile] as $file) { if (is_file($file)) { if (!empty($dodozip->filefilters)) { if (!in_array(end(explode(".", $file)), $dodozip->filefilters)) { continue; } } echo "<font face=\"wingdings\" size=\"5\">2</font> {$file}<br>"; } else { echo "<font face=\"wingdings\" size=\"5\">0</font> {$file}<br>"; } $filenum += listfiles($file); } $dodozip->createfile(); echo "<br>压缩完成,共添加 {$filenum} 个文件.<br><a href='{$_REQUEST['todir']}{$_REQUEST['zipname']}' _fcksavedurl='{$_REQUEST['todir']}{$_REQUEST['zipname']}'>{$_REQUEST['todir']}{$_REQUEST['zipname']} (" . num_bitunit(filesize("{$_REQUEST['todir']}{$_REQUEST['zipname']}")) . ")</a>"; } else { echo "{$_REQUEST['todir']}{$_REQUEST['zipname']} 不能写入,请检查路径或权限是否正确.<br>"; } } ?> </form> <hr color="#003388"> <center> <a href="http://www.sectop.com" target="_blank">DoDo's Blog</a> </center> </body> </html>
} } natsort($real_list); $match = array(); foreach ($real_list as $file) { if (preg_match('/_([0-9])+\\.sql$/', $file, $match)) { if ($match[1] == 1) { $mark = 1; } else { $mark = 2; } } else { $mark = 0; } $file_size = filesize($sqldata_dir . $file); $list[] = array('name' => $file, 'file_size' => num_bitunit($file_size), 'mark' => $mark); } } include_once 'pageheader.php'; ?> <!-- start list --> <div class="list-div" id="listDiv"> <form method="post" action="?act=backup" enctype="multipart/form-data"> <table cellspacing='1' cellpadding='3'> <tr> <th colspan="2">数据库备份</th> </tr> <tr> <td class="narrow-label">备份文件名</td> <td><input type="text" name="sql_name" size="40" value="<?php
function get_hander() { global $dbkdir; $filedb = array(); if (is_dir($dbkdir) && file_exists($dbkdir) && dir_size($dbkdir) > 0) { $filedb['version'] = VERSION; $filedb['time'] = date("Y-m-d H:i:s"); $filedb['dbsize'] = num_bitunit(dir_size($dbkdir)); } return $filedb; }