コード例 #1
0
ファイル: Zip.php プロジェクト: ixtrum/file-manager-plugins
 /**
  * Zip files
  *
  * @param string $targetDir Target dir path
  * @param array  $files     Files to zip
  *
  * @throws \Exception
  */
 private function zipFiles($targetDir, $files)
 {
     $zip = new \ZipArchive();
     $zipName = pathinfo($files[0], PATHINFO_FILENAME);
     $zipPath = FileSystem::getUniquePath($targetDir . DIRECTORY_SEPARATOR . $zipName . ".zip");
     if ($zip->open($zipPath, \ZipArchive::CREATE)) {
         foreach ($files as $file) {
             $path = $targetDir . DIRECTORY_SEPARATOR . $file;
             if (is_dir($path)) {
                 $zip->addEmptyDir($file);
                 foreach (Finder::find("*")->from($path) as $item) {
                     $name = $file . DIRECTORY_SEPARATOR . substr_replace($item->getPathname(), "", 0, strlen($path) + 1);
                     if ($item->isDir()) {
                         $zip->addEmptyDir($name);
                     } else {
                         $zip->addFile($item->getRealPath(), $name);
                     }
                 }
             } else {
                 $zip->addFile($path, $file);
             }
         }
         $zip->close();
     } else {
         throw new \Exception("Can not create ZIP archive '{$zipPath}' from '{$targetDir}'.");
     }
 }
コード例 #2
0
ファイル: detail.php プロジェクト: lasticshow/filmmva6
<?php

include "functions.php";
//Récupérer le paramétre de l'identifiant passé dans l'URL de la page
$id = $_GET["film"];
//Trouver le bon film
$finder = new Finder($data);
$film = $finder->find($id);
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title><?php 
echo "MVA - " . $film->title;
?>
</title>
        <link href="css/bootstrap.min.css" rel="stylesheet" />
        <script src="js/jquery-2.2.0.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
    </head>
    <body>
       <nav class="navbar navbar-default" role="navigation">
           <div class="container">
                <div class="collapse navbar-collapse">
                    <ul class="nav navbar-nav">
                       <li><a href="/">Films</a></li>
                       <li><a href="#">A Propos</a></li>
                       <li><a href="#">Contact</a></li>
                    </ul>
コード例 #3
0
ファイル: FileStorage.php プロジェクト: riskatlas/micka
 /**
  * Removes items from the cache by conditions & garbage collector.
  * @param  array  conditions
  * @return void
  */
 public function clean(array $conds)
 {
     $all = !empty($conds[Cache::ALL]);
     $collector = empty($conds);
     // cleaning using file iterator
     if ($all || $collector) {
         $now = time();
         foreach (Finder::find('_*')->from($this->dir)->childFirst() as $entry) {
             $path = (string) $entry;
             if ($entry->isDir()) {
                 // collector: remove empty dirs
                 @rmdir($path);
                 // @ - removing dirs is not necessary
                 continue;
             }
             if ($all) {
                 $this->delete($path);
             } else {
                 // collector
                 $meta = $this->readMetaAndLock($path, LOCK_SH);
                 if (!$meta) {
                     continue;
                 }
                 if (!empty($meta[self::META_DELTA]) && filemtime($meta[self::FILE]) + $meta[self::META_DELTA] < $now || !empty($meta[self::META_EXPIRE]) && $meta[self::META_EXPIRE] < $now) {
                     $this->delete($path, $meta[self::HANDLE]);
                     continue;
                 }
                 flock($meta[self::HANDLE], LOCK_UN);
                 fclose($meta[self::HANDLE]);
             }
         }
         if ($this->journal) {
             $this->journal->clean($conds);
         }
         return;
     }
     // cleaning using journal
     if ($this->journal) {
         foreach ($this->journal->clean($conds) as $file) {
             $this->delete($file);
         }
     }
 }
コード例 #4
0
ファイル: Source.php プロジェクト: jahudka/minify
 public function includeDir($path, $types, $recursive, $indent)
 {
     if (!file_exists($path) || !is_dir($path)) {
         throw new \LogicException("{$path} does not exist or is not a directory");
     }
     $files = Finder::find($path, $types, $recursive);
     $contents = '';
     foreach ($files as $file) {
         /** @var $file \SplFileInfo */
         if ($file->isDir()) {
             continue;
         }
         $contents .= $this->includeFile($file->getRealPath(), $indent) . "\n";
     }
     return $contents;
 }