path 兼容preview_前缀

This commit is contained in:
zyx0814 2024-09-29 17:56:34 +08:00
parent c6ecf813f9
commit 894d7edf5b
2 changed files with 20 additions and 4 deletions

View File

@ -127,6 +127,9 @@ class io_dzz extends io_api
public function getStream($path, $fop = '')
{
global $_G;//123
if (strpos($path, 'preview_') === 0) {
$path = preg_replace('/^preview_/', '', $path);
}
if (strpos($path, 'attach::') === 0) {
$attach = C::t('attachment')->fetch(intval(str_replace('attach::', '', $path)));
Hook::listen('io_dzz_getstream_attach',$attach);//挂载点
@ -548,6 +551,10 @@ class io_dzz extends io_api
//获取icosdata
public function getMeta($icoid)
{
if (strpos($icoid, 'preview_') === 0) {
$icoid = preg_replace('/^preview_/', '', $icoid);
$preview = true;
}
if (strpos($icoid, 'dzz::') === 0) {
$attachment = preg_replace('/^dzz::/i', '', $icoid);
$name = array_pop(explode('/', $icoid));
@ -611,9 +618,9 @@ class io_dzz extends io_api
if (!$rid = DB::result_first("select rid from %t where pfid = %d and name = %s", array('resources', $pfid, $filename))) {
return false;
}
return C::t('resources')->fetch_by_rid($rid);
return C::t('resources')->fetch_by_rid($rid,'',$preview);
} elseif (preg_match('/\w{32}/i', $icoid)) {
return C::t('resources')->fetch_by_rid($icoid);
return C::t('resources')->fetch_by_rid($icoid,'',$preview);
} else {
return false;//C::t('resources')->fetch_by_icoid($icoid);
}
@ -729,6 +736,9 @@ class io_dzz extends io_api
}
@set_time_limit(0);
$attachexists = FALSE;
if (strpos($path, 'preview_') === 0) {
$path = preg_replace('/^preview_/', '', $path);
}
if (strpos($path, 'attach::') === 0) {
$attachment = C::t('attachment')->fetch(intval(str_replace('attach::', '', $path)));
$attachment['name'] = $filename ? $filename : $attachment['filename'];
@ -844,6 +854,9 @@ class io_dzz extends io_api
{
global $_G;
if (strpos($path, 'preview_') === 0) {
$path = preg_replace('/^preview_/', '', $path);
}
if (strpos($path, 'dzz::') === 0) {
if (strpos($path, './') !== false) return false;
@unlink($_G['setting']['attachdir'] . preg_replace('/^dzz::/i', '', $path));
@ -2896,7 +2909,9 @@ class io_dzz extends io_api
//判断大小
//判断空间大小
$filename = self::name_filter($filename);
if (strpos($path, 'preview_') === 0) {
$path = preg_replace('/^preview_/', '', $path);
}
if (strpos($path, 'dzz::') === false && strpos($path, 'TMP::') === false) {
$gid = DB::result_first("select gid from %t where fid=%d", array('folder', $path));
if (!SpaceSize($size, $gid)) {

View File

@ -375,7 +375,7 @@ class table_resources extends dzz_table
return $resourcedata;
}
public function fetch_by_rid($rid, $force_from_db = false)
public function fetch_by_rid($rid, $force_from_db = false,$preview = false)
{ //返回一条数据同时加载资源表数据
global $_G;
$cachekey = 'resourcesdata_' . $rid;
@ -425,6 +425,7 @@ class table_resources extends dzz_table
$data['relpath'] = dirname(preg_replace('/dzz:(.+?):/', '', $data['relativepath'])) . '/';
$data['path'] = $data['rid'];
$data['bz'] = '';
$data['preview'] = $preview;
$data['collect'] = C::t('resources_collect')->fetch_by_rid($rid);
if ($data['remote'] > 1) $data['rbz'] = io_remote::getBzByRemoteid($data['remote']);