[add] multiple download method (Apache, X-Sendfile, PHP)
This commit is contained in:
parent
849eaab71c
commit
1fbeba5a0b
|
@ -11,7 +11,7 @@ if (!empty($ci['ac']) && $ci['ac'] === 'login') {
|
|||
<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="hidden" name="token" value="', $token, '"/>
|
||||
<input type="submit" />
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
@ -25,7 +25,7 @@ if (!empty($ci['ac']) && $ci['ac'] === 'newDir') {
|
|||
<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="hidden" name="token" value="', $token, '"/>
|
||||
<input type="submit"/>
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
@ -41,7 +41,7 @@ if (!empty($ci['ac']) && $ci['ac'] === 'renDir') {
|
|||
<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="hidden" name="token" value="', $token, '"/>
|
||||
<input type="submit"/>
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
@ -66,7 +66,7 @@ if (!empty($ci['ac']) && $ci['ac'] === 'addVideo') {
|
|||
<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="hidden" name="token" value="', $token, '"/>
|
||||
<input type="submit"/>
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
@ -80,7 +80,7 @@ if (!empty($ci['ac']) && $ci['ac'] === 'addThumbnail') {
|
|||
<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="hidden" name="token" value="', $token, '"/>
|
||||
<input type="submit"/>
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
@ -168,6 +168,11 @@ if (!empty($ci['ac']) && $ci['ac'] === 'view' && !empty($listCurrentFile)) {
|
|||
<a href="?ac=view&op=4&bc=', $ci['bc'], '&file=', $ci['file'], '&token=', $token, '"><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>
|
||||
|
@ -187,20 +192,20 @@ if (!empty($ci['ac']) && $ci['ac'] === 'view' && !empty($listCurrentFile)) {
|
|||
</tr>
|
||||
<tr>
|
||||
<th>Url</th>
|
||||
<td><a href="', htmlentities($videoInfo['url']), '">', $videoInfo['url'], '</a></td>
|
||||
<td><a href="', htmlentities($videoInfo['url']), '">', $videoInfo['url'], '</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Duration</th>
|
||||
<td>', $videoInfo['duration'], '</td>
|
||||
<tr>
|
||||
<th>Publish date</th>
|
||||
<td>', date("d m Y", strtotime($videoInfo['uploadDate'])), '</td>
|
||||
<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>';
|
||||
echo '<a href="', htmlentities($videoInfo['via']), '">', $videoInfo['via'], '</a>';
|
||||
} else {
|
||||
echo '';
|
||||
}
|
||||
|
@ -212,7 +217,7 @@ if (!empty($ci['ac']) && $ci['ac'] === 'view' && !empty($listCurrentFile)) {
|
|||
</tr>
|
||||
<tr>
|
||||
<th>Download</th>
|
||||
<td><a href="', $path.$videoInfo['hash'], '.webm">Download</a></td>
|
||||
<td><a href="', $downloadLink, '">Download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>View image preview</th>
|
||||
|
|
42
index.php
42
index.php
|
@ -23,7 +23,11 @@ $GLOBALS['config']['BAN_AFTER'] = 4;
|
|||
$GLOBALS['config']['BAN_DURATION'] = 1800;
|
||||
// Page cache directory.
|
||||
$GLOBALS['config']['PAGECACHE'] = 'pagecache';
|
||||
|
||||
// Download method
|
||||
// apache
|
||||
// xsendfile (use x-sendfile)
|
||||
// php
|
||||
$GLOBALS['config']['DOWNLOAD_METHOD'] = 'xsendfile';
|
||||
if (get_magic_quotes_gpc()) {
|
||||
function stripslashes_deep($value) {
|
||||
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
|
||||
|
@ -161,9 +165,9 @@ function n_print($data, $name = '') {
|
|||
<fieldset style="border: 1px solid orange; padding: 5px;color:#1E1915; background-color: #fff;">';
|
||||
echo '
|
||||
<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">
|
||||
', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '
|
||||
', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '
|
||||
</legend>';
|
||||
echo '<pre style="color:#1E1915;">', htmlentities(print_r($data, 1)), '</pre>';
|
||||
echo '<pre style="color:#1E1915;">', htmlentities(print_r($data, 1)), '</pre>';
|
||||
echo '
|
||||
</fieldset>
|
||||
<br />';
|
||||
|
@ -392,6 +396,35 @@ function convertToJpeg($path, $type) {
|
|||
unlink($pathAndNameFile);
|
||||
}
|
||||
|
||||
function sendVideo($bc, $file) {
|
||||
global $fullListFile;
|
||||
$path = chunk_split($bc, 8, '/');
|
||||
$fileName = html_entity_decode($fullListFile[$file]['title']).'.webm';
|
||||
$fileNameTesrt = 'tttt.webm';
|
||||
$fileSize = filesize($GLOBALS['config']['VIDEODIR'].'/'.$path.$file.'.webm');
|
||||
$pathAndFile = $GLOBALS['config']['VIDEODIR'].'/'.$path.$file.'.webm';
|
||||
|
||||
if ($GLOBALS['config']['DOWNLOAD_METHOD'] === 'php') {
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header("Content-Disposition: attachment; filename=\"$fileNameTesrt\"");
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: '.$fileSize);
|
||||
ob_clean();
|
||||
flush();
|
||||
readfile($GLOBALS['config']['VIDEODIR'].'/'.$path.$file.'.webm');
|
||||
}
|
||||
if ($GLOBALS['config']['DOWNLOAD_METHOD'] === 'xsendfile') {
|
||||
header("X-Sendfile: $pathAndFile");
|
||||
header("Content-type: application/octet-stream");
|
||||
header('Content-Disposition: attachment; filename="'.$fileName);
|
||||
}
|
||||
exit ;
|
||||
}
|
||||
|
||||
if (!empty($ci['ac']) && $ci['ac'] === 'login' && !empty($ci['op']) && (int)$ci['op'] === 2) {
|
||||
verifToken($ci['token']);
|
||||
if (login($ci) === true) {
|
||||
|
@ -443,6 +476,9 @@ if (isset($ci['ac']) && !empty($ci['ac'])) {
|
|||
$page = 'admin';
|
||||
}
|
||||
}
|
||||
if (isset($ci['dl']) && !empty($ci['dl'])) {
|
||||
sendVideo($ci['bc'], $ci['dl']);
|
||||
}
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
|
|
|
@ -4,4 +4,5 @@ AddType video/webm .webm
|
|||
<Files *.webm>
|
||||
ForceType application/octet-stream
|
||||
Header set Content-Disposition attachment
|
||||
</Files>
|
||||
</Files>
|
||||
XSendFile on
|
Loading…
Reference in New Issue