task.php
资源名称:BBWPS.rar [点击查看]
上传用户:yttaitong
上传日期:2009-05-10
资源大小:128k
文件大小:19k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
PHP
- <?php
- /*
- [BBWPS!] (C)2006-2010 小蜜蜂版权所有.
- This is NOT a freeware, use is subject to license terms
- 时间:2007年12月
- 描述:
- */
- define('IN_SELF', 'task');
- require_once ("./global.php");
- session_start();
- require_once ($T_function);
- $path = urldecode($_POST['path']);
- $parentpath = urlencode(direction($path));
- $realpath = truepath($path);
- if($_GET['type']==folder){
- $realpath = truepath($path,2);
- }
- $zippath = $T_zipdir.'/'.str_replace('/','_',$path);
- $reload = "window.location=('".$T_main."?path=".$parentpath."')";
- $sreload = "window.location=('".$T_main."?path=".$_POST['path']."')";
- $preload = "parent.location=('".$T_main."?path=".$parentpath."')";
- $rreload = "parent.location=('".$T_main."?path=".$_POST['path']."')";
- $window = true;
- require_once ($T_language);
- if($_POST['action']){
- switch($_POST['action']){
- case "shortcut":
- include_once("shortcut.list");
- if(in_array($_POST['path'],(array)$shortcuts)){
- echo "<script>alert('快捷方式已存在');</script>";
- exit();
- }
- $i=0;
- $shortcuts[]=$_POST['path'];
- $handle=fopen("shortcut.list","w");
- $str="<?php
- ";
- foreach($shortcuts as $value){
- $str.="$shortcuts[".($i++)."]="".$value."";
- ";
- }
- $str.="?>";
- fwrite($handle,$str);
- fclose($handle);
- echo "<script>alert('创建成功');</script>";
- break;
- case "replace"://字符串替换
- include_once("manager/include/replace.php");
- $arrConfig['isReg'] = $_POST['isReg']?1:0;
- $arrConfig['sub'] = $_POST['sub']?1:0;
- $arrConfig['replacePath'] = $realpath."/";
- $arrConfig['fileType'] = explode(",",$_POST['filetype']);
- $arrConfig['search'][0] = $_POST['key'];
- $arrConfig['replace'][0] = $_POST['keynew'];
- $str = new ReplaceFile($arrConfig);
- $content="<div style="width:100%;height:200;overflow-x:hidden;overflow-y:scroll;"><table><tr><td> </td><td align="left">$str->msg</td></tr></table></div>";
- $title="字符串替换";
- break;
- case "rename"://重命名文件夹或文件之前的检查
- $title = $T_lang['title'][0];
- $name = basename($path);
- if(checkcore($path)){
- $content = $T_lang['rename'][0].$T_lang['confirm'][0];
- }else{
- $content = $T_lang['rename'][1].$T_lang['form'][0].$T_lang['path'][0].
- $T_lang['action'][0].str_replace("--name--",$name,$T_lang['rename'][2]).
- $T_lang['submit'][0].$T_lang['cancel'][0].$T_lang['form']['end'];
- }
- break;
- case "truerename"://重命名文件夹或文件
- $title = $T_lang['title'][0];
- if($_POST['newname']===""){//判断文件夹或文件名有没有给
- $content = $T_lang['newfolder'][0].$T_lang['confirm'][0];
- }else{
- $newname = $_POST['newname'];
- if(file_exists(dirname($realpath)."/".$newname)){
- $content = $T_lang['rename'][3].$T_lang['confirm'][0];
- }else{
- if(rename($realpath,dirname($realpath)."/".$newname)){
- $window = false;
- $method = $preload;
- }else{
- $content = $T_lang['rename'][4].$T_lang['confirm'][0];
- }
- }
- }
- break;
- case "newfolder"://新文件夹
- $title = $T_lang['title'][1];
- if($_POST['foldername']===""){//判断文件夹名有没有给
- $content = $T_lang['newfolder'][0].$T_lang['confirm'][0];
- }else{
- $name = $_POST['foldername'];
- if(is_dir($realpath."/".$name)){
- $content = $T_lang['newfolder'][1].$T_lang['confirm'][0];
- }else{
- if(@mkdir($realpath."/".$name,0777)){
- $window = false;
- $method = $rreload;
- }else{
- $content = $T_lang['newfolder'][2].$T_lang['confirm'][0];
- }
- }
- }
- break;
- case "newfile"://新文件
- $title = $T_lang['title'][2];
- $name = $_POST['filename'].".".$_POST['exttype'];
- if($_POST['filename']===""){//判断文件名有没有给
- $content = $T_lang['newfile'][0].$T_lang['confirm'][0];
- }elseif(file_exists($realpath."/".$name)){
- $content = $T_lang['newfile'][1].$T_lang['confirm'][0];
- }else{
- if(file_exists($T_newfile)){
- if(copy($T_newfile,$realpath."/".$name)){
- $window = false;
- $method = $rreload;
- }elseif($fp = fopen($realpath."/".$name,"w")){
- flock($fp,LOCK_EX);
- fwrite($fp,"newfile",1024);
- flock($fp,LOCK_UN);
- fclose($fp);
- $window = false;
- $method = $rreload;
- }else{
- $content = $T_lang['newfile'][2].$T_lang['confirm'][0];
- }
- }elseif($fp = fopen($realpath."/".$name,"w")){
- flock($fp,LOCK_EX);
- fwrite($fp,"newfile",1024);
- flock($fp,LOCK_UN);
- fclose($fp);
- $window = false;
- $method = $rreload;
- }else{
- $content = $T_lang['newfile'][3].$T_lang['confirm'][0];
- }
- }
- break;
- case "download"://下载文件或文件夹前的准备
- $title = $T_lang['title'][3];
- if(is_dir($realpath)){//压缩要下载的文件夹
- $zip = new ZipAllFloder();
- $zip->ZipFolder($realpath,$zippath.".zip");
- $content = $T_lang['download'][0].$T_lang['form'][2].$T_lang['action'][1].
- $T_lang['path'][1].$T_lang['submit'][1].$T_lang['cancel'][1].
- $T_lang['form']['end'];
- }else{//检查是否存在文件
- if(file_exists($realpath)){
- $content = $T_lang['download'][1].$T_lang['form'][1].
- $T_lang['action'][1].$T_lang['path'][0].$T_lang['submit'][1].
- $T_lang['cancel'][1].$T_lang['form']['end'];
- }else{
- $content = $T_lang['download'][2].$T_lang['confirm'][0];
- }
- }
- break;
- case "truedownload"://直接下载文件
- $filename = basename($path);
- $str='Content-Disposition: attachment; filename="'.$filename.'"';
- header("Content-type: application/force-download");
- header($str);
- readfile($realpath);
- exit;
- break;
- case "crush"://回收文件或文件夹前的检查
- $title = $T_lang['title'][4];
- if(checkcore($path)){//检查核心文件是否是该$path的一个节点
- $content = $T_lang['crush'][0].$T_lang['confirm'][0];
- }else{
- $content = $T_lang['crush'][1].$T_lang['form'][0].$T_lang['path'][0].
- $T_lang['action'][2].$T_lang['submit'][2].$T_lang['cancel'][0].
- $T_lang['form']['end'];
- }
- break;
- case "back"://删除文件或文件夹
- $title = $T_lang['title'][4];
- $from = $T_fprefix.base64_encode(direction($path)).$T_fsuffix;
- if(is_dir($realpath)){
- $target = $T_Recycled."/".basename($path).$T_tprefix.date('Y-m-d H-i-s').
- $T_tsuffix.$from;
- $return = movepath($realpath,$target);
- if($return){
- $content = str_replace("--alert--",$return,$T_lang['font'][0]).
- $T_lang['confirm'][1];
- }else{
- $content = $T_lang['back'][0].$T_lang['confirm'][1];
- }
- }else{
- if($suffix=fileext(basename($realpath))){
- $suffix = ".".$suffix;
- $target = $T_Recycled."/".basename($path,$suffix).$T_tprefix.
- date('Y-m-d H-i-s').$T_tsuffix.$from.$suffix;
- }else{
- $target = $T_Recycled."/".basename($path).$T_tprefix.
- date('Y-m-d H-i-s').$T_tsuffix.$from;
- }
- if(@copy($realpath,$target)){
- @unlink($realpath);
- $content = $T_lang['back'][1].$T_lang['confirm'][1];
- }else{
- $content = $T_lang['back'][2].$T_lang['confirm'][0];
- }
- }
- break;
- case "return"://还原回收站内的文件或文件夹
- $title = $T_lang['title'][5];
- if(ereg(".*".$T_fprefix_."(.*)".$T_fsuffix_.".*",$path)){
- $return = ereg_replace(".*".$T_fprefix_."(.*)".$T_fsuffix_.".*",
- "\1",$path);
- $return = truepath(base64_decode($return));
- if(is_dir($realpath)){
- $target = $return."/".ereg_replace("(.*)".$T_tprefix_.".*","\1",
- basename($path));
- if($errors = movepath($realpath,$target)){
- $content = str_replace("--alert--",$errors,$T_lang['font'][0]).
- $T_lang['confirm'][0];
- }else{
- $window = false;
- $method = $preload;
- }
- }else{
- $target = $return."/".
- ereg_replace("(.*)".$T_tprefix_.".*".$T_tsuffix_."(..*)?","\1\2",
- basename($path));
- if(file_exists($target)){
- $content = $T_lang['return'][0].$T_lang['confirm'][0];
- }else{
- if(@copy($realpath,$target)){
- if(@unlink($realpath)){
- $window = false;
- $method = $preload;
- }else{
- $content = $T_lang['return'][1].$T_lang['confirm'][0];
- }
- }
- }
- }
- }else{
- $content = $T_lang['return'][2].$T_lang['confirm'][0];
- }
- break;
- case "delete"://删除文件夹或文件前的confirm
- $title = $T_lang['title'][6];
- if(checkcore($path)){
- $content = $T_lang['delete'][0].$T_lang['confirm'][0];
- }else{
- $content = $T_lang['delete'][1].$T_lang['form'][0].$T_lang['action'][3].
- $T_lang['path'][0].$T_lang['submit'][3].$T_lang['cancel'][0].
- $T_lang['form']['end'];
- }
- break;
- case "truedelete"://删除文件夹或文件
- $title = $T_lang['title'][6];
- if(file_exists($realpath)){
- if(is_dir($realpath)){//删除整个文件夹
- $return = delpath($realpath);
- if($return){
- $content = str_replace("--alert--",$return,$T_lang['font'][0]).
- $T_lang['confirm'][1];
- }else{
- $content = $T_lang['delete'][2].$T_lang['confirm'][1];
- }
- }else{//删除单个文件
- if(@unlink($realpath)){
- $content = $T_lang['delete'][3].$T_lang['confirm'][1];
- }else{
- $content = $T_lang['delete'][4].$T_lang['confirm'][1];
- }
- }
- }else{
- $content = $T_lang['delete'][5].$T_lang['confirm'][1];
- }
- break;
- case "scissor"://创建剪切任务
- if(checkcore($path)){
- $title = $T_lang['title'][7];
- $content = $T_lang['scissor'][0].$T_lang['confirm'][0];
- }else{
- if(isset($_SESSION['readystick'])){
- unset($_SESSION['readystick']);
- }
- $_SESSION['readystick'][0] = $_POST['path'];
- $_SESSION['readystick'][1] = "scissor";
- $window = false;
- $method = NULL;
- }
- break;
- case "copy"://创建拷贝任务
- if(isset($_SESSION['readystick'])){
- unset($_SESSION['readystick']);
- }
- $_SESSION['readystick'][0] = $_POST['path'];
- $_SESSION['readystick'][1] = "copy";
- $window = false;
- $method = NULL;
- break;
- case "stepstick"://粘贴前的检查
- $break = true;
- $title = $T_lang['title'][8];
- if(isset($_SESSION['readystick'])){
- $source = truepath(urldecode($_SESSION['readystick'][0]));
- if(is_dir($realpath."/".basename($source))&&is_dir($source)&&
- (strtolower(dirname($source))!=strtolower($realpath)))
- {
- $content = str_replace("--target--",$path."/".basename($source),
- $T_lang['stick'][0]).$T_lang['submit'][4].$T_lang['cancel'][0];
- }elseif(file_exists($realpath."/".basename($source))&&is_file($source)&&
- (strtolower(dirname($source))!=strtolower($realpath)))
- {
- $content = str_replace("--target--",$path."/".basename($source),
- $T_lang['stick'][1]).$T_lang['submit'][4].$T_lang['cancel'][0];
- }else{
- $break = false;
- }
- }else{
- $content = $T_lang['stick'][3].$T_lang['confirm'][0];
- }
- if($break){
- break;
- }
- case "stick"://开始粘贴
- $title = $T_lang['title'][8];
- if(isset($_SESSION['readystick'])){
- $source = truepath(urldecode($_SESSION['readystick'][0]));
- if($_SESSION['readystick'][1] == "copy"){//粘贴拷贝任务
- if(strtolower(dirname($source)) == strtolower($realpath)){
- $target = $path."/".$T_lang['stick'][4].basename($source);
- }else{
- $target = $path."/".basename($source);
- }
- if(checkcore($target)){
- $errors = $T_lang['stick'][5];
- }else{
- $target = truepath($target);
- if(is_dir($source)){
- if($_POST['type']=="cover"){
- $errors = copypath($source,$target,false);
- }else{
- $errors = copypath($source,$target);
- }
- if($errors==""){
- $errors = $T_lang['stick'][6];
- }else{
- $errors = str_replace("--alert--",$errors,
- $T_lang['font'][0]);
- }
- }else{
- if(@copy($source,$target)){
- $errors = $T_lang['stick'][7];
- }else{
- $errors = str_replace("--source--",$source,
- $T_lang['stick'][8]);
- }
- }
- }
- }elseif($_SESSION['readystick'][1] == "scissor"){//粘贴剪切任务
- if(strtolower(dirname($source)) == strtolower($realpath)){
- $errors = $T_lang['stick'][9];
- }else{
- $target = $path."/".basename($source);
- if(checkcore($target)){
- $errors = $T_lang['stick'][10];
- }else{
- $target = truepath($target);
- if(is_dir($source)){
- if($_POST['type']=="cover"){
- $errors = movepath($source,$target,false);
- }else{
- $errors = movepath($source,$target);
- }
- if($errors==""){
- $errors = $T_lang['stick'][11];
- }else{
- $errors = str_replace("--alert--",$errors,
- $T_lang['font'][0]);
- }
- }else{
- if(@copy($source,$target)){
- if(@unlink($source)){
- $errors = $T_lang['stick'][12];
- }else{
- $errors = str_replace("--source--",$source,
- $T_lang['stick'][13]);
- }
- }else{
- $errors = str_replace("--source--",$source,
- $T_lang['stick'][14]);
- }
- }
- }
- }
- }
- unset($_SESSION['readystick']);
- }else{
- $errors = $T_lang['stick'][15];
- }
- $content = $errors.$T_lang['confirm'][2];
- break;
- case "recycled"://清空回收站任务
- $title = $T_lang['title'][9];
- $errors=delpath($T_Recycled);
- if($errors==""){
- $errors = $T_lang['recycled'][0];
- }else{
- $errors = str_replace("--alert--",$errors,$T_lang['font'][0]);
- }
- $content = $errors.$T_lang['confirm'][1];
- echo "<script>parent.parent.left.webFXTreeHandler.selected.reload();</script>";
- break;
- case "attribute"://获得文件或文件夹的信息
- $title = $T_lang['title'][10];
- $basename = basename($path);
- $position = $path;
- if(is_dir($realpath)){
- $attribute = new StatFolder($realpath);
- $size = $attribute->GetTotalSize();
- $num = $attribute->GetFileNum();
- $typenum = $attribute->GetTypeNum();
- $foldernum = $attribute->GetFolderNum();
- $content = str_replace("--basename--",$basename,$T_lang['attribute'][0]);
- $content = str_replace("--position--",$position,$content);
- $content = str_replace("--size--",$size,$content);
- $content = str_replace("--num--",$num,$content);
- $content = str_replace("--typenum--",$typenum,$content);
- $content = str_replace("--foldernum--",$foldernum,$content);
- }else{
- $size = filesize($realpath);//大小
- $atime = date("Y-m-d H:i:s", fileatime($realpath));//修改时间
- $mtime = date("Y-m-d H:i:s", filemtime($realpath));//访问时间
- clearstatcache();
- $content = str_replace("--basename--",$basename,$T_lang['attribute'][1]);
- $content = str_replace("--position--",$position,$content);
- $content = str_replace("--size--",$size,$content);
- $content = str_replace("--atime--",$atime,$content);
- $content = str_replace("--mtime--",$mtime,$content);
- }
- break;
- case "upload"://上传文件
- $title = $T_lang['title'][11];
- $content = "";
- foreach($_FILES["file"]["error"] as $key => $value){
- if($_FILES["file"]["name"][$key]!=""){
- if($value==UPLOAD_ERR_OK){
- $filename = $_FILES["file"]["name"][$key];
- if(move_uploaded_file($_FILES["file"]["tmp_name"][$key],
- $T_tempdir."/".$filename))
- {
- if(file_exists($realpath."/".$filename)){
- $content.= str_replace("--filename--",$filename,
- $T_lang['upload'][0]);
- }else{
- if(copy($T_tempdir."/".$filename,$realpath."/".$filename)){
- @unlink($T_tempdir."/".$filename);
- $content .= str_replace("--filename--",$filename,
- $T_lang['upload'][1]);
- }else{
- $content .= str_replace("--filename--",$filename,
- $T_lang['upload'][2]);
- }
- }
- }else{
- $content .= str_replace("--filename--",$filename,
- $T_lang['upload'][2]);
- }
- }else{
- $content .= str_replace("--filename--",$filename,
- $T_lang['upload'][2]);
- }
- }
- }
- $content.= $T_lang['confirm'][2];
- break;
- case "rewrite"://编辑文件准备
- $title = $T_lang['title'][13]."[".$path."]";
- if(checkcore($path)){
- $content = $T_lang['rewrite'][0].$T_lang['confirm'][0];
- }else{
- if(in_array(fileext($path),$T_editext)){
- $txtfile = $T_task."?action=edit&path=".$_POST['path'];
- $editfile = str_replace("--txtfile--",$txtfile,$T_lang['rewrite'][1]);
- }else{
- $content = $T_lang['rewrite'][2].$T_lang['confirm'][0];
- }
- }
- break;
- case "savefile"://保存文件
- $txtdata = trim($_POST['txtdata']);
- if($txtdata!==""){
- if($T_Magic) $txtdata = stripslashes($txtdata);
- $txtdata = preg_replace("/[s]textarea/i","textarea",$txtdata);
- $txtdata = preg_replace("/[s]xml/i","xml",$txtdata);
- $fp = fopen($realpath, 'w');
- flock($fp,LOCK_EX);
- fwrite($fp,$txtdata);
- flock($fp,LOCK_UN);
- fclose($fp);
- }
- header("Location:{$T_task}?action=edit&path=".$_POST['path']);
- exit;
- break;
- default://未定义页面
- $title = $T_lang['title'][15];
- $content = $T_lang['undefined'][0].$T_lang['confirm'][0];
- break;
- }
- }elseif($_GET['action']=="edit"&&$_GET['path']){//编辑文件
- $path = urldecode($_GET['path']);
- $realpath = truepath($path);
- $datafile = "";
- if(is_file($realpath)&&!checkcore($path)){
- if(filesize($realpath)==0){
- $datafile = $T_lang['rewrite'][4];
- }else{
- $fp = fopen($realpath, 'r');
- flock($fp,LOCK_SH);
- $datafile = fread($fp,filesize($realpath));
- flock($fp,LOCK_UN);
- fclose($fp);
- $datafile = preg_replace("/textarea/i"," textarea",$datafile);
- $datafile = preg_replace("/<?xml/i","<? xml",$datafile);
- }
- }else{
- $datafile = str_replace("--filename--",$path,$T_lang['rewrite'][3]);
- }
- }
- if($window){
- if($content!=""){
- echo "<script type="text/javascript">parent.newwindow('".$title.
- "','".$content."');</script>";
- exit;
- }elseif($datafile!=""){
- require_once($T_edit);
- exit;
- }elseif($editfile!=""){
- echo "<script type="text/javascript">parent.editwindow('".$title.
- "','".$editfile."');</script>";
- exit;
- }
- }else{
- if($method){
- echo "<script type="text/javascript">".$method."</script>";
- }
- }
- ?>