20 Commits

Author SHA1 Message Date
Alcea dea427c8d4 Add files via upload
Link support to stream from router via
--streamtplink.php--
<?php

if (!isset($_GET['path'])) {
    http_response_code(400);
    echo "Missing 'path' parameter.";
    exit;
}

$relativePath = ltrim($_GET['path'], '/');

// Validate file extension
if (strtolower(pathinfo($relativePath, PATHINFO_EXTENSION)) !== 'mp4') {
    http_response_code(403);
    echo "Only .mp4 files are allowed.";
    exit;
}

$ftpHost = '192.168.0.1';
$ftpPort = 21;
$ftpUser = 'anonymous';
$ftpPass = ''; // Typically anonymous password can be blank or email

// Connect to FTP
$conn = ftp_connect($ftpHost, $ftpPort, 10);
if (!$conn || !ftp_login($conn, $ftpUser, $ftpPass)) {
    http_response_code(500);
    echo "FTP connection failed.";
    exit;
}

// Get file size
$size = ftp_size($conn, $relativePath);
if ($size === -1) {
    ftp_close($conn);
    http_response_code(404);
    echo "File not found on FTP server.";
    exit;
}

$start = 0;
$end = $size - 1;
$length = $size;

if (isset($_SERVER['HTTP_RANGE']) &&
    preg_match('/bytes=(\d+)-(\d*)/', $_SERVER['HTTP_RANGE'], $matches)) {
    
    $start = intval($matches[1]);
    $end = ($matches[2] !== '') ? intval($matches[2]) : $end;

    if ($start > $end || $start >= $size) {
        ftp_close($conn);
        http_response_code(416);
        header("Content-Range: bytes */$size");
        exit;
    }

    $length = $end - $start + 1;
    http_response_code(206);
    header("Content-Range: bytes $start-$end/$size");
} else {
    http_response_code(200);
}

// Set headers
$filename = basename($relativePath);
header("Content-Type: video/mp4");
header("Content-Length: $length");
header("Accept-Ranges: bytes");
header("Content-Disposition: inline; filename=\"$filename\"");

// Open a temp stream
$tempHandle = fopen('php://temp', 'r+');

if (!ftp_fget($conn, $tempHandle, $relativePath, FTP_BINARY, 0)) {
    ftp_close($conn);
    http_response_code(500);
    echo "Failed to download file from FTP.";
    exit;
}
ftp_close($conn);

// Seek to the range offset
rewind($tempHandle);
if ($start > 0) {
    fseek($tempHandle, $start);
}

// Stream the requested range
$remaining = $length;
while (!feof($tempHandle) && $remaining > 0) {
    $chunkSize = min(8192, $remaining);
    $data = fread($tempHandle, $chunkSize);
    echo $data;
    flush();
    $remaining -= strlen($data);
}

fclose($tempHandle);
2025-08-23 01:55:16 +02:00
Alcea 79b101a9c3 Add files via upload
Total json parser rewrite
2025-08-09 08:25:39 +02:00
Alcea 7a8db252df Add files via upload
More robust parsing to catch
       "waybackurl": "https:\/\/web.archive.org\/web\/20250622154401\/https:\/\/alcea-wisteria.de\/ytarchive\/fin\/IwgICbILJ9o.mp4 "

(Which will break full video count)
2025-08-07 04:42:45 +02:00
Alcea a51a817b3a Add files via upload
More robust parsing to catch
       "waybackurl": "https:\/\/web.archive.org\/web\/20250622154401\/https:\/\/alcea-wisteria.de\/ytarchive\/fin\/IwgICbILJ9o.mp4 "

(Which will break full video count)
2025-08-07 04:16:09 +02:00
Alcea cfa5d23145 Add files via upload
Finally fixed issues with trailing json entries not showing up
2025-08-06 20:46:05 +02:00
Alcea 2d137f563e Add files via upload 2025-07-28 12:33:20 +02:00
Alcea 9ab1d43933 Add files via upload 2025-07-06 15:37:35 +02:00
Alcea b698f59ddf Add files via upload 2025-07-01 10:59:34 +02:00
Alcea a4050538ed Add files via upload 2025-07-01 10:31:14 +02:00
alceawisteria 85a4afa1cf Update index.html 2025-06-26 22:44:43 +02:00
alceawisteria c5da510d73 Upload files to "/" 2025-06-26 22:11:04 +02:00
alceawisteria cccd8f6413 Upload files to "/"
Preservetube addition
2025-06-25 22:50:18 +02:00
alceawisteria 538ca68b69 Upload files to "/" 2025-06-25 21:40:08 +02:00
alceawisteria 898bbc158b Update index.html 2025-06-25 17:09:29 +02:00
alceawisteria 31ed541475 Upload files to "/"
Added youtube link to replace archive version with online one (if exists)
2025-06-22 17:16:24 +02:00
alceawisteria df8e222779 Upload files to "/"
Online check manual.
Takes too long otherwise
2025-06-22 16:29:40 +02:00
alceawisteria ac1d849b71 Upload files to "/"
Added realtimesearch to searchbar
2025-06-22 16:04:08 +02:00
alceawisteria 33b3577b13 Upload files to "/"
Show number of archived videos in Searchbar
Wayback fixer php for nont-yet-timeststamp ed links
2025-06-22 14:39:28 +02:00
alceawisteria 8e7eaad356 Upload files to "/"
Better offline handling
2025-06-22 12:13:29 +02:00
alceawisteria c5ba30a087 Upload files to "/" 2025-06-22 10:14:49 +02:00