public function actionDisplay() { $model = Article::getInstance(); $params["items"] = $model->getTinTuc(); $page_title = "wapsite - trang tin tức tổng hợp nhanh nhất"; setSysConfig("seopage.title", $page_title); setSysConfig("seopage.keyword", $page_title); setSysConfig("seopage.description", $page_title); $this->render('default', $params); }
public function actionDisplay() { $cid = Request::getVar('id', null); $alias = Request::getVar('alias', null); $model = Article::getInstance(); $obj_item = $model->getItem($cid, $alias); $obj_category = $model->getCategory($obj_item['catID']); $data['item'] = $obj_item; $data['category'] = $obj_category; $page_title = $obj_item['title']; $page_keyword = $obj_item['metakey'] != "" ? $obj_item['metakey'] : $page_title; $page_description = $obj_item['metadesc'] != "" ? $obj_item['metadesc'] : $page_title; setSysConfig("seopage.title", $page_title); setSysConfig("seopage.keyword", $page_keyword); setSysConfig("seopage.description", $page_description); $this->render('default', $data); }
public function actionBlog() { $model = Article::getInstance(); $catAlias = Request::getVar('alias', null); $currentPage = Request::getVar('page', 1); $limit = 12; $data['alias'] = $catAlias; $catID = Request::getVar("id"); $obj_category = $model->getCategory($catID, $catAlias); if ($obj_category == false) { $this->redirect($this->createUrl("articles/")); } $start = ($currentPage - 1) * $limit; $obj_category['items'] = $model->getArticlesCategoy($obj_category['id'], $start, $limit); if ($obj_category['total'] > $start + $limit) { $page = $currentPage + 1; } else { $page = $currentPage - 1; } $catAlias = $obj_category['alias']; if ($page > 1) { $obj_category['pagemore'] = Yii::app()->createUrl("articles/category", array("alias" => $catAlias, "page" => $page)); } elseif ($page == 1) { $obj_category['pagemore'] = Yii::app()->createUrl("articles/category", array("alias" => $catAlias)); } $page_title = $obj_category['title']; if ($currentPage > 1) { $page_title = $page_title . " trang {$currentPage}"; } $page_keyword = $obj_category['metakey'] != "" ? $obj_category['metakey'] : $page_title; $page_description = $obj_category['metadesc'] != "" ? $obj_category['metadesc'] : $page_title; setSysConfig("seopage.title", $page_title); setSysConfig("seopage.keyword", $page_keyword); setSysConfig("seopage.description", $page_description); $data['category'] = $obj_category; $this->render('default', $data); }
public function reply() { $mail = $this->_sendInit(); $this->js[] = "forum.post.js"; $this->css[] = "post.css"; $this->notice[] = array("url" => "/mail/send", "text" => "回复邮件"); $u = User::getInstance(); if (false === $mail) { //reply article if (!isset($this->params['type'])) { $this->error(ECode::$MAIL_NOBOX); } if (!isset($this->params['num'])) { $this->error(ECode::$MAIL_NOMAIL); } $type = $this->params['type']; $num = $this->params['num']; 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); $this->set("rid", $mail->OWNER); $sigOption = array(); foreach (range(0, $u->signum) as $v) { if ($v == 0) { $sigOption["{$v}"] = "不使用签名档"; } else { $sigOption["{$v}"] = "使用第{$v}个"; } } $sigOption["-1"] = "使用随机签名档"; App::import('Sanitize'); $title = Sanitize::html($title); $content = Sanitize::html($content); $this->set("title", $title); $this->set("content", $content); $this->set("sigOption", $sigOption); $this->set("sigNow", $u->signature); $this->set("bak", $u->getCustom("mailbox_prop", 0)); $this->render('send'); }
private function _editInit() { if ($this->_board->isReadOnly()) { $this->error(ECode::$BOARD_READONLY); } if (!$this->_board->hasPostPerm(User::getInstance())) { $this->error(ECode::$BOARD_NOPOST); } if (!isset($this->params['id'])) { $this->error(ECode::$ARTICLE_NONE); } $id = intval($this->params['id']); try { $article = Article::getInstance($id, $this->_board); } catch (ArticleNullException $e) { $this->error(ECode::$ARTICLE_NONE); } $u = User::getInstance(); if (!$article->hasEditPerm($u)) { $this->error(ECode::$ARTICLE_NOEDIT); } $this->set('reid', $id); return $article; }
public function delete() { $u = User::getInstance(); if (isset($this->params['gid'])) { try { $a = Article::getInstance(intval($this->params['gid']), $this->_board); if (!$a->hasEditPerm($u)) { $this->error(ECode::$ARTICLE_NODEL); } if (!$a->delete()) { $this->error(ECode::$ARTICLE_NODEL); } } catch (ArticleNullException $e) { $this->error(ECode::$ARTICLE_NONE); } } $single = isset($this->params['url']['s']) || isset($this->params['form']['s']); $this->redirect($this->_mbase . "/board/" . $this->_board->NAME . ($single ? "/0" : "") . "?m=" . ECode::$ARTICLE_DELOK); }
function actionSavecopy() { $cid = Request::getVar("id", 0); $model = Article::getInstance(); $cid = $model->copyitem($cid); $this->redirect(Router::buildLink("articles", array("layout" => "edit", 'cid' => $cid))); }
private function _attList() { $u = User::getInstance(); if (isset($this->params['id'])) { $id = $this->params['id']; try { $article = Article::getInstance($id, $this->_board); if (!$article->hasEditPerm($u)) { $this->error(ECode::$ARTICLE_NOEDIT); } $atts = $article->getAttList(); $this->set("postUrl", "/{$article->ID}"); } catch (Exception $e) { $this->error(ECode::$ARTICLE_NONE); } } else { $atts = Forum::listAttach(); } return $atts; }
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)); }
public function delete() { if (!$this->RequestHandler->isPost()) { $this->error(ECode::$SYS_REQUESTERROR); } if (!isset($this->params['id'])) { $this->error(ECode::$ARTICLE_NONE); } $id = intval($this->params['id']); try { App::import('vendor', "model/article"); $article = Article::getInstance($id, $this->_board); } catch (ArticleNullException $e) { $this->error(ECode::$ARTICLE_NONE); } $u = User::getInstance(); if (!$article->hasEditPerm($u)) { $this->error(ECode::$ARTICLE_NODEL); } $wrapper = Wrapper::getInstance(); $this->set('data', $wrapper->article($article, array('content' => true))); if (!$article->delete()) { $this->error(ECode::$ARTICLE_NODEL); } }
public function delete() { if (!$this->RequestHandler->isPost()) { $this->error(ECode::$SYS_REQUESTERROR); } $this->_attOpInit(); $u = User::getInstance(); if (!isset($this->params['form']['name'])) { $this->error(ECode::$ATT_NAMEERROR); } $attName = strval($this->params['form']['name']); try { if (isset($this->params['id'])) { $id = $this->params['id']; $article = Article::getInstance($id, $this->_board); if (!$article->hasEditPerm($u)) { $this->error(ECode::$ARTICLE_NOEDIT); } $attNum = 0; foreach ($article->getAttList() as $k => $v) { if ($v['name'] == $attName) { $attNum = intval($k + 1); break; } } $article->delAttach($attNum); $article = Article::getInstance($id, $this->_board); } else { Forum::delAttach($attName); $article = Forum::listAttach(); } $wrapper = Wrapper::getInstance(); $this->set('data', $wrapper->attachment($article)); return; } catch (ArchiveAttException $e) { $msg = $e->getMessage(); } catch (AttException $e) { $msg = $e->getMessage(); } catch (Exception $e) { $this->error(); } }
public function classic() { $map = array("recommend" => array("commend.xml", "近期热点活动", "/board/recommend"), "bless" => array("bless.xml", "十大祝福", "/board/Blessing")); if (!isset($this->params['file'])) { $this->_stop(); } $key = strtolower(trim($this->params['file'])); if (!array_key_exists($key, $map)) { $this->_stop(); } $file = BBS_HOME . "/xml/" . $map[$key][0]; if (!file_exists($file)) { $this->_stop(); } $mTime = @filemtime($file); $this->cache(true, $mTime); $this->header("Content-Type: text/xml; charset=" . $this->encoding); $this->header("Content-Disposition: inline;filename={$key}.xml"); $this->_cache_read($key, $mTime); $channel = $items = array(); $channel['title'] = $map[$key][1]; $channel['description'] = $this->_siteName . $map[$key][1]; $channel['link'] = $this->_domain . $this->base . $map[$key][2]; $channel['language'] = "zh-cn"; $channel['generator'] = "nForum RSS Generator By xw"; if ($mTime > 0) { $channel['lastBuildDate'] = $mTime; } $ret = array(); $xml = simplexml_load_file($file); if ($xml == false) { return $ret; } foreach ($xml->hotsubject as $v) { $board = $v->o_board == "" ? $v->board : $v->o_board; $id = $v->o_groupid == 0 ? $v->groupid : $v->o_groupid; $link = $this->_domain . $this->base . '/article/' . $board . '/' . $id; $item = array("title" => nforum_fix_gbk(urldecode($v->title)), "link" => $link, "author" => $v->owner, "pubDate" => intval($v->time), "guid" => $link, "comments" => $link); try { $article = Article::getInstance(intval($v->groupid), Board::getInstance($v->board)); $item['description'] = "<![CDATA[" . XUBB::parse($article->getHtml()) . "]]>"; } catch (Exception $e) { } $items[] = $item; } $rss = new Rss($channel, $items); $out = $rss->getRss(); $this->_cache_write($key, $mTime, $out); echo $out; $this->_stop(); }