Пример #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
 /**
  * @return void
  */
 public function captcha()
 {
     if (!Core::checkRequiredGetVars("form", "input")) {
         Go::to404();
     }
     $form = $_GET["form"];
     $input = $_GET["input"];
     $form = new Form($form);
     $captcha = $form->getInput($input);
     if (empty($captcha) || $captcha["tag"] != Form::TAG_CAPTCHA) {
         Go::to404();
     }
     $avaibles = array("backgroundColor", "fontSizeMax", "fontSizeMin", "width", "height", "rotation", "transparent");
     if (!isset($captcha["length"]) || empty($captcha["length"]) || $captcha["length"] == 0) {
         $captcha["length"] = 5;
     }
     $c = new Captcha($captcha["length"], $input);
     if (isset($captcha["fontColors"]) && is_array($captcha["fontColors"])) {
         $a = $captcha["fontColors"];
         for ($i = 0, $max = count($a); $i < $max; $i++) {
             $c->addFontColor($a[$i]);
         }
     }
     if (isset($captcha["fontFace"]) && is_array($captcha["fontFace"])) {
         $a = $captcha["fontFace"];
         for ($i = 0, $max = count($a); $i < $max; $i++) {
             $c->addFontFace($a[$i]);
         }
     }
     for ($i = 0, $max = count($avaibles); $i < $max; $i++) {
         if (isset($captcha[$avaibles[$i]]) && !empty($captcha[$avaibles[$i]])) {
             $c->{$avaibles}[$i] = $captcha[$avaibles[$i]];
         }
     }
     $c->render();
     Core::endApplication();
 }
Пример #3
0
<?php

date_default_timezone_set("Europe/Paris");
define("MEMORY_REAL_USAGE", true);
$timeInit = microtime(true);
$memInit = memory_get_usage(MEMORY_REAL_USAGE);
require_once __DIR__ . "/includes/libs/core/application/class.Singleton.php";
require_once __DIR__ . "/includes/libs/core/application/class.Autoload.php";
use core\application\Autoload;
use core\application\Core;
Autoload::$folder = __DIR__;
spl_autoload_register(array(Autoload::getInstance(), "load"));
Core::checkEnvironment();
Core::init();
Core::parseURL();
Core::execute(Core::getController(), Core::getAction(), Core::getTemplate());
Core::endApplication();
Пример #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();
     }
 }
Пример #5
0
 /**
  * @param string $pContent
  */
 private function output($pContent)
 {
     Header::content_length(strlen($pContent));
     echo $pContent;
     Core::endApplication();
 }