public function show()
{
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 {
$box = new MailBox(User::getInstance(), $type);
$mail = Mail::getInstance($num, $box);
} catch (Exception $e) {
$this->error(ECode::$MAIL_NOMAIL);
}
$this->notice = $box->desc . "-阅读邮件";
$mail->setRead();
$content = $mail->getHtml();
preg_match("|来 源:[\\s]*([0-9a-zA-Z.:*]+)|", $content, $f);
$f = empty($f) ? "" : "<br />FROM {$f[1]}";
$s = ($pos = strpos($content, "<br/><br/>")) === false ? 0 : $pos + 10;
$e = ($pos = strpos($content, "<br/>--<br/>")) === false ? strlen($content) : $pos + 7;
$content = substr($content, $s, $e - $s) . $f;
if (Configure::read("ubb.parse")) {
$content = XUBB::parse($content);
}
App::import("Sanitize");
$this->set("type", $type);
$this->set("num", $mail->num);
$this->set("title", Sanitize::html($mail->TITLE));
$this->set("sender", $mail->OWNER);
$this->set("time", date("Y-m-d H:i:s", $mail->POSTTIME));
$this->set("content", $content);
}