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}");
     }
 }
Beispiel #2
0
 function forumdisplay_variables(&$variables)
 {
     global $_G;
     if (!$_G['wechat']['setting']['wsq_allow'] || !$_G['wechat']['setting']['showactivity']['tids']) {
         return;
     }
     $tids = array();
     foreach ($variables['forum_threadlist'] as &$thread) {
         if (in_array($thread['tid'], $_G['wechat']['setting']['showactivity']['tids'])) {
             $thread['showactivity'] = 1;
             $tids[] = $thread['tid'];
         }
     }
     $activities = C::t('forum_activity')->fetch_all($tids);
     foreach ($activities as $tid => $activity) {
         $variables['showactivity'][$tid]['starttimefrom'] = dgmdate($activities[$tid]['starttimefrom']);
         $variables['showactivity'][$tid]['expiration'] = dgmdate($activities[$tid]['expiration']);
         $variables['showactivity'][$tid]['applynumber'] = $activities[$tid]['applynumber'];
         $variables['showactivity'][$tid]['thumb'] = $activity['aid'] ? $_G['siteurl'] . getforumimg($activity['aid'], 0, 400, 400) : '';
     }
 }
Beispiel #3
0
                 $feed['title_template'] = 'feed_thread_debatevote_title_1';
             } elseif ($stand == 2) {
                 $feed['title_template'] = 'feed_thread_debatevote_title_2';
             } else {
                 $feed['title_template'] = 'feed_thread_debatevote_title_3';
             }
             $feed['title_data'] = array('subject' => "<a href=\"{$_G['siteurl']}forum.php?mod=viewthread&tid={$_G['tid']}\">{$thread['subject']}</a>", 'author' => "<a href=\"home.php?mod=space&uid={$thread['authorid']}\">{$thread['author']}</a>");
         } elseif ($thread['authorid'] != $_G['uid']) {
             $post_url = "forum.php?mod=redirect&goto=findpost&pid={$pid}&ptid={$_G['tid']}";
             $feed['icon'] = 'post';
             $feed['title_template'] = !empty($thread['author']) ? 'feed_reply_title' : 'feed_reply_title_anonymous';
             $feed['title_data'] = array('subject' => "<a href=\"{$post_url}\">{$thread['subject']}</a>", 'author' => "<a href=\"home.php?mod=space&uid={$thread['authorid']}\">{$thread['author']}</a>");
             if (!empty($_G['forum_attachexist'])) {
                 $firstaid = DB::result_first("SELECT aid FROM " . DB::table('forum_attachment') . " WHERE pid='{$pid}' AND dateline>'0' AND isimage='1' ORDER BY dateline LIMIT 1");
                 if ($firstaid) {
                     $feed['images'] = array(getforumimg($firstaid));
                     $feed['image_links'] = array($post_url);
                 }
             }
         }
         $feed['title_data']['hash_data'] = "tid{$_G[tid]}";
         $feed['id'] = $tid;
         $feed['idtype'] = 'tid';
         postfeed($feed);
     }
     include_once libfile('function/stat');
     updatestat($thread['isgroup'] ? 'grouppost' : 'post');
     $page = getstatus($thread['status'], 4) ? 1 : @ceil(($thread['special'] ? $thread['replies'] + 1 : $thread['replies'] + 2) / $_G['ppp']);
     $url = empty($_POST['portal_referer']) ? "forum.php?mod=viewthread&tid={$thread[tid]}&pid={$pid}&page={$page}&extra={$extra}#pid{$pid}" : $_POST['portal_referer'];
     showmessage($replymessage, $url, $param);
 }
<td>&nbsp;</td>
<td>
<label class="labeltxt">图片</label>
<select name="selectattach" onchange="updateimginfo(this.value)" class="ps" style="width: 132px">
<option value="">不显示</option><?php if(is_array($imgattach)) foreach($imgattach as $imginfo) { ?><option value="<?php echo $imginfo['aid'];?>"<?php if($selectattach == $imginfo['aid']) { ?> selected="selected"<?php } ?>><?php echo $imginfo['filename'];?></option>
<?php } ?>
</select>
</td>
</tr>
<tr class="dopt">
<td>&nbsp;</td>
<td>
<label class="labeltxt">&nbsp;</label>
<img id="selectimg" src="<?php echo STATICURL;?>image/common/none.gif"  width="120" height="80" />
<script type="text/javascript" reload="1">
var imgk = new Array();<?php if(is_array($imgattach)) foreach($imgattach as $imginfo) { $a = '\"\'\t\\""\\\''."\\\\";$k = getforumimg($imginfo['aid'], 1, 120, 80);?>imgk[<?php echo $imginfo['aid'];?>] = '<?php echo $k;?>';
<?php } ?>
function updateimginfo(aid) {
if(aid) {
$('selectimg').src=imgk[aid];
} else {
$('selectimg').src='<?php echo STATICURL;?>image/common/none.gif';
}
}
<?php if($selectattach) { ?>updateimginfo('<?php echo $selectattach;?>');<?php } ?>
</script>
</td>
</tr>
<?php } } ?>
</table>
</li>
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     loadcache('grouptype');
     $typeids = !empty($parameter['gtids']) && !in_array('0', $parameter['gtids']) ? $parameter['gtids'] : array_keys($_G['cache']['grouptype']['first']);
     $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'] : '';
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     if (empty($fids)) {
         $plusids = $typeids ? array(0) : array();
         foreach ($typeids as $typeid) {
             if (!empty($_G['cache']['grouptype']['first'][$typeid]['secondlist'])) {
                 $plusids = array_merge($plusids, $_G['cache']['grouptype']['first'][$typeid]['secondlist']);
             }
         }
         $typeids = array_merge($typeids, $plusids);
         $groups = array();
         if ($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) . ")");
             while ($value = DB::fetch($query)) {
                 $groups[$value['fid']] = $value;
                 $fids[] = intval($value['fid']);
             }
         }
     }
     require_once libfile('function/post');
     $datalist = $list = array();
     if ($keyword) {
         if (preg_match("(AND|\\+|&|\\s)", $keyword) && !preg_match("(OR|\\|)", $keyword)) {
             $andor = ' AND ';
             $keywordsrch = '1';
             $keyword = preg_replace("/( AND |&| )/is", "+", $keyword);
         } else {
             $andor = ' OR ';
             $keywordsrch = '0';
             $keyword = preg_replace("/( OR |\\|)/is", "+", $keyword);
         }
         $keyword = str_replace('*', '%', addcslashes($keyword, '%_'));
         foreach (explode('+', $keyword) as $text) {
             $text = trim($text);
             if ($text) {
                 $keywordsrch .= $andor;
                 $keywordsrch .= "tr.subject LIKE '%{$text}%'";
             }
         }
         $keyword = " AND ({$keywordsrch})";
     } else {
         $keyword = '';
     }
     $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) . ')' : '') . " AND t.isgroup='1'";
     $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 = gmdate('w', TIMESTAMP) - 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 = ' WHERE tr.dateline>=' . $historytime;
         $orderby = 'totalitems';
     }
     $where .= ($uids ? ' AND tr.sellerid IN (' . dimplode($uids) . ')' : '') . $keyword;
     $where .= $bannedids ? ' AND tr.pid NOT IN (' . dimplode($bannedids) . ')' : '';
     $sqlfrom = " INNER JOIN `" . DB::table('forum_thread') . "` t ON t.tid=tr.tid {$sql} AND t.displayorder>='0'";
     if ($recommend) {
         $sqlfrom .= " INNER JOIN `" . DB::table('forum_forumrecommend') . "` fc ON fc.tid=tr.tid";
     }
     $query = DB::query("SELECT tr.pid, tr.tid, tr.aid, tr.price, tr.credit, tr.subject, tr.totalitems, tr.seller, tr.sellerid\n\t\t\tFROM " . DB::table('forum_trade') . " tr {$sqlfrom} {$where}\n\t\t\tORDER BY tr.{$orderby} DESC\n\t\t\tLIMIT {$startrow},{$items};");
     include_once libfile('block/thread', 'class');
     $bt = new block_thread();
     while ($data = DB::fetch($query)) {
         $list[] = 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'] ? getforumimg($data['aid']) : IMGDIR . '/nophoto.gif', 'picflag' => '0', 'summary' => !empty($style['getsummary']) ? $bt->getthread($data['tid'], $summarylength, true) : '', 'fields' => array('totalitems' => $data['totalitems'], 'author' => $data['seller'] ? $data['seller'] : 'Anonymous', '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'] : '')));
     }
     return array('html' => '', 'data' => $list);
 }
echo $curaidkey + 1;
?>
</span> 张 / 共 <?php 
echo $count;
?>
 张</span>
</div>
<ul class="postalbum_c"><?php 
if (is_array($imglist['url'])) {
    foreach ($imglist['url'] as $key => $imgurl) {
        ?>
<li class="postalbum_u" id="u_<?php 
        echo $key;
        ?>
"><?php 
        $imgurl = getforumimg($imglist[aid][$key], 0, 2000, 550, 'fixnone');
        ?>
<img class="postalbum_i" load="0" id="img_<?php 
        echo $key;
        ?>
" <?php 
        if ($curaidkey == $key) {
            ?>
src="<?php 
            echo $imgurl;
            ?>
"<?php 
        }
        ?>
 zsrc="<?php 
        echo $imgurl;
function showsorttemplate($sortid, $fid, $sortoptionarray, $templatearray, $threadlist, $threadids = array())
{
    global $_G;
    $searchtitle = $searchvalue = $searchunit = $stemplate = $searchtids = $sortlistarray = $skipaids = $sortdata = array();
    $addsortid = !empty($sortid) ? "sortid='{$sortid}' AND" : '';
    $addthreadid = !empty($threadids) ? "AND tid IN (" . dimplode($threadids) . ")" : '';
    $query = DB::query("SELECT sortid, tid, optionid, value, expiration FROM " . DB::table('forum_typeoptionvar') . " WHERE {$addsortid} fid='{$fid}' {$addthreadid}");
    while ($sortthread = DB::fetch($query)) {
        $optionid = $sortthread['optionid'];
        $sortid = $sortthread['sortid'];
        $tid = $sortthread['tid'];
        $arrayoption = $sortoptionarray[$sortid][$optionid];
        if ($sortoptionarray[$sortid][$optionid]['subjectshow']) {
            $_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['title'] = $arrayoption['title'];
            $_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['unit'] = $arrayoption['unit'];
            if (in_array($arrayoption['type'], array('radio', 'checkbox', 'select'))) {
                if ($arrayoption['type'] == 'checkbox') {
                    foreach (explode("\t", $sortthread['value']) as $choiceid) {
                        $sortthreadlist[$tid][$arrayoption['title']] .= $arrayoption['choices'][$choiceid] . '&nbsp;';
                        $_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['value'] .= $arrayoption['choices'][$choiceid] . '&nbsp;';
                    }
                } elseif ($arrayoption['type'] == 'select') {
                    $sortthreadlist[$tid][$arrayoption['title']] = $_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['value'] = $arrayoption['choices'][$sortthread['value']]['content'];
                } else {
                    $sortthreadlist[$tid][$arrayoption['title']] = $_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['value'] = $arrayoption['choices'][$sortthread['value']];
                }
            } elseif ($arrayoption['type'] == 'image') {
                $imgoptiondata = unserialize($sortthread['value']);
                if (empty($templatearray[$sortid])) {
                    $maxwidth = $arrayoption['maxwidth'] ? 'width="' . $arrayoption['maxwidth'] . '"' : '';
                    $maxheight = $arrayoption['maxheight'] ? 'height="' . $arrayoption['maxheight'] . '"' : '';
                    $sortthreadlist[$tid][$arrayoption['title']] = $_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['value'] = $imgoptiondata['url'] ? "<img src=\"{$imgoptiondata['url']}\" onload=\"thumbImg(this)\" {$maxwidth} {$maxheight} border=\"0\">" : '';
                } else {
                    $sortthread['value'] = '';
                    if ($imgoptiondata['aid']) {
                        $sortthread['value'] = getforumimg($imgoptiondata['aid'], 0, 120, 120);
                    } elseif ($imgoptiondata['url']) {
                        $sortthread['value'] = $imgoptiondata['url'];
                    }
                    $sortthreadlist[$tid][$arrayoption['title']] = $_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['value'] = $sortthread['value'] ? $sortthread['value'] : './static/image/common/nophotosmall.gif';
                }
            } else {
                $sortthreadlist[$tid][$arrayoption['title']] = $_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['value'] = $sortthread['value'] ? $sortthread['value'] : $arrayoption['defaultvalue'];
            }
            $sortthreadlist[$tid]['sortid'] = $sortid;
            $sortthreadlist[$tid]['expiration'] = $sortthread['expiration'] && $sortthread['expiration'] <= TIMESTAMP ? 1 : 0;
        }
    }
    if ($templatearray && $sortthreadlist) {
        foreach ($threadlist as $thread) {
            $thread['digest'] = $thread['digest'] ? '&nbsp;<img src="' . $_G['style']['imgdir'] . '/digest_' . $thread['digest'] . '.gif" class="vm" alt="" title="" />' : '';
            $sortdata[$thread['tid']]['subject'] = '<a href="forum.php?mod=viewthread&tid=' . $thread['tid'] . '" ' . $thread['highlight'] . '>' . $thread['subject'] . '</a>' . $thread['digest'];
            $sortdata[$thread['tid']]['author'] = '<a href="home.php?mod=space&uid=' . $thread['authorid'] . '" target="_blank">' . $thread['author'] . '</a>';
        }
        foreach ($sortoptionarray as $sortid => $optionarray) {
            foreach ($optionarray as $option) {
                if ($option['subjectshow']) {
                    $searchtitle[$sortid][] = '/{(' . $option['identifier'] . ')}/e';
                    $searchvalue[$sortid][] = '/\\[(' . $option['identifier'] . ')value\\]/e';
                    $searchunit[$sortid][] = '/\\[(' . $option['identifier'] . ')unit\\]/e';
                }
            }
        }
        foreach ($sortthreadlist as $tid => $option) {
            $sortid = $option['sortid'];
            $sortexpiration[$sortid][$tid] = $option['expiration'];
            $stemplate[$sortid][$tid] = preg_replace(array("/\\{sortname\\}/i", "/\\{author\\}/i", "/\\{subject\\}/i", "/\\[url\\](.+?)\\[\\/url\\]/i"), array('<a href="forum.php?mod=forumdisplay&fid=' . $_G['fid'] . '&filter=sortid&sortid=' . $sortid . '">' . $_G['forum']['threadsorts']['types'][$sortid] . '</a>', $sortdata[$tid]['author'], $sortdata[$tid]['subject'], "<a href=\"forum.php?mod=viewthread&tid={$tid}\">\\1</a>"), stripslashes($templatearray[$sortid]));
            $stemplate[$sortid][$tid] = preg_replace($searchtitle[$sortid], "showlistoption('\\1', 'title', '{$tid}', '{$sortid}')", $stemplate[$sortid][$tid]);
            $stemplate[$sortid][$tid] = preg_replace($searchvalue[$sortid], "showlistoption('\\1', 'value', '{$tid}', '{$sortid}')", $stemplate[$sortid][$tid]);
            $stemplate[$sortid][$tid] = preg_replace($searchunit[$sortid], "showlistoption('\\1', 'unit', '{$tid}', '{$sortid}')", $stemplate[$sortid][$tid]);
        }
    }
    $sortlistarray['template'] = $stemplate;
    $sortlistarray['expiration'] = $sortexpiration;
    return $sortlistarray;
}
Beispiel #8
0
 $feed = array();
 if (!empty($_G['gp_addfeed']) && $_G['forum']['allowfeed'] && !$isanonymous) {
     $feed['icon'] = 'goods';
     $feed['title_template'] = 'feed_thread_goods_title';
     if ($_G['gp_item_price'] > 0) {
         if ($_G['setting']['creditstransextra'][5] != -1 && $_G['gp_item_credit']) {
             $feed['body_template'] = 'feed_thread_goods_message_1';
         } else {
             $feed['body_template'] = 'feed_thread_goods_message_2';
         }
     } else {
         $feed['body_template'] = 'feed_thread_goods_message_3';
     }
     $feed['body_data'] = array('itemname' => "<a href=\"{$_G['siteurl']}forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}\">{$_G['gp_item_name']}</a>", 'itemprice' => $_G['gp_item_price'], 'itemcredit' => $_G['gp_item_credit'], 'creditunit' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][5]]['unit'] . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][5]]['title']);
     if ($_G['gp_tradeaid']) {
         $feed['images'] = array(getforumimg($_G['gp_tradeaid']));
         $feed['image_links'] = array("{$_G['siteurl']}forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}");
     }
     if ($_G['gp_tradeaid']) {
         $attachment = DB::fetch_first("SELECT * FROM " . DB::table('forum_attachment') . " WHERE aid='{$_G['gp_tradeaid']}'");
         if (in_array($attachment['filetype'], array('image/gif', 'image/jpeg', 'image/png'))) {
             $_G['setting']['attachurl'] = preg_match("/^((https?|ftps?):\\/\\/|www\\.)/i", $_G['setting']['attachurl']) ? $_G['setting']['attachurl'] : $_G['siteurl'] . $_G['setting']['attachurl'];
             $imgurl = $_G['setting']['attachurl'] . '/forum/' . $attachment['attachment'] . ($attachment['thumb'] && $attachment['filetype'] != 'image/gif' ? '.thumb.jpg' : '');
             $feed['images'][] = $attachment['attachment'] ? $imgurl : '';
             $feed['image_links'][] = $attachment['attachment'] ? "{$_G['siteurl']}forum.php?mod=viewthread&tid={$tid}" : '';
         }
     }
     $feed['title_data']['hash_data'] = "tid{$tid}";
     $feed['id'] = $tid;
     $feed['idtype'] = 'tid';
     postfeed($feed);
Beispiel #9
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;
 }
 public function before_replyfeed()
 {
     if ($this->forum['allowfeed'] && !$this->param['isanonymous']) {
         if ($this->param['special'] == 2 && !empty($_GET['trade'])) {
             $creditstransextra = $this->setting['creditstransextra'];
             $extcredits = $this->setting['extcredits'];
             $this->feed['icon'] = 'goods';
             $this->feed['title_template'] = 'feed_thread_goods_title';
             if ($_GET['item_price'] > 0) {
                 if ($creditstransextra[5] != -1 && $_GET['item_credit']) {
                     $this->feed['body_template'] = 'feed_thread_goods_message_1';
                 } else {
                     $this->feed['body_template'] = 'feed_thread_goods_message_2';
                 }
             } else {
                 $this->feed['body_template'] = 'feed_thread_goods_message_3';
             }
             $this->feed['body_data'] = array('itemname' => "<a href=\"forum.php?mod=viewthread&do=tradeinfo&tid=" . $this->thread['tid'] . "&pid=" . $this->pid . "\">" . dhtmlspecialchars($_GET['item_name']) . "</a>", 'itemprice' => $_GET['item_price'], 'itemcredit' => $_GET['item_credit'], 'creditunit' => $extcredits[$creditstransextra[5]]['unit'] . $extcredits[$creditstransextra[5]]['title']);
             if ($_GET['tradeaid']) {
                 $this->feed['images'] = array(getforumimg($_GET['tradeaid']));
                 $this->feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid=" . $this->thread['tid'] . "&pid=" . $this->pid);
             }
         }
     }
 }
 function getthread($tidarray, $messagelength = 80, $nospecial = false)
 {
     global $_G;
     if (!$tidarray) {
         return '';
     }
     $notexists = $messagearr = $returnarr = array();
     foreach ($tidarray as $var) {
         foreach ($var as $v) {
             if (empty($_G['block_thread'][$v])) {
                 $notexists[] = $v;
             }
         }
     }
     if ($notexists) {
         $query = DB::query("SELECT tid, fid, subject, posttableid, price, special FROM " . DB::table('forum_thread') . " WHERE tid IN (" . dimplode($notexists) . ")");
         while ($result = DB::fetch($query)) {
             $_G['block_thread'][$result['tid']] = $result;
         }
     }
     foreach ($tidarray as $key => $var) {
         if ($key == 0) {
             $posttable = 'forum_post';
         } else {
             $posttable = "forum_post_{$key}";
         }
         $query = DB::query("SELECT tid, message FROM " . DB::table($posttable) . " WHERE tid IN  (" . dimplode($var) . ") AND first=1");
         while ($result = DB::fetch($query)) {
             $messagearr[$result['tid']] = $result['message'];
         }
     }
     require_once libfile('function/post');
     require_once libfile('function/discuzcode');
     if ($messagearr) {
         foreach ($messagearr as $tid => $var) {
             $thread = $_G['block_thread'][$tid];
             if ($nospecial) {
                 $thread['special'] = 0;
             }
             if ($thread['special'] == 1) {
                 $polloptions = array();
                 $multiple = DB::result_first("SELECT multiple FROM " . DB::table('forum_poll') . " WHERE tid='{$tid}'");
                 $optiontype = $multiple ? 'checkbox' : 'radio';
                 $query = DB::query("SELECT polloptionid, polloption FROM " . DB::table('forum_polloption') . " WHERE tid='{$tid}' ORDER BY displayorder");
                 while ($polloption = DB::fetch($query)) {
                     $polloption['polloption'] = preg_replace("/\\[url=(https?){1}:\\/\\/([^\\[\"']+?)\\](.+?)\\[\\/url\\]/i", "<a href=\"\\1://\\2\" target=\"_blank\">\\3</a>", $polloption['polloption']);
                     $polloptions[] = $polloption;
                 }
             } elseif ($thread['special'] == 2) {
                 $trade = C::t('forum_trade')->fetch_first_goods($tid);
                 $trade['aid'] = $trade['aid'] ? getforumimg($trade['aid']) : '';
                 $trades[] = $trade;
             } elseif ($thread['special'] == 3) {
                 $extcredits = $_G['settings']['extcredits'];
                 $creditstransextra = $_G['settings']['creditstransextra'];
                 $rewardend = $thread['price'] < 0;
                 $rewardprice = abs($thread['price']);
                 $message = messagecutstr($var, $messagelength);
             } elseif ($thread['special'] == 4) {
                 $message = messagecutstr($var, $messagelength);
                 $activity = DB::fetch_first("SELECT aid, number, applynumber FROM " . DB::table('forum_activity') . " WHERE tid='{$tid}'");
                 $activity['aid'] = $activity['aid'] ? getforumimg($activity['aid']) : '';
                 $activity['aboutmember'] = $activity['number'] - $activity['applynumber'];
             } elseif ($thread['special'] == 5) {
                 $message = messagecutstr($var, $messagelength);
                 $debate = C::t('forum_debate')->fetch($tid);
                 $debate['affirmvoteswidth'] = $debate['affirmvotes'] ? intval(80 * (($debate['affirmvotes'] + 1) / ($debate['affirmvotes'] + $debate['negavotes'] + 1))) : 1;
                 $debate['negavoteswidth'] = $debate['negavotes'] ? intval(80 * (($debate['negavotes'] + 1) / ($debate['affirmvotes'] + $debate['negavotes'] + 1))) : 1;
                 $debate['affirmpoint'] = discuzcode($debate['affirmpoint'], 0, 0, 0, 1, 1, 0, 0, 0, 0, 0);
                 $debate['negapoint'] = discuzcode($debate['negapoint'], 0, 0, 0, 1, 1, 0, 0, 0, 0, 0);
             } else {
                 $message = messagecutstr($var, $messagelength);
             }
             include template('common/block_thread');
             $returnarr[$tid] = $return;
         }
     }
     return $returnarr;
 }
 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 recommendupdate($fid, &$modrecommend, $force = '', $position = 0)
{
    global $_G;
    $recommendlist = $recommendimagelist = $modedtids = array();
    $num = $modrecommend['num'] ? intval($modrecommend['num']) : 10;
    $imagenum = $modrecommend['imagenum'] = $modrecommend['imagenum'] ? intval($modrecommend['imagenum']) : 0;
    $imgw = $modrecommend['imagewidth'] = $modrecommend['imagewidth'] ? intval($modrecommend['imagewidth']) : 200;
    $imgh = $modrecommend['imageheight'] = $modrecommend['imageheight'] ? intval($modrecommend['imageheight']) : 150;
    if ($modrecommend['sort'] && (TIMESTAMP - $modrecommend['updatetime'] > $modrecommend['cachelife'] || $force)) {
        foreach (C::t('forum_forumrecommend')->fetch_all_by_fid($fid) as $row) {
            if ($modrecommend['sort'] == 2 && $row['moderatorid']) {
                $modedtids[] = $row['tid'];
            }
        }
        C::t('forum_forumrecommend')->delete_by_fid($fid, $modrecommend['sort'] == 2 ? 0 : false);
        $orderby = 'dateline';
        $dateline = $modrecommend['dateline'] ? TIMESTAMP - $modrecommend['dateline'] * 3600 : null;
        $recommends = null;
        switch ($modrecommend['orderby']) {
            case '':
            case '1':
                $orderby = 'lastpost';
                break;
            case '2':
                $orderby = 'views';
                break;
            case '3':
                $orderby = 'replies';
                break;
            case '4':
                $orderby = 'digest';
                break;
            case '5':
                $orderby = 'recommends';
                $recommends = 0;
                break;
            case '6':
                $orderby = 'heats';
                break;
        }
        $i = 0;
        $addthread = $addimg = $recommendlist = $recommendimagelist = $tids = array();
        foreach (C::t('forum_thread')->fetch_all_by_fid_displayorder($fid, 0, $dateline, $recommends, 0, $num, $orderby) as $thread) {
            $recommendlist[$thread['tid']] = $thread;
            $tids[] = $thread['tid'];
            if (!$modedtids || !in_array($thread['tid'], $modedtids)) {
                $addthread[$thread['tid']] = array('fid' => $thread['fid'], 'tid' => $thread['tid'], 'position' => 1, 'displayorder' => $i, 'subject' => $thread['subject'], 'author' => $thread['author'], 'authorid' => $thread['authorid'], 'moderatorid' => 0, 'expiration' => 0, 'highlight' => $thread['highlight']);
                $i++;
            }
        }
        if ($tids && $imagenum) {
            $attachtables = array();
            foreach ($tids as $tid) {
                $attachtables[getattachtablebytid($tid)][] = $tid;
            }
            foreach ($attachtables as $attachtable => $tids) {
                $attachmentpost = array();
                $postlist = C::t('forum_post')->fetch_all_by_tid(0, $tids, false, '', 0, 0, 1);
                if ($postlist) {
                    $pids = array();
                    foreach ($postlist as $post) {
                        $pids[] = $post['pid'];
                    }
                    $attachmentlist = C::t('forum_attachment_n')->fetch_all_by_pid_width('tid:' . $tids[0], $pids, $imgw);
                    if ($attachmentlist) {
                        foreach ($attachmentlist as $k => $attachment) {
                            $attachmentpost[$k]['fid'] = $postlist[$attachment['pid']]['fid'];
                            $attachmentpost[$k]['tid'] = $postlist[$attachment['pid']]['tid'];
                            $attachmentpost[$k]['aid'] = $attachment['aid'];
                        }
                    }
                    unset($postlist, $attachmentlist, $pids);
                }
                foreach ($attachmentpost as $attachment) {
                    if (isset($recommendimagelist[$attachment['tid']])) {
                        continue;
                    }
                    $key = md5($attachment['aid'] . '|' . $imgw . '|' . $imgh);
                    $recommendlist[$attachment['tid']]['filename'] = $attachment['aid'] . "\t" . $imgw . "\t" . $imgh . "\t" . $key;
                    $recommendimagelist[$attachment['tid']] = $recommendlist[$attachment['tid']];
                    $recommendimagelist[$attachment['tid']]['subject'] = addslashes($recommendimagelist[$attachment['tid']]['subject']);
                    $addthread[$attachment['tid']]['aid'] = '';
                    $addthread[$attachment['tid']]['filename'] = $recommendlist[$attachment['tid']]['filename'];
                    $addthread[$attachment['tid']]['typeid'] = 1;
                    if (count($recommendimagelist) == $imagenum) {
                        break;
                    }
                }
            }
        }
        unset($recommendimagelist);
        if ($addthread) {
            foreach ($addthread as $row) {
                C::t('forum_forumrecommend')->insert($row, false, true);
            }
            $modrecommend['updatetime'] = TIMESTAMP;
            $modrecommendnew = serialize($modrecommend);
            C::t('forum_forumfield')->update($fid, array('modrecommend' => $modrecommendnew));
        }
    }
    $recommendlists = $recommendlist = array();
    foreach (C::t('forum_forumrecommend')->fetch_all_by_fid($fid, $position) as $recommend) {
        if ($recommend['expiration'] && $recommend['expiration'] > TIMESTAMP || !$recommend['expiration']) {
            if ($recommend['filename'] && strexists($recommend['filename'], "\t")) {
                $imgd = explode("\t", $recommend['filename']);
                if ($imgd[0] && $imgd[3]) {
                    $recommend['filename'] = getforumimg($imgd[0], 0, $imgd[1], $imgd[2]);
                }
            }
            $recommendlist[] = $recommend;
            if ($recommend['typeid'] && count($recommendimagelist) < $imagenum) {
                $recommendimagelist[] = $recommend;
            }
        }
        if (count($recommendlist) == $num) {
            break;
        }
    }
    if ($recommendlist) {
        $_G['forum_colorarray'] = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
        foreach ($recommendlist as $thread) {
            if ($thread['highlight']) {
                $string = sprintf('%02d', $thread['highlight']);
                $stylestr = sprintf('%03b', $string[0]);
                $thread['highlight'] = ' style="';
                $thread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
                $thread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
                $thread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
                $thread['highlight'] .= $string[1] ? 'color: ' . $_G['forum_colorarray'][$string[1]] : '';
                $thread['highlight'] .= '"';
            } else {
                $thread['highlight'] = '';
            }
            $recommendlists[$thread['tid']]['author'] = $thread['author'];
            $recommendlists[$thread['tid']]['authorid'] = $thread['authorid'];
            $recommendlists[$thread['tid']]['subject'] = $modrecommend['maxlength'] ? cutstr($thread['subject'], $modrecommend['maxlength']) : $thread['subject'];
            $recommendlists[$thread['tid']]['subjectstyles'] = $thread['highlight'];
        }
    }
    if ($recommendimagelist && $recommendlist) {
        $recommendlists['images'] = $recommendimagelist;
    }
    return $recommendlists;
}
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     loadcache('grouptype');
     $typeids = !empty($parameter['gtids']) && !in_array('0', $parameter['gtids']) ? $parameter['gtids'] : array_keys($_G['cache']['grouptype']['first']);
     $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 = !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')) ? $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']) ? $parameter['class'] : '';
     $gender = !empty($parameter['gender']) ? intval($parameter['gender']) : '';
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     if (empty($fids)) {
         $plusids = $typeids ? array(0) : array();
         foreach ($typeids as $typeid) {
             if (!empty($_G['cache']['grouptype']['first'][$typeid]['secondlist'])) {
                 $plusids = array_merge($plusids, $_G['cache']['grouptype']['first'][$typeid]['secondlist']);
             }
         }
         $typeids = array_merge($typeids, $plusids);
         $groups = array();
         if ($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) . ")");
             while ($value = DB::fetch($query)) {
                 $groups[$value['fid']] = $value;
                 $fids[] = intval($value['fid']);
             }
         }
     }
     require_once libfile('function/post');
     $datalist = $list = array();
     if ($keyword) {
         if (preg_match("(AND|\\+|&|\\s)", $keyword) && !preg_match("(OR|\\|)", $keyword)) {
             $andor = ' AND ';
             $keywordsrch = '1';
             $keyword = preg_replace("/( AND |&| )/is", "+", $keyword);
         } else {
             $andor = ' OR ';
             $keywordsrch = '0';
             $keyword = preg_replace("/( OR |\\|)/is", "+", $keyword);
         }
         $keyword = str_replace('*', '%', addcslashes($keyword, '%_'));
         foreach (explode('+', $keyword) as $text) {
             $text = trim($text);
             if ($text) {
                 $keywordsrch .= $andor;
                 $keywordsrch .= "t.subject LIKE '%{$text}%'";
             }
         }
         $keyword = " AND ({$keywordsrch})";
     } else {
         $keyword = '';
     }
     $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='1'";
     $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';
     } else {
         $orderby = 't.dateline DESC';
     }
     $where .= $uids ? ' AND t.authorid IN (' . dimplode($uids) . ')' : '';
     if ($gender) {
         $where .= " AND a.gender='{$gender}'";
     }
     $sqlfrom = " INNER JOIN `" . DB::table('forum_thread') . "` t ON t.tid=a.tid {$sql} AND t.displayorder>='0'";
     if ($recommend) {
         $sqlfrom .= " INNER JOIN `" . DB::table('forum_forumrecommend') . "` fc ON fc.tid=tr.tid";
     }
     $query = DB::query("SELECT a.*, t.tid, t.subject, t.authorid, t.author\n\t\t\tFROM " . DB::table('forum_activity') . " a {$sqlfrom} {$where}\n\t\t\tORDER BY {$orderby}\n\t\t\tLIMIT {$startrow},{$items};");
     include_once libfile('block/thread', 'class');
     $bt = new block_thread();
     while ($data = DB::fetch($query)) {
         $data['time'] = dgmdate($data['starttimefrom']);
         if ($data['starttimeto']) {
             $data['time'] .= ' - ' . dgmdate($data['starttimeto']);
         }
         $list[] = array('id' => $data['pid'], 'idtype' => 'pid', 'title' => cutstr(str_replace('\\\'', '&#39;', addslashes($data['subject'])), $titlelength), 'url' => 'forum.php?mod=viewthread&tid=' . $data['tid'], 'pic' => $data['aid'] ? getforumimg($data['aid']) : IMGDIR . '/nophoto.gif', 'picflag' => '0', 'summary' => !empty($style['getsummary']) ? $bt->getthread($data['tid'], $summarylength, true) : '', 'fields' => array('time' => $data['time'], 'expiration' => $data['expiration'] ? dgmdate($data['expiration']) : 'N/A', 'author' => $data['author'] ? $data['author'] : 'Anonymous', 'authorid' => $data['authorid'] ? $data['authorid'] : 0, 'cost' => $data['cost'], 'place' => $data['place'], 'class' => $data['class'], 'gender' => $data['gender'], 'number' => $data['number'], 'applynumber' => $data['applynumber']));
     }
     return array('html' => '', 'data' => $list);
 }
function attachinpost($attach)
{
    global $_G;
    $attach['refcheck'] = !$attach['remote'] && $_G['setting']['attachrefcheck'] || $attach['remote'] && ($_G['setting']['ftp']['hideurl'] || $attach['isimage'] && $_G['setting']['attachimgpost'] && strtolower(substr($_G['setting']['ftp']['attachurl'], 0, 3)) == 'ftp');
    $mobilethumburl = $attach['attachimg'] && $_G['setting']['showimages'] && (!$attach['price'] || $attach['payed']) && ($_G['group']['allowgetimage'] || $_G['uid'] == $attach['uid']) ? getforumimg($attach['aid'], 0, 140, 140, 'fixnone') : '';
    $aidencode = packaids($attach);
    $is_archive = $_G['forum_thread']['is_archived'] ? '&fid=' . $_G['fid'] . '&archiveid=' . $_G[forum_thread][archiveid] : '';
    $return = <<<EOF


EOF;
    if ($attach['attachimg'] && $_G['setting']['showimages'] && (!$attach['price'] || $attach['payed']) && ($_G['group']['allowgetimage'] || $_G['uid'] == $attach['uid'])) {
        if ($_G['setting']['mobile']['mobilesimpletype'] == 0) {
            $return .= <<<EOF

<a href="forum.php?mod=viewthread&amp;tid={$attach['tid']}&amp;aid={$attach['aid']}&amp;from=album&amp;page={$_G['page']}" class="orange"><img id="aimg_{$attach['aid']}" src="{$mobilethumburl}" alt="{$attach['imgalt']}" title="{$attach['imgalt']}" /></a>

EOF;
        }
    } else {
        if (!$attach['price'] || $attach['payed']) {
            $return .= <<<EOF

<div id="attach_{$attach['aid']}" class="box attach mbn" >

EOF;
            if ($_G['setting']['mobile']['mobilesimpletype'] == 0) {
                $return .= <<<EOF

{$attach['attachicon']}

EOF;
            }
            if (!$attach['price'] || $attach['payed']) {
                $return .= <<<EOF

<a href="forum.php?mod=attachment{$is_archive}&amp;aid={$aidencode}" target="_blank">{$attach['filename']}</a>

EOF;
            } else {
                $return .= <<<EOF

<a href="forum.php?mod=misc&amp;action=attachpay&amp;aid={$attach['aid']}&amp;tid={$attach['tid']}" target="_blank">{$attach['filename']}</a>

EOF;
            }
            $return .= <<<EOF

<em class="xg1">({$attach['attachsize']})</em>
<em class="xg1"><br />(下载次数: {$attach['downloads']}, {$attach['dateline']} 上传)
</em>

EOF;
            if (!$attach['attachimg'] && $_G['getattachcredits']) {
                $return .= <<<EOF
<p>下载积分: {$_G['getattachcredits']}</p>
EOF;
            }
            $return .= <<<EOF

</div>

EOF;
        }
    }
    $return .= <<<EOF


EOF;
    return $return;
}
         $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);
 }
Beispiel #17
0
         $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' => $_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);
 }
            }
        }
        ?>
</p>
<span id="attachupdate<?php 
        echo $attach['aid'];
        ?>
"></span>
<?php 
        if ($attach['isimage']) {
            ?>
<div id="attach_preview_<?php 
            echo $attach['aid'];
            ?>
_menu" class="attach_preview" style="display:none"><img src="<?php 
            echo getforumimg($attach['aid'], 1, 300, 300, 'fixnone');
            ?>
&ramdom=<?php 
            echo random(5);
            ?>
" id="image_<?php 
            echo $attach['aid'];
            ?>
" cwidth="<?php 
            if ($attach['width'] < 300) {
                echo $attach['width'];
            } else {
                ?>
300<?php 
            }
            ?>
Beispiel #19
0
 public function connectParseAttach($content, $fId, $pId, &$attachImages)
 {
     global $_G;
     $permissions = $this->connectGetUserGroupPermissions(self::SPECIAL_GID, $fId);
     $visitorPermission = $permissions[self::SPECIAL_GID];
     $attachIds = array();
     $attachImages = array();
     $attachments = C::t('forum_attachment')->fetch_all_by_id('pid', $pId);
     $attachments = C::t('forum_attachment_n')->fetch_all("pid:{$pId}", array_keys($attachments));
     foreach ($attachments as $k => $attach) {
         $aid = $attach['aid'];
         if ($attach['isimage'] == 0 || $attach['price'] > 0 || $attach['readperm'] > $visitorPermission['readPermission'] || in_array($fId, $visitorPermission['forbidViewAttachForumIds']) || in_array($attach['aid'], $attachIds)) {
             continue;
         }
         $imageItem = array();
         $thumbWidth = '100';
         $thumbHeight = '100';
         $bigWidth = '400';
         $bigHeight = '400';
         $thumbImageURL = $_G['siteurl'] . getforumimg($aid, 1, $thumbWidth, $thumbHeight, 'fixwr');
         $bigImageURL = $_G['siteurl'] . getforumimg($aid, 1, $bigWidth, $bigHeight, 'fixnone');
         $imageItem['aid'] = $aid;
         $imageItem['thumb'] = $thumbImageURL;
         $imageItem['big'] = $bigImageURL;
         if ($attach['remote']) {
             $imageItem['path'] = $_G['setting']['ftp']['attachurl'] . 'forum/' . $attach['attachment'];
             $imageItem['remote'] = true;
         } else {
             $imageItem['path'] = $_G['setting']['attachdir'] . 'forum/' . $attach['attachment'];
         }
         $attachIds[] = $aid;
         $attachImages[] = $imageItem;
     }
     $content = preg_replace('/\\[attach\\](\\d+)\\[\\/attach\\]/ie', '$this->connectParseAttachTag(\\1, $attachNames)', $content);
     return $content;
 }
</td>
</tr>
<tr class="dopt">
<td>&nbsp;</td>
<td>
<label class="labeltxt">&nbsp;</label>
<img id="selectimg" src="<?php 
                echo STATICURL;
                ?>
image/common/none.gif"  width="120" height="80" />
<script type="text/javascript" reload="1">
var imgk = new Array();<?php 
                if (is_array($imgattach)) {
                    foreach ($imgattach as $imginfo) {
                        $a = '\\"\'\\t\\""\\\'' . "\\\\";
                        $k = getforumimg($imginfo['aid'], 1, 120, 80);
                        ?>
imgk[<?php 
                        echo $imginfo['aid'];
                        ?>
] = '<?php 
                        echo $k;
                        ?>
';
<?php 
                    }
                }
                ?>
function updateimginfo(aid) {
if(aid) {
$('selectimg').src=imgk[aid];
<?php if(!defined('IN_DISCUZ')) exit('Access Denied'); if($imagelist) { if($_GET['type'] != 'single') { $i = 0;?><table cellspacing="2" cellpadding="2" class="imgl"><tr>
<?php } if(is_array($imagelist)) foreach($imagelist as $image) { $i++;?><?php if($_GET['type'] != 'single') { ?>
<td valign="bottom" id="image_td_<?php echo $image['aid'];?>" width="25%">
<?php } ?>
<a href="javascript:;" title="<?php echo $image['filename'];?>" id="imageattach<?php echo $image['aid'];?>"><img src="<?php echo getforumimg($image['aid'], 1, 300, 300, 'fixnone'); ?>" id="image_<?php echo $image['aid'];?>" onclick="insertAttachimgTag('<?php echo $image['aid'];?>');doane(event);" width="<?php if($image['width'] < 110) { ?><?php echo $image['width'];?><?php } else { ?>110<?php } ?>" cwidth="<?php if($image['width'] < 300) { ?><?php echo $image['width'];?><?php } else { ?>300<?php } ?>" /></a>
<p class="mtn mbn xi2">
<?php if($attach['pid']) { ?>
<input type="hidden" name="attachupdate[<?php echo $image['aid'];?>]" id="attachupdate<?php echo $image['aid'];?>" size="2" />&nbsp;
<a href="javascript:;" onclick="uploadWindow(function (aid, url, name){$('attachupdate<?php echo $image['aid'];?>').value = aid;ajaxget('forum.php?mod=ajax&action=getimage&aid=' + aid, 'imageattach<?php echo $image['aid'];?>');}, 'image');return false;">更新</a>
<span class="pipe">|</span>
<?php } ?>
<a href="javascript:;" onclick="delImgAttach(<?php echo $image['aid'];?>,<?php if(!$attach['pid']) { ?>1<?php } else { ?>0<?php } ?>);return false;">删除</a>
</p>
<p class="imgf">
<?php if($image['description']) { ?>
<input type="text" name="attachnew[<?php echo $image['aid'];?>][description]" class="px xg2" value="<?php echo $image['description'];?>" id="image_desc_<?php echo $image['aid'];?>" />
<?php } else { ?>
<input type="text" class="px xg2" value="描述" onclick="this.style.display='none';$('image_desc_<?php echo $image['aid'];?>').style.display='';$('image_desc_<?php echo $image['aid'];?>').focus();" />
<input type="text" name="attachnew[<?php echo $image['aid'];?>][description]" class="px" style="display: none" id="image_desc_<?php echo $image['aid'];?>" />
<?php } ?>
</p>
<?php if(helper_access::check_module('album') && $_G['group']['allowupload']) { ?>
<p class="mtn"><?php if(!$attach['pid']) { ?><input type="hidden" class="pc" id="albumaid_<?php echo $image['aid'];?>" name="albumaid[]" value="" /><label for="albumaidchk_<?php echo $image['aid'];?>"><input id="albumaidchk_<?php echo $image['aid'];?>" type="checkbox" class="pc" onclick="$('albumaid_<?php echo $image['aid'];?>').value=this.checked?this.value:''" value="<?php echo $image['aid'];?>" />保存到相册</label><?php } ?></p>
<?php } ?>
</td>
<?php if($_GET['type'] != 'single' && $i % 4 == 0 && isset($imagelist[$i])) { ?></tr><tr><?php } } if($_GET['type'] != 'single') { if(($imgpad = $i % 4) > 0) { echo str_repeat('<td width="25%"></td>', 4 - $imgpad);; } ?>
</tr></table>
<?php } if($_G['inajax']) { ?>
<script type="text/javascript" reload="1">
ATTACHNUM['imageunused'] += <?php echo count($imagelist); ?>;
updateattachnum('image');
function attachinpost($attach) {
global $_G;
$attach['refcheck'] = (!$attach['remote'] && $_G['setting']['attachrefcheck']) || ($attach['remote'] && ($_G['setting']['ftp']['hideurl'] || ($attach['isimage'] && $_G['setting']['attachimgpost'] && strtolower(substr($_G['setting']['ftp']['attachurl'], 0, 3)) == 'ftp')));
$mobilethumburl = $attach['attachimg'] && $_G['setting']['showimages'] && (!$attach['price'] || $attach['payed']) && ($_G['group']['allowgetimage'] || $_G['uid'] == $attach['uid']) ? getforumimg($attach['aid'], 0, 200, 200, 'fixnone') : '' ;
$aidencode = packaids($attach);
$is_archive = $_G['forum_thread']['is_archived'] ? '&fid='.$_G['fid'].'&archiveid='.$_G[forum_thread][archiveid] : '';?><?php
$return = <<<EOF


EOF;
 if($attach['attachimg'] && $_G['setting']['showimages'] && (!$attach['price'] || $attach['payed']) && ($_G['group']['allowgetimage'] || $_G['uid'] == $attach['uid'])) { 
$return .= <<<EOF

<a href="
EOF;
 if($attach['refcheck']) { 
$return .= <<<EOF
forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes&nothumb=yes
EOF;
 } else { 
$return .= <<<EOF
{$attach['url']}{$attach['attachment']}
EOF;
 } 
$return .= <<<EOF
"><img id="aimg_{$attach['aid']}" src="{$mobilethumburl}" alt="{$attach['imgalt']}" title="{$attach['imgalt']}"/></a>

EOF;
 } else { 
$return .= <<<EOF

<div id="attach_{$attach['aid']}" class="box attach mbn" >

EOF;
 if($_G['setting']['mobile']['mobilesimpletype'] == 0) { 
$return .= <<<EOF

{$attach['attachicon']}

EOF;
 } if(!$attach['price'] || $attach['payed']) { 
$return .= <<<EOF

<a href="forum.php?mod=attachment{$is_archive}&amp;aid={$aidencode}" target="_blank">{$attach['filename']}</a>

EOF;
 } else { 
$return .= <<<EOF

<a href="forum.php?mod=misc&amp;action=attachpay&amp;aid={$attach['aid']}&amp;tid={$attach['tid']}" target="_blank">{$attach['filename']}</a>

EOF;
 } 
$return .= <<<EOF

<em class="xg1">({$attach['attachsize']})</em>
<em class="xg1"><br />(下载次数: {$attach['downloads']}, {$attach['dateline']} 上传)
</em>

EOF;
 if($attach['price']) { 
$return .= <<<EOF

<p class="xg1">售价: {$attach['price']} {$_G['setting']['extcredits'][$_G['setting']['creditstransextra']['1']]['unit']}{$_G['setting']['extcredits'][$_G['setting']['creditstransextra']['1']]['title']}&nbsp;<a href="forum.php?mod=misc&amp;action=viewattachpayments&amp;aid={$attach['aid']}">[记录]</a>

EOF;
 if(!$attach['payed']) { 
$return .= <<<EOF

&nbsp;[<a href="forum.php?mod=misc&amp;action=attachpay&amp;aid={$attach['aid']}&amp;tid={$attach['tid']}" target="_blank">购买</a>]

EOF;
 } 
$return .= <<<EOF

</p>

EOF;
 } if(!$attach['attachimg'] && $_G['getattachcredits']) { 
$return .= <<<EOF
<p>下载积分: {$_G['getattachcredits']}</p>
EOF;
 } 
$return .= <<<EOF

</div>

EOF;
 } 
$return .= <<<EOF


EOF;
?><?php return $return;?><?php }?>
Beispiel #23
0
 function getthread($tid, $messagelength = 80, $nospecial = false)
 {
     global $_G;
     if (!$tid) {
         return '';
     }
     require_once libfile('function/post');
     if (empty($_G['thread'][$tid])) {
         $thread = DB::fetch_first("SELECT subject, fid, special, price, posttableid FROM " . DB::table('forum_thread') . " WHERE tid='{$tid}'");
         $_G['thread'][$tid] = $thread;
     } else {
         $thread = $_G['thread'][$tid];
     }
     if ($thread['posttableid'] == 0) {
         $posttable = 'forum_post';
     } else {
         $posttable = "forum_post_{$thread['posttableid']}";
     }
     $fid = $thread['fid'];
     if ($nospecial) {
         $thread['special'] = 0;
     }
     if ($thread['special'] == 1) {
         $multiple = DB::result_first("SELECT multiple FROM " . DB::table('forum_poll') . " WHERE tid='{$tid}'");
         $optiontype = $multiple ? 'checkbox' : 'radio';
         $query = DB::query("SELECT polloptionid, polloption FROM " . DB::table('forum_polloption') . " WHERE tid='{$tid}' ORDER BY displayorder");
         while ($polloption = DB::fetch($query)) {
             $polloption['polloption'] = preg_replace("/\\[url=(https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:\\/\\/([^\\[\"']+?)\\](.+?)\\[\\/url\\]/i", "<a href=\"\\1://\\2\" target=\"_blank\">\\3</a>", $polloption['polloption']);
             $polloptions[] = $polloption;
         }
     } elseif ($thread['special'] == 2) {
         $trade = DB::fetch_first("SELECT subject, price, credit, aid, pid FROM " . DB::table('forum_trade') . " WHERE tid='{$tid}' ORDER BY displayorder DESC LIMIT 1");
         $trade['aid'] = $trade['aid'] ? getforumimg($trade['aid']) : '';
         $trades[] = $trade;
     } elseif ($thread['special'] == 3) {
         $extcredits = $_G['settings']['extcredits'];
         $creditstransextra = $_G['settings']['creditstransextra'];
         $rewardend = $thread['price'] < 0;
         $rewardprice = abs($thread['price']);
         $message = messagecutstr(DB::result_first("SELECT message FROM " . DB::table($posttable) . " WHERE tid='{$tid}' AND first=1"), $messagelength);
     } elseif ($thread['special'] == 4) {
         $message = messagecutstr(DB::result_first("SELECT message FROM " . DB::table($posttable) . " WHERE tid='{$tid}' AND first=1"), $messagelength);
         $activity = DB::fetch_first("SELECT aid, number, applynumber FROM " . DB::table('forum_activity') . " WHERE tid='{$tid}'");
         $activity['aid'] = $activity['aid'] ? getforumimg($activity['aid']) : '';
         $activity['aboutmember'] = $activity['number'] - $activity['applynumber'];
     } elseif ($thread['special'] == 5) {
         $message = messagecutstr(DB::result_first("SELECT message FROM " . DB::table($posttable) . " WHERE tid='{$tid}' AND first=1"), $messagelength);
         $debate = DB::fetch_first("SELECT affirmdebaters, negadebaters, affirmvotes, negavotes, affirmpoint, negapoint FROM " . DB::table('forum_debate') . " WHERE tid='{$tid}'");
         $debate['affirmvoteswidth'] = $debate['affirmvotes'] ? intval(80 * (($debate['affirmvotes'] + 1) / ($debate['affirmvotes'] + $debate['negavotes'] + 1))) : 1;
         $debate['negavoteswidth'] = $debate['negavotes'] ? intval(80 * (($debate['negavotes'] + 1) / ($debate['affirmvotes'] + $debate['negavotes'] + 1))) : 1;
         @(require_once libfile('function/discuzcode'));
         $debate['affirmpoint'] = discuzcode($debate['affirmpoint'], 0, 0, 0, 1, 1, 0, 0, 0, 0, 0);
         $debate['negapoint'] = discuzcode($debate['negapoint'], 0, 0, 0, 1, 1, 0, 0, 0, 0, 0);
     } else {
         $message = messagecutstr(DB::result_first("SELECT message FROM " . DB::table($posttable) . " WHERE tid='{$tid}' AND first=1"), $messagelength);
     }
     include template('common/block_thread');
     return $return;
 }
                ?>
<td valign="bottom" id="image_td_<?php 
                echo $image['aid'];
                ?>
" width="25%">
<?php 
            }
            ?>
<a href="javascript:;" title="<?php 
            echo $image['filename'];
            ?>
" id="imageattach<?php 
            echo $image['aid'];
            ?>
"><img src="<?php 
            echo getforumimg($image['aid'], 1, 300, 300, 'fixnone');
            ?>
" id="image_<?php 
            echo $image['aid'];
            ?>
" onclick="insertAttachimgTag('<?php 
            echo $image['aid'];
            ?>
');doane(event);" width="<?php 
            if ($image['width'] < 110) {
                echo $image['width'];
            } else {
                ?>
110<?php 
            }
            ?>
Beispiel #25
0
            if ($_G['forum']['threadtypes']['moderators'][$typeid] && $_G['forum'] && !$_G['forum']['ismoderator']) {
                continue;
            }
            echo '<option value="' . $typeid . '">' . $typename . '</option>';
        }
    } else {
        echo '<option value="0" /></option>';
    }
    echo '</select>';
    include template('common/footer_ajax');
} elseif ($_GET['action'] == 'getimage') {
    $_GET['aid'] = intval($_GET['aid']);
    $image = C::t('forum_attachment_n')->fetch('aid:' . $_GET['aid'], $_GET['aid'], 1);
    include template('common/header_ajax');
    if ($image['aid']) {
        echo '<img src="' . getforumimg($image['aid'], 1, 300, 300, 'fixnone') . '" id="image_' . $image['aid'] . '" onclick="insertAttachimgTag(\'' . $image['aid'] . '\')" width="' . ($image['width'] < 110 ? $image['width'] : 110) . '" cwidth="' . ($image['width'] < 300 ? $image['width'] : 300) . '" />';
    }
    include template('common/footer_ajax');
    dexit();
} elseif ($_GET['action'] == 'setthreadcover') {
    $aid = intval($_GET['aid']);
    $imgurl = $_GET['imgurl'];
    require_once libfile('function/post');
    if ($_G['forum'] && ($aid || $imgurl)) {
        if ($imgurl) {
            $tid = intval($_GET['tid']);
            $pid = intval($_GET['pid']);
        } else {
            $threadimage = C::t('forum_attachment_n')->fetch('aid:' . $aid, $aid);
            $tid = $threadimage['tid'];
            $pid = $threadimage['pid'];
 public function replyfeed()
 {
     if (!$this->feed) {
         if ($this->forum['allowfeed'] && !$this->param['isanonymous']) {
             if ($this->thread['authorid'] != $this->member['uid']) {
                 $post_url = "forum.php?mod=redirect&goto=findpost&pid=" . $this->pid . "&ptid=" . $this->thread['tid'];
                 $this->feed['icon'] = 'post';
                 $this->feed['title_template'] = !empty($this->thread['author']) ? 'feed_reply_title' : 'feed_reply_title_anonymous';
                 $this->feed['title_data'] = array('subject' => "<a href=\"{$post_url}\">" . $this->thread['subject'] . "</a>", 'author' => "<a href=\"home.php?mod=space&uid=" . $this->thread['authorid'] . "\">" . $this->thread['author'] . "</a>");
                 $forum_attachexist = getglobal('forum_attachexist');
                 if (!empty($forum_attachexist)) {
                     $imgattach = C::t('forum_attachment_n')->fetch_max_image('tid:' . $this->thread['tid'], 'pid', $this->pid);
                     $firstaid = $imgattach['aid'];
                     unset($imgattach);
                     if ($firstaid) {
                         $this->feed['images'] = array(getforumimg($firstaid));
                         $this->feed['image_links'] = array($post_url);
                     }
                 }
             }
         }
     }
     $this->feed['title_data']['hash_data'] = "tid" . $this->thread['tid'];
     $this->feed['id'] = $this->pid;
     $this->feed['idtype'] = 'pid';
     if ($this->feed['icon']) {
         postfeed($this->feed);
     }
 }
 function _viewthread_share_method_output()
 {
     global $_G, $postlist, $canonical;
     $needFeedStatus = getstatus($_G['forum_thread']['status'], 7);
     $needWeiboStatus = getstatus($_G['forum_thread']['status'], 8);
     $_G['connect']['thread_url'] = $_G['siteurl'] . $canonical;
     $connectService = Cloud::loadClass('Service_Connect');
     $_G['connect']['qzone_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=1&thread_id=' . $_G['tid'];
     $_G['connect']['weibo_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=2&thread_id=' . $_G['tid'];
     $_G['connect']['pengyou_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=3&thread_id=' . $_G['tid'];
     $_G['connect']['qq_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=4&thread_id=' . $_G['tid'];
     $_G['connect']['first_post'] = $postlist[$_G['forum_firstpid']];
     if ($_G['connect']['first_post']['anonymous']) {
         $_G['connect']['first_post']['authorid'] = 0;
         $_G['connect']['first_post']['author'] = '';
     }
     $_GET['connect_autoshare'] = !empty($_GET['connect_autoshare']) ? 1 : 0;
     $_G['connect']['weibo_appkey'] = $_G['connect']['weibo_public_appkey'];
     if ($this->allow && $_G['setting']['connect']['qshare_appkey']) {
         $_G['connect']['weibo_appkey'] = $_G['setting']['connect']['qshare_appkey'];
     }
     $condition1 = $_G['uid'] != $_G['forum_thread']['authorid'] || !$_G['member']['conopenid'];
     $condition2 = $_G['forum_thread']['displayorder'] < 0;
     $condition3 = $_G['timestamp'] - $_G['forum_thread']['dateline'] > $this->retryAvaiableTime;
     if ($condition1 || $condition2 || $condition3) {
         $needFeedStatus = $needWeiboStatus = false;
     }
     if ($_G['group']['allowgetimage'] && $_G['thread']['price'] == 0) {
         if (trim($_G['forum']['viewperm'])) {
             $allowViewPermGroupIds = explode("\t", trim($_G['forum']['viewperm']));
         }
         if (trim($_G['forum']['getattachperm'])) {
             $allowViewAttachGroupIds = explode("\t", trim($_G['forum']['getattachperm']));
         }
         $bigWidth = '400';
         $bigHeight = '400';
         $share_images = array();
         foreach ($_G['connect']['first_post']['attachments'] as $attachment) {
             if ($attachment['isimage'] == 0 || $attachment['price'] > 0 || $attachment['readperm'] > $_G['group']['readaccess'] || $allowViewPermGroupIds && !in_array($_G['groupid'], $allowViewPermGroupIds) || $allowViewAttachGroupIds && !in_array($_G['groupid'], $allowViewAttachGroupIds)) {
                 continue;
             }
             $bigImageURL = $_G['siteurl'] . getforumimg($attachment['aid'], 1, $bigWidth, $bigHeight, 'fixnone');
             $share_images[] = urlencode($bigImageURL);
         }
         $_G['connect']['share_images'] = implode('|', $share_images);
     }
     if (!$needFeedStatus && !$needWeiboStatus) {
         return tpl_viewthread_share_method($jsurl);
     }
     if ($_G['page'] == 1 && $_G['forum_firstpid'] && $postlist[$_G['forum_firstpid']]['invisible'] == 0) {
         $feedLog = C::t('#qqconnect#connect_feedlog')->fetch_by_tid($_G['tid']);
         if ($feedLog['publishtimes'] >= $this->retryMax) {
             return tpl_viewthread_share_method($jsurl);
         }
         $hadFeedStatus = getstatus($feedLog['status'], 2);
         $hadWeiboStatus = getstatus($feedLog['status'], 4);
         if (!$hadFeedStatus || !$hadWeiboStatus) {
             if ($needFeedStatus && !$hadFeedStatus) {
                 if ($_G['timestamp'] - $feedLog['lastpublished'] < 60) {
                     $needFeedStatus = false;
                 }
             } else {
                 $needFeedStatus = false;
             }
             if ($needWeiboStatus && !$hadWeiboStatus) {
                 if ($_G['timestamp'] - $feedLog['lastpublished'] < 60) {
                     $needWeiboStatus = false;
                 }
             } else {
                 $needWeiboStatus = false;
             }
         }
         $jsurl = '';
         if ($needFeedStatus || $needWeiboStatus) {
             $params = array();
             $params['thread_id'] = $_G['tid'];
             $params['ts'] = TIMESTAMP;
             $params['type'] = bindec(($needWeiboStatus ? '1' : '0') . ($needFeedStatus ? '1' : '0'));
             $params['sig'] = $connectService->connectGetSig($params, $connectService->connectGetSigKey());
             $utilService = Cloud::loadClass('Service_Util');
             $jsurl = $_G['connect']['discuz_new_feed_url'] . '&' . $utilService->httpBuildQuery($params, '', '&');
         }
         $connectService->connectMergeMember();
         return tpl_viewthread_share_method($jsurl);
     }
 }
Beispiel #28
0
 $feed = array();
 if (!empty($_GET['addfeed']) && $_G['forum']['allowfeed'] && !$isanonymous) {
     $feed['icon'] = 'goods';
     $feed['title_template'] = 'feed_thread_goods_title';
     if ($_GET['item_price'] > 0) {
         if ($_G['setting']['creditstransextra'][5] != -1 && $_GET['item_credit']) {
             $feed['body_template'] = 'feed_thread_goods_message_1';
         } else {
             $feed['body_template'] = 'feed_thread_goods_message_2';
         }
     } else {
         $feed['body_template'] = 'feed_thread_goods_message_3';
     }
     $feed['body_data'] = array('itemname' => "<a href=\"forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}\">{$_GET['item_name']}</a>", 'itemprice' => $_GET['item_price'], 'itemcredit' => $_GET['item_credit'], 'creditunit' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][5]]['unit'] . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][5]]['title']);
     if ($_GET['tradeaid']) {
         $feed['images'] = array(getforumimg($_GET['tradeaid']));
         $feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}");
     }
     if ($_GET['tradeaid']) {
         $attachment = C::t('forum_attachment_n')->fetch('tid:' . $tid, $_GET['tradeaid']);
         if (in_array($attachment['filetype'], array('image/gif', 'image/jpeg', 'image/png'))) {
             $imgurl = $_G['setting']['attachurl'] . 'forum/' . ($attachment['thumb'] && $attachment['filetype'] != 'image/gif' ? getimgthumbname($attachment['attachment']) : $attachment['attachment']);
             $feed['images'][] = $attachment['attachment'] ? $imgurl : '';
             $feed['image_links'][] = $attachment['attachment'] ? "forum.php?mod=viewthread&tid={$tid}" : '';
         }
     }
     $feed['title_data']['hash_data'] = "tid{$tid}";
     $feed['id'] = $tid;
     $feed['idtype'] = 'tid';
     postfeed($feed);
 }
 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);
         }
     }
 }
Beispiel #30
0
function article_move_forums($arr, $old_arr)
{
    global $_G;
    $arr['content'] = preg_replace(array('/<center>([\\s\\S]*?)<\\/center>/', '/\\s(?=\\s)/'), array("[align=center]\\1[/align]", ''), $arr['content']);
    $subject = addslashes(trim($arr['title']));
    if ($arr['check']) {
        if (!strlen($subject)) {
            return FALSE;
        }
        $num = DB::result_first('SELECT COUNT(*) FROM ' . DB::table('forum_thread') . " WHERE subject='{$subject}' AND displayorder > '-1'");
        if ($num) {
            return FALSE;
        }
    }
    if ($arr['contents'] > 1 && $arr['is_content_reply'] != 1) {
        $arr['reply'] = array();
    }
    $time_arr = create_public_time($arr, count($arr['reply']) + 1, 1);
    if ($arr['contents'] == 1) {
        $uid_arr = get_rand_uid($arr, 'reply');
    } else {
        if ($arr['is_content_reply'] != 1) {
            if ($arr['content_arr']) {
                $arr['content'] = content_merge($arr['content_arr']);
            }
            $uid_arr = get_rand_uid($arr);
        }
    }
    $arr['public_time'] = $arr['public_time'] ? $arr['public_time'] : array_shift($time_arr);
    require_once libfile('function/editor');
    require_once libfile('function/forum');
    $subject = htmlspecialchars_decode(format_html($subject));
    $subject = htmlspecialchars_decode(format_html($subject));
    $arr['content'] = dstripslashes($arr['content']);
    $arr['content'] = img_htmlbbcode($arr['content'], $arr['page_url']);
    $arr['content'] = media_htmlbbcode($arr['content'], $arr['page_url']);
    $arr['content'] = audio_htmlbbcode($arr['content'], $arr['page_url']);
    $message = htmlspecialchars_decode(html2bbcode($arr['content']));
    $message = dstripslashes(format_html($message));
    $arr['fid'] = $_G['fid'] = $_GET['forums'] ? $_GET['forums'] : $arr['forum_fid'];
    $_G['uid'] = $arr['uid'] ? $arr['uid'] : $_G['uid'];
    $view_num = $arr['view_num'];
    require_once libfile('function/post');
    $special = 0;
    if (trim($subject) == '' || trim($message) == '') {
        return -1;
    }
    if (!$sortid && !$special && trim($message) == '') {
        return -1;
    }
    $_GET['save'] = $arr['uid'] ? $arr['uid'] : $_G['uid'];
    $uid = $_GET['save'];
    $typeid = intval($_GET['threadtypeid']) ? intval($_GET['threadtypeid']) : $arr['forum_typeid'];
    $displayorder = 0;
    $digest = $_G['forum']['ismoderator'] && $_G['group']['allowdigestthread'] && !empty($_GET['addtodigest']) ? 1 : 0;
    $readperm = $_G['group']['allowsetreadperm'] ? $readperm : 0;
    $isanonymous = $_G['group']['allowanonymous'] && $_GET['isanonymous'] ? 1 : 0;
    $price = intval($price);
    $price = $_G['group']['maxprice'] && !$special ? $price <= $_G['group']['maxprice'] ? $price : $_G['group']['maxprice'] : 0;
    if (!$typeid && $_G['forum']['threadtypes']['required'] && !$special) {
        return -2;
    }
    if (!$sortid && $_G['forum']['threadsorts']['required'] && !$special) {
        return -3;
    }
    if ($price > 0 && floor($price * (1 - $_G['setting']['creditstax'])) == 0) {
        return -4;
    }
    $_G['forum'] = DB::fetch_first("SELECT * FROM " . DB::table('forum_forum') . " WHERE fid = '{$arr['fid']}'");
    //查询版块信息
    if (!$_G['forum']) {
        return -5;
    }
    $sortid = $special && $_G['forum']['threadsorts']['types'][$sortid] ? 0 : $sortid;
    $typeexpiration = intval($_GET['typeexpiration']);
    if ($_G['forum']['threadsorts']['expiration'][$typeid] && !$typeexpiration) {
        return -5;
    }
    $_G['forum_optiondata'] = array();
    if ($_G['forum']['threadsorts']['types'][$sortid] && !$_G['forum']['allowspecialonly']) {
        $_G['forum_optiondata'] = threadsort_validator($_GET['typeoption'], $pid);
    }
    $author = !$arr['username'] ? $_G['username'] : $arr['username'];
    $moderated = $digest || $displayorder > 0 ? 1 : 0;
    $thread['status'] = 0;
    $_GET['ordertype'] && ($thread['status'] = setstatus(4, 1, $thread['status']));
    $_GET['hiddenreplies'] && ($thread['status'] = setstatus(2, 1, $thread['status']));
    $_GET['allownoticeauthor'] && ($thread['status'] = setstatus(6, 1, $thread['status']));
    $isgroup = $_G['forum']['status'] == 3 ? 1 : 0;
    //检查各项设置
    $bbcodeoff = checkbbcodes($message, FALSE);
    $smileyoff = checksmilies($message, FALSE);
    $parseurloff = FALSE;
    $htmlon = $_G['group']['allowhtml'] && !empty($_GET['htmlon']) ? 1 : 0;
    if ($_G['group']['allowreplycredit']) {
        $_GET['replycredit_extcredits'] = intval($_GET['replycredit_extcredits']);
        $_GET['replycredit_times'] = intval($_GET['replycredit_times']);
        $_GET['replycredit_membertimes'] = intval($_GET['replycredit_membertimes']);
        $_GET['replycredit_random'] = intval($_GET['replycredit_random']);
        $_GET['replycredit_random'] = $_GET['replycredit_random'] < 0 || $_GET['replycredit_random'] > 99 ? 0 : $_GET['replycredit_random'];
        $replycredit = $replycredit_real = 0;
    }
    if ($old_arr['forum_id']) {
        $info = DB::fetch_first("SELECT p.pid,p.tid,t.tid,p.first FROM " . DB::table('forum_post') . " p Inner Join " . DB::table('forum_thread') . " t  ON p.tid = t.tid WHERE p.first = '1' AND t.tid='" . $old_arr['forum_id'] . "' AND t.displayorder > '-1'");
    }
    $reply_count = count($arr['reply']);
    $view_num = $view_num < $reply_count - 1 ? rand($reply_count * 2, $reply_count * 10) : $view_num;
    if ($info['tid']) {
        //更新
        DB::query("UPDATE " . DB::table('forum_thread') . " SET typeid='{$typeid}', author='{$author}', authorid='{$uid}', subject='{$subject}', dateline='{$arr['public_time']}', lastpost='{$arr['public_time']}', fid='{$arr['fid']}', lastposter='{$author}', views='{$view_num}', attachment='0' WHERE tid='{$info['tid']}'", 'UNBUFFERED');
        $tid = $info['tid'];
    } else {
        //添加
        DB::query("INSERT INTO " . DB::table('forum_thread') . " (fid, posttableid, readperm, price, typeid, sortid, author, authorid, subject, dateline, lastpost, lastposter, views, displayorder, digest, special, attachment, moderated, status, isgroup, replycredit, closed)\r\n\t\t\tVALUES ('{$_G['fid']}', '0', '{$readperm}', '{$price}', '{$typeid}', '{$sortid}', '{$author}', '{$_G['uid']}', '{$subject}', '{$arr['public_time']}', '{$arr['public_time']}', '{$author}', '{$view_num}', '{$displayorder}', '{$digest}', '{$special}', '0', '{$moderated}', '32', '{$isgroup}', '{$replycredit}', '" . ($closed ? "1" : '0') . "')");
        $tid = DB::insert_id();
        useractionlog($uid, 'tid');
    }
    DB::update('common_member_field_home', array('recentnote' => $subject), array('uid' => $uid));
    if ($moderated) {
        updatemodlog($tid, $displayorder > 0 ? 'STK' : 'DIG');
        updatemodworks($displayorder > 0 ? 'STK' : 'DIG', 1);
    }
    if (DISCUZ_VERSION == 'X2') {
        //2.0版本
        $tagstr = addthreadtag($arr['article_tag'], $tid);
    } else {
        $class_tag = new tag();
        $tagstr = $class_tag->add_tag($arr['article_tag'], $tid, 'tid');
    }
    if ($_G['group']['allowreplycredit']) {
        if ($replycredit > 0 && $replycredit_real > 0) {
            updatemembercount($_G['uid'], array('extcredits' . $_G['setting']['creditstransextra'][10] => -$replycredit_real), 1, 'RCT', $tid);
            DB::query("INSERT INTO " . DB::table('forum_replycredit') . " (tid, extcredits, extcreditstype, times, membertimes, random)VALUES('{$tid}', '{$_G['gp_replycredit_extcredits']}', '{$_G[setting][creditstransextra][10]}', '{$_G['gp_replycredit_times']}', '{$_G['gp_replycredit_membertimes']}', '{$_G['gp_replycredit_random']}')");
        }
    }
    if ($_G['group']['allowpostrushreply'] && $_GET['rushreply']) {
        DB::query("INSERT INTO " . DB::table('forum_threadrush') . " (tid, stopfloor, starttimefrom, starttimeto, rewardfloor) VALUES ('{$tid}', '{$_G['gp_stopfloor']}', '{$_G['gp_rushreplyfrom']}', '{$_G['gp_rushreplyto']}', '{$_G['gp_rewardfloor']}')");
    }
    $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message);
    $post_setarr = array('fid' => $arr['fid'], 'tid' => $tid, 'first' => '1', 'author' => $author, 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $arr['public_time'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => 0, 'anonymous' => $isanonymous, 'usesig' => 1, 'htmlon' => $htmlon, 'bbcodeoff' => $bbcodeoff, 'smileyoff' => $smileyoff, 'parseurloff' => $parseurloff, 'attachment' => '0', 'replycredit' => 0, 'status' => defined('IN_MOBILE') ? 8 : 0);
    if (DISCUZ_VERSION != 'X2') {
        //2.5版本 2.5版本多了一个position字段
        $post_setarr['position'] = 1;
        $post_setarr = dstripslashes($post_setarr);
    } else {
        $post_setarr = daddslashes($post_setarr);
    }
    $post_setarr['tags'] = $tagstr;
    $replys = 0;
    if ($info['tid']) {
        //更新
        //发布时间要做更改
        $new_post_arr = DB::fetch_first("SELECT dateline FROM " . DB::table('forum_post') . " WHERE tid='{$tid}' ORDER BY dateline ASC limit 1");
        $post_setarr['dateline'] = $new_post_arr['dateline'] - 3600;
        DB::update('forum_post', $post_setarr, array('pid' => $info['pid']));
        $pid = $info['pid'];
    } else {
        $pid = insertpost($post_setarr);
        $post_setarr = array();
        //发布回复
        if ($arr['is_public_reply'] == 1 && $arr['reply'] || $arr['is_content_reply'] == 1) {
            //是否开启发布回复
            if ($arr['is_content_reply'] == 1) {
                $uid_arr = $time_arr = array();
            }
            $reply_arr = $arr['reply'];
            $replys = count($reply_arr);
            if ($arr['public_reply_seq'] == 1) {
                shuffle($reply_arr);
            }
            foreach ((array) $reply_arr as $k => $v) {
                $message = dstripslashes($v['content']);
                $message = media_htmlbbcode($message, $arr['page_url']);
                $message = img_htmlbbcode($message, $arr['page_url']);
                $message = htmlspecialchars_decode(html2bbcode($message));
                //print_r($v['content']);exit();
                if (!$message || strlen($message) < 2) {
                    continue;
                }
                $post_setarr = array('fid' => $arr['fid'], 'tid' => $tid, 'first' => '0', 'author' => $uid_arr[$k]['username'] ? $uid_arr[$k]['username'] : $arr['username'], 'authorid' => $uid_arr[$k]['uid'] ? $uid_arr[$k]['uid'] : $arr['uid'], 'subject' => '', 'dateline' => $time_arr[$k] ? $time_arr[$k] : $arr['public_time'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => 0, 'anonymous' => $_G['group']['allowanonymous'] && !empty($_GET['isanonymous']) ? 1 : 0, 'usesig' => 1, 'htmlon' => $_G['group']['allowhtml'] && !empty($_GET['htmlon']) ? 1 : 0, 'bbcodeoff' => checkbbcodes($message, !empty($_GET['bbcodeoff'])), 'smileyoff' => checksmilies($message, !empty($_GET['smileyoff'])), 'parseurloff' => !empty($_GET['parseurloff']), 'attachment' => '0', 'tags' => 0, 'replycredit' => 0, 'status' => defined('IN_MOBILE') ? 8 : 0);
                $lastpost = $post_setarr['dateline'];
                $lastposter = $post_setarr['author'];
                if (DISCUZ_VERSION != 'X2') {
                    //2.5版本 2.5版本多了一个position字段
                    $post_setarr['position'] = $k + 2;
                    $post_setarr = dstripslashes($post_setarr);
                } else {
                    $post_setarr = daddslashes($post_setarr);
                }
                $reply_pid = insertpost($post_setarr);
                $v['tid'] = $tid;
                $v['pid'] = $reply_pid;
                $v['is_post'] = 1;
                //标识是回复
                $v['cookie'] = $arr['cookie'];
                $v['is_water_img'] = $arr['is_water_img'];
                $v['is_download_img'] = $arr['is_download_img'];
                $v['is_download_file'] = $arr['is_download_file'];
                $forum_arr['tid'] = $tid;
                $forum_arr['pid'] = $reply_pid;
                $forum_arr['is_post'] = 1;
                //标识是回复
                $forum_arr['cookie'] = $arr['cookie'];
                $forum_arr['is_water_img'] = $arr['is_water_img'];
                $forum_arr['is_download_img'] = $arr['is_download_img'];
                $forum_arr['content'] = $v['content'];
                //$re_arr = forum_downremotefile($forum_arr);
                if ($arr['is_download_img'] == 1) {
                    $re_arr = forum_downremotefile($v);
                }
                DB::query("UPDATE " . DB::table('common_member_count') . " SET posts=posts+1 WHERE uid='{$post_setarr['authorid']}'");
                //更新数
                $new[$k] = $post_setarr;
            }
            unset($post_setarr);
            DB::update('forum_thread', array('replies' => count($reply_arr), 'lastpost' => $lastpost, 'lastposter' => $lastposter), array('tid' => $tid));
        }
    }
    //exit();
    $re = $arr;
    $re['fid'] = $fid;
    $re['tid'] = $tid;
    $re['fid'] = $fid;
    $re['uid'] = $arr['uid'];
    $re['username'] = $author;
    $re['pid'] = $pid;
    $re['message'] = $message;
    if ($pid && getstatus($thread['status'], 1)) {
        savepostposition($tid, $pid);
    }
    $threadimageaid = 0;
    $threadimage = array();
    //print_r($message);exit();
    if ($_G['forum']['threadsorts']['types'][$sortid] && !empty($_G['forum_optiondata']) && is_array($_G['forum_optiondata']) && $sortaids) {
        foreach ($sortaids as $sortaid) {
            convertunusedattach($sortaid, $tid, $pid);
        }
    }
    if (($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) && ($_GET['attachnew'] || $sortid || !empty($_GET['activityaid']))) {
        updateattach($displayorder == -4 || $modnewthreads, $tid, $pid, $_GET['attachnew']);
        if (!$threadimageaid) {
            $threadimage = DB::fetch_first("SELECT aid, attachment, remote FROM " . DB::table(getattachtablebytid($tid)) . " WHERE tid='{$tid}' AND isimage IN ('1', '-1') ORDER BY width DESC LIMIT 1");
            $threadimageaid = $threadimage['aid'];
        }
        if ($_G['forum']['picstyle']) {
            setthreadcover($pid, 0, $threadimageaid);
        }
    }
    /*删除附件*/
    if ($old_arr['forum_id']) {
        $query = DB::query("SELECT attachment, thumb, remote, aid FROM " . DB::table(getattachtablebytid($old_arr['forum_id'])) . " WHERE tid='{$old_arr['forum_id']}'");
        while ($v = DB::fetch($query)) {
            $attach[] = $v;
        }
        dunlink($attach);
        DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE tid='{$old_arr['forum_id']}'");
        DB::query("DELETE FROM " . DB::table(getattachtablebytid($old_arr['forum_id'])) . " WHERE tid='{$old_arr['forum_id']}'");
        DB::delete('forum_threadimage', "tid='{$old_arr['forum_id']}'");
        //图片表
    }
    $param = array('fid' => $arr['fid'], 'tid' => $tid, 'pid' => $pid);
    $statarr = array(0 => 'thread', 1 => 'poll', 2 => 'trade', 3 => 'reward', 4 => 'activity', 5 => 'debate', 127 => 'thread');
    include_once libfile('function/stat');
    updatestat($isgroup ? 'groupthread' : $statarr[$special]);
    dsetcookie('clearUserdata', 'forum');
    if ($specialextra) {
        $classname = 'threadplugin_' . $specialextra;
        if (class_exists($classname) && method_exists($threadpluginclass = new $classname(), 'newthread_submit_end')) {
            $threadpluginclass->newthread_submit_end($_G['fid'], $tid);
        }
    }
    $feed = array('icon' => '', 'title_template' => '', 'title_data' => array(), 'body_template' => '', 'body_data' => array(), 'title_data' => array(), 'images' => array());
    if (!empty($_GET['addfeed']) && $_G['forum']['allowfeed'] && !$isanonymous) {
        $message = !$price ? $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'])) {
                $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");
                if ($firstaid) {
                    $feed['images'] = array(getforumimg($firstaid));
                    $feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}");
                }
            }
        }
    }
    $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) {
            DB::query("UPDATE " . DB::table('forum_groupuser') . " SET threads=threads+1, lastupdate='" . $arr['public_time'] . "' WHERE uid='{$_G['uid']}' AND fid='{$_G['fid']}'");
        }
        $subject = str_replace("\t", ' ', $subject);
        $f_lastpost = "{$tid}\t{$subject}\t" . $arr['public_time'] . "\t{$author}";
        if ($_G['forum']['type'] == 'sub') {
            DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$f_lastpost}' WHERE fid='" . $_G['forum'][fup] . "'", 'UNBUFFERED');
        }
    }
    $subject = str_replace("\t", ' ', $subject);
    $replys = $replys ? $replys : 1;
    //今日发帖
    $todayposts = date("Yjn", $arr['public_time']) == date("Yjn", $v) ? 1 : 0;
    foreach ((array) $time_arr as $k => $v) {
        if (date("Yjn", $_G['timestamp']) == date("Yjn", $v)) {
            $todayposts++;
        }
    }
    DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$f_lastpost}', threads=threads+1, posts=posts+{$replys}, todayposts=todayposts+{$todayposts} WHERE fid='{$arr['fid']}'", 'UNBUFFERED');
    //更新今日发帖这些数据
    if ($_G['forum']['status'] == 3) {
        require_once libfile('function/group');
        updateactivity($_G['fid'], 0);
        require_once libfile('function/grouplog');
        updategroupcreditlog($_G['fid'], $_G['uid']);
    }
    return $re;
}