-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetfile.php
50 lines (36 loc) · 1.26 KB
/
getfile.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
<?php
@ini_set("display_errors","1");
@ini_set("display_startup_errors","1");
require_once("include/dbcommon.php");
$shortTableName = postvalue("table");
$table = GetTableByShort( $shortTableName );
if( !$table )
exit(0);
$pageName = postvalue("pagename");
$strFilename = postvalue("filename");
$ext = substr( $strFilename, strlen($strFilename) - 4 );
$ctype = getContentTypeByExtension($ext);
$field = postvalue("field");
if( !Security::userHasFieldPermissions( $table, $field, PAGE_LIST, $pageName, false ) )
return;
$pSet = new ProjectSettings( $table, PAGE_LIST, $pageName );
$_connection = $cman->byTable( $table );
$keys = array();
foreach( $pSet->getTableKeys() as $ind => $k ) {
$keys[ $k ] = postvalue("key".($ind + 1));
}
$dc = new DsCommand();
$dc->filter = Security::SelectCondition( "S", $pSet );
$dc->keys = $keys;
$dataSource = getDataSource( $table, $pSet, $_connection );
$qResult = $dataSource->getSingle( $dc );
if( !$qResult || !( $data = $qResult->fetchAssoc() ) )
return;
$value = $_connection->stripSlashesBinary( $data[$field ] );
header("Content-Type: ".$ctype);
header("Content-Disposition: attachment;Filename=\"".$strFilename."\"");
header("Cache-Control: private");
SendContentLength( strlen_bin($value) );
echoBinary( $value );
return;
?>