kenken999/php
0
1<?php 2@ini_set("display_errors","1");3@ini_set("display_startup_errors","1");4 5require_once("include/dbcommon.php");6 7 8$shortTableName = postvalue("table");9$table = GetTableByShort( $shortTableName );10if( !$table )11 exit(0);12 13$pageName = postvalue("pagename");14 15$strFilename = postvalue("filename");16$ext = substr( $strFilename, strlen($strFilename) - 4 );17$ctype = getContentTypeByExtension($ext);18$field = postvalue("field");19 20if( !Security::userHasFieldPermissions( $table, $field, PAGE_LIST, $pageName, false ) )21 return;22 23$pSet = new ProjectSettings( $table, PAGE_LIST, $pageName );24 25$_connection = $cman->byTable( $table );26 27$keys = array();28foreach( $pSet->getTableKeys() as $ind => $k ) {29 $keys[ $k ] = postvalue("key".($ind + 1));30}31 32$dc = new DsCommand();33$dc->filter = Security::SelectCondition( "S", $pSet );34$dc->keys = $keys;35 36$dataSource = getDataSource( $table, $pSet, $_connection );37$qResult = $dataSource->getSingle( $dc );38if( !$qResult || !( $data = $qResult->fetchAssoc() ) )39 return;40 41$value = $_connection->stripSlashesBinary( $data[$field ] );42 43header("Content-Type: ".$ctype);44header("Content-Disposition: attachment;Filename=\"".$strFilename."\"");45header("Cache-Control: private");46SendContentLength( strlen_bin($value) );47echoBinary( $value );48return;49 50?>51 