360 lines
13 KiB
PHP
360 lines
13 KiB
PHP
<?php
|
|
require 'inc/topMenu.php';
|
|
if (!empty($ci['ac']) && $ci['ac'] === 'login') {
|
|
echo '<form action="?" method="post">
|
|
<fieldset>
|
|
<legend>Login</legend>
|
|
<p>
|
|
<label>Login</label>
|
|
<input type="text" name="loginName" required />
|
|
</p>
|
|
<p>
|
|
<label>Password</label>
|
|
<input type="password" name="loginPass" required />
|
|
</p>
|
|
<p>
|
|
<input type="hidden" name="op" value="2"/>
|
|
<input type="hidden" name="ac" value="login"/>
|
|
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
|
|
<input type="hidden" name="token" value="', $token, '"/>
|
|
<input type="submit" />
|
|
</p>
|
|
</fieldset>
|
|
</form>';
|
|
}
|
|
if (!empty($ci['ac']) && $ci['ac'] === 'newDir' && isLog()) {
|
|
echo '<form action="?" method="post">
|
|
<fieldset>
|
|
<p>
|
|
<legend>New directory</legend>
|
|
<label>Name</label>
|
|
</p>
|
|
<p>
|
|
<input type="text" name="newDir" autofocus/>
|
|
<input type="hidden" name="op" value="1"/>
|
|
<input type="hidden" name="ac" value="newDir" />
|
|
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
|
|
<input type="hidden" name="token" value="', $token, '"/>
|
|
<input type="submit"/>
|
|
</p>
|
|
</fieldset>
|
|
</form>';
|
|
}
|
|
if (!empty($ci['ac']) && $ci['ac'] === 'renDir' && isLog()) {
|
|
if (empty($ci['op'])) {
|
|
$currentDir = getCurrentDir($ci['bc']);
|
|
echo '<form action="?" method="post">
|
|
<fieldset>
|
|
<legend>', $fullListDir[$currentDir], '</legend>
|
|
<p>
|
|
<label>New name</label>
|
|
<input type="text" name="renDir" value="', $fullListDir[$currentDir], '" autofocus autocomplete="off"/>
|
|
</p>
|
|
<p>
|
|
<input type="hidden" name="op" value="1"/>
|
|
<input type="hidden" name="ac" value="renDir" />
|
|
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
|
|
<input type="hidden" name="token" value="', $token, '"/>
|
|
<input type="submit"/>
|
|
</p>
|
|
</fieldset>
|
|
</form>';
|
|
}
|
|
}
|
|
if (!empty($ci['ac']) && $ci['ac'] === 'addVideo' && isLog()) {
|
|
echo '<form action="?" method="post">
|
|
<fieldset>
|
|
<legend>New video</legend>
|
|
<p>
|
|
<label>Url</label>
|
|
<input type="url" name="url" autofocus autocomplete="off"/>
|
|
</p>
|
|
<p>
|
|
<label>Name</label>
|
|
<input type="text" name="name" autocomplete="off"/>
|
|
</p>
|
|
<p>
|
|
<label>Description</label>
|
|
<textarea name="desc"></textarea>
|
|
</p>
|
|
<p>
|
|
<label>Via</label>
|
|
<input type="url" name="via" autocomplete="off"/>
|
|
</p>
|
|
<p>
|
|
<label>Direct download</label>
|
|
<input type="checkbox" name="ddl" value="1"/>
|
|
</p>
|
|
<p>
|
|
<input type="hidden" name="op" value="1"/>
|
|
<input type="hidden" name="ac" value="addVideo" />
|
|
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
|
|
<input type="hidden" name="token" value="', $token, '"/>
|
|
<input type="submit"/>
|
|
</p>
|
|
</fieldset>
|
|
</form>';
|
|
}
|
|
if (!empty($ci['ac']) && $ci['ac'] === 'viewEditForm' && isLog()) {
|
|
$videoInfo = getVideoInfo($ci['file'], $ci['bc'], $fullListFile);
|
|
echo '<form action="?" method="post">
|
|
<fieldset>
|
|
<legend>Video information</legend>
|
|
<p>
|
|
<label>Name</label>
|
|
<input type="text" name="name" autocomplete="off" value="',$videoInfo['title'],'"/>
|
|
</p>
|
|
<p>
|
|
<label>Description</label>
|
|
<textarea name="desc">',$videoInfo['desc'],'</textarea>
|
|
</p>
|
|
<p>
|
|
<label>Via</label>
|
|
<input type="url" name="via" autocomplete="off" value="',$videoInfo['via'],'"/>
|
|
</p>
|
|
<p>
|
|
<input type="hidden" name="op" value="updateFileDesc"/>
|
|
<input type="hidden" name="ac" value="view" />
|
|
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
|
|
<input type="hidden" name="file" value="'.$ci['file'].'"/>
|
|
<input type="hidden" name="token" value="', $token, '"/>
|
|
<input type="submit"/>
|
|
</p>
|
|
</fieldset>
|
|
</form>';
|
|
$ci['ac'] = 'view';
|
|
}
|
|
if (!empty($ci['ac']) && $ci['ac'] === 'addThumbnail' && isLog()) {
|
|
echo '<form action="?" method="post" enctype="multipart/form-data">
|
|
<fieldset>
|
|
<legend>Add thumbnail</legend>
|
|
<p>
|
|
<label>Thumbnail</label>
|
|
<input type="file" name="file" />
|
|
</p>
|
|
<p>
|
|
<input type="hidden" name="op" value="1"/>
|
|
<input type="hidden" name="ac" value="addThumbnail" />
|
|
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
|
|
<input type="hidden" name="token" value="', $token, '"/>
|
|
<input type="submit"/>
|
|
</p>
|
|
</fieldset>
|
|
</form>';
|
|
}
|
|
if (!empty($ci['ac']) && $ci['ac'] === 'importDirForm' && isLog()) {
|
|
echo '<form action="?" method="post" enctype="multipart/form-data">
|
|
<fieldset>
|
|
<legend>Add dir</legend>
|
|
<p>
|
|
<label>Directory</label>
|
|
<input type="file" name="file" />
|
|
</p>
|
|
<p>
|
|
<input type="hidden" name="op" value="1"/>
|
|
<input type="hidden" name="ac" value="importDir" />
|
|
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
|
|
<input type="hidden" name="token" value="', $token, '"/>
|
|
<input type="submit"/>
|
|
</p>
|
|
</fieldset>
|
|
</form>';
|
|
}
|
|
if (!empty($ci['ac']) && $ci['ac'] === 'view') {
|
|
if (!empty($ci['op']) && (int)$ci['op'] === 1) {
|
|
verifToken($ci['token']);
|
|
} else {
|
|
$videoInfo = getVideoInfo($ci['file'], $ci['bc'], $fullListFile);
|
|
}
|
|
}
|
|
if (empty($ci['bc'])) {
|
|
$path = $GLOBALS['config']['VIDEODIR'].'/';
|
|
} else {
|
|
$splitBc = chunk_split($ci['bc'], 8, '/');
|
|
$path = $GLOBALS['config']['VIDEODIR'].'/'.$splitBc;
|
|
$breadcrumb = makeBreadcrumb($ci['bc'], $fullListDir);
|
|
$nbBread = count($breadcrumb);
|
|
}
|
|
$listCurrentDir = listCurrentDir($path);
|
|
$listCurrentFile = listVideo($path);
|
|
if (!empty($listCurrentFile) && count($listCurrentFile) > 1 && $ci['ac'] !== 'view') {
|
|
echo '<div id="sort">
|
|
<ul>
|
|
<li><a href="?bc=', $ci['bc'], '&sort=date">Date</a></li>
|
|
<li><a href="?bc=', $ci['bc'], '&sort=name">Name</a></li>
|
|
</ul>
|
|
</div>';
|
|
}
|
|
echo '<div id="breadcrumb">';
|
|
$i = 1;
|
|
echo '<a href="?">Home</a> >>';
|
|
if (!empty($breadcrumb)) {
|
|
foreach ($breadcrumb as $key => $value) {
|
|
if ($i === $nbBread && $ci['ac'] !== 'view') {
|
|
echo $value;
|
|
} else {
|
|
echo '<a href="?bc=', $key, '">', $value, '</a> >> ';
|
|
}
|
|
$i++;
|
|
}
|
|
}
|
|
echo '</div>';
|
|
if (isset($_SESSION['cutFile']) && !empty($_SESSION['cutFile'])) {
|
|
echo '<div class="paste"><a href="?bc=', $ci['bc'], '&op=paste&token=', $token, '"><img src="images/paste.svg" alt="Paste here" title="Paste here"/>', substr($fullListFile[$_SESSION['cutFile']]['title'], 0, 22), '...</a></div>';
|
|
}
|
|
if (empty($listCurrentDir) && empty($listCurrentFile)) {
|
|
if ($ci['ac'] === 'confDelDir' && isLog()) {
|
|
echo '<div class="confirm">
|
|
<h3>Delete this directory</h3>
|
|
<a href="?bc=', $ci['bc'], '&token=', $token, '&ac=delDir" class="valid">Yes</a>
|
|
<a href="?bc=', $ci['bc'], '&token=', $token, '" class="cancel">No</a>
|
|
</div>';
|
|
} else {
|
|
echo '<a href="?bc=', $ci['bc'], '&token=', $token, '&ac=confDelDir" class="delete">Delete this directory</a>';
|
|
}
|
|
}
|
|
if ($ci['op'] === 'confDelVideo' && isLog()) {
|
|
echo '<div class="confirm">
|
|
<h3>Delete this file</h3>
|
|
<a href="?ac=view&op=4&bc=', $ci['bc'], '&file=', $ci['file'], '&token=', $token, '" class="valid">Yes</a>
|
|
<a href="?ac=view&bc=', $ci['bc'], '&file=', $ci['file'], '&token=', $token, '" class="cancel">No</a>
|
|
</div>';
|
|
}
|
|
echo '<div id="listFile">';
|
|
if (!empty($listCurrentDir) && $ci['ac'] !== 'view') {
|
|
$listCurrentDir = sortDir($listCurrentDir, $fullListDir);
|
|
foreach ($listCurrentDir as $key => $value) {
|
|
$thumbnail = getThumbnail($path, $key);
|
|
if (empty($thumbnail)) {
|
|
echo '<a href="?bc=', $ci['bc'].$key, '"><span class="fulldir"></span>', $value, '</a> ';
|
|
} else {
|
|
echo '<a href="?bc=', $ci['bc'].$key, '"><span class="dir"></span><img alt="Thumbnail of video" src="', $thumbnail, '" />', $value, '</a> ';
|
|
}
|
|
}
|
|
}
|
|
if (!empty($listCurrentFile) && $ci['ac'] !== 'view') {
|
|
echo '
|
|
<div class="export">
|
|
<ul>
|
|
<li>Stream : </li>
|
|
<li><a href="?ac=m3u&bc='.$ci['bc'], '"><img src="images/playlist.svg" alt="Playlist m3u" title="Playlist m3u"/></a><li>
|
|
<li><a href="?ac=rss&bc='.$ci['bc'], '"><img src="images/rss.svg" alt="RSS" title="RSS"/></a></li>
|
|
</ul>
|
|
</div>';
|
|
$listCurrentFile = sortFile($listCurrentFile, $fullListFile, $ci['sort']);
|
|
foreach ($listCurrentFile as $key => $value) {
|
|
$thumb = '';
|
|
if ($key == 'thumb') {
|
|
continue;
|
|
}
|
|
if (file_exists($_SERVER['DOCUMENT_ROOT'].'/'.$path.$key.'.thumb.jpg')) {
|
|
$thumb = $path.$key.'.thumb.jpg';
|
|
}
|
|
if (empty($thumb) && file_exists($_SERVER['DOCUMENT_ROOT'].'/'.$path.$key.'.jpg')) {
|
|
$thumb = makeThumb($path, $key);
|
|
}
|
|
if (empty($thumb)) {
|
|
$thumb = 'images/noThumb.gif';
|
|
}
|
|
echo '<a href="?bc=', $ci['bc'], '&file=', $key, '&ac=view"><span class="video"></span><img alt="', $path.$key, '" src="', $thumb, '" />', $value['title'], '</a>';
|
|
}
|
|
}
|
|
echo '</div>';
|
|
if (!empty($ci['ac']) && $ci['ac'] === 'view' && !empty($listCurrentFile)) {
|
|
$_SESSION['video'] = $videoInfo['hash'];
|
|
if (!empty($videoInfo)) {
|
|
if (empty($videoInfo['title']) || empty($videoInfo['uploadDateSort'])) {
|
|
if (empty($videoInfo['title'])) {
|
|
$fullTitle = $videoInfo['originalTitle'];
|
|
} else {
|
|
$fullTitle = $videoInfo['title'];
|
|
}
|
|
$uploadDate = $videoInfo['uploadDate'];
|
|
updateFileInfo($videoInfo['hash'], $fullTitle, $uploadDate);
|
|
$videoInfo['title'] = $fullTitle = $videoInfo['originalTitle'].' ('.$videoInfo['originalTitle'].')';
|
|
$videoInfo['uploadDateSort'] = $videoInfo['uploadDate'];
|
|
deleteCache($ci['bc'], $ci['file'], $ci['sort'], true);
|
|
} else {
|
|
$fullTitle = $videoInfo['title'].' ('.$videoInfo['originalTitle'].')';
|
|
}
|
|
echo '<div id="viewFile">';
|
|
echo '<h2>', $fullTitle, '</h2>';
|
|
echo '<video width="640" controls="controls" poster="', $path.$videoInfo['hash'], '.jpg">';
|
|
echo '<source src="', $path.$videoInfo['hash'], '.webm" type="video/webm" />';
|
|
echo 'Oops your browser can\'t play webm video. Try a modern browser. Look <a href="http://browsehappy.com/">browsehappy.com</a> for list.';
|
|
echo '</video>';
|
|
}
|
|
if ($_SESSION['log'] === true) {
|
|
echo '<div id="toolbar">
|
|
<a href="?ac=view&bc=', $ci['bc'], '&file=', $ci['file'], '&token=', $token, '&ac=viewEditForm"><img src="images/edit.svg" alt="Edit video information" title="Edit video information"/></a>
|
|
<a href="?ac=view&bc=', $ci['bc'], '&file=', $ci['file'], '&token=', $token, '&op=cutVideo"><img src="images/cut.svg" alt="Cut this video" title="Cut this video"/></a>
|
|
<a href="?ac=view&op=3&bc=', $ci['bc'], '&file=', $ci['file'], '&token=', $token, '"><img src="images/useThumbnail.svg" alt="Use this thumbnail for folder thumbnail" title="Use this thumbnail for folder thumbnail"/></a>
|
|
<a href="?ac=view&bc=', $ci['bc'], '&file=', $ci['file'], '&token=', $token, '&op=reDownload"><img src="images/reload.svg" alt="Re-download" title="Re-download"/></a>
|
|
<a href="?ac=view&bc=', $ci['bc'], '&file=', $ci['file'], '&token=', $token, '&op=updateInfo"><img src="images/getInfo.svg" alt="Get info" title="Get info"/></a>
|
|
<a href="?ac=view&bc=', $ci['bc'], '&file=', $ci['file'], '&token=', $token, '&op=confDelVideo"><img src="images/delete.svg" alt="Delete this video" title="Delete this video"/></a>
|
|
</div>';
|
|
}
|
|
if ($GLOBALS['config']['DOWNLOAD_METHOD'] === 'xsendfile' || $GLOBALS['config']['DOWNLOAD_METHOD'] === 'php') {
|
|
$downloadLink = '?bc='.$ci['bc'].'&dl='.$videoInfo['hash'];
|
|
} else {
|
|
$downloadLink = $path.$videoInfo['hash'].'.webm';
|
|
}
|
|
echo '<table>
|
|
<tr>
|
|
<th>Title</th>
|
|
<td>', $videoInfo['title'], '</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Original title</th>
|
|
<td>', $videoInfo['originalTitle'], '</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Description</th>
|
|
<td>', nl2br($videoInfo['desc']), '</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Original description</th>
|
|
<td>', nl2br(text2clickable($videoInfo['originalDesc'])), '</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Url</th>
|
|
<td><a href="', $videoInfo['url'], '">', $videoInfo['url'], '</a></td>
|
|
</tr>
|
|
<tr>
|
|
<th>Duration</th>
|
|
<td>', $videoInfo['duration'], '</td>
|
|
<tr>
|
|
<tr>
|
|
<th>Dimension</th>
|
|
<td>', $videoInfo['size'], '</td>
|
|
<tr>
|
|
<tr>
|
|
<th>Size</th>
|
|
<td>', humanFilesize(filesize($_SERVER["DOCUMENT_ROOT"].$path.$videoInfo['hash'].'.webm')), '</td>
|
|
<tr>
|
|
<th>Publish date</th>
|
|
<td>', date("d m Y", strtotime($videoInfo['uploadDate'])), '</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Via</th>
|
|
<td>';
|
|
if (!empty($videoInfo['via'])) {
|
|
echo '<a href="', htmlentities($videoInfo['via']), '">', $videoInfo['via'], '</a>';
|
|
} else {
|
|
echo '';
|
|
}
|
|
echo '</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Download</th>
|
|
<td><a href="', $downloadLink, '">Download</a></td>
|
|
</tr>
|
|
<tr>
|
|
<th>View image preview</th>
|
|
<td><a href="', $path.$videoInfo['hash'], '.jpg">Image preview</a></td>
|
|
</tr>
|
|
</table>
|
|
</div>';
|
|
}
|
|
?>
|