Exemple #1
0
 public function avatar()
 {
     $mime = File::getMimeType(self::DEFAULT_AVATAR);
     Header::content_type($mime);
     echo file_get_contents(self::DEFAULT_AVATAR);
     Core::endApplication();
 }
Exemple #2
0
 public function out()
 {
     if (!Core::checkRequiredGetVars("permalink")) {
         Go::to404();
     }
     $m = new ModelPost();
     $post = $m->oneByPermalink($_GET["permalink"]);
     Header::location($post['url_post']);
 }
 /**
  * Méthode permettant de redimensionner une image uploadée (enregistrée en base)
  * http://www.site.com/statique/resize/id:2/w:200/h:200/
  *
  * $_GET["id"]		int		Id de l'upload
  * $_GET["w"]		int		largeur max souhaitée
  * $_GET["h"]		int		hauteur max souhaitée
  * @return void
  */
 public function resize()
 {
     if (!Form::isNumeric($_GET["id"]) || !Form::isNumeric($_GET["w"]) || !Form::isNumeric($_GET["h"])) {
         Go::to404();
     }
     if (!file_exists($image = ModelUpload::getPathById($_GET["id"]))) {
         Go::to404();
     }
     preg_match(File::REGEXP_EXTENSION, $image, $extract);
     $ext = $extract[1];
     $folder_cache = "includes/applications/" . Core::$application . "/_cache/imgs/";
     $file_cache = $folder_cache . "resize_" . $_GET["id"] . "_" . $_GET["w"] . "_" . $_GET["h"] . "." . $ext;
     if ($app != "main") {
         Configuration::$server_url .= "../";
     }
     if (file_exists($file_cache)) {
         Header::location(Configuration::$server_url . $file_cache);
     }
     Image::createCopy($image, $file_cache, $_GET["w"], $_GET["h"]);
     Header::location(Configuration::$server_url . $file_cache);
 }
Exemple #4
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);
     }
 }
Exemple #5
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();
     }
 }
Exemple #6
0
 public function create()
 {
     $m = new ModelList();
     $perma = $m->create(AuthenticationHandler::$data['id_user']);
     Header::location(Configuration::$server_url . 'list/' . $perma . '/edit');
 }
 /**
  * @param string $pContent
  */
 private function output($pContent)
 {
     Header::content_length(strlen($pContent));
     echo $pContent;
     Core::endApplication();
 }