Example #1
0
function build_cache_heats()
{
    global $_G;
    $data = array();
    if ($_G['setting']['indexhot']['status']) {
        require_once libfile('function/post');
        $_G['setting']['indexhot'] = array('status' => 1, 'limit' => intval($_G['setting']['indexhot']['limit'] ? $_G['setting']['indexhot']['limit'] : 10), 'days' => intval($_G['setting']['indexhot']['days'] ? $_G['setting']['indexhot']['days'] : 7), 'expiration' => intval($_G['setting']['indexhot']['expiration'] ? $_G['setting']['indexhot']['expiration'] : 900), 'messagecut' => intval($_G['setting']['indexhot']['messagecut'] ? $_G['setting']['indexhot']['messagecut'] : 200));
        $heatdateline = TIMESTAMP - 86400 * $_G['setting']['indexhot']['days'];
        $query = DB::query("SELECT t.tid,t.posttableid,t.views,t.dateline,t.replies,t.author,t.authorid,t.subject,t.price\r\n\t\t\tFROM " . DB::table('forum_thread') . " t\r\n\t\t\tWHERE t.dateline>'{$heatdateline}' AND t.heats>'0' AND t.displayorder>='0' ORDER BY t.heats DESC LIMIT " . $_G['setting']['indexhot']['limit'] * 2);
        $messageitems = 2;
        $limit = $_G['setting']['indexhot']['limit'];
        while ($heat = DB::fetch($query)) {
            $posttable = $heat['posttableid'] ? "forum_post_{$heat['posttableid']}" : 'forum_post';
            $post = DB::fetch_first("SELECT p.pid, p.message FROM " . DB::table($posttable) . " p WHERE p.tid='{$heat['tid']}' AND p.first='1'");
            $heat = array_merge($heat, (array) $post);
            if ($limit == 0) {
                break;
            }
            if ($messageitems > 0) {
                $heat['message'] = !$heat['price'] ? messagecutstr($heat['message'], $_G['setting']['indexhot']['messagecut']) : '';
                $data['message'][$heat['tid']] = $heat;
            } else {
                unset($heat['message']);
                $data['subject'][$heat['tid']] = $heat;
            }
            $messageitems--;
            $limit--;
        }
        $data['expiration'] = TIMESTAMP + $_G['setting']['indexhot']['expiration'];
    }
    save_syscache('heats', $data);
}
Example #2
0
function updatersscache($num)
{
    global $_G;
    $processname = 'portal_rss_cache';
    if (discuz_process::islocked($processname, 600)) {
        return false;
    }
    C::t('portal_rsscache')->truncate();
    require_once libfile('function/post');
    foreach ($_G['cache']['portalcategory'] as $catid => $catarray) {
        $query = C::t('portal_article_title')->fetch_all_for_cat($catid, 0, 1, 0, $num);
        $catarray['catname'] = addslashes($catarray['catname']);
        foreach ($query as $article) {
            $article['author'] = $article['author'] != '' ? addslashes($article['author']) : ($article['username'] ? addslashes($article['username']) : 'Anonymous');
            $article['title'] = addslashes($article['title']);
            $articleattach = C::t('portal_attachment')->fetch_by_aid_image($article['aid']);
            $attachdata = '';
            if (!empty($articleattach)) {
                $attachdata = "\t" . $articleattach['remote'] . "\t" . $articleattach['attachment'] . "\t" . $articleattach['filesize'];
            }
            $article['description'] = addslashes(messagecutstr($article['summary'], 250 - strlen($attachdata)) . $attachdata);
            C::t('portal_rsscache')->insert(array('lastupdate' => $_G['timestamp'], 'catid' => $catid, 'aid' => $article['aid'], 'dateline' => $article['dateline'], 'catname' => $catarray['catname'], 'author' => $article['author'], 'subject' => $article['title'], 'description' => $article['description']));
        }
    }
    discuz_process::unlock($processname);
    return true;
}
Example #3
0
function build_cache_heats()
{
    global $_G;
    $addsql = '';
    $data = array();
    if (discuz_process::islocked('update_heats_list')) {
        return false;
    }
    if ($_G['setting']['indexhot']['status']) {
        require_once libfile('function/post');
        $_G['setting']['indexhot'] = array('status' => 1, 'limit' => intval($_G['setting']['indexhot']['limit'] ? $_G['setting']['indexhot']['limit'] : 10), 'days' => intval($_G['setting']['indexhot']['days'] ? $_G['setting']['indexhot']['days'] : 7), 'expiration' => intval($_G['setting']['indexhot']['expiration'] ? $_G['setting']['indexhot']['expiration'] : 900), 'messagecut' => intval($_G['setting']['indexhot']['messagecut'] ? $_G['setting']['indexhot']['messagecut'] : 200));
        $messageitems = 2;
        $limit = $_G['setting']['indexhot']['limit'];
        foreach (C::t('forum_thread')->fetch_all_heats() as $heat) {
            $post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($heat['tid']);
            $heat = array_merge($heat, (array) $post);
            if ($limit == 0) {
                break;
            }
            if ($messageitems > 0) {
                $heat['message'] = !$heat['price'] ? messagecutstr($heat['message'], $_G['setting']['indexhot']['messagecut']) : '';
                $data['message'][$heat['tid']] = $heat;
            } else {
                unset($heat['message']);
                $data['subject'][$heat['tid']] = $heat;
            }
            $messageitems--;
            $limit--;
        }
        $data['expiration'] = TIMESTAMP + $_G['setting']['indexhot']['expiration'];
    }
    savecache('heats', $data);
    discuz_process::unlock('update_heats_list');
}
Example #4
0
function updatersscache($num)
{
    global $_G;
    $processname = 'portal_rss_cache';
    if (discuz_process::islocked($processname, 600)) {
        return false;
    }
    DB::query("DELETE FROM " . DB::table('portal_rsscache') . "");
    require_once libfile('function/post');
    foreach ($_G['cache']['portalcategory'] as $catid => $catarray) {
        $query = DB::query("SELECT aid, username, author, dateline, title, summary\r\n\t\t\tFROM " . DB::table('portal_article_title') . "\r\n\t\t\tWHERE catid='{$catid}' AND status=0\r\n\t\t\tORDER BY aid DESC LIMIT {$num}");
        $catarray['catname'] = addslashes($catarray['catname']);
        while ($article = DB::fetch($query)) {
            $article['author'] = $article['author'] != '' ? addslashes($article['author']) : ($article['username'] ? addslashes($article['username']) : 'Anonymous');
            $article['title'] = addslashes($article['title']);
            $articleattach = DB::fetch_first("SELECT * FROM " . DB::table('portal_attachment') . " WHERE aid='" . $article['aid'] . "' AND isimage=1");
            $attachdata = '';
            if (!empty($articleattach)) {
                $attachdata = "\t" . $articleattach['remote'] . "\t" . $articleattach['attachment'] . "\t" . $articleattach['filesize'];
            }
            $article['description'] = addslashes(messagecutstr($article['summary'], 250 - strlen($attachdata)) . $attachdata);
            DB::query("REPLACE INTO " . DB::table('portal_rsscache') . " (lastupdate, catid, aid, dateline, catname, author, subject, description)\r\n\t\t\t\tVALUES ('{$_G['timestamp']}', '{$catid}', '{$article['aid']}', '{$article['dateline']}', '{$catarray['catname']}', '{$article['author']}', '{$article['title']}', '{$article['description']}')");
        }
    }
    discuz_process::unlock($processname);
    return true;
}
 public function before_feed()
 {
     $message = !$this->param['price'] && !$this->param['readperm'] ? $this->param['message'] : '';
     $this->feed['icon'] = 'debate';
     $this->feed['title_template'] = 'feed_thread_debate_title';
     $this->feed['body_template'] = 'feed_thread_debate_message';
     $this->feed['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$this->tid}\">{$this->param['subject']}</a>", 'message' => messagecutstr($message, 150), 'affirmpoint' => messagecutstr($this->affirmpoint, 150), 'negapoint' => messagecutstr($this->negapoint, 150));
 }
 public function before_newreply($parameters)
 {
     global $nauthorid;
     list(, $this->param['modnewreplies']) = threadmodstatus($this->param['subject'] . "\t" . $this->param['message'] . $this->param['extramessage']);
     if ($this->thread['displayorder'] == -4) {
         $this->param['modnewreplies'] = 0;
     }
     $pinvisible = $parameters['modnewreplies'] ? -2 : ($this->thread['displayorder'] == -4 ? -3 : 0);
     $this->postcomment = in_array(2, $this->setting['allowpostcomment']) && $this->group['allowcommentreply'] && !$pinvisible && !empty($_GET['reppid']) && ($nauthorid != $this->member['uid'] || $this->setting['commentpostself']) ? messagecutstr($parameters['message'], 200, ' ') : '';
 }
Example #7
0
 function misc_mobile_message($message)
 {
     global $_G, $thread;
     if (!in_array($message, array('recommend_succed', 'recommend_daycount_succed'))) {
         return;
     }
     $thaquote = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']);
     $quote = $thaquote['message'];
     $quote = messagecutstr($quote, 100);
     $quote = implode("\n", array_slice(explode("\n", $quote), 0, 3));
 }
 public function before_feed()
 {
     $message = !$this->param['price'] && !$this->param['readperm'] ? $this->param['message'] : '';
     $this->feed['icon'] = 'activity';
     $this->feed['title_template'] = 'feed_thread_activity_title';
     $this->feed['body_template'] = 'feed_thread_activity_message';
     $this->feed['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$this->tid}\">{$this->param['subject']}</a>", 'starttimefrom' => $_GET['starttimefrom'][$this->activitytime], 'activityplace' => $this->activity['place'], 'message' => messagecutstr($message, 150));
     if ($_GET['activityaid']) {
         $this->feed['images'] = array(getforumimg($_GET['activityaid']));
         $this->feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid={$this->tid}&pid={$this->pid}");
     }
 }
 public function before_feed()
 {
     $pvs = explode("\t", messagecutstr($this->polloptionpreview, 150));
     $s = '';
     $i = 1;
     foreach ($pvs as $pv) {
         $s .= $i . '. ' . $pv . '<br />';
     }
     $s .= '&nbsp;&nbsp;&nbsp;...';
     $this->feed['icon'] = 'poll';
     $this->feed['title_template'] = 'feed_thread_poll_title';
     $this->feed['body_template'] = 'feed_thread_poll_message';
     $this->feed['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$this->tid}\">" . $this->param['subject'] . "</a>", 'message' => $s);
 }
Example #10
0
 foreach ($posts as $pid => $post) {
     $delrow = false;
     if ($post['anonymous'] && $post['authorid'] != $_G['uid']) {
         $delrow = true;
     } elseif ($viewuserthread && $post['authorid'] != $_G['uid']) {
         if ($_G['adminid'] != 1 && !empty($viewfids) && !in_array($post['fid'], $viewfids)) {
             $delrow = true;
         }
     }
     if ($delrow) {
         unset($posts[$pid]);
         $hiddennum++;
         continue;
     } else {
         $tids[$post['tid']][] = $pid;
         $post['message'] = !getstatus($post['status'], 2) || $post['authorid'] == $_G['uid'] ? messagecutstr($post['message'], 100) : '';
         $posts[$pid] = $post;
     }
 }
 if (!empty($tids)) {
     $threads = C::t('forum_thread')->fetch_all_by_tid_displayorder(array_keys($tids), $displayorder, $dglue, array(), $closed);
     foreach ($threads as $tid => $thread) {
         $delrow = false;
         if ($_G['adminid'] != 1 && $thread['displayorder'] < 0) {
             $delrow = true;
         } elseif ($_G['adminid'] != 1 && $_G['uid'] != $thread['authorid'] && getstatus($thread['status'], 2)) {
             $delrow = true;
         } elseif (!isset($_G['cache']['forums'][$thread['fid']])) {
             if (!$_G['setting']['groupstatus']) {
                 $delrow = true;
             } else {
Example #11
0
</a></div>
                                <div class="yjgl_li_tit_other">
								<span class="yjglico">
									<span class="view"><?php 
    echo $item['views'];
    ?>
</span><span class="view_fx"><?php 
    echo $item['replies'];
    ?>
</span>
								</span>
                                </div>
                            </div>
                            <div class="clear"></div>
                            <div class="yjgl_li_des"><?php 
    echo messagecutstr($item['message'], 130);
    ?>
</div>
                        </div>
                    </li>
                <?php 
}
?>
            </ul>
        </div>
        <div class="clear"></div>
    </div>
</div>
<?php 
$this->load->view('foot_v1');
?>
Example #12
0
function getranklist_blog($num = 20, $view = 'hot', $orderby = 'all')
{
    $dateline = $timestamp = '';
    if ($orderby == 'today') {
        $timestamp = TIMESTAMP - 86400;
        $dateline = "AND b.dateline>='{$timestamp}'";
    } elseif ($orderby == 'thisweek') {
        $timestamp = TIMESTAMP - 604800;
        $dateline = "AND b.dateline>='{$timestamp}'";
    } elseif ($orderby == 'thismonth') {
        $timestamp = TIMESTAMP - 2592000;
        $dateline = "AND b.dateline>='{$timestamp}'";
    }
    $data = array();
    $query = DB::query("SELECT b.blogid, b.uid, b.username, b.subject, b.dateline, b.viewnum, b.replynum, b.hot, b.sharetimes, b.favtimes,\n\t\tb.click1, b.click2, b.click3, b.click4, b.click5, b.click6, b.click7, b.click8, bf.message\n\t\tFROM " . DB::table('home_blog') . " b\n\t\tLEFT JOIN " . DB::table('home_blogfield') . " bf ON bf.blogid=b.blogid\n\t\tWHERE b.friend='0' AND status = '0' {$dateline}\n\t\tORDER BY b.{$view} DESC\n\t\tLIMIT 0, {$num}");
    require_once libfile('function/forum');
    require_once libfile('function/post');
    $rank = 0;
    while ($blog = DB::fetch($query)) {
        ++$rank;
        $blog['rank'] = $rank;
        $blog['dateline'] = dgmdate($blog['dateline']);
        $blog['avatar'] = avatar($blog['uid'], 'small');
        $blog['message'] = preg_replace('/<([^>]*?)>/', '', $blog['message']);
        $blog['message'] = messagecutstr($blog['message'], 140);
        $data[] = $blog;
    }
    return $data;
}
Example #13
0
     if (!($thapost && ($thapost['invisible'] == 0 || $thapost['authorid'] == $_G['uid'] && $thapost['invisible'] == -2))) {
         $thapost = array();
     }
     if ($thapost['tid'] != $_G['tid']) {
         showmessage('targetpost_donotbelongto_thisthread', NULL);
     }
     $thapost['useip'] = substr($thapost['useip'], 0, strrpos($thapost['useip'], '.')) . '.x';
     if ($thapost['author'] && $thapost['anonymous']) {
         $thapost['author'] = '[color=Olive]' . lang('forum/misc', 'anonymoususer') . '[/color]';
     } elseif (!$thapost['author']) {
         $thapost['author'] = '[color=Olive]' . lang('forum/misc', 'guestuser') . '[/color] ' . $thapost['useip'];
     } else {
         $thapost['author'] = '[color=Olive]' . $thapost['author'] . '[/color]';
     }
     $quotemessage = discuzcode($message, 0, 0);
     $noticeauthormsg = dhtmlspecialchars(messagecutstr($thapost['message'], 100));
     $noticeauthor = dhtmlspecialchars(authcode('r|' . $thapost['authorid'], 'ENCODE'));
     $noticetrimstr = dhtmlspecialchars($message);
     $message = '';
     $reppid = $_GET['reppost'];
 }
 if (isset($_GET['addtrade']) && $thread['special'] == 2 && $_G['group']['allowposttrade'] && $thread['authorid'] == $_G['uid']) {
     $expiration_7days = date('Y-m-d', TIMESTAMP + 86400 * 7);
     $expiration_14days = date('Y-m-d', TIMESTAMP + 86400 * 14);
     $trade['expiration'] = $expiration_month = date('Y-m-d', mktime(0, 0, 0, date('m') + 1, date('d'), date('Y')));
     $expiration_3months = date('Y-m-d', mktime(0, 0, 0, date('m') + 3, date('d'), date('Y')));
     $expiration_halfyear = date('Y-m-d', mktime(0, 0, 0, date('m') + 6, date('d'), date('Y')));
     $expiration_year = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y') + 1));
 }
 if ($thread['replies'] <= $_G['ppp']) {
     $postlist = array();
Example #14
0
     if (getstatus($post['status'], 3) == 0) {
         updatepostcredits('+', $post['authorid'], 'reply', $post['fid']);
         $attachcount = C::t('forum_attachment_n')->count_by_id('tid:' . $post['tid'], 'pid', $post['pid']);
         updatecreditbyaction('postattach', $post['authorid'], array(), '', $attachcount, 1, $post['fid']);
     }
     $threads[$post['tid']]['posts']++;
     if ($post['dateline'] > $post['lastpost'] && $post['dateline'] > $lastpost[$post['tid']]) {
         $threads[$post['tid']]['lastpost'] = $post['dateline'];
         $threads[$post['tid']]['lastposter'] = $post['anonymous'] && $post['dateline'] != $post['lastpost'] ? '' : addslashes($post[author]);
     }
     if ($threads[$post['tid']]['attachadd'] || $post['attachment']) {
         $threads[$post['tid']]['attachment'] = 1;
     }
     $pm = 'pm_' . $post['pid'];
     if ($post['authorid'] && $post['authorid'] != $_G['uid']) {
         $pmlist[] = array('act' => 'modreplies_validate', 'notevar' => array('reason' => dhtmlspecialchars($_GET['reason']), 'pid' => $post['pid'], 'tid' => $post['tid'], 'post' => messagecutstr($post['message'], 30), 'from_id' => 0, 'from_idtype' => 'modreplies'), 'authorid' => $post['authorid']);
     }
 }
 unset($postlist, $tids, $threadlist);
 foreach ($threads as $tid => $thread) {
     $updatedata = array('replies' => $thread['posts']);
     if (isset($thread['lastpost'])) {
         $updatedata['lastpost'] = array($thread['lastpost']);
         $updatedata['lastposter'] = array($thread['lastposter']);
     }
     if (isset($thread['attachment'])) {
         $updatedata['attachment'] = $thread['attachment'];
     }
     C::t('forum_thread')->increase($tid, $updatedata);
 }
 if ($_G['fid']) {
Example #15
0
         $focus['title'] = trim($focus_title);
         $focus['title'] = empty($focus['title']) ? lang('misc_focus') : $focus['title'];
         $db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('focus', '" . addslashes(serialize($focus)) . "')");
         updatecache('focus');
         cpmsg('focus_conf_succeed', $BASESCRIPT . '?action=misc&operation=focus&do=config', 'succeed');
     }
 } elseif ($do == 'fetchthread' && $id) {
     $thread = $db->fetch_first("SELECT pid, subject, message, attachment FROM {$tablepre}posts WHERE tid='{$id}' AND first='1'");
     ajaxshowheader();
     if (!$thread) {
         echo '<script type="text/JavaScript">alert(\'' . lang('misc_focus_nothread') . '\');</script>';
         ajaxshowfooter();
         exit;
     }
     showsetting('misc_focus_topic_subject', 'focus_subject', $thread['subject'], 'text');
     showsetting('misc_focus_topic_msg', 'focus_summary', messagecutstr($thread['message'], 150), 'textarea');
     if ($thread['attachment']) {
         $attachlist = $attachkeys = array();
         $attachlist[] = array('', lang('select'));
         $attachlist[] = array(0, lang('misc_focus_noimage'));
         $query = $db->query("SELECT aid, filename FROM {$tablepre}attachments WHERE pid='{$thread['pid']}' AND isimage IN ('1', '-1')");
         while ($attach = $db->fetch_array($query)) {
             $attachlist[] = array($attach['aid'], $attach['filename']);
             $attachkeys[$attach['aid']] = rawurlencode(authcode("{$attach['aid']}\t58\t58", 'ENCODE', $_DCACHE['settings']['authkey']));
         }
         if ($attachkeys) {
             showsetting('misc_focus_image', array('focus_aid', $attachlist), '', 'select');
             showsetting('', 'focus_img', '', '<div id="focus_img_preview"></div><input type="hidden" name="focus_filename" value="" />');
         }
     }
     echo '<script type="text/JavaScript">var attachkeys = [];';
Example #16
0
             $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' => $_G['gp_starttimefrom'][$activitytime], 'activityplace' => $activity['place'], 'message' => messagecutstr($message, 150));
             if ($_G['gp_activityaid']) {
                 $feed['images'] = array(getforumimg($_G['gp_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 ($displayorder != -4) {
     if ($digest) {
         updatepostcredits('+', $_G['uid'], 'digest', $_G['fid']);
     }
     updatepostcredits('+', $_G['uid'], 'post', $_G['fid']);
     if ($isgroup) {
Example #17
0
        if (!IS_ROBOT) {
            $activityuser = array_keys($groupcache['activityuser']['data']);
            if ($activityuser) {
                $query = C::t('home_feed')->fetch_all_by_uid_dateline($activityuser);
                foreach ($query as $feed) {
                    if ($feed['friend'] == 0) {
                        $groupfeedlist[] = mkfeed($feed);
                    }
                }
            }
        }
        if ($_G['forum']['livetid']) {
            include_once libfile('function/post');
            $livethread = C::t('forum_thread')->fetch($_G['forum']['livetid']);
            $livepost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_G['forum']['livetid']);
            $livemessage = messagecutstr($livepost['message'], 200);
            $liveallowpostreply = $groupuser['uid'] && $groupuser['level'] ? true : false;
            list($seccodecheck, $secqaacheck) = seccheck('post', 'newthread');
        }
    } else {
        $newuserlist = $activityuserlist = array();
        $newuserlist = array_slice($groupcache['newuserlist']['data'], 0, 4);
        foreach ($newuserlist as $user) {
            $newuserlist[$user['uid']] = $user;
            $newuserlist[$user['uid']]['online'] = !empty($onlinemember['list']) && is_array($onlinemember['list']) && !empty($onlinemember['list'][$user['uid']]) ? 1 : 0;
        }
    }
    write_groupviewed($_G['fid']);
    include template('diy:group/group:' . $_G['fid']);
} elseif ($action == 'memberlist') {
    $oparray = array('card', 'address', 'alluser');
Example #18
0
    exit;
} elseif ($_GET['action'] == 'livelastpost') {
    $fid = dintval($_GET['fid']);
    $forum = C::t('forum_forumfield')->fetch($fid);
    $livetid = $forum['livetid'];
    $postlist = array();
    if ($livetid) {
        $thread = C::t('forum_thread')->fetch($livetid);
        $postlist['count'] = $thread['replies'];
        $postarr = C::t('forum_post')->fetch_all_by_tid('tid:' . $livetid, $livetid, true, 'DESC', 20);
        ksort($postarr);
        foreach ($postarr as $post) {
            if ($post['first'] == 1 || getstatus($post['status'], 1)) {
                continue;
            }
            $contentarr = array('authorid' => !$post['anonymous'] ? $post['authorid'] : '', 'author' => !$post['anonymous'] ? $post['author'] : lang('forum/misc', 'anonymous'), 'message' => str_replace("\r\n", '<br>', messagecutstr($post['message'])), 'dateline' => dgmdate($post['dateline'], 'u'), 'avatar' => !$post['anonymous'] ? avatar($post['authorid'], 'small') : '');
            $postlist['list'][$post['pid']] = $contentarr;
        }
    }
    showmessage('', '', $postlist);
    exit;
} else {
    if (empty($_G['forum']['allowview'])) {
        if (!$_G['forum']['viewperm'] && !$_G['group']['readaccess']) {
            showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
        } elseif ($_G['forum']['viewperm'] && !forumperm($_G['forum']['viewperm'])) {
            showmessage('forum_nopermission', NULL, array($_G['group']['grouptitle']), array('login' => 1));
        }
    }
    $thread = C::t('forum_thread')->fetch($_G['tid']);
    if (!($thread['displayorder'] >= 0 || $thread['displayorder'] == -4 && $thread['authorid'] == $_G['uid'])) {
Example #19
0
        }
        $invitename = lang('forum/misc', 'at_invite');
    } else {
        $invitename = lang('forum/misc', 'join_activity');
    }
    if (!submitcheck('invitesubmit')) {
        $inviteduids = !empty($inviteduids) ? implode(',', $inviteduids) : '';
    } else {
        $uids = $_GET['uids'];
        if ($uids) {
            if (count($uids) > $maxselect) {
                showmessage('group_choose_friends_max');
            }
            $post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($id);
            require_once libfile('function/post');
            $post['message'] = messagecutstr($post['message'], 150);
            foreach (C::t('common_member')->fetch_all($uids, false, 0) as $uid => $user) {
                if ($at) {
                    notification_add($uid, 'at', 'at_message', array('from_id' => $id, 'from_idtype' => 'at', 'buyerid' => $_G['uid'], 'buyer' => $_G['username'], 'tid' => $id, 'subject' => $thread['subject'], 'pid' => $post['pid'], 'message' => $post['message']));
                } else {
                    notification_add($uid, 'thread', 'thread_invite', array('subject' => $thread['subject'], 'invitename' => $invitename, 'tid' => $id, 'from_id' => $id, 'from_idtype' => 'invite_thread'));
                }
            }
            showmessage($at ? 'at_succeed' : 'group_invite_succeed', "forum.php?mod=viewthread&tid={$id}");
        } else {
            showmessage($at ? 'at_choose_member' : 'group_invite_choose_member', "forum.php?mod=viewthread&tid={$id}");
        }
    }
} elseif ($_GET['action'] == 'blog') {
    $id = intval($_GET['id']);
    $blog = C::t('home_blog')->fetch($id);
Example #20
0
function updatersscache($num)
{
    global $_G;
    $processname = 'forum_rss_cache';
    if (discuz_process::islocked($processname, 600)) {
        return false;
    }
    C::t('forum_rsscache')->truncate();
    require_once libfile('function/post');
    foreach ($_G['cache']['forums'] as $fid => $forum) {
        if ($forum['type'] != 'group') {
            $forum['name'] = addslashes($forum['name']);
            foreach (C::t('forum_thread')->fetch_all_by_fid_displayorder($fid, 0, null, null, 0, $num, 'tid') as $thread) {
                $thread['author'] = $thread['author'] != '' ? addslashes($thread['author']) : 'Anonymous';
                $thread['subject'] = addslashes($thread['subject']);
                $post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']);
                $attachdata = '';
                if ($post['attachment'] == 2) {
                    $attach = C::t('forum_attachment_n')->fetch_max_image('tid:' . $thread['tid'], 'pid', $post['pid']);
                    $attachdata = "\t" . $attach['remote'] . "\t" . $attach['attachment'] . "\t" . $attach['filesize'];
                }
                $thread['message'] = $post['message'];
                $thread['status'] = $post['status'];
                $thread['description'] = $thread['readperm'] > 0 || $thread['price'] > 0 || $thread['status'] & 1 ? '' : addslashes(messagecutstr($thread['message'], 250 - strlen($attachdata)) . $attachdata);
                C::t('forum_rsscache')->insert(array('lastupdate' => $_G['timestamp'], 'fid' => $fid, 'tid' => $thread['tid'], 'dateline' => $thread['dateline'], 'forum' => $forum['name'], 'author' => $thread['author'], 'subject' => $thread['subject'], 'description' => $thread['description']), false, true);
            }
        }
    }
    discuz_process::unlock($processname);
    return true;
}
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: resourcepush.inc.php 34814 2014-08-07 01:46:48Z nemohou $
 */
if (!defined('IN_DISCUZ')) {
    exit('Access Denied');
}
if ($_G['adminid'] != 1) {
    showmessage('undefined_action');
}
require_once libfile('function/forum');
require_once libfile('function/post');
$thread = get_thread_by_tid($_GET['tid']);
if (!$thread) {
    showmessage('undefined_action');
}
$post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_GET['tid']);
if ($thread['cover']) {
    $picurl = getthreadcover($thread['tid'], $thread['cover']);
} else {
    $attach = C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $_GET['tid'], 'pid', array($post['pid']), '', true);
    $picurl = '';
    if ($attach) {
        $attach = array_shift($attach);
        $picurl = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/' . $attach['attachment'];
    }
}
$data = array('name' => lang('plugin/wechat', 'resource_thread_push') . ': ' . $thread['subject'], 'data' => array('title' => $thread['subject'], 'pic' => $picurl ? (preg_match('/^http:/', $picurl) ? '' : $_G['siteurl']) . $picurl : '', 'desc' => messagecutstr($post['message'], 0, 120), 'content' => nl2br(messagecutstr($post['message'])), 'url' => $_G['siteurl'] . 'forum.php?mod=viewthread&tid=' . $_GET['tid']));
C::t('#wechat#mobile_wechat_resource')->insert($data);
showmessage('wechat:resource_msg_pushed', '', array(), array('alert' => 'right'));
Example #22
0
$posts = dunserialize($key['svalue']);
if (trim($newmessage) != '' && !getstatus($thread['status'], 2)) {
    if (!$posts) {
        $posts = array();
    }
    if (count($posts) > 2) {
        array_shift($posts);
    }
    $post = array('pid' => $pid, 'author' => empty($_GET['isanonymous']) ? $_G['username'] : $_G['setting']['anonymoustext'], 'authorid' => empty($_GET['isanonymous']) ? $_G['uid'] : 0, 'message' => $newmessage);
    array_push($posts, $post);
}
if (count($posts) < 3 && $thread['replies'] >= count($posts) && !getstatus($thread['status'], 2)) {
    $posts = array();
    foreach (C::t('forum_post')->fetch_all_by_tid($thread['posttableid'], $thread['tid'], true, 'DESC', 0, 10, 0, 0) as $p) {
        $p['message'] = preg_replace('/<\\/*.*?>|&nbsp;|\\r\\n|\\[attachimg\\].*?\\[\\/attachimg\\]|\\[quote\\].*?\\[\\/quote\\]|\\[\\/*.*?\\]/ms', '', $p['message']);
        $p['message'] = trim(messagecutstr($p['message'], 100));
        if ($p['anonymous']) {
            $p['author'] = $_G['setting']['anonymoustext'];
            $p['authorid'] = 0;
        }
        $post = array('pid' => $p['pid'], 'author' => $p['author'], 'authorid' => $p['authorid'], 'message' => $p['message'], 'avatar' => avatar($p['authorid'], 'small', true));
        if ($post['message'] != '') {
            array_push($posts, $post);
        }
        if (count($posts) > 2) {
            break;
        }
    }
    $posts = array_reverse($posts);
}
$data = array('skey' => $_G['tid'], 'svalue' => serialize($posts));
Example #23
0
 $usesig = !empty($usesig) ? 1 : 0;
 $isanonymous = $allowanonymous && !empty($isanonymous) ? 1 : 0;
 $author = empty($isanonymous) ? $discuz_user : '';
 $pinvisible = $modnewreplies ? -2 : 0;
 $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message);
 $db->query("INSERT INTO {$tablepre}posts (fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, anonymous, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment)\r\n\t\t\tVALUES ('{$fid}', '{$tid}', '0', '{$discuz_user}', '{$discuz_uid}', '{$subject}', '{$timestamp}', '{$message}', '{$onlineip}', '{$pinvisible}', '{$isanonymous}', '{$usesig}', '{$htmlon}', '{$bbcodeoff}', '{$smileyoff}', '{$parseurloff}', '0')");
 $pid = $db->insert_id();
 $cacheposition = getstatus($thread['status'], 1);
 if ($pid && $cacheposition) {
     savepostposition($tid, $pid);
 }
 $nauthorid = 0;
 if (!empty($noticeauthor) && !$isanonymous) {
     list($ac, $nauthorid, $nauthor) = explode('|', $noticeauthor);
     if ($nauthorid != $discuz_uid) {
         $postmsg = messagecutstr(str_replace($noticetrimstr, '', $message), 100);
         if ($ac == 'q') {
             sendnotice($nauthorid, 'repquote_noticeauthor', 'threads');
         } elseif ($ac == 'r') {
             sendnotice($nauthorid, 'reppost_noticeauthor', 'threads');
         }
     }
 }
 $uidarray = array();
 $query = $db->query("SELECT uid FROM {$tablepre}favoritethreads WHERE tid='{$tid}'");
 while ($favthread = $db->fetch_array($query)) {
     if ($favthread['uid'] !== $discuz_uid && (!$nauthorid || $nauthorid != $favthread['uid'])) {
         $uidarray[] = $favthread['uid'];
     }
 }
 if ($discuz_uid && !empty($uidarray)) {
Example #24
0
 public function detail($id)
 {
     $this->set_vars('questionid', $id);
     $question = $this->get_one_data('question', '*', array('id' => $id));
     $this->set_vars('question', $question);
     $this->question_model->question_set($id, 'hits', 'hits+1');
     $members = $this->user_model->get_members($question['uid']);
     $member = $members[0];
     $this->set_vars('question_member', $member);
     $spid = $question['group_id'];
     $this->set_vars('spid', $spid);
     $sport = $this->get_one_data('sport', '*', array('spid' => $spid));
     $this->set_vars('sport', $sport);
     $this->set_vars('title', $this->title($question['title'] . $sport['name'] . ' ' . $sport['name_en'] . ' 部落问答'));
     $this->set_vars('keywords', $this->keywords($question['title'] . $sport['name'] . ' ' . $sport['name_en'] . ' 部落问答'));
     $this->set_vars('description', $this->description(messagecutstr($question['body'], 500)));
     $joined = $this->sport->sport_joined($spid, $this->uid);
     //判断是否加入
     $this->set_vars('joined', $joined);
     $joined_count = $this->sport->sport_join_count($spid);
     $this->set_vars('joined_count', "{$joined_count}");
     $where = array('group_id' => $spid);
     $question_count = $this->question_model->get_questions_count($where);
     $this->set_vars('question_count', "{$question_count}");
     $followed = $this->question_model->question_followed($id, $this->uid);
     //判断是否关注
     $this->set_vars('followed', $followed);
     $sports = $this->sport->get_random_sports_list($spid, 5);
     foreach ($sports as &$s) {
         $spid2 = $s['spid'];
         $joined_count2 = $this->sport->sport_join_count($spid2);
         $question_count2 = $this->question_model->get_questions_count(array('group_id' => $spid2));
         $s['joined_count'] = $joined_count2;
         $s['question_count'] = $question_count2;
     }
     $this->set_vars('sports', $sports);
     $pagesize = 6;
     $currentpage = $this->get_uri_segment(4);
     $orderby = 'id desc';
     $where = array('question_id' => $id);
     $total = $this->question_model->get_answer_count($where);
     //数量
     $pagelink = $this->get_pagination('question/detail/' . $id, 4, 2, $total, $pagesize);
     $this->set_vars('pagelink', $pagelink);
     $list = $this->question_model->get_answer_list($currentpage, $pagesize, $where, $orderby);
     //回答 列表
     foreach ($list as &$item) {
         $where = array('object_id' => $item['id'], 'uid' => $this->uid);
         $liked = $this->question_model->get_answer_liked_count($where);
         $item['user_liked'] = $liked;
         /*----------------------------------------------------------------------*/
         $item['answer_reply'] = $this->question_model->get_answer_reply_list(array('answer_id' => $item['id']), $orderby);
         //回答的回复列表
         $reply_reply_array = array();
         foreach ($item['answer_reply'] as $answer_reply) {
             $reply_reply_array["{$answer_reply['id']}"] = $this->question_model->get_answer_reply_reply_list(array('reply_id' => $answer_reply['id']), $orderby);
             //回答的回复的回复列表
         }
         $item['answer_reply_reply'] = $reply_reply_array;
         /*----------------------------------------------------------------------*/
     }
     $this->set_vars('list', $list);
     $question_follow_list = $this->question_model->get_question_follow_list(1, 20, array('object_id' => $id), 'created desc');
     //列表
     $this->set_vars('question_follow_list', $question_follow_list);
     //关注的用户
     #$question_follow_count=$this->question_model->get_question_follow_count(array()); //关注人数
     $this->set_vars('user_id', $this->uid);
     //关注的用户
     $this->load->view('question/detail');
 }
    array_unshift($postarr, $_newpostarr_first);
    unset($_newpostarr_first, $sticklist);
}
foreach ($postarr as $post) {
    if (($onlyauthoradd && empty($post['anonymous']) || !$onlyauthoradd) && !isset($postlist[$post['pid']])) {
        if (isset($hotpostarr[$post['pid']])) {
            $post['existinfirstpage'] = true;
        }
        $postusers[$post['authorid']] = array();
        if ($post['first']) {
            if ($ordertype == 1 && $page != 1) {
                continue;
            }
            $_G['forum_firstpid'] = $post['pid'];
            if (IS_ROBOT || $_G['adminid'] == 1) {
                $summary = str_replace(array("\r", "\n"), '', messagecutstr(strip_tags($post['message']), 160));
            }
            $tagarray_all = $posttag_array = array();
            $tagarray_all = explode("\t", $post['tags']);
            if ($tagarray_all) {
                foreach ($tagarray_all as $var) {
                    if ($var) {
                        $tag = explode(',', $var);
                        $posttag_array[] = $tag;
                        $tagnames[] = $tag[1];
                    }
                }
            }
            $post['tags'] = $posttag_array;
            if ($post['tags']) {
                $post['relateitem'] = getrelateitem($post['tags'], $post['tid'], $_G['setting']['relatenum'], $_G['setting']['relatetime']);
Example #26
0
        }
    }
    $page = max(1, intval($_G['page']));
    $total = 0;
    $query = $multipage = '';
    if ($do == 'list') {
        $result = $modsession->get('srchresult_p' . $_G['fid']);
        $threadoptionselect[$result['threadoption']] = 'selected';
        if ($result['fid'] == $_G['fid']) {
            $total = $result['count'];
            $tpage = ceil($total / $_G['tpp']);
            $page = min($tpage, $page);
            $multipage = multi($total, $_G['tpp'], $page, "{$cpscript}?mod=modcp&amp;action={$_G['gp_action']}&amp;op={$op}&amp;fid={$_G['fid']}&amp;do={$do}");
            if ($total && $result['pids']) {
                $start = ($page - 1) * $_G['tpp'];
                $postarray = getallwithposts(array('select' => 'p.*, t.subject as tsubject', 'from' => DB::table('forum_post') . " p LEFT JOIN " . DB::table('forum_thread') . " t USING(tid)", 'where' => "pid IN ({$result['pids']})", 'order' => 'dateline DESC', 'limit' => "{$start}, {$_G['tpp']}"));
            }
        }
    }
    $postlist = array();
    if ($postarray) {
        require_once libfile('function/post');
        foreach ($postarray as $post) {
            $post['dateline'] = dgmdate($post['dateline']);
            $post['message'] = messagecutstr($post['message'], 200);
            $post['forum'] = $modforums['list'][$post['fid']];
            $post['modthreadkey'] = modauthkey($post['tid']);
            $postlist[] = $post;
        }
    }
}
Example #27
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 #28
0
function updatersscache($num)
{
    global $_G;
    DB::query("DELETE FROM " . DB::table('forum_rsscache') . "");
    require_once libfile('function/post');
    foreach ($_G['cache']['forums'] as $fid => $forum) {
        if ($forum['type'] != 'group') {
            $query = DB::query("SELECT t.tid, t.readperm, t.author, t.dateline, t.subject\n\t\t\t\tFROM " . DB::table('forum_thread') . " t\n\t\t\t\tWHERE t.fid='{$fid}' AND t.displayorder>='0' AND t.price='0'\n\t\t\t\tORDER BY t.dateline DESC LIMIT {$num}");
            $forum['name'] = addslashes($forum['name']);
            while ($thread = DB::fetch($query)) {
                $thread['author'] = $thread['author'] != '' ? addslashes($thread['author']) : 'Anonymous';
                $thread['subject'] = addslashes($thread['subject']);
                $posttable = getposttablebytid($thread['tid']);
                $post = DB::fetch_first("SELECT pid, attachment, message, status FROM " . DB::table($posttable) . " WHERE tid='{$thread['tid']}' AND first='1'");
                $attachdata = '';
                if ($post['attachment'] == 2) {
                    $attach = DB::fetch_first("SELECT remote, attachment, filesize FROM " . DB::table('forum_attachment') . " WHERE pid='{$post['pid']}' AND isimage='1' ORDER BY dateline LIMIT 1");
                    $attachdata = "\t" . $attach['remote'] . "\t" . $attach['attachment'] . "\t" . $attach['filesize'];
                }
                $thread['message'] = $post['message'];
                $thread['status'] = $post['status'];
                $thread['description'] = $thread['readperm'] > 0 || $thread['price'] > 0 || $thread['status'] & 1 ? '' : addslashes(nl2br(messagecutstr($thread['message'], 250 - strlen($attachdata))) . $attachdata);
                DB::query("REPLACE INTO " . DB::table('forum_rsscache') . " (lastupdate, fid, tid, dateline, forum, author, subject, description)\n\t\t\t\t\tVALUES ('{$_G['timestamp']}', '{$fid}', '{$thread['tid']}', '{$thread['dateline']}', '{$forum['name']}', '{$thread['author']}', '{$thread['subject']}', '{$thread['description']}')");
            }
        }
    }
}
 public function feed()
 {
     if ($this->forum('allowfeed') && !$this->param['isanonymous']) {
         if (empty($this->feed)) {
             $this->feed = array('icon' => '', 'title_template' => '', 'title_data' => array(), 'body_template' => '', 'body_data' => array(), 'title_data' => array(), 'images' => array());
             $message = !$this->param['price'] && !$this->param['readperm'] ? $this->param['message'] : '';
             $message = messagesafeclear($message);
             $this->feed['icon'] = 'thread';
             $this->feed['title_template'] = 'feed_thread_title';
             $this->feed['body_template'] = 'feed_thread_message';
             $this->feed['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$this->tid}\">{$this->param['subject']}</a>", 'message' => messagecutstr($message, 150));
             if (getglobal('forum_attachexist')) {
                 //					$firstaid = DB::result_first("SELECT aid FROM ".DB::table(getattachtablebytid($tid))." WHERE pid='$pid' AND dateline>'0' AND isimage='1' ORDER BY dateline LIMIT 1");
                 $imgattach = C::t('forum_attachment_n')->fetch_max_image('tid:' . $this->tid, 'pid', $this->pid);
                 $firstaid = $imgattach['aid'];
                 unset($imgattach);
                 if ($firstaid) {
                     $this->feed['images'] = array(getforumimg($firstaid));
                     $this->feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid={$this->tid}&pid={$this->pid}");
                 }
             }
         }
         $this->feed['title_data']['hash_data'] = 'tid' . $this->tid;
         $this->feed['id'] = $this->tid;
         $this->feed['idtype'] = 'tid';
         if ($this->feed['icon']) {
             postfeed($this->feed);
         }
     }
 }
Example #30
0
             }
         }
     }
     $threadlist = $posttables = array();
     $query = DB::query("SELECT * FROM " . DB::table('forum_thread') . " WHERE tid IN ({$index['ids']}) AND displayorder>='0' ORDER BY {$orderby} {$ascdesc} LIMIT {$start_limit}, {$_G['tpp']}");
     while ($thread = DB::fetch($query)) {
         $thread['subject'] = bat_highlight($thread['subject'], $keyword);
         $thread['realtid'] = $thread['isgroup'] == 1 ? $thread['closed'] : $thread['tid'];
         $threadlist[$thread['tid']] = procthread($thread, 'dt');
         $posttables[$thread['posttableid']][] = $thread['tid'];
     }
     if ($threadlist) {
         foreach ($posttables as $tableid => $tids) {
             $query = DB::query("SELECT tid, message FROM " . DB::table(getposttable($tableid)) . " WHERE tid IN (" . dimplode($tids) . ") AND first='1'");
             while ($post = DB::fetch($query)) {
                 $threadlist[$post['tid']]['message'] = bat_highlight(messagecutstr($post['message'], 200), $keyword);
             }
         }
     }
     $multipage = multi($index['num'], $_G['tpp'], $page, "search.php?mod=forum&searchid={$searchid}&orderby={$orderby}&ascdesc={$ascdesc}&searchsubmit=yes");
     $url_forward = 'search.php?mod=forum&' . $_SERVER['QUERY_STRING'];
     $fulltextchecked = $searchstring[1] == 'fulltext' ? 'checked="checked"' : '';
     include template('search/forum');
 } else {
     if ($_G['group']['allowsearch'] & 32 && $srchtype == 'fulltext') {
         periodscheck('searchbanperiods');
     } elseif ($srchtype != 'title') {
         $srchtype = 'title';
     }
     $forumsarray = array();
     if (!empty($srchfid)) {