-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstream.php
More file actions
73 lines (59 loc) · 2.34 KB
/
stream.php
File metadata and controls
73 lines (59 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/******************************************************************************
* Software: Pass - Private Audio Streaming Service *
* Version: 0.1 Alpha *
* Date: 2025-03-15 *
* Author: Sandeep - sans *
* License: Free for All Church and Ministry Usage *
* *
* You may use and modify this software as you wish. *
* But Give Credits and Feedback *
*******************************************************************************/
// Enable error reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'includes/functions.php';
require_once 'includes/auth.php';
// Check if session ID is provided
if (!isset($_GET['sid'])) {
header('HTTP/1.1 400 Bad Request');
exit('Session ID not provided');
}
$session_id = $_GET['sid'];
// Get session data
$session = db_select_one("SELECT * FROM streaming_sessions WHERE session_id = '$session_id'");
if (!$session) {
header('HTTP/1.1 404 Not Found');
exit('Session not found');
}
// Get audio file data
$audio_file = db_select_one("SELECT * FROM audio_files WHERE id = {$session['audio_file_id']}");
if (!$audio_file) {
header('HTTP/1.1 404 Not Found');
exit('Audio file not found');
}
// Define file path
$file_path = AUDIO_DIR . '/' . $audio_file['file_path'];
// Debug - check if file exists
if (!file_exists($file_path)) {
header('HTTP/1.1 404 Not Found');
exit("File not found: $file_path");
}
// Debug - log file info
error_log("Streaming file: $file_path");
error_log("File size: " . filesize($file_path) . " bytes");
// Set headers for streaming
header('Content-Type: audio/mpeg');
header('Content-Length: ' . filesize($file_path));
header('Content-Disposition: inline; filename="audio.mp3"');
header('Accept-Ranges: bytes');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Expires: 0');
// Update session
db_update('streaming_sessions', [
'last_active_at' => date('Y-m-d H:i:s')
], "id = {$session['id']}");
// Stream the file
readfile($file_path);
exit;