-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetblob.php
113 lines (101 loc) · 2.4 KB
/
getblob.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
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
basename($_SERVER['DOCUMENT_ROOT']);
$myreporter=basename(dirname(__FILE__));
if(basename($_SERVER['DOCUMENT_ROOT'])==$myreporter)
{
$myreporter="";
}
include($_SERVER['DOCUMENT_ROOT']."/$myreporter/initvar.php");
$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$query_str = parse_url($url, PHP_URL_QUERY);
$parts = parse_url($url);
$logid=null;
$blob=null;
$blobtype=null;
$preview="false";
if (isset($parts['query'])) {
parse_str($parts['query'], $query);
}
if (isset($query['logid'])) {
$logid=$query['logid'];
}
else
{
echo "required logid";
}
if (isset($query['preview'])) {
$preview=$query['preview'];
}
include($_SERVER['DOCUMENT_ROOT']."/$myreporter/mysqli_connection.php");
$mysqli = OpenCon();
if (!isset($mysqli)) {
echo "Connection failed";
}
if(isset($query['logid']))
{
if($preview=="true")
{
$getblobquery="SELECT l_screenshot_preview,l_screenshot_type FROM reporter.log where id=".$logid.";";
}
else
{
$getblobquery="SELECT l_screenshot_file_name,l_screenshot_type FROM reporter.log where id=".$logid.";";
}
//echo($getblobquery);
if($result = $mysqli->query($getblobquery))
{
//var_dump($result);
while($rows=mysqli_fetch_array($result)){
//var_dump($rows);
if($rows[0])
{
$blob=$rows[0];
}
$blobtype=$rows[1];
}
$result->close();
//$mysqli->next_result();
}
}
//var_dump($blobtype);
//var_dump($blob);
//header("Content-type: image/png");
if(is_null($blobtype))
{
header("Content-type: image/png");
echo $blob;
}
else
{
if($preview=="true")
{
if(is_null($blob))
{
if(strpos("$blobtype",'text/html') !== false)
{
header("Content-type: image/svg+xml");
echo(file_get_contents("img/icons/mime/Crystal-Clear-mime-text-html.svg"));
}
elseif(strpos("$blobtype",'text') !== false)
{
header("Content-type: image/png");
echo(file_get_contents("img/icons/mime/Gnome-mime-text.png"));
}
}
else
{
header("Content-type: $blobtype");
echo $blob;
}
}
else
{
header("Content-type: $blobtype");
echo $blob;
}
}
//echo '<img src="'.$blob.'" alt="HTML5 Icon" style="width:128px;height:128px">';;
CloseCon($mysqli);
?>