-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreview-slide.php
58 lines (57 loc) · 1.86 KB
/
preview-slide.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
<?php
define("PATH_SLIDERS", "preview/ppt/");
$slide_name=$token=$org_id=$app_id="";
if (isset($_GET['slide_name'])) {
$slide_name=$_GET['slide_name'];
}
if (isset($_GET['token'])) {
$token=$_GET['token'];
}
if (isset($_GET['org_id'])) {
$org_id=$_GET['org_id'];
}
if (isset($_GET['app_id'])) {
$app_id=$_GET['app_id'];
}
require_once "sftk.php";
$az_store= new AzureStore();
$file=getcwd()."/[email protected]";
if (($org_id !="") && ($app_id !="")) {
if ($az_store->findSlideByOrgApp($org_id,$app_id) ) { //---by org app
outputImg('OrgApp');
}
}elseif ($az_store->findSlideByToken($token) ) { //---by token
outputImg('token');
} elseif ($az_store->findSlideByOrgApp($org_id,$app_id)) {//---by org_id,app_id
outputImg('token-not-OrgApp-try');
exit;
}
header("Content-Type: image/png");
header("Content-Length: " . filesize($file));
readfile($file);
//-----------------------------------------------output----------------------
function outputImg($by_what) {
global $az_store,$slide_name,$token;
$file=getcwd()."/".PATH_SLIDERS.$az_store->org_id."/".$az_store->app_id."/sliders/".$slide_name;
if (file_exists($file)) {
$filename = basename($file);
$file_extension = strtolower(substr(strrchr($filename,"."),1));
error_log(__FUNCTION__.' By '.$by_what.' '.$token.' show file: '.$file);
$ctype="image/jpg";
switch( $file_extension ) {
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg":
case "jpg": $ctype="image/jpg"; break;
default:
}
header("Content-Type: " . $ctype);
header("Content-Length: " . filesize($file));
readfile($file);
exit;
} else {
error_log(__FUNCTION__.' no file: '.$file);
$file=getcwd()."/[email protected]";
}
}
?>