<!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="950" border="1" cellspacing="0" cellpadding="5" bordercolor="#C4DFF4" style="border-collapse: collapse" id="myTable">
<tr><td class=title align="center" colspan=6>模板文件管理 ｜ <a title="新增模板" href="<?=site_url('admin/skins/add/')?>">新增模板</a></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/skins/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/skins/delall')?>"><tr>
<td width="50" align="center">选中</td>
<td width="280" align="center">文件/文件夹名</td>
<td width="180" align="center">文件类型</td>
<td width="120" align="center">文件大小</td>
<td width="170" align="center">最后修改时间</td>
<td width="150" align="center">可用操作</td>
</tr>
<?php
if(!$show) echo "<tr><td colspan='6' align='center'>当前没有模板文件!</td></tr>";
foreach ($show as $value) {
   if(is_dir('.'.$path.$value['name'])){
       if($path=="/skins/" && $value['name']=='index'){
             $link=$url.Skins_dir;
       }elseif($path=="/skins/" && $value['name']=='home'){
             $link=$url.Skins_home_dir;
       }elseif($path=="/skins/" && $value['name']=='user'){
             $link=$url.Skins_user_dir;
       }else{
             $link=$url.$value['name']."/";
       }
       echo '<tr id="tr_'.$value['name'].'"><td align="center"></td><td><img src="'.base_url().'csdj/admin/images/folder.gif" align="absmiddle"> <a href="'.$link.'">'.$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="'.$link.'">打开</a></td></tr>';
   }
}
foreach ($show as $value) {
   if(!is_dir('.'.$path.$value['name'])){
       if(date("Y-m-d",strtotime(date('Y-m-d H:i:s',$value['date'])))==date('Y-m-d')){
            $times="<font color=red>".date('Y-m-d H:i:s',$value['date'])."</font>";
       }else{
            $times=date('Y-m-d H:i:s',$value['date']);
       }
       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>'.$times.'</td><td align="center"><a href="'.$path.$value['name'].'" target="_blank">浏览</a> | <a href="'.site_url('admin/skins/del/').'?path='.$path.$value['name'].'" onClick="return confirm(\'确定要删除选择的文件么？\n此操作不可以恢复！\');">删除</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="'.site_url('admin/skins/edit/').'?path='.$path.$value['name'].'&name='.$value['name'].'">'.$value['name'].'</a></td><td align="center">'.getpicType($value['name']).'</td><td align="center">'.$this->CsdjSkins->formatsize($value['size']).'</td><td align="center" nowrap>'.$times.'</td><td align="center"><a href="'.site_url('admin/skins/edit/').'?path='.$path.$value['name'].'&name='.$value['name'].'">编辑</a> |<a href="'.site_url('admin/skins/copy/').'?path='.$path.$value['name'].'">复制</a> | <a href="'.site_url('admin/skins/del/').'?path='.$path.$value['name'].'" onClick="return confirm(\'确定要删除选择的文件么？\n此操作不可以恢复！\');">删除</a></td></tr>';
       }
   }
}
if($path!="/skins/" && $show){
?>
<tr><td colspan='6'>选中<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>
<?php } ?>
</form></table>
</BODY>
</HTML>
<?php
function getpicType($filename){
	switch(strtolower($filename)){
		case "home-head.html":
			$getTemplateType="会员主页顶部";
			break;
		case "home-bottom.html":
			$getTemplateType="会员主页底部";
			break;
		case 'home-index.html':
			$getTemplateType="会员主页";
			break;
		case "user-head.html":
			$getTemplateType="会员中心顶部";
			break;
		case "user-bottom.html":
			$getTemplateType="会员中心底部";
			break;
		case 'user-index.html':
			$getTemplateType="会员中心主页";
			break;
		case 'cs-index.html':
			$getTemplateType="网站首页";
			break;
		case 'cs-404.html':
			$getTemplateType="网站404";
			break;
		case "cs-head.html":
			$getTemplateType="网站顶部";
			break;
		case "cs-bottom.html":
			$getTemplateType="网站底部";
			break;
		case "cs-ding.html":
			$getTemplateType="顶踩模版";
			break;
		case "dance-index.html":
			$getTemplateType="音乐主页";
			break;
		case "news-index.html":
			$getTemplateType="文章主页";
			break;
		case "singer-index.html":
			$getTemplateType="歌手主页";
			break;
		case "singer-list.html":
			$getTemplateType="歌手分类";
		case "singer-show.html":
			$getTemplateType="歌手内容";
			break;
		case "vod-index.html":
			$getTemplateType="视频主页";
			break;
		case "vod-list.html":
			$getTemplateType="视频列表";
			break;
		case "vod-show.html":
			$getTemplateType="视频内容";
			break;
		case "vod-play.html":
			$getTemplateType="视频播放";
			break;
		case "so-dance-key.html":
			$getTemplateType="歌曲搜索";
			break;
		case "so-singer-key.html":
			$getTemplateType="歌手搜索";
			break;
		case "so-singer-tags.html":
			$getTemplateType="歌手标签";
			break;
		case "so-dance-tags.html":
			$getTemplateType="歌曲标签";
			break;
		case "so-topic-key.html":
			$getTemplateType="专集搜索";
			break;
		case "so-topic-tags.html":
			$getTemplateType="专集标签";
			break;
		case "so-vod-key.html":
			$getTemplateType="视频搜索";
			break;
		case "so-vod-tags.html":
			$getTemplateType="视频标签";
			break;
		case "so-news-key.html":
			$getTemplateType="文章搜索";
			break;
		case "topic-dance.html":
			$getTemplateType="音乐专集列表";
			break;
		case "topic-news-show.html":
			$getTemplateType="文章专题内容";
			break;
		case "topic-dance-show.html":
			$getTemplateType="音乐专集内容";
			break;
		case "news-list.html":
			$getTemplateType="文章列表";
			break;
		case "dance-list.html":
			$getTemplateType="歌曲列表";
			break;
		case "news-show.html":
			$getTemplateType="文章内容";
			break;
		case "dance-play.html":
			$getTemplateType="歌曲播放";
			break;
		case "dance-sp-play.html":
			$getTemplateType="视频播放";
			break;
		case "cs-gbook.html":
			$getTemplateType="留言模板";
			break;
		case "cs-ulogin.html":
			$getTemplateType="会员登陆";
			break;	
		case "cs-uinfo.html":
			$getTemplateType="会员信息";
			break;	
		Case "dance-down.html";
			$getTemplateType="下载页面";
			break;	
		Case "dance-sp-list.html";
			$getTemplateType="视频栏目";
			break;	
		Case "dance-playsong.html";
			$getTemplateType="连播页面";
			break;	
		Case "down-list.html";
			$getTemplateType="下载列表";
			break;	
		Case "fans-list.html";
			$getTemplateType="粉丝列表";
			break;	
		Case "fav-list.html";
			$getTemplateType="收藏列表";
			break;	
		Case "feed-list.html";
			$getTemplateType="动态列表";
			break;	
		Case "friend-list.html";
			$getTemplateType="好友列表";
			break;	
		Case "funco-list.html";
			$getTemplateType="访客列表";
			break;	
		Case "gbook-add.html";
			$getTemplateType="留言框";
			break;	
		Case "gbook-list.html";
			$getTemplateType="留言列表";
			break;	
		Case "pic-show.html";
			$getTemplateType="图片详细页面";
			break;	
		Case "pic-list.html";
			$getTemplateType="图片列表";
			break;	
		Case "blog-list.html";
			$getTemplateType="说说列表";
			break;	
		Case "blog-list.html";
			$getTemplateType="说说列表";
			break;	
		Case "dance-add.html";
			$getTemplateType="上传歌曲";
			break;	
		Case "edit-index.html";
			$getTemplateType="资料修改";
			break;	
		Case "edit-logo.html";
			$getTemplateType="头像修改";
			break;	
		Case "edit-pass.html";
			$getTemplateType="密码修改";
			break;	
		Case "edit-web.html";
			$getTemplateType="主页相关修改";
			break;	
		Case "feed-ajax.html";
			$getTemplateType="动态AJAX页面";
			break;	
		Case "msg-add.html";
			$getTemplateType="发送消息";
			break;	
		Case "msg-list.html";
			$getTemplateType="消息列表";
			break;	
		Case "msg-show.html";
			$getTemplateType="消息内容";
			break;	
		Case "news-add.html";
			$getTemplateType="新增文章";
			break;	
		Case "pay-index.html";
			$getTemplateType="在线充值";
			break;	
		Case "pay-list.html";
			$getTemplateType="充值记录";
			break;	
		Case "pic-add.html";
			$getTemplateType="上传图片";
			break;	
		Case "pic-list-all.html";
			$getTemplateType="大家的相片";
			break;	
		Case "pic-list-my.html";
			$getTemplateType="我的相片";
			break;	
		Case "topic-add.html";
			$getTemplateType="专集制作";
			break;	
		Case "topic-list.html";
			$getTemplateType="专集列表";
			break;	
		Case "user-login.html";
			$getTemplateType="会员登入";
			break;
		Case "user-pass.html";
			$getTemplateType="密码找回";
			break;	
		Case "user-passto.html";
			$getTemplateType="找回新密码";
			break;	
		Case "user-reg.html";
			$getTemplateType="会员注册";
			break;	
		Case "user-space.html";
			$getTemplateType="会员中心";
			break;	
		Case "vip-index.html";
			$getTemplateType="升级VIP";
			break;	
		Case "vod-add.html";
			$getTemplateType="发布视频";
			break;	
		Case "user-denglu.html";
			$getTemplateType="第三方登入";
			break;	
		Case "cs-pl.html";
			$getTemplateType="评论模板";
			break;
		Case "so-dance-zm.html";
			$getTemplateType="歌曲字母搜索";
			break;	
		Case "so-vod-zm.html";
			$getTemplateType="视频字母搜索";
			break;
		Case "so-singer-zm.html";
			$getTemplateType="歌手字母搜索";
			break;
		Case "so-topic-tags.html";
			$getTemplateType="专集Tags搜索";
			break;		
		Case "cs-wap.html";
			$getTemplateType="PC手机模板";
			break;
		Case "home-ulogin.html";
			$getTemplateType="会员主页登陆前";
			break;		
		Case "home-uinfo.html";
			$getTemplateType="会员主页登陆后";
			break;
		default:
			if(stristr($filename,'.gif') or stristr($filename,'.jpg') or stristr($filename,'.png')){
				$getTemplateType="图片文件";
			}elseif(stristr($filename,'.css')){
				 $getTemplateType="样式文件";
			}elseif(stristr($filename,'.js')){
				$getTemplateType="脚本文件";
			}elseif(stristr($filename,'-复制.html')){
				 $getTemplateType="备份文件";
			}else{
				$getTemplateType="自定义文件";
			}
	}
	return $getTemplateType;
}
function getdirType($type){
	if($type=='index'){
		return "网站主模板目录";
	}elseif($type=='home'){
		return "会员主页模板目录";
	}elseif($type=='user'){
		return "会员中心模板目录";
	}elseif($type=='js'){
		return "JS文件目录";
	}elseif($type=='css'){
		return "CSS文件目录";
	}elseif($type=='images'){
		return "图片文件目录";
        }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;
}
?>

