| 21 |
| http://www.gnu.org/ |
| http://www.gnu.org/ |
| 22 |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| 23 |
$Id$ |
$Id$ |
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
// CODE FOR EMBEDDING AVI/MPEG/MOV FILES IN HTML |
| 28 |
|
|
| 29 |
|
<embed src="filename" autostart="false" width="320" height="240" align="left" oncursor="play" hspace="20"> |
| 30 |
|
<noembed> |
| 31 |
|
<a href="filename">click to view</a> |
| 32 |
|
<img dynsrc="filename" start="mouseover" align="left" controls width="320" height="240" hspace="25"> |
| 33 |
|
</a> |
| 34 |
|
</noembed> |
| 35 |
*/ |
*/ |
| 36 |
|
|
| 37 |
$global_var['metadata']['author'] = "Carl Johan Schedvin <cjsc02@student.bth.se>"; |
$global_var['metadata']['author'] = "Carl Johan Schedvin <cjsc02@student.bth.se>"; |
| 52 |
'ql' => 70, |
'ql' => 70, |
| 53 |
'wm' => '' |
'wm' => '' |
| 54 |
); |
); |
|
|
|
| 55 |
$global_var['image_sz']['640'] = array ( |
$global_var['image_sz']['640'] = array ( |
| 56 |
'x' => 640, |
'x' => 640, |
| 57 |
'y' => 480, |
'y' => 480, |
| 71 |
'wm' => '' |
'wm' => '' |
| 72 |
); |
); |
| 73 |
|
|
| 74 |
|
$global_var['image_sz']['default'] =& $global_var['image_sz']['640']; |
| 75 |
|
|
| 76 |
|
$global_var['exif'] = array ( |
| 77 |
|
'Make', |
| 78 |
|
'ApertureFNumber', |
| 79 |
|
'FocalLength', |
| 80 |
|
'DateTime', |
| 81 |
|
'FlashMode' |
| 82 |
|
); |
| 83 |
|
$exif_headers = array (); |
| 84 |
|
|
| 85 |
|
|
| 86 |
if(isset($_SERVER['PHP_SELF'])) { |
if(isset($_SERVER['PHP_SELF'])) { |
| 87 |
$php_self = $_SERVER['PHP_SELF']; |
$php_self = $_SERVER['PHP_SELF']; |
| 88 |
} else { |
} else { |
| 106 |
*/ |
*/ |
| 107 |
function extract_exif_data() |
function extract_exif_data() |
| 108 |
{ |
{ |
| 109 |
|
global $global_var, $pwd, $get_vars, $exif_headers; |
| 110 |
|
|
| 111 |
|
$src_image = $get_vars['img']; |
| 112 |
|
$exif_data = @exif_read_data($pwd.'/'.$src_image,0,true); |
| 113 |
|
|
| 114 |
|
if($exif_data) { |
| 115 |
|
|
| 116 |
|
foreach($exif_data as $exif_section_key => $exif_section) { |
| 117 |
|
foreach($exif_section as $exif_key => $exif_value) { |
| 118 |
|
|
| 119 |
|
if(array_search($exif_key, $global_var['exif'])) { |
| 120 |
|
|
| 121 |
|
switch($exif_key) { |
| 122 |
|
case 'Make': |
| 123 |
|
array_push($exif_headers, 'Model: '.$exif_value); |
| 124 |
|
break; |
| 125 |
|
|
| 126 |
|
case 'ApertureFNumber': |
| 127 |
|
array_push($exif_headers, 'Aperture: '. $exif_value); |
| 128 |
|
break; |
| 129 |
|
|
| 130 |
|
case 'FocalLength': |
| 131 |
|
$factor = 6.49122807; |
| 132 |
|
$vars = split("/",$exif_value); |
| 133 |
|
$focal_length = round(($vars[0]/$vars[1])*$factor); |
| 134 |
|
array_push($exif_headers, 'Focal Length: '. $focal_length .'mm'); |
| 135 |
|
break; |
| 136 |
|
|
| 137 |
|
case 'DateTime': |
| 138 |
|
array_push($exif_headers, 'Date: '.$exif_value); |
| 139 |
|
break; |
| 140 |
|
|
| 141 |
|
case 'FlashMode': |
| 142 |
|
switch($exif_value) { |
| 143 |
|
case '0': |
| 144 |
|
array_push($exif_headers, 'Flash: Off'); |
| 145 |
|
break; |
| 146 |
|
case '1': |
| 147 |
|
array_push($exif_headers, 'Flash: On'); |
| 148 |
|
break; |
| 149 |
|
} |
| 150 |
|
break; |
| 151 |
|
|
| 152 |
|
default: |
| 153 |
|
break; |
| 154 |
|
} |
| 155 |
|
} |
| 156 |
|
} |
| 157 |
|
} |
| 158 |
|
if(sizeof($exif_headers)>0) { |
| 159 |
|
ksort($exif_headers); |
| 160 |
|
reset($exif_headers); |
| 161 |
|
} |
| 162 |
|
} |
| 163 |
} |
} |
| 164 |
|
|
| 165 |
|
|
| 191 |
if(!file_exists($pwd.'/'.$global_var['path']['thumb_dir'])) |
if(!file_exists($pwd.'/'.$global_var['path']['thumb_dir'])) |
| 192 |
mkdir($pwd.'/'.$global_var['path']['thumb_dir'],0777); |
mkdir($pwd.'/'.$global_var['path']['thumb_dir'],0777); |
| 193 |
|
|
| 194 |
|
echo <<<EOT |
| 195 |
|
<div id="thumbnails_container">\n |
| 196 |
|
|
| 197 |
|
EOT; |
| 198 |
|
|
| 199 |
foreach($image_files as $image) { |
foreach($image_files as $image) { |
| 200 |
|
|
| 201 |
|
$thumb_image = $pwd.'/'.$global_var['path']['thumb_dir'].'/'.$image; |
| 202 |
|
|
| 203 |
// check if a thumbnail for current image exists, if not create one. |
// check if a thumbnail for current image exists, if not create one. |
| 204 |
if(!file_exists($pwd.'/'.$global_var['path']['thumb_dir'].'/'.$image)) |
if(!file_exists($thumb_image)) |
| 205 |
create_thumbnail($image); |
create_thumbnail($image); |
| 206 |
|
|
| 207 |
|
$thumb_sz = GetImageSize($thumb_image); |
| 208 |
|
|
| 209 |
echo <<<EOT |
echo <<<EOT |
| 210 |
<div class="thumbnail">\n |
<div class="thumbnail" style="width: {$thumb_sz[0]}px; height: {$thumb_sz[1]}px;">\n |
| 211 |
<a href="$php_self?dir=$pwd&img=$image"> |
<a href="$php_self?dir=$pwd&img=$image"> |
| 212 |
<img src="$pwd/{$global_var[path][thumb_dir]}/$image" alt=""/> |
<img src="$thumb_image" alt=""/> |
| 213 |
</a> |
</a> |
| 214 |
</div>\n |
</div>\n |
| 215 |
EOT; |
EOT; |
| 216 |
} |
} |
| 217 |
|
|
| 218 |
|
echo <<<EOT |
| 219 |
|
</div>\n |
| 220 |
|
<div style="clear: both;"><br/></div>\n |
| 221 |
|
EOT; |
| 222 |
} |
} |
| 223 |
|
|
| 224 |
|
|
| 226 |
|
|
| 227 |
function show_image() |
function show_image() |
| 228 |
{ |
{ |
| 229 |
global $global_var, $get_vars, $pwd; |
global $global_var, $get_vars, $pwd, $exif_headers; |
| 230 |
|
|
| 231 |
|
$image = $pwd.'/'.$get_vars['img']; |
| 232 |
|
|
| 233 |
|
$cached_image = $pwd.'/'.$global_var['path']['cache_dir']; |
| 234 |
|
|
| 235 |
|
if(file_exists($image)) { |
| 236 |
|
|
| 237 |
|
$image_size = GetImageSize($image); |
| 238 |
|
|
| 239 |
|
if(isset($get_var['width'])) { |
| 240 |
|
if($get_var['width'] >= $image_size[0]) |
| 241 |
|
$cache_image = $image; |
| 242 |
|
} else { |
| 243 |
|
if(!file_exists($cached_image.'/default_'.$get_vars['img'])) { |
| 244 |
|
resize_image('default_'); |
| 245 |
|
} |
| 246 |
|
$cached_image = $cached_image.'/default_'.$get_vars['img']; |
| 247 |
|
} |
| 248 |
|
|
| 249 |
|
$image_size = GetImageSize($cached_image); |
| 250 |
|
|
| 251 |
|
extract_exif_data(); |
| 252 |
|
|
| 253 |
|
if(sizeof($exif_headers) > 0) { |
| 254 |
|
|
| 255 |
|
$exif_str .= sprintf("<span style=\"font-weight: bold; color:#333;\">EXIF</span> "); |
| 256 |
|
|
| 257 |
if(file_exists($pwd.'/'.$get_vars['img'])) { |
foreach($exif_headers as $exif_tag) { |
| 258 |
|
$exif_str .= sprintf("| %s ", $exif_tag); |
| 259 |
|
} |
| 260 |
|
|
| 261 |
|
echo <<<EOT |
| 262 |
|
<div id="exif_headers">\n |
| 263 |
|
<span>$exif_str</span>\n |
| 264 |
|
</div>\n |
| 265 |
|
EOT; |
| 266 |
|
|
| 267 |
|
} |
| 268 |
|
|
| 269 |
|
|
| 270 |
echo <<<EOT |
echo <<<EOT |
| 271 |
<div id="image">\n |
<div id="image" style="width: {$image_size[0]}px; height: {$image_size[1]}px;">\n |
| 272 |
<img src="$pwd/{$get_vars[img]}" alt=""> |
<a href="$image" target="_blank"><img src="$cached_image" alt=""></a> |
| 273 |
</div>\n |
</div>\n |
| 274 |
EOT; |
EOT; |
| 275 |
|
|
| 276 |
|
$image_index = get_image_index(); |
| 277 |
|
$next = get_next_image($image_index); |
| 278 |
|
$prev = get_prev_image($image_index); |
| 279 |
|
|
| 280 |
|
echo <<<EOT |
| 281 |
|
<a href="$php_self?dir=$pwd&img=$prev">prev</a> |
| 282 |
|
<a href="$php_self?dir=$pwd&img=$next">next</a> |
| 283 |
|
EOT; |
| 284 |
|
|
| 285 |
} |
} |
| 286 |
} |
} |
| 287 |
|
|
| 288 |
|
|
| 289 |
|
|
| 290 |
|
|
| 291 |
function resize_image() |
function resize_image($prefix) |
| 292 |
|
{ |
| 293 |
|
global $global_var, $get_vars, $pwd; |
| 294 |
|
$src_image = $get_vars['img']; |
| 295 |
|
$cache_dir = $pwd.'/'.$global_var['path']['cache_dir']; |
| 296 |
|
|
| 297 |
|
if(isset($global_var['external']['magick'])) { |
| 298 |
|
if(file_exists($pwd.'/'.$src_image)) { |
| 299 |
|
$src_image_sz = GetImageSize($pwd.'/'.$src_image); |
| 300 |
|
$resize_aspect = round(($global_var['image_sz']['default']['y'] / $src_image_sz[1])*100, 2); |
| 301 |
|
|
| 302 |
|
// DEBUG: print "Quality: ".$global_var['image_sz']['default']['ql'] ." Resize Aspect: ". $resize_aspect ."%"; |
| 303 |
|
if(!file_exists($cache_dir)) |
| 304 |
|
mkdir($cache_dir,0777); |
| 305 |
|
|
| 306 |
|
exec($global_var['external']['magick'] |
| 307 |
|
.' -geometry '.$resize_aspect.'%' |
| 308 |
|
.' -quality '.$global_var['image_sz']['default']['ql'] |
| 309 |
|
.' '.$pwd.'/'.$src_image |
| 310 |
|
.' '.$pwd.'/'.$global_var['path']['cache_dir'].'/'.$prefix.$src_image |
| 311 |
|
); |
| 312 |
|
} |
| 313 |
|
} |
| 314 |
|
} |
| 315 |
|
|
| 316 |
|
|
| 317 |
|
|
| 318 |
|
|
| 319 |
|
function get_image_index() |
| 320 |
|
{ |
| 321 |
|
global $get_vars, $image_files; |
| 322 |
|
|
| 323 |
|
return array_search($get_vars['img'], $image_files); |
| 324 |
|
} |
| 325 |
|
|
| 326 |
|
function get_next_image($pos) |
| 327 |
|
{ |
| 328 |
|
global $get_vars, $image_files; |
| 329 |
|
|
| 330 |
|
$next = $pos + 1; |
| 331 |
|
|
| 332 |
|
if($next >= sizeof($image_files)) |
| 333 |
|
$next = 0; |
| 334 |
|
|
| 335 |
|
return $image_files[$next]; |
| 336 |
|
} |
| 337 |
|
|
| 338 |
|
function get_prev_image($pos) |
| 339 |
{ |
{ |
| 340 |
|
global $get_vars, $image_files; |
| 341 |
|
|
| 342 |
|
$prev = $pos - 1; |
| 343 |
|
|
| 344 |
|
if($prev < 0) |
| 345 |
|
$prev = sizeof($image_files) - 1; |
| 346 |
|
|
| 347 |
|
return $image_files[$prev]; |
| 348 |
} |
} |
| 349 |
|
|
| 350 |
|
|
| 351 |
|
function get_split_path() |
| 352 |
|
{ |
| 353 |
|
global $pwd; |
| 354 |
|
|
| 355 |
|
$split_path = split('/', $pwd); |
| 356 |
|
|
| 357 |
|
return $split_path; |
| 358 |
|
} |
| 359 |
/** |
/** |
| 360 |
* Retirieves all filenames that are images exclude all |
* Retirieves all filenames that are images exclude all |
| 361 |
* other files. It's not recursive so it only examins the |
* other files. It's not recursive so it only examins the |
| 373 |
$pwd_dd = opendir($path); |
$pwd_dd = opendir($path); |
| 374 |
while(($file = readdir($pwd_dd)) !== false) { |
while(($file = readdir($pwd_dd)) !== false) { |
| 375 |
if(is_file($path."/".$file) |
if(is_file($path."/".$file) |
| 376 |
&& !eregi("^\.|^.*.php|^.*.css|^.*~",$file)) |
&& !eregi("^\.|^.*.php|^.*.css|^.*~|^.txt",$file)) |
| 377 |
array_push($images, $file); |
array_push($images, $file); |
| 378 |
} |
} |
| 379 |
} |
} |
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
|
|
| 386 |
/** |
/** |
| 387 |
* Retrieves all directory names present in $path. Using |
* Retrieves all directory names present in $path. Using |
| 388 |
* eregi we exclude names we don't want in the list. |
* eregi we exclude names we don't want in the list. |
| 406 |
|
|
| 407 |
|
|
| 408 |
|
|
| 409 |
|
|
| 410 |
|
|
| 411 |
|
|
| 412 |
|
|
| 413 |
if (isset($get_vars['dir']) && is_dir(rawurldecode($get_vars['dir']))) |
if (isset($get_vars['dir']) && is_dir(rawurldecode($get_vars['dir']))) |
| 414 |
{ |
{ |
| 415 |
$pwd = rawurldecode($get_vars['dir']); |
$pwd = rawurldecode($get_vars['dir']); |
| 424 |
// print the html header before continuing processing. |
// print the html header before continuing processing. |
| 425 |
html_template_header(); |
html_template_header(); |
| 426 |
|
|
| 427 |
|
//if($global_var['navigation_bar']) |
| 428 |
|
html_template_navbar(); |
| 429 |
|
|
| 430 |
if(sizeof($image_files) <= 0) { |
if(sizeof($image_files) <= 0) { |
| 431 |
if(sizeof($dir_files) > 0) { |
if(sizeof($dir_files) > 0) { |
| 474 |
<meta name="description" content="{$global_var[metadata][description]}" /> |
<meta name="description" content="{$global_var[metadata][description]}" /> |
| 475 |
<meta name="robots" content="all" /> |
<meta name="robots" content="all" /> |
| 476 |
|
|
| 477 |
<title></title> |
<title>expose: </title> |
| 478 |
|
|
| 479 |
<style type="text/css"> |
<style type="text/css"> |
| 480 |
@import "/~ikea/style.css"; |
@import "./style.css"; |
| 481 |
</style> |
</style> |
| 482 |
|
|
| 483 |
<link rel="Shortcut Icon" type="image/x-icon" href="/img/favicon.ico" /> |
<link rel="Shortcut Icon" type="image/x-icon" href="/img/favicon.ico" /> |
| 485 |
</head> |
</head> |
| 486 |
|
|
| 487 |
<body> |
<body> |
| 488 |
|
<div id="header">\n |
| 489 |
|
<h1>expose:</h1> |
| 490 |
|
<span style="font-style: italic;"></span> |
| 491 |
|
</div>\n |
| 492 |
<div id="container">\n |
<div id="container">\n |
| 493 |
EOF; |
EOF; |
| 494 |
} |
} |
| 496 |
|
|
| 497 |
|
|
| 498 |
|
|
| 499 |
|
|
| 500 |
|
|
| 501 |
|
|
| 502 |
/** |
/** |
| 503 |
* Prints the html footer, this contains only closing |
* Prints the html footer, this contains only closing |
| 504 |
* tags for the html document and the copyright notice. |
* tags for the html document and the copyright notice. |
| 508 |
global $global_var; |
global $global_var; |
| 509 |
echo <<<EOF |
echo <<<EOF |
| 510 |
<div id="copyright">\n |
<div id="copyright">\n |
| 511 |
{$global_var[str_msg][copyright]}<br /> |
{$global_var[str_msg][copyright]}<br />\n |
| 512 |
<a href="">expose</a> <span style="font-style: italic;">cvs version: $Revision$</span> |
<a href="">expose</a>\n <span style="font-style: italic;">\$Revision$</span>\n |
| 513 |
</div> |
</div>\n\n |
| 514 |
</div> |
</div>\n |
| 515 |
</body> |
</body>\n |
| 516 |
</html> |
</html>\n |
| 517 |
EOF; |
EOF; |
| 518 |
} |
} |
| 519 |
|
|
| 520 |
|
|
| 521 |
|
|
| 522 |
|
|
| 523 |
|
|
| 524 |
|
|
| 525 |
|
function html_template_navbar() |
| 526 |
|
{ |
| 527 |
|
global $get_vars; |
| 528 |
|
$split_path = get_split_path(); |
| 529 |
|
|
| 530 |
|
if(sizeof($split_path) > 0) { |
| 531 |
|
|
| 532 |
|
foreach($split_path as $dir) { |
| 533 |
|
if($dir!='') { |
| 534 |
|
$path .= $dir.'/'; |
| 535 |
|
echo <<<EOT |
| 536 |
|
<a style="text-decoration: none;" href="$php_self?dir=$path"> |
| 537 |
|
EOT; |
| 538 |
|
if($dir == '.') |
| 539 |
|
$dir = 'expose'; |
| 540 |
|
|
| 541 |
|
echo <<<EOT |
| 542 |
|
$dir</a> > \n |
| 543 |
|
EOT; |
| 544 |
|
} |
| 545 |
|
} |
| 546 |
|
if(isset($get_vars['img'])) { |
| 547 |
|
echo <<<EOT |
| 548 |
|
{$get_vars[img]} |
| 549 |
|
EOT; |
| 550 |
|
} |
| 551 |
|
} |
| 552 |
|
} |
| 553 |
|
|
| 554 |
|
|
| 555 |
|
|
| 556 |
|
|
| 557 |
|
|
| 558 |
|
|
| 559 |
|
|
| 560 |
|
function html_template_alt_resolutions() |
| 561 |
|
{ |
| 562 |
|
} |
| 563 |
?> |
?> |