2018-03-23 14:20:16 +08:00
|
|
|
|
<?php
|
|
|
|
|
/* //分享地址支持下载(a=down),预览(a=view)和流
|
|
|
|
|
* @copyright Leyun internet Technology(Shanghai)Co.,Ltd
|
|
|
|
|
* @license http://www.dzzoffice.com/licenses/license.txt
|
|
|
|
|
* @package DzzOffice
|
|
|
|
|
* @link http://www.dzzoffice.com
|
|
|
|
|
* @author zyx(zyx@dzz.cc)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
define('APPTYPEID', 200);
|
2024-09-30 12:12:15 +08:00
|
|
|
|
define('DZZSCRIPT', 'index.php');
|
2018-03-23 14:20:16 +08:00
|
|
|
|
require './core/coreBase.php';
|
|
|
|
|
$dzz = C::app();
|
|
|
|
|
$dzz->init();
|
|
|
|
|
|
|
|
|
|
if(!$path=dzzdecode(trim($_GET['s']))){
|
|
|
|
|
exit('Access Denied');
|
|
|
|
|
}
|
|
|
|
|
if($_GET['a']=='down'){
|
|
|
|
|
IO::download($path,$_GET['filename']);
|
|
|
|
|
exit();
|
|
|
|
|
}elseif($_GET['a']=='view'){
|
2018-05-26 11:10:27 +08:00
|
|
|
|
$vid = isset($_GET['vid']) ? intval($_GET['vid']):0;
|
|
|
|
|
if($vid){
|
|
|
|
|
if(!$icoarr = C::t('resources_version')->fetch_version_by_rid_vid($path,$vid)){
|
|
|
|
|
showmessage(lang('attachment_nonexistence'));
|
|
|
|
|
}else{
|
|
|
|
|
$path = dzzdecode($icoarr['icoid']);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if(!$icoarr=IO::getMeta($path)){
|
|
|
|
|
showmessage(lang('attachment_nonexistence'));
|
|
|
|
|
}
|
|
|
|
|
$icoarr['icoid'] = $_GET['s'];
|
|
|
|
|
}
|
2024-10-24 09:04:51 +08:00
|
|
|
|
if ($icoarr['type'] == 'link') {
|
|
|
|
|
@header('Location: '.$icoarr['url']);
|
|
|
|
|
exit();
|
|
|
|
|
}
|
2018-05-26 11:10:27 +08:00
|
|
|
|
$imageexts=array('jpg','jpeg','png','gif'); //图片使用;
|
|
|
|
|
$filename=$icoarr['name'];//rtrim($_GET['n'],'.dzz');
|
|
|
|
|
$ext=$icoarr['ext'];//strtolower(substr(strrchr($filename, '.'), 1, 10));
|
|
|
|
|
if(!$ext) $ext=preg_replace("/\?.+/i",'',strtolower(substr(strrchr(rtrim($url,'.dzz'), '.'), 1, 10)));
|
2018-03-23 14:20:16 +08:00
|
|
|
|
if(in_array($ext,$imageexts)){
|
2018-05-26 11:10:27 +08:00
|
|
|
|
$url=$_G['siteurl'].'index.php?mod=io&op=thumbnail&original=1&path='.$icoarr['icoid'];
|
2018-03-23 14:20:16 +08:00
|
|
|
|
@header("Location: $url");
|
|
|
|
|
exit();
|
|
|
|
|
}
|
2018-05-26 11:10:27 +08:00
|
|
|
|
$extall=C::t('app_open')->fetch_all_ext();
|
|
|
|
|
$exts=array();
|
|
|
|
|
$bzarr=explode(':',$icoarr['rbz']?$icoarr['rbz']:$icoarr['bz']);
|
|
|
|
|
$bz=($bzarr[0]) ? $bzarr[0]:'dzz';
|
|
|
|
|
foreach($extall as $value){
|
|
|
|
|
if(!isset($exts[$value['ext']]) || $value['isdefault']) $exts[$value['ext']]=$value;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-23 14:20:16 +08:00
|
|
|
|
if(isset($exts[$bz.':'.$ext])){
|
|
|
|
|
$data=$exts[$bz.':'.$ext];
|
|
|
|
|
}elseif($exts[$ext]){
|
|
|
|
|
$data=$exts[$ext];
|
|
|
|
|
}elseif($exts[$icoarr['type']]){
|
|
|
|
|
$data=$exts[$icoarr['type']];
|
|
|
|
|
}else $data=array();
|
|
|
|
|
if($data){
|
|
|
|
|
$url=$data['url'];
|
|
|
|
|
if(strpos($url,'dzzjs:')!==false){//dzzjs形式时
|
|
|
|
|
@header("Location: $icoarr[url]");
|
|
|
|
|
exit();
|
|
|
|
|
}else{
|
|
|
|
|
//替换参数
|
|
|
|
|
$url=preg_replace_callback("/{(\w+)}/i", function($matches) use($icoarr){
|
|
|
|
|
$key=$matches[1];
|
|
|
|
|
if($key=='path'){
|
2018-05-26 11:10:27 +08:00
|
|
|
|
return $icoarr['icoid'];
|
2018-03-23 14:20:16 +08:00
|
|
|
|
}else if($key=='icoid'){
|
|
|
|
|
return 'preview_'.random(5);
|
|
|
|
|
}else{
|
|
|
|
|
return urlencode($icoarr[$key]);
|
|
|
|
|
}
|
|
|
|
|
}, $url);
|
|
|
|
|
//添加path参数;
|
|
|
|
|
if(strpos($url,'?')!==false && strpos($url,'path=')===false){
|
2024-09-29 21:59:54 +08:00
|
|
|
|
$path = $path ? $path : $_GET['s'];
|
|
|
|
|
$url.='&path=' . dzzencode('preview_' . $path);
|
2018-03-23 14:20:16 +08:00
|
|
|
|
}
|
2018-05-26 11:10:27 +08:00
|
|
|
|
$url = $_G['siteurl'].$url;
|
2018-03-23 14:20:16 +08:00
|
|
|
|
@header("Location: $url");
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else{//没有可用的打开方式,转入下载;
|
2024-10-09 17:19:00 +08:00
|
|
|
|
$path=dzzencode('preview_' . $path);
|
2018-03-23 14:20:16 +08:00
|
|
|
|
IO::download($path);
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//获取文件流地址
|
|
|
|
|
if(!$url=(IO::getStream($path))){
|
|
|
|
|
exit(lang('failed_get_file'));
|
|
|
|
|
}
|
|
|
|
|
if(is_array($url)) exit($url['error']);
|
|
|
|
|
|
|
|
|
|
//如果是阻止运行的后缀名时,直接调用;
|
|
|
|
|
if($ext && in_array($ext,$_G['setting']['unRunExts'])){
|
|
|
|
|
$mime='text/plain';
|
|
|
|
|
}else{
|
|
|
|
|
$mime=dzz_mime::get_type($ext);
|
|
|
|
|
}
|
|
|
|
|
@set_time_limit(0);
|
|
|
|
|
@header('Content-Type: '.$mime);
|
|
|
|
|
@ob_end_clean();
|
|
|
|
|
@readfile($url);
|
|
|
|
|
@flush();
|
|
|
|
|
@ob_flush();
|
|
|
|
|
exit();
|