function geturlipstr($ext,$filename){//获得预览代码,本地模式
if(file_exists('./' . C('mtceo_attach_path')."docswf/data/".$filename.".php")){
$ipstr=F($filename,'','./' . C('mtceo_attach_path').'docswf/data/');
}else{
$urlarr=array();
$urlarr[0]=$ext;
$urlarr[1]=$filename;
$urlarr[2]=C('mtceo_site_url');
$urlpost=join('|',$urlarr);
$data=file_get_contents('http://www.mtceo.net/index.php?m=common&a=getipstr&u='.$urlpost);
$ipstrarr=json_decode($data,true);
if($ipstrarr['status']==0){
$ipstr="<div class=\"stl_01 mod reader-page complex reader-page-\"><div style=\"height:300px;font-size:30px;color:red;padding-top:150px;font-weight:bolder;text-align:center;\">".$ipstrarr['info']."</div></div>";
}else{
$ipstr=$ipstrarr['info'];
F($filename,$ipstr,'./' . C('mtceo_attach_path').'docswf/data/');//缓存文件
}
}
return $ipstr;
}
function getipstr($ext,$filename){//获得预览代码,本地模式
$extarr=array('xls','xlsx','ppt','pptx','dps','et');
if(in_array($ext, $extarr)){
$pngname='./' . C('mtceo_attach_path').'docswf/data/'.$filename.'/01.png';
$filepath='./' . C('mtceo_attach_path').'docswf/data/'.$filename.'/';
if(!file_exists('./' . C('mtceo_attach_path')."docswf/data/".$filename.".php")){
if(file_exists($pngname)){//如果该文档存在,则取出字符串
$opendir=opendir($filepath);
$ipstr="<!--[if IE]> <html class='ie'> <![endif]--><link rel='stylesheet' type='text/css' href='./public/images/docstyle.css' />";
while ($file=readdir($opendir)){
if(is_file($filepath.$file)){
if(strpos($filepath.$file, '.png')){
$ipstr.="<div class=\"stl_01 mod reader-page complex reader-page-\"><img src='".$filepath.$file."' /></div>";
}
}
}//经过循环已经得到$ipstr代码了
F($filename,$ipstr,'./' . C('mtceo_attach_path').'docswf/data/');//缓存文件
}
else{
//如果没有该文件则显示未生成预览
$ipstr="<div class=\"stl_01 mod reader-page complex reader-page-\"><div style=\"height:300px;font-size:30px;color:red;padding-top:150px;font-weight:bolder;text-align:center;\">该文档尚未生成预览</div></div>";
}
}//如果不存在缓存文件的判断结束
else{
$ipstr=F($filename,'','./' . C('mtceo_attach_path').'docswf/data/');
}//存在缓存文件的判断结束
}//以下将为生成html预览的部分
else{
$htmlname='./' . C('mtceo_attach_path').'docswf/data/'.$filename.'.html';
if(!file_exists('./' . C('mtceo_attach_path')."docswf/data/".$filename.".php")){
if(file_exists($htmlname)){//如果该文档存在,则取出字符串
$ipstr=file_get_contents(HOST.__ROOT__ . '/' . C('mtceo_attach_path').'docswf/data/'.$filename.'.html');
$ipstr=str_replace("<!DOCTYPE html>", '', $ipstr);
$ipstr=str_replace("<html>", '', $ipstr);
$ipstr=str_replace("</html>", '', $ipstr);
$ipstr=str_replace("<meta charset=\"utf-8\" />", '', $ipstr);
$ipstr=str_replace("<title>", '', $ipstr);
$ipstr=str_replace("</title>", '', $ipstr);
$ipstr=str_replace("<head>", '', $ipstr);
$ipstr=str_replace("</head>", '', $ipstr);
$ipstr=str_replace("<body>", '', $ipstr);
$ipstr=str_replace("</body>", '', $ipstr);
$ipstr=str_replace($filename.'_files', './' . C('mtceo_attach_path').'docswf/data/'.$filename.'_files', $ipstr);
$ipstr=str_replace('stl_01', 'stl_01 mod reader-page complex reader-page-', $ipstr);
//得到ipstr
F($filename,$ipstr,'./' . C('mtceo_attach_path').'docswf/data/');//缓存文件
}
else{
//如果没有该文件则显示未生成预览
$ipstr="<div class=\"stl_01 mod reader-page complex reader-page-\"><div style=\"height:300px;font-size:30px;color:red;padding-top:150px;font-weight:bolder;text-align:center;\">该文档尚未生成预览</div></div>";
}
}//如果不存在缓存文件的判断结束
else{
$ipstr=F($filename,'','./' . C('mtceo_attach_path').'docswf/data/');
}//存在缓存文件的判断结束
}
return $ipstr;
}