mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 16:33:00 +00:00
Redriect to video / audio if storage dir is the current directory
This commit is contained in:
parent
bb10011606
commit
4de2f62e77
3 changed files with 51 additions and 3 deletions
|
@ -2789,6 +2789,16 @@ register_module([
|
||||||
}
|
}
|
||||||
/// ETag handling end ///
|
/// ETag handling end ///
|
||||||
|
|
||||||
|
/* Disabled until we work out what to do about caching previews *
|
||||||
|
$previewFilename = "$filepath.preview.$outputFormat";
|
||||||
|
if($target_size === $settings->default_preview_size)
|
||||||
|
{
|
||||||
|
// The request is for the default preview size
|
||||||
|
// Check to see if we have a preview pre-rendered
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
$preview = new Imagick();
|
$preview = new Imagick();
|
||||||
switch(substr($mime_type, 0, strpos($mime_type, "/")))
|
switch(substr($mime_type, 0, strpos($mime_type, "/")))
|
||||||
{
|
{
|
||||||
|
@ -2808,6 +2818,14 @@ register_module([
|
||||||
|
|
||||||
case "video":
|
case "video":
|
||||||
case "audio":
|
case "audio":
|
||||||
|
if($settings->data_storage_dir == ".")
|
||||||
|
{
|
||||||
|
// The data storage directory is the current directory
|
||||||
|
// Redirect to the file isntead
|
||||||
|
http_response_code(307);
|
||||||
|
header("location: " . $pageindex->{$env->page}->uploadedfilepath);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
// TODO: Add support for ranges here.
|
// TODO: Add support for ranges here.
|
||||||
// Get the file size
|
// Get the file size
|
||||||
$filesize = filesize($filepath);
|
$filesize = filesize($filepath);
|
||||||
|
@ -2837,8 +2855,14 @@ register_module([
|
||||||
// Send the completed preview image to the user
|
// Send the completed preview image to the user
|
||||||
header("content-type: $output_mime");
|
header("content-type: $output_mime");
|
||||||
header("x-generation-time: " . (microtime(true) - $start_time) . "s");
|
header("x-generation-time: " . (microtime(true) - $start_time) . "s");
|
||||||
$preview->setImageFormat(substr($output_mime, strpos($output_mime, "/") + 1));
|
$outputFormat = substr($output_mime, strpos($output_mime, "/") + 1);
|
||||||
|
$preview->setImageFormat($outputFormat);
|
||||||
echo($preview->getImageBlob());
|
echo($preview->getImageBlob());
|
||||||
|
/* Disabled while we work out what to do about caching previews *
|
||||||
|
// Save a preview file if there isn't one alreaddy
|
||||||
|
if(!file_exists($previewFilename))
|
||||||
|
file_put_contents($previewFilename, $preview->getImageBlob());
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
"author": "Starbeamrainbowlabs",
|
"author": "Starbeamrainbowlabs",
|
||||||
"description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File:' prefix.",
|
"description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File:' prefix.",
|
||||||
"id": "feature-upload",
|
"id": "feature-upload",
|
||||||
"lastupdate": 1460282792,
|
"lastupdate": 1460283999,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -243,6 +243,16 @@ register_module([
|
||||||
}
|
}
|
||||||
/// ETag handling end ///
|
/// ETag handling end ///
|
||||||
|
|
||||||
|
/* Disabled until we work out what to do about caching previews *
|
||||||
|
$previewFilename = "$filepath.preview.$outputFormat";
|
||||||
|
if($target_size === $settings->default_preview_size)
|
||||||
|
{
|
||||||
|
// The request is for the default preview size
|
||||||
|
// Check to see if we have a preview pre-rendered
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
$preview = new Imagick();
|
$preview = new Imagick();
|
||||||
switch(substr($mime_type, 0, strpos($mime_type, "/")))
|
switch(substr($mime_type, 0, strpos($mime_type, "/")))
|
||||||
{
|
{
|
||||||
|
@ -262,6 +272,14 @@ register_module([
|
||||||
|
|
||||||
case "video":
|
case "video":
|
||||||
case "audio":
|
case "audio":
|
||||||
|
if($settings->data_storage_dir == ".")
|
||||||
|
{
|
||||||
|
// The data storage directory is the current directory
|
||||||
|
// Redirect to the file isntead
|
||||||
|
http_response_code(307);
|
||||||
|
header("location: " . $pageindex->{$env->page}->uploadedfilepath);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
// TODO: Add support for ranges here.
|
// TODO: Add support for ranges here.
|
||||||
// Get the file size
|
// Get the file size
|
||||||
$filesize = filesize($filepath);
|
$filesize = filesize($filepath);
|
||||||
|
@ -291,8 +309,14 @@ register_module([
|
||||||
// Send the completed preview image to the user
|
// Send the completed preview image to the user
|
||||||
header("content-type: $output_mime");
|
header("content-type: $output_mime");
|
||||||
header("x-generation-time: " . (microtime(true) - $start_time) . "s");
|
header("x-generation-time: " . (microtime(true) - $start_time) . "s");
|
||||||
$preview->setImageFormat(substr($output_mime, strpos($output_mime, "/") + 1));
|
$outputFormat = substr($output_mime, strpos($output_mime, "/") + 1);
|
||||||
|
$preview->setImageFormat($outputFormat);
|
||||||
echo($preview->getImageBlob());
|
echo($preview->getImageBlob());
|
||||||
|
/* Disabled while we work out what to do about caching previews *
|
||||||
|
// Save a preview file if there isn't one alreaddy
|
||||||
|
if(!file_exists($previewFilename))
|
||||||
|
file_put_contents($previewFilename, $preview->getImageBlob());
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue