您的位置:首页 > 编程语言 > PHP开发

检测模板的完整性 Monxin专用(PHP代码函数)

2015-04-09 10:54 537 查看
//检测模板的完整性 Monxin专用(PHP代码函数)
//本代码基于Monxin 运行
//代码来源:Monxin ./config/functions.php

function check_template_files($path,$template,$program=''){
//echo $template.','.$program;
$files=array('icon.png','info.txt');
$dirs=array('page_icon','pc','phone');
$dir=new Dir();
if(is_file($path)){
$path=extract_zip($path,false);
$del=true;
}else{$del=false;}
if(is_dir($path.'/'.$template)){
$lack='';
if(is_file($path.'/'.$template.'/info.txt') && $program!=''){
//echo 'xx';
$template_info=get_txt_info($path.'/'.$template.'/info.txt');

if($template_info['for']!=$program){

$lack.='The template and the program does not match<br />';
}
}
$r=scandir($path.'/'.$template);
$dir_list=array();
foreach($r as $v){
$dir_list[$v]=$v;
}

foreach($files as $v){
if(!isset($dir_list[$v])){$lack.='File: '.$v.'<br />';}
}
foreach($dirs as $v){
if(!isset($dir_list[$v])){$lack.='Dir: '.$v.'<br />';}
}

$_POST['files_size']=$dir->get_dir_size($path.'/'.$template.'/pc/img/');
if(is_file($path.'/'.$template.'/pc/img/Thumbs.db')){$_POST['files_size']-=filesize($path.'/'.$template.'/pc/img/Thumbs.db'); }
$_POST['files_list']=$dir->show_dir($path.'/'.$template.'/pc/img/',array('jpg','jpeg','png','gif'),false,false);
$_POST['files_list']=@implode('|',$_POST['files_list']);
$_POST['files_list']=str_replace($path.'/'.$template.'/pc/img/','',$_POST['files_list']);
$_POST['get_txt_info']=get_txt_info($path.'/'.$template.'/info.txt');

}else{
return 'Dir: '.$template.'<br />';;
}
if($del && is_dir($path)){
$dir->del_dir($path);
}
return $lack;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: