-
Notifications
You must be signed in to change notification settings - Fork 0
/
archive.php
128 lines (120 loc) · 4.78 KB
/
archive.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
// archive.php - List the archived video files
// Copyright (C) 2009 St. lokale omroep Midvliet
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// This file is partly based on Basic TODO list (todo.php) written by
// Amadeus Stevenson. See acknowledgements.txt for the license of todo.php
require_once ('tvfunctions.php'); // Functions for TV scripts
authorize(1);
require_once ('tvconfig.php'); // Settings for TV scripts
testConfiguration(); // Test if configuration of directorys is OK
if (isset ($_POST["submit"] )) {
if ($_POST["submit"] == "Verwijderen") {
// Process "Delete" button
foreach ($_POST as $key => $value) {
if (strpos($key, 'line_') === 0) {
$line = substr($key, 5);
$filename = $_POST['file_'.$line];
if (strpos($filename, '/') === FALSE) {
unlink(ARCHIVEDIR.'/'.$filename);
}
}
}
} elseif ($_POST["submit"] == "Activeren") {
// Process "Archive" button
foreach ($_POST as $key => $value) {
if (strpos($key, 'line_') === 0) {
$line = substr($key, 5);
$filename = $_POST['file_'.$line];
if (strpos($filename, '/') === FALSE) {
if (isVideo($filename)) {
rename (ARCHIVEDIR."/".$filename, VIDEODIR."/".$filename);
}
}
}
}
}
}
?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title><?php echo OWNER; ?></title>
<link rel="stylesheet" href="tv.css" type="text/css" />
</head>
<body>
<form method="post" enctype="multipart/form-data">
<b>TV beheer pagina, versie <?php echo VERSION;?></b><br /><br />
<fieldset class="navigation">
<?php echo 'Gebruiker: ', $_SERVER['PHP_AUTH_USER'], ' | '; ?>
<a href="tv.php"><?php echo "terug"; ?></a><?php echo ' | '; ?>
<a href="help/archivehelp.php"><?php echo "help"; ?></a>
</fieldset>
<fieldset class="main">
<fieldset class="buttons">
<legend>Acties</legend>
<tr>
<td><input type="submit" name="submit" value="Activeren" /></td>
<td><input type="submit" name="submit" value="Verwijderen" /></td>
</tr>
</fieldset>
<fieldset class="edit">
<legend>Video's in archief</legend>
<pre>
<table>
<?php
echo "<tr>"; // Make table header
echo "<td></td>";
echo "<td>Video</td>";
echo "<td>Datum</td>";
echo "<td>Grootte</td>";
echo "<td>Speeltijd</td>";
echo "<td>Toelichting</td>";
echo "</tr>";
$n = 0;
if ($handle = opendir(ARCHIVEDIR)) {
while (false !== ($file = readdir($handle))) {
if (!is_dir(ARCHIVEDIR.'/'.$file)) {
if (isVideo($file)) { // if file is video file
$modified = filemtime (ARCHIVEDIR."/".$file); // Get modified date of video file
$size = filesize(ARCHIVEDIR."/".$file); // Get file size
$movie = new ffmpeg_movie (ARCHIVEDIR."/".$file, false); // Loaf movie with ffmpeg
$duration = $movie->getDuration(); // Get duration
echo "<tr>"; // Make table header
echo "<td><input type='checkbox' name='line_$n' /><input type='hidden' name='file_$n' value='$file' /></td>";
echo "<td>$file</td>"; // Print file name
echo "<td style=\"text-align: right\">".date("d-m-Y", $modified)."</td>"; // Modification date
echo "<td style=\"text-align: right\">".@niceSize($size)."</td>"; // File size
if ($duration>=3600) // Print duration
printf ("<td style=\"text-align: right\">%02d:%02d:%02d</td>", floor($duration/3600), floor(($duration/60)%60), floor($duration%60));
else
printf ("<td style=\"text-align: right\">%02d:%02d</td>", floor(($duration/60)%60), floor($duration%60));
echo "</tr>\n";
}
}
$n++;
}
closedir($handle);
}
?>
</table>
</pre>
</fieldset>
</fieldset>
</form>
</body>
</html>