<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=gbk">
<title>文件管理</title>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<link href="<?=base_url()?>csdj/admin/images/admin.css" type=text/css id="skincolor" rel="stylesheet" media="all" >
<SCRIPT type=text/javascript src="<?=base_url()?>csdj/admin/js/admin.js"></SCRIPT>
<SCRIPT type=text/javascript src="<?=base_url()?>csdj/admin/js/ajaxrequest.js"></SCRIPT>
<SCRIPT type=text/javascript src="<?=base_url()?>csdj/admin/js/showtitle.js"></SCRIPT>
</head>
<body style="margin:2px">
<table align="center"  width="100%"  border="1" cellspacing="0" cellpadding="5" bordercolor="#A2DAE7" style="border-collapse: collapse" id="myTable">
<tr><td class=title align="center" colspan=6>上传文件管理</td></tr><tr><td colspan=4>&nbsp;&nbsp;&nbsp;当前目录：<?=$path?>&nbsp;&nbsp;&nbsp;&nbsp;占用空间：<font color="#ff0000"><?=$this->CsdjSkins->formatsize(getDirSize(dirname($_SERVER['SCRIPT_FILENAME']).$path))?></font></td><td align="center" colspan=2><a href="<?=site_url('admin/files/index/')?>" title="返回主目录"><font color=0000ff>返回主目录</font></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="<?=$uppage?>" title="返回到上级目录"><font color=FF0000>↑上一目录 </font></a></td></tr>
<form method="post" Name="Form" action="<?=site_url('admin/files/delall')?>"><tr>
<td width="50" align="center">选中</td>
<td width="300" align="center">文件/文件夹名</td>
<td width="200" align="center">文件类型</td>
<td width="120" align="center">文件大小</td>
<td width="170" align="center">最后修改时间</td>
<td width="110" align="center">可用操作</td>
</tr>
<?php
foreach ($show as $value) {
   if(is_dir('.'.$path.$value['name'])){
       
       echo '<tr id="tr_'.$value['name'].'"><td align="center"><input type="checkbox" name="dirs[]" value=".'.$path.$value['name'].'"></td><td><img src="'.base_url().'csdj/admin/images/folder.gif" align="absmiddle"> <a href="'.$url.$value['name'].'/">'.$value['name'].'</a></td><td align="center">'.getdirType($value['name']).'</td><td align="center">'.$this->CsdjSkins->formatsize(getDirSize(dirname($_SERVER['SCRIPT_FILENAME']).$path.$value['name'])).'</td><td align="center" nowrap>'.date('Y-m-d H:i:s',$value['date']).'</td><td align="center"><a href="'.$url.$value['name'].'/">打开</a></td></tr>';
   }
}
foreach ($show as $value) {
   if(!is_dir('.'.$path.$value['name'])){
       if(getpicType($value['name'])=='JPEG 图像' || getpicType($value['name'])=='GIF 图像' || getpicType($value['name'])=='PNG 图像'){
             $aa=getimagesize(".".$path.$value['name']);
             echo '<tr id="tr_'.$value['name'].'"><td align="center"><input type="checkbox" name="files[]" value=".'.$path.$value['name'].'"></td><td><a Cstip="<DIV align=\'center\'>图片尺寸：'.$aa[0].'×'.$aa[1].'</DIV><DIV align=\'center\'><img src=\''.$path.$value['name'].'\' onload=\'ResizeImages(this,200,200);\'></DIV>" href="'.$path.$value['name'].'" target="_blank">'.$value['name'].'</a></td><td align="center">'.getpicType($value['name']).'</td><td align="center">'.$this->CsdjSkins->formatsize($value['size']).'</td><td align="center" nowrap>'.date('Y-m-d H:i:s',$value['date']).'</td><td align="center"><a href="'.$path.$value['name'].'" target="_blank">浏览</a> | <a href="javascript:void(0);" onclick="javascript:if (confirm(\'确定要删除选择的文件么？\n此操作不可以恢复！\')) delUserFiles(\''.$path.$value['name'].'\');else return;">删除</a></td></tr>';
       }else{
             echo '<tr id="tr_'.$value['name'].'"><td align="center"><input type="checkbox" name="files[]" value=".'.$path.$value['name'].'"></td><td><a title="'.getpicType($value['name']).'" href="'.$path.$value['name'].'" target="_blank">'.$value['name'].'</a></td><td align="center">'.getpicType($value['name']).'</td><td align="center">'.$this->CsdjSkins->formatsize($value['size']).'</td><td align="center" nowrap>'.date('Y-m-d H:i:s',$value['date']).'</td><td align="center"><a href="'.$path.$value['name'].'" target="_blank">浏览</a> | <a href="javascript:void(0);" onclick="javascript:if (confirm(\'确定要删除选择的文件么？\n此操作不可以恢复！\')) delUserFiles(\''.$path.$value['name'].'\');else return;">删除</a></td></tr>';
       }
   }
}
?>
<tr><td colspan='6'><span style="float:right;">&nbsp;&nbsp;&nbsp;&nbsp;
<a href="<?=$url?>&page=1">首 页</a>&nbsp;
<?php
   if($page>1){
        echo '<a href="'.$url.'&page='.($page-1).'">上一页 </a>&nbsp;';
   }else{
        echo '<a href="'.$url.'&page=1">上一页 </a>&nbsp;';
   }

   for ($i=$page-2;$i<=$page+2;$i++){
        if ($i<=0){
               continue;
        }
        if ($i>$pagejs){
            break;
        }
        if ($i==$page){
              $curpage=" style='color:#f00;'";
        }else{
              $curpage="";
        }
        echo "<a href='?page=".$i.$url."'$curpage>$i</a>&nbsp;";
    }

    if ($page==$pagejs || $pagejs==0){
         echo '<a href="'.$url.'&page='.$pagejs.'">下一页</a>&nbsp;';
    }else{
         echo '<a href="'.$url.'&page='.($page+1).'">下一页</a>&nbsp;';
    }
    echo '<a href="'.$url.'&page='.$pagejs.'">尾 页</a>&nbsp;';
?>
</span>选中<input type="checkbox" name="chkall" onclick="CheckAll(this.form)" value="ON">
	&nbsp;&nbsp;<input type="submit" name="Submit" class="italk-st3" value="批量删除所选" onClick="return confirm('您确定删除吗?')">
</span>
</td></tr>
</form></table>
</BODY>
</HTML>
<?php
function getpicType($type){
	if(stristr($type,'.jpg')){
		return "JPEG 图像";
	}elseif(stristr($type,'.gif')){
		return "GIF 图像";
	}elseif(stristr($type,'.png')){
		return "PNG 图像";
	}elseif(stristr($type,'.mp3')){
		return "MP3 文件";
	}elseif(stristr($type,'.mp4')){
		return "MP4 文件";
	}elseif(stristr($type,'.flv')){
		return "Flv 文件";
	}elseif(stristr($type,'.avi')){
		return "Avi 文件";
	}elseif(stristr($type,'.wmv')){
		return "Wmv 文件";
	}elseif(stristr($type,'.asf')){
		return "Asf 文件";
	}elseif(stristr($type,'.m4a')){
		return "M4A 文件";
	}elseif(stristr($type,'.sql')){
		return "SQL 文件";
	}elseif(stristr($type,'.zip')){
		return "ZIP 文件";
	}elseif(stristr($type,'.html')){
		return "HTML 文件";
        }else{
		return "其他文件";
	}
}
function getdirType($type){
	if($type=='vod'){
		return "视频图片目录";
	}elseif($type=='dance'){
		return "歌曲文件目录";
	}elseif($type=='video'){
		return "视频文件目录";
	}elseif($type=='backup'){
		return "备份数据目录";
	}elseif($type=='editor'){
		return "编辑器数据";
	}elseif($type=='js'){
		return "自定义JS目录";
	}elseif($type=='logo'){
		return "会员头像目录";
	}elseif($type=='news'){
		return "文章图片目录";
	}elseif($type=='pic'){
		return "会员图片目录";
	}elseif($type=='singer'){
		return "歌手图片目录";
	}elseif($type=='topic'){
		return "专集图片目录";
	}elseif($type=='other'){
		return "其他附件目录";
	}elseif($type=='image'){
		return "图片目录";
	}elseif($type=='media'){
		return "音乐目录";
	}elseif($type=='flash'){
		return "flash目录";
        }else{
		return "文件夹";
	}
}
function getDirSize($dir){ 
        $handle = opendir($dir);
        $sizeResult=0;
        while (false!==($FolderOrFile = readdir($handle)))
        { 
            if($FolderOrFile != "." && $FolderOrFile != "..") 
            { 
                if(is_dir("$dir/$FolderOrFile"))
                { 
                    $sizeResult += getDirSize("$dir/$FolderOrFile"); 
                }
                else
                { 
                    $sizeResult += filesize("$dir/$FolderOrFile"); 
                }
            }    
        }
        closedir($handle);
        return $sizeResult;
}
?>

