Beispiel #1
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;
}
Beispiel #2
0
    echo '</select>';
    include template('common/footer_ajax');
} elseif ($_G['gp_action'] == 'getimage') {
    $_G['gp_aid'] = intval($_G['gp_aid']);
    $image = DB::fetch_first('SELECT * FROM ' . DB::table(getattachtablebyaid($_G['gp_aid'])) . " WHERE aid='{$_G['gp_aid']}' AND isimage='1'");
    include template('common/header_ajax');
    if ($image['aid']) {
        echo '<img src="' . getforumimg($image['aid'], 1, 300, 300, 'fixnone') . '" id="image_' . $image['aid'] . '" onclick="insertAttachimgTag(\'' . $image['aid'] . '\')" width="' . ($image['width'] < 110 ? $image['width'] : 110) . '" cwidth="' . ($image['width'] < 300 ? $image['width'] : 300) . '" />';
    }
    include template('common/footer_ajax');
    dexit();
} elseif ($_G['gp_action'] == 'setthreadcover') {
    $aid = intval($_G['gp_aid']);
    require_once libfile('function/post');
    if ($_G['forum'] && $aid) {
        $threadimage = DB::fetch_first("SELECT tid, pid, attachment, remote FROM " . DB::table(getattachtablebyaid($aid)) . " WHERE aid='{$aid}'");
        if ($threadimage['tid'] && $threadimage['pid']) {
            $firstpost = DB::result_first("SELECT first FROM " . DB::table(getposttablebytid($threadimage['tid'])) . " WHERE pid='{$threadimage['pid']}'");
            if (empty($firstpost)) {
                $trade_aid = DB::result_first("SELECT aid FROM " . DB::table('forum_trade') . " WHERE pid='{$threadimage['pid']}'");
                if ($trade_aid == $aid) {
                    $firstpost = 1;
                }
            }
        } else {
            $firstpost = 0;
        }
        if (empty($firstpost)) {
            showmessage('set_cover_faild', '', array(), array('closetime' => 3));
        }
        if (setthreadcover(0, 0, $aid)) {
Beispiel #3
0
$dw = intval($w);
$dh = intval($h);
$thumbfile = 'image/' . $daid . '_' . $dw . '_' . $dh . '.jpg';
$parse = parse_url($_G['setting']['attachurl']);
$attachurl = !isset($parse['host']) ? $_G['siteurl'] . $_G['setting']['attachurl'] : $_G['setting']['attachurl'];
if (!$nocache) {
    if (file_exists($_G['setting']['attachdir'] . $thumbfile)) {
        dheader('location: ' . $attachurl . $thumbfile);
    }
}
define('NOROBOT', TRUE);
$id = !empty($_G['gp_atid']) ? $_G['gp_atid'] : $daid;
if (md5($id . '|' . $dw . '|' . $dh) != $_G['gp_key']) {
    dheader('location: ' . $_G['siteurl'] . 'static/image/common/none.gif');
}
if ($attach = DB::fetch(DB::query("SELECT * FROM " . DB::table(getattachtablebyaid($daid)) . " WHERE aid='{$daid}' AND isimage IN ('1', '-1')"))) {
    if (!$dw && !$dh && $attach['tid'] != $daid) {
        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']) {
        $filename = $_G['setting']['ftp']['attachurl'] . 'forum/' . $attach['attachment'];
    } 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) {
            @readfile($_G['setting']['attachdir'] . $thumbfile);
            @unlink($_G['setting']['attachdir'] . $thumbfile);
Beispiel #4
0
function resolve_replay($attachmentid, $attach, $aidencode, $is_archive)
{
    global $_G;
    // check if replay info is already in database
    $exits_attach = DB::fetch_first("select attachmentid from replayinfo where attachmentid=" . $attachmentid);
    if (empty($exits_attach)) {
        $table_att = DB::table(getattachtablebyaid($attachmentid));
        build_replay_info($attachmentid, $table_att);
    }
    $replayinfo_g = get_replayinfo($attachmentid);
    $time_len = get_game_lentime($replayinfo_g['length']);
    $data = get_replayplayerinfo($attachmentid);
    return build_html($replayinfo_g, $time_len, $data, $attach, $aidencode, $is_archive);
}
Beispiel #5
0
 } else {
     $payrequired = $_G['uid'] ? !DB::result_first("SELECT uid FROM " . DB::table('common_credit_log') . " WHERE uid='{$_G['uid']}' AND relatedid='{$attach['aid']}' AND operation='BAC'") : 1;
     $status = $payrequired ? $status : 2;
 }
 $balance = $status != 2 ? $balance - $attach['price'] : $balance;
 $sidauth = rawurlencode(authcode($_G['sid'], 'ENCODE', $_G['authkey']));
 $aidencode = aidencode($aid, 0, $attach['tid']);
 if (DB::result_first("SELECT COUNT(*) FROM " . DB::table('common_credit_log') . " WHERE uid='{$_G['uid']}' AND relatedid='{$aid}' AND operation='BAC'")) {
     showmessage('attachment_yetpay', "forum.php?mod=attachment&aid={$aidencode}", array(), array('redirectmsg' => 1));
 }
 $attach['netprice'] = $status != 2 ? round($attach['price'] * (1 - $_G['setting']['creditstax'])) : 0;
 if (!submitcheck('paysubmit')) {
     include template('forum/attachpay');
 } else {
     if (!empty($_G['gp_buyall'])) {
         $query = DB::query("SELECT aid, price, tid FROM " . DB::table(getattachtablebyaid($aid)) . " WHERE pid='{$attach['pid']}' AND price>'0'");
         $aids = $prices = array();
         $tprice = 0;
         while ($tmp = DB::fetch($query)) {
             $aids[$tmp['aid']] = $tmp['aid'];
             $prices[$tmp['aid']] = $status != 2 ? array($tmp['price'], round($tmp['price'] * (1 - $_G['setting']['creditstax']))) : array(0, 0);
         }
         if ($aids) {
             $query = DB::query("SELECT relatedid FROM " . DB::table('common_credit_log') . " WHERE uid='{$_G['uid']}' AND relatedid IN (" . dimplode($aids) . ") AND operation='BAC'");
             while ($tmp = DB::fetch($query)) {
                 unset($aids[$tmp['relatedid']]);
             }
         }
         foreach ($aids as $aid) {
             $tprice += $prices[$aid][0];
         }