Example #1
0
function getranklist_activity($num = 20, $view = 'heats', $orderby = 'all')
{
    global $_G;
    $dateline = $timestamp = '';
    if ($orderby == 'today') {
        $timestamp = TIMESTAMP - 86400;
        $dateline = "AND t.dateline>='{$timestamp}'";
    } elseif ($orderby == 'thisweek') {
        $timestamp = TIMESTAMP - 604800;
        $dateline = "AND t.dateline>='{$timestamp}'";
    } elseif ($orderby == 'thismonth') {
        $timestamp = TIMESTAMP - 2592000;
        $dateline = "AND t.dateline>='{$timestamp}'";
    }
    $data = array();
    $query = DB::query("SELECT t.tid, t.subject, t.views, t.author, t.authorid, t.replies, t.heats, t.sharetimes, t.favtimes, act.aid, act.starttimefrom, act.starttimeto, act.place, act.class, act.applynumber, act.expiration\n\t\tFROM " . DB::table('forum_thread') . " t\n\t\tLEFT JOIN " . DB::table('forum_activity') . " act ON act.tid=t.tid\n\t\tWHERE t.special='4' AND t.isgroup='0' AND t.closed='0' {$dateline} AND t.displayorder>='0'\n\t\tORDER BY t.{$view} DESC\n\t\tLIMIT 0, {$num}");
    $rank = 0;
    $attachtables = array();
    while ($thread = DB::fetch($query)) {
        ++$rank;
        $thread['rank'] = $rank;
        $thread['starttimefrom'] = dgmdate($thread['starttimefrom']);
        if ($thread['starttimeto']) {
            $thread['starttimeto'] = dgmdate($thread['starttimeto']);
        } else {
            $thread['starttimeto'] = '';
        }
        if ($thread['expiration'] && TIMESTAMP > $thread['expiration']) {
            $thread['has_expiration'] = true;
        } else {
            $thread['has_expiration'] = false;
        }
        $data[$thread['tid']] = $thread;
        $attachtables[getattachtableid($thread['tid'])][] = $thread['aid'];
    }
    foreach ($attachtables as $attachtable => $aids) {
        $attachtable = 'forum_attachment_' . $attachtable;
        $query = DB::query("SELECT tid, attachment, remote FROM " . DB::table($attachtable) . " WHERE aid IN (" . dimplode($aids) . ")");
        while ($attach = DB::fetch($query)) {
            $attach['attachurl'] = ($thread['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/' . $attach['attachment'];
            $data[$attach['tid']] = array_merge($data[$attach['tid']], $attach);
        }
    }
    return $data;
}
function convertunusedattach($aid, $tid, $pid)
{
    if (!$aid) {
        return;
    }
    global $_G;
    $attach = C::t('forum_attachment_n')->fetch_by_aid_uid(127, $aid, $_G['uid']);
    if (!$attach) {
        return;
    }
    $attach = daddslashes($attach);
    $attach['tid'] = $tid;
    $attach['pid'] = $pid;
    C::t('forum_attachment_n')->insert('tid:' . $tid, $attach);
    C::t('forum_attachment')->update($attach['aid'], array('tid' => $tid, 'pid' => $pid, 'tableid' => getattachtableid($tid)));
    C::t('forum_attachment_unused')->delete($attach['aid']);
}
Example #3
0
 private function getnews($tid, $news)
 {
     $data = C::t('forum_post')->fetch_threadpost_by_tid_invisible($tid);
     $tableid = getattachtableid($tid);
     $img = C::t('forum_attachment_n')->fetch_max_image($tableid, 'tid', $tid);
     $news['title'] = $data['subject'];
     $message = preg_replace('/\\[attach\\].+\\[\\/attach\\]/is', '', $data['message']);
     $message = preg_replace('/\\[hide\\].*?\\[\\/hide\\]/is', '', $message);
     $message = preg_replace('/\\{\\:soso_e(\\d+)\\:\\}/is', '', $message);
     $message = preg_replace('/\\[img\\].*?\\[\\/img\\]/is', '', $message);
     $news['description'] = cutstr(strip_tags($message), 250);
     if ($img['aid']) {
         $news['picurl'] = getforumimg($img['aid'], '', '360', '200');
     }
     $news['url'] = $_G['siteurl'] . 'forum.php?mod=viewthread&mobile=2&tid=' . $tid . '&openid=' . $postObj->FromUserName;
     return $news;
 }
Example #4
0
         $thread['author'] = "<a href=\"home.php?mod=space&uid={$thread['authorid']}\" target=\"_blank\">UID {$thread['uid']}</a>";
     } else {
         $thread['author'] = 'guest';
     }
     $thread['dateline'] = dgmdate($thread['dateline']);
     $posttable = $thread['posttableid'] ? (string) $thread['posttableid'] : '0';
     $posttablearr[$posttable][$thread['tid']] = $thread['tid'];
     $postlist[$thread['tid']] = $thread;
 }
 $attachtablearr = array();
 foreach ($posttablearr as $posttable => $tids) {
     foreach (C::t('forum_post')->fetch_all_by_tid($posttable, $tids, true, '', 0, 0, 1) as $post) {
         $thread = $postlist[$post['tid']] + $post;
         $thread['message'] = nl2br(dhtmlspecialchars($thread['message']));
         if ($thread['attachment']) {
             $attachtable = getattachtableid($thread['tid']);
             $attachtablearr[$attachtable][$thread['tid']] = $thread['tid'];
         } else {
             $thread['attach'] = '';
         }
         if ($thread['sortid']) {
             require_once libfile('function/threadsort');
             $threadsortshow = threadsortshow($thread['sortid'], $thread['tid']);
             foreach ($threadsortshow['optionlist'] as $option) {
                 $thread['sortinfo'] .= $option['title'] . ' ' . $option['value'] . "<br />";
             }
         } else {
             $thread['sortinfo'] = '';
         }
         $postlist[$post['tid']] = $thread;
     }
Example #5
0
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     loadcache('grouptype');
     $typeids = array();
     if (!empty($parameter['gtids'])) {
         if ($parameter['gtids'][0] == '0') {
             unset($parameter['gtids'][0]);
         }
         $typeids = $parameter['gtids'];
     }
     $tids = !empty($parameter['tids']) ? explode(',', $parameter['tids']) : array();
     $fids = !empty($parameter['fids']) ? explode(',', $parameter['fids']) : array();
     $uids = !empty($parameter['uids']) ? explode(',', $parameter['uids']) : array();
     $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = isset($parameter['items']) ? intval($parameter['items']) : 10;
     $digest = isset($parameter['digest']) ? $parameter['digest'] : 0;
     $stick = isset($parameter['stick']) ? $parameter['stick'] : 0;
     $orderby = isset($parameter['orderby']) ? in_array($parameter['orderby'], array('dateline', 'todayhots', 'weekhots', 'monthhots')) ? $parameter['orderby'] : 'dateline' : 'dateline';
     $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
     $summarylength = !empty($parameter['summarylength']) ? intval($parameter['summarylength']) : 80;
     $recommend = !empty($parameter['recommend']) ? 1 : 0;
     $keyword = !empty($parameter['keyword']) ? $parameter['keyword'] : '';
     $highlight = !empty($parameter['highlight']) ? 1 : 0;
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     $gviewperm = isset($parameter['gviewperm']) ? intval($parameter['gviewperm']) : -1;
     $gviewwhere = $gviewperm == -1 ? '' : " AND ff.gviewperm='{$gviewperm}'";
     $groups = array();
     if (empty($fids) && $typeids) {
         $query = DB::query('SELECT f.fid, f.name, ff.description FROM ' . DB::table('forum_forum') . " f LEFT JOIN " . DB::table('forum_forumfield') . " ff ON f.fid = ff.fid WHERE f.fup IN (" . dimplode($typeids) . ") AND threads > 0{$gviewwhere}");
         while ($value = DB::fetch($query)) {
             $groups[$value['fid']] = $value;
             $fids[] = intval($value['fid']);
         }
         if (empty($fids)) {
             return array('html' => '', 'data' => '');
         }
     }
     require_once libfile('function/post');
     require_once libfile('function/search');
     $datalist = $list = $listpids = $threadpids = $aid2pid = $attachtables = array();
     $keyword = $keyword ? searchkey($keyword, "tr.subject LIKE '%{text}%'") : '';
     $sql = ($fids ? ' AND t.fid IN (' . dimplode($fids) . ')' : '') . ($tids ? ' AND t.tid IN (' . dimplode($tids) . ')' : '') . ($digest ? ' AND t.digest IN (' . dimplode($digest) . ')' : '') . ($stick ? ' AND t.displayorder IN (' . dimplode($stick) . ')' : '');
     if (empty($fids)) {
         $sql .= " AND t.isgroup='1'";
         if ($gviewwhere) {
             $sql .= $gviewwhere;
         }
     }
     $where = '';
     if (in_array($orderby, array('todayhots', 'weekhots', 'monthhots'))) {
         $historytime = 0;
         switch ($orderby) {
             case 'todayhots':
                 $historytime = mktime(0, 0, 0, date('m', TIMESTAMP), date('d', TIMESTAMP), date('Y', TIMESTAMP));
                 break;
             case 'weekhots':
                 $week = dgmdate(TIMESTAMP, 'w', getglobal('setting/timeformat')) - 1;
                 $week = $week != -1 ? $week : 6;
                 $historytime = mktime(0, 0, 0, date('m', TIMESTAMP), date('d', TIMESTAMP) - $week, date('Y', TIMESTAMP));
                 break;
             case 'monthhots':
                 $historytime = mktime(0, 0, 0, date('m', TIMESTAMP), 1, date('Y', TIMESTAMP));
                 break;
         }
         $where = ' AND tr.dateline>=' . $historytime;
         $orderby = 'totalitems';
     }
     $where .= ($uids ? ' AND tr.sellerid IN (' . dimplode($uids) . ')' : '') . $keyword;
     $where .= $bannedids ? ' AND tr.pid NOT IN (' . dimplode($bannedids) . ')' : '';
     $where = "{$sql} AND t.displayorder>='0' {$where}";
     $sqlfrom = " INNER JOIN `" . DB::table('forum_thread') . "` t ON t.tid=tr.tid ";
     $joinmethod = empty($tids) ? 'INNER' : 'LEFT';
     if ($recommend) {
         $sqlfrom .= " {$joinmethod} JOIN `" . DB::table('forum_forumrecommend') . "` fc ON fc.tid=tr.tid";
     }
     $sqlfield = '';
     if (empty($fids)) {
         $sqlfield = ', f.name groupname';
         $sqlfrom .= ' LEFT JOIN ' . DB::table('forum_forum') . ' f ON t.fid=f.fid LEFT JOIN ' . DB::table('forum_forumfield') . ' ff ON f.fid = ff.fid';
     }
     $sqlfield = $highlight ? ', t.highlight' : '';
     $query = DB::query("SELECT tr.pid, tr.tid, tr.aid, tr.price, tr.credit, tr.subject, tr.totalitems, tr.seller, tr.sellerid{$sqlfield}\n\t\t\tFROM " . DB::table('forum_trade') . " tr {$sqlfrom}\n\t\t\tWHERE 1{$where}\n\t\t\tORDER BY tr.{$orderby} DESC\n\t\t\tLIMIT {$startrow},{$items};");
     require_once libfile('block_thread', 'class/block/forum');
     $bt = new block_thread();
     while ($data = DB::fetch($query)) {
         if ($style['getsummary']) {
             $threadpids[$data['posttableid']][] = $data['pid'];
         }
         if ($data['aid']) {
             $aid2pid[$data['aid']] = $data['pid'];
             $attachtable = getattachtableid($data['tid']);
             $attachtables[$attachtable][] = $data['aid'];
         }
         $listpids[] = $data['pid'];
         $list[$data['pid']] = array('id' => $data['pid'], 'idtype' => 'pid', 'title' => cutstr(str_replace('\\\'', '&#39;', addslashes($data['subject'])), $titlelength, ''), 'url' => 'forum.php?mod=viewthread&do=tradeinfo&tid=' . $data['tid'] . '&pid=' . $data['pid'], 'pic' => $data['aid'] ? '' : $_G['style']['imgdir'] . '/nophoto.gif', 'picflag' => '0', 'fields' => array('fulltitle' => str_replace('\\\'', '&#39;', addslashes($data['subject'])), 'totalitems' => $data['totalitems'], 'author' => $data['seller'] ? $data['seller'] : $_G['setting']['anonymoustext'], 'authorid' => $data['sellerid'] ? $data['sellerid'] : 0, 'price' => ($data['price'] > 0 ? '&yen; ' . $data['price'] : '') . ($data['credit'] > 0 ? ($data['price'] > 0 ? lang('block/grouptrade', 'grouptrade_price_add') : '') . $data['credit'] . ' ' . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][5]]['unit'] . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][5]]['title'] : '')));
         if ($highlight && $data['highlight']) {
             $list[$data['tid']]['fields']['showstyle'] = $bt->getthreadstyle($data['highlight']);
         }
     }
     if (!empty($listpids)) {
         foreach ($threadpids as $key => $var) {
             $posttable = $key == 0 ? 'forum_post' : 'forum_post_' . $key;
             $query = DB::query("SELECT pid, message FROM " . DB::table($posttable) . " WHERE pid IN  (" . dimplode($var) . ")");
             while ($result = DB::fetch($query)) {
                 $list[$result['pid']]['summary'] = messagecutstr($result['message'], $messagelength);
             }
         }
         foreach ($attachtables as $tableid => $taids) {
             $query = DB::query('SELECT aid, attachment, remote FROM ' . DB::table('forum_attachment_' . $tableid) . ' WHERE aid IN (' . dimplode($taids) . ')');
             while ($avalue = DB::fetch($query)) {
                 $list[$aid2pid[$avalue['aid']]]['pic'] = 'forum/' . $avalue['attachment'];
                 $list[$aid2pid[$avalue['aid']]]['picflag'] = $avalue['remote'] ? '2' : '1';
             }
         }
         foreach ($listpids as $key => $value) {
             $datalist[] = $list[$value];
         }
     }
     return array('html' => '', 'data' => $datalist);
 }
Example #6
0
function setattachment($bid, $caid, $tid, $pid)
{
    global $_G;
    $attachment = C::t('#sanree_brand#sanree_brand_attachment')->fetch_firstbyaid($caid);
    if ($attachment) {
        $aid = getattachnewaid($attachment['uid']);
        $insert = array('aid' => $aid, 'tid' => $tid, 'pid' => $pid, 'dateline' => $attachment['dateline'], 'filename' => $attachment['filename'], 'filesize' => $attachment['filesize'], 'attachment' => $attachment['attachment'], 'isimage' => $attachment['isimage'], 'uid' => $attachment['uid'], 'thumb' => $attachment['thumb'], 'remote' => $attachment['remote'], 'width' => $attachment['width']);
        $target = getglobal('setting/attachdir') . './forum/' . $attachment['attachment'];
        list($one, $tow) = explode("/", $attachment['attachment']);
        $appVer = $_G['setting']['version'];
        if ($appVer == 'X2') {
            require_once libfile('class/upload');
        }
        discuz_upload::make_dir(getglobal('setting/attachdir') . './forum/' . $one);
        discuz_upload::make_dir(getglobal('setting/attachdir') . './forum/' . $one . '/' . $tow);
        $source = getglobal('setting/attachdir') . './category/' . $attachment['attachment'];
        !file_exists($target) && @copy($source, $target);
        $tableid = getattachtableid($tid);
        DB::update('forum_attachment_' . $tableid, array('tid' => 0, 'pid' => 0), "tid=" . $tid);
        DB::update('forum_attachment', array('tid' => 0, 'pid' => 0), "tid=" . $tid);
        C::t('#sanree_brand#forum_attachment_n')->insert($tableid, $insert);
        DB::update('forum_attachment', array('tid' => $tid, 'pid' => $pid, 'uid' => $attachment['uid'], 'tableid' => $tableid), "aid=" . $aid);
        C::t('#sanree_brand#sanree_brand_businesses')->update($bid, array('aid' => $aid));
        $tidata = C::t('#sanree_brand#forum_post')->fetch_threadpost_by_tid_invisible($tid);
        $message = $tidata['message'];
        $message = preg_replace('/\\[poster\\]/is', '[attach]' . $aid . '[/attach]', $message);
        C::t('#sanree_brand#forum_post')->update(0, $pid, array('message' => $message, 'attachment' => 1), TRUE);
        $data = array('tid' => $tid, 'attachment' => $attachment['attachment'], 'remote' => 0);
        C::t('#sanree_brand#forum_threadimage')->delete($tid);
        C::t('#sanree_brand#forum_threadimage')->insert($data);
    }
}
Example #7
0
function updateattachtid($where, $oldtid, $newtid)
{
    $oldattachtable = getattachtablebytid($oldtid);
    $newattachtable = getattachtablebytid($newtid);
    if ($oldattachtable != $newattachtable) {
        $query = DB::query("SELECT * FROM " . DB::table($oldattachtable) . " WHERE {$where}");
        while ($attach = DB::fetch($query)) {
            $attach = daddslashes($attach);
            $attach['tid'] = $newtid;
            DB::insert($newattachtable, $attach);
        }
        DB::delete($oldattachtable, $where);
    }
    DB::query("UPDATE " . DB::table('forum_attachment') . " SET tid='{$newtid}',tableid='" . getattachtableid($newtid) . "' WHERE {$where}");
}
Example #8
0
function updateattach($modnewthreads, $tid, $pid, $attachnew, $attachupdate = array(), $uid = 0)
{
    global $_G;
    $uid = $uid ? $uid : $_G['uid'];
    $uidadd = $_G['forum']['ismoderator'] ? '' : " AND uid='{$uid}'";
    if ($attachnew) {
        $newaids = array_keys($attachnew);
        $newattach = $newattachfile = $albumattach = array();
        $query = DB::query("SELECT * FROM " . DB::table('forum_attachment_unused') . " WHERE aid IN (" . dimplode($newaids) . "){$uidadd}");
        while ($attach = DB::fetch($query)) {
            $newattach[$attach['aid']] = daddslashes($attach);
            if ($attach['isimage']) {
                $newattachfile[$attach['aid']] = $attach['attachment'];
            }
        }
        if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
            require_once libfile('class/image');
            $image = new image();
        }
        if (!empty($_G['gp_albumaid'])) {
            array_unshift($_G['gp_albumaid'], '');
            $_G['gp_albumaid'] = array_unique($_G['gp_albumaid']);
            unset($_G['gp_albumaid'][0]);
            foreach ($_G['gp_albumaid'] as $aid) {
                if (isset($newattach[$aid])) {
                    $albumattach[$aid] = $newattach[$aid];
                }
            }
        }
        foreach ($attachnew as $aid => $attach) {
            $update = array();
            $update['readperm'] = $_G['group']['allowsetattachperm'] ? $attach['readperm'] : 0;
            $update['price'] = $_G['group']['maxprice'] ? intval($attach['price']) <= $_G['group']['maxprice'] ? intval($attach['price']) : $_G['group']['maxprice'] : 0;
            $update['tid'] = $tid;
            $update['pid'] = $pid;
            $update['uid'] = $uid;
            $update['description'] = cutstr(dhtmlspecialchars($attach['description']), 100);
            DB::update(getattachtablebytid($tid), $update, "aid='{$aid}'");
            if (!$newattach[$aid]) {
                continue;
            }
            $update = array_merge($update, $newattach[$aid]);
            if (!empty($newattachfile[$aid])) {
                if ($_G['setting']['thumbstatus'] && $_G['forum']['disablethumb']) {
                    $update['thumb'] = 0;
                    @unlink($_G['setting']['attachdir'] . '/forum/' . getimgthumbname($newattachfile[$aid]));
                    if (!empty($albumattach[$aid])) {
                        $albumattach[$aid]['thumb'] = 0;
                    }
                }
                if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
                    $image->Watermark($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], '', 'forum');
                    $update['filesize'] = $image->imginfo['size'];
                }
            }
            if (!empty($_G['gp_albumaid']) && isset($albumattach[$aid])) {
                $newalbum = 0;
                if (!$_G['gp_uploadalbum']) {
                    require_once libfile('function/spacecp');
                    $_G['gp_uploadalbum'] = album_creat(array('albumname' => $_G['gp_newalbum']));
                    $newalbum = 1;
                }
                $picdata = array('albumid' => $_G['gp_uploadalbum'], 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $albumattach[$aid]['dateline'], 'postip' => $_G['clientip'], 'filename' => $albumattach[$aid]['filename'], 'title' => cutstr(dhtmlspecialchars($attach['description']), 100), 'type' => fileext($albumattach[$aid]['attachment']), 'size' => $albumattach[$aid]['filesize'], 'filepath' => $albumattach[$aid]['attachment'], 'thumb' => $albumattach[$aid]['thumb'], 'remote' => $albumattach[$aid]['remote'] + 2);
                $update['picid'] = DB::insert('home_pic', $picdata, 1);
                if ($newalbum) {
                    require_once libfile('function/home');
                    require_once libfile('function/spacecp');
                    album_update_pic($_G['gp_uploadalbum']);
                }
            }
            DB::insert(getattachtablebytid($tid), $update, false, true);
            DB::update('forum_attachment', array('tid' => $tid, 'pid' => $pid, 'tableid' => getattachtableid($tid)), "aid='{$aid}'");
            DB::delete('forum_attachment_unused', "aid='{$aid}'");
        }
        if (!empty($_G['gp_albumaid'])) {
            $albumdata = array('picnum' => DB::result_first("SELECT count(*) FROM " . DB::table('home_pic') . " WHERE albumid='{$_G['gp_uploadalbum']}'"), 'updatetime' => $_G['timestamp']);
            DB::update('home_album', $albumdata, "albumid='{$_G['gp_uploadalbum']}'");
        }
        if ($newattach) {
            ftpupload($newaids, $uid);
        }
    }
    if (!$modnewthreads && $newattach && $uid == $_G['uid']) {
        updatecreditbyaction('postattach', $uid, array(), '', count($newattach), 1, $_G['fid']);
    }
    if ($attachupdate) {
        $query = DB::query("SELECT pid, aid, attachment, thumb, remote FROM " . DB::table(getattachtablebytid($tid)) . " WHERE aid IN (" . dimplode(array_keys($attachupdate)) . ")");
        while ($attach = DB::fetch($query)) {
            if (array_key_exists($attach['aid'], $attachupdate) && $attachupdate[$attach['aid']]) {
                dunlink($attach);
            }
        }
        $uaids = dimplode($attachupdate);
        $query = DB::query("SELECT aid, width, filename, filesize, attachment, isimage, thumb, remote FROM " . DB::table('forum_attachment_unused') . " WHERE aid IN ({$uaids}){$uidadd}");
        DB::query("DELETE FROM " . DB::table('forum_attachment_unused') . " WHERE aid IN ({$uaids}){$uidadd}");
        $attachupdate = array_flip($attachupdate);
        while ($attach = DB::fetch($query)) {
            $update = $attach;
            $update['dateline'] = TIMESTAMP;
            $update['remote'] = 0;
            unset($update['aid']);
            if ($attach['isimage'] && $_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
                $image->Watermark($_G['setting']['attachdir'] . '/forum/' . $attach['attachment'], '', 'forum');
                $update['filesize'] = $image->imginfo['size'];
            }
            DB::update(getattachtablebytid($tid), $update, "aid='" . $attachupdate[$attach['aid']] . "'");
            ftpupload(array($attachupdate[$attach['aid']]), $uid);
        }
    }
    $attachcount = DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($tid)) . " WHERE tid='{$tid}'" . ($pid > 0 ? " AND pid='{$pid}'" : ''));
    $attachment = $attachcount ? DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($tid)) . " WHERE tid='{$tid}'" . ($pid > 0 ? " AND pid='{$pid}'" : '') . " AND isimage != 0") ? 2 : 1 : 0;
    DB::query("UPDATE " . DB::table('forum_thread') . " SET attachment='{$attachment}' WHERE tid='{$tid}'", 'UNBUFFERED');
    if (!$attachment) {
        DB::delete('forum_threadimage', "tid='{$tid}'");
    }
    $posttable = getposttablebytid($tid);
    DB::query("UPDATE " . DB::table($posttable) . " SET attachment='{$attachment}' WHERE pid='{$pid}'", 'UNBUFFERED');
    $_G['forum_attachexist'] = $attachment;
}
Example #9
0
function getranklist_activity($num = 20, $view = 'heats', $orderby = 'all')
{
    global $_G;
    $dateline = '';
    $timestamp = 0;
    if ($orderby == 'today') {
        $timestamp = TIMESTAMP - 86400;
    } elseif ($orderby == 'thisweek') {
        $timestamp = TIMESTAMP - 604800;
    } elseif ($orderby == 'thismonth') {
        $timestamp = TIMESTAMP - 2592000;
    }
    $data = array();
    $rank = 0;
    $attachtables = array();
    $notfid = $_G['setting']['ranklist']['ignorefid'] ? explode(',', $_G['setting']['ranklist']['ignorefid']) : array();
    foreach (C::t('forum_thread')->fetch_all_rank_activity($timestamp, $notfid, $view, $num) as $thread) {
        ++$rank;
        $thread['rank'] = $rank;
        $thread['starttimefrom'] = dgmdate($thread['starttimefrom']);
        if ($thread['starttimeto']) {
            $thread['starttimeto'] = dgmdate($thread['starttimeto']);
        } else {
            $thread['starttimeto'] = '';
        }
        if ($thread['expiration'] && TIMESTAMP > $thread['expiration']) {
            $thread['has_expiration'] = true;
        } else {
            $thread['has_expiration'] = false;
        }
        $data[$thread['tid']] = $thread;
        $attachtables[getattachtableid($thread['tid'])][] = $thread['aid'];
    }
    foreach ($attachtables as $attachtable => $aids) {
        $attachs = C::t('forum_attachment_n')->fetch_all($attachtable, $aids);
        foreach ($attachs as $attach) {
            $attach['attachurl'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/' . $attach['attachment'];
            $data[$attach['tid']] = array_merge($data[$attach['tid']], $attach);
        }
    }
    return $data;
}
Example #10
0
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     loadcache('forums');
     $tids = !empty($parameter['tids']) ? explode(',', $parameter['tids']) : array();
     $uids = !empty($parameter['uids']) ? explode(',', $parameter['uids']) : array();
     $startrow = !empty($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = !empty($parameter['items']) ? intval($parameter['items']) : 10;
     $digest = isset($parameter['digest']) ? $parameter['digest'] : 0;
     $stick = isset($parameter['stick']) ? $parameter['stick'] : 0;
     $orderby = isset($parameter['orderby']) ? in_array($parameter['orderby'], array('dateline', 'weekstart', 'monthstart', 'weekexp', 'monthexp', 'weekhot', 'monthhot', 'alltimehot')) ? $parameter['orderby'] : 'dateline' : 'dateline';
     $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
     $summarylength = !empty($parameter['summarylength']) ? intval($parameter['summarylength']) : 80;
     $recommend = !empty($parameter['recommend']) ? 1 : 0;
     $keyword = !empty($parameter['keyword']) ? $parameter['keyword'] : '';
     $place = !empty($parameter['place']) ? $parameter['place'] : '';
     $class = !empty($parameter['class']) ? trim($parameter['class']) : '';
     $gender = !empty($parameter['gender']) ? intval($parameter['gender']) : '';
     $viewmod = !empty($parameter['viewmod']) ? 1 : 0;
     $highlight = !empty($parameter['highlight']) ? 1 : 0;
     $fids = array();
     if (!empty($parameter['fids'])) {
         if ($parameter['fids'][0] == '0') {
             unset($parameter['fids'][0]);
         }
         $fids = $parameter['fids'];
     }
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     require_once libfile('function/post');
     require_once libfile('function/search');
     $datalist = $list = array();
     $keyword = $keyword ? searchkey($keyword, "t.subject LIKE '%{text}%'") : '';
     $sql = ($fids ? ' AND t.fid IN (' . dimplode($fids) . ')' : '') . $keyword . ($tids ? ' AND t.tid IN (' . dimplode($tids) . ')' : '') . ($bannedids ? ' AND t.tid NOT IN (' . dimplode($bannedids) . ')' : '') . ($digest ? ' AND t.digest IN (' . dimplode($digest) . ')' : '') . ($stick ? ' AND t.displayorder IN (' . dimplode($stick) . ')' : '') . " AND t.isgroup='0'";
     $where = '';
     if (in_array($orderby, array('weekstart', 'monthstart'))) {
         $historytime = 0;
         switch ($orderby) {
             case 'weekstart':
                 $historytime = TIMESTAMP + 86400 * 7;
                 break;
             case 'monthstart':
                 $historytime = TIMESTAMP + 86400 * 30;
                 break;
         }
         $where = ' WHERE a.starttimefrom>=' . TIMESTAMP . ' AND a.starttimefrom<=' . $historytime;
         $orderby = 'a.starttimefrom ASC';
     } elseif (in_array($orderby, array('weekexp', 'monthexp'))) {
         $historytime = 0;
         switch ($orderby) {
             case 'weekexp':
                 $historytime = TIMESTAMP + 86400 * 7;
                 break;
             case 'monthexp':
                 $historytime = TIMESTAMP + 86400 * 30;
                 break;
         }
         $where = ' WHERE a.expiration>=' . TIMESTAMP . ' AND a.expiration<=' . $historytime;
         $orderby = 'a.expiration ASC';
     } elseif (in_array($orderby, array('weekhot', 'monthhot'))) {
         $historytime = 0;
         switch ($orderby) {
             case 'weekhot':
                 $historytime = TIMESTAMP + 86400 * 7;
                 break;
             case 'monthhot':
                 $historytime = TIMESTAMP + 86400 * 30;
                 break;
         }
         $where = ' WHERE a.expiration>=' . TIMESTAMP . ' AND a.expiration<=' . $historytime;
         $orderby = 'a.applynumber DESC';
     } elseif ($orderby == 'alltimehot') {
         $where = ' WHERE (a.expiration>=' . TIMESTAMP . " OR a.expiration='0')";
         $orderby = 'a.applynumber DESC';
     } else {
         $orderby = 't.dateline DESC';
     }
     $where .= $uids ? ' AND t.authorid IN (' . dimplode($uids) . ')' : '';
     if ($gender) {
         $where .= " AND a.gender='{$gender}'";
     }
     if ($class) {
         $where .= " AND a.class='{$class}'";
     }
     $sqlfrom = " INNER JOIN `" . DB::table('forum_thread') . "` t ON t.tid=a.tid {$sql} AND t.displayorder>='0'";
     $joinmethod = empty($tids) ? 'INNER' : 'LEFT';
     if ($recommend) {
         $sqlfrom .= " {$joinmethod} JOIN `" . DB::table('forum_forumrecommend') . "` fc ON fc.tid=tr.tid";
     }
     $sqlfield = $highlight ? ', t.highlight' : '';
     $query = DB::query("SELECT a.*, t.tid, t.subject, t.authorid, t.author{$sqlfield}\n\t\t\tFROM " . DB::table('forum_activity') . " a {$sqlfrom} {$where}\n\t\t\tORDER BY {$orderby}\n\t\t\tLIMIT {$startrow},{$items};");
     require_once libfile('block_thread', 'class/block/forum');
     $bt = new block_thread();
     $listtids = $threadtids = $threads = $aid2tid = $attachtables = array();
     while ($data = DB::fetch($query)) {
         $data['time'] = dgmdate($data['starttimefrom']);
         if ($data['starttimeto']) {
             $data['time'] .= ' - ' . dgmdate($data['starttimeto']);
         }
         if ($style['getsummary']) {
             $threadtids[$data['posttableid']][] = $data['tid'];
         }
         if ($data['aid']) {
             $aid2tid[$data['aid']] = $data['tid'];
             $attachtable = getattachtableid($data['tid']);
             $attachtables[$attachtable][] = $data['aid'];
         }
         $listtids[] = $data['tid'];
         $list[$data['tid']] = array('id' => $data['tid'], 'idtype' => 'tid', 'title' => cutstr(str_replace('\\\'', '&#39;', $data['subject']), $titlelength, ''), 'url' => 'forum.php?mod=viewthread&tid=' . $data['tid'] . ($viewmod ? '&from=portal' : ''), 'pic' => $data['aid'] ? '' : $_G['style']['imgdir'] . '/nophoto.gif', 'picflag' => '0', 'fields' => array('fulltitle' => str_replace('\\\'', '&#39;', addslashes($data['subject'])), 'time' => $data['time'], 'expiration' => $data['expiration'] ? dgmdate($data['expiration']) : 'N/A', 'author' => $data['author'] ? $data['author'] : $_G['setting']['anonymoustext'], 'authorid' => $data['authorid'] ? $data['authorid'] : 0, 'cost' => $data['cost'], 'place' => $data['place'], 'class' => $data['class'], 'gender' => $data['gender'], 'number' => $data['number'], 'applynumber' => $data['applynumber']));
         if ($highlight && $data['highlight']) {
             $list[$data['tid']]['fields']['showstyle'] = $bt->getthreadstyle($data['highlight']);
         }
     }
     if (!empty($listtids)) {
         $query = DB::query("SELECT tid,COUNT(*) as sum FROM " . DB::table('forum_activityapply') . " WHERE tid IN(" . dimplode($listtids) . ") GROUP BY tid");
         while ($value = DB::fetch($query)) {
             $list[$value['tid']]['fields']['applynumber'] = $value['sum'];
         }
         $threads = $bt->getthread($threadtids, $summarylength, true);
         if ($threads) {
             foreach ($threads as $tid => $var) {
                 $list[$tid]['summary'] = $var;
             }
         }
         foreach ($attachtables as $tableid => $taids) {
             $query = DB::query('SELECT aid, attachment, remote FROM ' . DB::table('forum_attachment_' . $tableid) . ' WHERE aid IN (' . dimplode($taids) . ')');
             while ($avalue = DB::fetch($query)) {
                 $list[$aid2tid[$avalue['aid']]]['pic'] = 'forum/' . $avalue['attachment'];
                 $list[$aid2tid[$avalue['aid']]]['picflag'] = $avalue['remote'] ? '2' : '1';
             }
         }
         foreach ($listtids as $key => $value) {
             $datalist[] = $list[$value];
         }
     }
     return array('html' => '', 'data' => $datalist);
 }
 $update['pid'] = $pid;
 $update['uid'] = $uid;
 $update['dateline'] = time();
 $update['filename'] = $filename;
 $update['filesize'] = $filesize;
 $update['attachment'] = $attachments;
 $update['description'] = censor(cutstr(dhtmlspecialchars($description), 100));
 $update['readperm'] = 0;
 $update['price'] = 0;
 $update['isimage'] = 1;
 $update['width'] = $width;
 $update['thumb'] = 0;
 $update['picid'] = 0;
 $update['sha1'] = '';
 C::t('forum_attachment_n')->insert('tid:' . $tid, $update, false, true);
 C::t('forum_attachment')->update($aid, array('tid' => $tid, 'pid' => $pid, 'tableid' => getattachtableid($tid)));
 $attachcount = C::t('forum_attachment_n')->count_by_id('tid:' . $tid, $pid ? 'pid' : 'tid', $pid ? $pid : $tid);
 $attachment = 0;
 if ($attachcount) {
     if (C::t('forum_attachment_n')->count_image_by_id('tid:' . $tid, $pid ? 'pid' : 'tid', $pid ? $pid : $tid)) {
         $attachment = 2;
     } else {
         $attachment = 1;
     }
 } else {
     $attachment = 0;
 }
 C::t('forum_thread')->update($tid, array('attachment' => $attachment));
 C::t('forum_post')->update('tid:' . $tid, $pid, array('attachment' => $attachment), true);
 if (!$attachment) {
     C::t('forum_threadimage')->delete_by_tid($tid);
 public function getPublishPollObj()
 {
     function isdate($str, $format = "Y-m-d")
     {
         $strArr = explode("-", $str);
         if (empty($strArr)) {
             return false;
         }
         foreach ($strArr as $val) {
             if (strlen($val) < 2) {
                 $val = "0" . $val;
             }
             $newArr[] = $val;
         }
         $str = implode("-", $newArr);
         $unixTime = strtotime($str);
         $checkDate = date($format, $unixTime);
         if ($checkDate == $str) {
             return true;
         } else {
             return false;
         }
     }
     $rPostion = $_GET['r'] ? $_GET['r'] : 0;
     $longitude = $_GET['longitude'];
     $latitude = $_GET['latitude'];
     $location = echo_urldecode($_GET['location']);
     $aid = $_REQUEST['aid'];
     $aid_Img = explode(',', $aid);
     $_G['fid'] = $_GET['boardId'];
     require_once '../tool/mobcentDatabase.php';
     $info = new mobcentGetInfo();
     $modnewposts = $info->getBoard($_G['fid']);
     $readperm = 0;
     $price = 0;
     $typeid = 0;
     $sortid = 0;
     $displayorder = $modnewposts['modnewposts'] > 0 ? -2 : 0;
     $digest = 0;
     $special = 1;
     /*tou piao tie, $special=1 */
     $attachment = 0;
     $moderated = 0;
     $isgroup = 0;
     $replycredit = 0;
     $closed = 0;
     $publishdate = time();
     $accessSecret = $_GET['accessSecret'];
     $accessToken = $_GET['accessToken'];
     $qquser = Common::get_unicode_charset('\\u6e38\\u5ba2');
     $group = $info->rank_check_allow($accessSecret, $accessToken, $qquser);
     if (!$group['allowvisit']) {
         $data_post['rs'] = 0;
         $data_post['errcode'] = '01110001';
         return $data_post;
         exit;
     }
     $arrAccess = $info->sel_accessTopkent($accessSecret, $accessToken);
     $ruid = $_G['uid'] = $arrAccess['user_id'];
     $space = $info->getUserInfo(intval($ruid));
     if (empty($_G['uid'])) {
         return $info->userAccessError();
         exit;
     }
     $author = $space['username'];
     $_G['username'] = $lastposter = $author;
     $_G = array_merge($_G, $space);
     $a = array("qq" => "a", "ff" => "b");
     $b = array("ss" => "c", "dd" => "d");
     $c = array();
     foreach ($a as $key => $value) {
         $c[$key] = $value;
     }
     foreach ($b as $key => $value) {
         $c[$key] = $value;
     }
     /*renxing vote data and check */
     $pollItem = echo_array(urldecode($_GET['pollItem']));
     $pollarray = array();
     foreach ($pollItem as $poll) {
         $pitems[] = $poll[itemName];
     }
     if (count($pitems) > 20) {
         $data_post['rs'] = 0;
         $data_post['errcode'] = '04000020';
         return $data_post;
         exit;
     }
     if (count($pitems) < 2) {
         $data_post['rs'] = 0;
         $data_post['errcode'] = '04000021';
         return $data_post;
         exit;
     }
     if (!preg_match("/^\\d*\$/", trim($_GET['type']))) {
         $data_post['rs'] = 0;
         $data_post['errcode'] = '04000022';
         return $data_post;
         exit;
     }
     if (!preg_match("/^\\d*\$/", trim($_GET['deadline']))) {
         $data_post['rs'] = 0;
         $data_post['errcode'] = '04000023';
         return $data_post;
         exit;
     }
     $pollarray[maxchoices] = empty($_GET['type']) ? 0 : $_GET['type'];
     $pollarray[multiple] = empty($_GET['type']) || intval($_GET['type']) == 1 ? 0 : 1;
     $pollarray[options] = $pitems;
     $pollarray[visible] = empty($_GET['isVisible']);
     $pollarray[overt] = !empty($_GET['overt']);
     if (empty($_GET['deadline'])) {
         $pollarray['expiration'] = 0;
     } else {
         $pollarray['expiration'] = TIMESTAMP + 86400 * $_GET['deadline'];
     }
     /*end check */
     $subject = echo_urldecode($_GET['title']);
     $message = '';
     $i = 0;
     $array_message = echo_array(urldecode($_GET['content']));
     foreach ($array_message as $k => $v) {
         switch ($v["type"]) {
             case 0:
                 $message .= $v["infor"];
                 break;
             case 1:
                 if (empty($aid_Img)) {
                     $message .= '[attachimg]' . $aid . '[/attachimg]';
                 } else {
                     $message .= '[attachimg]' . $aid_Img[$i] . '[/attachimg]';
                     $i = $i + 1;
                 }
                 $attachment = 2;
                 break;
             case 3:
                 $message .= "[audio]" . $v["infor"] . "[/audio]";
                 break;
         }
     }
     /* 判断是否发匿名与仅该作者可见贴*/
     $isOnlyAuthor = $_GET['isOnlyAuthor'] ? $_GET['isOnlyAuthor'] : 0;
     $thread['status'] = 32;
     $isOnlyAuthor == 1 && ($thread['status'] = setstatus(2, 1, $thread['status']));
     $isAnonymous = $_GET['isAnonymous'] ? $_GET['isAnonymous'] : 0;
     $author = !$isAnonymous ? $_G['username'] : '';
     $newthread = array('fid' => $_G['fid'], 'posttableid' => 0, 'readperm' => $readperm, 'price' => $price, 'typeid' => $typeid, 'sortid' => $sortid, 'author' => $author, 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $publishdate, 'lastpost' => $publishdate, 'lastposter' => $author, 'displayorder' => $displayorder, 'digest' => $digest, 'special' => $special, 'attachment' => $attachment, 'moderated' => $moderated, 'status' => $thread['status'], 'isgroup' => $isgroup, 'replycredit' => $replycredit, 'closed' => $closed);
     $tid = C::t('forum_thread')->insert($newthread, true);
     if ($modnewposts['modnewposts'] > 0) {
         table_forum_thread_moderate::insert($tid, 0, time());
     }
     if (!$tid) {
         echo '{"rs":0}';
         exit;
     }
     useractionlog($_G['uid'], 'tid');
     C::t('common_member_field_home')->update($_G['uid'], array('recentnote' => $subject));
     $pinvisible = $modnewposts['modnewposts'] > 0 ? -2 : 0;
     $isanonymous = 0;
     $usesig = 1;
     $htmlon = 0;
     $bbcodeoff = -1;
     $smileyoff = -1;
     $parseurloff = false;
     $tagstr = null;
     $message = htmlspecialchars_decode($message);
     $_G['group']['allowat'] = substr_count($message, '@');
     if ($_G['group']['allowat']) {
         $bbcodeoff = 0;
         $atlist = $atlist_tmp = array();
         $res = preg_match_all("#@([^\r\n]*?)\\s#i", $message . ' ', $atlist_tmp);
         $atlist_tmp = array_slice(array_unique($atlist_tmp[1]), 0, $_G['group']['allowat']);
         if (!empty($atlist_tmp)) {
             if (empty($_G['setting']['at_anyone'])) {
                 foreach (C::t('home_follow')->fetch_all_by_uid_fusername($_G['uid'], $atlist_tmp) as $row) {
                     $atlist[$row['followuid']] = $row['fusername'];
                 }
                 if (count($atlist) < $_G['group']['allowat']) {
                     $query = C::t('home_friend')->fetch_all_by_uid_username($_G['uid'], $atlist_tmp);
                     foreach ($query as $row) {
                         $atlist[$row['fuid']] = $row['fusername'];
                     }
                 }
             } else {
                 foreach (C::t('common_member')->fetch_all_by_username($atlist_tmp) as $row) {
                     $atlist[$row['uid']] = $row['username'];
                 }
             }
         }
         if ($atlist) {
             foreach ($atlist as $atuid => $atusername) {
                 $atsearch[] = "/@{$atusername} /i";
                 $atreplace[] = "[url=home.php?mod=space&uid={$atuid}]@{$atusername}[/url] ";
             }
             $message = preg_replace($atsearch, $atreplace, $message . ' ', 1);
         }
     }
     /*renxing vote insert*/
     foreach ($pollarray['options'] as $polloptvalue) {
         $polloptvalue = dhtmlspecialchars(trim($polloptvalue));
         C::t('forum_polloption')->insert(array('tid' => $tid, 'polloption' => $polloptvalue));
     }
     $polloptionpreview = '';
     $query = C::t('forum_polloption')->fetch_all_by_tid($tid, 1, 2);
     foreach ($query as $option) {
         $polloptvalue = preg_replace("/\\[url=(https?){1}:\\/\\/([^\\[\"']+?)\\](.+?)\\[\\/url\\]/i", "<a href=\"\\1://\\2\" target=\"_blank\">\\3</a>", $option['polloption']);
         $polloptionpreview .= $polloptvalue . "\t";
     }
     $polloptionpreview = daddslashes($polloptionpreview);
     $data = array('tid' => $tid, 'multiple' => $pollarray['multiple'], 'visible' => $pollarray['visible'], 'maxchoices' => $pollarray['maxchoices'], 'expiration' => $pollarray['expiration'], 'overt' => $pollarray['overt'], 'pollpreview' => $polloptionpreview);
     C::t('forum_poll')->insert($data);
     /*end  renxing vote insert*/
     $class_tag = new tag();
     $tagstr = $class_tag->add_tag($_GET['tags'], $tid, 'tid');
     $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message);
     $message = $_GET['platType'] == 1 ? $message . "\r\n[url=/mobcent/download/down.php]" . Common::get_unicode_charset('\\u6765\\u81ea\\u5b89\\u5353\\u5ba2\\u6237\\u7aef') . '[/url]' : $message . "\r\n[url=/mobcent/download/down.php]" . Common::get_unicode_charset('\\u6765\\u81ea\\u0069\\u0070\\u0068\\u006f\\u006e\\u0065\\u5ba2\\u6237\\u7aef') . "[/url]";
     $pid = insertpost(array('fid' => $_G['fid'], 'tid' => $tid, 'first' => '1', 'author' => $author, 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => time(), 'message' => $message, 'useip' => get_client_ip(), 'invisible' => $pinvisible, 'anonymous' => $isAnonymous, 'usesig' => $usesig, 'htmlon' => $htmlon, 'bbcodeoff' => 0, 'smileyoff' => $smileyoff, 'parseurloff' => $parseurloff, 'attachment' => $attachment, 'tags' => $tagstr, 'replycredit' => 0, 'status' => 0));
     if ($_G['group']['allowat'] && $atlist) {
         foreach ($atlist as $atuid => $atusername) {
             mobcent_helper_notification::notification_add($_G['username'], $atuid, 'at', 'at_message', $_G['uid'], array('from_id' => $tid, 'from_idtype' => 'at', 'buyerid' => $_G['uid'], 'buyer' => $_G['username'], 'tid' => $tid, 'subject' => $subject, 'pid' => $pid, 'message' => messagecutstr($message, 150)));
         }
         set_atlist_cookie(array_keys($atlist));
     }
     if (empty($aid_Img)) {
         $threadimageaid = $aid;
         if ($aid) {
             $tableid = getattachtableid($tid);
             $query = get_forum_attachment_unused($aid);
             while ($attach = DB::fetch($query)) {
                 $aids = $attach['aid'];
                 $data = $attach;
             }
             $uid = $_G['uid'];
             update_forum_attachment($tid, $tableid, $uid, $pid, $aids);
             $data['uid'] = 1;
             $data['tid'] = $tid;
             $data['pid'] = $pid;
             C::t('forum_attachment_n')->insert($tableid, $data);
         }
         $values = array('fid' => $_G['fid'], 'tid' => $tid, 'pid' => $pid, 'coverimg' => '');
         $param = array();
         if ($_G['forum']['picstyle']) {
             if (!setthreadcover($pid, 0, $threadimageaid)) {
                 preg_match_all("/(\\[img\\]|\\[img=\\d{1,4}[x|\\,]\\d{1,4}\\])\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/is", $message, $imglist, PREG_SET_ORDER);
                 $values['coverimg'] = "<p id=\"showsetcover\">" . lang('message', 'post_newthread_set_cover') . "<span id=\"setcoverwait\"></span></p><script>if(\$('forward_a')){\$('forward_a').style.display='none';setTimeout(\"\$('forward_a').style.display=''\", 5000);};ajaxget('forum.php?mod=ajax&action=setthreadcover&tid={$tid}&pid={$pid}&fid={$_G['fid']}&imgurl={$imglist[0][2]}&newthread=1', 'showsetcover', 'setcoverwait')</script>";
                 $param['clean_msgforward'] = 1;
                 $param['timeout'] = $param['refreshtime'] = 15;
             }
         }
         if ($threadimageaid && empty($imagearr)) {
             if (!$threadimage) {
                 $threadimage = C::t('forum_attachment_n')->fetch('tid:' . $tid, $threadimageaid);
             }
             $threadimage = daddslashes($threadimage);
             C::t('forum_threadimage')->insert(array('tid' => $tid, 'attachment' => $threadimage['attachment'], 'remote' => $threadimage['remote']));
         }
     } else {
         $isInsertForumImage = false;
         foreach ($aid_Img as $key => $val) {
             $threadimageaid = $val;
             if ($val) {
                 $tableid = getattachtableid($tid);
                 $query = DB::query("SELECT * FROM %t WHERE aid=%d", array('forum_attachment_unused', $val));
                 while ($attach = DB::fetch($query)) {
                     $aids = $attach['aid'];
                     $data = $attach;
                 }
                 DB::query("UPDATE %t SET tid=%d,tableid=%d,uid=%d,pid=%d WHERE aid IN (%n)", array('forum_attachment', $tid, getattachtableid($tid), $_G['uid'], $pid, $aids));
                 $data['uid'] = 1;
                 $data['tid'] = $tid;
                 $data['pid'] = $pid;
                 C::t('forum_attachment_n')->insert($tableid, $data);
             }
             $values = array('fid' => $_G['fid'], 'tid' => $tid, 'pid' => $pid, 'coverimg' => '');
             $param = array();
             if ($_G['forum']['picstyle']) {
                 if (!setthreadcover($pid, 0, $threadimageaid)) {
                     preg_match_all("/(\\[img\\]|\\[img=\\d{1,4}[x|\\,]\\d{1,4}\\])\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/is", $message, $imglist, PREG_SET_ORDER);
                     $values['coverimg'] = "<p id=\"showsetcover\">" . lang('message', 'post_newthread_set_cover') . "<span id=\"setcoverwait\"></span></p><script>if(\$('forward_a')){\$('forward_a').style.display='none';setTimeout(\"\$('forward_a').style.display=''\", 5000);};ajaxget('forum.php?mod=ajax&action=setthreadcover&tid={$tid}&pid={$pid}&fid={$_G['fid']}&imgurl={$imglist[0][2]}&newthread=1', 'showsetcover', 'setcoverwait')</script>";
                     $param['clean_msgforward'] = 1;
                     $param['timeout'] = $param['refreshtime'] = 15;
                 }
             }
             if (!$isInsertForumImage && $threadimageaid && empty($imagearr)) {
                 if (!$threadimage) {
                     $threadimage = C::t('forum_attachment_n')->fetch('tid:' . $tid, $threadimageaid);
                 }
                 $threadimage = daddslashes($threadimage);
                 C::t('forum_threadimage')->insert(array('tid' => $tid, 'attachment' => $threadimage['attachment'], 'remote' => $threadimage['remote']));
                 $isInsertForumImage = true;
             }
         }
     }
     $feed = array('icon' => '', 'title_template' => '', 'title_data' => array(), 'body_template' => '', 'body_data' => array(), 'title_data' => array(), 'images' => array());
     if (1) {
         $message = !$price && !$readperm ? $message : '';
         if ($special == 0) {
             $feed['icon'] = 'thread';
             $feed['title_template'] = 'feed_thread_title';
             $feed['body_template'] = 'feed_thread_message';
             $feed['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$tid}\">{$subject}</a>", 'message' => messagecutstr($message, 150));
             if (!empty($_G['forum_attachexist'])) {
                 $imgattach = C::t('forum_attachment_n')->fetch_max_image('tid:' . $tid, 'pid', $pid);
                 $firstaid = $imgattach['aid'];
                 unset($imgattach);
                 if ($firstaid) {
                     $feed['images'] = array(getforumimg($firstaid));
                     $feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}");
                 }
             }
         } elseif ($special > 0) {
             if ($special == 1) {
                 $pvs = explode("\t", messagecutstr($polloptionpreview, 150));
                 $s = '';
                 $i = 1;
                 foreach ($pvs as $pv) {
                     $s .= $i . '. ' . $pv . '<br />';
                 }
                 $s .= '&nbsp;&nbsp;&nbsp;...';
                 $feed['icon'] = 'poll';
                 $feed['title_template'] = 'feed_thread_poll_title';
                 $feed['body_template'] = 'feed_thread_poll_message';
                 $feed['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$tid}\">{$subject}</a>", 'message' => $s);
             } elseif ($special == 3) {
                 $feed['icon'] = 'reward';
                 $feed['title_template'] = 'feed_thread_reward_title';
                 $feed['body_template'] = 'feed_thread_reward_message';
                 $feed['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$tid}\">{$subject}</a>", 'rewardprice' => $rewardprice, 'extcredits' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]['title']);
             } elseif ($special == 4) {
                 $feed['icon'] = 'activity';
                 $feed['title_template'] = 'feed_thread_activity_title';
                 $feed['body_template'] = 'feed_thread_activity_message';
                 $feed['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$tid}\">{$subject}</a>", 'starttimefrom' => $_GET['starttimefrom'][$activitytime], 'activityplace' => $activity['place'], 'message' => messagecutstr($message, 150));
                 if ($_GET['activityaid']) {
                     $feed['images'] = array(getforumimg($_GET['activityaid']));
                     $feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}");
                 }
             } elseif ($special == 5) {
                 $feed['icon'] = 'debate';
                 $feed['title_template'] = 'feed_thread_debate_title';
                 $feed['body_template'] = 'feed_thread_debate_message';
                 $feed['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$tid}\">{$subject}</a>", 'message' => messagecutstr($message, 150), 'affirmpoint' => messagecutstr($affirmpoint, 150), 'negapoint' => messagecutstr($negapoint, 150));
             }
         }
         $feed['title_data']['hash_data'] = "tid{$tid}";
         $feed['id'] = $tid;
         $feed['idtype'] = 'tid';
         if ($feed['icon']) {
             postfeed($feed);
         }
     }
     if ($digest) {
         updatepostcredits('+', $_G['uid'], 'digest', $_G['fid']);
     }
     updatepostcredits('+', $_G['uid'], 'post', $_G['fid']);
     if ($isgroup) {
         C::t('forum_groupuser')->update_counter_for_user($_G['uid'], $_G['fid'], 1);
     }
     if (!$pid) {
         $obj->rs = SUCCESS;
         echo echo_json($obj);
         exit;
     }
     $subject = str_replace("\t", ' ', $subject);
     $lastpost = "{$tid}\t" . $subject . "\t{$publishdate}\t{$author}";
     C::t('forum_forum')->update($_G['fid'], array('lastpost' => $lastpost));
     C::t('forum_forum')->update_forum_counter($_G['fid'], 1, 1, 1);
     DB::query("DELETE FROM %t WHERE uid=%d", array('forum_attachment_unused', $_G['uid']));
     if (isset($rPostion) && !empty($rPostion)) {
         surround_user::insert_all_thread_location($longitude, $latitude, $location, $pid);
     }
     $data_post["rs"] = 1;
     $data_post["content"] = $modnewposts['modnewposts'] > 0 ? Common::get_unicode_charset('\\u65b0\\u4e3b\\u9898\\u9700\\u8981\\u5ba1\\u6838\\uff0c\\u60a8\\u7684\\u5e16\\u5b50\\u901a\\u8fc7\\u5ba1\\u6838\\u540e\\u624d\\u80fd\\u663e\\u793a') : '';
     return $data_post;
 }
function convertunusedattach($aid, $tid, $pid)
{
    if (!$aid) {
        return;
    }
    global $_G;
    $attach = DB::fetch_first("SELECT * FROM " . DB::table('forum_attachment_unused') . " WHERE aid='{$aid}' AND uid='{$_G['uid']}'");
    if (!$attach) {
        return;
    }
    $attach = daddslashes($attach);
    $attach['tid'] = $tid;
    $attach['pid'] = $pid;
    DB::insert(getattachtablebytid($tid), $attach, false);
    DB::update('forum_attachment', array('tid' => $tid, 'pid' => $pid, 'tableid' => getattachtableid($tid)), "aid='{$attach['aid']}'");
    DB::delete('forum_attachment_unused', "aid='{$attach['aid']}'");
}
Example #14
0
function updateattach($modnewthreads, $tid, $pid, $attachnew, $attachupdate = array(), $uid = 0)
{
    global $_G;
    $thread = C::t('forum_thread')->fetch($tid);
    $uid = $uid ? $uid : $_G['uid'];
    if ($attachnew) {
        $newaids = array_keys($attachnew);
        $newattach = $newattachfile = $albumattach = array();
        foreach (C::t('forum_attachment_unused')->fetch_all($newaids) as $attach) {
            if ($attach['uid'] != $uid && !$_G['forum']['ismoderator']) {
                continue;
            }
            $attach['uid'] = $uid;
            $newattach[$attach['aid']] = daddslashes($attach);
            if ($attach['isimage']) {
                $newattachfile[$attach['aid']] = $attach['attachment'];
            }
        }
        if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark']) || !$_G['setting']['thumbdisabledmobile']) {
            require_once libfile('class/image');
            $image = new image();
        }
        if (!empty($_GET['albumaid'])) {
            array_unshift($_GET['albumaid'], '');
            $_GET['albumaid'] = array_unique($_GET['albumaid']);
            unset($_GET['albumaid'][0]);
            foreach ($_GET['albumaid'] as $aid) {
                if (isset($newattach[$aid])) {
                    $albumattach[$aid] = $newattach[$aid];
                }
            }
        }
        foreach ($attachnew as $aid => $attach) {
            $update = array();
            $update['readperm'] = $_G['group']['allowsetattachperm'] ? $attach['readperm'] : 0;
            $update['price'] = $_G['group']['maxprice'] ? intval($attach['price']) <= $_G['group']['maxprice'] ? intval($attach['price']) : $_G['group']['maxprice'] : 0;
            $update['tid'] = $tid;
            $update['pid'] = $pid;
            $update['uid'] = $uid;
            $update['description'] = censor(cutstr(dhtmlspecialchars($attach['description']), 100));
            C::t('forum_attachment_n')->update('tid:' . $tid, $aid, $update);
            if (!$newattach[$aid]) {
                continue;
            }
            $update = array_merge($update, $newattach[$aid]);
            if (!empty($newattachfile[$aid])) {
                if ($_G['setting']['thumbstatus'] && $_G['forum']['disablethumb']) {
                    $update['thumb'] = 0;
                    @unlink($_G['setting']['attachdir'] . '/forum/' . getimgthumbname($newattachfile[$aid]));
                    if (!empty($albumattach[$aid])) {
                        $albumattach[$aid]['thumb'] = 0;
                    }
                } elseif (!$_G['setting']['thumbdisabledmobile']) {
                    $_daid = sprintf("%09d", $aid);
                    $dir1 = substr($_daid, 0, 3);
                    $dir2 = substr($_daid, 3, 2);
                    $dir3 = substr($_daid, 5, 2);
                    $dw = 320;
                    $dh = 320;
                    $thumbfile = 'image/' . $dir1 . '/' . $dir2 . '/' . $dir3 . '/' . substr($_daid, -2) . '_' . $dw . '_' . $dh . '.jpg';
                    $image->Thumb($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], $thumbfile, $dw, $dh, 'fixwr');
                    $dw = 720;
                    $dh = 720;
                    $thumbfile = 'image/' . $dir1 . '/' . $dir2 . '/' . $dir3 . '/' . substr($_daid, -2) . '_' . $dw . '_' . $dh . '.jpg';
                    $image->Thumb($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], $thumbfile, $dw, $dh, 'fixwr');
                }
                if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
                    $image->Watermark($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], '', 'forum');
                    $update['filesize'] = $image->imginfo['size'];
                }
            }
            if (!empty($_GET['albumaid']) && isset($albumattach[$aid])) {
                $newalbum = 0;
                if (!$_GET['uploadalbum']) {
                    require_once libfile('function/spacecp');
                    $_GET['uploadalbum'] = album_creat(array('albumname' => $_GET['newalbum']));
                    $newalbum = 1;
                }
                $picdata = array('albumid' => $_GET['uploadalbum'], 'uid' => $uid, 'username' => $_G['username'], 'dateline' => $albumattach[$aid]['dateline'], 'postip' => $_G['clientip'], 'filename' => censor($albumattach[$aid]['filename']), 'title' => censor(cutstr(dhtmlspecialchars($attach['description']), 100)), 'type' => fileext($albumattach[$aid]['attachment']), 'size' => $albumattach[$aid]['filesize'], 'filepath' => $albumattach[$aid]['attachment'], 'thumb' => $albumattach[$aid]['thumb'], 'remote' => $albumattach[$aid]['remote'] + 2);
                $update['picid'] = C::t('home_pic')->insert($picdata, 1);
                if ($newalbum) {
                    require_once libfile('function/home');
                    require_once libfile('function/spacecp');
                    album_update_pic($_GET['uploadalbum']);
                }
            }
            C::t('forum_attachment_n')->insert('tid:' . $tid, $update, false, true);
            C::t('forum_attachment')->update($aid, array('tid' => $tid, 'pid' => $pid, 'tableid' => getattachtableid($tid)));
            C::t('forum_attachment_unused')->delete($aid);
        }
        if (!empty($_GET['albumaid'])) {
            $albumdata = array('picnum' => C::t('home_pic')->check_albumpic($_GET['uploadalbum']), 'updatetime' => $_G['timestamp']);
            C::t('home_album')->update($_GET['uploadalbum'], $albumdata);
            require_once libfile('function/home');
            require_once libfile('function/spacecp');
            album_update_pic($_GET['uploadalbum']);
        }
        if ($newattach) {
            ftpupload($newaids, $uid);
        }
    }
    if (!$modnewthreads && $newattach && $uid == $_G['uid']) {
        updatecreditbyaction('postattach', $uid, array(), '', count($newattach), 1, $_G['fid']);
    }
    if ($attachupdate) {
        $attachs = C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $tid, 'aid', array_keys($attachupdate));
        foreach ($attachs as $attach) {
            if (array_key_exists($attach['aid'], $attachupdate) && $attachupdate[$attach['aid']]) {
                dunlink($attach);
            }
        }
        $unusedattachs = C::t('forum_attachment_unused')->fetch_all($attachupdate);
        $attachupdate = array_flip($attachupdate);
        $unusedaids = array();
        foreach ($unusedattachs as $attach) {
            if ($attach['uid'] != $uid && !$_G['forum']['ismoderator']) {
                continue;
            }
            $unusedaids[] = $attach['aid'];
            $update = $attach;
            $update['dateline'] = TIMESTAMP;
            $update['remote'] = 0;
            unset($update['aid']);
            if ($attach['isimage'] && $_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
                $image->Watermark($_G['setting']['attachdir'] . '/forum/' . $attach['attachment'], '', 'forum');
                $update['filesize'] = $image->imginfo['size'];
            }
            C::t('forum_attachment_n')->update('tid:' . $tid, $attachupdate[$attach['aid']], $update);
            @unlink($_G['setting']['attachdir'] . 'image/' . $attach['aid'] . '_100_100.jpg');
            C::t('forum_attachment_exif')->delete($attachupdate[$attach['aid']]);
            C::t('forum_attachment_exif')->update($attach['aid'], array('aid' => $attachupdate[$attach['aid']]));
            ftpupload(array($attachupdate[$attach['aid']]), $uid);
        }
        if ($unusedaids) {
            C::t('forum_attachment_unused')->delete($unusedaids);
        }
    }
    $attachcount = C::t('forum_attachment_n')->count_by_id('tid:' . $tid, $pid ? 'pid' : 'tid', $pid ? $pid : $tid);
    $attachment = 0;
    if ($attachcount) {
        if (C::t('forum_attachment_n')->count_image_by_id('tid:' . $tid, $pid ? 'pid' : 'tid', $pid ? $pid : $tid)) {
            $attachment = 2;
        } else {
            $attachment = 1;
        }
    } else {
        $attachment = 0;
    }
    C::t('forum_thread')->update($tid, array('attachment' => $attachment));
    C::t('forum_post')->update('tid:' . $tid, $pid, array('attachment' => $attachment), true);
    if (!$attachment) {
        C::t('forum_threadimage')->delete_by_tid($tid);
    }
    $_G['forum_attachexist'] = $attachment;
}
Example #15
0
function followcode($message, $tid = 0, $pid = 0, $length = 0, $allowimg = true)
{
    global $_G;
    include_once libfile('function/post');
    $message = strip_tags($message);
    $message = messagesafeclear($message);
    if ((strpos($message, '[/code]') || strpos($message, '[/CODE]')) !== FALSE) {
        $message = preg_replace("/\\s?\\[code\\](.+?)\\[\\/code\\]\\s?/ies", "", $message);
    }
    $msglower = strtolower($message);
    $htmlon = 0;
    $message = dhtmlspecialchars($message);
    if ($_G['setting']['plugins']['func'][HOOKTYPE]['discuzcode']) {
        $_G['discuzcodemessage'] =& $message;
        $param = func_get_args();
        hookscript('discuzcode', 'global', 'funcs', array('param' => $param, 'caller' => 'discuzcode'), 'discuzcode');
    }
    $_G['delattach'] = array();
    $message = fparsesmiles($message);
    if (strpos($msglower, 'attach://') !== FALSE) {
        $message = preg_replace("/attach:\\/\\/(\\d+)\\.?(\\w*)/ie", '', $message);
    }
    if (strpos($msglower, 'ed2k://') !== FALSE) {
        $message = preg_replace("/ed2k:\\/\\/(.+?)\\//e", '', $message);
    }
    if (strpos($msglower, '[/i]') !== FALSE) {
        $message = preg_replace("/\\s*\\[i=s\\][\n\r]*(.+?)[\n\r]*\\[\\/i\\]\\s*/is", '', $message);
    }
    $message = str_replace('[/p]', "\n", $message);
    $message = str_replace(array('[/color]', '[/backcolor]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]', '[s]', '[/s]', '[hr]', '[i=s]', '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]', '[list=A]', "\r\n[*]", '[*]', '[/list]', '[indent]', '[/indent]', '[/float]'), '', preg_replace(array("/\\[color=([#\\w]+?)\\]/i", "/\\[color=((rgb|rgba)\\([\\d\\s,]+?\\))\\]/i", "/\\[backcolor=([#\\w]+?)\\]/i", "/\\[backcolor=((rgb|rgba)\\([\\d\\s,]+?\\))\\]/i", "/\\[size=(\\d{1,2}?)\\]/i", "/\\[size=(\\d{1,2}(\\.\\d{1,2}+)?(px|pt)+?)\\]/i", "/\\[font=([^\\[\\<]+?)\\]/i", "/\\[align=(left|center|right)\\]/i", "/\\[float=left\\]/i", "/\\[float=right\\]/i"), '', $message));
    if (strpos($msglower, '[/p]') !== FALSE) {
        $message = preg_replace("/\\[p=(\\d{1,2}|null), (\\d{1,2}|null), (left|center|right)\\]/i", "<p style=\"line-height:\\1px;text-indent:\\2em;text-align:left;\">", $message);
        $message = str_replace('[/p]', '</p>', $message);
    }
    if (strpos($msglower, '[/quote]') !== FALSE) {
        $message = preg_replace("/\\s?\\[quote\\][\n\r]*(.+?)[\n\r]*\\[\\/quote\\]\\s?/is", '', $message);
    }
    if (strpos($msglower, '[/free]') !== FALSE) {
        $message = preg_replace("/\\s*\\[free\\][\n\r]*(.+?)[\n\r]*\\[\\/free\\]\\s*/is", '', $message);
    }
    if (isset($_G['cache']['bbcodes'][-$allowbbcode])) {
        $message = preg_replace($_G['cache']['bbcodes'][-$allowbbcode]['searcharray'], '', $message);
    }
    if (strpos($msglower, '[/hide]') !== FALSE) {
        preg_replace("/\\[hide.*?\\]\\s*(.*?)\\s*\\[\\/hide\\]/ies", "hideattach('\\1')", $message);
        if (strpos($msglower, '[hide]') !== FALSE) {
            $message = preg_replace("/\\[hide\\]\\s*(.*?)\\s*\\[\\/hide\\]/is", '', $message);
        }
        if (strpos($msglower, '[hide=') !== FALSE) {
            $message = preg_replace("/\\[hide=(d\\d+)?[,]?(\\d+)?\\]\\s*(.*?)\\s*\\[\\/hide\\]/ies", '', $message);
        }
    }
    if (strpos($msglower, '[/url]') !== FALSE) {
        $message = preg_replace("/\\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\\/\\/|www\\.|mailto:)?([^\r\n\\[\"']+?))?\\](.+?)\\[\\/url\\]/ies", "fparseurl('\\1', '\\5', '\\2')", $message);
    }
    if (strpos($msglower, '[/email]') !== FALSE) {
        $message = preg_replace("/\\[email(=([a-z0-9\\-_.+]+)@([a-z0-9\\-_]+[.][a-z0-9\\-_.]+))?\\](.+?)\\[\\/email\\]/ies", "fparseemail('\\1', '\\4')", $message);
    }
    $nest = 0;
    while (strpos($msglower, '[table') !== FALSE && strpos($msglower, '[/table]') !== FALSE) {
        $message = preg_replace("/\\[table(?:=(\\d{1,4}%?)(?:,([\\(\\)%,#\\w ]+))?)?\\]\\s*(.+?)\\s*\\[\\/table\\]/ies", "fparsetable('\\1', '\\2', '\\3')", $message);
        if (++$nest > 4) {
            break;
        }
    }
    if (strpos($msglower, '[/media]') !== FALSE) {
        $message = preg_replace("/\\[media=([\\w,]+)\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/media\\]/ies", "fparsemedia('\\1', '\\2')", $message);
    }
    if (strpos($msglower, '[/audio]') !== FALSE) {
        $message = preg_replace("/\\[audio(=1)*\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/audio\\]/ies", "fparseaudio('\\2')", $message);
    }
    if (strpos($msglower, '[/flash]') !== FALSE) {
        $message = preg_replace("/\\[flash(=(\\d+),(\\d+))?\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/flash\\]/ies", "fparseflash('\\4');", $message);
    }
    if ($parsetype != 1 && strpos($msglower, '[swf]') !== FALSE) {
        $message = preg_replace("/\\[swf\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/swf\\]/ies", "bbcodeurl('\\1', ' <img src=\"'.STATICURL.'image/filetype/flash.gif\" align=\"absmiddle\" alt=\"\" /> <a href=\"{url}\" target=\"_blank\">Flash: {url}</a> ')", $message);
    }
    $flag = $length ? 1 : 0;
    if ($tid) {
        $extra = "onclick=\"changefeed({$tid}, {$pid}, {$flag}, this)\"";
    }
    if (strpos($msglower, '[/img]') !== FALSE) {
        $message = preg_replace(array("/\\[img\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/ies", "/\\[img=(\\d{1,4})[x|\\,](\\d{1,4})\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/ies"), $allowimg ? array("fparseimg('\\1', '{$extra}')", "fparseimg('\\3', '{$extra}')") : '', $message);
    }
    if ($tid && $pid) {
        $_G['post_attach'] = C::t('forum_attachment_n')->fetch_all_by_id(getattachtableid($tid), 'pid', $pid);
        foreach ($_G['post_attach'] as $aid => $attach) {
            if (!empty($_G['delattach']) && in_array($aid, $_G['delattach'])) {
                continue;
            }
            $message .= "[attach]{$attach['aid']}[/attach]";
            $message = preg_replace("/\\[attach\\]{$attach['aid']}\\[\\/attach\\]/i", fparseattach($attach['aid'], $length, $extra), $message, 1);
        }
    }
    if (strpos($msglower, '[/attach]') !== FALSE) {
        $message = preg_replace("/\\[attach\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/attach\\]/ies", '', $message);
    }
    $message = clearnl($message);
    if ($length) {
        $sppos = strpos($message, chr(0) . chr(0) . chr(0));
        if ($sppos !== false) {
            $message = substr($message, 0, $sppos);
        }
        $checkstr = cutstr($message, $length, '');
        if (strpos($checkstr, '[') && strpos(strrchr($checkstr, "["), ']') === FALSE) {
            $length = strpos($message, ']', strrpos($checkstr, strrchr($checkstr, "[")));
        }
        $message = cutstr($message, $length + 1, ' <a href="javascript:;" class="flw_readfull xi2 xs1"' . $extra . '>' . lang('space', 'follow_view_fulltext') . '</a>');
    } elseif ($allowimg && !empty($extra)) {
        $message .= '<div class="ptm cl"><a href="javascript:;" class="flw_readfull y xi2 xs1"' . $extra . '>' . lang('space', 'follow_retract') . '</a></div>';
    }
    for ($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) {
        $code = '';
        if (isset($_G['forum_discuzcode']['codehtml'][$i]) && !empty($_G['forum_discuzcode']['codehtml'][$i])) {
            $code = $_G['forum_discuzcode']['codehtml'][$i];
        } elseif (!$length) {
            if (isset($_G['forum_discuzcode']['audio'][$i]) && !empty($_G['forum_discuzcode']['audio'][$i])) {
                $code = $_G['forum_discuzcode']['audio'][$i];
            } elseif (isset($_G['forum_discuzcode']['video'][$i]) && !empty($_G['forum_discuzcode']['video'][$i])) {
                $code = $_G['forum_discuzcode']['video'][$i];
            } elseif (isset($_G['forum_discuzcode']['media'][$i]) && !empty($_G['forum_discuzcode']['media'][$i])) {
                $code = $_G['forum_discuzcode']['media'][$i];
            } elseif (isset($_G['forum_discuzcode']['image'][$i]) && !empty($_G['forum_discuzcode']['image'][$i])) {
                $code = $_G['forum_discuzcode']['image'][$i];
            } elseif (isset($_G['forum_discuzcode']['attach'][$i]) && !empty($_G['forum_discuzcode']['attach'][$i])) {
                $code = $_G['forum_discuzcode']['attach'][$i];
            }
        }
        $message = str_replace("[\tD_{$i}\t]", $code, $message);
    }
    $message = clearnl($message);
    if (!empty($_GET['highlight'])) {
        $highlightarray = explode('+', $_GET['highlight']);
        $sppos = strrpos($message, chr(0) . chr(0) . chr(0));
        if ($sppos !== FALSE) {
            $specialextra = substr($message, $sppos + 3);
            $message = substr($message, 0, $sppos);
        }
        $message = preg_replace(array("/(^|>)([^<]+)(?=<|\$)/sUe", "/<highlight>(.*)<\\/highlight>/siU"), array("highlightword('\\2', \$highlightarray, '\\1')", "<strong><font color=\"#FF0000\">\\1</font></strong>"), $message);
        if ($sppos !== FALSE) {
            $message = $message . chr(0) . chr(0) . chr(0) . $specialextra;
        }
    }
    unset($msglower);
    if ($length) {
        $count = 0;
        $imagecode = $mediacode = $videocode = $audiocode = $mediahtml = '';
        for ($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) {
            if (isset($_G['forum_discuzcode']['audio'][$i]) && !empty($_G['forum_discuzcode']['audio'][$i])) {
                $audiocode .= '<li>' . $_G['forum_discuzcode']['audio'][$attachcodei] . '</li>';
            } elseif (isset($_G['forum_discuzcode']['video'][$i]) && !empty($_G['forum_discuzcode']['video'][$i])) {
                $videocode .= '<li>' . $_G['forum_discuzcode']['video'][$i] . '</li>';
            } elseif (isset($_G['forum_discuzcode']['media'][$i]) && !empty($_G['forum_discuzcode']['media'][$i])) {
                $mediacode .= '<li>' . $_G['forum_discuzcode']['media'][$i] . '</li>';
            } elseif (isset($_G['forum_discuzcode']['image'][$i]) && !empty($_G['forum_discuzcode']['image'][$i]) && $count < 4) {
                $imagecode .= '<li>' . $_G['forum_discuzcode']['image'][$i] . '</li>';
                $count++;
            } elseif (isset($_G['forum_discuzcode']['attach'][$i]) && !empty($_G['forum_discuzcode']['attach'][$i])) {
                $attachcode .= '<li>' . $_G['forum_discuzcode']['attach'][$i] . '</li>';
            }
        }
        if (!empty($audiocode)) {
            $message .= '<div class="flw_music"><ul>' . $audiocode . '</ul></div>';
        }
        if (!empty($videocode)) {
            $message .= '<div class="flw_video"><ul>' . $videocode . '</ul></div>';
        }
        if (!empty($mediacode)) {
            $message .= '<div class="flw_video"><ul>' . $mediacode . '</ul></div>';
        }
        if (!empty($imagecode)) {
            $message = '<div class="flw_image' . ($count < 2 ? ' flw_image_1' : '') . '"><ul>' . $imagecode . '</ul></div>' . $message;
        }
        if (!empty($attachcode)) {
            $message .= '<div class="flw_attach"><ul>' . $attachcode . '</ul></div>';
        }
    }
    return $htmlon ? $message : nl2br(str_replace(array("\t", '   ', '  '), ' ', $message));
}
Example #16
0
 public function parseTopic($_G, $postlist, $forumclass, $uid, $temp)
 {
     foreach ($postlist as $pid => $post) {
         //print_r($postlist);exit;
         if (!empty($post['tid'])) {
             $topicRemote = DB::fetch(DB::query("SELECT remote FROM " . DB::table('forum_threadimage') . " where tid=" . $post['tid']));
             //print_r($topicRemote);exit;
         }
         $uids[] = $post['authorid'];
         preg_match_all("/\\[attach\\](\\d+)\\[\\/attach\\]/i", $postlist[$pid]['message'], $matches);
         $aids = $matches['1'];
         $matches = array_filter($matches);
         foreach (C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $post['tid'], 'pid', $post['pid']) as $attach) {
             $Allaids[] = $attach['aid'];
         }
         if (count($aids) !== count($Allaids)) {
             $tableid = getattachtableid($post['tid']);
             $attachmentAid = C::t('forum_attachment')->fetch_all_by_id('pid', $post['pid']);
             foreach ($attachmentAid as $key => $val) {
                 if (in_array($key, $aids)) {
                     continue;
                 }
                 $path = DB::fetch_first("SELECT * FROM %t WHERE %i AND isimage IN ('1', '-1') ", array('forum_attachment_' . $tableid, DB::field('aid', $val['aid'])));
                 if (!empty($path)) {
                     $filename = $this->parseTargeImage($path);
                     $imgs[] = '<img src="' . $filename . '" />';
                     $attachmentId = $key;
                     $attachmentAId[] = $path['aid'];
                     $postlist[$pid]['message'] = $postlist[$pid]['message'] . '[attach]' . $key . '[/attach]';
                     $pattern[] = "#\\[attach\\]" . $key . "\\[\\/attach\\]#i";
                 }
             }
         }
         if (!empty($matches) && is_array($matches)) {
             foreach ($matches[1] as $k => $v) {
                 $dataImg['attachment'] = $post['attachments'][$v]['attachment'];
                 $dataImg['dateline'] = $post['dateline'];
                 $dataImg['remote'] = $post['attachments'][$v]['remote'];
                 $filename = $this->parseTargeImage($dataImg);
                 $imgs[] = '<img src="' . $filename . '" />';
                 $attachmentId = $v;
             }
         }
         foreach ($matches[1] as $k => $v) {
             $pattern[] = "#\\[attach\\]" . $v . "\\[\\/attach\\]#i";
         }
         $message_string = preg_replace($pattern, $imgs, $postlist[$pid]['message']);
         if ($message_string) {
             $postlist[$pid]['message'] = $message_string;
         }
         $tempPostlist = $forumclass->viewthread_procpost($postlist[$pid], $_G['member']['lastvisit'], 2, 2);
         /*$ti1=Common::get_web_unicode_charset('\u6e38\u5ba2');
         			$tempPostlist[message]=str_replace($ti1,'',$tempPostlist[message]);
         		echo ($tempPostlist[message]);exit;*/
         $topicContent = text_replace($tempPostlist['message']);
         $topicContent = discuzcode($topicContent, $post['smileyoff'], $post['bbcodeoff']);
         $topicContent = str_replace('<img src="static/', '<img src="/static/', $topicContent);
         $postlist[$pid]['message'] = text_replace($topicContent);
         $postlist[$pid]['message'] = preg_replace("/\\<font class=\"jammer\">.+\\<\\/font>/i", '', $postlist[$pid]['message']);
         $postlist[$pid]['message'] = preg_replace("/\\<span style=\"display:none\">.+\\<\\/span>/i", '', $postlist[$pid]['message']);
         $img_url = $post['attachments'][$attachmentId]['url'];
         $font[$pid]['quote_content'] = getContent($post['quotemessage']);
         $font[$pid]['quote_content'] = preg_replace("/\\[attach\\]\\d+\\[\\/attach\\]/i", '', $font[$pid]['quote_content']);
         $tempPostlist_quote_content = $forumclass->viewthread_procpost($post, $_G['member']['lastvisit'], 2, 2);
         $topicContent_quote_content = text_replace($tempPostlist_quote_content['quotemessage']);
         $topicContent_quote_content = discuzcode($topicContent_quote_content, $post['smileyoff'], $post['bbcodeoff']);
         $topicContent_quote_content = str_replace('<img src="static/', '<img src="/static/', $topicContent_quote_content);
         $font[$pid]['quote_content'] = text_replace($topicContent_quote_content);
     }
     $uids = array_unique($uids);
     empty($uid) ? 0 : $uid;
     $uidsql = ' AND ' . DB::field('uid', $uid);
     $fav = DB::fetch_first("SELECT * FROM %t WHERE id=%d AND idtype=%s {$uidsql}", array('home_favorite', $_G['tid'], 'tid'));
     if ($fav) {
         $is_favor = 1;
     } else {
         $is_favor = 0;
     }
     $profile = new memberProfile();
     $profile_list = $profile->get_profile_by_uid($uids, 'gender');
     foreach ($profile_list as $k => $v) {
         $data_profile[$v['uid']]['gender'] = $v['gender'];
         $data_profile[$v['uid']]['level'] = (int) $v['stars'];
     }
     $member = commonMember::getUserStatus($uids);
     $special = get_special_by_tid($_G['tid']);
     if ($special == 2) {
         $i = 0;
         foreach ($postlist as $key => $val) {
             if ($i == 1) {
                 $key1 = $key;
             }
             $i++;
         }
     }
     unset($postlist[$key1]);
     $_user = Anonymous_User($_G['tid']);
     $content = $this->parseTradeTopic($_G, $post);
     foreach ($postlist as $key => $val) {
         $post = $tags = array();
         $thread = C::t('forum_thread')->fetch($val['tid']);
         $post['gender'] = $data_profile[$val['authorid']]['gender'];
         $post['level'] = $data_profile[$val['authorid']]['level'];
         $tags = explode(',', $val['tags']);
         global $_G;
         preg_match_all("/\\[(\\d+)\\]+/i", $val['message'], $smailyArr);
         $thisUrl = dirname('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) . '/../../';
         foreach ($smailyArr[1] as $key => $Sval) {
             /*rx 20131016 tie zi xiang qing biao qing chu li*/
             $smArr = DB::fetch(DB::query("SELECT * FROM " . DB::table('common_smiley') . " where id=" . $Sval));
             $smTypeArr = DB::fetch(DB::query("SELECT directory FROM " . DB::table('forum_imagetype') . " where typeid=" . $smArr['typeid']));
             $smUrl = $thisUrl . 'static/image/' . $smArr['type'] . '/' . $smTypeArr['directory'] . '/' . $smArr['url'];
             $smile .= "[mobcent_phiz=" . $smUrl . "]";
             /*end rx 20131016*/
             $_G['cache']['smilies']['searcharray'][$Sval] = str_replace('/', "", $_G['cache']['smilies']['searcharray'][$Sval]);
             $val['message'] = str_replace($smailyArr[0][$key], $smile, $val['message']);
             unset($smile);
         }
         if ($tags[0] > 0 || $val['position'] == 1) {
             $message1 = doContent($val['message'], $val[imagelist]);
             $message2 = getContentFont($val['message']);
             foreach ($message1 as $k => $v) {
                 if ($v['type'] == 0) {
                     unset($message1[$k]);
                 } else {
                 }
             }
             $message_array2 = explode('|~|', $message2);
             $message2 = str_replace('[', '1', $message2);
             $message2 = str_replace(']', '1', $message2);
             if (is_array($message_array2) && count($message_array2) > 0) {
                 foreach ($message_array2 as $k => $v) {
                     $message[] = array("infor" => $v, "originalInfo" => '', "type" => 0);
                     if ($message1[$k]["infor"] && !empty($message1)) {
                         $message[] = $message1[$k];
                     }
                 }
             } else {
                 $message = getContentFont($val['message']);
             }
             $post['hits'] = (int) $thread['views'];
             $post['replies'] = (int) $thread['replies'];
             $post['essence'] = (int) $thread['digest'] > 0 || (int) $thread['icon'] == 9 || (int) $thread['stamp'] == 0 ? 1 : 0;
             $post['content'] = $message;
             $post['create_date'] = $val['dateline'] . "000";
             $post['icon'] = userIconImg($val['authorid']);
             $post['is_favor'] = (int) $is_favor;
             if ($val['invisible'] == -5 || $val['invisible'] == -1) {
                 $post['status'] = (int) 0;
                 $arr['rs'] = 0;
                 $arr['errcode'] = '01040007';
                 return $arr;
                 exit;
             } else {
                 if ($thread['closed'] == 1) {
                     $post['status'] = 2;
                 } else {
                     $post['status'] = 1;
                 }
             }
             $post['title'] = $val['subject'];
             $post['topic_id'] = (int) $val['tid'];
             $post['user_id'] = (int) $val['authorid'];
             if (empty($val['author']) && isset($val['authorid']) && !empty($val['authorid'])) {
                 $post['reply_status'] = (int) '-1 ';
                 $post['user_nick_name'] = Common::get_unicode_charset('\\u8be5\\u7528\\u6237\\u5df2\\u88ab\\u5220\\u9664');
             } else {
                 if (empty($val['author']) && empty($val['authorid'])) {
                     $post['reply_status'] = (int) '0 ';
                     $post['user_nick_name'] = Common::get_unicode_charset('\\u533f\\u540d\\u7528\\u6237');
                 } else {
                     $post['reply_status'] = (int) '1 ';
                     $post['user_nick_name'] = $val['author'];
                 }
             }
             $post['reply_posts_id'] = (int) $val['pid'];
             $info = surround_user::fetch_all_by_pid($val['tid']);
             if (empty($info)) {
                 $post['location'] = '';
             } else {
                 $post['location'] = $info['location'];
             }
             $data_post["topic"] = $post;
         } else {
             $message1 = doContent($val['message'], $val[imagelist]);
             $message2 = getContentFont($val['message']);
             foreach ($message1 as $k => $v) {
                 if ($v['type'] == 0) {
                     unset($message1[$k]);
                 } else {
                 }
             }
             $message_array2 = explode('|~|', $message2);
             $message2 = str_replace('[', '1', $message2);
             $message2 = str_replace(']', '1', $message2);
             if (is_array($message_array2) && count($message_array2) > 0) {
                 foreach ($message_array2 as $k => $v) {
                     $message[] = array("infor" => $v, "originalInfo" => '', "type" => 0);
                     if ($message1[$k]["infor"] && !empty($message1)) {
                         $message[] = $message1[$k];
                     }
                 }
             } else {
                 $message = getContentFont($val['message']);
             }
             $post['location'] = "";
             $post['icon'] = userIconImg($val['authorid']);
             $post['posts_date'] = $val['dateline'] . "000";
             $post['reply_content'] = $message;
             $post['reply_id'] = (int) $val['authorid'];
             if (empty($val['author']) && isset($val['authorid']) && !empty($val['authorid'])) {
                 $post['reply_status'] = (int) '-1 ';
                 $post['reply_name'] = Common::get_unicode_charset('\\u8be5\\u7528\\u6237\\u5df2\\u88ab\\u5220\\u9664');
             } else {
                 if (empty($val['author']) && empty($val['authorid'])) {
                     $post['reply_status'] = (int) '0 ';
                     $post['reply_name'] = Common::get_unicode_charset('\\u533f\\u540d\\u7528\\u6237');
                 } else {
                     $post['reply_status'] = (int) '1 ';
                     $post['reply_name'] = $val['author'];
                 }
             }
             $post['reply_posts_id'] = (int) $val['pid'];
             if ($val['invisible'] == -5) {
                 $post['status'] = (int) 0;
             } else {
                 if ($thread['closed'] == 1) {
                     $post['status'] = 2;
                 } else {
                     $post['status'] = 1;
                 }
             }
             $post['title'] = preg_replace("#(\\w*)\\<.*?\\>(\\w*)#", "\$1\$2", $val['subject']);
             $post['role_num'] = $val['groupid'];
             $post['is_quote'] = (bool) $val['is_quote'];
             $post['quote_pid'] = $val['quote_pid'];
             if ((bool) $val['is_quote'] != false) {
                 $post["quote_content"] = preg_replace("/\\[attach\\]\\d+\\[\\/attach\\]/i", '', preg_replace("#(\\w*)\\<.*?\\>(\\w*)#", "\$1\$2", $font[$post['reply_posts_id']]['quote_content']));
             } else {
                 $post["quote_content"] = '';
             }
             $post["quote_user_name"] = null;
             $post['position'] = $val['position'];
             $info = surround_user::fetch_all_by_pid($val['tid']);
             if (empty($info)) {
                 $post['location'] = '';
             } else {
                 $post['location'] = $info['location'];
             }
             $data_post['list'][] = $post;
             unset($quote);
             unset($pid);
             $temp++;
         }
         unset($post);
         unset($message);
     }
     return $data_post;
 }
Example #17
0
function deletethread($tids, $membercount = false, $credit = false, $ponly = false)
{
    global $_G;
    if ($_G['setting']['plugins']['func'][HOOKTYPE]['deletethread']) {
        $_G['deletethreadtids'] =& $tids;
        $hookparam = func_get_args();
        hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'check'), 'deletethread');
    }
    if (!$tids) {
        return 0;
    }
    $count = count($tids);
    $arrtids = $tids;
    $tids = dimplode($tids);
    loadcache(array('threadtableids', 'posttableids'));
    $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array();
    $posttableids = !empty($_G['cache']['posttableids']) ? $_G['cache']['posttableids'] : array('0');
    if (!in_array(0, $threadtableids)) {
        $threadtableids = array_merge(array(0), $threadtableids);
    }
    C::t('common_moderate')->delete($arrtids, 'tid');
    C::t('forum_threadclosed')->delete($arrtids);
    $cachefids = $atids = $fids = $postids = $threadtables = array();
    foreach ($threadtableids as $tableid) {
        foreach (C::t('forum_thread')->fetch_all_by_tid($arrtids, 0, 0, $tableid) as $row) {
            $atids[] = $row['tid'];
            $row['posttableid'] = !empty($row['posttableid']) && in_array($row['posttableid'], $posttableids) ? $row['posttableid'] : '0';
            $postids[$row['posttableid']][$row['tid']] = $row['tid'];
            if ($tableid) {
                $fids[$row['fid']][] = $tableid;
            }
            $cachefids[$row['fid']] = $row['fid'];
        }
        if (!$tableid && !$ponly) {
            $threadtables[] = $tableid;
        }
    }
    if ($credit || $membercount) {
        $losslessdel = $_G['setting']['losslessdel'] > 0 ? TIMESTAMP - $_G['setting']['losslessdel'] * 86400 : 0;
        $postlist = $uidarray = $tuidarray = $ruidarray = array();
        foreach ($postids as $posttableid => $posttabletids) {
            foreach (C::t('forum_post')->fetch_all_by_tid($posttableid, $posttabletids, false) as $post) {
                if ($post['invisible'] != -1 && $post['invisible'] != -5) {
                    $postlist[] = $post;
                }
            }
        }
        foreach (C::t('forum_replycredit')->fetch_all($arrtids) as $rule) {
            $rule['extcreditstype'] = $rule['extcreditstype'] ? $rule['extcreditstype'] : $_G['setting']['creditstransextra'][10];
            $replycredit_rule[$rule['tid']] = $rule;
        }
        foreach ($postlist as $post) {
            if ($post['dateline'] < $losslessdel) {
                if ($membercount) {
                    if ($post['first']) {
                        updatemembercount($post['authorid'], array('threads' => -1, 'post' => -1), false);
                    } else {
                        updatemembercount($post['authorid'], array('posts' => -1), false);
                    }
                }
            } else {
                if ($credit) {
                    if ($post['first']) {
                        $tuidarray[$post['fid']][] = $post['authorid'];
                    } else {
                        $ruidarray[$post['fid']][] = $post['authorid'];
                    }
                }
            }
            if ($credit || $membercount) {
                if ($post['authorid'] > 0 && $post['replycredit'] > 0) {
                    if ($replycredit_rule[$post['tid']]['extcreditstype']) {
                        updatemembercount($post['authorid'], array($replycredit_rule[$post['tid']]['extcreditstype'] => (int) ('-' . $post['replycredit'])));
                    }
                }
            }
        }
        if ($credit) {
            if ($tuidarray || $ruidarray) {
                require_once libfile('function/post');
            }
            if ($tuidarray) {
                foreach ($tuidarray as $fid => $tuids) {
                    updatepostcredits('-', $tuids, 'post', $fid);
                }
            }
            if ($ruidarray) {
                foreach ($ruidarray as $fid => $ruids) {
                    updatepostcredits('-', $ruids, 'reply', $fid);
                }
            }
            $auidarray = $attachtables = array();
            foreach ($atids as $tid) {
                $attachtables[getattachtableid($tid)][] = $tid;
            }
            foreach ($attachtables as $attachtable => $attachtids) {
                foreach (C::t('forum_attachment_n')->fetch_all_by_id($attachtable, 'tid', $attachtids) as $attach) {
                    if ($attach['dateline'] > $losslessdel) {
                        $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1;
                    }
                }
            }
            if ($auidarray) {
                $postattachcredits = !empty($_G['forum']['postattachcredits']) ? $_G['forum']['postattachcredits'] : $_G['setting']['creditspolicy']['postattach'];
                updateattachcredits('-', $auidarray, $postattachcredits);
            }
        }
    }
    $relatecollection = C::t('forum_collectionthread')->fetch_all_by_tids($arrtids);
    if (count($relatecollection) > 0) {
        $collectionids = array();
        foreach ($relatecollection as $collection) {
            $collectionids[] = $collection['ctid'];
        }
        $collectioninfo = C::t('forum_collection')->fetch_all($collectionids);
        foreach ($relatecollection as $collection) {
            $decthread = C::t('forum_collectionthread')->delete_by_ctid_tid($collection['ctid'], $arrtids);
            $lastpost = null;
            if (in_array($collectioninfo[$collection['ctid']]['lastpost'], $arrtids) && $collectioninfo[$collection['ctid']]['threadnum'] - $decthread > 0) {
                $collection_thread = C::t('forum_collectionthread')->fetch_by_ctid_dateline($collection['ctid']);
                if ($collection_thread) {
                    $thread = C::t('forum_thread')->fetch($collection_thread['tid']);
                    $lastpost = array('lastpost' => $thread['tid'], 'lastsubject' => $thread['subject'], 'lastposttime' => $thread['dateline'], 'lastposter' => $thread['authorid']);
                }
            }
            C::t('forum_collection')->update_by_ctid($collection['ctid'], -$decthread, 0, 0, 0, 0, 0, $lastpost);
        }
        C::t('forum_collectionrelated')->delete($arrtids);
    }
    if ($cachefids) {
        C::t('forum_thread')->clear_cache($cachefids, 'forumdisplay_');
    }
    if ($ponly) {
        if ($_G['setting']['plugins']['func'][HOOKTYPE]['deletethread']) {
            hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread');
        }
        C::t('forum_thread')->update($arrtids, array('displayorder' => -1, 'digest' => 0, 'moderated' => 1));
        foreach ($postids as $posttableid => $oneposttids) {
            C::t('forum_post')->update_by_tid($posttableid, $oneposttids, array('invisible' => '-1'));
        }
        return $count;
    }
    C::t('forum_replycredit')->delete($arrtids);
    C::t('forum_post_location')->delete_by_tid($arrtids);
    C::t('common_credit_log')->delete_by_operation_relatedid(array('RCT', 'RCA', 'RCB'), $arrtids);
    deletethreadcover($arrtids);
    foreach ($threadtables as $tableid) {
        C::t('forum_thread')->delete_by_tid($arrtids, false, $tableid);
    }
    if ($atids) {
        foreach ($postids as $posttableid => $oneposttids) {
            deletepost($oneposttids, 'tid', false, $posttableid);
        }
        deleteattach($atids, 'tid');
    }
    if ($fids) {
        loadcache('forums');
        foreach ($fids as $fid => $tableids) {
            if (empty($_G['cache']['forums'][$fid]['archive'])) {
                continue;
            }
            foreach (C::t('forum_thread')->count_posts_by_fid($fid) as $row) {
                C::t('forum_forum_threadtable')->insert(array('fid' => $fid, 'threadtableid' => $tableid, 'threads' => $row['threads'], 'posts' => $row['posts']), false, true);
            }
        }
    }
    foreach (array('forum_forumrecommend', 'forum_polloption', 'forum_poll', 'forum_activity', 'forum_activityapply', 'forum_debate', 'forum_debatepost', 'forum_threadmod', 'forum_relatedthread', 'forum_pollvoter', 'forum_threadimage', 'forum_threadpreview') as $table) {
        C::t($table)->delete_by_tid($arrtids);
    }
    C::t('forum_typeoptionvar')->delete_by_tid($arrtids);
    C::t('forum_poststick')->delete_by_tid($arrtids);
    C::t('home_feed')->delete_by_id_idtype($arrtids, 'tid');
    C::t('common_tagitem')->delete(0, $tids, 'tid');
    C::t('forum_threadrush')->delete($arrtids);
    if ($_G['setting']['plugins']['func'][HOOKTYPE]['deletethread']) {
        hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread');
    }
    return $count;
}
    exit('Access Denied');
}
define('NOROBOT', TRUE);
@(list($_G['gp_aid'], $_G['gp_k'], $_G['gp_t'], $_G['gp_uid'], $_G['gp_tableid']) = daddslashes(explode('|', base64_decode($_G['gp_aid']))));
$aid = intval($_G['gp_aid']);
if (!empty($_G['gp_findpost']) && ($attach = DB::fetch_first("SELECT pid, tid FROM " . DB::table('forum_attachment') . " WHERE aid='{$aid}'"))) {
    dheader('location: forum.php?mod=redirect&goto=findpost&pid=' . $attach['pid'] . '&ptid=' . $attach['tid']);
}
if ($_G['gp_uid'] != $_G['uid'] && $_G['gp_uid']) {
    $_G['gp_uid'] = intval($_G['gp_uid']);
    $groupid = DB::result_first("SELECT groupid FROM " . DB::table('common_member') . " WHERE uid='{$_G['gp_uid']}'");
    loadcache('usergroup_' . $groupid);
    $_G['group'] = $_G['cache']['usergroup_' . $groupid];
}
$requestmode = !empty($_G['gp_request']) && empty($_G['gp_uid']);
$tableid = !empty($_G['gp_tableid']) ? getattachtableid($_G['gp_tableid']) : DB::result_first("SELECT tableid FROM " . DB::table('forum_attachment') . " WHERE aid='{$aid}'");
if (!is_numeric($tableid)) {
    if (!$requestmode) {
        showmessage('attachment_nonexistence');
    } else {
        exit;
    }
}
if ($_G['setting']['attachexpire']) {
    $k = $_G['gp_k'];
    $t = $_G['gp_t'];
    $authk = !$requestmode ? substr(md5($aid . md5($_G['config']['security']['authkey']) . $t . $_G['gp_uid']), 0, 8) : md5($aid . md5($_G['config']['security']['authkey']) . $t);
    if (empty($k) || empty($t) || $k != $authk || TIMESTAMP - $t > $_G['setting']['attachexpire'] * 3600) {
        $aid = intval($aid);
        if ($attach = DB::fetch_first("SELECT pid, tid, isimage FROM " . DB::table('forum_attachment_' . $tableid) . " WHERE aid='{$aid}'")) {
            if ($attach['isimage']) {
Example #19
0
function getattachtablebytid($tid)
{
    return 'forum_attachment_' . getattachtableid($tid);
}
Example #20
0
 public function update_by_id($idtype, $ids, $newtid)
 {
     if (in_array($idtype, array('tid', 'pid')) && $ids) {
         DB::query("UPDATE %t SET tid=%d,tableid=%d WHERE %i IN (%n)", array($this->_table, $newtid, getattachtableid($newtid), $idtype, (array) $ids), false, true);
     }
 }
Example #21
0
function forum_downremotefile($arr, $old_arr)
{
    global $_G;
    $evo_img_no = $_G['cache']['evn_milu_pick']['evo_img_no'];
    $config = get_pick_set();
    $get_file_ext_arr = $config['get_file_ext'] ? explode('|', $config['get_file_ext']) : array();
    $arr['is_download_file'] = $arr['is_download_file'] ? $arr['is_download_file'] : $arr['p_arr']['is_download_file'];
    $arr['message'] = dstripslashes($arr['content']);
    //print_r($arr);
    //$arr['message'] = str_replace(array("\r", "\n"), array($_GET['wysiwyg'] ? '<br />' : '', "\\n"), $arr['message']);
    preg_match_all("/\\[img\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]|\\[img=\\d{1,4}[x|\\,]\\d{1,4}\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/is", $arr['message'], $image1, PREG_SET_ORDER);
    //preg_match_all("/\<img.+src=('|\"|)?(.*)(\\1)([\s].*)?\>/ismUe", $arr['message'], $image2, PREG_SET_ORDER);
    preg_match_all("/\\<img.+src=('|\"|)?(.*)(\\1)(.*)?\\>/isU", $arr['message'], $image2, PREG_SET_ORDER);
    $temp = $aids = $existentimg = $attach_arr = array();
    if (is_array($image1) && !empty($image1)) {
        foreach ($image1 as $value) {
            $v = trim(!empty($value[1]) ? $value[1] : $value[2]);
            $no_remote = 0;
            if (!filter_something($v, $evo_img_no)) {
                //存在
                $no_remote = 1;
            }
            if ($no_remote == 0) {
                $temp[] = array('0' => $value[0], '1' => $v);
            }
        }
    }
    if (is_array($image2) && !empty($image2)) {
        foreach ($image2 as $v) {
            $no_remote = 0;
            $v[2] = trim(strip_tags($v[2]));
            if (!filter_something($v[2], $evo_img_no)) {
                //存在
                $no_remote = 1;
            }
            if ($no_remote == 0) {
                $temp[] = array('0' => $v[0], '1' => $v[2]);
            }
        }
    }
    if ($arr['is_download_file'] == 1) {
        $attach_arr = get_attach_data($arr['page_url'], $arr['message']);
    }
    $attach_arr = $attach_arr ? $attach_arr : array();
    $temp = $temp ? $temp : array();
    $temp = array_merge($temp, $attach_arr);
    //if(VIP) $arr['message'] = post($arr['message'], array('cookie' => $arr['cookie'], 'page_url' => $arr['page_url'], 'cid' => $arr['cid']));
    $del_a = 0;
    if ($arr['content_filter_html'][0] == 0 && $arr['content_filter_html']) {
        $del_a = 1;
    }
    //print_r($arr['message']);exit();
    require_once libfile('class/image');
    if (is_array($temp) && !empty($temp)) {
        if (file_exists(libfile('class/upload'))) {
            require_once libfile('class/upload');
        } else {
            require_once libfile('discuz/upload', 'class');
        }
        $upload = new discuz_upload();
        $attachaids = array();
        $threadimage_flag = 0;
        $content_md5_arr = array();
        foreach ($temp as $key => $value) {
            $snoopy_args['cookie'] = $arr['cookie'];
            $snoop_obj = get_snoopy_obj($snoopy_args);
            $imageurl = $value[1];
            $hash = md5($imageurl);
            if (strlen($imageurl)) {
                $imagereplace['oldimageurl'][] = $value[0];
                if (!isset($existentimg[$hash])) {
                    $existentimg[$hash] = $imageurl;
                    $attach['ext'] = $upload->fileext($imageurl);
                    if ($upload->is_image_ext($attach['ext']) == 1 && $arr['is_download_img'] != 1) {
                        $imagereplace['newimageurl'][] = $value[0];
                        continue;
                    }
                    if (!$upload->is_image_ext($attach['ext'])) {
                        $ext = 'no_get';
                    }
                    if (preg_match('/^(http:\\/\\/|\\.)/i', $imageurl)) {
                        if ($imageurl && snoop_obj) {
                            $content_re = get_img_content($imageurl, $snoop_obj, $ext);
                        }
                        if (is_array($content_re)) {
                            $content = $content_re['content'];
                            $file_name = $attach['name'] = $content_re['file_name'] ? $content_re['file_name'] : ($value[2] ? _striptext($value[2]) : time() . '.' . $content_re['file_ext']);
                            $attach['ext'] = $content_re['file_ext'] ? $content_re['file_ext'] : trim($upload->fileext($file_name));
                            $file_name = $attach['name'] = $file_name;
                        } else {
                            $content = $content_re;
                        }
                        if (in_array(md5($content), $content_md5_arr)) {
                            $imagereplace['newimageurl'][] = '';
                            continue;
                        }
                        $content_md5_arr[] = md5($content);
                    } elseif (preg_match('/^(' . preg_quote(getglobal('setting/attachurl'), '/') . ')/i', $imageurl)) {
                        $imagereplace['newimageurl'][] = $value[0];
                    }
                    if (empty($content)) {
                        if ($value[4] == 1) {
                            if ($del_a == 1) {
                                $imagereplace['newimageurl'][] = $value[2];
                            } else {
                                unset($imagereplace['oldimageurl'][$key]);
                            }
                        } else {
                            $imagereplace['newimageurl'][] = '';
                        }
                        continue;
                    }
                    if (!$attach['name']) {
                        $patharr = explode('/', $imageurl);
                        $attach['name'] = trim($patharr[count($patharr) - 1]);
                    }
                    $patharr = explode('/', $imageurl);
                    if (!$attach['name']) {
                        $attach['name'] = trim($patharr[count($patharr) - 1]);
                    }
                    $attach['thumb'] = '';
                    $attach['ext'] = trim($attach['ext']);
                    //不加这个有些还真不行
                    $attach['isimage'] = $upload->is_image_ext($attach['ext']);
                    if ($attach['isimage'] == 1 && $arr['is_download_img'] != 1) {
                        $imagereplace['newimageurl'][] = $value[0];
                        continue;
                    }
                    $attach['extension'] = $upload->get_target_extension($attach['ext']);
                    $attach['attachdir'] = $upload->get_target_dir('forum');
                    $attach['attachment'] = $attach['attachdir'] . $upload->get_target_filename('forum') . '.' . $attach['extension'];
                    $attach['target'] = getglobal('setting/attachdir') . './forum/' . $attach['attachment'];
                    if (!in_array($attach['ext'], $get_file_ext_arr) && $get_file_ext_arr && $attach['isimage'] == 0) {
                        if ($value[4] == 1) {
                            if ($del_a == 1) {
                                $imagereplace['newimageurl'][] = $value[2];
                            } else {
                                unset($imagereplace['oldimageurl'][$key]);
                            }
                        } else {
                            $imagereplace['newimageurl'][] = '';
                        }
                        continue;
                    }
                    if (!@($fp = fopen($attach['target'], 'wb'))) {
                        continue;
                    } else {
                        flock($fp, 2);
                        fwrite($fp, $content);
                        fclose($fp);
                    }
                    if (!$upload->get_image_info($attach['target']) && $attach['isimage'] == 1) {
                        @unlink($attach['target']);
                        continue;
                    }
                    $attach['size'] = filesize($attach['target']);
                    $upload->attach = $attach;
                    $thumb = $width = 0;
                    if ($upload->attach['isimage']) {
                        if ($_G['setting']['thumbstatus']) {
                            $image = new image();
                            $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], $_G['setting']['thumbsource']) ? 1 : 0;
                            $width = $image->imginfo['width'];
                        }
                        if ($_G['setting']['thumbsource'] || !$_G['setting']['thumbstatus']) {
                            list($width) = @getimagesize($upload->attach['target']);
                        }
                        if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark']) && $arr['is_water_img'] == 1) {
                            $image = new image();
                            $image->Watermark($attach['target'], '', 'forum');
                        }
                    }
                    $desc = $value[3];
                    $arr['public_time'] = $arr['public_time'] ? $arr['public_time'] : $arr['dateline'];
                    $arr['public_time'] = $arr['public_time'] ? $arr['public_time'] : $_G['timestamp'];
                    $remote = 0;
                    $setarr = array('uid' => $arr['uid'], 'tid' => $arr['tid'], 'pid' => $arr['pid'], 'filename' => daddslashes($upload->attach['name']), 'attachment' => $upload->attach['attachment'], 'filesize' => $upload->attach['size'], 'thumb' => $thumb, 'remote' => $remote, 'picid' => $picid, 'isimage' => $attach['isimage'], 'description' => $desc, 'readperm' => 0, 'price' => 0, 'width' => $width, 'dateline' => $arr['public_time']);
                    $setimg_arr = array('tid' => $arr['tid'], 'attachment' => $upload->attach['attachment'], 'remote' => $remote);
                    $set_att = array('downloads' => rand(1, 15), 'tableid' => getattachtableid($arr['tid']), 'uid' => $arr['uid'], 'pid' => $arr['pid'], 'tid' => $arr['tid']);
                    if ($threadimage_flag == 0 && !$arr['is_post'] && $attach['isimage'] == 1) {
                        DB::insert('forum_threadimage', $setimg_arr, true);
                        $threadimage_flag = 1;
                    }
                    $setarr['aid'] = $newaids[] = DB::insert('forum_attachment', $set_att, true);
                    $at[] = $setarr['aid'];
                    $attachnew_arr[$setarr['aid']] = array('description' => $setarr['description']);
                    DB::insert(getattachtablebytid($arr['tid']), $setarr, true);
                    $attachaids[$hash] = $imagereplace['newimageurl'][] = '[attach]' . $setarr['aid'] . '[/attach]';
                } else {
                    $imagereplace['newimageurl'][] = $attachaids[$hash];
                }
            }
        }
        if ($_G['setting']['ftp']['on'] == 1) {
            require_once libfile('function/post');
            ftpupload($newaids, $arr['uid']);
        }
        if (count($at) > 0) {
            $arr['attachment'] = 2;
        }
        $arr['message'] = str_replace($imagereplace['oldimageurl'], $imagereplace['newimageurl'], $arr['message']);
        if ($del_a == 1) {
            $arr['message'] = clear_html_script($arr['message'], array(0));
        }
        forum_article_content($arr);
    }
}