public function download()
 {
     if (isset($this->params['hash'])) {
         $hash = str_replace(' ', '+', $this->params['hash']);
         $info = Forum::decodeAttHash($hash);
         $name = $info['bid'];
         $id = $info['id'];
         $pos = $info['ap'];
         $mode = $info['ftype'];
         $num = $info['num'];
     } else {
         if (isset($this->params['name']) && isset($this->params['id']) && isset($this->params['pos'])) {
             if ($this->ByrSession->Cookie->read("XWJOKE") == "" && Configure::read("article.att_check")) {
                 $this->error404(ECode::$SYS_NOFILE);
             }
             $name = $this->params['name'];
             $mode = '' == $this->params['mode'] ? Board::$THREAD : intval($this->params['mode']);
             $num = $id = intval($this->params['id']);
             $pos = intval($this->params['pos']);
             $type = $this->params['type'];
         } else {
             $this->error404(ECode::$SYS_NOFILE);
         }
     }
     $archive = null;
     App::import("vendor", "model/mail");
     try {
         if (in_array($name, get_class_vars("MailBox"))) {
             $this->requestLogin();
             $box = new MailBox(User::getInstance(), $name);
             $archive = Mail::getInstance($id, $box);
         } else {
             $board = Board::getInstance($name);
             $board->setMode($mode);
             if (!$board->isSortMode()) {
                 $id = $num;
             }
             if (!$board->hasReadPerm(User::getInstance())) {
                 $this->error404(ECode::$SYS_NOFILE);
             }
             $archive = Article::getInstance($id, $board);
             $file = $archive->getFileName();
             if ($board->isNormal()) {
                 $this->cache(true, @filemtime($file));
             }
         }
     } catch (Exception $e) {
         $this->error404(ECode::$SYS_NOFILE);
     }
     //check thumbnail
     if (!empty($type)) {
         $this->Thumbnail->archive($type, $archive, $pos);
     }
     $archive->getAttach($pos);
     $this->_stop();
 }
Example #2
0
 public function sendConfirmation($userAttr)
 {
     $mail = Mail::getInstance();
     $mail->setTo($userAttr['email']);
     $mail->setFrom();
     $mail->setSubject('Your account is created succussful');
     $view = new View(HOME . DS . 'views' . DS . 'confirm.tpl');
     $view->set('user', $userAttr);
     $view->set('url', APP_URL . '/activate.php?token=' . $userAttr['confirmation_code']);
     $mail->setTemplate($view->content());
     return $mail->send();
 }
 public function download()
 {
     if (!isset($this->params['name']) || !isset($this->params['id']) || !isset($this->params['pos'])) {
         $this->error(ECode::$SYS_NOFILE);
     }
     $name = $this->params['name'];
     $mode = '' == $this->params['mode'] ? Board::$THREAD : intval($this->params['mode']);
     $id = $this->params['id'];
     $pos = $this->params['pos'];
     $type = $this->params['type'];
     $archive = null;
     App::import("vendor", "model/mail");
     try {
         if (in_array($name, get_class_vars("MailBox"))) {
             $this->requestLogin();
             $box = new MailBox(User::getInstance(), $name);
             $archive = Mail::getInstance($id, $box);
         } else {
             $board = Board::getInstance($name);
             $board->setMode($mode);
             if (!$board->hasReadPerm(User::getInstance())) {
                 $this->error(ECode::$SYS_NOFILE);
             }
             $archive = Article::getInstance($id, $board);
             $file = $archive->getFileName();
             if ($board->isNormal()) {
                 $this->cache(true, @filemtime($file));
             }
         }
     } catch (Exception $e) {
         $this->error(ECode::$SYS_NOFILE);
     }
     //check thumbnail
     if (!empty($type)) {
         $this->Thumbnail->archive($type, $archive, $pos);
     }
     $archive->getAttach($pos);
     $this->_stop();
 }
Example #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);
 }
Example #5
0
 /**
  * ajaxRegister
  * 
  * @param  array $postData
  * @return mix
  */
 public function ajaxRegister($postData)
 {
     $validator = new Validator();
     $user = User::getInstance();
     $validator->addValidation('first_name', 'req', 'Please fill in first name');
     $validator->addValidation('last_name', 'req', 'Please fill in last name');
     $validator->addValidation('email', 'req', 'Please fill in email');
     $validator->addValidation('email', 'email', 'The input for Email should be a valid email value');
     $validator->addValidation('password', 'req', 'Please fill in password');
     $validator->addValidation('password', 'eqelmnt=confirm_password');
     if ($user->findByEmail($postData['email'])) {
         return $this->_response('', 1, 'Email already taken in system');
     }
     if (!$validator->validate()) {
         $errorHash = $validator->GetErrors();
         foreach ($errorHash as $input => $error) {
             return $this->_response('', 1, $error);
             break;
         }
     } else {
         $postData['password'] = md5($postData['password']);
         $postData['confirmation_code'] = Util::generateConfirmCode();
         if ($uid = $user->save($postData)) {
             $mail = Mail::getInstance();
             $mail->sendConfirmation($user->find($uid));
             return $this->_response('', 0, 'Your account is created succussful, please check your inbox (or spam box) and confirm your email to continue');
         }
     }
     return $this->_response('', 1, 'Oops! try again');
 }
Example #6
0
 public function delete()
 {
     if (!$this->RequestHandler->isPost()) {
         $this->error(ECode::$SYS_REQUESTERROR);
     }
     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);
         $wrapper = Wrapper::getInstance();
         $data = $wrapper->mail($mail);
         if (!$mail->delete()) {
             $this->error(ECode::$MAIL_DELETEERROR);
         }
     } catch (MailBoxNullException $e) {
         $this->error(ECode::$MAIL_NOBOX);
     } catch (MailNullException $e) {
         $this->error(ECode::$MAIL_NOMAIL);
     } catch (Exception $e) {
         $this->error(ECode::$MAIL_DELETEERROR);
     }
     $this->set('data', $data);
 }
     $message = "Information required is not complete!";
 } else {
     $username = $_POST['username'];
     $password = md5($_POST['password']);
     $firstname = $_POST['firstname'];
     $lastname = $_POST['lastname'];
     $email = $_POST['email'];
     $phone_number = $_POST['phone'];
     $fields = array('username' => $username, 'password' => $password, 'firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'phone_number' => $phone_number);
     try {
         $user = new User();
         $user->create($fields);
         $success = true;
         $message = 'Welcome to sign up with FineTable :)';
         // Send welcome email
         $mail = Mail::getInstance();
         $mailto = $_POST['email'];
         $subject = 'Welcome to FineTable!';
         $body = '
             <div class="mail-body" style="padding: 20px; border: 5px solid rgb(254, 127, 65); border-radius: 4px; margin: 0 auto; width: 90%;">
                 <p>Hello ' . $firstname . ',</p>
                 <p>Thank you for joining FineTable. We will do our best to help you find the best restaurant for you!.</p>
                 <p>Click <a href="http://sfsuswe.com/~f15g06" target="_blank">FineTable</a> to start look for restaurant!</p>
                 <p>Thank you!</p>
                 <p>FineTable team</p>
             </div>
             ';
         $mail->add_mailto($mailto);
         $mail->add_subject($subject);
         $mail->add_body($body);
         $mail->send();
Example #8
0
 public function delete()
 {
     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);
     } catch (MailBoxNullException $e) {
         $this->error(ECode::$MAIL_NOBOX);
     }
     try {
         $mail = Mail::getInstance($num, $box);
         if (!$mail->delete()) {
             $this->error(ECode::$MAIL_DELETEERROR);
         }
     } catch (Exception $e) {
         $this->error(ECode::$MAIL_DELETEERROR);
     }
     $this->redirect($this->_mbase . "/mail/{$type}?m=" . ECode::$MAIL_DELETEOK);
 }