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>"; |
71 |
'wm' => '' |
'wm' => '' |
72 |
); |
); |
73 |
|
|
74 |
|
$global_var['image_sz']['valid_sizes'] = array ( |
75 |
|
'640x480', |
76 |
|
'800x600', |
77 |
|
'1024x768' |
78 |
|
); |
79 |
|
|
80 |
$global_var['image_sz']['default'] =& $global_var['image_sz']['640']; |
$global_var['image_sz']['default'] =& $global_var['image_sz']['640']; |
81 |
|
|
|
$global_var['exif'] = array ( |
|
|
'Make', |
|
|
'ApertureFNumber', |
|
|
'FocalLength', |
|
|
'DateTime', |
|
|
'FlashMode' |
|
|
); |
|
82 |
$exif_headers = array (); |
$exif_headers = array (); |
83 |
|
|
84 |
|
|
97 |
|
|
98 |
|
|
99 |
/** |
/** |
|
* ! NOT IMPLEMENTED ! |
|
|
* |
|
100 |
* Extracts the EXIF header of a JPG if available using |
* Extracts the EXIF header of a JPG if available using |
101 |
* built-in php function exif_read_data, this information |
* built-in php function exif_read_data, this information |
102 |
* is extracted upon request and not written to disk. |
* is extracted upon request and not written to disk. |
112 |
|
|
113 |
foreach($exif_data as $exif_section_key => $exif_section) { |
foreach($exif_data as $exif_section_key => $exif_section) { |
114 |
foreach($exif_section as $exif_key => $exif_value) { |
foreach($exif_section as $exif_key => $exif_value) { |
|
|
|
|
if(array_search($exif_key, $global_var['exif'])) { |
|
115 |
|
|
116 |
switch($exif_key) { |
switch($exif_key) { |
117 |
case 'Make': |
case 'Model': |
118 |
array_push($exif_headers, 'Model: '.$exif_value); |
array_push($exif_headers, 'Model: '.$exif_value); |
119 |
break; |
break; |
120 |
|
|
123 |
break; |
break; |
124 |
|
|
125 |
case 'FocalLength': |
case 'FocalLength': |
126 |
array_push($exif_headers, 'Focal Length: '. $exif_value .'mm'); |
$factor = 6.49122807; |
127 |
|
$vars = split("/",$exif_value); |
128 |
|
$focal_length = round(($vars[0]/$vars[1])*$factor); |
129 |
|
array_push($exif_headers, 'Focal Length: '. $focal_length .'mm'); |
130 |
break; |
break; |
131 |
|
|
132 |
case 'DateTime': |
case 'DateTime': |
143 |
break; |
break; |
144 |
} |
} |
145 |
break; |
break; |
146 |
|
case 'ISOSpeedRatings'; |
147 |
|
array_push($exif_headers, 'ISO: '.$exif_value); |
148 |
|
break; |
149 |
default: |
default: |
150 |
break; |
break; |
151 |
} |
} |
|
} |
|
152 |
} |
} |
153 |
} |
} |
154 |
if(sizeof($exif_headers)>0) { |
if(sizeof($exif_headers)>0) { |
231 |
if(file_exists($image)) { |
if(file_exists($image)) { |
232 |
|
|
233 |
$image_size = GetImageSize($image); |
$image_size = GetImageSize($image); |
234 |
|
$src_image_size = $image_size; |
235 |
|
|
236 |
if(isset($get_var['width'])) { |
if(isset($get_vars['width'])) { |
237 |
if($get_var['width'] >= $image_size[0]) |
|
238 |
|
$cache_size = split("x",$get_vars['width']); |
239 |
|
|
240 |
|
if($cache_size[0] >= $src_image_size[0]) { |
241 |
$cache_image = $image; |
$cache_image = $image; |
242 |
|
} else { |
243 |
|
if(array_search($get_vars['width'], $global_var['image_sz']['valid_sizes'])) { |
244 |
|
if(!file_exists($pwd.'/.cache/'.$get_vars['width'].'_'.$get_vars['img'])) { |
245 |
|
resize_image($get_vars['width'].'_'); |
246 |
|
} |
247 |
|
$cached_image = $pwd.'/.cache/'.$get_vars['width'].'_'.$get_vars['img']; |
248 |
|
} |
249 |
|
if($cache_size[0] == $global_var['image_sz']['default']['x']) |
250 |
|
$cached_image = $cached_image.'/default_'.$get_vars['img']; |
251 |
|
} |
252 |
|
|
253 |
} else { |
} else { |
254 |
if(!file_exists($cached_image.'/default_'.$get_vars['img'])) { |
if(!file_exists($cached_image.'/default_'.$get_vars['img'])) { |
255 |
resize_image('default_'); |
resize_image('default_'); |
256 |
|
|
257 |
} |
} |
258 |
$cached_image = $cached_image.'/default_'.$get_vars['img']; |
$cached_image = $cached_image.'/default_'.$get_vars['img']; |
259 |
|
|
260 |
} |
} |
261 |
|
|
262 |
$image_size = GetImageSize($cached_image); |
$image_size = GetImageSize($cached_image); |
265 |
|
|
266 |
if(sizeof($exif_headers) > 0) { |
if(sizeof($exif_headers) > 0) { |
267 |
|
|
268 |
$exif_str .= sprintf("<span style=\"font-weight: bold;\">EXIF</span> "); |
$exif_str .= sprintf("<span style=\"font-weight: bold; color:#333;\">EXIF</span> "); |
269 |
|
|
270 |
foreach($exif_headers as $exif_tag) { |
foreach($exif_headers as $exif_tag) { |
271 |
$exif_str .= sprintf("| %s ", $exif_tag); |
$exif_str .= sprintf("| %s ", $exif_tag); |
289 |
$image_index = get_image_index(); |
$image_index = get_image_index(); |
290 |
$next = get_next_image($image_index); |
$next = get_next_image($image_index); |
291 |
$prev = get_prev_image($image_index); |
$prev = get_prev_image($image_index); |
292 |
|
|
293 |
|
echo <<<EOT |
294 |
|
<span style="font-weight: bold;">Size:</span> |
295 |
|
EOT; |
296 |
|
|
297 |
|
foreach($global_var['image_sz']['valid_sizes'] as $new_size) { |
298 |
|
|
299 |
|
if($get_vars['width'] == $new_size) { |
300 |
|
echo $new_size; |
301 |
|
} elseif($cache_size[0] >= $src_image_size[0]) { |
302 |
|
} else { |
303 |
|
|
304 |
|
echo <<<EOT |
305 |
|
<a href="$php_self?dir=$pwd&img={$get_vars[img]}&width=$new_size">$new_size</a> |
306 |
|
EOT; |
307 |
|
} |
308 |
|
|
309 |
|
} |
310 |
|
|
311 |
echo <<<EOT |
echo <<<EOT |
312 |
<a href="$php_self?dir=$pwd&img=$prev">prev</a> |
<a href="$pwd/{$get_vars[img]}" target="_blank">{$src_image_size[0]}x{$src_image_size[1]}</a> |
313 |
<a href="$php_self?dir=$pwd&img=$next">next</a> |
EOT; |
314 |
|
|
315 |
|
echo <<<EOT |
316 |
|
<div>\n |
317 |
|
<a href="$php_self?dir=$pwd&img=$prev">prev</a> |
318 |
|
<a href="$php_self?dir=$pwd&img=$next">next</a>\n |
319 |
|
</div>\n |
320 |
EOT; |
EOT; |
321 |
|
|
322 |
} |
} |
329 |
{ |
{ |
330 |
global $global_var, $get_vars, $pwd; |
global $global_var, $get_vars, $pwd; |
331 |
$src_image = $get_vars['img']; |
$src_image = $get_vars['img']; |
332 |
|
$cache_dir = $pwd.'/'.$global_var['path']['cache_dir']; |
333 |
|
|
334 |
if(isset($global_var['external']['magick'])) { |
if(isset($global_var['external']['magick'])) { |
335 |
if(file_exists($pwd.'/'.$src_image)) { |
if(file_exists($pwd.'/'.$src_image)) { |
336 |
|
|
337 |
$src_image_sz = GetImageSize($pwd.'/'.$src_image); |
$src_image_sz = GetImageSize($pwd.'/'.$src_image); |
338 |
$resize_aspect = round(($global_var['image_sz']['default']['y'] / $src_image_sz[1])*100, 2); |
$resize_aspect = round(($global_var['image_sz']['default']['y'] / $src_image_sz[1])*100, 2); |
339 |
|
$resize_quality = $global_var['image_sz']['default']['ql']; |
340 |
|
|
341 |
|
if(isset($get_vars['width'])) { |
342 |
|
$new_width = split("x", $get_vars['width']); |
343 |
|
$resize_aspect = round(($new_width[1] / $src_image_sz[1])*100, 2); |
344 |
|
} |
345 |
|
|
346 |
|
print "Quality: ".$global_var['image_sz']['default']['ql'] ." Resize Aspect: ". $resize_aspect ."%"; |
347 |
|
if(!file_exists($cache_dir)) |
348 |
|
mkdir($cache_dir,0777); |
349 |
|
|
350 |
// DEBUG: print "Quality: ".$global_var['image_sz']['default']['ql'] ." Resize Aspect: ". $resize_aspect ."%"; |
$debug = array(); |
351 |
|
|
352 |
exec($global_var['external']['magick'] |
exec($global_var['external']['magick'] |
353 |
.' -geometry '.$resize_aspect.'%' |
.' -geometry '.$resize_aspect.'%' |
354 |
.' -quality '.$global_var['image_sz']['default']['ql'] |
.' -quality '.$resize_quality |
355 |
.' '.$pwd.'/'.$src_image |
.' '.$pwd.'/'.$src_image |
356 |
.' '.$pwd.'/'.$global_var['path']['cache_dir'].'/'.$prefix.$src_image |
.' '.$pwd.'/'.$global_var['path']['cache_dir'].'/'.$prefix.$src_image, $debug, $ret_val |
357 |
); |
); |
358 |
|
|
359 |
|
print_r($debug); |
360 |
} |
} |
361 |
} |
} |
362 |
} |
} |
395 |
return $image_files[$prev]; |
return $image_files[$prev]; |
396 |
} |
} |
397 |
|
|
398 |
|
|
399 |
|
function get_split_path() |
400 |
|
{ |
401 |
|
global $pwd; |
402 |
|
|
403 |
|
$split_path = split('/', $pwd); |
404 |
|
|
405 |
|
return $split_path; |
406 |
|
} |
407 |
/** |
/** |
408 |
* Retirieves all filenames that are images exclude all |
* Retirieves all filenames that are images exclude all |
409 |
* other files. It's not recursive so it only examins the |
* other files. It's not recursive so it only examins the |
421 |
$pwd_dd = opendir($path); |
$pwd_dd = opendir($path); |
422 |
while(($file = readdir($pwd_dd)) !== false) { |
while(($file = readdir($pwd_dd)) !== false) { |
423 |
if(is_file($path."/".$file) |
if(is_file($path."/".$file) |
424 |
&& !eregi("^\.|^.*.php|^.*.css|^.*~",$file)) |
&& !eregi("^\.|^.*.php|^.*.css|^.*~|^.txt",$file)) |
425 |
array_push($images, $file); |
array_push($images, $file); |
426 |
} |
} |
427 |
} |
} |
455 |
|
|
456 |
|
|
457 |
|
|
458 |
|
|
459 |
|
|
460 |
|
function create_directory_browser() |
461 |
|
{ |
462 |
|
global $pwd, $dir_files; |
463 |
|
|
464 |
|
if(sizeof($dir_files)>0) { |
465 |
|
|
466 |
|
foreach($dir_files as $dir) { |
467 |
|
|
468 |
|
$dir_image = 'open.png'; |
469 |
|
|
470 |
|
if(file_exists($pwd.'/'.$dir.'/.htaccess')) |
471 |
|
$dir_image = 'protected.png'; |
472 |
|
|
473 |
|
echo <<<EOT |
474 |
|
<div style="text-align: center;">\n |
475 |
|
<a href="$php_self?dir=$pwd/$dir">\n |
476 |
|
<img src="../images/$dir_image" alt=""/><br/>$dir\n |
477 |
|
</a>\n |
478 |
|
</div>\n |
479 |
|
EOT; |
480 |
|
} |
481 |
|
} |
482 |
|
} |
483 |
|
|
484 |
|
|
485 |
|
|
486 |
|
|
487 |
|
|
488 |
|
|
489 |
if (isset($get_vars['dir']) && is_dir(rawurldecode($get_vars['dir']))) |
if (isset($get_vars['dir']) && is_dir(rawurldecode($get_vars['dir']))) |
490 |
{ |
{ |
491 |
$pwd = rawurldecode($get_vars['dir']); |
$pwd = rawurldecode($get_vars['dir']); |
500 |
// print the html header before continuing processing. |
// print the html header before continuing processing. |
501 |
html_template_header(); |
html_template_header(); |
502 |
|
|
503 |
|
//if($global_var['navigation_bar']) |
504 |
|
html_template_navbar(); |
505 |
|
|
506 |
if(sizeof($image_files) <= 0) { |
if(sizeof($image_files) <= 0) { |
507 |
if(sizeof($dir_files) > 0) { |
if(sizeof($dir_files) > 0) { |
508 |
|
create_directory_browser(); |
509 |
} else { |
} else { |
510 |
} |
} |
511 |
} else { |
} else { |
518 |
} |
} |
519 |
} |
} |
520 |
|
|
521 |
|
|
522 |
|
|
523 |
|
|
524 |
// print the html footer to make it nice and tidy. |
// print the html footer to make it nice and tidy. |
525 |
html_template_footer(); |
html_template_footer(); |
526 |
|
|
557 |
<title>expose: </title> |
<title>expose: </title> |
558 |
|
|
559 |
<style type="text/css"> |
<style type="text/css"> |
560 |
@import "/~ikea/style.css"; |
@import "./style.css"; |
561 |
</style> |
</style> |
562 |
|
|
563 |
<link rel="Shortcut Icon" type="image/x-icon" href="/img/favicon.ico" /> |
<link rel="Shortcut Icon" type="image/x-icon" href="/img/favicon.ico" /> |
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
|
581 |
|
|
582 |
/** |
/** |
583 |
* Prints the html footer, this contains only closing |
* Prints the html footer, this contains only closing |
584 |
* tags for the html document and the copyright notice. |
* tags for the html document and the copyright notice. |
588 |
global $global_var; |
global $global_var; |
589 |
echo <<<EOF |
echo <<<EOF |
590 |
<div id="copyright">\n |
<div id="copyright">\n |
591 |
{$global_var[str_msg][copyright]}<br /> |
{$global_var[str_msg][copyright]}<br />\n |
592 |
<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 |
593 |
</div> |
</div>\n\n |
594 |
</div> |
</div>\n |
595 |
</body> |
</body>\n |
596 |
</html> |
</html>\n |
597 |
EOF; |
EOF; |
598 |
} |
} |
599 |
|
|
600 |
|
|
601 |
|
|
602 |
|
|
603 |
|
|
604 |
|
|
605 |
|
function html_template_navbar() |
606 |
|
{ |
607 |
|
global $get_vars; |
608 |
|
$split_path = get_split_path(); |
609 |
|
|
610 |
|
if(sizeof($split_path) > 0) { |
611 |
|
|
612 |
|
foreach($split_path as $dir) { |
613 |
|
if($dir!='') { |
614 |
|
$path .= $dir.'/'; |
615 |
|
echo <<<EOT |
616 |
|
<a style="text-decoration: none;" href="$php_self?dir=$path"> |
617 |
|
EOT; |
618 |
|
if($dir == '.') |
619 |
|
$dir = 'expose'; |
620 |
|
|
621 |
|
echo <<<EOT |
622 |
|
$dir</a> > \n |
623 |
|
EOT; |
624 |
|
} |
625 |
|
} |
626 |
|
if(isset($get_vars['img'])) { |
627 |
|
echo <<<EOT |
628 |
|
{$get_vars[img]} |
629 |
|
EOT; |
630 |
|
} |
631 |
|
} |
632 |
|
} |
633 |
|
|
634 |
?> |
?> |