示例#1
0
 function _parseAttach($content, $fId, $pId, &$attachImages = array())
 {
     global $_G;
     $permissions = $this->_getUserGroupPermissions(array(7));
     $visitorPermission = $permissions[7];
     $attachNames = array();
     $query = DB::query("SELECT aid, filename, isimage, readperm, price FROM " . DB::table(getattachtablebypid($pId)) . " WHERE pid='{$pId}'");
     while ($attach = DB::fetch($query)) {
         if ($attach['price'] > 0 || $attach['readperm'] > $visitorPermission['readPermission'] || in_array($fId, $visitorPermission['forbidViewAttachForumIds'])) {
             continue;
         }
         $attachNames[$attach['aid']] = $attach['filename'];
         if ($attach['isimage']) {
             $imageURL = X_BOARDURL . '/attachment.php?aid=' . aidencode($attach['aid']);
             $attachImages[] = $imageURL;
         }
     }
     $content = preg_replace('/\\[attach\\](\\d+)\\[\\/attach\\]/ie', '$this->_parseAttachTag(\\1, $attachNames)', $content);
     return $content;
 }
示例#2
0
function setthreadcover($pid, $tid = 0, $aid = 0)
{
    global $_G;
    $cover = 0;
    if (empty($_G['uid']) || !intval($_G['setting']['forumpicstyle']['thumbwidth']) || !intval($_G['setting']['forumpicstyle']['thumbwidth'])) {
        return false;
    }
    if (($pid || $aid) && empty($tid)) {
        if ($aid) {
            $attachtable = getattachtablebyaid($aid);
            $wheresql = "aid='{$aid}' AND isimage IN ('1', '-1')";
        } else {
            $attachtable = getattachtablebypid($pid);
            $wheresql = "pid='{$pid}' AND isimage IN ('1', '-1') ORDER BY width DESC LIMIT 1";
        }
        $query = DB::query("SELECT * FROM " . DB::table($attachtable) . " WHERE {$wheresql}");
        if (!($attach = DB::fetch($query))) {
            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;
        $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);
        $picsource = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/' . $attach['attachment'];
        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 = DB::result_first("SELECT COUNT(*) FROM " . DB::table($attachtable) . " WHERE pid='{$pid}' AND isimage IN ('1', '-1')");
            $cover = $remote . $cover;
        } else {
            return false;
        }
    }
    if ($tid || $cover) {
        if (empty($cover)) {
            $oldcover = DB::result_first("SELECT cover FROM " . DB::table('forum_thread') . " WHERE tid='{$tid}'");
            $cover = DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($tid)) . " WHERE pid='{$pid}' AND isimage IN ('1', '-1')");
            $cover = $cover && $oldcover < 0 ? '-' . $cover : $cover;
        }
        DB::update('forum_thread', array('cover' => $cover), array('tid' => $tid));
    }
    return true;
}
示例#3
0
function connect_parse_attach($content, $fId, $pId, &$attachImages)
{
    global $_G;
    $permissions = connect_get_user_group_permissions(array(7));
    $visitorPermission = $permissions[7];
    $attachIds = array();
    $attachImages = array();
    $query = DB::query("SELECT aid, filename, isimage, readperm, price FROM " . DB::table(getattachtablebypid($pId)) . " WHERE pid='{$pId}'");
    while ($attach = DB::fetch($query)) {
        $aid = $attach['aid'];
        if ($attach['isimage'] == 0 || $attach['price'] > 0 || $attach['readperm'] > $visitorPermission['readPermission'] || in_array($fId, $visitorPermission['forbidViewAttachForumIds']) || in_array($attach['aid'], $attachIds)) {
            continue;
        }
        $imageItem = array();
        $thumbWidth = '100';
        $thumbHeight = '100';
        $bigWidth = '400';
        $bigHeight = '400';
        $key = md5($aid . '|' . $thumbWidth . '|' . $thumbHeight);
        $thumbImageURL = $_G['siteurl'] . 'forum.php?mod=image&aid=' . $aid . '&size=' . $thumbWidth . 'x' . $thumbHeight . '&key=' . rawurlencode($key) . '&type=fixwr&nocache=1';
        $key = md5($aid . '|' . $bigWidth . '|' . $bigHeight);
        $bigImageURL = $_G['siteurl'] . 'forum.php?mod=image&aid=' . $aid . '&size=' . $bigWidth . 'x' . $bigHeight . '&key=' . rawurlencode($key) . '&type=fixnone&nocache=1';
        $imageItem['aid'] = $aid;
        $imageItem['thumb'] = $thumbImageURL;
        $imageItem['big'] = $bigImageURL;
        $attachIds[] = $aid;
        $attachImages[] = $imageItem;
    }
    $content = preg_replace('/\\[attach\\](\\d+)\\[\\/attach\\]/ie', 'connect_parse_attach_tag(\\1, $attachNames)', $content);
    return $content;
}