Skip to content

Instantly share code, notes, and snippets.

@julp
Last active November 19, 2019 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julp/6dcbaec4d337cf64160e3e0005b18e83 to your computer and use it in GitHub Desktop.
Save julp/6dcbaec4d337cf64160e3e0005b18e83 to your computer and use it in GitHub Desktop.
[OC]
<?php
const ROOT = 'adresse du répertoire';
$videos = iterator_to_array(
new RegexIterator(
new FilesystemIterator(ROOT, FilesystemIterator::CURRENT_AS_PATHNAME),
'#\.(mov|avi|mp4)$#i'
)
);
if (!$videos) {
echo 'Aucun document mis en ligne ...';
} else {
rsort($videos);
echo <<<'EOH'
<table>
<tr>
<td>Date</td>
<td>Aperçu</td>
<td>Fichiers vidéos</td>
<td>Taille</td>
</tr>
EOH;
foreach ($videos as $video) {
$image = preg_replace('~\.avi$~i', '.jpg', $video);
list($nom, $dateang) = explode('-', pathinfo($video, PATHINFO_FILENAME), 2);
$datefr = implode('/', array_reverse(preg_split('~[.]~', $nom)));
$size = filesize($video);
echo <<<EOH
<tr>
<td>{$datefr}</td>
<td><img src="{$image}" /></td>
<td><a href="{$video}" target="_blank">{$nom}</a></td>
<td>{$size}</td>
</tr>
EOH;
}
echo '</table>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment