$key = urldecode($_GET['key']); $keyarray = explode(' ', $key); $isay = new isay(); $isay->config($server, $user, $password, $db); if ($isay->connect()) { $array = $isay->search($keyarray); if ($_GET['page']) { $page = $_GET['page']; } else { $page = 1; } $totalPage = ceil(count($array) / $eachPage); $result = pageItem($page, $eachPage, $array); if (!empty($result)) { foreach ($result as $item) { echo '<div class="content_item">' . ubb2html($item['content']) . '</div>'; echo '<div class="content_info">'; echo $item['postime']; if ($_SESSION['logtag'] == 'in') { echo ' | <a href="edit.php?id=' . $item['id'] . '">编辑</a> | ' . '<a href="delete.php?id=' . $item['id'] . '">删除</a>'; } echo '</div>'; } } $result = pageView($page, $eachPage, count($array)); echo '<div class="content_page"><a href="search.php?key=' . urlencode($key) . '">首页</a> '; if (!empty($result)) { foreach ($result as $item) { if ($item == $page) { echo $item . ' '; } else {
<?php //此程序为UBB模式下的服务端显示测试程序 header('Content-Type: text/html; charset=utf-8'); require_once '../serverscript/php/ubb2html.php'; $sHtml = ubb2html($_POST['elm1']); //htmlspecialchars function showCode($match) { $match[1] = strtolower($match[1]); if (!$match[1]) { $match[1] = 'plain'; } $match[2] = preg_replace("/</", '<', $match[2]); $match[2] = preg_replace("/>/", '>', $match[2]); return '<pre class="brush: ' . $match[1] . ';">' . $match[2] . '</pre>'; } $sHtml = preg_replace_callback('/\\[code\\s*(?:=\\s*((?:(?!")[\\s\\S])+?)(?:"[\\s\\S]*?)?)?\\]([\\s\\S]*?)\\[\\/code\\]/i', 'showCode', $sHtml); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>UBB文章显示测试页</title> <style type="text/css"> pre1 { margin: 5px 20px !important; border-color:#2080D0 !important; border-style:solid !important; border-width:1px 1px 1px 4px !important; padding: 5px !important;
function autoformat($html) { $html = stripslashes($html); $html = preg_replace(array('@on(\\w+)=(["\']?)+\\1@is', '@style=(["|\']?)+\\1@is', '@<script[^>]*>.*?</script>@is', '@<style[^>]*>.*?</style>@is', '@<br[^>]*>@is', '@<div[^>]*>(.*?)</div>@is', '@<p[^>]*>(.*?)</p>@is', '@<b[^>]*>(.*?)</b>@is', '@<strong[^>]*>(.*?)</strong>@is', '@<img[^>]+src=(["\']?)(.*?)\\1[^>]*?>@is'), array('', '', '', '', "\n[br]\n", "\$1\n", "\$1\n", "[b]\$1[/b]", "[b]\$1[/b]", "\n[img]\$2[/img]\n"), $html); if (stripos($html, '<embed') !== false) { preg_match_all("@<embed[^>]*>@is", $html, $embed_match); foreach ((array) $embed_match[0] as $key => $value) { preg_match("@.*?src\\s*=[\"|'|](.*?)[\"|'|]@is", $value, $src_match); preg_match("@.*?class\\s*=[\"|'|](.*?)[\"|'|]@is", $value, $class_match); preg_match("@.*?width\\s*=[\"|'|](\\d+)[\"|'|]@is", $value, $width_match); preg_match("@.*?height\\s*=[\"|'|](\\d+)[\"|'|]@is", $value, $height_match); $embed_width = $width_match[1]; $embed_height = $height_match[1]; if ($class_match[1] == 'edui-faked-music') { empty($embed_width) && ($embed_width = "400"); empty($embed_height) && ($embed_height = "95"); $html = str_replace($value, '[music=' . $embed_width . ',' . $embed_height . ']' . $src_match[1] . '[/music]', $html); } else { empty($embed_width) && ($embed_width = "500"); empty($embed_height) && ($embed_height = "450"); $html = str_replace($value, '[video=' . $embed_width . ',' . $embed_height . ']' . $src_match[1] . '[/video]', $html); } } } $html = str_replace(array(" ", " "), '', $html); $html = preg_replace('@<[/\\!]*?[^<>]*?>@is', '', $html); $html = ubb2html($html); $html = autoclean($html); return $html; }
private function __action_manage_publish() { $aid = (int) $_POST['id']; $cid = (int) $_POST['cid']; $_cid = (int) $_POST['_cid']; $ucid = (int) $_POST['ucid']; $_ucid = (int) $_POST['_ucid']; $mobile = (int) $_POST['mobile']; $title = iS::escapeStr($_POST['title']); $source = iS::escapeStr($_POST['source']); $keywords = iS::escapeStr($_POST['keywords']); $description = iS::escapeStr($_POST['description']); $creative = (int) $_POST['creative']; $userid = user::$userid; $author = user::$nickname; $editor = user::$nickname; if (iCMS::$config['user']['post']['seccode']) { $seccode = iS::escapeStr($_POST['seccode']); iPHP::seccode($seccode, true) or iPHP::alert('iCMS:seccode:error'); } if (iCMS::$config['user']['post']['interval']) { $last_postime = iDB::value("\n SELECT MAX(postime)\n FROM `#iCMS@__article`\n WHERE userid='" . user::$userid . "'"); if ($_SERVER['REQUEST_TIME'] - $last_postime < iCMS::$config['user']['post']['interval']) { iPHP::alert('user:publish:interval'); } } if ($mobile) { $_POST['body'] = ubb2html($_POST['body']); $_POST['body'] = trim($_POST['body']); } $body = iPHP::cleanHtml($_POST['body']); empty($title) && iPHP::alert('标题不能为空!'); empty($cid) && iPHP::alert('请选择所属栏目!'); empty($body) && iPHP::alert('文章内容不能为空!'); $fwd = iCMS::filter($title); $fwd && iPHP::alert('user:publish:filter_title'); $fwd = iCMS::filter($description); $fwd && iPHP::alert('user:publish:filter_desc'); $fwd = iCMS::filter($body); $fwd && iPHP::alert('user:publish:filter_body'); $articleApp = iPHP::app("admincp.article.app"); if (empty($description)) { $description = $articleApp->autodesc($body); } $pubdate = time(); $postype = "0"; $category = iCache::get('iCMS/category/' . $cid); $status = $category['isexamine'] ? 3 : 1; iPHP::import(iPHP_APP_CORE . '/iMAP.class.php'); iPHP::app('article.table'); $fields = articleTable::fields($aid); $data_fields = articleTable::data_fields($aid); if (empty($aid)) { $postime = $pubdate; $chapter = $hits = $good = $bad = $comments = 0; $data = compact($fields); $aid = articleTable::insert($data); $article_data = compact($data_fields); articleTable::data_insert($article_data); map::init('category', iCMS_APP_ARTICLE); map::add($cid, $aid); iDB::query("UPDATE `#iCMS@__user_category` SET `count` = count+1 WHERE `cid` = '{$ucid}' AND `uid`='" . user::$userid . "' AND `appid`='" . iCMS_APP_ARTICLE . "';"); user::update_count(user::$userid, 1, 'article'); $lang = array('1' => 'user:article:add_success', '3' => 'user:article:add_examine'); } else { if (articleTable::update(compact($fields), array('id' => $aid, 'userid' => user::$userid))) { articleTable::data_update(compact($data_fields), array('aid' => $aid)); } map::init('category', iCMS_APP_ARTICLE); map::diff($cid, $_cid, $aid); if ($ucid != $_ucid) { iDB::query("UPDATE `#iCMS@__user_category` SET `count` = count+1 WHERE `cid` = '{$ucid}' AND `uid`='" . user::$userid . "' AND `appid`='" . iCMS_APP_ARTICLE . "';"); iDB::query("UPDATE `#iCMS@__user_category` SET `count` = count-1 WHERE `cid` = '{$_ucid}' AND `uid`='" . user::$userid . " AND `count`>0' AND `appid`='" . iCMS_APP_ARTICLE . "';"); } $lang = array('1' => 'user:article:update_success', '3' => 'user:article:update_examine'); } $url = iPHP::router('/user/article', iPHP_ROUTER_REWRITE); iPHP::success($lang[$status], 'url:' . $url); }
function disFormattedText($str, $linkStyle = "") { return ubb2html($str, $linkStyle); }
} if (!is_numeric($_GET['aid']) || $_GET['aid'] <= 0) { jsonOutput(2, '数据出错,请刷新重试'); } $aid = $_GET['aid']; $comlimit = 30; $start = ($_B['page'] - 1) * $comlimit; $comlist = J::t('comment')->fetch_list('*', "classify='article' AND aid={$aid} AND `status`=1", $start, $comlimit); $next = ''; if ($comlist) { require_once libfile('article'); foreach ($comlist as $k => $v) { $comlist[$k]['formattime'] = btime($v['dateline'], 1); $comlist[$k]['time'] = btime($v['dateline']); $comlist[$k]['avatar'] = IMGDIR . 'jam.png'; $comlist[$k]['content'] = ubb2html($v['content']); } if (count($comlist) >= $comlimit) { $next = 'index.php?m=comment&do=get&aid=' . $aid . '&page=' . ($_B['page'] + 1); } } $data['content'] = display('_comment', 0, true, array('comlist' => $comlist)); $data['next'] = $next; jsonOutput(1, $data); } elseif ($do == 'zan') { if (!$_B['ajax']) { jsonOutput(2, '不允许的操作'); } if (!is_numeric($_GET['cid']) || $_GET['cid'] <= 0) { jsonOutput(2, '数据出错,请刷新重试'); }
function autoformat($html) { $html = stripslashes($html); $html = preg_replace(array('/on(\\w+)="[^"]+"/is', '/<script[^>]*?>.*?<\\/script>/si', '/<style[^>]*?>.*?<\\/style>/si', '/style=[" ]?([^"]+)[" ]/is', '/<br[^>]*>/i', '/<div[^>]*>(.*?)<\\/div>/is', '/<p[^>]*>(.*?)<\\/p>/is', '/<img[^>]+src=[" ]?([^"]+)[" ]?[^>]*>/is'), array('', '', '', '', "\n", "\$1\n", "\$1\n", "\n[img]\$1[/img]"), $html); if (stripos($html, '<embed') !== false) { preg_match_all("/<embed[^>]*>/is", $html, $embed_match); foreach ((array) $embed_match[0] as $key => $value) { preg_match("/.*?src\\s*=[\"|'|](.*?)[\"|'|]/is", $value, $src_match); preg_match("/.*?class\\s*=[\"|'|](.*?)[\"|'|]/is", $value, $class_match); preg_match("/.*?width\\s*=[\"|'|](\\d+)[\"|'|]/is", $value, $width_match); preg_match("/.*?height\\s*=[\"|'|](\\d+)[\"|'|]/is", $value, $height_match); $embed_width = $width_match[1]; $embed_height = $height_match[1]; if ($class_match[1] == 'edui-faked-music') { empty($embed_width) && ($embed_width = "400"); empty($embed_height) && ($embed_height = "95"); $html = str_replace($value, '[music=' . $embed_width . ',' . $embed_height . ']' . $src_match[1] . '[/music]', $html); } else { empty($embed_width) && ($embed_width = "500"); empty($embed_height) && ($embed_height = "450"); $html = str_replace($value, '[video=' . $embed_width . ',' . $embed_height . ']' . $src_match[1] . '[/video]', $html); } } } $html = str_replace(array(" ", " "), '', $html); $html = preg_replace(array('/<b[^>]*>(.*?)<\\/b>/i', '/<strong[^>]*>(.*?)<\\/strong>/i'), "[b]\$1[/b]", $html); $html = preg_replace('/<[\\/\\!]*?[^<>]*?>/is', '', $html); $html = ubb2html($html); $html = nl2p($html); return addslashes($html); }
<form id="message" action="message.php?action=add" method="post"> <input class="book_guest" type="text" name="guest"/> <input class="book_message" type="text" name="message"/> <a class="book_submit" href="javascript:messageSubmit()"></a> </form> </div> <div class="content"></div> <div class="content"> <?php $message = new message(); $message->config($server, $user, $password, $db); if ($message->connect()) { $array = $message->getAll(); if (!empty($array)) { foreach ($array as $item) { echo '<div class="content_item">' . '<font color="green"><strong>' . $item['guest'] . '</strong></font><br />' . ubb2html($item['message']) . '</div>'; echo '<div class="content_info">'; echo $item['postime']; if ($_SESSION['logtag'] == 'in') { echo ' | <a href="message.php?action=delete&id=' . $item['id'] . '">删除</a>'; } echo '</div>'; } } } ?> <div class="content_page">欢迎给我们留言 | 共<?php echo count($array); ?> 条记录</div> </div>
} } jsonOutput($status, $data); } if (!$_B['uid']) { shownotice('请先登录', array('referer' => $_B['referer'])); } $navtitle = $_B['setting']['blog']['blogName'] . ' - 写文章'; $defaultcontent = ''; break; case 'update': if ($_B['ajax'] && $_GET['type'] == 'update') { } $aid = $_GET['aid'] ?: 0; if (!$aid || !is_numeric($aid)) { shownotice('该文章不存在', array('referer' => $_B['referer'])); } $article = J::t('article')->find_by_pk($aid); if (!$article) { shownotice('该文章不存在', array('referer' => $_B['referer'])); } if ($_B['uid'] != $article['authorid'] || $article['status'] != 1 && !$_B['admin']) { shownotice('无权编辑该文章', array('referer' => $_B['referer'])); } $navtitle = '编辑文章 - ' . $article['subject']; $aidattach = $article['image'] ? $article['aid'] : 0; $defaultcontent = ubb2html($article['content'], $aidattach, 'update'); $do = 'new'; break; } include display('article_' . $do);