Esempio n. 1
0
 /**
  * Escapes a string by converting the characters that have a special meaning in Javascript.
  * Uses the charset {@link PHP_MANUAL#mb_internal_encoding()} to try to encode $value.
  * IMPORTANT: The value will be converted into a string.
  *
  * @param string|null $value
  *            value to be protected
  * @return string protected value or empty string if the encoding failed
  */
 public static final function jsonEncode($value)
 {
     \PHPYAM\libs\StringUtils::jsonEncode($value, null, mb_internal_encoding());
     return $value;
 }
Esempio n. 2
0
 /**
  * \PHPYAM\core\Router's constructor.
  * Automatically starts the routing by analyzing the elements of the web request URL and by calling
  * the corresponding control + action. Non-catched exceptions redirect the user to an error page
  * (or return the full list of errors + HTTP code 500 when it's an Ajax request).
  */
 public final function __construct()
 {
     try {
         $this->initRouter();
         if (!$this->authentication->authenticate($this->urlController, $this->urlAction, $this->urlParameters)) {
             throw new RouterException(StringUtils::gettext('You are not authorized to access this page.'));
         }
         $this->call($this->urlController, $this->urlAction, $this->urlParameters);
         $this->endRouter();
     } catch (RouterException $ex) {
         $this->endRouterOnError(array($ex->getMessage()));
     } catch (Exception $ex) {
         if (USE_LOG4PHP) {
             \Logger::getLogger(__CLASS__)->error($ex);
         }
         $this->endRouterOnError(array(StringUtils::gettext('Internal error. Please restart the application.'), $ex));
         $this->cleanupOnFatalError();
     }
 }