<!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>
<?php
   if(empty($dir)){
        $path=".".$path;
   }else{
        $path=$dir.$path;
   }
   $path=str_replace("\\","/",$path);
   $path=str_replace("//","/",$path);
?>
<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($path))?></font></td><td align="center" colspan=2><a href="<?=$uppage?>" title="返回到上级目录"><font color=FF0000>↑返回上一目录 </font></a></td></tr>
<form method="post" Name="Form" action="<?=site_url('admin/saomiao/ruku')?>?dir=<?=$dirs?>&sid=<?=$sid?>&hz=<?=$hz?>"><tr>
<td width="50" align="center">选中</td>
<td width="400" align="center">文件/文件夹名</td>
<td width="100" 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">文件夹</td><td align="center">'.$this->CsdjSkins->formatsize(getDirSize($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> | <a title="入库当前目录所有歌曲" href="'.site_url('admin/saomiao/ruku/').'?dir='.$dirs.'&hz='.$hz.'&sid='.$sid.'&dirs='.$path.$value['name'].'/">入库</a></td></tr>';
   }
}
foreach ($show as $value) {
   if(!is_dir($path.$value['name'])){
       $sys=pathinfo($value['name']);//获取文件名后缀
       if(is_int(strpos($hz,$sys['extension'])) !== false){  //只显示要扫描的文件
             echo '<tr id="tr_'.$value['name'].'"><td align="center"><input type="checkbox" name="files[]" value="'.$path.$value['name'].'"></td><td>'.$value['name'].'</td><td align="center">'.getpicType($value['server_path']).'</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 title="入库这首歌曲" href="'.site_url('admin/saomiao/ruku/').'?dir='.$dirs.'&sid='.$sid.'&files='.$path.$value['name'].'">==入库==</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='".$url."&page=".$i."'$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="批量入库所选">
</span>
</td></tr>
</form></table>
</BODY>
</HTML>
<?php
function getpicType($type){
	if(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 文件";
        }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;
}
?>

