本文整理汇总了PHP中Board::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Board::getInstance方法的具体用法?PHP Board::getInstance怎么用?PHP Board::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Board
的用法示例。
在下文中一共展示了Board::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeFilter
public function beforeFilter()
{
parent::beforeFilter();
if (!isset($this->params['name'])) {
$this->error(ECode::$BOARD_NONE);
}
try {
$boardName = $this->params['name'];
if (preg_match("/^\\d+\$/", $boardName)) {
throw new BoardNullException();
}
$this->_board = Board::getInstance($boardName);
} catch (BoardNullException $e) {
$this->error(ECode::$BOARD_UNKNOW);
}
if (isset($this->params['url']['mode'])) {
$mode = (int) trim($this->params['url']['mode']);
if (!$this->_board->setMode($mode)) {
$this->error(ECode::$BOARD_NOPERM);
}
}
if (!$this->_board->hasReadPerm(User::getInstance())) {
if (!$this->ByrSession->isLogin) {
$this->requestLogin();
}
$this->error(ECode::$BOARD_NOPERM);
}
$this->_board->setOnBoard();
$this->ByrSession->Cookie->write("XWJOKE", "hoho", false);
}
示例2: beforeFilter
public function beforeFilter()
{
parent::beforeFilter();
if (isset($this->params['name'])) {
$bName = trim($this->params['name']);
} else {
$this->error(ECode::$BOARD_NONE);
}
try {
$this->_board = Board::getInstance($bName);
if ($this->_board->isDir()) {
throw new BoardNullException();
}
} catch (BoardNullException $e) {
$this->error(ECode::$BOARD_NONE);
}
if (isset($this->params['mode'])) {
$mode = (int) trim($this->params['mode']);
if (!$this->_board->setMode($mode)) {
$this->error(ECode::$BOARD_NOPERM);
}
}
if (!$this->_board->hasReadPerm(User::getInstance())) {
$this->error(ECode::$BOARD_NOPERM);
}
$this->_board->setOnBoard();
}
示例3: beforeFilter
public function beforeFilter()
{
parent::beforeFilter();
App::import("vendor", array("model/board", "inc/pagination"));
if (!isset($this->params['name'])) {
$this->error(ECode::$BOARD_NONE);
}
try {
$boardName = $this->params['name'];
if (preg_match("/^\\d+\$/", $boardName)) {
throw new BoardNullException();
}
$this->_board = Board::getInstance($boardName);
if ($this->_board->isDir()) {
throw new BoardNullException();
}
} catch (BoardNullException $e) {
$this->error(ECode::$BOARD_UNKNOW);
}
if (isset($this->params['url']['mode'])) {
$mode = (int) trim($this->params['url']['mode']);
$this->_board->setMode($mode);
}
if (!$this->_board->hasReadPerm(User::getInstance())) {
$this->error(ECode::$BOARD_NOPERM);
}
$this->_board->setOnBoard();
}
示例4: delete
public function delete()
{
if (!$this->RequestHandler->isPost()) {
$this->error(ECode::$SYS_REQUESTERROR);
}
if (!isset($this->params['form']['dir']) || !isset($this->params['form']['name'])) {
$this->error();
}
$dir = $this->params['form']['dir'] == '1';
$val = trim($this->params['form']['name']);
$level = $this->params['num'];
try {
$fav = Favor::getInstance($level);
} catch (FavorNullException $e) {
$this->error(ECode::$USER_FAVERROR);
}
if ($val == "") {
$this->error();
}
if ($dir) {
if (!$fav->delete($val, Favor::$DIR)) {
$this->error();
}
} else {
App::import('vendor', 'model/board');
try {
$board = Board::getInstance($val);
if (!$fav->delete($board, Favor::$BOARD)) {
$this->error();
}
} catch (BoardNullException $e) {
$this->error();
}
}
try {
$fav = Favor::getInstance($level);
} catch (FavorNullException $e) {
$this->error(ECode::$USER_FAVERROR);
}
$this->set('data', $this->_favor($fav));
}
示例5: ajax_add
public function ajax_add()
{
if (!$this->RequestHandler->isPost()) {
$this->error(ECode::$SYS_REQUESTERROR);
}
$this->requestLogin();
$db = DB::getInstance();
$u = User::getInstance();
if (!$u->isAdmin()) {
$sql = "select count(*) as num from pl_vote where status=1 and start>=? and uid=?";
$res = $db->one($sql, array(strtotime(date("Y-m-d", time())), $u->userid));
if ($res !== false && $res['num'] >= 2) {
$this->error("每天你最多开启两次投票");
}
}
$subject = @trim($this->params['form']['subject']);
$desc = @trim($this->params['form']['desc']);
$end = @trim($this->params['form']['end']);
$type = @trim($this->params['form']['type']);
$limit = @trim($this->params['form']['limit']);
$result_voted = isset($this->params['form']['result_voted']) ? 1 : 0;
if (empty($subject) || empty($end)) {
$this->error();
}
if ($type != "0" && $type != "1") {
$type = 0;
}
if (empty($limit) || intval($limit) < 2 || intval($limit) > 19) {
$limit = 0;
}
if (strtotime($end) === false || !preg_match("/\\d{4}(-\\d{2}){2}/", $end)) {
$this->error("截止日期错误");
}
$items = array();
foreach ($this->params['form'] as $k => $v) {
if (preg_match('/^i\\d+$/', $k) && trim($v) != "") {
$items[] = nforum_iconv('UTF-8', $this->encoding, trim($v));
}
}
$realNum = count($items);
if ($realNum < 2 || $realNum > 20) {
$this->error("选项数量错误,发起投票失败");
}
if ($limit > $realNum) {
$limit = $realNum;
}
$subject = nforum_iconv('UTF-8', $this->encoding, $subject);
$desc = nforum_iconv('UTF-8', $this->encoding, $desc);
$vid = Vote::add($u->userid, $subject, $desc, strtotime($end), $type, $limit, $items, $result_voted);
$site = Configure::read("site");
$a_title = $subject;
$a_content = "主题:{$subject}\n描述:{$desc}\n发起人:{$u->userid}\n类型:" . ($type == 0 ? '单选' : '多选') . "\n截止日期:{$end}\n链接:[url={$site['domain']}{$site['prefix']}/vote/view/{$vid}]{$site['domain']}{$site['prefix']}/vote/view/{$vid}[/url]\n[vote={$vid}][/vote]";
App::import("vendor", "model/article");
$aid = Article::autoPost($this->_board, $a_title, $a_content);
$db->update("pl_vote", array("aid" => $aid), "where vid=?", array($vid));
if (isset($this->params['form']['b'])) {
App::import("vendor", "model/board");
try {
$board = Board::getInstance(trim($this->params['form']['b']));
if ($board->hasPostPerm($u)) {
Article::autoPost($board->NAME, '[投票]' . $a_title, $a_content);
}
} catch (Exception $e) {
}
}
$ret['ajax_code'] = "发起投票成功";
$ret['default'] = "/vote?c=list&u=" . $u->userid;
$ret['list'][] = array("text" => '我的投票', "url" => "/vote?c=list&u=" . $u->userid);
$ret['list'][] = array("text" => '热门投票', "url" => "/vote?c=hot");
$this->set('no_html_data', $ret);
}
示例6: ajax_change
public function ajax_change()
{
if (!isset($this->params['form']['ac']) || !isset($this->params['form']['v'])) {
$this->error();
}
$action = $this->params['form']['ac'];
$val = $this->params['form']['v'];
$level = $this->params['num'];
try {
$fav = Favor::getInstance($level);
} catch (FavorNullException $e) {
$this->error(ECode::$USER_FAVERROR);
}
if ($val == "") {
$this->error();
}
switch ($action) {
case "ab":
try {
$val = Board::getInstance($val);
if (!$fav->add($val, Favor::$BOARD)) {
$this->error();
}
} catch (Exception $e) {
$this->error(ECode::$BOARD_UNKNOW);
}
break;
case "ad":
if (!$fav->add(nforum_iconv("utf-8", $this->encoding, $val), Favor::$DIR)) {
$this->error();
}
break;
case "db":
try {
$val = Board::getInstance($val);
if (!$fav->delete($val, Favor::$BOARD)) {
$this->error();
}
} catch (Exception $e) {
$this->error(ECode::$BOARD_UNKNOW);
}
break;
case "dd":
if (!$fav->delete($val, Favor::$DIR)) {
$this->error();
}
break;
}
}
示例7: threads
public function threads()
{
App::import('vendor', array('model/board', 'model/threads', 'inc/pagination'));
$day = 7;
$title1 = $title2 = $title3 = $author = '';
if (isset($this->params['url']['title1'])) {
$title1 = trim($this->params['url']['title1']);
}
if (isset($this->params['url']['title2'])) {
$title2 = trim($this->params['url']['title2']);
}
if (isset($this->params['url']['titlen'])) {
$title3 = trim($this->params['url']['titlen']);
}
if (isset($this->params['url']['author'])) {
$author = trim($this->params['url']['author']);
}
if (isset($this->params['url']['day'])) {
$day = intval($this->params['url']['day']);
}
$m = isset($this->params['url']['m']) && $this->params['url']['m'] == '1';
$a = isset($this->params['url']['a']) && $this->params['url']['a'] == '1';
$return = Configure::read('search.max');
$res = array();
if (!isset($this->params['url']['boards'])) {
$this->error(ECode::$BOARD_UNKNOW);
}
$boards = $this->params['url']['boards'];
foreach (explode('|', $boards) as $b) {
try {
$brd = Board::getInstance($b);
$res = array_merge($res, Threads::search($brd, $title1, $title2, $title3, $author, $day, $m, $a, $return));
} catch (BoardNullException $e) {
}
}
$count = isset($this->params['url']['count']) ? $this->params['url']['count'] : Configure::read("pagination.threads");
if (($count = intval($count)) <= 0) {
$count = Configure::read("pagination.threads");
}
if ($count > Configure::read('plugins.api.page_item_limit')) {
$count = Configure::read("pagination.threads");
}
$page = isset($this->params['url']['page']) ? $this->params['url']['page'] : 1;
$page = intval($page);
$pagination = new Pagination(new ArrayPageableAdapter($res), $count);
$articles = $pagination->getPage($page);
$wrapper = Wrapper::getInstance();
$data = array();
$data['pagination'] = $wrapper->page($pagination);
foreach ($articles as $v) {
$data['threads'][] = $wrapper->article($v, array('threads' => true));
}
$this->set('data', $data);
}
示例8: file
public function file()
{
if (!isset($this->params['url']['pos']) && !preg_match("/ajax_file.json\$/", $this->here) && !$this->spider) {
$this->redirect('elite/path?v=' . preg_replace("|/([^/]+)/*\$|", "&f=", trim($this->params['url']['v'])) . trim($this->params['url']['v']));
}
$path = Configure::read("elite.root") . "/";
$boardName = "";
$articles = array();
if (isset($this->params['url']['v'])) {
$path .= preg_replace("/^\\//", "", trim($this->params['url']['v']));
}
$u = User::getInstance();
if (bbs_ann_traverse_check($path, $u->userid) < 0) {
if (!$this->ByrSession->isLogin) {
$this->requestLogin();
}
$this->error(ECode::$ELITE_NODIR);
}
$up_dirs = array();
$up_cnt = $this->_getUpdir($path, $boardName, $up_dirs);
if ($boardName) {
try {
$brd = Board::getInstance($boardName);
} catch (BoardNullException $e) {
$this->error(ECode::$ELITE_NODIR);
}
if (!$brd->hasReadPerm($u)) {
if (!$this->ByrSession->isLogin) {
$this->requestLogin();
}
$this->error(ECode::$ELITE_NODIR);
}
if ($brd->isNormal()) {
$this->cache(true, @filemtime($path));
}
}
$e = new Elite($path);
if (isset($this->params['url']['pos'])) {
$pos = intval($this->params['url']['pos']);
if ($pos == 0) {
$this->_stop();
}
$e->getAttach($pos);
$this->_stop();
}
$content = $e->getHtml(true);
$subject = '';
if (preg_match("|标 题: ([\\s\\S]*?)<br|", $content, $subject)) {
$subject = trim($subject[1]);
}
if (Configure::read("ubb.parse")) {
App::import("vendor", "inc/ubb");
$content = preg_replace("'^(.*?<br \\/>.*?<br \\/>)'e", "XUBB::remove('\\1')", $content);
$content = XUBB::parse($content);
}
$this->set(array('subject' => $subject, 'content' => $content));
}
示例9: article
public function article()
{
$this->js[] = "forum.board.js";
$this->css[] = "board.css";
$this->notice[] = array("url" => "", "text" => "ËÑË÷½á¹û");
App::import('Sanitize');
$day = $title1 = $title2 = $title3 = $author = $t = "";
if (isset($this->params['url']['t1'])) {
$title1 = trim(rawurldecode($this->params['url']['t1']));
}
if (isset($this->params['url']['t2'])) {
$title2 = trim(rawurldecode($this->params['url']['t2']));
}
if (isset($this->params['url']['tn'])) {
$title3 = trim(rawurldecode($this->params['url']['tn']));
}
if (isset($this->params['url']['au'])) {
$author = trim($this->params['url']['au']);
}
if (isset($this->params['url']['d'])) {
$day = intval($this->params['url']['d']);
}
$title1 = nforum_iconv('utf-8', $this->encoding, $title1);
$title2 = nforum_iconv('utf-8', $this->encoding, $title2);
$title3 = nforum_iconv('utf-8', $this->encoding, $title3);
$m = isset($this->params['url']['m']);
$a = isset($this->params['url']['a']);
$full = isset($this->params['url']['f']);
$site = Configure::read('search.site');
$return = Configure::read("search.max");
$res = array();
$u = User::getInstance();
if ($title1 == '' && $title3 == '' && $author == '' && !$m && !$a) {
$res = array();
} else {
if ($full && $site && $u->isAdmin()) {
App::import('vendor', 'model/section');
$secs = array_keys(Configure::read("section"));
foreach ($secs as $v) {
$sec = Section::getInstance($v, Section::$ALL);
foreach ($sec->getList() as $brd) {
if (!$brd->isNormal()) {
continue;
}
$res = array_merge($res, Threads::search($brd, $title1, $title2, $title3, $author, $day, $m, $a, $return));
}
}
} else {
$b = @$this->params['url']['b'];
try {
$brd = Board::getInstance($b);
} catch (BoardNullException $e) {
$this->error(ECode::$BOARD_NONE);
}
$res = Threads::search($brd, $title1, $title2, $title3, $author, $day, $m, $a, $return);
}
}
$p = 1;
if (isset($this->params['url']['p'])) {
$p = $this->params['url']['p'];
}
App::import("vendor", "inc/pagination");
$page = new Pagination(new ArrayPageableAdapter($res), Configure::read("pagination.search"));
$threads = $page->getPage($p);
$info = false;
$curTime = strtotime(date("Y-m-d", time()));
$pageArticle = Configure::read("pagination.article");
foreach ($threads as $v) {
$tabs = ceil($v->articleNum / $pageArticle);
$last = $v->LAST;
$postTime = $curTime > $v->POSTTIME ? date("Y-m-d", $v->POSTTIME) : date("H:i:s", $v->POSTTIME) . " ";
$replyTime = $curTime > $last->POSTTIME ? date("Y-m-d", $last->POSTTIME) : date("H:i:s", $last->POSTTIME) . " ";
$info[] = array("title" => Sanitize::html($v->TITLE), "poster" => $v->isSubject() ? $v->OWNER : "ÔÌûÒÑɾ³ý", "postTime" => $postTime, "gid" => $v->ID, "last" => $last->OWNER, "replyTime" => $replyTime, "page" => $tabs, "bName" => $v->getBoard()->NAME, "num" => $v->articleNum - 1);
}
$this->set("info", $info);
$query = $this->params['url'];
unset($query['url']);
unset($query['p']);
unset($query['ext']);
foreach ($query as $k => &$v) {
$v = $k . '=' . rawurlencode($v);
}
$query[] = "p=%page%";
$link = "{$this->base}/s/article?" . join("&", $query);
$this->set("pageBar", $page->getPageBar($p, $link));
$this->set("pagination", $page);
}
示例10: wGetList
public function wGetList()
{
$arr = array();
$brds = $this->getList();
if (empty($brds)) {
$arr[] = array("text" => ECode::msg(ECode::$SEC_NOBOARD), "url" => "");
$arr = array("s" => "w-list-line", "v" => $arr);
} else {
foreach ($brds as $v) {
$arr[] = array("text" => $v->DESC, "url" => "/board/{$v->NAME}");
}
$arr = array("s" => "w-list-float", "v" => $arr);
}
if ($this->isRoot()) {
$file = BBS_HOME . "/xml/day_sec{$this->_num}.xml";
$ret = array();
if (file_exists($file)) {
$xml = simplexml_load_file($file);
if ($xml !== false) {
foreach ($xml->hotsubject as $v) {
$title = nforum_fix_gbk(urldecode($v->title));
try {
$brd = Board::getInstance(urldecode($v->board));
$ret[] = array("text" => '[<a style="color:blue" href="' . Configure::read("site.prefix") . "/board/" . $brd->NAME . '">' . $brd->DESC . '</a>] <a title="' . $title . '" href="' . Configure::read("site.prefix") . '/article/' . $v->board . "/" . $v->groupid . '">' . $title . '</a>', "url" => "");
} catch (BoardNullException $e) {
}
}
}
}
if (empty($ret)) {
$ret[] = array("text" => ECode::msg(ECode::$SEC_NOHOT), "url" => "");
}
$ret = array("s" => "w-list-line", "v" => $ret);
return array(array("t" => "热门话题", "v" => $ret), array("t" => "版面列表", "v" => $arr));
} else {
return $arr;
}
}
示例11: index
public function index()
{
if (!isset($this->params['name'])) {
$this->error();
}
$name = $this->params['name'];
App::import('vendor', 'model/widget');
try {
$widget = Widget::getInstance($name);
} catch (WidgetNullException $e) {
$this->error($e->getMessage());
}
$wrapper = Wrapper::getInstance();
$data = $wrapper->widget($widget);
$list = $widget->wGetList();
switch (array_shift(split('-', $name))) {
case 'topten':
case 'recommend':
if (!is_array($list['v'])) {
break;
}
App::import('vendor', array('model/board', 'model/threads'));
$article = array();
foreach ($list['v'] as $v) {
if (isset($v['url'])) {
$ret = array();
preg_match("|^/article/(.*?)/(.*?)\$|", $v['url'], $ret);
if (empty($ret[1]) || empty($ret[2])) {
continue;
}
$board = rawurldecode($ret[1]);
$id = (int) $ret[2];
if ($widget->wGetName() == 'topten') {
$text = $v['text'];
$text = preg_replace("|<[^>]*?>|", '', $text);
if (preg_match("/\\((\\d+)\\)\$/", $text, $c)) {
$c = $c[1];
} else {
$c = 0;
}
}
try {
$t = $wrapper->article(Threads::getInstance($id, Board::getInstance($board)), array('threads' => true));
if ($widget->wGetName() == 'topten') {
$t['id_count'] = $c;
$t['title'] .= "({$c})";
}
$article[] = $t;
} catch (Exception $e) {
continue;
}
}
}
$data['article'] = $article;
break;
case 'section':
if (!is_array($list[0]['v']['v'])) {
break;
}
App::import('vendor', array('model/board', 'model/threads'));
$article = array();
foreach ($list[0]['v']['v'] as $v) {
if (isset($v['text'])) {
$ret = array();
preg_match("|/article/(.+?)/(\\d+)|", $v['text'], $ret);
if (empty($ret[1]) || empty($ret[2])) {
continue;
}
$board = rawurldecode($ret[1]);
$id = (int) $ret[2];
try {
$article[] = $wrapper->article(Threads::getInstance($id, Board::getInstance($board)), array('threads' => true));
} catch (Exception $e) {
continue;
}
}
}
$data['article'] = $article;
break;
default:
$this->error('no such widget');
}
$this->set('data', $data);
}
示例12: _attOpInit
private function _attOpInit()
{
$this->cache(false);
if (!isset($this->params['name'])) {
$this->error(ECode::$BOARD_UNKNOW);
}
$name = $this->params['name'];
$u = User::getInstance();
try {
$brd = Board::getInstance($name);
if (!$brd->hasPostPerm($u) || !$brd->isAttach()) {
$this->error(ECode::$BOARD_NOPERM);
}
} catch (Exception $e) {
$this->error(ECode::$BOARD_UNKNOW);
}
$this->_board = $brd;
$this->set("bName", $this->_board->NAME);
}
示例13: send
public function send()
{
if (!Mail::canSend()) {
$this->error(ECode::$MAIL_SENDERROR);
}
$u = User::getInstance();
$mail = false;
if (isset($this->params['type']) && isset($this->params['num'])) {
$type = $this->params['type'];
$num = $this->params['num'];
try {
$mail = MAIL::getInstance($num, new MailBox($u, $type));
} catch (Exception $e) {
}
}
if ($this->RequestHandler->isPost()) {
$title = $content = '';
$sig = User::getInstance()->signature;
if (isset($this->params['form']['title'])) {
$title = trim($this->params['form']['title']);
}
if (isset($this->params['form']['content'])) {
$content = $this->params['form']['content'];
}
$sig = 0;
$bak = isset($this->params['form']['backup']) ? 1 : 0;
$title = nforum_iconv($this->encoding, $this->appEncoding, $title);
$content = nforum_iconv($this->encoding, $this->appEncoding, $content);
try {
if (false === $mail) {
//send new
if (!isset($this->params['form']['id'])) {
$this->error(ECode::$POST_NOID);
}
$id = trim($this->params['form']['id']);
Mail::send($id, $title, $content, $sig, $bak);
$this->redirect($this->_mbase . "/mail?m=" . ECode::$MAIL_SENDOK);
} else {
//reply
$mail->reply($title, $content, $sig, $bak);
$this->redirect($this->_mbase . "/mail/{$type}?m=" . ECode::$MAIL_SENDOK);
}
} catch (MailSendException $e) {
$this->error($e->getMessage());
}
}
$uid = $title = $content = "";
if (isset($this->params['type']) && isset($this->params['num'])) {
$this->notice = "邮件-回复邮件";
if (false === $mail) {
//reply article
try {
$b = Board::getInstance($type);
if (!$b->hasReadPerm($u)) {
$this->error(ECode::$BOARD_NOPERM);
}
$mail = Article::getInstance($num, $b);
} catch (Exception $e) {
$this->error(ECode::$MAIL_NOMAIL);
}
}
if (!strncmp($mail->TITLE, "Re: ", 4)) {
$title = $mail->TITLE;
} else {
$title = "Re: " . $mail->TITLE;
}
$content = "\n" . $mail->getRef();
//remove ref ubb tag
$content = XUBB::remove($content);
$uid = $mail->OWNER;
} else {
$this->notice = "邮件-新邮件";
}
$this->set("uid", $uid);
$this->set("title", $title);
$this->set("content", $content);
$this->set("bak", $u->getCustom("mailbox_prop", 0));
}
示例14: _attOpInit
private function _attOpInit()
{
$this->requestLogin();
$name = $this->params['name'];
$u = User::getInstance();
try {
$brd = Board::getInstance($name);
if (!$brd->hasPostPerm($u) || !$brd->isAttach()) {
$this->error(ECode::$ARTICLE_NOEDIT);
}
} catch (BoardNullException $e) {
$this->error(ECode::$BOARD_NONE);
}
$this->_board = $brd;
App::import("vendor", "model/forum");
}
示例15: search
/**
* function search match with board name
*
* @param $name
* @return array
* @static
* @access public
*/
public static function search($name)
{
$boards = array();
if (!bbs_searchboard(trim($name), 0, $boards)) {
return array();
}
$ret = array();
foreach ($boards as $v) {
try {
$ret[] = Board::getInstance($v['NAME']);
} catch (BoardNullException $e) {
}
}
return $ret;
}