2013-07-12 17:25:57 +02:00
< ? php
require 'inc/topMenu.php' ;
if ( ! empty ( $ci [ 'ac' ]) && $ci [ 'ac' ] === 'login' ) {
echo ' < form action = " ? " method = " post " >
< fieldset >
< legend > Login </ login >
< label > Login </ label >
< input type = " text " name = " loginName " required />
< label > Password </ label >
< input type = " password " name = " loginPass " required />
< input type = " hidden " name = " op " value = " 2 " />
< input type = " hidden " name = " ac " value = " login " />
< input type = " hidden " name = " bc " value = " '. $ci['bc'] .' " />
2013-08-01 16:18:20 +02:00
< input type = " hidden " name = " token " value = " ', $token , ' " />
2013-07-12 17:25:57 +02:00
< input type = " submit " />
</ fieldset >
</ form > ' ;
}
2013-08-08 16:54:22 +02:00
if ( ! empty ( $ci [ 'ac' ]) && $ci [ 'ac' ] === 'newDir' && isLog ()) {
2013-07-26 13:41:07 +02:00
echo ' < form action = " ? " method = " post " >
2013-07-12 17:25:57 +02:00
< fieldset >
2013-07-26 10:06:54 +02:00
< legend > New directory </ legend >
2013-07-12 17:25:57 +02:00
< label > Name </ label >
< input type = " text " name = " newDir " />
< input type = " hidden " name = " op " value = " 1 " />
< input type = " hidden " name = " ac " value = " newDir " />
< input type = " hidden " name = " bc " value = " '. $ci['bc'] .' " />
2013-08-01 16:18:20 +02:00
< input type = " hidden " name = " token " value = " ', $token , ' " />
2013-07-26 10:06:54 +02:00
< input type = " submit " />
</ fieldset >
</ form > ' ;
}
2013-08-08 16:54:22 +02:00
if ( ! empty ( $ci [ 'ac' ]) && $ci [ 'ac' ] === 'renDir' && isLog ()) {
2013-07-26 13:41:07 +02:00
if ( empty ( $ci [ 'op' ])) {
2013-07-26 10:06:54 +02:00
$currentDir = getCurrentDir ( $ci [ 'bc' ]);
echo ' < form action = " ? " method = " post " >
< fieldset >
< legend > ', $fullListDir[$currentDir], ' </ legend >
< label > New name </ label >
< input type = " text " name = " renDir " value = " ', $fullListDir[$currentDir] , ' " />
< input type = " hidden " name = " op " value = " 1 " />
< input type = " hidden " name = " ac " value = " renDir " />
< input type = " hidden " name = " bc " value = " '. $ci['bc'] .' " />
2013-08-01 16:18:20 +02:00
< input type = " hidden " name = " token " value = " ', $token , ' " />
2013-07-12 17:25:57 +02:00
< input type = " submit " />
</ fieldset >
</ form > ' ;
}
}
2013-08-08 16:54:22 +02:00
if ( ! empty ( $ci [ 'ac' ]) && $ci [ 'ac' ] === 'addVideo' && isLog ()) {
2013-07-26 13:41:07 +02:00
echo ' < form action = " ? " method = " post " >
2013-07-12 17:25:57 +02:00
< fieldset >
2013-07-26 10:06:54 +02:00
< legend > New video </ legend >
2013-07-12 17:25:57 +02:00
< label > Url </ label >
< input type = " url " name = " url " />
< label > Name </ label >
< input type = " text " name = " name " />
< label > Description </ label >
2015-01-29 11:44:46 +01:00
< textarea name = " desc " ></ textarea >
2013-07-12 17:25:57 +02:00
< label > Via </ label >
< input type = " url " name = " via " />
< label > Licence </ label >
< select name = " licence " >
< option > CC - NC </ option >
</ select >
2015-01-29 11:44:46 +01:00
< label > Direct download </ label >
< input type = " checkbox " name = " ddl " value = " 1 " />
2013-07-12 17:25:57 +02:00
< input type = " hidden " name = " op " value = " 1 " />
< input type = " hidden " name = " ac " value = " addVideo " />
< input type = " hidden " name = " bc " value = " '. $ci['bc'] .' " />
2013-08-01 16:18:20 +02:00
< input type = " hidden " name = " token " value = " ', $token , ' " />
2013-07-30 14:45:18 +02:00
< input type = " submit " />
</ fieldset >
</ form > ' ;
}
2013-08-08 16:54:22 +02:00
if ( ! empty ( $ci [ 'ac' ]) && $ci [ 'ac' ] === 'addThumbnail' && isLog ()) {
2013-07-30 14:45:18 +02:00
echo ' < form action = " ? " method = " post " enctype = " multipart/form-data " >
< fieldset >
< legend > Add thumbnail </ legend >
< label > Thumbnail </ label >
< input type = " file " name = " file " />
< input type = " hidden " name = " op " value = " 1 " />
< input type = " hidden " name = " ac " value = " addThumbnail " />
< input type = " hidden " name = " bc " value = " '. $ci['bc'] .' " />
2013-08-01 16:18:20 +02:00
< input type = " hidden " name = " token " value = " ', $token , ' " />
2013-07-12 17:25:57 +02:00
< input type = " submit " />
</ fieldset >
</ form > ' ;
2013-12-20 16:10:56 +01:00
}
if ( ! empty ( $ci [ 'ac' ]) && $ci [ 'ac' ] === 'importDirForm' && isLog ()) {
2013-08-12 14:51:22 +02:00
echo ' < form action = " ? " method = " post " enctype = " multipart/form-data " >
< fieldset >
< legend > Add dir </ legend >
< label > Directory </ label >
< input type = " file " name = " file " />
< 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 " />
</ fieldset >
</ form > ' ;
2013-07-26 12:20:48 +02:00
}
2013-07-12 17:25:57 +02:00
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' ])) {
2013-08-06 10:51:56 +02:00
$path = $GLOBALS [ 'config' ][ 'VIDEODIR' ] . '/' ;
2013-07-12 17:25:57 +02:00
} else {
$splitBc = chunk_split ( $ci [ 'bc' ], 8 , '/' );
2013-08-06 10:51:56 +02:00
$path = $GLOBALS [ 'config' ][ 'VIDEODIR' ] . '/' . $splitBc ;
2013-07-12 17:25:57 +02:00
$breadcrumb = makeBreadcrumb ( $ci [ 'bc' ], $fullListDir );
$nbBread = count ( $breadcrumb );
}
$listCurrentDir = listCurrentDir ( $path );
$listCurrentFile = listVideo ( $path );
2013-08-08 13:36:13 +02:00
if ( ! empty ( $listCurrentFile ) && count ( $listCurrentFile ) > 1 && $ci [ 'ac' ] !== 'view' ) {
2013-08-06 15:40:31 +02:00
echo ' < div id = " sort " >
< ul >
2013-08-08 13:36:13 +02:00
< li >< a href = " ?bc=', $ci['bc'] , '&sort=date " > Date </ a ></ li >
< li >< a href = " ?bc=', $ci['bc'] , '&sort=name " > Name </ a ></ li >
2013-08-06 15:40:31 +02:00
</ ul >
</ div > ' ;
}
2013-07-12 17:25:57 +02:00
echo '<div id="breadcrumb">' ;
$i = 1 ;
echo '<a href="?">Home</a> >>' ;
if ( ! empty ( $breadcrumb )) {
foreach ( $breadcrumb as $key => $value ) {
2013-07-26 12:04:17 +02:00
if ( $i === $nbBread && $ci [ 'ac' ] !== 'view' ) {
2013-07-12 17:25:57 +02:00
echo $value ;
} else {
echo '<a href="?bc=' , $key , '">' , $value , '</a> >> ' ;
}
$i ++ ;
}
}
echo '</div>' ;
2013-12-20 16:10:56 +01:00
if ( isset ( $_SESSION [ 'cutFile' ]) && ! empty ( $_SESSION [ 'cutFile' ])) {
2015-01-30 15:09:21 +01:00
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>' ;
2013-12-20 16:10:56 +01:00
}
2013-08-08 16:54:22 +02:00
if ( empty ( $listCurrentDir ) && empty ( $listCurrentFile )) {
2013-08-08 17:26:22 +02:00
if ( $ci [ 'ac' ] === 'confDelDir' && isLog ()) {
2013-08-08 13:36:13 +02:00
echo ' < div class = " confirm " >
2013-08-08 17:26:22 +02:00
< h3 > Delete this directory </ h3 >
< a href = " ?bc=', $ci['bc'] , '&token=', $token , '&ac=delDir " class = " valid " > Yes </ a >
2013-08-08 13:36:13 +02:00
< a href = " ?bc=', $ci['bc'] , '&token=', $token , ' " class = " cancel " > No </ a >
</ div > ' ;
} else {
2013-08-08 17:26:22 +02:00
echo '<a href="?bc=' , $ci [ 'bc' ], '&token=' , $token , '&ac=confDelDir" class="delete">Delete this directory</a>' ;
2013-08-08 13:36:13 +02:00
}
}
2013-08-08 17:26:22 +02:00
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 > ' ;
}
2013-08-08 13:36:13 +02:00
echo '<div id="listFile">' ;
2013-08-01 09:38:13 +02:00
if ( ! empty ( $listCurrentDir ) && $ci [ 'ac' ] !== 'view' ) {
2013-08-08 13:36:13 +02:00
$listCurrentDir = sortDir ( $listCurrentDir , $fullListDir );
2013-08-06 11:40:48 +02:00
foreach ( $listCurrentDir as $key => $value ) {
$thumbnail = getThumbnail ( $path , $key );
2013-07-29 17:28:45 +02:00
if ( empty ( $thumbnail )) {
2013-08-06 11:40:48 +02:00
echo '<a href="?bc=' , $ci [ 'bc' ] . $key , '"><span class="fulldir"></span>' , $value , '</a> ' ;
2013-07-12 17:25:57 +02:00
} else {
2013-08-06 11:40:48 +02:00
echo '<a href="?bc=' , $ci [ 'bc' ] . $key , '"><span class="dir"></span><img alt="Thumbnail of video" src="' , $thumbnail , '" />' , $value , '</a> ' ;
2013-07-12 17:25:57 +02:00
}
}
}
if ( ! empty ( $listCurrentFile ) && $ci [ 'ac' ] !== 'view' ) {
2013-12-23 16:09:58 +01:00
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 > ' ;
2013-08-08 13:36:13 +02:00
$listCurrentFile = sortFile ( $listCurrentFile , $fullListFile , $ci [ 'sort' ]);
2013-08-06 11:40:48 +02:00
foreach ( $listCurrentFile as $key => $value ) {
2013-08-09 13:52:08 +02:00
$thumb = '' ;
2013-08-06 11:40:48 +02:00
if ( $key == 'thumb' ) {
2013-07-29 17:28:45 +02:00
continue ;
}
2013-08-09 13:52:08 +02:00
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>' ;
2013-07-12 17:25:57 +02:00
}
}
2013-07-26 12:20:48 +02:00
echo '</div>' ;
2013-08-01 14:08:43 +02:00
if ( ! empty ( $ci [ 'ac' ]) && $ci [ 'ac' ] === 'view' && ! empty ( $listCurrentFile )) {
2013-07-26 15:40:30 +02:00
$_SESSION [ 'video' ] = $videoInfo [ 'hash' ];
2013-07-12 17:25:57 +02:00
if ( ! empty ( $videoInfo )) {
2013-08-06 15:40:31 +02:00
if ( empty ( $videoInfo [ 'title' ]) || empty ( $videoInfo [ 'uploadDateSort' ])) {
2015-01-29 11:44:46 +01:00
if ( empty ( $videoInfo [ 'title' ])) {
$fullTitle = $videoInfo [ 'originalTitle' ];
} else {
$fullTitle = $videoInfo [ 'title' ];
}
2013-08-06 15:40:31 +02:00
$uploadDate = $videoInfo [ 'uploadDate' ];
updateFileInfo ( $videoInfo [ 'hash' ], $fullTitle , $uploadDate );
2013-08-09 15:55:31 +02:00
$videoInfo [ 'title' ] = $fullTitle = $videoInfo [ 'originalTitle' ] . ' (' . $videoInfo [ 'originalTitle' ] . ')' ;
$videoInfo [ 'uploadDateSort' ] = $videoInfo [ 'uploadDate' ];
2013-12-20 16:10:56 +01:00
deleteCache ( $ci [ 'bc' ], $ci [ 'file' ], $ci [ 'sort' ], true );
2013-07-26 13:41:07 +02:00
} else {
$fullTitle = $videoInfo [ 'title' ] . ' (' . $videoInfo [ 'originalTitle' ] . ')' ;
}
2013-07-12 17:25:57 +02:00
echo '<div id="viewFile">' ;
2013-07-29 17:28:45 +02:00
echo '<h2>' , $fullTitle , '</h2>' ;
2013-07-26 10:06:54 +02:00
echo '<video width="640" controls="controls" poster="' , $path . $videoInfo [ 'hash' ], '.jpg">' ;
2013-07-12 17:25:57 +02:00
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>' ;
}
2013-07-29 17:28:45 +02:00
if ( $_SESSION [ 'log' ] === true ) {
echo ' < div id = " toolbar " >
2013-12-20 16:10:56 +01:00
< 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 >
2013-07-31 12:27:58 +02:00
< 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 >
2013-08-08 17:26:22 +02:00
< 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 >
2015-01-30 15:09:21 +01:00
< 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 >
2015-02-02 11:49:44 +01:00
< 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 >
2013-07-29 17:28:45 +02:00
</ div > ' ;
}
2013-08-01 16:18:20 +02:00
if ( $GLOBALS [ 'config' ][ 'DOWNLOAD_METHOD' ] === 'xsendfile' || $GLOBALS [ 'config' ][ 'DOWNLOAD_METHOD' ] === 'php' ) {
$downloadLink = '?bc=' . $ci [ 'bc' ] . '&dl=' . $videoInfo [ 'hash' ];
} else {
$downloadLink = $path . $videoInfo [ 'hash' ] . '.webm' ;
}
2013-07-12 17:25:57 +02:00
echo ' < table >
< tr >
< th > Title </ th >
2013-07-29 17:28:45 +02:00
< td > ', $videoInfo[' title '], ' </ td >
2013-07-26 13:41:07 +02:00
</ tr >
< tr >
< th > Original title </ th >
2013-07-29 17:28:45 +02:00
< td > ', $videoInfo[' originalTitle '], ' </ td >
2013-07-12 17:25:57 +02:00
</ tr >
< tr >
< th > Description </ th >
2013-07-26 10:06:54 +02:00
< td > ', $videoInfo[' desc '], ' </ td >
2013-07-12 17:25:57 +02:00
</ tr >
< tr >
< th > Original description </ th >
2013-07-26 10:06:54 +02:00
< td > ', $videoInfo[' originalDesc '], ' </ td >
2013-07-12 17:25:57 +02:00
</ tr >
< tr >
< th > Url </ th >
2015-01-29 11:44:46 +01:00
< td >< a href = " ', $videoInfo['url'] , ' " > ', $videoInfo[' url '], ' </ a ></ td >
2013-07-12 17:25:57 +02:00
</ tr >
< tr >
2013-07-26 10:06:54 +02:00
< th > Duration </ th >
< td > ', $videoInfo[' duration '], ' </ td >
2013-08-20 15:38:46 +02:00
< tr >
< tr >
< th > Size </ th >
< td > ', $videoInfo[' size '], ' </ td >
2013-07-26 10:06:54 +02:00
< tr >
< th > Publish date </ th >
2015-01-30 15:09:21 +01:00
< td > ', date("d m Y", strtotime($videoInfo[' uploadDate '])), ' </ td >
2013-07-12 17:25:57 +02:00
</ tr >
< tr >
< th > Via </ th >
2013-07-26 12:20:48 +02:00
< td > ' ;
2013-07-26 13:41:07 +02:00
if ( ! empty ( $videoInfo [ 'via' ])) {
2015-01-30 15:09:21 +01:00
echo '<a href="' , htmlentities ( $videoInfo [ 'via' ]), '">' , $videoInfo [ 'via' ], '</a>' ;
2013-07-26 13:41:07 +02:00
} else {
echo '' ;
}
2013-07-26 15:40:30 +02:00
echo ' </ td >
2013-07-12 17:25:57 +02:00
</ tr >
< tr >
< th > Licence </ th >
2013-07-26 10:06:54 +02:00
< td > ', $videoInfo[' licence '], ' </ td >
2013-07-12 17:25:57 +02:00
</ tr >
2013-07-26 15:40:30 +02:00
< tr >
< th > Download </ th >
2013-08-01 16:18:20 +02:00
< td >< a href = " ', $downloadLink , ' " > Download </ a ></ td >
2013-07-29 17:28:45 +02:00
</ tr >
< tr >
< th > View image preview </ th >
< td >< a href = " ', $path . $videoInfo['hash'] , '.jpg " > Image preview </ a ></ td >
2013-07-26 15:40:30 +02:00
</ tr >
2013-07-12 17:25:57 +02:00
</ table >
</ div > ' ;
}
2013-12-20 16:10:56 +01:00
?>