fixbugs add TimThumb
							parent
							
								
									5655c2034b
								
							
						
					
					
						commit
						af21e879f9
					
				| 
						 | 
				
			
			@ -97,9 +97,13 @@ $HTTP["url"] =~ "^/(i|public)/" {
 | 
			
		|||
 - 或者参考:[https://blog.png.cm/996.html](https://blog.png.cm/996.html)
 | 
			
		||||
 | 
			
		||||
<details><summary><mark><font color=darkred>点击查看2.0版更新日志</font></mark></summary>
 | 
			
		||||
* 2022-1-28 v2.4.8
 | 
			
		||||
 | 
			
		||||
* 2022-1-28 v2.4.8 dev
 | 
			
		||||
- 修复无可疑图片时显示错误
 | 
			
		||||
- 修复开启登录上传后无法上传的bug
 | 
			
		||||
- 增加安装时检测.user.ini
 | 
			
		||||
- 增加WordPress上大名鼎鼎的实时缩略图生成TimThumb
 | 
			
		||||
- TimeThumb为本图床修改版,会缓存到缓存文件夹方便下次调用
 | 
			
		||||
 | 
			
		||||
* 2022-1-27 v2.4.7
 | 
			
		||||
- 优化页面排版
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -555,8 +555,8 @@ if (isset($_GET['reimg'])) {
 | 
			
		|||
                        <tbody>
 | 
			
		||||
                            <?php
 | 
			
		||||
                            // 获取被隔离的文件
 | 
			
		||||
                            @$cache_dir = APP_ROOT . $config['path'] . 'suspic/';                               // cache目录
 | 
			
		||||
                            @$cache_file = getFile($cache_dir);                                                 // 获取所有文件
 | 
			
		||||
                            $cache_dir = APP_ROOT . $config['path'] . 'suspic/';                               // cache目录
 | 
			
		||||
                            $cache_file = get_file_by_glob($cache_dir . '*.*');                                   // 获取所有文件
 | 
			
		||||
                            @$cache_num = count($cache_file);                                                   // 统计目录文件个数
 | 
			
		||||
                            for ($i = 0; $i < $cache_num and $i < 21; $i++) {                                   // 循环输出文件
 | 
			
		||||
                                $file_cache_path = APP_ROOT . $config['path'] . 'suspic/' . $cache_file[$i];    // 图片绝对路径
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -113,7 +113,7 @@ if ($handle->uploaded) {
 | 
			
		|||
            "result" => "success",
 | 
			
		||||
            "code"   => 200,
 | 
			
		||||
            "url"    => $imageUrl,
 | 
			
		||||
            "thumb"  => $config['domain'] . '/application/thumb.php?img=' . config_path() . $handle->file_dst_name . '&width=258&height=258',
 | 
			
		||||
            "thumb"  => $config['domain'] . '/application/thumb.php?img=' . config_path() . $handle->file_dst_name,
 | 
			
		||||
            "del"    => $delUrl,
 | 
			
		||||
        );
 | 
			
		||||
        echo json_encode($reJson, JSON_UNESCAPED_UNICODE);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -93,6 +93,7 @@ function config_path($path = null)
 | 
			
		|||
    if (!is_writable($img_path)) {
 | 
			
		||||
        @chmod($img_path, 0755);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    return $img_path;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -671,15 +672,15 @@ function creat_thumbnail_images($imgName)
 | 
			
		|||
    require_once __DIR__ . '/class.thumb.php';
 | 
			
		||||
    global $config;
 | 
			
		||||
 | 
			
		||||
    $old_img_path = APP_ROOT . config_path() . $imgName;                                                   // 获取要创建缩略图文件的绝对路径
 | 
			
		||||
    $cache_path = APP_ROOT . $config['path'] . 'thumbnails/';                                                   // cache目录的绝对路径
 | 
			
		||||
    $old_img_path = APP_ROOT . config_path() . $imgName;                                               // 获取要创建缩略图文件的绝对路径
 | 
			
		||||
    $cache_path = APP_ROOT . $config['path'] . 'thumbnails/';                                          // cache目录的绝对路径
 | 
			
		||||
 | 
			
		||||
    if (!is_dir($cache_path)) {                                                                              // 创建cache目录
 | 
			
		||||
    if (!is_dir($cache_path)) {                                                                        // 创建cache目录
 | 
			
		||||
        mkdir($cache_path, 0777, true);
 | 
			
		||||
    }
 | 
			
		||||
    if (!isAnimatedGif($old_img_path)) {                                                                   // 仅针对非gif创建图片缩略图
 | 
			
		||||
    if (!isAnimatedGif($old_img_path)) {                                                               // 仅针对非gif创建图片缩略图
 | 
			
		||||
        $new_imgName = APP_ROOT . $config['path'] . 'thumbnails/' . date('Y_m_d') . '_' . $imgName;    // 缩略图缓存的绝对路径
 | 
			
		||||
        Thumb::out($old_img_path, $new_imgName, 258, 258);                                    // 保存缩略图
 | 
			
		||||
        Thumb::out($old_img_path, $new_imgName, 258, 258);                                             // 保存缩略图
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -693,16 +694,16 @@ function return_thumbnail_images($url)
 | 
			
		|||
    global $config;
 | 
			
		||||
    $cache_image_file = str_replace($config['imgurl'], '', $url);
 | 
			
		||||
 | 
			
		||||
    if (isAnimatedGif(APP_ROOT . $cache_image_file)) {                            // 仅读取非gif的缩略图
 | 
			
		||||
        return $url;                                                                    // 如果是gif则直接返回url
 | 
			
		||||
    if (isAnimatedGif(APP_ROOT . $cache_image_file)) {                                      // 仅读取非gif的缩略图
 | 
			
		||||
        return $url;                                                                        // 如果是gif则直接返回url
 | 
			
		||||
    } else {
 | 
			
		||||
        $cache_image_file = str_replace($config['path'], '', $cache_image_file); // 将网址中的/i/去除
 | 
			
		||||
        $cache_image_file = str_replace('/', '_', $cache_image_file);        // 将文件的/转换为_
 | 
			
		||||
        $isFile = APP_ROOT . $config['path'] . 'thumbnails/' . $cache_image_file;            // 缓存文件的绝对路径
 | 
			
		||||
        if (file_exists($isFile)) {                                                    // 缓存文件是否存在
 | 
			
		||||
        $cache_image_file = str_replace($config['path'], '', $cache_image_file);            // 将网址中的/i/去除
 | 
			
		||||
        $cache_image_file = str_replace('/', '_', $cache_image_file);                       // 将文件的/转换为_
 | 
			
		||||
        $isFile = APP_ROOT . $config['path'] . 'thumbnails/' . $cache_image_file;           // 缓存文件的绝对路径
 | 
			
		||||
        if (file_exists($isFile)) {                                                         // 缓存文件是否存在
 | 
			
		||||
            return $config['imgurl'] . $config['path'] . 'thumbnails/' . $cache_image_file; // 存在则返回缓存文件
 | 
			
		||||
        } else {
 | 
			
		||||
            return $url;                                                                // 不存在直接返回url
 | 
			
		||||
            return $url;                                                                    // 不存在直接返回url
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -717,7 +718,7 @@ function get_online_thumbnail($imgUrl)
 | 
			
		|||
    global $config;
 | 
			
		||||
    if ($config['thumbnail']) {
 | 
			
		||||
        $imgUrl = str_replace($config['imgurl'], '', $imgUrl);
 | 
			
		||||
        return $config['domain'] . '/application/thumb.php?img=' . $imgUrl . '&width=258&height=258';
 | 
			
		||||
        return $config['domain'] . '/application/thumb.php?img=' . $imgUrl;
 | 
			
		||||
    } else {
 | 
			
		||||
        return $imgUrl;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
<?php
 | 
			
		||||
/*
 | 
			
		||||
// +----------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
// | 把大图缩略到缩略图指定的范围内,不留白(原图会剪切掉不符合比例的右边和下边)
 | 
			
		||||
| 
						 | 
				
			
			@ -21,3 +22,63 @@ $w = isset($_GET['width']) ? $_GET['width'] : 258; // 预生成缩略图的宽
 | 
			
		|||
$h = isset($_GET['height']) ? $_GET['height'] : 258; // 预生成缩略图的高
 | 
			
		||||
 | 
			
		||||
Thumb::show($src, $w, $h);
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 使用新的TimThumb.php生成缩略图
 | 
			
		||||
 * TimThumb.php EasyImage修改版 by Icret
 | 
			
		||||
 * form https://github.com/podipod/TimThumb
 | 
			
		||||
 * 2022-1-30 06:35:08
 | 
			
		||||
 *
 | 
			
		||||
 * TimThumb参数指南
 | 
			
		||||
 * 命令	作用		参数				描述
 | 
			
		||||
 * src	源		图像URL			告诉TimThumb调整哪个图片
 | 
			
		||||
 * w	宽度		宽度调整			调整输出图像的宽度
 | 
			
		||||
 * h	高度		高度调整			调整输出图像的高度
 | 
			
		||||
 * q	质量		0 - 100			压缩质量,值越大质量越高。不建议高于95
 | 
			
		||||
 * a	对齐	    c, t, l, r, b, tl, tr, bl, br	图像对齐。 c = center, t = top, b = bottom, r = right, l = left。 可以创建对角位置
 | 
			
		||||
 * zc	缩放/裁剪	0、1、2、3	0:根据传入的值进行缩放(不裁剪), 1:以最合适的比例裁剪和调整大小(裁剪), 2:按比例调整大小,并添加边框(裁剪),3:按比例调整大小,不添加边框(裁剪)
 | 
			
		||||
 * f	过滤器	太多了			可以改变亮度/对比度;甚至模糊图像
 | 
			
		||||
 * s	锐化		锐化				使得按比例缩小图片看起来有点;更清晰
 | 
			
		||||
 * cc	画布上的颜色	十六进制的颜色值(# ffffff)	改变背景颜色。 大多数更改缩放和作物设置时使用,进而可以添加图像边界。
 | 
			
		||||
 * ct	画布的透明度	true (1)	使用透明而忽略背景颜色
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
require_once __DIR__ . '/function.php';
 | 
			
		||||
define('LOCAL_FILE_BASE_DIRECTORY', APP_ROOT);
 | 
			
		||||
define('DEFAULT_WIDTH', 258);
 | 
			
		||||
define('DEFAULT_HEIGHT', 258);
 | 
			
		||||
define('FILE_CACHE_PREFIX', 'EasyImage');
 | 
			
		||||
define('DEFAULT_ZC', 0);
 | 
			
		||||
define('MAX_WIDTH', 10240);
 | 
			
		||||
define('MAX_HEIGHT', 10240);
 | 
			
		||||
define('FILE_CACHE_DIRECTORY', APP_ROOT . $config['path'] . 'thumbnails');
 | 
			
		||||
define('NOT_FOUND_IMAGE', '../public/images/404.png');
 | 
			
		||||
define('ERROR_IMAGE', '无法生成缩略图');
 | 
			
		||||
define('DISPLAY_ERROR_MESSAGES', false);
 | 
			
		||||
define('MAX_FILE_SIZE', 10485760);      // 10 Megs 是 10485760。这是我们将处理的最大内部或外部文件大小。
 | 
			
		||||
define('FILE_CACHE_TIME_BETWEEN_CLEANS', 86400); // 多久清理一次缓存
 | 
			
		||||
define('FILE_CACHE_MAX_FILE_AGE', 86400);    // 文件必须从缓存中删除多长时间
 | 
			
		||||
define('BROWSER_CACHE_MAX_AGE', 864000);    // 浏览器缓存时间
 | 
			
		||||
 | 
			
		||||
global $ALLOWED_SITES;
 | 
			
		||||
$ALLOWED_SITES = array(
 | 
			
		||||
    $config['domain'],
 | 
			
		||||
    $config['imgurl'],
 | 
			
		||||
    'flickr.com',
 | 
			
		||||
    'staticflickr.com',
 | 
			
		||||
    'picasa.com',
 | 
			
		||||
    'img.youtube.com',
 | 
			
		||||
    'upload.wikimedia.org',
 | 
			
		||||
    'photobucket.com',
 | 
			
		||||
    'imgur.com',
 | 
			
		||||
    'imageshack.us',
 | 
			
		||||
    'tinypic.com',
 | 
			
		||||
    'mind.sh',
 | 
			
		||||
    'mindsharelabs.com',
 | 
			
		||||
    'mindsharestudios.com'
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
require_once __DIR__ . '/TimThumb.php';
 | 
			
		||||
timthumb::start();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ $config=Array
 | 
			
		|||
	'extensions'=>'gif,jpeg,png,tif,bmp,tif,svg,webp,jpg,tga,svg,ico',
 | 
			
		||||
	'compress'=>0,
 | 
			
		||||
	'compress_ratio'=>80,
 | 
			
		||||
	'thumbnail'=>2,
 | 
			
		||||
	'thumbnail'=>1,
 | 
			
		||||
	'imgConvert'=>'',
 | 
			
		||||
	'maxWidth'=>10240,
 | 
			
		||||
	'maxHeight'=>10240,
 | 
			
		||||
| 
						 | 
				
			
			@ -81,5 +81,5 @@ var _hmt = _hmt || [];
 | 
			
		|||
	'check_ip_model'=>0,
 | 
			
		||||
	'check_ip_list'=>'',
 | 
			
		||||
	'version'=>'2.4.7',
 | 
			
		||||
	'form'=>'2022-01-29 20:37:05'
 | 
			
		||||
	'form'=>'2022-01-30 06:34:23'
 | 
			
		||||
	);
 | 
			
		||||
		Loading…
	
		Reference in New Issue