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'); }
public function ajax_single() { if (!isset($this->params['id'])) { $this->error(ECode::$ARTICLE_NONE); } $id = $this->params['id']; try { $article = Article::getInstance($id, $this->_board); } catch (ArticleNullException $e) { $this->error(ECode::$ARTICLE_NONE); } App::import('vendor', 'inc/wrapper'); $wrapper = Wrapper::getInstance(); $ret = $wrapper->article($article, array('single' => true, 'content' => false)); $u = User::getInstance(); $ret['allow_post'] = $this->_board->hasPostPerm($u); $ret['is_bm'] = $u->isBM($this->_board) || $u->isAdmin(); $content = $article->getHtml(true); if (Configure::read("ubb.parse")) { //remove ubb of nickname in first and title second line preg_match("'^(.*?<br \\/>.*?<br \\/>)'", $content, $res); $content = preg_replace("'(^.*?<br \\/>.*?<br \\/>)'", '', $content); $content = XUBB::remove($res[1]) . $content; $content = XUBB::parse($content); } $ret['content'] = $content; $this->set('no_html_data', $ret); }
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 post() { if ($this->_board->isReadOnly()) { $this->error(ECode::$BOARD_READONLY); } if (!$this->_board->hasPostPerm(User::getInstance())) { $this->error(ECode::$BOARD_NOPOST); } $article = false; if (isset($this->params['gid'])) { $reID = (int) $this->params['gid']; if ($this->_board->isNoReply()) { $this->error(ECode::$BOARD_NOREPLY); } try { $article = Article::getInstance($reID, $this->_board); } catch (ArticleNullException $e) { $this->error(ECode::$ARTICLE_NOREID); } if ($article->isNoRe()) { $this->error(ECode::$ARTICLE_NOREPLY); } } else { if ($this->_board->isTmplPost()) { $this->error(ECode::$TMPL_ERROR); } $reID = 0; } $single = isset($this->params['url']['s']) || isset($this->params['form']['s']); if ($this->RequestHandler->isPost()) { if (!isset($this->params['form']['subject'])) { $this->error(ECode::$POST_NOSUB); } if (!isset($this->params['form']['content'])) { $this->error(ECode::$POST_NOCON); } $subject = trim($this->params['form']['subject']); $content = trim($this->params['form']['content']); $subject = nforum_iconv($this->encoding, $this->appEncoding, $subject); $content = nforum_iconv($this->encoding, $this->appEncoding, $content); $subject = rawurldecode($subject); $sig = User::getInstance()->signature; $email = 0; $anony = null; $outgo = 0; if (isset($this->params['form']['email'])) { $email = 1; } if (isset($this->params['form']['anony']) && $this->_board->isAnony()) { $anony = 1; } if (isset($this->params['form']['outgo']) && $this->_board->isOutgo()) { $outgo = 1; } try { if (false === $article) { Article::post($this->_board, $subject, $content, $sig, $email, $anony, $outgo); } else { $article->reply($subject, $content, $sig, $email, $anony, $outgo); } } catch (ArticlePostException $e) { $this->error($e->getMessage()); } $this->redirect($this->_mbase . "/board/" . $this->_board->NAME . ($single ? "/0" : "") . "?m=" . ECode::$POST_OK); } else { $reTitle = $reContent = ""; if ($reID != 0) { $this->notice = "{$this->_board->DESC}-回复"; $reContent = "\n" . $article->getRef(); //remove ref ubb tag $reContent = XUBB::remove($reContent); if (!strncmp($article->TITLE, "Re: ", 4)) { $reTitle = $article->TITLE; } else { $reTitle = "Re: " . $article->TITLE; } } else { $this->notice = "{$this->_board->DESC}-发表"; } } $this->set("single", $single); $this->set("bName", $this->_board->NAME); $this->set("email", true); $this->set("anony", $this->_board->isAnony()); $this->set("outgo", $this->_board->isOutgo()); $this->set("title", (string) $reTitle); $this->set("content", (string) $reContent); $this->set("reid", $reID); }
public function setSignature($signature) { App::import("vendor", "inc/ubb"); $fileName = $this->getHome("signatures"); $fp = @fopen($fileName, "w+"); if ($fp != false) { fwrite($fp, str_replace("\r\n", "\n", XUBB::remove($signature))); fclose($fp); bbs_recalc_sig(); } }