Beispiel #1
0
 function global_header()
 {
     global $_G;
     //防盗链 token 写入用户网站的一级域名
     $cookie_domain = substr($_SERVER['SERVER_NAME'], strpos($_SERVER['SERVER_NAME'], '.'));
     setcookie('_upt', upyun_gen_sign(), $_SERVER['REQUEST_TIME'] + 180, '/', $cookie_domain);
 }
Beispiel #2
0
function setthreadcover($pid, $tid = 0, $aid = 0, $countimg = 0, $imgurl = '')
{
    global $_G;
    $cover = 0;
    if (empty($_G['uid']) || !intval($_G['setting']['forumpicstyle']['thumbheight']) || !intval($_G['setting']['forumpicstyle']['thumbwidth'])) {
        return false;
    }
    if (($pid || $aid) && empty($countimg)) {
        if (empty($imgurl)) {
            if ($aid) {
                $attachtable = 'aid:' . $aid;
                $attach = C::t('forum_attachment_n')->fetch('aid:' . $aid, $aid, array(1, -1));
            } else {
                $attachtable = 'pid:' . $pid;
                $attach = C::t('forum_attachment_n')->fetch_max_image('pid:' . $pid, 'pid', $pid);
            }
            if (!$attach) {
                return false;
            }
            if (empty($_G['forum']['ismoderator']) && $_G['uid'] != $attach['uid']) {
                return false;
            }
            $pid = empty($pid) ? $attach['pid'] : $pid;
            $tid = empty($tid) ? $attach['tid'] : $tid;
            $sign = upyun_gen_sign('/forum/' . $attach['attachment']);
            $picsource = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/' . $attach['attachment'] . '?_upt=' . $sign;
        } else {
            $attachtable = 'pid:' . $pid;
            $picsource = $imgurl;
        }
        $basedir = !$_G['setting']['attachdir'] ? DISCUZ_ROOT . './data/attachment/' : $_G['setting']['attachdir'];
        $coverdir = 'threadcover/' . substr(md5($tid), 0, 2) . '/' . substr(md5($tid), 2, 2) . '/';
        dmkdir($basedir . './forum/' . $coverdir);
        require_once libfile('class/image');
        $image = new image();
        if ($image->Thumb($picsource, 'forum/' . $coverdir . $tid . '.jpg', $_G['setting']['forumpicstyle']['thumbwidth'], $_G['setting']['forumpicstyle']['thumbheight'], 2)) {
            $remote = '';
            if (getglobal('setting/ftp/on')) {
                if (ftpcmd('upload', 'forum/' . $coverdir . $tid . '.jpg')) {
                    $remote = '-';
                }
            }
            $cover = C::t('forum_attachment_n')->count_image_by_id($attachtable, 'pid', $pid);
            if ($imgurl && empty($cover)) {
                $cover = 1;
            }
            $cover = $remote . $cover;
        } else {
            return false;
        }
    }
    if ($countimg) {
        if (empty($cover)) {
            $thread = C::t('forum_thread')->fetch($tid);
            $oldcover = $thread['cover'];
            $cover = C::t('forum_attachment_n')->count_image_by_id('tid:' . $tid, 'pid', $pid);
            if ($cover) {
                $cover = $oldcover < 0 ? '-' . $cover : $cover;
            }
        }
    }
    if ($cover) {
        C::t('forum_thread')->update($tid, array('cover' => $cover));
        return true;
    }
}
Beispiel #3
0
function upyun_attachment_download($attach, $module)
{
    global $_G;
    $upyun_config = $_G['cache']['plugin']['upyun'];
    $url = rtrim($upyun_config['url'], '/') . "/{$module}/";
    if ($attach['remote'] && !$_G['setting']['ftp']['hideurl']) {
        if (strtolower(CHARSET) == 'gbk') {
            $attach['filename'] = urlencode(iconv('GBK', 'UTF-8', $attach['filename']));
        } elseif (strtolower(CHARSET) == 'big5') {
            $attach['filename'] = urlencode(iconv('BIG5', 'UTF-8', $attach['filename']));
        } else {
            $attach['filename'] = urlencode($attach['filename']);
        }
        $path = $module ? "/{$module}/{$attach['attachment']}" : $attach['attachment'];
        $sign = upyun_gen_sign($path);
        dheader('location:' . $url . $attach['attachment'] . "?_upd={$attach['filename']}" . ($sign ? '&_upt=' . $sign : ''));
    }
}
Beispiel #4
0
    if (file_exists($_G['setting']['attachdir'] . $thumbfile)) {
        dheader('location: ' . $attachurl . $thumbfile);
    }
}
define('NOROBOT', TRUE);
$id = !empty($_GET['atid']) ? $_GET['atid'] : $daid;
if (dsign($id . '|' . $dw . '|' . $dh) != $_GET['key']) {
    dheader('location: ' . $_G['siteurl'] . 'static/image/common/none.gif');
}
if ($attach = C::t('forum_attachment_n')->fetch('aid:' . $daid, $daid, array(1, -1))) {
    if (!$dw && !$dh && $attach['tid'] != $id) {
        dheader('location: ' . $_G['siteurl'] . 'static/image/common/none.gif');
    }
    dheader('Expires: ' . gmdate('D, d M Y H:i:s', TIMESTAMP + 3600) . ' GMT');
    if ($attach['remote']) {
        $sign = upyun_gen_sign('/forum/' . $attach['attachment']);
        $filename = $_G['setting']['ftp']['attachurl'] . 'forum/' . $attach['attachment'] . '?_upt=' . $sign;
    } else {
        $filename = $_G['setting']['attachdir'] . 'forum/' . $attach['attachment'];
    }
    require_once libfile('class/image');
    $img = new image();
    if ($img->Thumb($filename, $thumbfile, $w, $h, $type)) {
        if ($nocache) {
            dheader('Content-Type: image');
            @readfile($_G['setting']['attachdir'] . $thumbfile);
            @unlink($_G['setting']['attachdir'] . $thumbfile);
        } else {
            dheader('location: ' . $attachurl . $thumbfile);
        }
    } else {