예제 #1
0
    try {
        include $lampcmsClasses . 'Controllers' . DIRECTORY_SEPARATOR . 'Logintwitter.php';
        $o = new \Lampcms\Controllers\Logintwitter($Registry);
        header('Content-Type: text/html; charset=utf-8');
        echo $o->getResult();
        session_write_close();
        fastcgi_finish_request();
    } catch (\OutOfBoundsException $e) {
        session_write_close();
        /**
         * Special case is OutOfBoundsException which
         * is our special way of saying exit(); but do it
         * gracefully - let it be caught here and then do nothing
         * This is better than using exit() because on some servers
         * exit may terminate the whole fastcgi process instead of just
         * stopping this one script
         */
        $errMessage = trim($e->getMessage());
        if (!empty($errMessage)) {
            echo '<div class="exit_error">' . $errMessage . '</div>';
            d('Got exit signal from ' . $e->getTraceAsString());
        }
        fastcgi_finish_request();
    } catch (\Exception $e) {
        try {
            echo \Lampcms\Responder::makeErrorPage('<strong>Error:</strong> ' . \Lampcms\Exception::formatException($e));
        } catch (Exception $e2) {
            echo \Lampcms\Responder::makeErrorPage('<strong>Exception:</strong> ' . $e2->getMessage() . "\nIn file:" . $e2->getFile() . "\nLine: " . $e2->getLine());
        }
    }
}
예제 #2
0
 /**
  * Formats the exception, adding
  * additional exception data like backtrace
  * if running in debug mode
  * then adds the 'error' to a page
  *
  * @return
  * @param object $e Exception object
  */
 public function handleException(\Lampcms\Exception $le)
 {
     try {
         if ($le instanceof RedirectException) {
             session_write_close();
             header("Location: " . $le->getMessage(), true, $le->getCode());
             fastcgi_finish_request();
             throw new \OutOfBoundsException();
         }
         if ($le instanceof CaptchaLimitException) {
             d('Captcha limit reached.');
             /**
              * @todo add ip to CAPTCHA_HACKS collection
              *
              */
         }
         /**
          * In case of LampcmsAuthException
          * the value of 'c' attribute in exception
          * element will be set to "login"
          * indicating to template that this
          * is a 'must login' type of exception
          * and to render the login form
          *
          */
         $class = $le instanceof AuthException ? 'login' : 'excsl';
         /**
          * Special case:
          * the http error code can be
          * passed in exception as third argument
          * (in case where there are no second arg,
          * the second arg must be passed as null)
          */
         if (201 < ($errCode = $le->getCode())) {
             $this->httpCode = (int) $errCode;
         }
         if ($le instanceof Lampcms404Exception) {
             $this->httpCode = 404;
         }
         if (!$le instanceof Lampcms404Exception && !$le instanceof AuthException && !$le instanceof LoginException && !$le instanceof MustLoginException && !$le instanceof \OutOfBoundsException) {
             e('Exception caught in: ' . $le->getFile() . ' on line: ' . $le->getLine() . ' ' . $le->getMessage());
         }
         /**
          *
          * Exception::formatException will correctly
          * handle sending out JSON and exiting
          * if the request isAjax
          *
          */
         $err = Exception::formatException($le, null, $this->Registry->Tr);
         /**
          * @todo if Login exception then present a login form!
          *
          */
         $this->aPageVars['layoutID'] = 1;
         $this->aPageVars['body'] = \tplException::parse(array('message' => $err, 'class' => $class, 'title' => $this->_('Alert')));
     } catch (\OutOfBoundsException $e) {
         throw $e;
     } catch (\Exception $e) {
         e('Exception object ' . $e->getMessage());
         $err = Responder::makeErrorPage($le->getMessage() . ' in ' . $e->getFile());
         echo $err;
         fastcgi_finish_request();
         throw new \OutOfBoundsException();
     }
 }
예제 #3
0
 /**
  * Formats the exception, adding
  * additional exception data like backtrace
  * if running in debug mode
  * then adds the 'error' to a page
  *
  * @return void
  *
  * @param \Lampcms\Exception $le
  *
  * @throws \OutOfBoundsException
  * @throws \Exception|\OutOfBoundsException
  * @internal param object $e Exception object
  */
 public function handleException(\Lampcms\Exception $le)
 {
     try {
         if ($le instanceof RedirectException) {
             \session_write_close();
             $newUrl = $le->getMessage();
             /**
              * If redirect url contains any URI placeholders
              * (like {_WEB_ROOT_} for example)
              * then use mapper callback function
              * to replace those placeholders
              */
             if (\strstr($newUrl, '{_')) {
                 $mapper = $this->Router->getCallback();
                 $newUrl = $mapper($newUrl);
             }
             /**
              * If a relative url then turn into
              * full url to comply with w3c standard that says
              * redirect headers must point to complete url
              */
             if (0 !== \strncasecmp('http', $newUrl, 4)) {
                 $newUrl = $this->Registry->Ini->SITE_URL . $newUrl;
             }
             header("Location: " . $newUrl, true, $le->getCode());
             throw new \OutOfBoundsException();
         }
         if ($le instanceof CaptchaLimitException) {
             d('Captcha limit reached.');
             /**
              * @todo add ip to CAPTCHA_HACKS collection
              *
              */
         }
         /**
          * In case of LampcmsAuthException
          * the value of 'c' attribute in exception
          * element will be set to "login"
          * indicating to template that this
          * is a 'must login' type of exception
          * and to render the login form
          *
          */
         $class = $le instanceof AuthException ? 'login' : 'excsl';
         /**
          * Special case:
          * the http error code can be
          * passed in exception as third argument
          * (in case where there are no second arg,
          * the second arg must be passed as null)
          */
         if (201 < ($errCode = $le->getCode())) {
             $this->httpCode = (int) $errCode;
         }
         if ($le instanceof Lampcms404Exception) {
             $this->httpCode = 404;
         }
         /**
          * e() will also email error to developer
          * In case of Login and OutOfBoundsException we don't want
          * to email developers
          * We also don't want to email developers
          * in special types of exceptions that have
          * code set to -1
          * which is a way to say
          * "This exception is not severe enough for email to be sent out"
          */
         if ($errCode >= 0 && !$le instanceof Lampcms404Exception && !$le instanceof AuthException && !$le instanceof LoginException && !$le instanceof NoticeException && !$le instanceof MustLoginException && !$le instanceof \OutOfBoundsException) {
             e('Exception caught in: ' . $le->getFile() . ' on line: ' . $le->getLine() . ' ' . $le->getMessage() . ' trace: ' . $le->getTraceAsString());
         }
         /**
          *
          * Exception::formatException will correctly
          * handle sending out JSON and exiting
          * if the request isAjax
          *
          */
         $err = Exception::formatException($le, null, $this->Registry->Tr);
         /**
          * @todo if Login exception then present a login form!
          *
          */
         $this->aPageVars['layoutID'] = 1;
         $this->aPageVars['body'] = \tplException::parse(array('message' => \nl2br($err), 'class' => $class, 'title' => '@@Alert@@'));
     } catch (\OutOfBoundsException $e) {
         throw $e;
     } catch (\Exception $e) {
         e('Exception object ' . $e->getMessage());
         $err = Responder::makeErrorPage($le->getMessage() . ' in ' . $e->getFile());
         echo $err;
         fastcgi_finish_request();
         throw new \OutOfBoundsException();
     }
 }