-
Notifications
You must be signed in to change notification settings - Fork 13
/
stream.php
669 lines (561 loc) · 23.8 KB
/
stream.php
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
<?php
// +------------------------------------------------------------------------+
// | O!MPD, Copyright � 2015-2021 Artur Sierzant |
// | http://www.ompd.pl |
// | |
// | |
// | netjukebox, Copyright � 2001-2012 Willem Bartels |
// | |
// | http://www.netjukebox.nl |
// | http://forum.netjukebox.nl |
// | |
// | This program is free software: you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation, either version 3 of the License, or |
// | (at your option) any later version. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program. If not, see <http://www.gnu.org/licenses/>. |
// +------------------------------------------------------------------------+
// +------------------------------------------------------------------------+
// | stream.php |
// +------------------------------------------------------------------------+
require_once('include/initialize.inc.php');
require_once('include/stream.inc.php');
require_once('include/cache.inc.php');
require_once('include/play.inc.php');
$action = get('action');
$album_id = get('album_id');
$track_id = get('track_id');
if ($action == 'playlist') playlist();
//elseif ($action == 'playTo') playTo();
elseif ($action == 'stream') stream();
elseif ($action == 'streamTo') streamTo();
elseif ($action == 'streamTidal') streamTidal($track_id);
elseif ($action == 'streamYouTube') streamYouTube($track_id);
elseif ($action == 'streamHRA') streamHRA($track_id);
elseif ($action == 'shareAlbum') shareAlbum($album_id);
else message(__FILE__, __LINE__, 'error', '[b]Unsupported input value for[/b][br]action');
exit();
// +------------------------------------------------------------------------+
// | Playlist |
// +------------------------------------------------------------------------+
function playlist() {
global $cfg, $db;
$stream_id = get('stream_id');
$track_id = get('track_id');
$album_id = get('album_id');
$favorite_id = get('favorite_id');
$random = get('random');
$sid = get('sid');
if ($sid) {
// Share stream
header('Expires: Mon, 9 Oct 2000 18:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
mysqli_query($db,'UPDATE share_stream SET
ip = "' . mysqli_real_escape_string($db,$_SERVER['REMOTE_ADDR']) . '"
WHERE sid = BINARY "' . mysqli_real_escape_string($db,$sid) . '"
AND ip = ""');
$query = mysqli_query($db,'SELECT album_id, stream_id
FROM share_stream
WHERE sid = BINARY "' . mysqli_real_escape_string($db,$sid) . '"
AND ip = "' . mysqli_real_escape_string($db,$_SERVER['REMOTE_ADDR']) . '"
AND expire_time > ' . (int) time());
$share_stream = mysqli_fetch_assoc($query);
if ($share_stream == false || $cfg['album_share_stream'] == false)
message(__FILE__, __LINE__, 'error', '[b]Stream failed[/b][br]Authentication failed or share stream is disabled');
$album_id = $share_stream['album_id'];
$stream_id = $share_stream['stream_id'];
}
else {
// Common stream
authenticate('access_stream');
}
if ($sid) {
$query = mysqli_query($db,'SELECT artist, title, relative_file, miliseconds, audio_bitrate, track_id
FROM track, share_stream
WHERE share_stream.sid = "' . mysqli_real_escape_string($db,$sid) . '" AND
share_stream.album_id = track.album_id
ORDER BY relative_file');
}
elseif ($track_id) {
$query = mysqli_query($db,'SELECT artist, title, relative_file, miliseconds, audio_bitrate, track_id FROM track WHERE track_id = "' . mysqli_real_escape_string($db,$track_id) . '"');
}
elseif ($album_id) {
$query = mysqli_query($db,'SELECT artist, title, relative_file, miliseconds, audio_bitrate, track_id FROM track WHERE album_id = "' . mysqli_real_escape_string($db,$album_id) . '" ORDER BY relative_file');
}
elseif ($favorite_id) {
$query = mysqli_query($db,'SELECT stream
FROM favorite
WHERE favorite_id = ' . (int) $favorite_id . '
AND stream = 1');
if (mysqli_fetch_row($query))
streamPlaylist($favorite_id);
$query = mysqli_query($db,'SELECT track.artist, track.title, track.relative_file, track.miliseconds, track.audio_bitrate, track.track_id
FROM track, favoriteitem
WHERE favoriteitem.track_id = track.track_id
AND favorite_id = "' . mysqli_real_escape_string($db,$favorite_id) . '"
ORDER BY position');
}
elseif ($random == 'database') {
$query = mysqli_query($db,'SELECT artist, title, relative_file, miliseconds, audio_bitrate, track.track_id
FROM track, random
WHERE random.sid = "' . mysqli_real_escape_string($db,$cfg['sid']) . '" AND
random.track_id = track.track_id
ORDER BY position');
}
elseif ($random == 'new') {
$blacklist = explode(',', $cfg['random_blacklist']);
$blacklist = '"' . implode('","', $blacklist) . '"';
$query = mysqli_query($db,'SELECT track.artist, title, relative_file, miliseconds, audio_bitrate, track_id
FROM track, album
WHERE (genre_id = "" OR genre_id NOT IN (' . $blacklist . ')) AND
audio_dataformat != "" AND
video_dataformat = "" AND
track.album_id = album.album_id
ORDER BY RAND()
LIMIT 30');
}
else
message(__FILE__, __LINE__, 'error', '[b]Unsupported query string[/b][br]' . $_SERVER['QUERY_STRING']);
if ($stream_id != -1 && isset($cfg['encode_extension'][$stream_id]) == false)
message(__FILE__, __LINE__, 'error', '[b]Unsupported input value for[/b][br]stream_id');
createHiddenDir(NJB_HOME_DIR . 'stream/');
$m3u = 'stream/netjukebox_' . randomHex() . '.m3u';
$m3u_content = '#EXTM3U' . "\n";
while ($track = mysqli_fetch_assoc($query)) {
$extension = substr(strrchr($track['relative_file'], '.'), 1);
$extension = strtolower($extension);
if (sourceFile($extension, $track['audio_bitrate'], $stream_id))
$stream_extension = $extension;
else
$stream_extension = $cfg['encode_extension'][$stream_id];
if ($sid) {
// Share stream
$url = NJB_HOME_URL . 'stream.php?action=stream&stream_id=' . $stream_id . '&track_id=' . $track['track_id'] . '&sid=' . $sid . '&ext=.' . $stream_extension;
}
else {
// Common stream
$hash = hmacsha1($cfg['server_seed'], $track['track_id'] . $stream_id . $cfg['sid']);
$url = NJB_HOME_URL . 'stream.php?action=stream&stream_id=' . $stream_id . '&track_id=' . $track['track_id'] . '&sid=' . $cfg['sid'] . '&hash=' . $hash . '&ext=.' . $stream_extension;
}
$m3u_content .= '#EXTINF:' . round($track['miliseconds'] / 1000) . ',' . $track['artist'] . ' - ' . $track['title'] . "\n";
$m3u_content .= $url . "\n";
}
$m3u_content .= '#EXT-X-ENDLIST' . "\n";
if (file_put_contents(NJB_HOME_DIR . $m3u, $m3u_content) === false)
message(__FILE__, __LINE__, 'error', '[b]Failed to write file:[/b][br]' . NJB_HOME_DIR . $m3u);
// Cleanup stream directory
$dir = NJB_HOME_DIR . 'stream/';
$entries = @scandir($dir) or message(__FILE__, __LINE__, 'error', '[b]Failed to open directory:[/b][br]' . $dir);
foreach ($entries as $entry) {
$file = $dir . $entry;
if (!in_array($entry, array('.', '..', 'index.php','.gitignore')) && is_file($file) && filemtime($file) < filemtime(NJB_HOME_DIR . $m3u) - 86400)
@unlink($file);
}
if ($album_id)
updateCounter($album_id, NJB_COUNTER_STREAM);
header('Location: ' . NJB_HOME_URL . $m3u);
exit();
}
// +------------------------------------------------------------------------+
// | Stream playlist |
// +------------------------------------------------------------------------+
function streamPlaylist($favorite_id) {
global $cfg, $db;
createHiddenDir(NJB_HOME_DIR . 'stream/');
$m3u = 'stream/netjukebox_' . randomHex() . '.m3u';
$m3u_content = '#EXTM3U' . "\n";
$query = mysqli_query($db,'SELECT stream_url FROM favoriteitem WHERE favorite_id = ' . (int) $favorite_id . ' AND stream_url != "" ORDER BY position');
while ($favoriteitem = mysqli_fetch_assoc($query))
$m3u_content .= $favoriteitem['stream_url'] . "\n";
$m3u_content .= '#EXT-X-ENDLIST' . "\n";
if (file_put_contents(NJB_HOME_DIR . $m3u, $m3u_content) === false)
message(__FILE__, __LINE__, 'error', '[b]Failed to write file:[/b][br]' . NJB_HOME_DIR . $m3u);
header('Location: ' . NJB_HOME_URL . $m3u);
exit();
}
// +------------------------------------------------------------------------+
// | Stream |
// +------------------------------------------------------------------------+
function stream() {
global $cfg, $db;
$track_id = get('track_id');
$stream_id = (int) get('stream_id');
$sid = get('sid');
$hash = get('hash');
if ($stream_id != -1 && isset($cfg['encode_extension'][$stream_id]) == false) {
header('HTTP/1.1 400 Bad Request');
exit();
}
if ($hash) authenticateStream();
else authenticateShareStream();
$query = mysqli_query($db,'SELECT
LOWER(SUBSTRING_INDEX(relative_file, ".", -1)) AS extension,
track.artist, title, album, album.year, disc, discs, number,
relative_file, mime_type, miliseconds, filesize, filemtime, audio_bitrate
FROM track, album
WHERE track_id = "' . mysqli_real_escape_string($db,$track_id) . '"
AND track.album_id = album.album_id');
$track = mysqli_fetch_assoc($query);
$file = $cfg['media_dir'] . $track['relative_file'];
if (sourceFile($track['extension'], $track['audio_bitrate'], $stream_id)) {
// Stream from source
streamFile($file, $track['mime_type']);
}
elseif ($cache = cacheGetFile($track_id, $stream_id)) {
// Stream from cache
cacheUpdateTag($track_id, $stream_id, $cache);
streamFile($cache, $cfg['encode_mime_type'][$stream_id]);
}
else {
// Real time transcode stream
ini_set('zlib.output_compression', 'off');
ini_set('max_execution_time', 0);
if (file_exists(NJB_HOME_DIR . '-'))
@unlink(NJB_HOME_DIR . '-');
$cmd = $cfg['decode_stdout'][$track['extension']] . ' | ' . $cfg['encode_stdout'][$stream_id];
$cmd = str_replace('%source', escapeCmdArg($file), $cmd);
header('Accept-Ranges: none');
header('Content-Type: ' . $cfg['encode_mime_type'][$stream_id]);
if (@passthru($cmd) == false) {
header('HTTP/1.1 500 Internal Server Error');
exit();
}
}
}
// +------------------------------------------------------------------------+
// | Stream to other mpd in network |
// +------------------------------------------------------------------------+
function streamTo() {
global $cfg, $db;
$track_id = get('track_id');
$filepath = get('filepath');
$filepath = str_replace('ompd_ampersand_ompd','&',$filepath);
$stream_id = (int) get('stream_id');
$sid = get('sid');
$hash = get('hash');
if ($stream_id != -1 && isset($cfg['encode_extension'][$stream_id]) == false) {
header('HTTP/1.1 400 Bad Request');
exit();
}
/* if ($hash) authenticateStream();
else authenticateShareStream(); */
if ($filepath) {
$mime = mime_content_type_replacement($filepath);
if (strpos($mime, 'audio') !== false) {
streamFile($filepath, $mime);
}
}
$query = mysqli_query($db,'SELECT
LOWER(SUBSTRING_INDEX(relative_file, ".", -1)) AS extension,
track.artist, title, album, album.year, disc, discs, number,
relative_file, mime_type, miliseconds, filesize, filemtime, audio_bitrate
FROM track, album
WHERE track_id = "' . mysqli_real_escape_string($db,$track_id) . '"
AND track.album_id = album.album_id');
$track = mysqli_fetch_assoc($query);
$file = $cfg['media_dir'] . $track['relative_file'];
if (sourceFile($track['extension'], $track['audio_bitrate'], $stream_id)) {
// Stream from source
streamFile($file, $track['mime_type']);
}
elseif ($cache = cacheGetFile($track_id, $stream_id)) {
// Stream from cache
cacheUpdateTag($track_id, $stream_id, $cache);
streamFile($cache, $cfg['encode_mime_type'][$stream_id]);
}
else {
// Real time transcode stream
ini_set('zlib.output_compression', 'off');
ini_set('max_execution_time', 0);
if (file_exists(NJB_HOME_DIR . '-'))
@unlink(NJB_HOME_DIR . '-');
$cmd = $cfg['decode_stdout'][$track['extension']] . ' | ' . $cfg['encode_stdout'][$stream_id];
$cmd = str_replace('%source', escapeCmdArg($file), $cmd);
header('Accept-Ranges: none');
header('Content-Type: ' . $cfg['encode_mime_type'][$stream_id]);
if (@passthru($cmd) == false) {
header('HTTP/1.1 500 Internal Server Error');
exit();
}
}
}
// +------------------------------------------------------------------------+
// | Stream Tidal track |
// +------------------------------------------------------------------------+
function streamTidal($id) {
global $cfg, $db, $t;
cliLog('======================================================');
cliLog('New Tidal stream for track ' . $id);
cliLog('======================================================');
$conn = $t->connect();
if ($conn === true){
$trackURL = $t->getStreamURL($id);
for ($i=0;$i<4;$i++) {
//get 8 bytes of stream to make sure that stream is ready
$stream = file_get_contents($trackURL["url"], NULL, NULL, 0, 8);
if (strlen($stream) > 0) {
cliLog('trackURL: ' . $trackURL["url"]);
cliLog('timestamp: ' . time() . ' stream: ' . $stream . ' iteration: ' . $i);
break;
}
}
if ($cfg['fix_tidal_freezes']) {
$logWD = 'false';
if ($cfg['debug']) $logWD = 'true';
$handle = popen('curl "' . NJB_HOME_URL . 'watchdog.php?host=' . $_SERVER['REMOTE_ADDR'] . '&port=6600&track_id=' . $id .'&logWD=' . $logWD .' " &', 'r');
}
cliLog('About to redirect...');
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header("Location: " . $trackURL["url"]);
cliLog('Redirect done.');
exit;
}
else {
cliLog('TIDAL_CONNECT_ERROR for id=' . $id);
echo 'TIDAL_CONNECT_ERROR';
var_dump($conn);
}
}
// +------------------------------------------------------------------------+
// | Stream HRA track |
// +------------------------------------------------------------------------+
function streamHRA($id) {
global $cfg, $db;
$h = new HraAPI;
$h->username = $cfg["hra_username"];
$h->password = $cfg["hra_password"];
if (NJB_WINDOWS) $h->fixSSLcertificate();
$conn = $h->connect();
if ($conn === true){
$results = $h->getTrack($id);
}
else {
return false;
}
if ($results["data"]["results"]["tracks"]) {
$url = $results["data"]["results"]["tracks"]["url"];
}
/* $streamUrl = get('streamUrl');
$parts = parse_url($streamUrl);
parse_str($parts['query'], $query);
$expire = (int) $query['expire'];
if ($expire > time()){
$url = $streamUrl;
}
else {
$url = getYouTubeStreamUrl($id);
} */
if ($url){
//$stream = file_get_contents($trackURL["url"], NULL, NULL, 0, 8);
cliLog('HRA track URL for ' . $id . ': ' . $url);
header("Location: " . $url);
}
else {
echo 'HRA_CONNECT_ERROR';
var_dump($url);
}
}
// +------------------------------------------------------------------------+
// | Stream YouTube track |
// +------------------------------------------------------------------------+
function streamYouTube($id) {
global $cfg, $db;
$streamUrl = get('streamUrl');
$parts = parse_url($streamUrl);
parse_str($parts['query'], $query);
$expire = (int) $query['expire'];
if ($expire > time()){
$url = $streamUrl;
}
else {
$url = getYouTubeStreamUrl($id);
}
if ($url){
//$stream = file_get_contents($trackURL["url"], NULL, NULL, 0, 8);
cliLog('YouTube track URL for ' . $id . ': ' . $url);
header("Location: " . $url);
}
else {
echo 'YOUTUBE_CONNECT_ERROR';
var_dump($url);
}
}
// +------------------------------------------------------------------------+
// | Authenticate stream |
// +------------------------------------------------------------------------+
function authenticateStream() {
global $cfg, $db;
header('Expires: Mon, 9 Oct 2000 18:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
$track_id = get('track_id');
$stream_id = (int) get('stream_id');
$sid = get('sid');
$hash = get('hash');
$query = mysqli_query($db,'SELECT logged_in, idle_time, user_id, ip FROM session WHERE sid = BINARY "' . mysqli_real_escape_string($db,$sid) . '"');
$session = mysqli_fetch_assoc($query);
$query = mysqli_query($db,'SELECT access_stream FROM user WHERE user_id = ' . (int) $session['user_id']);
$user = mysqli_fetch_assoc($query);
if ($session['logged_in'] &&
$session['idle_time'] + $cfg['session_lifetime'] > time() &&
$session['ip'] == $_SERVER['REMOTE_ADDR'] &&
$hash == hmacsha1($cfg['server_seed'], $track_id . $stream_id . $sid) &&
$user['access_stream']) {
mysqli_query($db,'UPDATE session SET
idle_time = ' . (int) time() . ',
hit_counter = hit_counter + 1,
visit_counter = visit_counter + ' . (time() > $session['idle_time'] + 3600 ? 1 : 0) . '
WHERE sid = BINARY "' . mysqli_real_escape_string($db,$sid) . '"');
return true;
}
header('HTTP/1.1 403 Forbidden');
exit();
}
// +------------------------------------------------------------------------+
// | Authenticate share stream |
// +------------------------------------------------------------------------+
function authenticateShareStream() {
global $cfg, $db;
header('Expires: Mon, 9 Oct 2000 18:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
$sid = get('sid');
$track_id = get('track_id');
$album_id = substr($track_id, 0, strpos($track_id, '_'));
$query = mysqli_query($db,'SELECT ip, album_id, stream_id, expire_time FROM share_stream
WHERE sid = BINARY "' . mysqli_real_escape_string($db,$sid) . '"');
$share_stream = mysqli_fetch_assoc($query);
if ($share_stream['ip'] == $_SERVER['REMOTE_ADDR'] &&
$share_stream['album_id'] == $album_id &&
$share_stream['expire_time'] > time())
return true;
header('HTTP/1.1 403 Forbidden');
exit();
}
// +------------------------------------------------------------------------+
// | Share album |
// +------------------------------------------------------------------------+
function shareAlbum($album_id) {
global $cfg, $db;
authenticate('access_admin', false, true);
if ($cfg['album_share_stream'] == false)
message(__FILE__, __LINE__, 'error', '[b]Error[/b][br]Share album disabled');
$query = mysqli_query($db,'SELECT artist_alphabetic, album, year
FROM album
WHERE album_id = "' . mysqli_real_escape_string($db,$album_id) . '"');
$album = mysqli_fetch_assoc($query);
if ($album == false)
message(__FILE__, __LINE__, 'error', '[b]Error[/b][br]album_id not found in database');
// formattedNavigator
$nav = array();
$nav['name'][] = 'Media';
$nav['url'][] = 'index.php';
$nav['name'][] = $album['artist_alphabetic'];
$nav['url'][] = 'index.php?action=view2&artist=' . rawurlencode($album['artist_alphabetic']);
$nav['name'][] = $album['album'];
$nav['url'][] = 'index.php?action=view3&album_id=' . $album_id;
$nav['name'][] = 'Share stream';
require_once('include/header.inc.php');
$expire_time = time() + $cfg['share_stream_lifetime'];
$sid = randomKey();
mysqli_query($db,'INSERT INTO share_stream (sid, album_id, stream_id, expire_time) VALUES (
"' . mysqli_real_escape_string($db,$sid) . '",
"' . mysqli_real_escape_string($db,$album_id) . '",
' . (int) $cfg['stream_id'] . ',
' . (int) $expire_time . ')');
$url = NJB_HOME_URL . 'stream.php?action=playlist&sid=' . $sid;
$name = $album['artist_alphabetic'] . ' - ';
$name .= ($album['year']) ? $album['year'] . ' - ' : '';
$name .= $album['album'];
// $name = encodeEscapeChar($name);
$transcode = false;
$exact = true;
$extensions = array();
$miliseconds = 0;
$query = mysqli_query($db,'SELECT track.filesize, cache.filesize AS cache_filesize,
miliseconds, audio_bitrate, track_id,
LOWER(SUBSTRING_INDEX(track.relative_file, ".", -1)) AS extension
FROM track LEFT JOIN cache
ON track.track_id = cache.id
AND cache.profile = ' . (int) $cfg['stream_id'] . '
WHERE album_id = "' . mysqli_real_escape_string($db,$album_id) . '"');
while($track = mysqli_fetch_assoc($query)) {
if (in_array($track['extension'], $extensions) == false) {
$extensions[] = $track['extension'];
}
if (sourceFile($track['extension'], $track['audio_bitrate'], $cfg['stream_id']) == false) {
$transcode = true;
if ($track['cache_filesize'] == false)
$exact = false;
}
$miliseconds += $track['miliseconds'];
}
sort($extensions);
$source = implode($extensions, ', ');
$profile_name = ($transcode) ? $cfg['encode_name'][$cfg['stream_id']] . ' (' . $source . ' source)' : 'Source (' . $source . ')';
if ($transcode && $exact) {$cache_txt = 'Transcoded:'; $cache_png = $cfg['img'] . 'small_check.png';}
elseif ($transcode && !$exact) {$cache_txt = 'Transcoded:'; $cache_png = $cfg['img'] . 'small_uncheck.png';}
else {$cache_txt = 'Source:'; $cache_png = $cfg['img'] . 'small_check.png';}
?>
<form action="" name="form" id="form">
<table cellspacing="0" cellpadding="0" class="border">
<tr class="header">
<td class="space"></td>
<td colspan="3"><?php echo html($name); ?></td>
<td class="space"></td>
</tr>
<tr class="line"><td colspan="5"></td></tr>
<tr class="odd">
<td></td>
<td>Play time:</td>
<td></td>
<td><?php echo formattedTime($miliseconds); ?></td>
<td class="space"></td>
</tr>
<tr class="even">
<td class="space"></td>
<td>Stream profile:</td>
<td class="textspace"></td>
<td><?php echo html($profile_name); ?></td>
<td class="space"></td>
</tr>
<tr class="odd">
<td></td>
<td><?php echo $cache_txt; ?></td>
<td></td>
<td><img src="<?php echo $cache_png; ?>" alt="" class="small"></td>
<td class="space"></td>
</tr>
<tr class="even">
<td></td>
<td>Mail:</td>
<td></td>
<td><a href="mailto:?SUBJECT=<?php echo rawurlencode($name); ?>&BODY=---%0APlay%20time%3A%20<?php echo rawurlencode(formattedTime($miliseconds));?>%0AStream%3A%20<?php echo rawurlencode($name); ?>%0A<?php echo rawurlencode(str_replace('&', '&', $url)); ?>%0A%0AThis%20stream%20will%20expire%20<?php echo rawurlencode(date($cfg['date_format'], $expire_time)); ?>%20and%20locked%20to%20the%20first%20used%20IP%20address."><img src="<?php echo $cfg['img']; ?>small_mail.png" alt="" class="small"></a></td>
<td></td>
</tr>
<tr class="odd">
<td></td>
<td>URL:</td>
<td></td>
<td><input type="text" value="<?php echo $url; ?>" readonly class="url" onClick="focus(this); select(this);"></td>
<td></td>
</tr>
<tr class="even">
<td></td>
<td>QR Code:</td>
<td></td>
<td><img src="qrcode.php?d=<?php echo rawurlencode(str_replace('&', '&', $url)); ?>&e=l&s=3" alt=""></td>
<td></td>
</tr>
</table>
</form>
<?php
require_once('include/footer.inc.php');
}
?>