$safe_num && $safe_num !== 0)printerror('您已经被限制登陆!');
/****************************************************************/
/* 用户登录函数 */
/* */
/* 需要浏览器开启Cookies才可使用 */
/****************************************************************/
if ($_COOKIE['user'] != $user || $_COOKIE['pass'] != md5($pass)) {
if (htmlspecialchars($_REQUEST['user']) == $user && htmlspecialchars($_REQUEST['pass']) == $pass) {
setcookie('user',$user,time()+60*60*24*1);
setcookie('pass',md5($pass),time()+60*60*24*1);
}else{
if (htmlspecialchars($_REQUEST['user']) == $user || htmlspecialchars($_REQUEST['pass'])) $er = true;
login($er);
exit;
}
}
/****************************************************************/
/* function maintop() */
/* */
/* 控制站点的样式和头部内容 */
/* $title -> 顶部标题 $showtop -> 是否显示头部菜单 */
/****************************************************************/
function maintop($title,$showtop = true) {
global $meurl,$sitetitle,$op;
echo "\n \n
\n \n"
."$sitetitle - $title \n"
."\n"
."\n";
$back=($op!=='home')?$back = "返回 ".$_SESSION['folder']." \n":$back = '';
echo " \n";
if ($showtop) {//头部菜单内容
if($op=='up'||$op=='upload'||$op=='yupload')$up = "class='curr'";if($op=='home'||$op =='edit'||$op =='ren'||$op =='unz')$home = "class='curr'";if($op=='cr'||$op=='create')$cr = "class='curr'";if($op=='allz'||$op=='allzip')$allz = "class='curr'";if($op=='sqlb'||$op=='sqlbackup')$sqlb = "class='curr'";if($op=='ftpa'||$op=='ftpall')$ftpa = "class='curr'";if($op=='kill'||$op=='killme')$kill = "class='curr'";
echo "";
}
echo "\n";
}
/****************************************************************/
/* function login() */
/* */
/* 登录验证 $user and md5($pass) */
/* 需要浏览器支持Cookie */
/****************************************************************/
function login($er=false) {
global $meurl,$op,$safe_num,$mail;
setcookie("user","",time()-60*60*24*1);
setcookie("pass","",time()-60*60*24*1);
maintop("登录",false);
if ($er) {
if (isset($_SESSION['error'])){
$_SESSION['error']++;
if($_SESSION['error'] > $safe_num && $safe_num !== 0){
mail($mail,'FileBox文件管理器提醒:文件被恶意登录!','该提醒来自FileBox:
登录者IP为:'.$_SERVER['REMOTE_ADDR'],'From:
');
echo ('ERROR: 您已经被限制登陆! ');
exit;
}
}else{
$_SESSION['error'] = 1;
}
echo "用户名或密码错误! \n";
}
echo "\n";
mainbottom();
}
/****************************************************************/
/* function home() */
/* */
/* Main function that displays contents of folders. */
/****************************************************************/
function home() {
global $os, $meurl ,$folder, $ufolder;
$content1 = "";
$content2 = "";
$folder = gCode($folder);
if(opendir($folder)){$style = opendir($folder);}else{printerror("目录不存在!\n");exit;}
$a=1;$b=1;
if($folder)$_SESSION['folder']=$ufolder;
maintop("主页");
echo '';
echo "\n";
echo "远程下载
什么是远程下载? 远程下载是从其他服务器获取文件并直接下载到当前服务器的一种功能。 类似于SSH的Wget功能,免去我们下载再手动上传所浪费的时间。
"
."\n"
.""
."";
mainbottom();
}
/****************************************************************/
/* function yupload() */
/* */
/* Second step in wget file. */
/* Saves the file to the disk. */
/* Recieves $upfile from up() as the uploaded file. */
/****************************************************************/
function yupload($url, $folder, $unzip, $delzip) {
global $meurl;
if(empty($folder)){
$folder="./";
}
$nfolder = $folder;
$nurl = $url;
$url = gCode($url);
$folder = gCode($folder);
if($url!==""){
ignore_user_abort(true); // 要求离线也可下载
set_time_limit (24 * 60 * 60); // 设置超时时间
if (!file_exists($folder)){
mkdir($folder, 0755);
}
$newfname = $folder . basename($url); // 取得文件的名称
if(function_exists('curl_init')){
$file = curl_get_contents($url);file_put_contents($newfname,$file);
}else{
$file=fopen($url,"rb");
if($file){$newf = fopen ($newfname, "wb");
if($newf)while (!feof($file)) {fwrite($newf, fread($file, 1024 * 8), 1024 * 8);}}
if($file)fclose($file);
if($newf)fclose($newf);
}
maintop("远程上传");
echo "文件 ".basename($url)." 上传成功
\n";
$end = explode('.', basename($url));
if((end($end)=="zip") && isset($unzip) && $unzip == "checkbox"){
if(class_exists('ZipArchive')){
echo "您可以
访问文件夹 或者
返回目录 或者
继续上传 \n";
echo "
';
}else{
echo('此服务器上的PHP不支持ZipArchive,无法解压文件! ');
}
}else{
echo "您可以 访问文件夹 或者 编辑文件 或者 返回目录 或者 继续上传 \n";
}
mainbottom();
return true;
}else{
printerror ('文件地址不能为空。');
}
}
/****************************************************************/
/* function upload() */
/* */
/* Second step in upload. */
/* 将文件保存到磁盘中 */
/* Recieves $upfile from up() as the uploaded file. */
/****************************************************************/
function upload($upfile,$ndir,$unzip,$delzip) {
global $meurl, $folder;
if(empty($ndir)){
$ndir="./";
}
$nfolder = $folder;
$nndir = $ndir;
$ndir = gCode($ndir);
if (!$upfile) {
printerror("您没有选择文件!");
exit;
}elseif($upfile) {
maintop("上传");
if (!file_exists($ndir)){
mkdir($ndir, 0755);
}
$i = 1;
echo "\n";
echo '';
mainbottom();
}else{
printerror("您没有选择文件!");
}
}
/****************************************************************/
/* function allz() */
/* */
/* First step in allzip. */
/* Prompts the user for confirmation. */
/* Recieves $dename and ask for deletion confirmation. */
/****************************************************************/
function allz() {
global $meurl, $folder;
maintop("全站备份");
echo "全站备份
压缩包格式为 zipper-年-月-日-时-分.zip 如存在同文件名压缩包,该压缩包将被覆盖!
"
."\n";
mainbottom();
}
/****************************************************************/
/* function allzip() */
/* */
/* Second step in unzip. */
/****************************************************************/
function allzip() {
global $meurl;
maintop("全站备份");
if (isset($_POST['allzip'])) {
$zippath = !empty($_POST['zippath']) ? strip_tags($_POST['zippath']) : '.';
$zipfile = 'zipper-' . date("Y-m-d-H-i") . '.zip';
Zipper::zipDir($zippath, $zipfile);
}
if (file_exists('zipper-' . date("Y-m-d-H-i") . '.zip')) {
unlink('zipper-' . date("Y-m-d-H-i") . '.zip'); }
else {
}
class Zipper extends ZipArchive {
public function addDir($path) {
$this->addEmptyDir($path);
$nodes = glob($path . '/*');
foreach ($nodes as $node) {
if (is_dir($node)) {
$this->addDir($node);
} else if (is_file($node)) {
$this->addFile($node);
}
}
}
}
$zip = new Zipper;
$res = $zip->open('zipper-' . date("Y-m-d-H-i") . '.zip', ZipArchive::CREATE);
if ($res === TRUE) {
$zip->addDir('.');
$zip->close();
echo '压缩包 zipper-' . date("Y-m-d-H-i") . '.zip 备份成功!
'
." \n";
} else {
echo '备份失败!
'
." \n";
}
mainbottom();
}
/****************************************************************/
/* function unz() */
/* */
/* First step in unz. */
/* Prompts the user for confirmation. */
/* Recieves $dename and ask for deletion confirmation. */
/****************************************************************/
function unz($dename) {
global $meurl, $folder, $content;
if (!$dename == "") {
if(class_exists('ZipArchive')){
maintop("解压");
echo "\n"
."解压 ".$folder.$dename."
\n"
."
\n";
mainbottom();
}else{
printerror("此服务器上的PHP不支持ZipArchive,无法解压文件!\n");
}
}else{
home();
}
}
/****************************************************************/
/* function unzip() */
/* */
/* Second step in unzip. */
/****************************************************************/
function unzip($dename,$ndir,$del) {
global $meurl, $folder;
$nndir = $ndir;
$nfolder = $folder;
$ndename = $dename;
$dename = gCode($dename);
$folder = gCode($folder);
$ndir = gCode($ndir);
if (!$dename == "") {
if (!file_exists($ndir)){
mkdir($ndir, 0755);
}
if(class_exists('ZipArchive')){
$zip = new ZipArchive();
if ($zip->open($folder.$dename) === TRUE) {
maintop("解压");
if($zip->extractTo($ndir)){
echo '';
echo '';
for($i = 0; $i < $zip->numFiles; $i++) {
echo uCode($zip->getNameIndex($i))."\n";
}
$zip->close();
echo $dename." 已经解压完成 $nndir\n";
}else{
echo('无法解压文件:'.$nfolder.$ndename);
}
if($del=='del'){
if(unlink($folder.$dename)){
echo $ndename." 已经被删除\n";
}else{
echo $ndename." 删除失败!\n";
}
}
echo " \n";
mainbottom();
}else{
printerror('无法解压文件:'.$nfolder.$ndename);
}
}else{
printerror('此服务器上的PHP不支持ZipArchive,无法解压文件!');
}
}else{
home();
}
}
/****************************************************************/
/* function delete() */
/* */
/* Second step in delete. */
/* Deletes the actual file from disk. */
/* Recieves $upfile from up() as the uploaded file. */
/****************************************************************/
function deltree($pathdir)
{
if(is_empty_dir($pathdir))//如果是空的
{
rmdir($pathdir);//直接删除
}
else
{//否则读这个目录,除了.和..外
$d=dir($pathdir);
while($a=$d->read())
{
if(is_file($pathdir.'/'.$a) && ($a!='.') && ($a!='..')){unlink($pathdir.'/'.$a);}
//如果是文件就直接删除
if(is_dir($pathdir.'/'.$a) && ($a!='.') && ($a!='..'))
{//如果是目录
if(!is_empty_dir($pathdir.'/'.$a))//是否为空
{//如果不是,调用自身,不过是原来的路径+他下级的目录名
deltree($pathdir.'/'.$a);
}
if(is_empty_dir($pathdir.'/'.$a))
{//如果是空就直接删除
rmdir($pathdir.'/'.$a);
}
}
}
$d->close();
}
}
function is_empty_dir($pathdir){
$d=opendir($pathdir);
$i=0;
while($a=readdir($d)){
$i++;
}
closedir($d);
if($i>2){return false;}
else return true;
}
/****************************************************************/
/* function edit() */
/* */
/* First step in edit. */
/* Reads the file from disk and displays it to be edited. */
/* Recieves $upfile from up() as the uploaded file. */
/****************************************************************/
function edit($fename) {
global $meurl,$folder;
$file = gCode($folder.$fename);
if (file_exists($file)) {
maintop("编辑");
$contents = file_get_contents($file);
if(function_exists('mb_detect_encoding'))$encode = mb_detect_encoding($contents,array('ASCII','UTF-8','GBK','GB2312'));else $encode = 'UTF-8';
if(htmlspecialchars($_REQUEST['encode'])){$encode = htmlspecialchars($_REQUEST['encode']);}
if($encode!="UTF-8" && !empty($encode))$contents = mb_convert_encoding($contents,"UTF-8",$encode);
foreach(mb_list_encodings() as $key => $value){
if($key >= 19):
$arr=array('EUC-CN' => 'GB2312','CP936' => 'GBK','SJIS-mac'=>'MacJapanese','SJIS-Mobile#DOCOMO'=>'SJIS-DOCOMO','SJIS-Mobile#KDDI'=>'SJIS-KDDI','SJIS-Mobile#SOFTBANK'=>'SJIS-SOFTBANK','UTF-8-Mobile#DOCOMO'=>'UTF-8-DOCOMO','UTF-8-Mobile#KDDI-B'=>'UTF-8-KDDI','UTF-8-Mobile#SOFTBANK'=>'UTF-8-SOFTBANK','ISO-2022-JP-MOBILE#KDDI'=>'ISO-2022-JP-KDDI');
if(array_key_exists($value, $arr)) $value_text = $arr[$value]; else $value_text = $value;
if($encode == $value) $list.="".$value_text.' '; else $list.="".$value_text.' ';
endif;
}
echo "编辑文件 {$folder}{$fename}\n"
.""
."当前文件编码 ".$list
.' ? '
.""
."保存文件编码 ".$list
.'
'
.""
.htmlspecialchars($contents)
." "
." \n"
." \n"
." \n"
." \n"
." \n";
mainbottom();
}else{
printerror("文件不存在!");
}
}
/****************************************************************/
/* function save() */
/* */
/* Second step in edit. */
/* Recieves $ncontent from edit() as the file content. */
/* Recieves $fename from edit() as the file name to modify. */
/****************************************************************/
function save($ncontent, $fename, $encode) {
global $meurl,$folder;
if (!$fename == "") {
$file = gCode($folder.$fename);
$ydata = $ncontent;
if($encode!=="UTF-8" && $encode!=="ASCII")$ydata = mb_convert_encoding($ydata,$encode,"UTF-8");
if(file_put_contents($file, $ydata) or $ncontent=="") {
maintop("编辑");
echo "\n";
echo "\n";
$fp = null;
mainbottom();
}else{
printerror("文件保存出错!");
}
}else{
home();
}
}
/****************************************************************/
/* function cr() */
/* */
/* First step in create. */
/* Promts the user to a filename and file/directory switch. */
/****************************************************************/
function cr() {
global $meurl, $folder;
maintop("创建");
echo "\n"
."创建文件 或 目录 文件 File \n"
."文件夹 Dir
文件名: \n"
."
";
echo " \n"
." \n"
." \n";
mainbottom();
}
/****************************************************************/
/* function create() */
/* */
/* Second step in create. */
/* Creates the file/directoy on disk. */
/* Recieves $nfname from cr() as the filename. */
/* Recieves $infolder from cr() to determine file trpe. */
/****************************************************************/
function create($nfname, $isfolder, $ndir) {
global $meurl, $folder;
if (!$nfname == "") {
$ndir = gCode($ndir);
$nfname = gCode($nfname);
if ($isfolder == 1) {
if(mkdir($ndir."/".$nfname, 0755)) {
$ndir = uCode($ndir);
$nfname = uCode($nfname);
maintop("创建");
echo "";
mainbottom();
}else{
$ndir = uCode($ndir);
$nfname = uCode($nfname);
printerror("您的目录 ".$ndir.$nfname." 不能被创建。请检查您的目录权限是否已经被设置为可写 或者 目录是否已经存在\n");
}
}else{
if(fopen($ndir."/".$nfname, "w")) {
$ndir = uCode($ndir);
$nfname = uCode($nfname);
maintop("创建");
echo "";
mainbottom();
}else{
$ndir = uCode($ndir);
$nfname = uCode($nfname);
printerror("您的文件 ".$ndir.$nfname." 不能被创建。请检查您的目录权限是否已经被设置为可写 或者 文件是否已经存在\n");
}
}
}else{
cr();
}
}
/****************************************************************/
/* function ren() */
/* */
/* First step in rename. */
/* Promts the user for new filename. */
/* Globals $file and $folder for filename. */
/****************************************************************/
function ren($file) {
global $meurl,$folder,$ufolder;
$ufile = $file;
if (!$file == "") {
maintop("重命名");
echo "\n"
."重命名 ".$ufolder.$ufile.'
';
echo " \n"
." \n"
." \n"
." \n";
mainbottom();
}else{
home();
}
}
/****************************************************************/
/* function renam() */
/* */
/* Second step in rename. */
/* Rename the specified file. */
/* Recieves $rename from ren() as the old filename. */
/* Recieves $nrename from ren() as the new filename. */
/****************************************************************/
function renam($rename, $nrename, $folder) {
global $meurl,$folder;
if (!$rename == "") {
$loc1 = gCode("$folder".$rename);
$loc2 = gCode("$folder".$nrename);
if(rename($loc1,$loc2)) {
maintop("重命名");
echo "文件 ".$folder.$rename." 已被重命名成 ".$folder.$nrename."
\n"
."\n";
mainbottom();
}else{
printerror("重命名出错!");
}
}else{
home();
}
}
/****************************************************************/
/* function movall */
/* */
/* 批量移动 2014-4-12 by jooies */
/****************************************************************/
function movall($file, $ndir, $folder) {
global $meurl,$folder;
if (!$file == "") {
maintop("批量移动");
$arr = str_split($ndir);
if($arr[count($arr)-1]!=='/'){
$ndir .= '/';
}
$nndir = $ndir;
$nfolder = $folder;
$file = gCode($file);
$ndir = gCode($ndir);
$folder = gCode($folder);
if (!file_exists($ndir)){
mkdir($ndir, 0755);
}
$file = explode(',',$file);
echo "";
foreach ($file as $v) {
if (file_exists($ndir.$v)){
if (rename($folder.$v, $ndir.$v."(1)")){
$v = uCode($v);
echo $nndir.$v." 文件已存在,自动更名为 {$nndir}(1)\n";
}else{
$v = uCode($v);
echo "无法移动 ".$nfolder.$v.",请检查文件权限\n";
}
}elseif (rename($folder.$v, $ndir.$v)){
$v = uCode($v);
echo $nfolder.$v." 已经成功移动到 ".$nndir.$v."\n";
}else{
$v = uCode($v);
echo "无法移动 ".$nfolder.$v.",请检查文件权限或文件是否存在\n";
}
}
echo " ";
mainbottom();
}else{
home();
}
}
/****************************************************************/
/* function tocopy */
/* */
/* 批量复制 2014-4-19 by jooies */
/****************************************************************/
function tocopy($file, $ndir, $folder) {
global $meurl,$folder;
if (!$file == "") {
maintop("复制");
$nndir = $ndir;
$nfolder = $folder;
$file = gCode($file);
$ndir = gCode($ndir);
$folder = gCode($folder);
if (!file_exists($ndir)){
mkdir($ndir, 0755);
}
$file = explode(',',$file);
echo "";
foreach ($file as $v) {
if (file_exists($ndir.$v)){
if (copy($folder.$v, $ndir.$v.'(1)')){
$v = iconv("GBK", "UTF-8",$v);
echo "{$nndir}{$v} 文件已存在,自动更名为 {$nfolder}{$v}(1)\n";
}else{
$v = iconv("GBK", "UTF-8",$v);
echo "无法复制 {$nfolder}{$v},请检查文件权限\n";
}
}elseif (copy($folder.$v, $ndir.$v)){
$v = iconv("GBK", "UTF-8",$v);
echo $nfolder.$v." 已经成功复制到 ".$nndir.$v."\n";
}else{
$v = iconv("GBK", "UTF-8",$v);
echo "无法复制 ".$nfolder.$v.",请检查文件权限\n";
}
}
echo " ";
mainbottom();
}else{
home();
}
}
/****************************************************************/
/* function logout() */
/* */
/* Logs the user out and kills cookies */
/****************************************************************/
function logout() {
global $meurl;
setcookie("user","",time()-60*60*24*1);
setcookie("pass","",time()-60*60*24*1);
maintop("注销",false);
echo "注销成功!
"
."
点击这里重新登录 ";
mainbottom();
}
/****************************************************************/
/* function mainbottom() */
/* */
/* 页面底部的版权声明 */
/****************************************************************/
function mainbottom() {
echo "
"
."FileBox Version 1.20
\n"
."\n";
exit;
}
/****************************************************************/
/* function sqlb() */
/* */
/* First step to backup sql. */
/****************************************************************/
function sqlb() {
global $meurl;
maintop("数据库备份");
echo "这将进行数据库导出并压缩成mysql.zip的动作! 如存在该文件,该文件将被覆盖!
\n数据库地址: 数据库名称: 数据库用户: 数据库密码: \n";
mainbottom();
}
/****************************************************************/
/* function sqlbackup() */
/* */
/* Second step in backup sql. */
/****************************************************************/
function sqlbackup($sql,$password,$ip="localhost",$username="root") {
global $meurl;
if(class_exists('ZipArchive')){
$database=$sql;//数据库名
$options=array(
'hostname' => $ip,//ip地址
'charset' => 'utf8',//编码
'filename' => $database.'.sql',//文件名
'username' => $username,
'password' => $password
);
$mysql = mysqli_connect($options['hostname'],$options['username'],$options['password'],$database)or die(printerror("不能连接数据库:".mysqli_connect_error()));
maintop("MySQL备份");
mysqli_query($mysql,"SET NAMES '{$options['charset']}'");
$tables = list_tables($database,$mysql);
$filename = sprintf($options['filename'],$database);
$fp = fopen($filename, 'w');
foreach ($tables as $table) {
dump_table($table, $fp,$mysql);
}
fclose($fp);
mysqli_close($mysql);
//压缩sql文件
if (file_exists('mysql.zip')) {
unlink('mysql.zip');
}
$file_name=$options['filename'];
$zip = new ZipArchive;
$res = $zip->open('mysql.zip', ZipArchive::CREATE);
if ($res === TRUE) {
$zip->addfile($file_name);
$zip->close();
//删除服务器上的sql文件
unlink($file_name);
echo '\n";
}else{
printerror('无法压缩文件!');
}
exit;
mainbottom();
}else{
printerror('此服务器上的PHP不支持ZipArchive,无法压缩文件!');
}
}
function list_tables($database,$mysql)
{
$rs = mysqli_query($mysql,"SHOW TABLES FROM $database");
$tables = array();
while ($row = mysqli_fetch_row($rs)) {
$tables[] = $row[0];
}
mysqli_free_result($rs);
return $tables;
}
//导出数据库
function dump_table($table,$mysql, $fp = null)
{
$need_close = false;
if (is_null($fp)) {
$fp = fopen($table . '.sql', 'w');
$need_close = true;
}
$a=mysqli_query($mysql,"show create table `{$table}`");
$row=mysqli_fetch_assoc($a);fwrite($fp,$row['Create Table'].';');//导出表结构
$rs = mysqli_query($mysql,"SELECT * FROM `{$table}`");
while ($row = mysqli_fetch_row($rs)) {
fwrite($fp, get_insert_sql($table, $row));
}
mysqli_free_result($rs);
if ($need_close) {
fclose($fp);
}
}
//导出表数据
function get_insert_sql($table, $row)
{
$sql = "INSERT INTO `{$table}` VALUES (";
$values = array();
foreach ($row as $value) {
$values[] = "'" . mysql_real_escape_string($value) . "'";
}
$sql .= implode(', ', $values) . ");";
return $sql;
}
/****************************************************************/
/* function ftpa() */
/* */
/* First step to backup sql. */
/****************************************************************/
function ftpa() {
global $meurl;
maintop("FTP备份");
echo "这将把文件远程上传到其他FTP!如目录存在该文件,文件将被覆盖!
\nFTP 地址: FTP 用户: FTP 密码: 上传目录: 上传文件:
\n";
mainbottom();
}
/****************************************************************/
/* function ftpall() */
/* */
/* Second step in backup sql. */
/****************************************************************/
function ftpall($ftpip,$ftpuser,$ftppass,$ftpdir,$ftpfile,$del) {
global $meurl;
$ftpfile = gCode($ftpfile);
$ftpip=explode(':', $ftpip);
$ftp_server=$ftpip['0'];//服务器
$ftp_user_name=$ftpuser;//用户名
$ftp_user_pass=$ftppass;//密码
if(empty($ftpip['1'])){
$ftp_port='21';
}else{
$ftp_port=$ftpip['1'];//端口
}
$ftp_put_dir=$ftpdir;//上传目录
$ffile=$ftpfile;//上传文件
$ftp_conn_id = ftp_connect($ftp_server,$ftp_port);
$ftp_login_result = ftp_login($ftp_conn_id, $ftp_user_name, $ftp_user_pass);
if((!$ftp_conn_id) || (!$ftp_login_result)) {
printerror('连接到ftp服务器失败');
exit;
}else{
ftp_pasv ($ftp_conn_id,true); //返回一下模式,这句很奇怪,有些ftp服务器一定需要执行这句
ftp_chdir($ftp_conn_id, $ftp_put_dir);
$ffile=explode(',', $ffile);
foreach ($ffile as $v) {
$ftp_upload = ftp_put($ftp_conn_id,$v,$v, FTP_BINARY);
if ($del == 'del') {
unlink('./'.$v);
}
}
ftp_close($ftp_conn_id); //断开
}
maintop("FTP上传");
echo "";
$ftpfile = uCode($ftpfile);
echo "文件 ".$ftpfile." 上传成功
";
mainbottom();
}
/****************************************************************/
/* function killme() */
/* 删除脚本 */
/****************************************************************/
function kill() {
global $meurl, $folder, $me;
maintop("删除程序");
echo "删除脚本
确认你要删除FlieBox脚本程序?
"
."\n";
mainbottom();
}
function killme($dename) {
global $folder;
if (!$dename == "") {
maintop("删除程序");
if(unlink($folder.$dename)) {
echo "删除成功!"
." 返回网站首页 \n";
} else {
echo "无法删除!"
." 返回网站首页 \n";
}
mainbottom();
} else {
home();
}
}
/****************************************************************/
/* function printerror() */
/* */
/* 用于显示错误信息的函数 */
/* $error为显示的提示 */
/****************************************************************/
function printerror($error) {
maintop("错误");
echo "错误信息如下:
";
mainbottom();
}
/****************************************************************/
/* function deleteall() */
/* */
/* 2014-3-9 Add by Jooies */
/* 实现文件的批量删除功能 */
/****************************************************************/
function deleteall($dename) {
if (!$dename == "") {
$udename = $dename;
$dename = gCode($dename);
if (is_dir($dename)) {
if(is_empty_dir($dename)){
rmdir($dename);
echo $udename." 已经被删除\n";
}else{
deltree($dename);
rmdir($dename);
echo $udename." 已经被删除\n";
}
}else{
if(unlink($dename)) {
echo $udename." 已经被删除\n";
}else{
echo("无法删除文件:$udename 。\n参考信息\n1.文件不存在\n2.文件正在执行\n");
}
}
}
}
switch($action) {//$action 为批量操作
case "删除":
if(isset($_POST['select_item'])){
maintop("删除");
echo "\n";
echo '';
if($_POST['select_item']['d']){
foreach($_POST['select_item']['d'] as $val){
deleteall($val);
}
}
if($_POST['select_item']['f']){
foreach($_POST['select_item']['f'] as $val){
if(deleteall($val)){}
}
}
echo ' ';
mainbottom();
}else{
printerror("您没有选择文件");
}
break;
case "移动":
if(isset($_POST['select_item'])){
maintop("批量移动");
$file = '';
if($_POST['select_item']['d']){
foreach($_POST['select_item']['d'] as $key => $val){
$file = $file.$key.',';
}
}
if($_POST['select_item']['f']){
foreach($_POST['select_item']['f'] as $key => $val){
$file = $file.$key.',';
}
}
$file = substr($file,0,-1);
echo "";
echo '移动文件
您将把下列文件移动到:'
." \n"
."
".$file." ";
echo " \n";
mainbottom();
}else{
printerror("您没有选择文件");
}
break;
case "复制":
if(isset($_POST['select_item'])){
maintop("复制");
$file = '';
if($_POST['select_item']['d']){
foreach($_POST['select_item']['d'] as $key => $val){
$file = $file.$key.',';
}
}
if($_POST['select_item']['f']){
foreach($_POST['select_item']['f'] as $key => $val){
$file = $file.$key.',';
}
}
$file = substr($file,0,-1);
echo " ";
echo '复制文件
您将把下列文件复制到:'
." \n"
."
".$file." ";
echo " \n";
mainbottom();
}else{
printerror("您没有选择文件");
}
break;
case "压缩":
if(isset($_POST['select_item'])){
if(class_exists('ZipArchive')){
maintop("目录压缩");
$time = $_SERVER['REQUEST_TIME'];
echo "";
echo '';
class Zipper extends ZipArchive {
public function addDir($path) {
if($_POST['select_item']['d']){
foreach($_POST['select_item']['d'] as $key => $val){
$val = substr($val,2);
$val = gCode($val);
$this->addDir2($val);
}
}
if($_POST['select_item']['f']){
foreach($_POST['select_item']['f'] as $key => $val){
$val = substr($val,2);
echo $val."\n";
$this->addFile($val);
}
$this->deleteName('./');
}
}
public function addDir2($path) {
$nval = iconv("GBK", "UTF-8",$path);
echo $nval."\n";
$this->addEmptyDir($path);
$dr = opendir($path);
$i=0;
while (($file = readdir($dr)) !== false)
{
if($file!=='.' && $file!=='..'){
$nodes[$i] = $path.'/'.$file;
$i++;
}
}
closedir($dr);
foreach ($nodes as $node) {
$nnode = iconv("GBK", "UTF-8",$node);
echo $nnode . "\n";
if (is_dir($node)) {
$this->addDir2($node);
}elseif(is_file($node)){
$this->addFile($node);
}
}
}
}
$zip = new Zipper;
$res = $zip->open($_SESSION['folder'].'Backup-'.$time.'.zip', ZipArchive::CREATE);
if ($res === TRUE) {
$f = substr($_SESSION['folder'], 0, -1);
$zip->addDir($f);
$zip->close();
echo "压缩完成,文件保存为Backup-".$time.".zip \n";
}else{
echo '压缩失败! '
."\n";
}
mainbottom();
}else{
printerror('此服务器上的PHP不支持ZipArchive,无法压缩文件!');
}
}else{
printerror("您没有选择文件");
}
break;
case "权限":
if($os != 'windows'){
if(isset($_POST['select_item'])){
maintop("修改权限");
echo "\n";
echo '';
$chmod = octdec(htmlentities($_REQUEST['chmod']));
function ChmodMine($file, $chmod)
{
$nfile = $file;
$file = gCode($file);
if(is_file($file)){
if(chmod($file, $chmod)){
echo '文件'.$nfile." 权限修改成功\n";
}else{
echo '文件'.$nfile." 权限修改失败\n";
}
}elseif(is_dir($file)){
if(chmod($file, $chmod)){
echo '文件夹'.$nfile." 权限修改成功\n";
}else{
echo '文件夹'.$nfile." 权限修改失败\n";
}
$foldersAndFiles = scandir($file);
$entries = array_slice($foldersAndFiles, 2);
foreach($entries as $entry){
$nentry = iconv("GBK", "UTF-8",$entry);
ChmodMine($nfile.'/'.$nentry, $chmod);
}
}else{
echo $nfile." 文件不存在!\n";
}
}
if($_POST['select_item']['d']){
foreach($_POST['select_item']['d'] as $val){
ChmodMine($val,$chmod);
}
}
if($_POST['select_item']['f']){
foreach($_POST['select_item']['f'] as $val){
ChmodMine($val,$chmod);
}
}
echo " ";
mainbottom();
}else{
printerror("您没有选择文件");
}
}else{printerror("Windows系统无法修改权限。");}
break;
}
/****************************************************************/
/* function switch() */
/* */
/* Switches functions. */
/* Recieves $op() and switches to it *.
/****************************************************************/
switch($op) {
case "home":
home();
break;
case "up":
up();
break;
case "yupload":
if(!isset($_REQUEST['url'])){
printerror('您没有输入文件地址!');
}elseif(isset($_REQUEST['ndir'])){
yupload($_REQUEST['url'], $_REQUEST['ndir'], $_REQUEST['unzip'],$_REQUEST['delzip']);
}else{
yupload($_REQUEST['url'], './',$_REQUEST['unzip'],$_REQUEST['delzip']);
}
break;
case "upload":
if(!isset($_FILES['upfile'])){
printerror('您没有选择文件!');
}elseif(isset($_REQUEST['ndir'])){
upload($_FILES['upfile'], $_REQUEST['ndir'], $_REQUEST['unzip'] ,$_REQUEST['delzip']);
}else{
upload($_FILES['upfile'], './', $_REQUEST['unzip'] ,$_REQUEST['delzip']);
}
break;
case "unz":
unz($_REQUEST['dename']);
break;
case "unzip":
unzip($_REQUEST['dename'],$_REQUEST['ndir'],$_REQUEST['del']);
break;
case "sqlb":
sqlb();
break;
case "sqlbackup":
sqlbackup($_POST['ip'], $_POST['sql'], $_POST['username'], $_POST['password']);
break;
case "ftpa":
ftpa();
break;
case "ftpall":
ftpall($_POST['ftpip'], $_POST['ftpuser'], $_POST['ftppass'], $_POST['goto'], $_POST['ftpfile'], $_POST['del']);
break;
case "allz":
allz();
break;
case "allzip":
allzip();
break;
case "edit":
edit($_REQUEST['fename']);
break;
case "save":
save($_REQUEST['ncontent'], $_REQUEST['fename'], $_REQUEST['encode']);
break;
case "cr":
cr();
break;
case "create":
create($_REQUEST['nfname'], $_REQUEST['isfolder'], $_REQUEST['ndir']);
break;
case "ren":
ren($_REQUEST['file']);
break;
case "rename":
renam($_REQUEST['rename'], $_REQUEST['nrename'], $folder);
break;
case "movall":
movall($_REQUEST['file'], $_REQUEST['ndir'], $folder);
break;
case "copy":
tocopy($_REQUEST['file'], $_REQUEST['ndir'], $folder);
break;
case "printerror":
printerror($error);
break;
case "logout":
logout();
break;
case "z":
z($_REQUEST['dename'],$_REQUEST['folder']);
break;
case "zip":
zip($_REQUEST['dename'],$_REQUEST['folder']);
break;
case "kill":
kill();
break;
case "killme":
killme($_REQUEST['dename']);
break;
default:
home();
break;
}
?>