diff --git a/core/class/class_image.php b/core/class/class_image.php
index c5d7470..ea2796c 100644
--- a/core/class/class_image.php
+++ b/core/class/class_image.php
@@ -50,6 +50,7 @@ class image {
function Thumb($source, $target, $thumbwidth, $thumbheight, $thumbtype = 1, $nosuffix = 0) {
$return = $this->init('thumb', $source, $target,$nosuffix);
+
if($return <= 0) {
return $this->returncode($return);
}
@@ -275,9 +276,81 @@ class image {
}
return array($x, $y, $w, $h);
}
+ function webpinfo($file) {
+ if (!is_file($file)) {
+ return false;
+ } else {
+ $file = realpath($file);
+ }
+
+ $fp = fopen($file, 'rb');
+ if (!$fp) {
+ return false;
+ }
+
+ $data = fread($fp, 90);
+
+ fclose($fp);
+ unset($fp);
+
+ $header_format = 'A4Riff/' . // 获取4个字符的字符串
+ 'I1Filesize/' . // 获取一个整数(文件大小,但不是实际大小)
+ 'A4Webp/' . // 获取4个字符的字符串
+ 'A4Vp/' . // 获取4个字符的字符串
+ 'A74Chunk'; // 获取74个字符的字符串
+ $header = unpack($header_format, $data);
+ unset($data, $header_format);
+
+ if (!isset($header['Riff']) || strtoupper($header['Riff']) !== 'RIFF') {
+ return false;
+ }
+ if (!isset($header['Webp']) || strtoupper($header['Webp']) !== 'WEBP') {
+ return false;
+ }
+ if (!isset($header['Vp']) || strpos(strtoupper($header['Vp']), 'VP8') === false) {
+ return false;
+ }
+
+ if (
+ strpos(strtoupper($header['Chunk']), 'ANIM') !== false ||
+ strpos(strtoupper($header['Chunk']), 'ANMF') !== false
+ ) {
+ $header['Animation'] = true;
+ } else {
+ $header['Animation'] = false;
+ }
+
+ if (strpos(strtoupper($header['Chunk']), 'ALPH') !== false) {
+ $header['Alpha'] = true;
+ } else {
+ if (strpos(strtoupper($header['Vp']), 'VP8L') !== false) {
+ // 如果是VP8L,假设该图像会有透明度
+ // 如Google文档中描述的WebP简单文件格式无损部分
+ $header['Alpha'] = true;
+ } else {
+ $header['Alpha'] = false;
+ }
+ }
+
+ unset($header['Chunk']);
+ return $header;
+ }
function loadsource() {
$imagecreatefromfunc = &$this->imagecreatefromfunc;
+ if($imagecreatefromfunc == 'imagecreatefromwebp'){
+ $info = $this->webpinfo($this->source);
+ if ($info !== false) {
+ if ($info['Animation']) {
+ return -1;
+ }
+ if ($info['Alpha']) {
+ return -1;
+ }
+ }else{
+ return -1;
+ }
+ }
$im = @$imagecreatefromfunc($this->source);
if(!$im) {
if(!function_exists('imagecreatefromstring')) {
@@ -299,7 +372,6 @@ class image {
if(!function_exists('imagecreatetruecolor') || !function_exists('imagecopyresampled') || !function_exists('imagejpeg') || !function_exists('imagecopymerge')) {
return -4;
}
-
$imagefunc = &$this->imagefunc;
$attach_photo = $this->loadsource();
if($attach_photo < 0) {
diff --git a/core/class/io/io_dzz.php b/core/class/io/io_dzz.php
index a15ef24..861651e 100644
--- a/core/class/io/io_dzz.php
+++ b/core/class/io/io_dzz.php
@@ -976,15 +976,16 @@ class io_dzz extends io_api
if($extraparams['istmp']){
return $thumbpath;
}
- $defaultspace = $_G['setting']['defaultspacesetting'];
- if($defaultspace['bz'] != 'dzz'){
- $cloudpath = $defaultspace['bz'].':'.$defaultspace['did'] . ':' .$thumbpath;
- $return = IO::moveThumbFile($cloudpath,$thumbpath);
- //$thumbpath = $return;
-
- }
- if(isset($return['error'])){
- return false;
+ if($thumbpath){
+ $defaultspace = $_G['setting']['defaultspacesetting'];
+ if($defaultspace['bz'] != 'dzz'){
+ $cloudpath = $defaultspace['bz'].':'.$defaultspace['did'] . ':' .$thumbpath;
+ $return = IO::moveThumbFile($cloudpath,$thumbpath);
+ //$thumbpath = $return;
+ }
+ if(isset($return['error'])){
+ return false;
+ }
}
return $thumbpath;
@@ -1091,7 +1092,7 @@ class io_dzz extends io_api
$extraparams['nomark'] = 1;
$thumbpath = IO::createThumbByOriginal($filepath, $data, $width, $height, $thumbtype, 0, $extraparams);
$bz = io_remote::getBzByRemoteid($defaultspace['remoteid']);
- $thumbpath = $bz.$thumbpath;
+ if($thumbpath)$thumbpath = $bz.$thumbpath;
if($thumbpath){
$img = IO::getFileUri($thumbpath);
if ($returnurl) return $img;
@@ -1305,7 +1306,7 @@ class io_dzz extends io_api
if(!$thumbpath){
$cthumbpath = IO::createThumbByOriginal($filepath, $data, $width, $height, $thumbtype, $original, $extraparams, $filesize);
$bz = io_remote::getBzByRemoteid($defaultspace['remoteid']);
- $thumbpath = $bz.$cthumbpath;
+ if($cthumbpath)$thumbpath = $bz.$cthumbpath;
if($cthumbpath){
$cacheid = '';
if($data['aid']){
@@ -1434,7 +1435,7 @@ class io_dzz extends io_api
//创建缩略图
$cthumbpath = IO::createThumbByOriginal($filepath, $data, $width, $height, $thumbtype, $original, $extraparams, $filesize);
$bz = io_remote::getBzByRemoteid($defaultspace['remoteid']);
- $thumbpath = $bz.$cthumbpath;
+ if($cthumbpath)$thumbpath = $bz.$cthumbpath;
if($cthumbpath){
$cacheid = '';
if($rdata['aid']){
diff --git a/core/class/table/table_pichome_resources.php b/core/class/table/table_pichome_resources.php
index b2c379c..092476e 100644
--- a/core/class/table/table_pichome_resources.php
+++ b/core/class/table/table_pichome_resources.php
@@ -387,6 +387,7 @@ class table_pichome_resources extends dzz_table
$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;
+ $imgdata['originalimg'] = (!$return) ? false: getglobal('siteurl') . 'index.php?mod=io&op=createThumb&path='.$resourcesdata['dpath'].'&size=large';
}else{
$thumbdata = C::t('thumb_record')->fetch($resourcesdata['rid']);
@@ -474,7 +475,7 @@ class table_pichome_resources extends dzz_table
$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;
-
+ $imgdata['originalimg'] = (!$return) ? false: getglobal('siteurl') . 'index.php?mod=io&op=createThumb&path='.$resourcesdata['dpath'].'&size=large';
}else{
$thumbdata = C::t('thumb_record')->fetch($resourcesdata['rid']);
if ($thumbdata['sstatus']) $imgdata['icondata'] = IO::getFileUri($thumbdata['spath']);
@@ -812,7 +813,7 @@ class table_pichome_resources extends dzz_table
$setarr = [];
$setarr['lastdate'] = TIMESTAMP;
//如果当前库有该文件,则使用当前文件
- if ($rid = DB::result_first("select rid from %t where path = %d and appid = %s ", array('pichome_resources_attr', $aid, $appid))) {
+ if ($rid = DB::result_first("select rid from %t where path = %s and appid = %s ", array('pichome_resources_attr', $aid, $appid))) {
$resourcesdata = C::t('pichome_resources')->fetch($rid);
$nfids = explode(',', $resourcesdata['fids']);
$setarr['rid'] = $rid;
@@ -897,7 +898,7 @@ class table_pichome_resources extends dzz_table
} else {
return false;
}
- } elseif ($rid = DB::result_first("select rid from %t where path = %d ", array('pichome_resources_attr', $aid))) {
+ } elseif ($rid = DB::result_first("select rid from %t where path = %s ", array('pichome_resources_attr', $aid))) {
//如果当前库无该文件但其它库有
//获取原文件基本数据
$resourcesdata = C::t('pichome_resources')->fetch($rid);
diff --git a/dzz/alonepage/template/assets/js/file_rec.js b/dzz/alonepage/template/assets/js/file_rec.js
index 300ff4e..dcf0700 100644
--- a/dzz/alonepage/template/assets/js/file_rec.js
+++ b/dzz/alonepage/template/assets/js/file_rec.js
@@ -190,6 +190,7 @@ const Tmpfile_rec = {
+
@@ -204,7 +205,7 @@ const Tmpfile_rec = {
-
+
diff --git a/misc/getthumb.php b/misc/getthumb.php
index 1f03e22..6d89440 100644
--- a/misc/getthumb.php
+++ b/misc/getthumb.php
@@ -26,7 +26,6 @@ $start = $i * $limit;
if ($locked) {
exit(json_encode(array('error' => '进程已被锁定请稍后再试')));
}
-
$imageCacheName = 'PICHOMETHUMBSTATUS';
$docCacheName = 'PICHOMEDOCSTATUS';
$mediaCacheName = 'PICHOMECONVERTSTATUS';
@@ -79,16 +78,18 @@ foreach (DB::fetch_all("select appid,path,`type` from %t where (`type` = %d or `
}
if (empty($appids)) {
+ dzz_process::unlock($processname);
exit('success');
}
-$datas = DB::fetch_all("select r.rid,r.appid,t.rid,t.sstatus,t.lstatus,t.ltimes,t.stimes,least(t.ltimes,t.stimes) as mintimes
+$datas = DB::fetch_all("select r.rid,r.appid,t.rid,t.sstatus,t.lstatus,t.ltimes,t.stimes,t.ltimes+t.stimes as mintimes
from %t t left join %t r on t.rid = r.rid
-where (t.sstatus < 1 or t.lstatus < 1) and ((t.ltimes+t.stimes) < %d) and r.isdelete = 0 and r.appid in(%n)
+where (t.sstatus < 1 or t.lstatus < 1) and ((t.ltimes+t.stimes) < %d) and r.isdelete = 0 and r.appid in(%n)
order by mintimes asc,r.dateline asc limit $start,$limit", array('thumb_record', 'pichome_resources', 6, $appids));
if ($datas) {
foreach ($datas as $v) {
+
$processname1 = 'PICHOMEGETTHUMB_' . $v['rid'];
//dzz_process::unlock($processname1);
//如果当前数据是锁定状态则跳过
@@ -124,10 +125,14 @@ if ($datas) {
dzz_process::unlock($processname1);
continue;
}
-
- //调用系统获取缩略图
- $returnurl = IO::getThumb($v['rid'], $thumbsign, 0, 1, 1);
- dzz_process::unlock($processname1);
+ try{
+ //调用系统获取缩略图
+ $returnurl = IO::getThumb($v['rid'], $thumbsign, 0, 1, 1);
+ dzz_process::unlock($processname1);
+ }catch (Exception $e){
+ runlog('createThumbError',$e->getMessage()."\t".$v['rid']);
+ dzz_process::unlock($processname1);
+ }
//exit('aaaa');
}
@@ -155,6 +160,7 @@ function getDzzExt($ext){
}else{
$imageext = $gdlimitext;
}
+ $imageext[] = 'webp';
$mediaext = explode(',',$_G['config']['pichomeconvertext']);
if(in_array($ext,$docext)){
$type = 'docstatus';