Пример #1
0
 function thumb($url = '', $source = '', $name = '', $type = -1, $width = 0, $height = 0)
 {
     //如何生成不成功,则返回原url
     global $cms_abs, $cmsurl, $ftp_url, $atm_smallsite;
     if (!$url || !$source || !$name || !$width || !$height) {
         return $url;
     }
     include_once M_ROOT . "./include/upload.cls.php";
     if ($ftp_url && preg_match(u_regcode($ftp_url), $url)) {
         //ftp上的文件
         include_once M_ROOT . "./include/http.cls.php";
         include_once M_ROOT . "./include/ftp.fun.php";
         //下载原图
         $tempfile = M_ROOT . './dynamic/imcache/' . basename($url);
         mmkdir($tempfile, 0, 1);
         $m_http = new http();
         $m_http->savetofile($url, $tempfile);
         unset($m_http);
         //生成缩略图
         $m_upload = new cls_upload();
         $m_upload->image_resize($tempfile, $width, $height, $tempfile . '.s.jpg');
         @unlink($tempfile);
         unset($m_upload);
         //上传缩略图
         $ftpfile = preg_replace(u_regcode($ftp_url), '', $url) . 's/' . $width . '_' . $height . '.jpg';
         //根据url得到缩略上传到的位置
         $tempfile .= '.s.jpg';
         if (ftp_upload($tempfile, $ftpfile)) {
             $this->refresh_record($source, $name, $type, $width, $height);
             //将缩略图规格写入数据库
             return $url . 's/' . $width . '_' . $height . '.jpg';
         } else {
             return $url;
         }
         @unlink($tempfile);
     } else {
         //本地服务器上的文件
         $m_upload = new cls_upload();
         $localfile = local_atm($url);
         $m_upload->image_resize($localfile, $width, $height, $localfile . 's/' . $width . '_' . $height . '.jpg');
         unset($m_upload);
         return $url . 's/' . $width . '_' . $height . '.jpg';
     }
 }
Пример #2
0
function islocal($url, $isatm = 0)
{
    //$isatm为0-非附件,1-ftp附件算本地,2-ftp附件不算本地
    global $cms_abs, $ftp_url, $atm_smallsite;
    if (strpos($url, '://') === false) {
        return true;
    }
    if (preg_match(u_regcode($cms_abs), $url)) {
        return true;
    }
    if ($isatm && $atm_smallsite && preg_match(u_regcode($atm_smallsite), $url)) {
        return true;
    }
    if ($ftp_url && $isatm == 1 && preg_match(u_regcode($ftp_url), $url)) {
        return true;
    }
    return false;
}