示例#1
0
 public function avatar()
 {
     $mime = File::getMimeType(self::DEFAULT_AVATAR);
     Header::content_type($mime);
     echo file_get_contents(self::DEFAULT_AVATAR);
     Core::endApplication();
 }
示例#2
0
 /**
  * Constructor
  * @param string $pType
  * @throws \Exception
  */
 public function __construct($pType = self::TYPE_JS)
 {
     $this->type = $pType;
     switch ($this->type) {
         case self::TYPE_JS:
             Header::content_type("application/javascript");
             break;
         case self::TYPE_CSS:
             Header::content_type("text/css");
             break;
     }
     /**
      * Load manifest
      */
     if (!file_exists(self::MANIFEST)) {
         $this->output($this->log("Manifest file '" . self::MANIFEST . "' not found", "error"));
     }
     $this->manifest = SimpleJSON::import(self::MANIFEST);
     $this->configuration = isset($this->manifest["config"]) ? $this->manifest["config"] : array();
     unset($this->manifest["config"]);
     /**
      * Cache
      */
     $cacheDuration = Stack::get("cache.duration", $this->configuration);
     if (!empty($cacheDuration)) {
         $eTag = md5($_GET["need"]);
         Header::handleCache($eTag, $cacheDuration);
     }
 }
示例#3
0
 /**
  * @static
  * @param DefaultController|null $pController
  * @param null $pAction
  * @param string $pTemplate
  * @return void
  */
 public static function execute($pController = null, $pAction = null, $pTemplate = "")
 {
     if ($pController != "statique") {
         $pController->setTemplate(self::$controller, self::$action, $pTemplate);
     }
     if ($pAction != null) {
         $pController->{$pAction}();
     }
     if (!Core::$request_async) {
         Header::content_type("text/html");
         $pController->render();
         if (Core::debug()) {
             Debugger::render();
         }
     } else {
         $return = $pController->getGlobalVars();
         $return = array_merge($return, Debugger::getGlobalVars());
         if (isset($_POST) && isset($_POST["render"]) && $_POST["render"] != "false") {
             $return["html"] = $pController->render(false);
         }
         $response = SimpleJSON::encode($return);
         $type = "json";
         self::performResponse($response, $type);
     }
 }
示例#4
0
 /**
  * Gestionnaire des erreurs de scripts Php
  * Peut stopper l'application en cas d'erreur bloquante
  * @param Number $pErrorLevel						Niveau d'erreur
  * @param String $pErrorMessage						Message renvoyé
  * @param String $pErrorFile						Adresse du fichier qui a déclenché l'erreur
  * @param Number $pErrorLine						Ligne où se trouve l'erreur
  * @param String $pErrorContext						Contexte
  * @return void
  */
 public static function errorHandler($pErrorLevel, $pErrorMessage, $pErrorFile, $pErrorLine, $pErrorContext)
 {
     $stopApplication = false;
     switch ($pErrorLevel) {
         case E_ERROR:
         case E_CORE_ERROR:
         case E_COMPILE_ERROR:
         case E_USER_ERROR:
             $stopApplication = true;
             $type = "error";
             break;
         case E_WARNING:
         case E_CORE_WARNING:
         case E_COMPILE_WARNING:
         case E_USER_WARNING:
             $type = "warning";
             break;
         case E_NOTICE:
         case E_USER_NOTICE:
             $type = "notice";
             break;
         default:
         case self::E_USER_EXCEPTION:
             $stopApplication = true;
             $type = "error";
             break;
     }
     $pErrorFile = pathinfo($pErrorFile);
     $pErrorFile = $pErrorFile["basename"];
     if (preg_match('/href=/', $pErrorMessage, $matches)) {
         $pErrorMessage = preg_replace('/href=\'([a-z\\.\\-\\_]*)\'/', 'href=\'http://www.php.net/$1\' target=\'_blank\'', $pErrorMessage);
     }
     self::addToConsole($type, $pErrorMessage, $pErrorFile, $pErrorLine);
     if ($stopApplication) {
         if (!Core::debug()) {
             Logs::write($pErrorMessage . " " . $pErrorFile . " " . $pErrorLine . " " . $pErrorContext, $pErrorLevel);
         }
         Header::content_type("text/html", Configuration::$global_encoding);
         self::$open = true;
         self::render(true, true);
         Core::endApplication();
     }
 }