Esempio n. 1
0
 public function getThumb($path, $width, $height, $original = false)
 {
     global $_G;
     //$path:可能的值 icoid,'dzz::dzz/201401/02/wrwsdfsdfasdsf.txt'等dzzPath格式;
     if (is_numeric($path)) {
         $data = C::t('icos')->fetch_by_icoid($path);
         $bz = io_remote::getBzByRemoteid($data['remote']);
         if ($bz != 'dzz') {
             $path = $bz . '/' . $data['attachment'];
             IO::getThumb($path, $width, $height, $original, $imgshow);
             exit;
         }
     } else {
         if (strpos($path, 'attach::') === 0) {
             $data = C::t('attachment')->fetch(intval(str_replace('attach::', '', $path)));
             $bz = io_remote::getBzByRemoteid($data['remote']);
             if ($bz != 'dzz') {
                 IO::getThumb($bz . '/' . $data['attachment'], $width, $height, $original);
                 exit;
             }
         } elseif (strpos($path, 'dzz::') === 0) {
             $data = array('attachment' => str_replace('dzz::', '', $path));
         } else {
             IO::getThumb($path, $width, $height, $original);
             exit;
         }
     }
     $enable_cache = true;
     //是否启用缓存
     $quality = 80;
     $imgcachePath = 'imgcache/';
     $cachepath = str_replace('//', '/', str_replace(':', '/', $data['attachment']));
     $imginfo = @getimagesize($_G['setting']['attachdir'] . './' . $data['attachment']);
     if ($original) {
         @header("Content-Type: " . image_type_to_mime_type($imginfo[2]));
         @ob_end_clean();
         if (getglobal('gzipcompress')) {
             @ob_start('ob_gzhandler');
         }
         @readfile($_G['setting']['attachdir'] . './' . $data['attachment']);
         @flush();
         @ob_flush();
         exit;
     }
     if ($imginfo[0] < $width && $imginfo[1] < $height) {
         header("Content-Type: " . image_type_to_mime_type($imginfo[2]));
         @ob_end_clean();
         if (getglobal('gzipcompress')) {
             @ob_start('ob_gzhandler');
         }
         @readfile($_G['setting']['attachdir'] . './' . $data['attachment']);
         @flush();
         @ob_flush();
         exit;
     }
     $target = $imgcachePath . $cachepath . '.' . $width . '_' . $height . '.jpeg';
     if ($enable_cache && @getimagesize($_G['setting']['attachdir'] . $target)) {
         header('Content-Type: image/JPEG');
         @ob_end_clean();
         if (getglobal('gzipcompress')) {
             @ob_start('ob_gzhandler');
         }
         @readfile($_G['setting']['attachdir'] . $target);
         @flush();
         @ob_flush();
         exit;
     }
     //获取缩略图
     include_once libfile('class/image');
     $target_attach = $_G['setting']['attachdir'] . $target;
     $targetpath = dirname($target_attach);
     dmkdir($targetpath);
     $image = new image();
     if ($thumb = $image->Thumb($_G['setting']['attachdir'] . './' . $data['attachment'], $target, $width, $height, 1)) {
         header('Content-Type: image/JPEG');
         @ob_end_clean();
         if (getglobal('gzipcompress')) {
             @ob_start('ob_gzhandler');
         }
         @readfile($_G['setting']['attachdir'] . $target);
         @flush();
         @ob_flush();
     } else {
         header("Content-Type: " . image_type_to_mime_type($imginfo[2]));
         @ob_end_clean();
         if (getglobal('gzipcompress')) {
             @ob_start('ob_gzhandler');
         }
         @readfile($_G['setting']['attachdir'] . './' . $data['attachment']);
         @flush();
         @ob_flush();
     }
     exit;
 }
Esempio n. 2
0
<?php

/*
 * @copyright   Leyun internet Technology(Shanghai)Co.,Ltd
 * @license     http://www.dzzoffice.com/licenses/license.txt
 * @package     DzzOffice
 * @link        http://www.dzzoffice.com
 * @author      zyx(zyx@dzz.cc)
 */
$path = dzzdecode(urldecode($_GET['path']));
$width = intval($_GET['width']);
$height = intval($_GET['height']);
$original = intval($_GET['original']);
IO::getThumb($path, $width, $height, $original);