forked from Kitware/CDash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
displayImage.php
70 lines (61 loc) · 1.67 KB
/
displayImage.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
<?php
/*=========================================================================
Program: CDash - Cross-Platform Dashboard System
Module: $Id$
Language: PHP
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
include("cdash/config.php");
require_once("cdash/pdo.php");
$imgid = pdo_real_escape_numeric($_GET["imgid"]);
// Checks
if(empty($imgid) || !is_numeric($imgid))
{
echo "Not a valid imgid!";
return;
}
$db = pdo_connect("$CDASH_DB_HOST", "$CDASH_DB_LOGIN","$CDASH_DB_PASS");
pdo_select_db("$CDASH_DB_NAME",$db);
$result = pdo_query("SELECT * FROM image WHERE id=$imgid");
$img_array = pdo_fetch_array($result);
switch($img_array["extension"])
{
case "image/jpg":
header("Content-type: image/jpeg");
break;
case "image/jpeg":
header("Content-type: image/jpeg");
break;
case "image/gif":
header("Content-type: image/gif");
break;
case "image/png":
header("Content-type: image/png");
break;
default:
echo "Unknown image type: ";
echo $img_array["extension"];
return;
}
if($CDASH_DB_TYPE == "pgsql")
{
$buf = "";
while(!feof($img_array["img"]))
{
$buf .= fread($img_array["img"], 2048);
}
$buf = stripslashes($buf);
}
else
{
$buf = $img_array["img"];
}
echo $buf;
return;
?>