function zoom($picfile, $dstW = 200, $dstH = 200, $bgcolor = null, $iszoom = 1) { if (empty($picfile)) { return false; } include admin_ROOT . 'datacache/command.php'; require_once 'ectemplates_image.php'; $bgcolor = empty($bgcolor) || !preg_match("/^#[a-zA-Z0-9]{3,6}\$/i", $bgcolor) ? !preg_match("/^#[a-zA-Z0-9]{3,6}\$/i", $CONFIG['img_bgcolor']) ? '#ffffff' : $CONFIG['img_bgcolor'] : $bgcolor; $nowpicname = $picfile; $picfile = admin_ROOT . $picfile; $picfile = $this->picpath($picfile); if (!file_exists($picfile) && !is_file($picfile)) { return false; } $mime = $this->getMimeType($picfile); $newsfilepathname = $this->cache_pic . $dstW . '_' . $dstH . '_' . md5($nowpicname . $bgcolor) . '.' . $mime; if (is_file($newsfilepathname)) { $newpicname = $this->picpathformat(basename($newsfilepathname)); return $newpicname; } $imagescreat = new ectemplates_image(); $newpicname = $imagescreat->imagecreat($dstW, $dstH, $bgcolor, $picfile, $newsfilepathname, $iszoom); return $this->picpathformat($newpicname); }
function in_zoom() { include_once admin_ROOT . 'public/ectemplates/ectemplates_image.php'; parent::start_pagetemplate(); $lng = admin_LNG == 'big5' ? $this->CON['is_lancode'] : admin_LNG; $filename = $this->fun->accept('filename', 'G'); if (empty($filename)) { return false; } $w = intval($this->fun->accept('w', 'G')); $h = intval($this->fun->accept('h', 'G')); $width = empty($w) ? 200 : $w; $height = empty($h) ? 200 : $h; $iszoom = intval($this->fun->accept('iszoom', 'G')); $bgcolor = $this->fun->accept('bgcolor', 'G'); $bgcolor = empty($bgcolor) || !preg_match("/^#[a-zA-Z0-9]{3,6}\$/i", $bgcolor) ? !preg_match("/^#[a-zA-Z0-9]{3,6}\$/i", $this->CON['img_bgcolor']) ? '#ffffff' : $this->CON['img_bgcolor'] : $bgcolor; $picfile = admin_ROOT . $filename; $picfile = $this->picpath($picfile); if (!file_exists($picfile) && !is_file($picfile)) { return false; } $mime = $this->getMimeType($picfile); $imageinfo = getimagesize($picfile); if (!$imageinfo) { return false; } $newsfilepathname = $this->pagetemplate->cache_pic . $width . '_' . $height . '_' . md5($filename . $bgcolor) . '.' . $mime; if (!is_file($newsfilepathname)) { $imagescreat = new ectemplates_image(); $imagescreat->imagecreat($width, $height, $bgcolor, $picfile, $newsfilepathname, $iszoom); } $imgdata = fread(fopen($newsfilepathname, 'rb'), filesize($newsfilepathname)); header("content-type:{$imageinfo['mime']}"); echo $imgdata; }