blob: 9beae22a74c935ae65f6c4435600fd3d89452b8e (
plain)
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
|
<?php
//
// Community file download
//
// $Id: communityfiles.php,v 1.4 2007-04-11 20:55:08 mha Exp $
//
require_once './global/settings.php';
if (empty($_GET['page']))
die('Invalid usage');
$page = explode('.',$_GET['page']);
$db = @pg_pconnect($_SETTINGS['db_portal']);
if (!$db)
die('No database connection');
$fid = $page[0];
if (!is_numeric($fid))
die('Invalid URL format');
$res = pg_query_params($db, "SELECT mimetype,image FROM communitypages_files WHERE fileid=$1", array($fid));
if (pg_num_rows($res) == 0) {
// Second try
$res = pg_query_params($db, "SELECT mimetype,image FROM communitypages_work_files WHERE fileid=$1", array($fid));
if (pg_num_rows($res) != 1) {
header('HTTP/1.0 404 Not found');
die('File does not exist');
}
}
header('Content-type: ' . pg_fetch_result($res, 0, 0));
print pg_unescape_bytea(pg_fetch_result($res, 0, 1));
?>
|