@@ -181,11 +181,21 @@ else if ($dopost == 'save') { | |||||
for ($i = 0; $i <= count($albumsArr) - 1; $i++) { | for ($i = 0; $i <= count($albumsArr) - 1; $i++) { | ||||
$album = $albumsArr[$i]; | $album = $albumsArr[$i]; | ||||
$data = explode(',', $album['img']); | $data = explode(',', $album['img']); | ||||
$ext = ".png"; | |||||
if(strpos($data[0], "data:image/jpeg") === 0){ | |||||
$ext = ".jpg"; | |||||
} elseif (strpos($data[0], "data:image/gif") === 0) { | |||||
$ext = ".gif"; | |||||
} elseif (strpos($data[0], "data:image/webp") === 0) { | |||||
$ext = ".webp"; | |||||
} elseif (strpos($data[0], "data:image/bmp") === 0) { | |||||
$ext = ".bmp"; | |||||
} | |||||
$ntime = time(); | $ntime = time(); | ||||
$savepath = $cfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime); | $savepath = $cfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime); | ||||
CreateDir($savepath); | CreateDir($savepath); | ||||
$fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999)); | $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999)); | ||||
$fullUrl = $fullUrl.".png"; | |||||
$fullUrl = $fullUrl.$ext; | |||||
file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1])); | file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1])); | ||||
$info = ''; | $info = ''; | ||||
$imginfos = GetImageSize($cfg_basedir.$fullUrl, $info); | $imginfos = GetImageSize($cfg_basedir.$fullUrl, $info); | ||||
@@ -276,11 +276,21 @@ else if ($dopost == 'save') { | |||||
for ($i = 0; $i <= count($albumsArr) - 1; $i++) { | for ($i = 0; $i <= count($albumsArr) - 1; $i++) { | ||||
$album = $albumsArr[$i]; | $album = $albumsArr[$i]; | ||||
$data = explode(',', $album['img']); | $data = explode(',', $album['img']); | ||||
$ext = ".png"; | |||||
if(strpos($data[0], "data:image/jpeg") === 0){ | |||||
$ext = ".jpg"; | |||||
} elseif (strpos($data[0], "data:image/gif") === 0) { | |||||
$ext = ".gif"; | |||||
} elseif (strpos($data[0], "data:image/webp") === 0) { | |||||
$ext = ".webp"; | |||||
} elseif (strpos($data[0], "data:image/bmp") === 0) { | |||||
$ext = ".bmp"; | |||||
} | |||||
$ntime = time(); | $ntime = time(); | ||||
$savepath = $cfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime); | $savepath = $cfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime); | ||||
CreateDir($savepath); | CreateDir($savepath); | ||||
$fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999)); | $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999)); | ||||
$fullUrl = $fullUrl.".png"; | |||||
$fullUrl = $fullUrl.$ext; | |||||
file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1])); | file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1])); | ||||
$info = ''; | $info = ''; | ||||
$imginfos = GetImageSize($cfg_basedir.$fullUrl, $info); | $imginfos = GetImageSize($cfg_basedir.$fullUrl, $info); | ||||
@@ -6,131 +6,6 @@ | |||||
* @license https://www.dedebiz.com/license | * @license https://www.dedebiz.com/license | ||||
* @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
*/ | */ | ||||
//事件句并 | |||||
function fileQueueError(file, errorCode, message) { | |||||
try { | |||||
var imageName = "error.gif"; | |||||
var errorName = ""; | |||||
if (errorCode === SWFUpload.errorCode_QUEUE_LIMIT_EXCEEDED) { | |||||
errorName = "您添加的文件超过了限制"; | |||||
} | |||||
if (errorName !== "") { | |||||
alert(errorName); | |||||
return; | |||||
} | |||||
switch (errorCode) { | |||||
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: | |||||
imageName = "zerobyte.gif"; | |||||
break; | |||||
case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: | |||||
imageName = "toobig.gif"; | |||||
break; | |||||
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: | |||||
case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE: | |||||
default: | |||||
alert(message); | |||||
break; | |||||
} | |||||
addImage("images/" + imageName, 0); | |||||
} catch (ex) { | |||||
this.debug(ex); | |||||
} | |||||
} | |||||
function fileDialogComplete(numFilesSelected, numFilesQueued) { | |||||
try { | |||||
if (numFilesQueued > 0) { | |||||
this.startUpload(); | |||||
} | |||||
} catch (ex) { | |||||
this.debug(ex); | |||||
} | |||||
} | |||||
function uploadProgress(file, bytesLoaded) { | |||||
try { | |||||
var percent = Math.ceil((bytesLoaded / file.size) * 100); | |||||
var progress = new FileProgress(file, this.customSettings.upload_target); | |||||
progress.setProgress(percent); | |||||
if (percent === 100) { | |||||
progress.setStatus("创建缩略图..."); | |||||
progress.toggleCancel(false, this); | |||||
} else { | |||||
progress.setStatus("上传中..."); | |||||
progress.toggleCancel(true, this); | |||||
} | |||||
} catch (ex) { | |||||
this.debug(ex); | |||||
} | |||||
} | |||||
function uploadSuccess(file, serverData) { | |||||
try { | |||||
var progress = new FileProgress(file, this.customSettings.upload_target); | |||||
if (serverData.substring(0, 7) === "FILEID:") { | |||||
addImage("swfupload.php?dopost=thumbnail&id=" + serverData.substring(7), serverData.substring(7)); | |||||
progress.setStatus("获取缩略图"); | |||||
progress.toggleCancel(false); | |||||
} else { | |||||
addImage("images/error.gif", 0); | |||||
progress.setStatus("有错误"); | |||||
progress.toggleCancel(false); | |||||
alert(serverData); | |||||
} | |||||
} catch (ex) { | |||||
this.debug(ex); | |||||
} | |||||
} | |||||
function uploadComplete(file) { | |||||
try { | |||||
if (this.getStats().files_queued > 0) { | |||||
this.startUpload(); | |||||
} else { | |||||
var progress = new FileProgress(file, this.customSettings.upload_target); | |||||
progress.setComplete(); | |||||
progress.setStatus("所有图片上传完成..."); | |||||
progress.toggleCancel(false); | |||||
} | |||||
} catch (ex) { | |||||
this.debug(ex); | |||||
} | |||||
} | |||||
function uploadError(file, errorCode, message) { | |||||
var imageName = "error.gif"; | |||||
var progress; | |||||
try { | |||||
switch (errorCode) { | |||||
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: | |||||
try { | |||||
progress = new FileProgress(file, this.customSettings.upload_target); | |||||
progress.setCancelled(); | |||||
progress.setStatus("Cancelled"); | |||||
progress.toggleCancel(false); | |||||
} | |||||
catch (ex1) { | |||||
this.debug(ex1); | |||||
} | |||||
break; | |||||
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: | |||||
try { | |||||
progress = new FileProgress(file, this.customSettings.upload_target); | |||||
progress.setCancelled(); | |||||
progress.setStatus("Stopped"); | |||||
progress.toggleCancel(true); | |||||
} | |||||
catch (ex2) { | |||||
this.debug(ex2); | |||||
} | |||||
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: | |||||
imageName = "uploadlimit.gif"; | |||||
break; | |||||
default: | |||||
alert(message); | |||||
break; | |||||
} | |||||
addImage("images/" + imageName, 0); | |||||
} catch (ex3) { | |||||
this.debug(ex3); | |||||
} | |||||
} | |||||
var albImg = 0; | var albImg = 0; | ||||
function addImage(src, pid) { | function addImage(src, pid) { | ||||
var newImgDiv = document.createElement("div"); | var newImgDiv = document.createElement("div"); | ||||
@@ -154,78 +29,4 @@ function addImage(src, pid) { | |||||
} | } | ||||
} | } | ||||
newImgDiv.innerHTML += '<div style="margin-top:10px">名称:<input type="text" name="picinfo' + albImg + '" value="" style="width:' + iptwidth + 'px"></div>'; | newImgDiv.innerHTML += '<div style="margin-top:10px">名称:<input type="text" name="picinfo' + albImg + '" value="" style="width:' + iptwidth + 'px"></div>'; | ||||
} | |||||
/* ****************************************** | |||||
* FileProgress Object | |||||
* Control object for displaying file info | |||||
* ****************************************** */ | |||||
function FileProgress(file, targetID) { | |||||
this.fileProgressID = "divFileProgress"; | |||||
this.fileProgressWrapper = document.getElementById(this.fileProgressID); | |||||
if (!this.fileProgressWrapper) { | |||||
this.fileProgressWrapper = document.createElement("div"); | |||||
this.fileProgressWrapper.className = "progressWrapper"; | |||||
this.fileProgressWrapper.id = this.fileProgressID; | |||||
this.fileProgressElement = document.createElement("div"); | |||||
this.fileProgressElement.className = "progressContainer"; | |||||
var progressCancel = document.createElement("a"); | |||||
progressCancel.className = "progressCancel"; | |||||
progressCancel.href = "#"; | |||||
progressCancel.style.visibility = "hidden"; | |||||
progressCancel.appendChild(document.createTextNode(" ")); | |||||
var progressText = document.createElement("div"); | |||||
progressText.className = "progressName"; | |||||
progressText.appendChild(document.createTextNode(file.name)); | |||||
var progressBar = document.createElement("div"); | |||||
progressBar.className = "progressBarInProgress"; | |||||
var progressStatus = document.createElement("div"); | |||||
progressStatus.className = "progressBarStatus"; | |||||
progressStatus.innerHTML = " "; | |||||
this.fileProgressElement.appendChild(progressCancel); | |||||
this.fileProgressElement.appendChild(progressText); | |||||
this.fileProgressElement.appendChild(progressStatus); | |||||
this.fileProgressElement.appendChild(progressBar); | |||||
this.fileProgressWrapper.appendChild(this.fileProgressElement); | |||||
document.getElementById(targetID).appendChild(this.fileProgressWrapper); | |||||
} else { | |||||
this.fileProgressElement = this.fileProgressWrapper.firstChild; | |||||
this.fileProgressElement.childNodes[1].firstChild.nodeValue = file.name; | |||||
} | |||||
this.height = this.fileProgressWrapper.offsetHeight; | |||||
} | |||||
FileProgress.prototype.setProgress = function (percentage) { | |||||
this.fileProgressElement.className = "progressContainer blue"; | |||||
this.fileProgressElement.childNodes[3].className = "progressBarInProgress"; | |||||
this.fileProgressElement.childNodes[3].style.width = percentage + "%"; | |||||
}; | |||||
FileProgress.prototype.setComplete = function () { | |||||
this.fileProgressElement.className = "progressContainer green"; | |||||
this.fileProgressElement.childNodes[3].className = "progressBarComplete"; | |||||
this.fileProgressElement.childNodes[3].style.width = ""; | |||||
}; | |||||
FileProgress.prototype.setError = function () { | |||||
this.fileProgressElement.className = "progressContainer red"; | |||||
this.fileProgressElement.childNodes[3].className = "progressBarError"; | |||||
this.fileProgressElement.childNodes[3].style.width = ""; | |||||
}; | |||||
FileProgress.prototype.setCancelled = function () { | |||||
this.fileProgressElement.className = "progressContainer"; | |||||
this.fileProgressElement.childNodes[3].className = "progressBarError"; | |||||
this.fileProgressElement.childNodes[3].style.width = ""; | |||||
}; | |||||
FileProgress.prototype.setStatus = function (status) { | |||||
this.fileProgressElement.childNodes[2].innerHTML = status; | |||||
}; | |||||
FileProgress.prototype.toggleCancel = function (show, swfuploadInstance) { | |||||
this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden"; | |||||
if (swfuploadInstance) { | |||||
var fileID = this.fileProgressID; | |||||
this.fileProgressElement.childNodes[0].onclick = function () { | |||||
swfuploadInstance.cancelUpload(fileID); | |||||
return false; | |||||
}; | |||||
} | |||||
}; | |||||
} |
@@ -93,7 +93,7 @@ if (!function_exists('ImageResize')) { | |||||
} | } | ||||
imagedestroy($im); | imagedestroy($im); | ||||
return true; | return true; | ||||
} catch(Throwable $th) { | |||||
} catch (Throwable $th) { | |||||
return false; | return false; | ||||
} catch (Exception $e) { | } catch (Exception $e) { | ||||
return false; | return false; | ||||
@@ -141,8 +141,8 @@ if (!function_exists('gdversion')) { | |||||
if (!function_exists('WaterImg')) { | if (!function_exists('WaterImg')) { | ||||
function WaterImg($srcFile, $fromGo = 'up') | function WaterImg($srcFile, $fromGo = 'up') | ||||
{ | { | ||||
include(DEDEDATA.'/mark/inc_photowatermark_config.php'); | |||||
require_once(DEDEINC.'/image.class.php'); | |||||
include(DEDEDATA . '/mark/inc_photowatermark_config.php'); | |||||
require_once(DEDEINC . '/image.class.php'); | |||||
if (isset($GLOBALS['needwatermark'])) { | if (isset($GLOBALS['needwatermark'])) { | ||||
$photo_markup = $photo_markdown = empty($GLOBALS['needwatermark']) ? '0' : '1'; | $photo_markup = $photo_markdown = empty($GLOBALS['needwatermark']) ? '0' : '1'; | ||||
} | } | ||||
@@ -162,7 +162,7 @@ if (!function_exists('WaterImg')) { | |||||
if ($fromGo == 'down' && $photo_markdown == '0') { | if ($fromGo == 'down' && $photo_markdown == '0') { | ||||
return; | return; | ||||
} | } | ||||
$TRUEMarkimg = DEDEDATA.'/mark/'.$photo_markimg; | |||||
$TRUEMarkimg = DEDEDATA . '/mark/' . $photo_markimg; | |||||
if (!file_exists($TRUEMarkimg) || empty($photo_markimg)) { | if (!file_exists($TRUEMarkimg) || empty($photo_markimg)) { | ||||
$TRUEMarkimg = ""; | $TRUEMarkimg = ""; | ||||
} | } | ||||
@@ -171,8 +171,8 @@ if (!function_exists('WaterImg')) { | |||||
} | } | ||||
$cfg_watermarktext = array(); | $cfg_watermarktext = array(); | ||||
if ($photo_marktype == '2') { | if ($photo_marktype == '2') { | ||||
if (file_exists(DEDEDATA.'/mark/simhei.ttf')) { | |||||
$cfg_watermarktext['fontpath'] = DEDEDATA.'/mark/simhei.ttf'; | |||||
if (file_exists(DEDEDATA . '/mark/simhei.ttf')) { | |||||
$cfg_watermarktext['fontpath'] = DEDEDATA . '/mark/simhei.ttf'; | |||||
} else { | } else { | ||||
return; | return; | ||||
} | } | ||||
@@ -220,9 +220,17 @@ if (!function_exists('ImageResizeNew')) { | |||||
if (!$cfg_photo_type['png']) return FALSE; | if (!$cfg_photo_type['png']) return FALSE; | ||||
$img = imagecreatefrompng($srcFile); | $img = imagecreatefrompng($srcFile); | ||||
break; | break; | ||||
case 8: | |||||
if (!$cfg_photo_type['wbmp']) return FALSE; | |||||
$img = imagecreatefromwbmp($srcFile); | |||||
break; | |||||
case 6: | case 6: | ||||
if (!$cfg_photo_type['bmp']) return FALSE; | if (!$cfg_photo_type['bmp']) return FALSE; | ||||
$img = imagecreatefromwbmp($srcFile); | |||||
$img = imagecreatefrombmp($srcFile); | |||||
break; | |||||
case 18: | |||||
if (!$cfg_photo_type['webp']) return FALSE; | |||||
$img = imagecreatefromwebp($srcFile); | |||||
break; | break; | ||||
} | } | ||||
$width = imageSX($img); | $width = imageSX($img); | ||||
@@ -247,7 +255,7 @@ if (!function_exists('ImageResizeNew')) { | |||||
if ($new_width > $target_width) { | if ($new_width > $target_width) { | ||||
$new_height = $target_width; | $new_height = $target_width; | ||||
} | } | ||||
$new_img = ImageCreateTrueColor($target_width, $target_height); | |||||
$new_img = imagecreatetruecolor($target_width, $target_height); | |||||
$alpha = imagecolorallocatealpha($new_img, 0, 0, 0, 127); | $alpha = imagecolorallocatealpha($new_img, 0, 0, 0, 127); | ||||
imagefill($new_img, 0, 0, $alpha); | imagefill($new_img, 0, 0, $alpha); | ||||
imagealphablending($new_img, true); | imagealphablending($new_img, true); | ||||
@@ -275,6 +283,9 @@ if (!function_exists('ImageResizeNew')) { | |||||
case 6: | case 6: | ||||
imagebmp($new_img, $toFile); | imagebmp($new_img, $toFile); | ||||
break; | break; | ||||
case 18: | |||||
imagewebp($new_img, $toFile); | |||||
break; | |||||
default: | default: | ||||
return FALSE; | return FALSE; | ||||
} | } | ||||
@@ -294,6 +305,9 @@ if (!function_exists('ImageResizeNew')) { | |||||
case 6: | case 6: | ||||
imagebmp($new_img); | imagebmp($new_img); | ||||
break; | break; | ||||
case 18: | |||||
imagewebp($new_img); | |||||
break; | |||||
default: | default: | ||||
return FALSE; | return FALSE; | ||||
} | } | ||||
@@ -302,4 +316,4 @@ if (!function_exists('ImageResizeNew')) { | |||||
imagedestroy($img); | imagedestroy($img); | ||||
return TRUE; | return TRUE; | ||||
} | } | ||||
} | |||||
} |
@@ -16,6 +16,8 @@ $cfg_photo_type['gif'] = FALSE; | |||||
$cfg_photo_type['jpeg'] = FALSE; | $cfg_photo_type['jpeg'] = FALSE; | ||||
$cfg_photo_type['png'] = FALSE; | $cfg_photo_type['png'] = FALSE; | ||||
$cfg_photo_type['wbmp'] = FALSE; | $cfg_photo_type['wbmp'] = FALSE; | ||||
$cfg_photo_type['bmp'] = FALSE; | |||||
$cfg_photo_type['webp'] = FALSE; | |||||
$cfg_photo_typenames = array(); | $cfg_photo_typenames = array(); | ||||
$cfg_photo_support = ''; | $cfg_photo_support = ''; | ||||
if (function_exists("imagecreatefromgif") && function_exists("imagegif")) { | if (function_exists("imagecreatefromgif") && function_exists("imagegif")) { | ||||
@@ -40,5 +42,15 @@ if (function_exists("imagecreatefromwbmp") && function_exists("imagewbmp")) { | |||||
$cfg_photo_typenames[] = "image/wbmp"; | $cfg_photo_typenames[] = "image/wbmp"; | ||||
$cfg_photo_support .= "WBMP "; | $cfg_photo_support .= "WBMP "; | ||||
} | } | ||||
if (function_exists("imagecreatefrombmp") && function_exists("imagebmp")) { | |||||
$cfg_photo_type["bmp"] = TRUE; | |||||
$cfg_photo_typenames[] = "image/bmp"; | |||||
$cfg_photo_support .= "BMP "; | |||||
} | |||||
if (function_exists("imagecreatefromwebp") && function_exists("imagewebp")) { | |||||
$cfg_photo_type["webp"] = TRUE; | |||||
$cfg_photo_typenames[] = "image/webp"; | |||||
$cfg_photo_support .= "WEBP "; | |||||
} | |||||
//引入图像处理小助手 | //引入图像处理小助手 | ||||
helper('image'); | helper('image'); |