Esempio n. 1
0
 public static function fileContent($url)
 {
     $ext = new Extensions();
     $header_http = new ResponseHttpFoundation();
     $file = Tmpfile::getThemeConfig('themes_folder') . DIRECTORY_SEPARATOR . $url;
     $file = Filter::systemPath($file);
     $path = Filter::realpath($file);
     if (!$path) {
         $header_http->setContent("<html><body><center><h1>Ops! file not exists :(</h1></center></body></html>");
         $header_http->setStatusCode(ResponseHttpFoundation::HTTP_NOT_FOUND);
         $header_http->headers->set('Content-Type', "text/html");
         $header_http->send();
         return false;
     }
     //Defined Content-type of file
     $ctype = $ext->ctype("." . $ext->check($path, true));
     $header_http->setContent(file_get_contents($path));
     $header_http->setStatusCode(ResponseHttpFoundation::HTTP_OK);
     $header_http->headers->set('Content-Type', $ctype);
     $header_http->send();
 }
Esempio n. 2
0
 public static function file(&$file, $extension = false)
 {
     $exts = new Extensions();
     $obj = new static();
     if (is_string($file)) {
         $is_ext = $exts->check($file);
         if (!$is_ext and $extension) {
             $file = "{$file}.{$extension}";
         }
         $obj->hasError($file, $is_ext, $extension);
     } elseif (is_array($file)) {
         foreach ($file as $key => $val) {
             $is_ext = $exts->check($val);
             if (is_string($val) and !$is_ext and $extension) {
                 $file[$key] = "{$val}.{$extension}";
             }
             $obj->hasError("{$val}", $is_ext, $extension);
         }
     } else {
         throw new ErrorRuntime("Value for \$file is invalid.");
     }
 }
Esempio n. 3
0
 /**
  * 
  * @param string $folder
  * @return array Files of the folder defined on variable $folder
  */
 public static function fileAll($folder)
 {
     $DS = DIRECTORY_SEPARATOR;
     $open_folder = glob("{$folder}{$DS}*");
     $exts = new Extensions();
     foreach ($open_folder as $key => $val) {
         $exp = explode($DS, $val);
         if (!$exts->check(end($exp))) {
             unset($open_folder[$key]);
         }
     }
     return $open_folder;
 }