| 41 |
'ql' => 70, |
'ql' => 70, |
| 42 |
'wm' => '' |
'wm' => '' |
| 43 |
); |
); |
|
|
|
| 44 |
$global_var['image_sz']['640'] = array ( |
$global_var['image_sz']['640'] = array ( |
| 45 |
'x' => 640, |
'x' => 640, |
| 46 |
'y' => 480, |
'y' => 480, |
| 60 |
'wm' => '' |
'wm' => '' |
| 61 |
); |
); |
| 62 |
|
|
| 63 |
|
$global_var['image_sz']['default'] =& $global_var['image_sz']['640']; |
| 64 |
|
|
| 65 |
|
$global_var['exif'] = array ( |
| 66 |
|
'Make', |
| 67 |
|
'ApertureFNumber', |
| 68 |
|
'FocalLength', |
| 69 |
|
'DateTime', |
| 70 |
|
'FlashMode' |
| 71 |
|
); |
| 72 |
|
$exif_headers = array (); |
| 73 |
|
|
| 74 |
|
|
| 75 |
if(isset($_SERVER['PHP_SELF'])) { |
if(isset($_SERVER['PHP_SELF'])) { |
| 76 |
$php_self = $_SERVER['PHP_SELF']; |
$php_self = $_SERVER['PHP_SELF']; |
| 77 |
} else { |
} else { |
| 95 |
*/ |
*/ |
| 96 |
function extract_exif_data() |
function extract_exif_data() |
| 97 |
{ |
{ |
| 98 |
|
global $global_var, $pwd, $get_vars, $exif_headers; |
| 99 |
|
|
| 100 |
|
$src_image = $get_vars['img']; |
| 101 |
|
$exif_data = @exif_read_data($pwd.'/'.$src_image,0,true); |
| 102 |
|
|
| 103 |
|
if($exif_data) { |
| 104 |
|
|
| 105 |
|
foreach($exif_data as $exif_section_key => $exif_section) { |
| 106 |
|
foreach($exif_section as $exif_key => $exif_value) { |
| 107 |
|
|
| 108 |
|
if(array_search($exif_key, $global_var['exif'])) { |
| 109 |
|
|
| 110 |
|
switch($exif_key) { |
| 111 |
|
case 'Make': |
| 112 |
|
array_push($exif_headers, 'Model: '.$exif_value); |
| 113 |
|
break; |
| 114 |
|
|
| 115 |
|
case 'ApertureFNumber': |
| 116 |
|
array_push($exif_headers, 'Aperture: '. $exif_value); |
| 117 |
|
break; |
| 118 |
|
|
| 119 |
|
case 'FocalLength': |
| 120 |
|
array_push($exif_headers, 'Focal Length: '. $exif_value .'mm'); |
| 121 |
|
break; |
| 122 |
|
|
| 123 |
|
case 'DateTime': |
| 124 |
|
array_push($exif_headers, 'Date: '.$exif_value); |
| 125 |
|
break; |
| 126 |
|
|
| 127 |
|
case 'FlashMode': |
| 128 |
|
switch($exif_value) { |
| 129 |
|
case '0': |
| 130 |
|
array_push($exif_headers, 'Flash: Off'); |
| 131 |
|
break; |
| 132 |
|
case '1': |
| 133 |
|
array_push($exif_headers, 'Flash: On'); |
| 134 |
|
break; |
| 135 |
|
} |
| 136 |
|
break; |
| 137 |
|
|
| 138 |
|
default: |
| 139 |
|
break; |
| 140 |
|
} |
| 141 |
|
} |
| 142 |
|
} |
| 143 |
|
} |
| 144 |
|
if(sizeof($exif_headers)>0) { |
| 145 |
|
ksort($exif_headers); |
| 146 |
|
reset($exif_headers); |
| 147 |
|
} |
| 148 |
|
} |
| 149 |
} |
} |
| 150 |
|
|
| 151 |
|
|
| 177 |
if(!file_exists($pwd.'/'.$global_var['path']['thumb_dir'])) |
if(!file_exists($pwd.'/'.$global_var['path']['thumb_dir'])) |
| 178 |
mkdir($pwd.'/'.$global_var['path']['thumb_dir'],0777); |
mkdir($pwd.'/'.$global_var['path']['thumb_dir'],0777); |
| 179 |
|
|
| 180 |
|
echo <<<EOT |
| 181 |
|
<div id="thumbnails_container">\n |
| 182 |
|
|
| 183 |
|
EOT; |
| 184 |
|
|
| 185 |
foreach($image_files as $image) { |
foreach($image_files as $image) { |
| 186 |
|
|
| 187 |
|
$thumb_image = $pwd.'/'.$global_var['path']['thumb_dir'].'/'.$image; |
| 188 |
|
|
| 189 |
// check if a thumbnail for current image exists, if not create one. |
// check if a thumbnail for current image exists, if not create one. |
| 190 |
if(!file_exists($pwd.'/'.$global_var['path']['thumb_dir'].'/'.$image)) |
if(!file_exists($thumb_image)) |
| 191 |
create_thumbnail($image); |
create_thumbnail($image); |
| 192 |
|
|
| 193 |
|
$thumb_sz = GetImageSize($thumb_image); |
| 194 |
|
|
| 195 |
echo <<<EOT |
echo <<<EOT |
| 196 |
<div class="thumbnail">\n |
<div class="thumbnail" style="width: {$thumb_sz[0]}px; height: {$thumb_sz[1]}px;">\n |
| 197 |
<a href="$php_self?dir=$pwd&img=$image"> |
<a href="$php_self?dir=$pwd&img=$image"> |
| 198 |
<img src="$pwd/{$global_var[path][thumb_dir]}/$image" alt=""/> |
<img src="$thumb_image" alt=""/> |
| 199 |
</a> |
</a> |
| 200 |
</div>\n |
</div>\n |
| 201 |
EOT; |
EOT; |
| 202 |
} |
} |
| 203 |
|
|
| 204 |
|
echo <<<EOT |
| 205 |
|
</div>\n |
| 206 |
|
<div style="clear: both;"><br/></div>\n |
| 207 |
|
EOT; |
| 208 |
} |
} |
| 209 |
|
|
| 210 |
|
|
| 212 |
|
|
| 213 |
function show_image() |
function show_image() |
| 214 |
{ |
{ |
| 215 |
global $global_var, $get_vars, $pwd; |
global $global_var, $get_vars, $pwd, $exif_headers; |
| 216 |
|
|
| 217 |
|
$image = $pwd.'/'.$get_vars['img']; |
| 218 |
|
|
| 219 |
|
$cached_image = $pwd.'/'.$global_var['path']['cache_dir']; |
| 220 |
|
|
| 221 |
if(file_exists($pwd.'/'.$get_vars['img'])) { |
if(file_exists($image)) { |
| 222 |
|
|
| 223 |
|
$image_size = GetImageSize($image); |
| 224 |
|
|
| 225 |
|
if(isset($get_var['width'])) { |
| 226 |
|
if($get_var['width'] >= $image_size[0]) |
| 227 |
|
$cache_image = $image; |
| 228 |
|
} else { |
| 229 |
|
if(!file_exists($cached_image.'/default_'.$get_vars['img'])) { |
| 230 |
|
resize_image('default_'); |
| 231 |
|
} |
| 232 |
|
$cached_image = $cached_image.'/default_'.$get_vars['img']; |
| 233 |
|
} |
| 234 |
|
|
| 235 |
|
$image_size = GetImageSize($cached_image); |
| 236 |
|
|
| 237 |
|
extract_exif_data(); |
| 238 |
|
|
| 239 |
|
if(sizeof($exif_headers) > 0) { |
| 240 |
|
|
| 241 |
|
$exif_str .= sprintf("<span style=\"font-weight: bold;\">EXIF</span> "); |
| 242 |
|
|
| 243 |
|
foreach($exif_headers as $exif_tag) { |
| 244 |
|
$exif_str .= sprintf("| %s ", $exif_tag); |
| 245 |
|
} |
| 246 |
|
|
| 247 |
|
echo <<<EOT |
| 248 |
|
<div id="exif_headers">\n |
| 249 |
|
<span>$exif_str</span>\n |
| 250 |
|
</div>\n |
| 251 |
|
EOT; |
| 252 |
|
|
| 253 |
|
} |
| 254 |
|
|
| 255 |
|
|
| 256 |
echo <<<EOT |
echo <<<EOT |
| 257 |
<div id="image">\n |
<div id="image" style="width: {$image_size[0]}px; height: {$image_size[1]}px;">\n |
| 258 |
<img src="$pwd/{$get_vars[img]}" alt=""> |
<a href="$image" target="_blank"><img src="$cached_image" alt=""></a> |
| 259 |
</div>\n |
</div>\n |
| 260 |
EOT; |
EOT; |
| 261 |
|
|
| 262 |
|
$image_index = get_image_index(); |
| 263 |
|
$next = get_next_image($image_index); |
| 264 |
|
$prev = get_prev_image($image_index); |
| 265 |
|
|
| 266 |
|
echo <<<EOT |
| 267 |
|
<a href="$php_self?dir=$pwd&img=$prev">prev</a> |
| 268 |
|
<a href="$php_self?dir=$pwd&img=$next">next</a> |
| 269 |
|
EOT; |
| 270 |
|
|
| 271 |
} |
} |
| 272 |
} |
} |
| 273 |
|
|
| 274 |
|
|
| 275 |
|
|
| 276 |
|
|
| 277 |
function resize_image() |
function resize_image($prefix) |
| 278 |
|
{ |
| 279 |
|
global $global_var, $get_vars, $pwd; |
| 280 |
|
$src_image = $get_vars['img']; |
| 281 |
|
if(isset($global_var['external']['magick'])) { |
| 282 |
|
if(file_exists($pwd.'/'.$src_image)) { |
| 283 |
|
$src_image_sz = GetImageSize($pwd.'/'.$src_image); |
| 284 |
|
$resize_aspect = round(($global_var['image_sz']['default']['y'] / $src_image_sz[1])*100, 2); |
| 285 |
|
|
| 286 |
|
// DEBUG: print "Quality: ".$global_var['image_sz']['default']['ql'] ." Resize Aspect: ". $resize_aspect ."%"; |
| 287 |
|
|
| 288 |
|
exec($global_var['external']['magick'] |
| 289 |
|
.' -geometry '.$resize_aspect.'%' |
| 290 |
|
.' -quality '.$global_var['image_sz']['default']['ql'] |
| 291 |
|
.' '.$pwd.'/'.$src_image |
| 292 |
|
.' '.$pwd.'/'.$global_var['path']['cache_dir'].'/'.$prefix.$src_image |
| 293 |
|
); |
| 294 |
|
} |
| 295 |
|
} |
| 296 |
|
} |
| 297 |
|
|
| 298 |
|
|
| 299 |
|
|
| 300 |
|
|
| 301 |
|
function get_image_index() |
| 302 |
|
{ |
| 303 |
|
global $get_vars, $image_files; |
| 304 |
|
|
| 305 |
|
return array_search($get_vars['img'], $image_files); |
| 306 |
|
} |
| 307 |
|
|
| 308 |
|
function get_next_image($pos) |
| 309 |
{ |
{ |
| 310 |
|
global $get_vars, $image_files; |
| 311 |
|
|
| 312 |
|
$next = $pos + 1; |
| 313 |
|
|
| 314 |
|
if($next >= sizeof($image_files)) |
| 315 |
|
$next = 0; |
| 316 |
|
|
| 317 |
|
return $image_files[$next]; |
| 318 |
} |
} |
| 319 |
|
|
| 320 |
|
function get_prev_image($pos) |
| 321 |
|
{ |
| 322 |
|
global $get_vars, $image_files; |
| 323 |
|
|
| 324 |
|
$prev = $pos - 1; |
| 325 |
|
|
| 326 |
|
if($prev < 0) |
| 327 |
|
$prev = sizeof($image_files) - 1; |
| 328 |
|
|
| 329 |
|
return $image_files[$prev]; |
| 330 |
|
} |
| 331 |
|
|
| 332 |
/** |
/** |
| 333 |
* Retirieves all filenames that are images exclude all |
* Retirieves all filenames that are images exclude all |
| 355 |
|
|
| 356 |
|
|
| 357 |
|
|
| 358 |
|
|
| 359 |
/** |
/** |
| 360 |
* Retrieves all directory names present in $path. Using |
* Retrieves all directory names present in $path. Using |
| 361 |
* eregi we exclude names we don't want in the list. |
* eregi we exclude names we don't want in the list. |
| 379 |
|
|
| 380 |
|
|
| 381 |
|
|
| 382 |
|
|
| 383 |
if (isset($get_vars['dir']) && is_dir(rawurldecode($get_vars['dir']))) |
if (isset($get_vars['dir']) && is_dir(rawurldecode($get_vars['dir']))) |
| 384 |
{ |
{ |
| 385 |
$pwd = rawurldecode($get_vars['dir']); |
$pwd = rawurldecode($get_vars['dir']); |
| 442 |
<meta name="description" content="{$global_var[metadata][description]}" /> |
<meta name="description" content="{$global_var[metadata][description]}" /> |
| 443 |
<meta name="robots" content="all" /> |
<meta name="robots" content="all" /> |
| 444 |
|
|
| 445 |
<title></title> |
<title>expose: </title> |
| 446 |
|
|
| 447 |
<style type="text/css"> |
<style type="text/css"> |
| 448 |
@import "/~ikea/style.css"; |
@import "/~ikea/style.css"; |
| 453 |
</head> |
</head> |
| 454 |
|
|
| 455 |
<body> |
<body> |
| 456 |
|
<div id="header">\n |
| 457 |
|
<h1>expose:</h1> |
| 458 |
|
<span style="font-style: italic;"></span> |
| 459 |
|
</div>\n |
| 460 |
<div id="container">\n |
<div id="container">\n |
| 461 |
EOF; |
EOF; |
| 462 |
} |
} |
| 473 |
global $global_var; |
global $global_var; |
| 474 |
echo <<<EOF |
echo <<<EOF |
| 475 |
<div id="copyright">\n |
<div id="copyright">\n |
| 476 |
{$global_var[str_msg][copyright]} |
{$global_var[str_msg][copyright]}<br /> |
| 477 |
|
<a href="">expose</a> <span style="font-style: italic;">Cvs version: \$Revision$</span> |
| 478 |
</div> |
</div> |
| 479 |
</div> |
</div> |
| 480 |
</body> |
</body> |