00001 <?php
00002
00003
00004
00005 $is_transformation_wrapper = true;
00006
00010 require_once('./libraries/grab_globals.lib.php');
00011
00015 require_once('./libraries/common.lib.php');
00016 require_once('./libraries/relation.lib.php');
00017 require_once('./libraries/transformations.lib.php');
00018 $cfgRelation = PMA_getRelationsParam();
00019
00023 require_once('./libraries/db_table_exists.lib.php');
00024
00025
00029 PMA_DBI_select_db($db);
00030 $table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table), NULL, PMA_DBI_QUERY_STORE);
00031 if (isset($primary_key)) {
00032 $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';', NULL, PMA_DBI_QUERY_STORE);
00033 $row = PMA_DBI_fetch_assoc($result);
00034 } else {
00035 $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1;', NULL, PMA_DBI_QUERY_STORE);
00036 $row = PMA_DBI_fetch_assoc($result);
00037 }
00038
00039
00040 if (!$row) {
00041 exit;
00042 }
00043
00044 $default_ct = 'application/octet-stream';
00045
00046 if ($cfgRelation['commwork'] && $cfgRelation['mimework']) {
00047 $mime_map = PMA_getMime($db, $table);
00048 $mime_options = PMA_transformation_getOptions((isset($mime_map[urldecode($transform_key)]['transformation_options']) ? $mime_map[urldecode($transform_key)]['transformation_options'] : ''));
00049
00050 foreach ($mime_options AS $key => $option) {
00051 if (substr($option, 0, 10) == '; charset=') {
00052 $mime_options['charset'] = $option;
00053 }
00054 }
00055 }
00056
00057
00058
00059
00060
00061 require_once('./libraries/header_http.inc.php');
00062
00063 if (isset($ct) && !empty($ct)) {
00064 $content_type = 'Content-Type: ' . urldecode($ct);
00065 } else {
00066 $content_type = 'Content-Type: ' . (isset($mime_map[urldecode($transform_key)]['mimetype']) ? str_replace('_', '/', $mime_map[urldecode($transform_key)]['mimetype']) : $default_ct) . (isset($mime_options['charset']) ? $mime_options['charset'] : '');
00067 }
00068
00069 if (isset($cn) && !empty($cn)) {
00070 $content_type .= "\n" . 'Content-Disposition: attachment; filename=' . urldecode($cn);
00071 }
00072
00073 header($content_type);
00074
00075 if (!isset($resize)) {
00076 echo $row[urldecode($transform_key)];
00077 } else {
00078
00079
00080
00081 $srcImage = imagecreatefromstring($row[urldecode($transform_key)]);
00082 $srcWidth = ImageSX( $srcImage );
00083 $srcHeight = ImageSY( $srcImage );
00084
00085
00086
00087
00088
00089 $ratioWidth = $srcWidth/$newWidth;
00090 $ratioHeight = $srcHeight/$newHeight;
00091
00092 if ($ratioWidth < $ratioHeight){
00093 $destWidth = $srcWidth/$ratioHeight;
00094 $destHeight = $newHeight;
00095 }else{
00096 $destWidth = $newWidth;
00097 $destHeight = $srcHeight/$ratioWidth;
00098 }
00099
00100 if ($resize) {
00101 $destImage = ImageCreateTrueColor( $destWidth, $destHeight);
00102 }
00103
00104
00105
00106 ImageCopyResampled( $destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight );
00107
00108 if ($resize == 'jpeg') {
00109 ImageJPEG( $destImage,'',75 );
00110 }
00111 if ($resize == 'png') {
00112 ImagePNG( $destImage);
00113 }
00114 ImageDestroy( $srcImage );
00115 ImageDestroy( $destImage );
00116 }
00117
00121 if (isset($GLOBALS['dbh']) && $GLOBALS['dbh']) {
00122 @PMA_DBI_close($GLOBALS['dbh']);
00123 }
00124 if (isset($GLOBALS['userlink']) && $GLOBALS['userlink']) {
00125 @PMA_DBI_close($GLOBALS['userlink']);
00126 }
00127 ?>