include template('newsview'); $content = ob_get_contents(); obclean(); fwrite($fp, $content); fclose($fp); unset($multipage); } } else { $news = makenews($multi_news[0], $attacharr, $itemid); //评论处理 $listcount = $news['replynum']; $_SCONFIG['viewspace_pernum'] = intval($_SCONFIG['viewspace_pernum']); if ($listcount) { $query = $_SGLOBAL['db']->query('SELECT c.* FROM ' . tname('spacecomments') . ' c WHERE c.itemid=\'' . $news['itemid'] . '\' ORDER BY c.dateline DESC LIMIT 0, ' . $_SCONFIG['viewspace_pernum']); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $value['message'] = snl2br($value['message']); if (empty($value['author'])) { $value['author'] = 'Guest'; } $commentlist[] = $value; } } //查看页相关资讯处理 if (!empty($news['relativeitemids'])) { $news['itemids'] = getdotstring($news['relativeitemids'], 'int'); $rquery = $_SGLOBAL['db']->query("SELECT * FROM " . tname('spaceitems') . " WHERE itemid IN(" . $news['itemids'] . ") ORDER BY dateline DESC LIMIT 0, 20"); while ($value = $_SGLOBAL['db']->fetch_array($rquery)) { //静态链接处理 $value['url'] = $htmlurl . '/' . sgmdate($value['dateline'], 'Y') . '/' . sgmdate($value['dateline'], 'n') . '/' . $catarr[$value['catid']]['pre_html'] . $value['itemid'] . '.html'; $relativeitem[] = $value; }
function formatcomment($comment, $repeatids = array(), $style = 0) { global $_SCONFIG, $lang; include_once S_ROOT . './function/misc.func.php'; $searcharr = $replacearr = array(); $comment['message'] = snl2br($comment['message']); if (empty($comment['author'])) { $comment['author'] = 'Guest'; } $comment['hideauthor'] = !empty($comment['hideauthor']) && !empty($_SCONFIG['commanonymous']) ? 1 : 0; $comment['hideip'] = !empty($comment['hideip']) && !empty($_SCONFIG['commhideip']) ? 1 : 0; $comment['hidelocation'] = !empty($comment['hidelocation']) && !empty($_SCONFIG['commhidelocation']) ? 1 : 0; $comment['iplocation'] = str_replace(array('-', ' '), '', convertip($comment['ip'])); $comment['ip'] = preg_replace("/^(\\d{1,3})\\.(\\d{1,3})\\.\\d{1,3}\\.\\d{1,3}\$/", "\$1.\$2.*.*", $comment['ip']); $_SCONFIG['commfloornum'] = intval($_SCONFIG['commfloornum']); $comment['floornum'] = intval($comment['floornum']); if (!$style) { if (!empty($_SCONFIG['commfloornum'])) { //Ï÷Â¥¹¦ÄÜ if ($_SCONFIG['commfloornum'] < $comment['floornum']) { $cutfloor = $comment['floornum'] - $_SCONFIG['commfloornum']; $searchstr = "/\\<div id=\"cid_{$comment['cid']}_{$cutfloor}\".*?\\<div id=\"cid_{$comment['cid']}_" . ($cutfloor + 1) . "_title\"/is"; $replacestr = "<div id=\"cid_{$comment['cid']}_" . ($cutfloor + 1) . "_title\""; $comment['message'] = preg_replace($searchstr, $replacestr, $comment['message']); } } else { //¸ß²ãµçÌÝ if ($comment['floornum'] > 49) { $elevatordetail = <<<EOF \t\t\t\t\t\t<div id="cid_{$comment['cid']}_elevator" class="floor_op"> \t\t\t\t\t\t\t<div class="old_title "><span class="author">{$lang['comment_elevator']}</span><span class="color_red">{$lang['comment_floor_hide']}</span></div> \t\t\t\t\t\t\t<p class="detail "><span><a class="color_red" href="javascript:;" onclick="elevator({$comment['cid']}, 2);" title="{$lang['comment_floor_up_title']}">[{$lang['comment_floor_up']}]</a> \t\t\t\t\t\t\t<a class="color_red" href="javascript:;" onclick="elevator({$comment['cid']}, 1);" title="{$lang['comment_floor_down_title']}">[{$lang['comment_floor_down']}]</a></span> \t\t\t\t\t\t\t{$lang['comment_floor_total']}{$comment['floornum']}{$lang['comment_floor_total_2']}</p> \t\t\t\t\t\t\t<input type="hidden" id="cid_{$comment['cid']}_elevatornum" value="40"> \t\t\t\t\t\t\t<input type="hidden" id="cid_{$comment['cid']}_floornum" value="{$comment['floornum']}"> \t\t\t\t\t\t</div> EOF; $searcharr[] = '<div id="cid_' . $comment['cid'] . '_' . ($comment['floornum'] - 8) . '_title"'; $replacearr[] = $elevatordetail . '<div id="cid_' . $comment['cid'] . '_' . ($comment['floornum'] - 8) . '_title"'; if (!in_array($comment['firstcid'], $repeatids)) { for ($i = 41; $i < $comment['floornum'] - 8; $i++) { $searcharr[] = "id=\"cid_{$comment['cid']}_{$i}\" class=\"old\""; $searcharr[] = "id=\"cid_{$comment['cid']}_{$i}_title\" class=\"old_title\""; $searcharr[] = "id=\"cid_{$comment['cid']}_{$i}_detail\" class=\"detail\""; $replacearr[] = "id=\"cid_{$comment['cid']}_{$i}\" class=\"hideold\""; $replacearr[] = "id=\"cid_{$comment['cid']}_{$i}_title\" class=\"hideelement\""; $replacearr[] = "id=\"cid_{$comment['cid']}_{$i}_detail\" class=\"hideelement\""; } } } } //Òþ²ØÖظ´¸ÇÂ¥ if (!empty($_SCONFIG['commhidefloor']) && in_array($comment['firstcid'], $repeatids)) { $tipdetail = "<p id=\"cid_{$comment['cid']}_tip_detail\" class=\"hidetip\">{$lang['comment_floor_repeat']} <a class=\"color_red\" href=\"javascript:;\" onclick=\"operatefloor({$comment['cid']});\">[{$lang['comment_floor_view_repeat']}]</a><p></div>"; $searcharr[] = 'class="old"'; $searcharr[] = 'class="old_title"'; $searcharr[] = 'class="detail"'; $searcharr[] = 'class="floor_op"'; $searcharr[] = '_1" class="hideold"'; $searcharr[] = '_tip" class="hideold"'; $searcharr[] = '_1_title" class="hideelement"'; $searcharr[] = '_1_detail" class="hideelement"'; $searcharr[] = '<div class="new"'; $replacearr[] = 'class="hideold"'; $replacearr[] = 'class="hideelement"'; $replacearr[] = 'class="hideelement"'; $replacearr[] = 'class="hideelement"'; $replacearr[] = '_1" class="old"'; $replacearr[] = '_tip" class="old"'; $replacearr[] = '_1_title" class="old_title"'; $replacearr[] = '_1_detail" class="detail"'; $replacearr[] = $tipdetail . '<div class="new"'; $comment['message'] = "<div id=\"cid_{$comment['cid']}_tip\" class=\"old\">" . $comment['message']; } $comment['message'] = str_replace($searcharr, $replacearr, $comment['message']); } else { preg_match_all("/\\<div class=\"new\">(.+)?\\<\\/div\\>/is", $comment['message'], $currentmessage, PREG_SET_ORDER); if (!empty($currentmessage)) { $comment['message'] = $currentmessage[0][0]; } $comment['message'] = preg_replace("/\\<div class=\"quote\"\\>\\<blockquote.+?\\<\\/blockquote\\>\\<\\/div\\>/is", '', $comment['message']); } return $comment; }
function bbcode($message) { global $_SGLOBAL; $message = preg_replace($_SGLOBAL['smilies']['searcharray'], $_SGLOBAL['smilies']['replacearray'], $message, 50); return snl2br($message); }
$page = $page < 1 ? 1 : $page; $start = ($page - 1) * $perpage; $itemid = empty($_SGET['itemid']) ? 0 : intval($_SGET['itemid']); if (empty($itemid)) { showmessage('not_found', S_URL); } $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('spaceitems') . ' WHERE itemid=\'' . $itemid . '\' AND type=\'news\' AND folder=\'1\' AND allowreply=\'1\''); if (!($item = $_SGLOBAL['db']->fetch_array($query))) { showmessage('not_found', S_URL); } $listcount = $item['replynum']; $iarr = array(); $multipage = ''; if ($listcount) { $i = ($page - 1) * $perpage + 1; $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('spacecomments') . ' WHERE itemid=\'' . $itemid . '\' ORDER BY dateline DESC LIMIT ' . $start . ',' . $perpage); while ($comment = $_SGLOBAL['db']->fetch_array($query)) { $comment['message'] = snl2br($comment['message']); $comment['num'] = $i; $i++; if (empty($comment['author'])) { $comment['author'] = 'Guest'; } $iarr[] = $comment; } $urlarr = array('action' => 'viewcomment', 'itemid' => $itemid); $multipage = multi($listcount, $perpage, $page, $urlarr, 0); } $title = $item['subject'] . ' - ' . $_SCONFIG['sitename']; include template('news_viewcomment'); ob_out();