Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /mnt/stoughton/include/ |
Upload File : |
<?php
// copy vtt from specified cdn to current
// /copy/[encrypted auth data]/[sourcemirror]
require_once __DIR__ . '/class.media-source.php';
require_once __DIR__ . '/RangeHeader.php';
require_once __DIR__ . '/class.captions.php';
$payload = empty($_GET['auth']) ? '' : $_GET['auth'];
$filename = empty($_GET['file']) ? '' : $_GET['file']; // source cdn site
$query = $_SERVER['REQUEST_URI'];
if (($p = strpos($query, '?')) !== FALSE) {
$query = substr($query, $p + 1);
parse_str($query, $res);
} else {
$res = [];
}
$source = new MediaSource;
$param = $source->decodeAuth($payload);
if (!$param->valid) {
header('Content-type: text/plain');
die("Invalid Link");
}
if ($param->expired) {
header('Content-type: text/plain');
//echo "debug: expired link\n";
die("Expired Link");
}
$sourcefile = dirname(__DIR__) . '/' . substr($param->id, 0, 1) . '/' . $param->id . '.' . $param->ext;
while (ob_get_level())
ob_end_clean();
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, DELETE, PUT, PATCH, OPTIONS');
header('Access-Control-Allow-Headers: token, Content-Type');
header('Access-Control-Max-Age: 86400');
header('Content-Length: 0');
header('Content-Type: text/plain');
die();
}
header('Access-Control-Allow-Origin: *');
header('Content-type: text/plain');
// determine server
$x = trim(`/bin/hostname`);
switch($x) {
case 'minimac18.local':
$server = MediaSource::BACKUP1;
break;
case 'alcor':
$server = MediaSource::ALCOR;
break;
case 'stoughton':
$server = MediaSource::CHURCH;
break;
default:
die('Unable to determine CDN from hostname');
}
// create new auth; get the file from the source cdn. Assumes source is vtt file
$mmitem = new \StdClass;
$mmitem->mi_id = $param->id;
$source->MmItem($mmitem);
$auth = $source->generateAuth($param->ext); // a new auth
// fetch the file from requested cdn
$url = "https://cdn{$filename}.hopeinstoughton.org/file/$auth";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$returned_text = curl_exec($ch);
curl_close($ch);
if (strlen($returned_text) > 512) {
// save it
file_put_contents($sourcefile, $returned_text);
$postRequest = [
'auth' => $auth,
'type' => $param->ext,
];
// mark as uploaded - curl request including: auth, type and $server
$url = "https://hopeinstoughton.org/~/cdn-sync?cdn={$server}";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postRequest);
$returned_text = curl_exec($ch);
curl_close($ch);
$result = json_decode($returned_text);
}
die("status=ok\n");