-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpullStream.php
72 lines (70 loc) · 2.44 KB
/
pullStream.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
<?php
include('includes/application_top.php');
$canView = false;
$name = substr($_GET['file'], 0, strpos($_GET['file'], '.'));
if($name == 'preview' && !isset($_GET['opID'])){
$canView = true;
}
/*
if($name != 'preview' && !stristr($name, 'loaded_stream_')){
$canView = false;
}
*/
$pID = (isset($_GET['pID']) ? $_GET['pID'] : (isset($_GET['pid']) ? $_GET['pid'] : false));
if($pID === false || !is_numeric($pID)){
$canView = false;
}
if($userAccount->isLoggedIn() === true && isset($_GET['opID']) && isset($_GET['oID'])){
$canView = true;
}
if($canView === true){
if(isset($_GET['oID']) && $userAccount->isLoggedIn() === true){
$QOrderPurchaseType = tep_db_query('select purchase_type from ' . TABLE_ORDERS_PRODUCTS . ' where orders_products_id = "' . (int) $_GET['opID'] . '"');
if(tep_db_num_rows($QOrderPurchaseType)){
$orderPurchaseType = tep_db_fetch_array($QOrderPurchaseType);
switch($orderPurchaseType['purchase_type']){
case 'stream':
$Stream = false;
EventManager::notify('PullStreamAfterUpdate', &$Stream, (int) $_GET['oID'], (int) $_GET['opID']);
$file = array('file_name' => $Stream['file_name'],
'type' => 'stream');
break;
case 'download':
$Download = false;
$fileName = $Stream['file_name'];
EventManager::notify('PullDownloadAfterUpdate', &$Download, (int) $_GET['oID'], (int) $_GET['opID']);
$file =
array
('file_name' => $Stream['file_name'],
'type' => 'download');
break;
}
}
} elseif($name == 'preview'){
$Qfile = tep_db_query('select movie_preview as file_name, "stream" as type from ' . TABLE_PRODUCTS . ' where products_id = "' . (int) $pID . '"');
if(tep_db_num_rows($Qfile)){
$file = tep_db_fetch_array($Qfile);
}
}
if($file['type'] == 'download'){
if(stristr($file['file_name'], '.gif')){
header('Content-type: image/gif');
} elseif(stristr($file['file_name'], '.png')){
header('Content-type: image/png');
} elseif(stristr($file['file_name'], '.jpg')){
header('Content-type: image/jpg');
} elseif(stristr($file['file_name'], '.mpg')){
header('Content-type: video/mpg');
} elseif(stristr($file['file_name'], '.flv')){
header("Content-Type: video/flv");
}
header('Content-Disposition: attachment; filename="' . $file['file_name'] . '"');
}
//readfile('streamer/movies/' . $file['file_name']);
readfile('streamer/' . $file['file_name']);
exit;
} else{
echo 'File Not Found';
}
include('includes/application_bottom.php');
?>