修复几个问题:
1:默认存储位置切换无效 2:删除文件提示失败 3:云存储文件预览地址兼容
This commit is contained in:
@@ -93,11 +93,10 @@ class table_pichome_resources extends dzz_table
|
|||||||
|
|
||||||
public function update_by_rids($appid, $rids, $attr)
|
public function update_by_rids($appid, $rids, $attr)
|
||||||
{
|
{
|
||||||
if (!is_array($rids)) $rids = (array)$rids;
|
if(!is_array($rids)) $rids = array($rids);
|
||||||
if (parent::update($rids, $attr)) {
|
Hook::listen('resourcesupdateBefore',$attr,$rids);
|
||||||
$hookindex = ['rids' => $rids, 'appid' => $appid];
|
if($attr) parent::update($rids,$attr);
|
||||||
Hook::listen('updatedataafter', $hookindex);
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//清空删除文件
|
//清空删除文件
|
||||||
@@ -322,10 +321,14 @@ class table_pichome_resources extends dzz_table
|
|||||||
$return = [];
|
$return = [];
|
||||||
foreach (DB::fetch_all("select * from %t where rid in(%n)", array('thumb_record', $rids)) as $v) {
|
foreach (DB::fetch_all("select * from %t where rid in(%n)", array('thumb_record', $rids)) as $v) {
|
||||||
if ($v['rid']) $return[$v['rid']]['imgstatus'] = 1;
|
if ($v['rid']) $return[$v['rid']]['imgstatus'] = 1;
|
||||||
if ($v['sstatus']) $return[$v['rid']]['icondata'] = getglobal('siteurl') . IO::getFileuri($v['spath']);
|
if ($v['sstatus']) {
|
||||||
else $return[$v['rid']]['icondata'] = false;
|
$uri = IO::getFileuri($v['spath']);
|
||||||
if ($v['lstatus']) $return[$v['rid']]['originalimg'] = getglobal('siteurl') . IO::getFileuri($v['lpath']);
|
$return[$v['rid']]['icondata'] =preg_match( '/^http(s)?:\\/\\/.+/',$uri) ? $uri:getglobal('siteurl') .$uri;
|
||||||
else $return[$v['rid']]['originalimg'] = false;
|
} else $return[$v['rid']]['icondata'] = false;
|
||||||
|
if ($v['lstatus']) {
|
||||||
|
$uri = IO::getFileuri($v['lpath']);
|
||||||
|
$return[$v['rid']]['originalimg'] = preg_match( '/^http(s)?:\\/\\/.+/',$uri) ? $uri:getglobal('siteurl') . $uri;
|
||||||
|
} else $return[$v['rid']]['originalimg'] = false;
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
@@ -339,7 +342,7 @@ class table_pichome_resources extends dzz_table
|
|||||||
$did = is_numeric($patharr[1]) ? $patharr[1] : 1;
|
$did = is_numeric($patharr[1]) ? $patharr[1] : 1;
|
||||||
//库路径
|
//库路径
|
||||||
$thumbdir = $apppath;
|
$thumbdir = $apppath;
|
||||||
if(strpos($resourcesdata['path'],$thumbdir)!==false)$resourcesdata['path'] = str_replace($thumbdir.BS,'',$resourcesdata['path']);
|
if(strpos($resourcesdata['path'],$thumbdir)!==false)$resourcesdata['path'] = str_replace([$thumbdir.BS,$thumbdir.'/'],'',$resourcesdata['path']);
|
||||||
$ext = $resourcesdata['ext'];
|
$ext = $resourcesdata['ext'];
|
||||||
//获取缩略图地址模式,默认0由服务器自动根据文件位置生成地址
|
//获取缩略图地址模式,默认0由服务器自动根据文件位置生成地址
|
||||||
$thumurlmod = getglobal('config/thumburlmod') ? getglobal('config/thumburlmod'):0;
|
$thumurlmod = getglobal('config/thumburlmod') ? getglobal('config/thumburlmod'):0;
|
||||||
@@ -351,7 +354,7 @@ class table_pichome_resources extends dzz_table
|
|||||||
//大图参数
|
//大图参数
|
||||||
$largethumbparams = ['rid' => $resourcesdata['rid'], 'hash' => VERHASH, 'download' => $download,
|
$largethumbparams = ['rid' => $resourcesdata['rid'], 'hash' => VERHASH, 'download' => $download,
|
||||||
'thumbsign' => '1','path'=>$resourcesdata['path'], 'ext' => $resourcesdata['ext'], 'appid' => $resourcesdata['appid'],'hasthumb'=>$resourcesdata['hasthumb']];
|
'thumbsign' => '1','path'=>$resourcesdata['path'], 'ext' => $resourcesdata['ext'], 'appid' => $resourcesdata['appid'],'hasthumb'=>$resourcesdata['hasthumb']];
|
||||||
if ($apptype == 3 || $apptype == 1) {
|
if ($apptype == 3) {
|
||||||
$thumbdata = C::t('thumb_record')->fetch($resourcesdata['rid']);
|
$thumbdata = C::t('thumb_record')->fetch($resourcesdata['rid']);
|
||||||
if ($thumbdata['sstatus']) $imgdata['icondata'] = getglobal('siteurl') . IO::getFileuri($thumbdata['spath']);
|
if ($thumbdata['sstatus']) $imgdata['icondata'] = getglobal('siteurl') . IO::getFileuri($thumbdata['spath']);
|
||||||
else $imgdata['icondata'] = false;
|
else $imgdata['icondata'] = false;
|
||||||
@@ -359,6 +362,20 @@ class table_pichome_resources extends dzz_table
|
|||||||
else {
|
else {
|
||||||
$imgdata['originalimg'] = (!$return) ? false: getglobal('siteurl') . 'index.php?mod=io&op=createThumb&path='.$resourcesdata['dpath'].'&size=large';
|
$imgdata['originalimg'] = (!$return) ? false: getglobal('siteurl') . 'index.php?mod=io&op=createThumb&path='.$resourcesdata['dpath'].'&size=large';
|
||||||
}
|
}
|
||||||
|
}elseif($apptype == 1){
|
||||||
|
if(isset($resourcesdata['isFilelistThumb']) && $resourcesdata['isFilelistThumb']){
|
||||||
|
$smallthumbparams = ['rid' => $resourcesdata['rid'], 'hash' => VERHASH, 'download' => $download,
|
||||||
|
'thumbsign' => '0', 'path'=>$resourcesdata['path'],'ext' => $resourcesdata['ext'], 'appid' => $resourcesdata['appid'],'hasthumb'=>$resourcesdata['hasthumb']];
|
||||||
|
$imgdata['iconimg'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . Pencode($smallthumbparams, 0, '') . '&' . VERHASH;
|
||||||
|
}else{
|
||||||
|
$thumbdata = C::t('thumb_record')->fetch($resourcesdata['rid']);
|
||||||
|
if ($thumbdata['sstatus']) $imgdata['icondata'] = getglobal('siteurl') . IO::getFileuri($thumbdata['spath']);
|
||||||
|
else $imgdata['icondata'] = false;
|
||||||
|
if ($thumbdata['lstatus']) $imgdata['originalimg'] = getglobal('siteurl') . IO::getFileuri($thumbdata['lpath']);
|
||||||
|
else {
|
||||||
|
$imgdata['originalimg'] = (!$return) ? false: getglobal('siteurl') . 'index.php?mod=io&op=createThumb&path='.$resourcesdata['dpath'].'&size=large';
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$imgdata['icondata'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . Pencode($smallthumbparams, 0, '') . '&' . VERHASH;
|
$imgdata['icondata'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . Pencode($smallthumbparams, 0, '') . '&' . VERHASH;
|
||||||
@@ -366,9 +383,9 @@ class table_pichome_resources extends dzz_table
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
switch ($apptype) {
|
switch ($apptype) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
//小图地址
|
//小图地址
|
||||||
if ($resourcesdata['hasthumb']) {
|
if ($resourcesdata['hasthumb']) {
|
||||||
$tmppath = str_replace(strrchr($resourcesdata['path'], "."), "", $resourcesdata['path']);
|
$tmppath = str_replace(strrchr($resourcesdata['path'], "."), "", $resourcesdata['path']);
|
||||||
@@ -424,6 +441,20 @@ class table_pichome_resources extends dzz_table
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
|
if(isset($resourcesdata['isFilelistThumb']) && $resourcesdata['isFilelistThumb']){
|
||||||
|
$smallthumbparams = ['rid' => $resourcesdata['rid'], 'hash' => VERHASH, 'download' => $download,
|
||||||
|
'thumbsign' => '0', 'path'=>$resourcesdata['path'],'ext' => $resourcesdata['ext'], 'appid' => $resourcesdata['appid'],'hasthumb'=>$resourcesdata['hasthumb']];
|
||||||
|
$imgdata['iconimg'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . Pencode($smallthumbparams, 0, '') . '&' . VERHASH;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$thumbdata = C::t('thumb_record')->fetch($resourcesdata['rid']);
|
||||||
|
if ($thumbdata['sstatus']) $imgdata['icondata'] = getglobal('siteurl') . IO::getFileuri($thumbdata['spath']);
|
||||||
|
else $imgdata['icondata'] = false;
|
||||||
|
if ($thumbdata['lstatus']) $imgdata['originalimg'] = getglobal('siteurl') . IO::getFileuri($thumbdata['lpath']);
|
||||||
|
else $imgdata['originalimg'] = (!$return) ? false: getglobal('siteurl') . 'index.php?mod=io&op=createThumb&path='.$resourcesdata['dpath'].'&size=large';
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
$thumbdata = C::t('thumb_record')->fetch($resourcesdata['rid']);
|
$thumbdata = C::t('thumb_record')->fetch($resourcesdata['rid']);
|
||||||
if ($thumbdata['sstatus']) $imgdata['icondata'] = getglobal('siteurl') . IO::getFileuri($thumbdata['spath']);
|
if ($thumbdata['sstatus']) $imgdata['icondata'] = getglobal('siteurl') . IO::getFileuri($thumbdata['spath']);
|
||||||
@@ -486,7 +517,9 @@ class table_pichome_resources extends dzz_table
|
|||||||
|
|
||||||
$resourcesdata['isdetail'] = 1;
|
$resourcesdata['isdetail'] = 1;
|
||||||
$resourcesdata['dpath'] =dzzencode($rid, '', 0, 0);
|
$resourcesdata['dpath'] =dzzencode($rid, '', 0, 0);
|
||||||
|
$resourcesdata['isFilelistThumb'] = 1;
|
||||||
$imgdata = $this->getfileimageurl($resourcesdata, $appdata['path'], $appdata['type'], $resourcesdata['download'],1);
|
$imgdata = $this->getfileimageurl($resourcesdata, $appdata['path'], $appdata['type'], $resourcesdata['download'],1);
|
||||||
|
if(!$imgdata['icondata'] && $imgdata['iconimg']) $imgdata['icondata'] = $imgdata['iconimg'];
|
||||||
$resourcesdata = array_merge($resourcesdata, $imgdata);
|
$resourcesdata = array_merge($resourcesdata, $imgdata);
|
||||||
|
|
||||||
if ($resourcesdata['width'] == 0) $resourcesdata['width'] = 900;
|
if ($resourcesdata['width'] == 0) $resourcesdata['width'] = 900;
|
||||||
@@ -511,6 +544,8 @@ class table_pichome_resources extends dzz_table
|
|||||||
unset($resourcesdata['path']);
|
unset($resourcesdata['path']);
|
||||||
$random = rand();
|
$random = rand();
|
||||||
$resourcesdata['iniframe'] = ($src) ? $src . '&random=' . $random . '&hash=' . VERHASH . '&path=' . $resourcesdata['dpath'] : '';
|
$resourcesdata['iniframe'] = ($src) ? $src . '&random=' . $random . '&hash=' . VERHASH . '&path=' . $resourcesdata['dpath'] : '';
|
||||||
|
|
||||||
|
Hook::listen('resourcesdataFilter',$resourcesdata,false);
|
||||||
return $resourcesdata;
|
return $resourcesdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,7 +567,7 @@ class table_pichome_resources extends dzz_table
|
|||||||
//获取所有的缩略图表数据
|
//获取所有的缩略图表数据
|
||||||
$imagedatas = $this->getThumbsByrids($rids);
|
$imagedatas = $this->getThumbsByrids($rids);
|
||||||
foreach ($resourcesdata as $v) {
|
foreach ($resourcesdata as $v) {
|
||||||
if ($nodel && $v['isdelete'] > 0) continue;
|
if (($nodel && $v['isdelete'] > 0) ) continue;
|
||||||
if($v['isdelete']){
|
if($v['isdelete']){
|
||||||
$v['share'] = $v['download'] = $v['collection'] = 0;
|
$v['share'] = $v['download'] = $v['collection'] = 0;
|
||||||
}else{
|
}else{
|
||||||
@@ -544,6 +579,11 @@ class table_pichome_resources extends dzz_table
|
|||||||
|
|
||||||
if ($imagedatas[$v['rid']]['imgstatus']) {
|
if ($imagedatas[$v['rid']]['imgstatus']) {
|
||||||
$imgdata = ['icondata' => $imagedatas[$v['rid']]['icondata'], 'originalimg' => $imagedatas[$v['rid']]['originalimg']];
|
$imgdata = ['icondata' => $imagedatas[$v['rid']]['icondata'], 'originalimg' => $imagedatas[$v['rid']]['originalimg']];
|
||||||
|
if($downshare[$v['appid']]['type'] == 1 && !$imgdata['icondata']){
|
||||||
|
$v['isFilelistThumb'] = 1;
|
||||||
|
$tmpimagedata = $this->getfileimageurl($v, $downshare[$v['appid']]['path'], $downshare[$v['appid']]['type'], $v['download']);
|
||||||
|
$imgdata = array_merge($imgdata,$tmpimagedata);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$imgdata = $this->getfileimageurl($v, $downshare[$v['appid']]['path'], $downshare[$v['appid']]['type'], $v['download']);
|
$imgdata = $this->getfileimageurl($v, $downshare[$v['appid']]['path'], $downshare[$v['appid']]['type'], $v['download']);
|
||||||
}
|
}
|
||||||
@@ -566,6 +606,7 @@ class table_pichome_resources extends dzz_table
|
|||||||
unset($v['path']);
|
unset($v['path']);
|
||||||
$returndata[] = $v;
|
$returndata[] = $v;
|
||||||
}
|
}
|
||||||
|
Hook::listen('resourcesdataFilter',$returndata,true);
|
||||||
return $returndata;
|
return $returndata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -637,7 +678,7 @@ class table_pichome_resources extends dzz_table
|
|||||||
//Return the results
|
//Return the results
|
||||||
return array($width,$height);
|
return array($width,$height);
|
||||||
}
|
}
|
||||||
public function geticondata_by_rid($rid, $onlyicon = 0)
|
public function geticondata_by_rid($rid, $onlyicon = 0,$force = 1)
|
||||||
{
|
{
|
||||||
$resourcesdata = DB::fetch_first("select r.rid,r.isdelete,r.appid,r.ext,r.type,ra.path as fpath,
|
$resourcesdata = DB::fetch_first("select r.rid,r.isdelete,r.appid,r.ext,r.type,ra.path as fpath,
|
||||||
v.path,v.type as apptype,v.download from %t r
|
v.path,v.type as apptype,v.download from %t r
|
||||||
@@ -647,11 +688,23 @@ class table_pichome_resources extends dzz_table
|
|||||||
if ($onlyicon) return false;
|
if ($onlyicon) return false;
|
||||||
else return $resourcesdata;
|
else return $resourcesdata;
|
||||||
} else {
|
} else {
|
||||||
|
$vapppath = $resourcesdata['path'];
|
||||||
|
if($resourcesdata['apptype'] != 3){
|
||||||
|
$resourcesdata['path'] = $vapppath.BS.$resourcesdata['fpath'];
|
||||||
|
}
|
||||||
|
if($force && $resourcesdata['apptype'] = 1){
|
||||||
|
$resourcesdata['isFilelistThumb'] = 1;
|
||||||
|
}
|
||||||
$download = C::t('pichome_vapp')->getpermbypermdata($resourcesdata['download'], $resourcesdata['appid'], 'download');
|
$download = C::t('pichome_vapp')->getpermbypermdata($resourcesdata['download'], $resourcesdata['appid'], 'download');
|
||||||
$imgdata = $this->getfileimageurl($resourcesdata, $resourcesdata['path'], $resourcesdata['apptype'], $download);
|
$imgdata = $this->getfileimageurl($resourcesdata, $vapppath, $resourcesdata['apptype'], $download);
|
||||||
|
|
||||||
if ($onlyicon) {
|
if ($onlyicon) {
|
||||||
return $imgdata['icondata'];
|
if($resourcesdata['apptype'] = 1 && !$imgdata['icondata'] && $imgdata['iconimg']){
|
||||||
|
$iconimgdata =$imgdata['iconimg'];
|
||||||
|
}else{
|
||||||
|
$iconimgdata = $imgdata['icondata'];
|
||||||
|
}
|
||||||
|
return $iconimgdata;
|
||||||
} else {
|
} else {
|
||||||
return array_merge($resourcesdata, $imgdata);
|
return array_merge($resourcesdata, $imgdata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,8 @@ class table_pichome_templatetagdata extends dzz_table
|
|||||||
|
|
||||||
foreach($v['tdata'] as $k=>$val){
|
foreach($v['tdata'] as $k=>$val){
|
||||||
if($val['aid']){
|
if($val['aid']){
|
||||||
$v['tdata'][$k]['imgurl'] = getglobal('siteurl').IO::getFileUri('attach::'.$val['aid']);
|
$uri = IO::getFileUri('attach::'.$val['aid']);
|
||||||
|
$v['tdata'][$k]['imgurl'] =preg_match( '/^http(s)?:\\/\\/.+/',$uri) ? $uri:getglobal('siteurl').$uri;
|
||||||
}
|
}
|
||||||
if(!$val['link']) $val['tdata'][$k]['url'] = $val['linkval'] ? $val['linkval']:'';
|
if(!$val['link']) $val['tdata'][$k]['url'] = $val['linkval'] ? $val['linkval']:'';
|
||||||
else{
|
else{
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ if($do == 'addspace'){
|
|||||||
'did'=>$space['id'],
|
'did'=>$space['id'],
|
||||||
'host'=>$space['host'],
|
'host'=>$space['host'],
|
||||||
];
|
];
|
||||||
if(DB::update('connect_storage',['isdefault'=>0],'id !='.$id) && DB::update('connect_storage',['isdefault'=>1],'id ='.$id)){
|
if(DB::update('connect_storage',['isdefault'=>1],'id ='.$id)){
|
||||||
|
DB::update('connect_storage',['isdefault'=>0],'id !='.$id);
|
||||||
C::t('setting')->update('defaultspacesetting',$defaultspacesettingdata);
|
C::t('setting')->update('defaultspacesetting',$defaultspacesettingdata);
|
||||||
updatecache('setting');
|
updatecache('setting');
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -13,19 +13,44 @@ ini_set('memory_limit', -1);
|
|||||||
$ridarr = isset($_GET['rids']) ? $_GET['rids']:[];
|
$ridarr = isset($_GET['rids']) ? $_GET['rids']:[];
|
||||||
if(!$ridarr) exit(json_encode(['success'=>true,'data'=>false]));
|
if(!$ridarr) exit(json_encode(['success'=>true,'data'=>false]));
|
||||||
|
|
||||||
|
$cachename = 'PICHOMETHUMBSTATUS';
|
||||||
|
$thumbstatus = C::t('cache')->fetch_cachedata_by_cachename($cachename);
|
||||||
|
if (!$thumbstatus) {
|
||||||
|
$thunbdata = [];
|
||||||
|
foreach(DB::fetch_all("select id,bz,imagestatus from %t where 1",array('connect_storage')) as $v){
|
||||||
|
if($v['bz'] == 'dzz'){
|
||||||
|
$key = $v['bz'].'::';
|
||||||
|
}else{
|
||||||
|
$key = $v['bz'].':'.$v['id'].':';
|
||||||
|
}
|
||||||
|
$thunbdata[$key] = intval($v['imagestatus']);
|
||||||
|
}
|
||||||
|
$setarr = ['cachekey' => $cachename, 'cachevalue' => serialize($thunbdata), 'dateline' => time()];
|
||||||
|
C::t('cache')->insert_cachedata_by_cachename($setarr);
|
||||||
|
} else {
|
||||||
|
$thunbdata = $thumbstatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
$thumbstate = 0;
|
||||||
|
foreach($thunbdata as $v){
|
||||||
|
if($v) $thumbstate = 1;
|
||||||
|
}
|
||||||
|
if(!$thumbstate) exit(json_encode(['success'=>true,'data'=>false]));
|
||||||
$data = [];
|
$data = [];
|
||||||
$needcreate = [];
|
$needcreate = [];
|
||||||
$hasrecordrids = [];
|
$hasrecordrids = [];
|
||||||
$thumbrecorddata = [];
|
$thumbrecorddata = [];
|
||||||
foreach(DB::fetch_all("select * from %t where rid in(%n) order by stimes",array('thumb_record',$ridarr)) as $v){
|
foreach(DB::fetch_all("select * from %t where rid in(%n) order by stimes",array('thumb_record',$ridarr)) as $v){
|
||||||
if($v['sstatus']){
|
if($v['sstatus']){
|
||||||
$data[$v['rid']][] = getglobal('siteurl').IO::getFileUri($v['spath']);
|
$uri = IO::getFileUri($v['spath']);
|
||||||
|
$data[$v['rid']][] = preg_match( '/^http(s)?:\\/\\/.+/',$uri) ? $uri:getglobal('siteurl').$uri;
|
||||||
}else{
|
}else{
|
||||||
$needcreate[] = $v['rid'];
|
$needcreate[] = $v['rid'];
|
||||||
}
|
}
|
||||||
$hasrecordrids[] = $v['rid'];
|
$hasrecordrids[] = $v['rid'];
|
||||||
$thumbrecorddata[$v['rid']] = $v;
|
$thumbrecorddata[$v['rid']] = $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
$diff = array_diff($ridarr,$hasrecordrids);
|
$diff = array_diff($ridarr,$hasrecordrids);
|
||||||
if($diff) $needcreate = array_merge($diff,$needcreate);
|
if($diff) $needcreate = array_merge($diff,$needcreate);
|
||||||
if(count($needcreate)>=$limit) $needcreate=array_splice($needcreate,0,$limit);
|
if(count($needcreate)>=$limit) $needcreate=array_splice($needcreate,0,$limit);
|
||||||
|
|||||||
Reference in New Issue
Block a user