[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 3 define( 'TABLE_METADATA', 'ezdbfile' ); 4 5 // Connect to storage database. 6 $connStr = "host=" . STORAGE_HOST . " "; 7 $connStr .= "port=" . STORAGE_PORT . " "; 8 $connStr .= "dbname=" . STORAGE_DB . " "; 9 $connStr .= "user=" . STORAGE_USER . " "; 10 $connStr .= "password=" . STORAGE_PASS; 11 if ( !( $db = @pg_connect( $connStr ) ) ) 12 die( "Unable to connect to storage server." ); 13 14 $filename = ltrim( $_SERVER['SCRIPT_URL'], "/"); 15 16 // Fetch file metadata. 17 18 //------ 19 $filePathHash = md5( $filename ); 20 if( !( $res = pg_query( $db, "SELECT * FROM " . TABLE_METADATA . " WHERE name_hash='$filePathHash'" ) ) ) 21 die( "Unable to fetch image metadata.\n" ); 22 if ( !( $metaData = pg_fetch_array( $res, null, PGSQL_ASSOC ) ) ) 23 { 24 header( "HTTP/1.1 404 Not Found" ); 25 ?> 26 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> 27 <HTML><HEAD> 28 <TITLE>404 Not Found</TITLE> 29 </HEAD><BODY> 30 <H1>Not Found</H1> 31 The requested URL <?=htmlspecialchars( $filename )?> was not found on this server.<P> 32 </BODY></HTML> 33 <?php 34 pg_free_result( $res ); 35 pg_close( $db ); 36 exit( 1 ); 37 } 38 pg_free_result( $res ); 39 40 // Fetch file data. 41 pg_query( $db, "BEGIN" ); 42 $lobHandle = pg_lo_open( $db, $metaData['lob_id'], 'r' ); 43 if ( $lobHandle ) 44 { 45 // Output HTTP headers. 46 $path = $metaData['name']; 47 $size = $metaData['size']; 48 $mimeType = $metaData['datatype']; 49 $mtime = $metaData['mtime']; 50 $mdate = gmdate( 'D, d M Y H:i:s T', $mtime ); 51 52 header( "Content-Length: $size" ); 53 header( "Content-Type: $mimeType" ); 54 header( "Last-Modified: $mdate" ); 55 header( "Expires: ". gmdate('D, d M Y H:i:s', time() + 6000) . 'GMT' ); 56 header( "Connection: close" ); 57 header( "X-Powered-By: eZ publish" ); 58 header( "Accept-Ranges: bytes" ); 59 header( 'Served-by: ' . $_SERVER["SERVER_NAME"] ); 60 61 while ( $chunk = pg_lo_read( $lobHandle, STORAGE_CHUNK_SIZE ) ) 62 echo $chunk; 63 pg_lo_close( $lobHandle ); 64 65 } 66 67 pg_query( $db, "COMMIT" ); 68 pg_close( $db ); 69 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |