";
253 | mainbottom();
254 | }
255 |
256 | //获得创建日期等
257 | function gettime($filename)
258 | {
259 | return "修改时间:".date("Y-m-d H:i:s",filemtime($filename))."\n"."创建时间:".date("Y-m-d H:i:s",filectime($filename));
260 | }
261 |
262 | function uCode($text)
263 | {
264 | return mb_convert_encoding($text,'UTF-8','GBK');
265 | }
266 |
267 | function gCode($text)
268 | {
269 | return mb_convert_encoding($text,'GBK','UTF-8');
270 | }
271 |
272 | // 计算文件夹大小的函数
273 | function dirSize($directoty){
274 | $dir_size=0;
275 | $times=0;
276 | if($times<=2){
277 | if($dir_handle=opendir($directoty))
278 | {
279 | while($filename=readdir($dir_handle)){
280 | $subFile=$directoty.DIRECTORY_SEPARATOR.$filename;
281 | if($filename=='.'||$filename=='..'){
282 | continue;
283 | }elseif (is_dir($subFile))
284 | {
285 | $times = $times + 1;
286 | $dir_size+=dirSize($subFile);
287 | }elseif (is_file($subFile)){
288 | $dir_size+=filesize($subFile);
289 | }
290 | }
291 | closedir($dir_handle);
292 | }
293 | }
294 | return ($dir_size);
295 | }
296 | // 计算文件大小的函数
297 | function Size($size) {
298 | $sz = ' kMGTP';
299 | $factor = floor((strlen($size) - 1) / 3);
300 | return ($size>=1024)?sprintf("%.2f", $size / pow(1024, $factor)) . @$sz[$factor]:$size;
301 | }
302 |
303 | function curl_get_contents($url)
304 | {
305 | $ch = curl_init();
306 | curl_setopt($ch, CURLOPT_URL, $url); //设置访问的url地址
307 | //curl_setopt($ch,CURLOPT_HEADER,1); //是否显示头部信息
308 | curl_setopt($ch, CURLOPT_TIMEOUT, 60); //设置超时
309 | curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1); //跟踪301
310 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //返回结果
311 | $r = curl_exec($ch);
312 | curl_close($ch);
313 | return $r;
314 | }
315 |
316 | /****************************************************************/
317 | /* function up() */
318 | /* */
319 | /* First step to Upload. */
320 | /* User enters a file and the submits it to upload() */
321 | /****************************************************************/
322 |
323 | function up() {
324 | global $meurl, $folder, $content;
325 | maintop("上传");
326 |
327 | echo "\n";
338 | echo "远程下载
远程下载是什么意思?
远程下载是从其他服务器获取文件并直接下载到当前服务器的一种功能。
类似于SSH的Wget功能,免去我们下载再手动上传所浪费的时间。
"
340 | ."\n"
342 | .""
343 | ."";
344 |
345 | mainbottom();
346 | }
347 |
348 |
349 | /****************************************************************/
350 | /* function yupload() */
351 | /* */
352 | /* Second step in wget file. */
353 | /* Saves the file to the disk. */
354 | /* Recieves $upfile from up() as the uploaded file. */
355 | /****************************************************************/
356 |
357 | function yupload($url, $folder, $unzip, $delzip) {
358 | global $meurl;
359 | if(empty($folder)){
360 | $folder="./";
361 | }
362 | $nfolder = $folder;
363 | $nurl = $url;
364 | $url = gCode($url);
365 | $folder = gCode($folder);
366 | if($url!==""){
367 | ignore_user_abort(true); // 要求离线也可下载
368 | set_time_limit (24 * 60 * 60); // 设置超时时间
369 | if (!file_exists($folder)){
370 | mkdir($folder, 0755);
371 | }
372 | $newfname = $folder . basename($url); // 取得文件的名称
373 | if(function_exists('curl_init')){
374 | $file = curl_get_contents($url);
375 | file_put_contents($newfname,$file);
376 | }else{
377 | $file = fopen ($url, "rb"); // 远程下载文件,二进制模式
378 | if ($file) { // 如果下载成功
379 | $newf = fopen ($newfname, "wb");
380 | if ($newf) // 如果文件保存成功
381 | while (!feof($file)) { // 判断附件写入是否完整
382 | fwrite($newf, fread($file, 1024 * 8), 1024 * 8); // 没有写完就继续
383 | }
384 | }
385 | if ($file) {
386 | fclose($file); // 关闭远程文件
387 | }
388 | if ($newf) {
389 | fclose($newf); // 关闭本地文件
390 | }
391 | }
392 | maintop("远程上传");
393 | echo "文件 ".basename($url)." 上传成功
\n";
394 | $end = explode('.', basename($url));
395 | if((end($end)=="zip") && isset($unzip) && $unzip == "checkbox"){
396 | if(class_exists('ZipArchive')){
397 | echo "您可以
访问文件夹 或者
返回目录 或者
继续上传\n";
398 | echo "
';
421 | }else{
422 | echo('此服务器上的PHP不支持ZipArchive,无法解压文件!');
423 | }
424 | }else{
425 | echo "您可以 访问文件夹 或者 编辑文件 或者 返回目录 或者 继续上传\n";
426 | }
427 | mainbottom();
428 | return true;
429 | }else{
430 | printerror ('文件地址不能为空。');
431 | }
432 | }
433 |
434 |
435 | /****************************************************************/
436 | /* function upload() */
437 | /* */
438 | /* Second step in upload. */
439 | /* 将文件保存到磁盘中 */
440 | /* Recieves $upfile from up() as the uploaded file. */
441 | /****************************************************************/
442 |
443 | function upload($upfile,$ndir,$unzip,$delzip) {
444 | global $meurl, $folder;
445 | if(empty($ndir)){
446 | $ndir="./";
447 | }
448 | $nfolder = $folder;
449 | $nndir = $ndir;
450 | $ndir = gCode($ndir);
451 | if (!$upfile) {
452 | printerror("您没有选择文件!");
453 | exit;
454 | }elseif($upfile) {
455 | maintop("上传");
456 | if (!file_exists($ndir)){
457 | mkdir($ndir, 0755);
458 | }
459 | $i = 1;
460 | echo "\n";
461 | echo '';
498 | mainbottom();
499 | }else{
500 | printerror("您没有选择文件!");
501 | }
502 | }
503 |
504 | /****************************************************************/
505 | /* function unz() */
506 | /* */
507 | /* First step in unz. */
508 | /* Prompts the user for confirmation. */
509 | /* Recieves $dename and ask for deletion confirmation. */
510 | /****************************************************************/
511 |
512 | function unz($dename) {
513 | global $meurl, $folder, $content;
514 | if (!$dename == "") {
515 | if(class_exists('ZipArchive')){
516 | maintop("解压");
517 | echo "\n"
518 | ."解压 ".$folder.$dename."
\n"
519 | ."
\n";
545 | mainbottom();
546 | }else{
547 | printerror("此服务器上的PHP不支持ZipArchive,无法解压文件!\n");
548 | }
549 | }else{
550 | home();
551 | }
552 | }
553 |
554 |
555 | /****************************************************************/
556 | /* function unzip() */
557 | /* */
558 | /* Second step in unzip. */
559 | /****************************************************************/
560 | function unzip($dename,$ndir,$del) {
561 | global $meurl, $folder;
562 | $nndir = $ndir;
563 | $nfolder = $folder;
564 | $ndename = $dename;
565 | $dename = gCode($dename);
566 | $folder = gCode($folder);
567 | $ndir = gCode($ndir);
568 | if (!$dename == "") {
569 | if (!file_exists($ndir)){
570 | mkdir($ndir, 0755);
571 | }
572 | if(class_exists('ZipArchive')){
573 | $zip = new ZipArchive();
574 | if ($zip->open($folder.$dename) === TRUE) {
575 | maintop("解压");
576 | if($zip->extractTo($ndir)){
577 | echo '';
578 | echo '\n";
595 | mainbottom();
596 | }else{
597 | printerror('无法解压文件:'.$nfolder.$ndename);
598 | }
599 | }else{
600 | printerror('此服务器上的PHP不支持ZipArchive,无法解压文件!');
601 | }
602 | }else{
603 | home();
604 | }
605 | }
606 |
607 |
608 | /****************************************************************/
609 | /* function delete() */
610 | /* */
611 | /* Second step in delete. */
612 | /* Deletes the actual file from disk. */
613 | /* Recieves $upfile from up() as the uploaded file. */
614 | /****************************************************************/
615 |
616 | function deltree($pathdir)
617 | {
618 | if(is_empty_dir($pathdir))//如果是空的
619 | {
620 | rmdir($pathdir);//直接删除
621 | }
622 | else
623 | {//否则读这个目录,除了.和..外
624 | $d=dir($pathdir);
625 | while($a=$d->read())
626 | {
627 | if(is_file($pathdir.'/'.$a) && ($a!='.') && ($a!='..')){unlink($pathdir.'/'.$a);}
628 | //如果是文件就直接删除
629 | if(is_dir($pathdir.'/'.$a) && ($a!='.') && ($a!='..'))
630 | {//如果是目录
631 | if(!is_empty_dir($pathdir.'/'.$a))//是否为空
632 | {//如果不是,调用自身,不过是原来的路径+他下级的目录名
633 | deltree($pathdir.'/'.$a);
634 | }
635 | if(is_empty_dir($pathdir.'/'.$a))
636 | {//如果是空就直接删除
637 | rmdir($pathdir.'/'.$a);
638 | }
639 | }
640 | }
641 | $d->close();
642 | }
643 | }
644 |
645 | function is_empty_dir($pathdir)
646 | {
647 | //判断目录是否为空
648 | $d=opendir($pathdir);
649 | $i=0;
650 | while($a=readdir($d)){
651 | $i++;
652 | }
653 | closedir($d);
654 | if($i>2){return false;}
655 | else return true;
656 | }
657 |
658 |
659 | /****************************************************************/
660 | /* function edit() */
661 | /* */
662 | /* First step in edit. */
663 | /* Reads the file from disk and displays it to be edited. */
664 | /* Recieves $upfile from up() as the uploaded file. */
665 | /****************************************************************/
666 |
667 | function edit($fename) {
668 | global $meurl,$folder;
669 | $file = gCode($folder.$fename);
670 | if (file_exists($file)) {
671 | maintop("编辑");
672 | $contents = file_get_contents($file);
673 | if(function_exists('mb_detect_encoding'))$encode = mb_detect_encoding($contents,array('ASCII','UTF-8','GBK','GB2312'));else $encode = 'UTF-8';
674 | if($_REQUEST['encode']){$encode = $_REQUEST['encode'];}
675 | if($encode!="UTF-8" && !empty($encode))$contents = mb_convert_encoding($contents,"UTF-8",$encode);
676 | foreach(mb_list_encodings() as $key => $value){
677 | if($key >= 19):
678 | $arr = array('EUC-CN' => 'GB2312',
679 | 'CP936' => 'GBK',
680 | 'SJIS-mac'=>'MacJapanese',
681 | 'SJIS-Mobile#DOCOMO'=>'SJIS-DOCOMO',
682 | 'SJIS-Mobile#KDDI'=>'SJIS-KDDI',
683 | 'SJIS-Mobile#SOFTBANK'=>'SJIS-SOFTBANK',
684 | 'UTF-8-Mobile#DOCOMO'=>'UTF-8-DOCOMO',
685 | 'UTF-8-Mobile#KDDI-B'=>'UTF-8-KDDI',
686 | 'UTF-8-Mobile#SOFTBANK'=>'UTF-8-SOFTBANK',
687 | 'ISO-2022-JP-MOBILE#KDDI'=>'ISO-2022-JP-KDDI'
688 | );
689 | if(array_key_exists($value, $arr)) $value_text = $arr[$value]; else $value_text = $value;
690 | if($encode == $value) $list.="'; else $list.="';
691 | endif;
692 | }
693 | echo "\n";
708 | mainbottom();
709 | }else{
710 | printerror("文件不存在!");
711 | }
712 | }
713 |
714 |
715 | /****************************************************************/
716 | /* function save() */
717 | /* */
718 | /* Second step in edit. */
719 | /* Recieves $ncontent from edit() as the file content. */
720 | /* Recieves $fename from edit() as the file name to modify. */
721 | /****************************************************************/
722 |
723 | function save($ncontent, $fename, $encode) {
724 | global $meurl,$folder;
725 | if (!$fename == "") {
726 | $file = gCode($folder.$fename);
727 | $ydata = $ncontent;
728 | if($encode!=="UTF-8" && $encode!=="ASCII")$ydata = mb_convert_encoding($ydata,$encode,"UTF-8");
729 | if(file_put_contents($file, $ydata) or $ncontent=="") {
730 | maintop("编辑");
731 | echo "\n";
732 | echo "\n";
733 | $fp = null;
734 | mainbottom();
735 | }else{
736 | printerror("文件保存出错!");
737 | }
738 | }else{
739 | home();
740 | }
741 | }
742 |
743 | /****************************************************************/
744 | /* function cr() */
745 | /* */
746 | /* First step in create. */
747 | /* Promts the user to a filename and file/directory switch. */
748 | /****************************************************************/
749 |
750 | function cr() {
751 | global $meurl, $folder;
752 | maintop("创建");
753 | echo "\n";
762 | mainbottom();
763 | }
764 |
765 |
766 | /****************************************************************/
767 | /* function create() */
768 | /* */
769 | /* Second step in create. */
770 | /* Creates the file/directoy on disk. */
771 | /* Recieves $nfname from cr() as the filename. */
772 | /* Recieves $infolder from cr() to determine file trpe. */
773 | /****************************************************************/
774 |
775 | function create($nfname, $isfolder, $ndir) {
776 | global $meurl, $folder;
777 | if (!$nfname == "") {
778 | $ndir = gCode($ndir);
779 | $nfname = gCode($nfname);
780 | if ($isfolder == 1) {
781 | if(mkdir($ndir."/".$nfname, 0755)) {
782 | $ndir = uCode($ndir);
783 | $nfname = uCode($nfname);
784 | maintop("创建");
785 | echo "\n"
786 | ."请选择
打开文件夹 或者
返回目录\n";
787 | echo "
";
788 | mainbottom();
789 | }else{
790 | $ndir = uCode($ndir);
791 | $nfname = uCode($nfname);
792 | printerror("您的目录 ".$ndir.$nfname." 不能被创建。请检查您的目录权限是否已经被设置为可写 或者 目录是否已经存在\n");
793 | }
794 | }else{
795 | if(fopen($ndir."/".$nfname, "w")) {
796 | $ndir = uCode($ndir);
797 | $nfname = uCode($nfname);
798 | maintop("创建");
799 | echo "\n"
800 | ."
编辑文件 或者是
返回目录\n";
801 | echo "
";
802 | mainbottom();
803 | }else{
804 | $ndir = uCode($ndir);
805 | $nfname = uCode($nfname);
806 | printerror("您的文件 ".$ndir.$nfname." 不能被创建。请检查您的目录权限是否已经被设置为可写 或者 文件是否已经存在\n");
807 | }
808 | }
809 | }else{
810 | cr();
811 | }
812 | }
813 |
814 |
815 | /****************************************************************/
816 | /* function ren() */
817 | /* */
818 | /* First step in rename. */
819 | /* Promts the user for new filename. */
820 | /* Globals $file and $folder for filename. */
821 | /****************************************************************/
822 |
823 | function ren($file) {
824 | global $meurl,$folder,$ufolder;
825 | $ufile = $file;
826 | if (!$file == "") {
827 | maintop("重命名");
828 | echo "\n";
834 | mainbottom();
835 | }else{
836 | home();
837 | }
838 | }
839 |
840 |
841 | /****************************************************************/
842 | /* function renam() */
843 | /* */
844 | /* Second step in rename. */
845 | /* Rename the specified file. */
846 | /* Recieves $rename from ren() as the old filename. */
847 | /* Recieves $nrename from ren() as the new filename. */
848 | /****************************************************************/
849 |
850 | function renam($rename, $nrename, $folder) {
851 | global $meurl,$folder;
852 | if (!$rename == "") {
853 | $loc1 = gCode("$folder".$rename);
854 | $loc2 = gCode("$folder".$nrename);
855 | if(rename($loc1,$loc2)) {
856 | maintop("重命名");
857 | echo "文件 ".$folder.$rename." 已被重命名成 ".$folder.$nrename."
\n"
858 | ."\n";
859 | mainbottom();
860 | }else{
861 | printerror("重命名出错!");
862 | }
863 | }else{
864 | home();
865 | }
866 | }
867 |
868 | /****************************************************************/
869 | /* function movall */
870 | /* */
871 | /* 批量移动 2014-4-12 by jooies */
872 | /****************************************************************/
873 |
874 | function movall($file, $ndir, $folder) {
875 | global $meurl,$folder;
876 | if (!$file == "") {
877 | maintop("批量移动");
878 | echo "";
879 | $arr = str_split($ndir);
880 | if($arr[count($arr)-1]!=='/'){
881 | $ndir .= '/';
882 | }
883 | $nndir = $ndir;
884 | $nfolder = $folder;
885 | $file = gCode($file);
886 | $ndir = gCode($ndir);
887 | $folder = gCode($folder);
888 | if (!file_exists($ndir)){
889 | mkdir($ndir, 0755);
890 | }
891 | $file = explode(',',$file);
892 | echo "您可以
前往文件夹查看文件 或者
返回目录\n";
893 | foreach ($file as $v) {
894 | if (file_exists($ndir.$v)){
895 | if (rename($folder.$v, $ndir.$v.".move")){
896 | $v = iconv("GBK", "UTF-8",$v);
897 | echo $nndir.$v." 文件已存在,自动更名为
{$nndir}{$v}.move";
898 | }else{
899 | $v = iconv("GBK", "UTF-8",$v);
900 | echo "
无法移动 ".$nfolder.$v.',请检查文件权限';
901 | }
902 | }elseif (rename($folder.$v, $ndir.$v)){
903 | $v = iconv("GBK", "UTF-8",$v);
904 | echo $nfolder.$v." 已经成功移动到 ".$nndir.$v.'
';
905 | }else{
906 | $v = iconv("GBK", "UTF-8",$v);
907 | echo "
无法移动 ".$nfolder.$v.',请检查文件权限或文件是否存在';
908 | }
909 | }
910 | echo "
";
911 | mainbottom();
912 | }else{
913 | home();
914 | }
915 | }
916 |
917 | /****************************************************************/
918 | /* function tocopy */
919 | /* */
920 | /* 批量复制 2014-4-19 by jooies */
921 | /****************************************************************/
922 |
923 | function tocopy($file, $ndir, $folder) {
924 | global $meurl,$folder;
925 | if (!$file == "") {
926 | maintop("复制");
927 | echo "";
928 | $nndir = $ndir;
929 | $nfolder = $folder;
930 | $file = gCode($file);
931 | $ndir = gCode($ndir);
932 | $folder = gCode($folder);
933 | if (!file_exists($ndir)){
934 | mkdir($ndir, 0755);
935 | }
936 | $file = explode(',',$file);
937 | echo "您可以
前往文件夹查看文件 或者
返回目录\n";
938 | foreach ($file as $v) {
939 | if (file_exists($ndir.$v)){
940 | if (copy($folder.$v, $ndir.$v.'.copy')){
941 | $v = iconv("GBK", "UTF-8",$v);
942 | echo "{$nndir}{$v} 文件已存在,自动更名为
{$nfolder}{$v}.copy";
943 | }else{
944 | $v = iconv("GBK", "UTF-8",$v);
945 | echo "
无法复制 {$nfolder}{$v},请检查文件权限";
946 | }
947 | }elseif (copy($folder.$v, $ndir.$v)){
948 | $v = iconv("GBK", "UTF-8",$v);
949 | echo $nfolder.$v." 已经成功复制到 ".$nndir.$v.'
';
950 | }else{
951 | $v = iconv("GBK", "UTF-8",$v);
952 | echo "
无法复制 ".$nfolder.$v.',请检查文件权限';
953 | }
954 | }
955 | echo "
";
956 | mainbottom();
957 | }else{
958 | home();
959 | }
960 | }
961 |
962 |
963 | /****************************************************************/
964 | /* function logout() */
965 | /* */
966 | /* Logs the user out and kills cookies */
967 | /****************************************************************/
968 |
969 | function logout() {
970 | global $meurl;
971 | setcookie("user","",time()-60*60*24*1);
972 | setcookie("pass","",time()-60*60*24*1);
973 |
974 | maintop("注销",false);
975 | echo "注销成功!
"
976 | ."
点击这里重新登录";
977 | mainbottom();
978 | }
979 |
980 |
981 | /****************************************************************/
982 | /* function mainbottom() */
983 | /* */
984 | /* 页面底部的版权声明 */
985 | /****************************************************************/
986 |
987 | function mainbottom() {
988 | echo "
"
989 | ."FileBox Version 1.8.1.2
\n"
990 | ."\n";
991 | exit;
992 | }
993 |
994 |
995 | /****************************************************************/
996 | /* function sqlb() */
997 | /* */
998 | /* First step to backup sql. */
999 | /****************************************************************/
1000 |
1001 | function sqlb() {
1002 | global $meurl;
1003 | maintop("数据库备份");
1004 | echo "这将进行数据库导出并压缩成mysql.zip的动作! 如存在该文件,该文件将被覆盖!
\n";
1005 | mainbottom();
1006 | }
1007 |
1008 |
1009 | /****************************************************************/
1010 | /* function sqlbackup() */
1011 | /* */
1012 | /* Second step in backup sql. */
1013 | /****************************************************************/
1014 |
1015 | function sqlbackup($ip,$sql,$username,$password) {
1016 | global $meurl;
1017 | if(class_exists('ZipArchive')){
1018 | maintop("MySQL备份");
1019 | $database=$sql;//数据库名
1020 | $options=array(
1021 | 'hostname' => $ip,//ip地址
1022 | 'charset' => 'utf8',//编码
1023 | 'filename' => $database.'.sql',//文件名
1024 | 'username' => $username,
1025 | 'password' => $password
1026 | );
1027 | $mysql = mysqli_connect($options['hostname'],$options['username'],$options['password'],$database)or die("不能连接数据库!".mysqli_connect_error());
1028 | mysqli_query($mysql,"SET NAMES '{$options['charset']}'");
1029 | $tables = list_tables($database,$mysql);
1030 | $filename = sprintf($options['filename'],$database);
1031 | $fp = fopen($filename, 'w');
1032 | foreach ($tables as $table) {
1033 | dump_table($table, $fp,$mysql);
1034 | }
1035 | fclose($fp);
1036 | mysqli_close($mysql);
1037 | //压缩sql文件
1038 | if (file_exists('mysql.zip')) {
1039 | unlink('mysql.zip');
1040 | }
1041 | $file_name=$options['filename'];
1042 | $zip = new ZipArchive;
1043 | $res = $zip->open('mysql.zip', ZipArchive::CREATE);
1044 | if ($res === TRUE) {
1045 | $zip->addfile($file_name);
1046 | $zip->close();
1047 | //删除服务器上的sql文件
1048 | unlink($file_name);
1049 | echo '数据库导出并压缩完成!'
1050 | ."
返回目录 \n";
1051 | }else{
1052 | printerror('无法压缩文件!');
1053 | }
1054 | exit;
1055 | mainbottom();
1056 | }else{
1057 | printerror('此服务器上的PHP不支持ZipArchive,无法压缩文件!');
1058 | }
1059 | }
1060 |
1061 | function list_tables($database,$mysql)
1062 | {
1063 | $rs = mysqli_query($mysql,"SHOW TABLES FROM $database");
1064 | $tables = array();
1065 | while ($row = mysqli_fetch_row($rs)) {
1066 | $tables[] = $row[0];
1067 | }
1068 | mysqli_free_result($rs);
1069 | return $tables;
1070 | }
1071 |
1072 | //导出数据库
1073 | function dump_table($table, $fp = null,$mysql)
1074 | {
1075 | $need_close = false;
1076 | if (is_null($fp)) {
1077 | $fp = fopen($table . '.sql', 'w');
1078 | $need_close = true;
1079 | }
1080 | $a=mysqli_query($mysql,"show create table `{$table}`");
1081 | $row=mysqli_fetch_assoc($a);fwrite($fp,$row['Create Table'].';');//导出表结构
1082 | $rs = mysqli_query($mysql,"SELECT * FROM `{$table}`");
1083 | while ($row = mysqli_fetch_row($rs)) {
1084 | fwrite($fp, get_insert_sql($table, $row));
1085 | }
1086 | mysqli_free_result($rs);
1087 | if ($need_close) {
1088 | fclose($fp);
1089 | }
1090 | }
1091 |
1092 | //导出表数据
1093 | function get_insert_sql($table, $row)
1094 | {
1095 | $sql = "INSERT INTO `{$table}` VALUES (";
1096 | $values = array();
1097 | foreach ($row as $value) {
1098 | $values[] = "'" . mysql_real_escape_string($value) . "'";
1099 | }
1100 | $sql .= implode(', ', $values) . ");";
1101 | return $sql;
1102 | }
1103 |
1104 | /****************************************************************/
1105 | /* function ftpa() */
1106 | /* */
1107 | /* First step to backup sql. */
1108 | /****************************************************************/
1109 |
1110 | function ftpa() {
1111 | global $meurl;
1112 | maintop("FTP备份");
1113 | echo "这将把文件远程上传到其他ftp!如目录存在该文件,文件将被覆盖!
\n\n";
1114 | mainbottom();
1115 | }
1116 |
1117 | /****************************************************************/
1118 | /* function ftpall() */
1119 | /* */
1120 | /* Second step in backup sql. */
1121 | /****************************************************************/
1122 |
1123 | function ftpall($ftpip,$ftpuser,$ftppass,$ftpdir,$ftpfile,$del) {
1124 | global $meurl;
1125 | $ftpfile = gCode($ftpfile);
1126 | $ftpip=explode(':', $ftpip);
1127 | $ftp_server=$ftpip['0'];//服务器
1128 | $ftp_user_name=$ftpuser;//用户名
1129 | $ftp_user_pass=$ftppass;//密码
1130 | if(empty($ftpip['1'])){
1131 | $ftp_port='21';
1132 | }else{
1133 | $ftp_port=$ftpip['1'];//端口
1134 | }
1135 | $ftp_put_dir=$ftpdir;//上传目录
1136 | $ffile=$ftpfile;//上传文件
1137 |
1138 | $ftp_conn_id = ftp_connect($ftp_server,$ftp_port);
1139 | $ftp_login_result = ftp_login($ftp_conn_id, $ftp_user_name, $ftp_user_pass);
1140 |
1141 | if((!$ftp_conn_id) || (!$ftp_login_result)) {
1142 | printerror('连接到ftp服务器失败');
1143 | exit;
1144 | }else{
1145 | ftp_pasv ($ftp_conn_id,true); //返回一下模式,这句很奇怪,有些ftp服务器一定需要执行这句
1146 | ftp_chdir($ftp_conn_id, $ftp_put_dir);
1147 | $ffile=explode(',', $ffile);
1148 | foreach ($ffile as $v) {
1149 | $ftp_upload = ftp_put($ftp_conn_id,$v,$v, FTP_BINARY);
1150 | if ($del == 'del') {
1151 | unlink('./'.$v);
1152 | }
1153 | }
1154 | ftp_close($ftp_conn_id); //断开
1155 | }
1156 | maintop("FTP上传");
1157 | echo "";
1158 | $ftpfile = uCode($ftpfile);
1159 | echo "文件 ".$ftpfile." 上传成功
\n"
1160 | ."
返回目录\n";
1161 | echo "
";
1162 | mainbottom();
1163 | }
1164 |
1165 |
1166 | /****************************************************************/
1167 | /* function printerror() */
1168 | /* */
1169 | /* 用于显示错误信息的函数 */
1170 | /* $error为显示的提示 */
1171 | /****************************************************************/
1172 |
1173 | function printerror($error) {
1174 | maintop("错误");
1175 | echo "错误信息如下:
";
1176 | mainbottom();
1177 | }
1178 |
1179 | /****************************************************************/
1180 | /* function deleteall() */
1181 | /* */
1182 | /* 2014-3-9 Add by Jooies */
1183 | /* 实现文件的批量删除功能 */
1184 | /****************************************************************/
1185 |
1186 | function deleteall($dename) {
1187 | if (!$dename == "") {
1188 | $udename = $dename;
1189 | $dename = gCode($dename);
1190 | if (is_dir($dename)) {
1191 | if(is_empty_dir($dename)){
1192 | rmdir($dename);
1193 | echo $udename." 已经被删除\n";
1194 | }else{
1195 | deltree($dename);
1196 | rmdir($dename);
1197 | echo $udename." 已经被删除\n";
1198 | }
1199 | }else{
1200 | if(unlink($dename)) {
1201 | echo $udename." 已经被删除\n";
1202 | }else{
1203 | echo("无法删除文件:$udename 。\n参考信息\n1.文件不存在\n2.文件正在执行\n");
1204 | }
1205 | }
1206 | }
1207 | }
1208 |
1209 | switch($action) {//$action 为批量操作
1210 | case "删除":
1211 | if(isset($_POST['select_item'])){
1212 | maintop("删除");
1213 | echo "\n";
1214 | echo '';
1226 | mainbottom();
1227 | }else{
1228 | printerror("您没有选择文件");
1229 | }
1230 | break;
1231 |
1232 | case "移动":
1233 | if(isset($_POST['select_item'])){
1234 | maintop("批量移动");
1235 | $file = '';
1236 | if($_POST['select_item']['d']){
1237 | foreach($_POST['select_item']['d'] as $key => $val){
1238 | $file = $file.$key.',';
1239 | }
1240 | }
1241 | if($_POST['select_item']['f']){
1242 | foreach($_POST['select_item']['f'] as $key => $val){
1243 | $file = $file.$key.',';
1244 | }
1245 | }
1246 | $file = substr($file,0,-1);
1247 | echo "编辑文件 {$folder}{$fename}\n"
637 | ." » '
640 | ."
'
643 | .""
646 | ."
\n"
647 | ."\n"
648 | ."\n"
649 | ."\n"
650 | ."\n";
651 | mainbottom();
652 | }else{
653 | printerror("文件不存在!");
654 | }
655 | }
656 |
657 |
658 | /****************************************************************/
659 | /* function save() */
660 | /* */
661 | /* Second step in edit. */
662 | /* Recieves $ncontent from edit() as the file content. */
663 | /* Recieves $fename from edit() as the file name to modify. */
664 | /****************************************************************/
665 |
666 | function save($ncontent, $fename, $encode) {
667 | global $meurl,$folder;
668 | if (!$fename == "") {
669 | $file = gCode($folder.$fename);
670 | $ydata = $ncontent;
671 | if($encode!=="UTF-8" && $encode!=="ASCII")$ydata = mb_convert_encoding($ydata,$encode,"UTF-8");
672 | if(file_put_contents($file, $ydata) or $ncontent=="") {
673 | maintop("编辑");
674 | echo "\n";
675 | echo "\n";
676 | $fp = null;
677 | mainbottom();
678 | }else{
679 | printerror("文件保存出错!");
680 | }
681 | }else{
682 | home();
683 | }
684 | }
685 |
686 | /****************************************************************/
687 | /* function cr() */
688 | /* */
689 | /* First step in create. */
690 | /* Promts the user to a filename and file/directory switch. */
691 | /****************************************************************/
692 |
693 | function cr() {
694 | global $meurl, $folder;
695 | maintop("创建");
696 | echo "\n"
697 | ."创建文件 或 目录
\n"
699 | ."
";
700 |
701 | echo "\n"
702 | ."\n"
703 | ."\n";
704 | mainbottom();
705 | }
706 |
707 |
708 | /****************************************************************/
709 | /* function create() */
710 | /* */
711 | /* Second step in create. */
712 | /* Creates the file/directoy on disk. */
713 | /* Recieves $nfname from cr() as the filename. */
714 | /* Recieves $infolder from cr() to determine file trpe. */
715 | /****************************************************************/
716 |
717 | function create($nfname, $isfolder, $ndir) {
718 | global $meurl, $folder;
719 | if (!$nfname == "") {
720 | $ndir = gCode($ndir);
721 | $nfname = gCode($nfname);
722 | if ($isfolder == 1) {
723 | if(mkdir($ndir."/".$nfname, 0755)) {
724 | $ndir = uCode($ndir);
725 | $nfname = uCode($nfname);
726 | maintop("创建");
727 | echo "\n"
728 | ."请选择
打开文件夹 或者
返回目录\n";
729 | echo "
";
730 | mainbottom();
731 | }else{
732 | $ndir = uCode($ndir);
733 | $nfname = uCode($nfname);
734 | printerror("您的目录 ".$ndir.$nfname." 不能被创建。请检查您的目录权限是否已经被设置为可写 或者 目录是否已经存在\n");
735 | }
736 | }else{
737 | if(fopen($ndir."/".$nfname, "w")) {
738 | $ndir = uCode($ndir);
739 | $nfname = uCode($nfname);
740 | maintop("创建");
741 | echo "\n"
742 | ."
编辑文件 或者是
返回目录\n";
743 | echo "
";
744 | mainbottom();
745 | }else{
746 | $ndir = uCode($ndir);
747 | $nfname = uCode($nfname);
748 | printerror("您的文件 ".$ndir.$nfname." 不能被创建。请检查您的目录权限是否已经被设置为可写 或者 文件是否已经存在\n");
749 | }
750 | }
751 | }else{
752 | cr();
753 | }
754 | }
755 |
756 |
757 | /****************************************************************/
758 | /* function ren() */
759 | /* */
760 | /* First step in rename. */
761 | /* Promts the user for new filename. */
762 | /* Globals $file and $folder for filename. */
763 | /****************************************************************/
764 |
765 | function ren($file) {
766 | global $meurl,$folder,$ufolder;
767 | $ufile = $file;
768 | if (!$file == "") {
769 | maintop("重命名");
770 | echo "\n"
771 | ."重命名 ".$ufolder.$ufile.'
';
772 | echo "\n"
773 | ."\n"
774 | ."\n"
775 | ."\n";
776 | mainbottom();
777 | }else{
778 | home();
779 | }
780 | }
781 |
782 |
783 | /****************************************************************/
784 | /* function renam() */
785 | /* */
786 | /* Second step in rename. */
787 | /* Rename the specified file. */
788 | /* Recieves $rename from ren() as the old filename. */
789 | /* Recieves $nrename from ren() as the new filename. */
790 | /****************************************************************/
791 |
792 | function renam($rename, $nrename, $folder) {
793 | global $meurl,$folder;
794 | if (!$rename == "") {
795 | $loc1 = gCode("$folder".$rename);
796 | $loc2 = gCode("$folder".$nrename);
797 | if(rename($loc1,$loc2)) {
798 | maintop("重命名");
799 | echo "文件 ".$folder.$rename." 已被重命名成 ".$folder.$nrename."
\n"
800 | ."\n";
801 | mainbottom();
802 | }else{
803 | printerror("重命名出错!");
804 | }
805 | }else{
806 | home();
807 | }
808 | }
809 |
810 | /****************************************************************/
811 | /* function movall */
812 | /* */
813 | /* 批量移动 2014-4-12 by jooies */
814 | /****************************************************************/
815 |
816 | function movall($file, $ndir, $folder) {
817 | global $meurl,$folder;
818 | if (!$file == "") {
819 | maintop("批量移动");
820 | $arr = str_split($ndir);
821 | if($arr[count($arr)-1]!=='/'){
822 | $ndir .= '/';
823 | }
824 | $nndir = $ndir;
825 | $nfolder = $folder;
826 | $file = gCode($file);
827 | $ndir = gCode($ndir);
828 | $folder = gCode($folder);
829 | if (!file_exists($ndir)){
830 | mkdir($ndir, 0755);
831 | }
832 | $file = explode(',',$file);
833 | echo "";
852 | mainbottom();
853 | }else{
854 | home();
855 | }
856 | }
857 |
858 | /****************************************************************/
859 | /* function tocopy */
860 | /* */
861 | /* 批量复制 2014-4-19 by jooies */
862 | /****************************************************************/
863 |
864 | function tocopy($file, $ndir, $folder) {
865 | global $meurl,$folder;
866 | if (!$file == "") {
867 | maintop("复制");
868 | $nndir = $ndir;
869 | $nfolder = $folder;
870 | $file = gCode($file);
871 | $ndir = gCode($ndir);
872 | $folder = gCode($folder);
873 | if (!file_exists($ndir)){
874 | mkdir($ndir, 0755);
875 | }
876 | $file = explode(',',$file);
877 | echo "";
896 | mainbottom();
897 | }else{
898 | home();
899 | }
900 | }
901 |
902 |
903 | /****************************************************************/
904 | /* function logout() */
905 | /* */
906 | /* Logs the user out and kills cookies */
907 | /****************************************************************/
908 |
909 | function logout() {
910 | global $meurl;
911 | setcookie("user","",time()-60*60*24*1);
912 | setcookie("pass","",time()-60*60*24*1);
913 |
914 | maintop("注销",false);
915 | echo "注销成功!
"
916 | ."
点击这里重新登录";
917 | mainbottom();
918 | }
919 |
920 |
921 | /****************************************************************/
922 | /* function mainbottom() */
923 | /* */
924 | /* 页面底部的版权声明 */
925 | /****************************************************************/
926 |
927 | function mainbottom() {
928 | echo "
"
929 | ."FileBox Version 1.10.0.2
\n"
930 | ."