forked from reportico-web/reportico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imageget.php
executable file
·152 lines (127 loc) · 4.28 KB
/
imageget.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
<?php
/*
Reportico - PHP Reporting Tool
Copyright (C) 2010-2014 Peter Deed
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 2
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* File: imageget.php
*
* Script to take location of an image within the database
* and output it to the browser. Used by the Reportico engine
* as a URL that can be embeeded in report browser output.
*
* @link http://www.reportico.org/
* @copyright 2010-2014 Peter Deed
* @author Peter Deed <[email protected]>
* @package Reportico
* @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @version $Id: imageget.php,v 1.13 2014/05/17 15:12:31 peter Exp $
*/
include_once('reportico_adodb/adodb.inc.php');
include_once ("reportico.php");
include_once ("swutil.php");
include_once ("swdb.php");
error_reporting(E_ALL);
// Session namespace for allowing multiple reporticos on a single
// page when called from a framework. In name space in operation the
// session array index to find reportico variables can be found in "reportico"
// otherwise it's reportic_<namespace>
global $g_session_namespace;
global $g_session_namespace_key;
$g_session_namespace = false;
$g_session_namespace_key = "reportico";
set_up_reportico_session();
if ( $g_session_namespace )
$g_session_namespace_key = "reportico_".$g_session_namespace;
if ( !function_exists("set_project_environment" ) )
{
/**
* Function set_project_environment
*
* Analyses configuration and current session to identify which project area
* is to be used.
* If a project is specified in the HTTP parameters then that is used, otherwise
* the current SESSION project is used. If none of these are specified then the default
* "reports" project is used
*/
function set_project_environment()
{
global $g_project;
global $g_menu;
global $g_menu_title;
$project = session_request_item("project", "reports");
$menu = false;
$menu_title = "Set Menu Title";
// Now we now the project include the relevant config.php
$projpath = "projects/".$project;
$configfile = $projpath."/config.php";
$menufile = $projpath."/menu.php";
if ( !is_file($projpath) )
find_file_to_include($projpath, $projpath);
if ( !$projpath )
{
find_file_to_include("config.php", $configfile);
if ( $configfile )
include_once($configfile);
$g_project = false;
$g_menu = false;
$g_menu_title = "";
$old_error_handler = set_error_handler("ErrorHandler");
handle_error("Project Directory $project not found. Check INCLUDE_PATH or project name");
return;
}
if ( !is_file($configfile) )
find_file_to_include($configfile, $configfile);
if ( !is_file($menufile) )
find_file_to_include($menufile, $menufile);
if ( $configfile )
{
include_once($configfile);
if ( is_file($menufile) )
include_once($menufile);
else
handle_error("Menu Definition file menu.php not found in project $project", E_USER_WARNING);
}
else
{
find_file_to_include("config.php", $configfile);
if ( $configfile )
include_once($configfile);
$g_project = false;
$g_menu = false;
$g_menu_title = "";
$old_error_handler = set_error_handler("ErrorHandler");
handle_error("Configuration Definition file config.php not found in project $project", E_USER_ERROR);
}
$g_project = $project;
$g_menu = $menu;
$g_menu_title = $menu_title;
return $project;
}
}
set_project_environment();
$datasource = new reportico_datasource();
$datasource->connect();
$imagesql = $_REQUEST["imagesql"];
if ( !preg_match("/^select/i", $imagesql ) )
return false;
$rs = $datasource->ado_connection->Execute($imagesql)
or die("Query failed : " . $ado_connection->ErrorMsg());
$line = $rs->FetchRow();
//header('Content-Type: image/gif');
foreach ( $line as $col )
{
$data = $col;
break;
}
echo $data;
?>