Exemple #1
0
 /**
  * Méthode permettant d'enregistrer des données textuelles dans un fichier de Logs
  * Définit le nom du dossier ainsi que celui du fichier en fonction de la date
  * @param String $pMessage					Message à enregistrer dans le fichier
  * @param String $pLevel					Niveau d'importance de l'information
  * @return void
  */
 public static final function write($pMessage, $pLevel = self::NOTICE)
 {
     $ip = $_SERVER["REMOTE_ADDR"];
     $folder = Autoload::$folder . "/includes/logs/" . date("m-y") . "/";
     $file = date("d-m-y") . ".txt";
     $message = "[ " . date("H\\hi\\ms\\s") . " ] [" . $ip . "] [ " . Core::$application . " ] [ " . $pLevel . " ]\t\t" . $pMessage . "\r\n";
     Folder::create($folder);
     File::create($folder . $file);
     chmod($folder . $file, 0666);
     File::append($folder . $file, $message);
 }
Exemple #2
0
 public function output($pFolder)
 {
     Folder::deleteRecursive($pFolder);
     Folder::create($pFolder);
     Folder::create($pFolder . '/classes');
     $smarty = new \Smarty();
     $smarty->clear_all_assign();
     $smartyDir = "includes/libs/core/tools/docs/templates/_cache/";
     $smarty->template_dir = "includes/libs/core/tools/docs/templates";
     $smarty->cache_dir = $smartyDir;
     $smarty->compile_dir = $smartyDir;
     $classIndex = array();
     foreach ($this->packages as $className => $details) {
         $parts = explode("\\", $className);
         $class = array_pop($parts);
         while (in_array($class, $classIndex) && !empty($parts)) {
             $class = $class . '\\' . array_pop($parts);
         }
         $file = 'classes/' . str_replace('\\', '_', $class) . '.html';
         $classIndex[] = array('name' => $class, 'href' => $file);
         $smarty->clear_all_assign();
         $details['name'] = $class;
         $smarty->assign('details', $details);
         file_put_contents($pFolder . $file, Encoding::BOM() . $smarty->fetch("template.class_details.tpl"));
     }
     $this->sortName($classIndex);
     $prefixed_ndx = array();
     foreach ($classIndex as $class) {
         $firstLetter = strtoupper(substr($class['name'], 0, 1));
         if (!array_key_exists($firstLetter, $prefixed_ndx)) {
             $prefixed_ndx[$firstLetter] = array();
         }
         $prefixed_ndx[$firstLetter][] = $class;
     }
     $classIndex = $prefixed_ndx;
     $smarty->clear_all_assign();
     $smarty->assign('classIndex', $classIndex);
     file_put_contents($pFolder . '/classes.html', Encoding::BOM() . $smarty->fetch("template.classes.tpl"));
     $smarty->clear_all_assign();
     file_put_contents($pFolder . '/index.html', Encoding::BOM() . $smarty->fetch("template.index.tpl"));
 }
Exemple #3
0
 /**
  * Méthode d'envoi de déclenchement des actions d'uploads, redimensionnement...
  * @throws Exception
  * @param bool $pCreateFolder
  * @return bool
  */
 public function send($pCreateFolder = false)
 {
     if ($pCreateFolder && !is_dir($this->folder)) {
         Folder::create($this->folder);
     }
     if (!isset($this->fileData) || $this->fileData["error"] != 0) {
         throw new Exception("Upload impossible : une erreur est survenue");
     }
     if (!@is_uploaded_file($this->fileData["tmp_name"])) {
         throw new Exception("Upload impossible");
     }
     if (!@move_uploaded_file($this->fileData["tmp_name"], $this->pathFile)) {
         throw new Exception("Upload impossible : le dossier cible n'existe pas");
     }
     chmod($this->pathFile, 0666);
     if (is_array($this->newSize) && count($this->newSize) == 2) {
         if (!Image::resize($this->pathFile, $this->newSize[0], $this->newSize[1])) {
             throw new Exception("Upload effectué : redimensionnement impossible");
         }
     }
     if ($this->miniatures) {
         $max = count($this->miniatures);
         for ($i = 0; $i < $max; ++$i) {
             Image::createCopy($this->pathFile, $this->miniatures[$i]["pathFile"], $this->miniatures[$i]["width"], $this->miniatures[$i]["height"]);
         }
     }
     if (!$this->model_upload->insertUpload($this->pathFile)) {
         $this->cancelUpload();
         throw new Exception("Upload impossible : erreur lors de l'insertion dans la base.");
     }
     $this->isUpload = true;
     $this->id_upload = $this->model_upload->getInsertId();
     return $this->isUpload;
 }