Beispiel #1
0
 public function index()
 {
     $type = MailBox::$IN;
     if (isset($this->params['type'])) {
         $type = $this->params['type'];
     }
     try {
         $mailBox = new MailBox(User::getInstance(), $type);
     } catch (MailBoxNullException $e) {
         $this->error(ECode::$MAIL_NOBOX);
     }
     $this->notice = '邮件-' . $mailBox->desc;
     $p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1;
     App::import('vendor', "inc/pagination");
     try {
         $pagination = new Pagination($mailBox, 10);
         $mails = $pagination->getPage($p);
     } catch (MailDataNullException $e) {
         $this->error(ECode::$MAIL_NOMAIL);
     }
     $info = false;
     if ($mailBox->getTotalNum() > 0) {
         App::import('Sanitize');
         foreach ($mails as $v) {
             $info[] = array("read" => $v->isRead(), "num" => $v->num, "sender" => $v->OWNER, "title" => Sanitize::html($v->TITLE), "time" => date("Y-m-d H:i:s", $v->POSTTIME), "size" => $v->EFFSIZE);
         }
     }
     $this->set("type", $type);
     $this->set("info", $info);
     $this->set("totalNum", $mailBox->getTotalNum());
     $this->set("curPage", $pagination->getCurPage());
     $this->set("totalPage", $pagination->getTotalPage());
 }
Beispiel #2
0
 public function ajax_session()
 {
     $this->cache(false);
     $static = Configure::read('site.static');
     $base = Configure::read('site.prefix');
     $user = User::getInstance();
     App::import('vendor', 'inc/wrapper');
     $wrapper = Wrapper::getInstance();
     $ret = $wrapper->user($user);
     $ret['is_login'] = $user->userid != 'guest';
     $ret['forum_totol_count'] = Forum::getOnlineNum();
     $ret['forum_user_count'] = Forum::getOnlineUserNum();
     $ret['forum_guest_count'] = Forum::getOnlineGuestNum();
     App::import("vendor", "model/mail");
     $info = MailBox::getInfo($user);
     $ret['new_mail'] = $info['newmail'];
     $ret['full_mail'] = $info['full'];
     if (Configure::read('refer.enable')) {
         App::import('vendor', 'model/refer');
         $ret['new_at'] = $ret['new_reply'] = false;
         try {
             if ($user->getCustom('userdefine1', 2)) {
                 $refer = new Refer($user, Refer::$AT);
                 $ret['new_at'] = $refer->getNewNum();
             }
             if ($user->getCustom('userdefine1', 3)) {
                 $refer = new Refer($user, Refer::$REPLY);
                 $ret['new_reply'] = $refer->getNewNum();
             }
         } catch (ReferNullException $e) {
         }
     }
     $this->set('no_html_data', $ret);
 }
 public function beforeRender()
 {
     if ($this->ByrSession->isLogin) {
         $u = User::getInstance();
         $login = true;
         $id = $u->userid;
         $isAdmin = $u->isAdmin();
         App::import("vendor", "model/mail");
         $info = MailBox::getInfo($u);
         $info['new_mail'] = $info['newmail'];
         $info['full_mail'] = $info['full'];
         $info['newAt'] = $info['newReply'] = false;
         if (Configure::read('refer.enable')) {
             App::import('vendor', 'model/refer');
             try {
                 if ($u->getCustom('userdefine1', 2)) {
                     $refer = new Refer($u, Refer::$AT);
                     $info['newAt'] = $refer->getNewNum();
                 }
                 if ($u->getCustom('userdefine1', 3)) {
                     $refer = new Refer($u, Refer::$REPLY);
                     $info['newReply'] = $refer->getNewNum();
                 }
             } catch (ReferNullException $e) {
             }
         }
         $this->set($info);
     } else {
         $login = false;
         $id = "guest";
         $isAdmin = false;
     }
     $this->_initAsset();
     $site = Configure::read("site");
     $this->set("domain", $site['domain']);
     $this->set("static", $site['static']);
     $this->set("siteName", $site['name'] . "手机版");
     $this->set("webTitle", empty($this->title) ? $site['name'] . "手机版" : $this->title);
     $this->set("encoding", $this->encoding);
     $this->set("home", $site['home']);
     $this->set("base", $this->base);
     $this->set("mbase", $this->base . $this->_mbase);
     $this->set("msg", ECode::msg($this->_msg));
     $this->set("pos", $this->notice);
     $this->set("css", $this->css);
     $this->set("islogin", $login);
     $this->set("id", $id);
     $this->set("isAdmin", $isAdmin);
 }
Beispiel #4
0
 public function ajax_delete()
 {
     if (!$this->RequestHandler->isPost()) {
         $this->error(ECode::$SYS_REQUESTERROR);
     }
     if (!isset($this->params['type'])) {
         $this->error(ECode::$MAIL_NOBOX);
     }
     $type = $this->params['type'];
     try {
         $box = new MailBox(User::getInstance(), $type);
     } catch (MailBoxNullException $e) {
         $this->error(ECode::$MAIL_NOBOX);
     }
     if (!isset($this->params['num'])) {
         if (isset($this->params['form']['all'])) {
             //delete all
             try {
                 $all = $box->getRecord(1, $box->getTotalNum());
                 foreach ($all as $mail) {
                     $mail->delete();
                 }
             } catch (Exception $e) {
                 continue;
             }
         } else {
             //delete normal
             foreach ($this->params['form'] as $k => $v) {
                 if (!preg_match("/m_/", $k)) {
                     continue;
                 }
                 $num = split("_", $k);
                 try {
                     $mail = Mail::getInstance($num[1], $box);
                     $mail->delete();
                 } catch (Exception $e) {
                     continue;
                 }
             }
         }
     } else {
         try {
             //delete single
             $num = $this->params['num'];
             $mail = Mail::getInstance($num, $box);
             if (!$mail->delete()) {
                 $this->error(ECode::$MAIL_DELETEERROR);
             }
         } catch (Exception $e) {
             $this->error(ECode::$MAIL_DELETEERROR);
         }
     }
     $ret['ajax_code'] = ECode::$MAIL_DELETEOK;
     $ret['default'] = "/mail/{$type}";
     $ret['list'][] = array("text" => $box->desc, "url" => "/mail/{$type}");
     $this->set('no_html_data', $ret);
 }
);
</script>
<script language="JavaScript" type="text/javascript" src="modules/Webmails/Webmails.js"></script>
<?php 
global $displayed_msgs;
// AJAX commands (should be moved)
if ($_POST["command"] == "move_msg" && $_POST["ajax"] == "true") {
    if (isset($_REQUEST["mailid"]) && $_REQUEST["mailid"] != '') {
        $mailids = explode(':', $_REQUEST["mailid"]);
    }
    foreach ($mailids as $mailid) {
        imap_mail_move($MailBox->mbox, $mailid, $_REQUEST["mvbox"]);
    }
    imap_expunge($MailBox->mbox);
    imap_close($MailBox->mbox);
    $MailBox = new MailBox($mailbox);
    $elist = $MailBox->mailList;
    $num_mails = $elist['count'];
    $start_page = ceil($num_mails / $MailBox->mails_per_page);
    imap_close($MailBox->mbox);
    echo "start=" . $start_page . ";";
    echo "id=" . $mailid . ";";
    flush();
    exit;
}
// Function to remove directories used for tmp attachment storage
function SureRemoveDir($dir)
{
    if (!($dh = @opendir($dir))) {
        return;
    }
Beispiel #6
0
 public function mailbox()
 {
     App::import("vendor", "model/mail");
     $ret = array();
     $info = MailBox::getInfo(User::getInstance());
     $ret['new_mail'] = $info['newmail'];
     $ret['full_mail'] = $info['full'];
     $ret['space_used'] = MailBox::getSpace() . 'KB';
     $ret['can_send'] = Mail::canSend();
     return $ret;
 }
Beispiel #7
0
 /**
  * function getInstance get a Mail object via $box & $num
  * suggest using this method to get a ref of mail
  *
  * @param int $num
  * @param MailBox $box
  * @return Mail object
  * @static
  * @access public
  * @throws MailNullException
  */
 public static function getInstance($num, $box)
 {
     $arr = array();
     if (bbs_get_records_from_num($box->getFullPath(), $num, $arr)) {
         return new Mail($arr[0], $box, $num);
     } else {
         throw new MailNullException();
     }
 }