forked from HPR/hpr_hub
Support for WYSIWYG upload server side
This commit is contained in:
48
hub/ccdn.php
48
hub/ccdn.php
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
# request.php > request_confirm.php > upload.php > upload_confirm.php
|
||||
|
||||
## Recent Changes
|
||||
# Support multiple mirrors
|
||||
|
||||
require "/home/hpr/php/include.php";
|
||||
|
||||
$ip = $_SERVER["REMOTE_ADDR"];
|
||||
@@ -52,12 +56,11 @@ if ( isset($_GET["filename"]) ) {
|
||||
naughty("c6a4329fe2f3c2c739ec666e956c2c5f");
|
||||
}
|
||||
|
||||
$prefix =pathinfo($filename, PATHINFO_FILENAME); // File name without extension
|
||||
$prefix = pathinfo($filename, PATHINFO_FILENAME); // File name without extension
|
||||
if ( empty($prefix) ) {
|
||||
naughty("f398399ec10ec9ab4b5b23ae43f21b01");
|
||||
}
|
||||
|
||||
|
||||
if ( strlen($filename) < 5 ) {
|
||||
naughty("f78bf180af9239fc7fcf5fbc2b13b59b");
|
||||
}
|
||||
@@ -66,27 +69,38 @@ if ( isset($_GET["filename"]) ) {
|
||||
naughty("38e9a0cf7f650ac62e75c08269c9d913");
|
||||
}
|
||||
|
||||
if ( !(
|
||||
strcmp($ext, "flac") === 0 or
|
||||
strcmp($ext, "jpg") === 0 or
|
||||
strcmp($ext, "json") === 0 or
|
||||
strcmp($ext, "mp3") === 0 or
|
||||
strcmp($ext, "ogg") === 0 or
|
||||
strcmp($ext, "opus") === 0 or
|
||||
strcmp($ext, "png") === 0 or
|
||||
strcmp($ext, "spx") === 0 or
|
||||
strcmp($ext, "srt") === 0 or
|
||||
strcmp($ext, "tsv") === 0 or
|
||||
strcmp($ext, "txt") === 0 or
|
||||
strcmp($ext, "vtt") === 0 )
|
||||
) {
|
||||
if (!in_array( $ext, $allowed_extensions, true )) {
|
||||
logextra( "This extension $this_ext, is not in the list of allowed_extensions" );
|
||||
naughty("545e49f7ac913863c6c3db40670ebb9d");
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
naughty("0b78322e1c5010ba289c20250ca1fb1f");
|
||||
}
|
||||
|
||||
header("location:https://alpha.nl.eu.mirror.hackerpublicradio.org${filename}");
|
||||
if (
|
||||
strcmp($dirname, "/eps") === 0 and
|
||||
in_array( $ext, $allowed_extensions_common, true )
|
||||
) {
|
||||
$mirrors = array_merge($ccdn_hosts_common, $ccdn_hosts_complete);
|
||||
}
|
||||
else {
|
||||
$mirrors = $ccdn_hosts_complete;
|
||||
}
|
||||
|
||||
$mirror = 'https://' . $mirrors[ array_rand($mirrors, 1) ];
|
||||
|
||||
$pos = strpos($mirror, 'archive.org');
|
||||
|
||||
if ($pos !== false) {
|
||||
$path = $mirror . '/download/' . $prefix . '/' . $name;
|
||||
} else {
|
||||
$path = $mirror . $filename;
|
||||
}
|
||||
|
||||
logextra( "Sending request to ${path}" );
|
||||
|
||||
header("location:${path}");
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user