底部黑条水印 仿铁血黑条水印 无错修正版 [复制链接]
7
0
底部黑条 修改文件版
- <?php
- /**
- * [Discuz!] (C)2001-2099 Comsenz Inc.
- * This is NOT a freeware, use is subject to license terms
- *
- * $Id: class_image.php 36349 2017-01-16 03:05:23Z nemohou $
- */
- if(!defined('IN_DISCUZ')) {
- exit('Access Denied');
- }
- class image {
- var $source = '';
- var $target = '';
- var $imginfo = array();
- var $imagecreatefromfunc = '';
- var $imagefunc = '';
- var $tmpfile = '';
- var $libmethod = 0;
- var $param = array();
- var $errorcode = 0;
- var $extension = array();
- function __construct() {
- global $_G;
- $this->extension['gd'] = extension_loaded('gd');
- $this->extension['imagick'] = extension_loaded('imagick');
- $this->param = array(
- 'imagelib' => $_G['setting']['imagelib'],
- 'imageimpath' => $_G['setting']['imageimpath'],
- 'thumbquality' => $_G['setting']['thumbquality'],
- 'watermarkstatus' => dunserialize($_G['setting']['watermarkstatus']),
- 'watermarkminwidth' => dunserialize($_G['setting']['watermarkminwidth']),
- 'watermarkminheight' => dunserialize($_G['setting']['watermarkminheight']),
- 'watermarktype' => $_G['setting']['watermarktype'],
- 'watermarktext' => $_G['setting']['watermarktext'],
- 'watermarktrans' => dunserialize($_G['setting']['watermarktrans']),
- 'watermarkquality' => dunserialize($_G['setting']['watermarkquality']),
- );
- }
- function Thumb($source, $target, $thumbwidth, $thumbheight, $thumbtype = 1, $nosuffix = 0) {
- $return = $this->init('thumb', $source, $target, $nosuffix);
- if($return <= 0) {
- return $this->returncode($return);
- }
- if($this->imginfo['animated']) {
- return $this->returncode(0);
- }
- $this->param['thumbwidth'] = intval($thumbwidth);
- if(!$thumbheight || $thumbheight > $this->imginfo['height']) {
- $thumbheight = $thumbwidth > $this->imginfo['width'] ? $this->imginfo['height'] : $this->imginfo['height']*($thumbwidth/$this->imginfo['width']);
- }
- $this->param['thumbheight'] = intval($thumbheight);
- $this->param['thumbtype'] = $thumbtype;
- if($thumbwidth < 100 && $thumbheight < 100) {
- $this->param['thumbquality'] = 100;
- }
- $return = !$this->libmethod ? $this->Thumb_GD() : $this->Thumb_IM();
- $return = !$nosuffix ? $return : 0;
- return $this->sleep($return);
- }
- function Cropper($source, $target, $dstwidth, $dstheight, $srcx = 0, $srcy = 0, $srcwidth = 0, $srcheight = 0) {
- $return = $this->init('thumb', $source, $target, 1);
- if($return <= 0) {
- return $this->returncode($return);
- }
- if($dstwidth < 0 || $dstheight < 0) {
- return $this->returncode(false);
- }
- $this->param['dstwidth'] = intval($dstwidth);
- $this->param['dstheight'] = intval($dstheight);
- $this->param['srcx'] = intval($srcx);
- $this->param['srcy'] = intval($srcy);
- $this->param['srcwidth'] = intval($srcwidth ? $srcwidth : $dstwidth);
- $this->param['srcheight'] = intval($srcheight ? $srcheight : $dstheight);
- $return = !$this->libmethod ? $this->Cropper_GD() : $this->Cropper_IM();
- }
- function Watermark($source, $target = '', $type = 'forum') {
- $return = $this->init('watermask', $source, $target);
- if($return <= 0) {
- return $this->returncode($return);
- }
- if(!$this->param['watermarkstatus'][$type] || ($this->param['watermarkminwidth'][$type] && $this->imginfo['width'] <= $this->param['watermarkminwidth'][$type] && $this->param['watermarkminheight'][$type] && $this->imginfo['height'] <= $this->param['watermarkminheight'][$type])) {
- return $this->returncode(0);
- }
- $this->param['watermarkfile'][$type] = './static/image/common/'.($this->param['watermarktype'][$type] == 'png' ? 'watermark.png' : 'watermark.gif');
- if(!is_readable($this->param['watermarkfile'][$type]) || ($this->param['watermarktype'][$type] == 'text' && (!file_exists($this->param['watermarktext']['fontpath'][$type]) || !is_file($this->param['watermarktext']['fontpath'][$type])))) {
- return $this->returncode(-3);
- }
- $return = !$this->libmethod ? $this->Watermark_GD($type) : $this->Watermark_IM($type);
- return $this->sleep($return);
- }
- function error() {
- return $this->errorcode;
- }
- function init($method, $source, $target, $nosuffix = 0) {
- global $_G;
- $this->errorcode = 0;
- if(empty($source)) {
- return -2;
- }
- $parse = parse_url($source);
- if(isset($parse['host'])) {
- if(empty($target)) {
- return -2;
- }
- $data = dfsockopen($source);
- $this->tmpfile = $source = tempnam($_G['setting']['attachdir'].'./temp/', 'tmpimg_');
- if(!$data || $source === FALSE) {
- return -2;
- }
- file_put_contents($source, $data);
- }
- if($method == 'thumb') {
- $target = empty($target) ? (!$nosuffix ? getimgthumbname($source) : $source) : $_G['setting']['attachdir'].'./'.$target;
- } elseif($method == 'watermask') {
- $target = empty($target) ? $source : $_G['setting']['attachdir'].'./'.$target;
- }
- $targetpath = dirname($target);
- dmkdir($targetpath);
- clearstatcache();
- if(!is_readable($source) || !is_writable($targetpath)) {
- return -2;
- }
- $imginfo = @getimagesize($source);
- if($imginfo === FALSE) {
- return -1;
- }
- $this->source = $source;
- $this->target = $target;
- $this->imginfo['width'] = $imginfo[0];
- $this->imginfo['height'] = $imginfo[1];
- $this->imginfo['mime'] = $imginfo['mime'];
- $this->imginfo['size'] = @filesize($source);
- $this->libmethod = $this->param['imagelib'];
- if(!$this->param['imagelib'] && $this->extension['gd']) {
- $this->libmethod = 0;
-
历史资源提醒--必看
该页面资源/教程来自原魔趣吧历史资源转移,因发布历史久远,部分资源/教程可能已失效或无法在最新版程序中安装使用!DZ资源建议在Discuz3.4及以下版本使用,PHP版本建议5.6。资源仅提供做代码研究学习使用!
因改版,部分贴内链接将无法正常跳转,如链接失效或未正常跳转,请利用站内搜索功能搜索资源名称获取对应资源!
最新回复 (0)