예제 #1
0
 protected function returnResult()
 {
     if (Request::isAjax()) {
         Responder::sendJSON(array());
     }
     Responder::redirectToPage();
 }
예제 #2
0
 protected function main()
 {
     d('cp');
     $o = new RegBlockQuickReg($this->Registry);
     $s = $o->getBlock();
     $aRet = array('quickreg' => $s);
     Responder::sendJSON($aRet);
 }
예제 #3
0
 protected function returnResult()
 {
     if (Request::isAjax()) {
         $ret = array('alert' => '@@Approved@@');
         $ret['reload'] = 1000;
         Responder::sendJSON($ret);
         exit;
     }
     Responder::redirectToPage();
 }
예제 #4
0
    protected function returnResult()
    {
        /**
         * @todo translate string
         */
        $message = '@@Question closed@@';
        $requested = 'A request to close
		this question has been sent to moderators<br>
		The final decision about closing the question or leaving it open will be up to moderators';
        if (Request::isAjax()) {
            $res = !$this->requested ? $message : $requested;
            $ret = array('alert' => $res);
            /**
             * If item was actually deleted then
             * add 'reload' => 2 to return
             * which will cause page reload
             * in 1.5 seconds.
             */
            if (!$this->requested) {
                $ret['reload'] = 1500;
            }
            Responder::sendJSON($ret);
        }
        Responder::redirectToPage($this->Resource->getUrl());
    }
예제 #5
0
 /**
  * Get paginated and sorted block with user
  * Answers and returl via XHR
  *
  */
 protected function getAnswers()
 {
     d('getting answers block');
     $s = \Lampcms\UserAnswers::get($this->Registry, $this->User);
     Responder::sendJSON(array('replace' => array('target' => 'useranswers', 'content' => $s)));
 }
예제 #6
0
 protected function main()
 {
     $this->setApi();
     $email = $this->Registry->Viewer->email;
     $this->Form = new \Lampcms\Forms\Apiclient($this->Registry);
     if ($this->Form->isSubmitted() && $this->Form->validate()) {
         d('$this->oApi: ' . print_r($this->oApi->getArrayCopy(), 1));
         $this->save();
         $this->Registry->Dispatcher->post($this->Form, 'onApiClientSave');
         $url = '/index.php?a=viewapp&app_id=' . $this->oApi['_id'];
         Responder::redirectToPage($url);
     } else {
         $this->setForm();
         $this->aPageVars['body'] = $this->Form->getForm();
     }
 }
예제 #7
0
 /**
  *
  */
 protected function main()
 {
     if (!Request::isAjax()) {
         e('Tweet called as non-ajax');
         throw new \Lampcms\Exception('This page can only be accessed using XHR request (ajax)');
     }
     try {
         $oTwitter = new Twitter($this->Registry);
         $aResponse = $oTwitter->prepareAndPost($this->Request->getUTF8('tweet'));
         Responder::sendJSON(array('tweet' => 'done'));
     } catch (\Lampcms\Exception $e) {
         e('Unable to post message to Twitter: ' . $e->getFile() . ' line: ' . $e->getLine() . ' ' . $e->getMessage());
         Responder::sendJSON(array('tweet' => 'error'));
     }
 }
예제 #8
0
        }
        fastcgi_finish_request();
    } catch (\Exception $e) {
        session_write_close();
        header("HTTP/1.0 500 Exception");
        try {
            /**
             * @mail must be here before the Lampcms\Exception::formatException
             * because Lampcms\Exception::formatException in case of ajax request will
             * send out ajax and then throw \OutOfBoundsException in order to finish request (better than exit())
             */
            if (defined('LAMPCMS_DEVELOPER_EMAIL') && strlen(trim(constant('LAMPCMS_DEVELOPER_EMAIL'))) > 7) {
                @mail(LAMPCMS_DEVELOPER_EMAIL, '500 Error in index.php', $sHtml . $extra);
            }
            $sHtml = \Lampcms\Responder::makeErrorPage('<strong>Error:</strong> ' . Lampcms\Exception::formatException($e));
            $extra = isset($_SERVER) ? ' $_SERVER: ' . print_r($_SERVER, 1) : ' no server';
            $extra .= 'file: ' . $e->getFile() . ' line: ' . $e->getLine() . ' trace: ' . $e->getTraceAsString();
            echo $sHtml;
        } catch (\OutOfBoundsException $e2) {
            // do nothing, this was a way to exit() from Responder::sendJSON()
        } catch (\Exception $e2) {
            $sHtml = \Lampcms\Responder::makeErrorPage('<strong>Exception:</strong> ' . strip_tags($e2->getMessage()) . "\nIn file:" . $e2->getFile() . "\nLine: " . $e2->getLine());
            $extra = isset($_SERVER) ? ' $_SERVER: ' . print_r($_SERVER, 1) : ' no extra';
            if (defined('LAMPCMS_DEVELOPER_EMAIL') && strlen(trim(constant('LAMPCMS_DEVELOPER_EMAIL'))) > 7) {
                @mail(LAMPCMS_DEVELOPER_EMAIL, 'Error in index.php on line ' . __LINE__, $sHtml . $extra);
            }
            echo $sHtml;
        }
        fastcgi_finish_request();
    }
}
예제 #9
0
 protected function processForm()
 {
     $formData = $this->Registry->Request->getArray();
     if (!empty($_FILES)) {
         $formData['files'] = $_FILES;
     }
     $Notification = $this->Registry->Dispatcher->post($this, 'onBeforeCategoryEdit', array('data' => $formData));
     if (!$Notification->isNotificationCancelled()) {
         try {
             $this->checkAccessPermission('edit_category');
             $canEdit = true;
         } catch (\Exception $e) {
             $canEdit = false;
         }
         /**
          * @todo when YUI 3.5.0 is released with fixed
          * upload-iframe or even better with XHR2 with upload support
          * we will either return a page with json here (in case of iframe)
          * or just add processing of uploaded file.
          */
         d('before start of Editor');
         if (Request::isAjax()) {
             d('sending out ajax');
             $Editor = new \Lampcms\Category\Editor($this->Registry);
             $aRes = $Editor->saveCategory(new \Lampcms\Category\SubmittedWWW($this->Registry->Request), $canEdit);
             $aRes = \array_diff_key($aRes, array('i_parent' => 1, 'a_subs' => 1));
             d('aRes: ' . print_r($aRes, 1));
             Responder::sendJSON(array('category' => $aRes));
         }
     } else {
         $message = '@@One of the Observers cancelled the onBeforeCategoryEdit event@@';
         d($message);
         Responder::sendJSON(array('alert' => $message));
     }
     return '@@Category data saved@@';
 }
예제 #10
0
 /**
  * Return array of resourceID, type (A or Q)
  * and parsed div with comment
  *
  *
  */
 protected function returnResult()
 {
     $aComment = $this->CommentParser->getArrayCopy();
     /**
      * Add edit and delete tools because
      * Viewer already owns this comment and is
      * allowed to edit or delete it right away.
      * Javascript that usually dynamically adds these tools
      * is not going to be fired, so these tools
      * must alreayd be included in the returned html
      *
      */
     $aComment['edit_delete'] = '  <span class="ico del ajax" title="Delete">delete</span> <span class="ico edit ajax" title="Edit">edit</span>';
     /**
      * Important to add owner_id key
      * because it's not in the comment array
      * It is used when creating the 'reply' link
      * in the tplComment
      * That ID is then used when figuring out if
      * viewer has permission to add comment.
      * Users with low reputation still always have
      * premission to add comments to own resources.
      * 
      */
     $aComment['owner_id'] = $this->Resource->getOwnerId();
     $aRet = array('comment' => array('id' => $aComment['_id'], 'res' => $aComment['i_res'], 'parent' => $aComment['i_prnt'], 'html' => \tplComment::parse($aComment)));
     Responder::sendJSON($aRet);
 }
예제 #11
0
 /**
  * Send Ajax based reponse
  * 
  */
 protected function respond()
 {
     $aRet = array('setmeta' => array('key' => 'fb', 'val' => '1'), 'replace' => array('target' => 'my_fb', 'content' => $this->Registry->Viewer->getFacebookUrl()));
     d('sending out JSON: ' . print_r($aRet, 1));
     Responder::sendJSON($aRet);
 }
예제 #12
0
 /**
  * Main entry point
  * (non-PHPdoc)
  *
  * @see WebPage::main()
  */
 protected function main()
 {
     $this->qid = $this->Router->getNumber(1, null, $this->Registry->Ini['URI_PARTS']['QID_PREFIX']);
     if (Request::isAjax()) {
         $this->getQuestion()->getAnswers();
         Responder::sendJSON(array('paginated' => $this->answers));
     }
     $this->pageID = $this->Router->getPageID();
     $this->tab = $this->Registry->Request->get('sort', 's', 'i_lm_ts');
     $this->Registry->registerObservers();
     $this->getQuestion()->validateSlug()->addMetas()->sendCacheHeaders()->configureEditor()->setTitle()->addMetaTags()->setAnswersHeader()->getAnswers()->setAnswers()->setSimilar()->makeForm()->setAnswerForm()->makeFollowButton()->setFollowersBlock()->setQuestionInfo()->setFooter()->increaseView()->makeTopTabs();
     $this->Registry->Dispatcher->post($this->Question, 'onQuestionView');
 }
예제 #13
0
 protected function returnResult()
 {
     /**
      * @todo translate string
      */
     $message = 'Topic retagged successfully';
     if (Request::isAjax()) {
         $ret = array('reload' => 100);
         //'alert' => $message,
         Responder::sendJSON($ret);
     }
     Responder::redirectToPage($this->Question->getUrl());
 }
예제 #14
0
 /**
  * Step 2 in oAuth process
  * this is when tumblr redirected the user back
  * to our callback url, which calls this controller
  *
  * @throws \Exception in case something goes wrong with oAuth class
  * @return object $this
  */
 protected function step2()
 {
     try {
         /**
          * This is a callback (redirected back from tumblr page
          * after user authorized us)
          * In this case we must: create account or update account
          * in USER table
          * Re-create oViewer object
          * send cookie to remember user
          * and then send out HTML with js instruction to close the popup window
          */
         d('Looks like we are at step 2 of authentication. Request: ' . \json_encode($_REQUEST));
         /**
          * @todo check first to make sure we do have oauth_token
          * on REQUEST, else close the window
          */
         $this->oAuth->setToken($this->Request['oauth_token'], $_SESSION['tumblr_oauth']['oauth_token_secret']);
         $this->aAccessToken = $this->oAuth->getAccessToken(self::ACCESS_TOKEN_URL);
         d('$this->aAccessToken: ' . \json_encode($this->aAccessToken));
         unset($_SESSION['tumblr_oauth']);
         $this->oAuth->setToken($this->aAccessToken['oauth_token'], $this->aAccessToken['oauth_token_secret']);
         /**
          * Now getUserBlogs
          * Then if user has more than one blog
          * display a form with "select blog"
          * + description about it
          *
          * Make sure to run connect() first so that oViewer['tumblr']
          * element will be created and will have all user blogs
          *
          *
          * Else - user has just one blog then close Window!
          *
          */
         d('cp');
         $this->getUserBlogs()->connect();
         d('cp');
         /**
          * If user has more than one blog
          * then show special form
          */
         if (count($this->aBlogs) > 1) {
             d('User has more than one blog, generating "select blog" form');
             $form = $this->makeBlogSelectionForm();
             d('$form: ' . $form);
             exit(Responder::makeErrorPage($form));
         } else {
             d('User has one tumblr blog, using it now');
             /**
              * Set flag to session indicating that user just
              * connected tumblr Account
              */
             $this->Registry->Viewer['b_tm'] = true;
             $this->closeWindow();
         }
     } catch (\OAuthException $e) {
         e('OAuthException: ' . $e->getMessage() . ' ' . \print_r($e, 1));
         $err = '@@Something went wrong during authorization. Please try again later@@' . $e->getMessage();
         throw new \Exception($err);
     }
     return $this;
 }
예제 #15
0
 protected function main()
 {
     $this->pageID = $this->Registry->Router->getPageID();
     $this->init()->getCursor()->paginate()->renderUsersHtml();
     /**
      * In case of Ajax request, just return
      * the content of the usersHtml
      * and don't proceed any further
      */
     if (Request::isAjax()) {
         Responder::sendJSON(array('paginated' => $this->usersHtml));
     }
     $this->setTitle()->makeSortTabs()->makeTopTabs()->setUsers();
 }
예제 #16
0
 /**
  *
  */
 protected function validateCaptcha()
 {
     if (!empty($_SESSION['reg_captcha'])) {
         return $this;
     }
     $oCaptcha = Captcha::factory($this->Registry->Ini);
     $res = $oCaptcha->validate_submit();
     /**
      * If validation good then
      * all is OK
      */
     if (1 === $res) {
         $_SESSION['reg_captcha'] = true;
         return $this;
     }
     /**
      * If 3 then reached the limit of attampts
      */
     if (3 === $res) {
         throw new \Lampcms\CaptchaLimitException('You have reached the limit of image verification attempts');
     }
     if (Request::isAjax()) {
         $aRet = array('exception' => self::CAPTCHA_ERROR, 'fields' => array('private_key'), 'captcha' => $oCaptcha->getCaptchaArray());
         \Lampcms\Responder::sendJSON($aRet);
     }
     /**
      * @todo translate string
      */
     $this->setFormError(self::CAPTCHA_ERROR);
     return $this;
 }
예제 #17
0
 /**
  * Set error message for the form as a whole.
  * This error message is not specific to any form field,
  * it usually appears on top of form as a general error message
  *
  * For example: You must wait 5 minutes between posting
  * This is not due to any element error, just a general error
  * message.
  *
  * The form template MUST have 'formError' variable in it!
  *
  * @param string $errMessage
  *
  * @return \Lampcms\Forms\Form
  */
 public function setFormError($errMessage)
 {
     if (Request::isAjax()) {
         \Lampcms\Responder::sendJSON(array('formError' => $errMessage));
     } else {
         $this->aErrors['formError'][] = $errMessage;
     }
     return $this;
 }
예제 #18
0
 /**
  * Main entry point
  * (non-PHPdoc)
  * @see WebPage::main()
  */
 protected function main()
 {
     if (Request::isAjax()) {
         $this->getQuestion()->getAnswers();
         Responder::sendJSON(array('paginated' => $this->answers));
     }
     $this->pageID = $this->Registry->Request->get('pageID', 'i', 1);
     $this->tab = $this->Registry->Request->get('sort', 's', 'i_lm_ts');
     $this->Registry->registerObservers();
     $this->getQuestion()->addMetas()->sendCacheHeaders()->configureEditor()->setTitle()->addMetaTags()->setAnswersHeader()->getAnswers()->setAnswers()->setSimilar()->makeForm()->setAnswerForm()->makeFollowButton()->setFollowersBlock()->setQuestionInfo()->setFooter()->increaseView()->makeTopTabs();
     $this->Registry->Dispatcher->post($this->Question, 'onQuestionView');
 }
예제 #19
0
 protected function returnResult()
 {
     $message = '@@Thank you for caring!<br>Moderators have been notified@@';
     if (Request::isAjax()) {
         Responder::sendJSON(array('alert' => $message));
     }
     Responder::redirectToPage($this->Resource->getUrl());
 }
예제 #20
0
 /**
  *
  */
 protected function validateCaptcha()
 {
     if (!empty($_SESSION['reg_captcha'])) {
         return $this;
     }
     $oCaptcha = Captcha::factory($this->Registry->Ini);
     $res = $oCaptcha->validate_submit();
     /**
      * If validation good then
      * all is OK
      */
     if (1 === $res) {
         $_SESSION['reg_captcha'] = true;
         return $this;
     }
     /**
      * If 3 then reached the limit of attempts
      */
     if (3 === $res) {
         throw new \Lampcms\CaptchaLimitException('@@You have reached the limit of image verification attempts@@');
     }
     $aRet = array('exception' => '@@Incorrect image verification text@@<br/>@@Please try again@@', 'fields' => array('private_key'), 'captcha' => $oCaptcha->getCaptchaArray());
     Responder::sendJSON($aRet);
 }
    /**
     * Add Twitter credentials to existing user
     *
     * @return $this
     */
    protected function connect($tid)
    {
        $aUser = $this->getUserByTid($tid);
        d('$aUser: '******'_id'] != $this->User->getUid()) {
            $name = '';
            if (!empty($aUser['fn'])) {
                $name .= $aUser['fn'];
            }
            if (!empty($aUser['ln'])) {
                $name .= ' ' . $aUser['fn'];
            }
            $trimmed = \trim($name);
            $name = !empty($trimmed) ? \trim($name) : $aUser['username'];
            /**
             * This error message will appear inside the
             * Small extra browser Window that Login with Twitter
             * opens
             *
             */
            $err = '<div class="larger"><p>This Twitter account is already connected to
			another registered user: <strong>' . $name . '</strong><br>
			<br>
			A Twitter account cannot be associated with more than one account on this site<br>
			If you still want to connect Twitter account to this account you must use a different Twitter account</p>';
            $err .= '<br><br>
			<input type="button" class="btn-m" onClick="window.close();" value="&nbsp;OK&nbsp;">&nbsp;
			<input type="button"  class="btn-m" onClick="window.close();" value="&nbsp;Close&nbsp;">
			</div>';
            $s = Responder::makeErrorPage($err);
            echo $s;
            exit;
        }
        $this->updateUser(false);
    }
예제 #22
0
 /**
  * Based on value of email address in the data received
  * from Google API
  * Login existing user or create a new account
  * and login the new user
  *
  */
 protected function createOrUpdate()
 {
     $User = null;
     $this->email = \mb_strtolower($this->userInfo['email']);
     /**
      * @todo this can be refactored for php 5.4
      * Search EMAILS collection
      * try to find user that has this email address
      */
     $res = $this->Registry->Mongo->EMAILS->findOne(array(Schema::EMAIL => $this->email), array('i_uid' => true));
     if (!empty($res) && !empty($res['i_uid'])) {
         d('found user id by email address. uid: ' . $res['i_uid']);
         $aUser = $this->Registry->Mongo->USERS->findOne(array(Schema::PRIMARY => $res['i_uid']));
         $User = User::userFactory($this->Registry, $aUser);
         $this->updateUser($User);
     }
     /**
      * Was Not able to find user by search EMAILS collection
      * Search USERS collection by email address
      */
     if (null === $User) {
         $a = $this->Registry->Mongo->USERS->findOne(array(Schema::EMAIL => $this->email));
         if (!empty($a)) {
             d('found user id by email address. uid: ' . $a['_id']);
             $User = User::userFactory($this->Registry, $a);
             $this->updateUser($User);
         }
     }
     if (null === $User) {
         $User = $this->createUser();
     }
     try {
         $this->processLogin($User);
         Cookie::sendLoginCookie($User->getUid(), $User->rs);
         $this->Registry->Dispatcher->post($this, 'onGoogleLogin');
         $this->closeWindow();
     } catch (\Lampcms\LoginException $e) {
         /**
          * re-throw as regular exception
          * so that it can be caught and shown in popup window
          */
         e('Unable to process login: ' . $e->getMessage());
         exit(\Lampcms\Responder::makeErrorPage($e->getMessage()));
     }
 }
 /**
  * Step 2 in oAuth process
  * this is when Blogger redirected the user back
  * to our callback url, which calls this controller
  * @return object $this
  *
  * @throws Exception in case something goes wrong with oAuth class
  */
 protected function step2()
 {
     try {
         /**
          * This is a callback (redirected back from Blogger page
          * after user authorized us)
          * In this case we must: create account or update account
          * in USER table
          * Re-create oViewer object
          * send cookie to remember user
          * and then send out HTML with js instruction to close the popup window
          */
         d('Looks like we are at step 2 of authentication. Request: ' . print_r($_REQUEST, 1));
         /**
          * @todo check first to make sure we do have oauth_token
          * on REQUEST, else close the window
          */
         $this->oAuth->setToken($this->Request['oauth_token'], $_SESSION['blogger_oauth']['oauth_token_secret']);
         $ver = $this->Registry->Request['oauth_verifier'];
         d(' $ver: ' . $ver);
         $url = self::ACCESS_TOKEN_URL . '?oauth_verifier=' . $ver;
         d('url: ' . $url);
         $this->aAccessToken = $this->oAuth->getAccessToken(self::ACCESS_TOKEN_URL);
         d('$this->aAccessToken: ' . print_r($this->aAccessToken, 1));
         unset($_SESSION['blogger_oauth']);
         $this->oAuth->setToken($this->aAccessToken['oauth_token'], $this->aAccessToken['oauth_token_secret']);
         /**
          * Now getUserBlogs
          * Then if user has more than one blog
          * display a form with "select blog"
          * + description about it
          *
          * Make sure to run connect() first so that oViewer['Blogger']
          * element will be created and will have all user blogs
          *
          * Else - user has just one blog then close Window!
          *
          */
         d('cp');
         $this->getUserBlogs()->connect();
         d('cp');
         /**
          * If user has more than one blog
          * then show special form
          */
         if (count($this->aBlogs) > 1) {
             d('User has more than one blog, generating "select blog" form');
             $form = $this->makeBlogSelectionForm();
             d('$form: ' . $form);
             echo Responder::makeErrorPage($form);
             throw new \OutOfBoundsException();
         } else {
             d('User has one Blogger blog, using it now');
             /**
              * Set flag to session indicating that user just
              * connected Blogger Account
              */
             $this->Registry->Viewer['b_bg'] = true;
             $this->closeWindow();
         }
     } catch (\OAuthException $e) {
         $aDebug = $this->oAuth->getLastResponseInfo();
         /**
          * Always check for response code first!
          * it must be 201 or it's no good!
          *
          * Also check the 'url' part of it
          * if it does not match url you used
          * in request then it was redirected!
          */
         e('OAuthException: ' . $e->getMessage() . ' in file ' . $e->getFile() . ' on line: ' . $e->getLine() . ' Debug: ' . print_r($aDebug, 1));
         $err = 'Something went wrong during authorization. Please try again later. ' . $e->getMessage();
         throw new \Exception($err);
     }
     return $this;
 }
예제 #24
0
 /**
  * Process submitted Answer
  *
  * @return void
  */
 protected function process()
 {
     $formVals = $this->Form->getSubmittedValues();
     d('formVals: ' . print_r($formVals, 1));
     $oAdapter = new AnswerParser($this->Registry);
     try {
         $Answer = $oAdapter->parse(new SubmittedAnswerWWW($this->Registry, $formVals));
         d('cp created new answer: ' . \print_r($Answer->getArrayCopy(), 1));
         d('ans id: ' . $Answer->getResourceId());
         /**
          * In case of ajax we need to send out a
          * parsed html block with one answer
          * under the 'answer' key
          *
          * In case of non-ajax redirect back to question page,
          * hopefully the new answer will show up there too
          */
         if (Request::isAjax()) {
             $aAnswer = $Answer->getArrayCopy();
             /**
              * Add edit and delete tools because
              * Viewer already owns this comment and is
              * allowed to edit or delete it right away.
              * Javascript that usually dynamically adds these tools
              * is not going to be fired, so these tools
              * must already be included in the returned html
              *
              */
             $aAnswer['edit_delete'] = ' <span class="ico del ajax" title="@@Delete@@">@@delete@@</span>  <span class="ico edit ajax" title="@@Edit@@">@@edit@@</span>';
             $a = array('answer' => \tplAnswer::parse($aAnswer));
             d('before sending out $a: ' . print_r($a, 1));
             Responder::sendJSON($a);
         } else {
             Responder::redirectToPage($this->Question->getUrl());
         }
     } catch (\Lampcms\AnswerParserException $e) {
         d('Got AnswerParserException ' . $e->getMessage());
         /**
          * The setFormError in Form sends our json in
          * case of Ajax request, so we don't have to
          * worry about it here
          */
         $this->Form->setFormError($e->getMessage());
         $this->showFormWithErrors();
     }
 }
 /**
  * Main entry point
  * (non-PHPdoc)
  * @see WebPage::main()
  */
 protected function main()
 {
     if (Request::isAjax()) {
         $this->getQuestion()->getAnswers();
         Responder::sendJSON(array('paginated' => $this->answers));
     }
     $this->pageID = $this->Registry->Request->get('pageID', 'i', 1);
     $this->Registry->registerObservers();
     $this->getQuestion();
     /**
      * Make sorting order: oldest=>newest for topics
      * without tag `question'
      */
     if (!in_array('question', $this->Question['a_tags'])) {
         $this->Registry->Request['sort'] = 'i_ts';
         $this->withQuestionTag = false;
     }
     $this->tab = $this->Registry->Request->get('sort', 's', 'i_lm_ts');
     $this->addMetas()->sendCacheHeaders()->configureEditor()->setTitle()->addMetaTags()->setAnswersHeader()->getAnswers()->setAnswers()->setSimilar()->makeForm()->setAnswerForm()->makeFollowButton()->setFollowersBlock()->setQuestionInfo()->setFooter()->increaseView()->makeTopTabs();
     $this->Registry->Dispatcher->post($this->Question, 'onQuestionView');
 }
예제 #26
0
    protected function returnResult()
    {
        /**
         * @todo translate string
         */
        $message = '@@Item deleted@@';
        $requested = 'You cannot delete question that already has answers.<br>A request to delete
		this question has been sent to moderators<br>
		It will be up to moderators to either delete or edit or close the question';
        if (Request::isAjax()) {
            $res = !$this->requested ? $message : $requested;
            $ret = array('alert' => $res);
            if (!empty($this->posterDetails)) {
                $ret['alert'] .= $this->posterDetails;
            } else {
                /**
                 * If item was actually deleted then
                 * add 'reload' => 2 to return
                 * which will cause page reload
                 * in 1.5 seconds.
                 */
                if (!$this->requested) {
                    $ret['reload'] = 1500;
                }
            }
            Responder::sendJSON($ret);
        }
        Responder::redirectToPage($this->Resource->getUrl());
    }
예제 #27
0
 /**
  * Validates the value of form token
  * passed in form against the one stored in SESSION
  *
  * @todo validate (store it first) IP address
  * of request that it must match ip when token is validate
  * and throw special type of Exception so that a user will
  * get explanation that IP address has changed
  *
  * @param string $token value as passed in the submitted form
  * @return true of success
  * @throws LampcmsException if validation fails
  */
 protected function validateToken($token = null)
 {
     $message = '';
     $token = null === $token && !empty($this->Request['token']) ? $this->Request['token'] : $token;
     if (empty($_SESSION['secret'])) {
         d("No token in SESSION ");
         /**
          * @todo
          * Translate String
          */
         $message = 'Form_token_missing';
     } elseif ($_SESSION['secret'] !== $token) {
         d('session token: ' . $_SESSION['secret'] . ' supplied token: ' . $token);
         $message = 'wrong form token';
     }
     if (!empty($message)) {
         if (Request::isAjax()) {
             Responder::sendJSON(array('exception' => $message));
         }
         throw new TokenException($message);
     }
     return true;
 }
예제 #28
0
파일: Shred.php 프로젝트: codex73/LampCMS
 protected function returnResult()
 {
     if (Request::isAjax()) {
         $message = '@@User Shredded@@<hr>@@Banned IPs@@:' . implode('<br>', array_keys($this->aIPs)) . '<hr><br>@@Countries@@: ' . implode('<br>', array_keys($this->aCountries));
         Responder::sendJSON(array('alert' => $message));
     }
     Responder::redirectToPage();
 }
예제 #29
0
 /**
  * Redirect back to the question page
  *
  */
 protected function redirect()
 {
     Responder::redirectToPage($this->Question->getUrl());
 }
예제 #30
0
 protected function handleReturn()
 {
     $isAjax = Request::isAjax();
     d('$isAjax: ' . $isAjax);
     if ($isAjax) {
         $ret = array('vote' => array('v' => $this->Resource->getScore(), 't' => $this->resType, 'rid' => $this->resID));
         Responder::sendJSON($ret);
     }
     Responder::redirectToPage($this->Resource->getUrl());
 }