예제 #1
0
function gethumb($sfp, $w = '', $h = '', $tdir = false, $scale = true, $callback = false)
{
    global $iCMS;
    if (strpos($sfp, 'thumb/') !== false) {
        return $sfp;
    }
    $info = pathinfo($sfp);
    $tpf = $info['dirname'] . '/thumb/' . $info['filename'] . '_';
    if ($callback) {
        $rootpf = uploadpath($tpf, '+iPATH');
        $tfArray = glob($rootpf . "*");
        if ($tfArray) {
            foreach ($tfArray as $_tfp) {
                if (file_exists($_tfp)) {
                    $fn = substr($_tfp, 0, strrpos($_tfp, '.'));
                    $per = substr($fn, strrpos($fn, '_') + 1);
                    $tfpList[$per] = uploadpath($_tfp, '-iPATH');
                }
            }
        }
        return $tfpList;
    } else {
        $srfp = uploadpath($sfp, 'http2iPATH');
        $tdir && ($tpf = $tdir . '/' . $info['filename'] . '_');
        $rootpf = uploadpath($tpf, 'http2iPATH');
        if (file_exists($srfp)) {
            empty($w) && ($w = $iCMS->config['thumbwidth']);
            empty($h) && ($h = $iCMS->config['thumbhight']);
            $twh = $rootpf . $w . 'x' . $h . '.' . FS::getext($sfp);
            if (file_exists($twh)) {
                return uploadpath($twh, 'iPATH2http');
            } else {
                if ($iCMS->config['issmall']) {
                    require_once iPATH . 'include/upload.class.php';
                    $Thumb = iUpload::thumbnail(dirname($tdir ? $rootpf : $srfp) . '/', $srfp, $info['filename'], $w, $h, $scale, $tdir ? '' : 'thumb');
                    return uploadpath($Thumb['src'], 'iPATH2http');
                } else {
                    return $sfp;
                }
            }
        } else {
            return $iCMS->config['uploadURL'] . '/nopic.gif';
        }
    }
}