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']['valid_sizes'] = array ( |
75 |
|
'640x480', |
76 |
|
'800x600', |
77 |
|
'1024x768' |
78 |
|
); |
79 |
|
|
80 |
|
$global_var['image_sz']['default'] =& $global_var['image_sz']['640']; |
81 |
|
|
82 |
|
$exif_headers = array (); |
83 |
|
|
84 |
|
|
85 |
if(isset($_SERVER['PHP_SELF'])) { |
if(isset($_SERVER['PHP_SELF'])) { |
86 |
$php_self = $_SERVER['PHP_SELF']; |
$php_self = $_SERVER['PHP_SELF']; |
87 |
} else { |
} else { |
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. |
103 |
*/ |
*/ |
104 |
function extract_exif_data() |
function extract_exif_data() |
105 |
{ |
{ |
106 |
|
global $global_var, $pwd, $get_vars, $exif_headers; |
107 |
|
|
108 |
|
$src_image = $get_vars['img']; |
109 |
|
$exif_data = @exif_read_data($pwd.'/'.$src_image,0,true); |
110 |
|
|
111 |
|
if($exif_data) { |
112 |
|
|
113 |
|
foreach($exif_data as $exif_section_key => $exif_section) { |
114 |
|
foreach($exif_section as $exif_key => $exif_value) { |
115 |
|
|
116 |
|
switch($exif_key) { |
117 |
|
case 'Model': |
118 |
|
array_push($exif_headers, 'Model: '.$exif_value); |
119 |
|
break; |
120 |
|
|
121 |
|
case 'ApertureFNumber': |
122 |
|
array_push($exif_headers, 'Aperture: '. $exif_value); |
123 |
|
break; |
124 |
|
|
125 |
|
case 'FocalLength': |
126 |
|
$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; |
131 |
|
|
132 |
|
case 'DateTime': |
133 |
|
array_push($exif_headers, 'Date: '.$exif_value); |
134 |
|
break; |
135 |
|
|
136 |
|
case 'FlashMode': |
137 |
|
switch($exif_value) { |
138 |
|
case '0': |
139 |
|
array_push($exif_headers, 'Flash: Auto'); |
140 |
|
break; |
141 |
|
case '1': |
142 |
|
array_push($exif_headers, 'Flash: On'); |
143 |
|
break; |
144 |
|
case '2': |
145 |
|
array_push($exif_headers, 'Flash: Off'); |
146 |
|
break; |
147 |
|
case '3': |
148 |
|
array_push($exif_headers, 'Flash: Red-Eye Reduction'); |
149 |
|
break; |
150 |
|
default: |
151 |
|
array_push($exif_headers, 'Flash: Unknown'); |
152 |
|
break; |
153 |
|
} |
154 |
|
break; |
155 |
|
case 'FocusMode': |
156 |
|
|
157 |
|
switch($exif_value) { |
158 |
|
case '0': |
159 |
|
array_push($exif_headers, 'Focus: C-AF/S-AF'); |
160 |
|
break; |
161 |
|
case '1': |
162 |
|
array_push($exif_headers, 'Focus: MF'); |
163 |
|
break; |
164 |
|
default: |
165 |
|
break; |
166 |
|
} |
167 |
|
break; |
168 |
|
case 'ISOSpeedRatings'; |
169 |
|
array_push($exif_headers, 'ISO: '.$exif_value); |
170 |
|
break; |
171 |
|
default: |
172 |
|
break; |
173 |
|
} |
174 |
|
} |
175 |
|
} |
176 |
|
if(sizeof($exif_headers)>0) { |
177 |
|
ksort($exif_headers); |
178 |
|
reset($exif_headers); |
179 |
|
} |
180 |
|
} |
181 |
} |
} |
182 |
|
|
183 |
|
|
209 |
if(!file_exists($pwd.'/'.$global_var['path']['thumb_dir'])) |
if(!file_exists($pwd.'/'.$global_var['path']['thumb_dir'])) |
210 |
mkdir($pwd.'/'.$global_var['path']['thumb_dir'],0777); |
mkdir($pwd.'/'.$global_var['path']['thumb_dir'],0777); |
211 |
|
|
212 |
|
echo <<<EOT |
213 |
|
<div id="thumbnails_container">\n |
214 |
|
|
215 |
|
EOT; |
216 |
|
|
217 |
foreach($image_files as $image) { |
foreach($image_files as $image) { |
218 |
|
|
219 |
|
$thumb_image = $pwd.'/'.$global_var['path']['thumb_dir'].'/'.$image; |
220 |
|
|
221 |
// check if a thumbnail for current image exists, if not create one. |
// check if a thumbnail for current image exists, if not create one. |
222 |
if(!file_exists($pwd.'/'.$global_var['path']['thumb_dir'].'/'.$image)) |
if(!file_exists($thumb_image)) |
223 |
create_thumbnail($image); |
create_thumbnail($image); |
224 |
|
|
225 |
|
$thumb_sz = GetImageSize($thumb_image); |
226 |
|
|
227 |
echo <<<EOT |
echo <<<EOT |
228 |
<div class="thumbnail">\n |
<div class="thumbnail" style="width: {$thumb_sz[0]}px; height: {$thumb_sz[1]}px;">\n |
229 |
<a href="$php_self?dir=$pwd&img=$image"> |
<a href="$php_self?dir=$pwd&img=$image"> |
230 |
<img src="$pwd/{$global_var[path][thumb_dir]}/$image" alt=""/> |
<img src="$thumb_image" alt=""/> |
231 |
</a> |
</a> |
232 |
</div>\n |
</div>\n |
233 |
EOT; |
EOT; |
234 |
} |
} |
235 |
|
|
236 |
|
echo <<<EOT |
237 |
|
</div>\n |
238 |
|
<div style="clear: both;"><br/></div>\n |
239 |
|
EOT; |
240 |
} |
} |
241 |
|
|
242 |
|
|
244 |
|
|
245 |
function show_image() |
function show_image() |
246 |
{ |
{ |
247 |
global $global_var, $get_vars, $pwd; |
global $global_var, $get_vars, $pwd, $exif_headers; |
248 |
|
|
249 |
|
$image = $pwd.'/'.$get_vars['img']; |
250 |
|
|
251 |
|
$cached_image = $pwd.'/'.$global_var['path']['cache_dir']; |
252 |
|
|
253 |
if(file_exists($pwd.'/'.$get_vars['img'])) { |
if(file_exists($image)) { |
254 |
|
|
255 |
|
$image_size = GetImageSize($image); |
256 |
|
$src_image_size = $image_size; |
257 |
|
|
258 |
|
if(isset($get_vars['width'])) { |
259 |
|
|
260 |
|
$cache_size = split("x",$get_vars['width']); |
261 |
|
|
262 |
|
if($cache_size[0] >= $src_image_size[0]) { |
263 |
|
$cache_image = $image; |
264 |
|
} else { |
265 |
|
if(array_search($get_vars['width'], $global_var['image_sz']['valid_sizes'])) { |
266 |
|
if(!file_exists($pwd.'/.cache/'.$get_vars['width'].'_'.$get_vars['img'])) { |
267 |
|
resize_image($get_vars['width'].'_'); |
268 |
|
} |
269 |
|
$cached_image = $pwd.'/.cache/'.$get_vars['width'].'_'.$get_vars['img']; |
270 |
|
} |
271 |
|
if($cache_size[0] == $global_var['image_sz']['default']['x']) |
272 |
|
$cached_image = $cached_image.'/default_'.$get_vars['img']; |
273 |
|
} |
274 |
|
|
275 |
|
} else { |
276 |
|
if(!file_exists($cached_image.'/default_'.$get_vars['img'])) { |
277 |
|
resize_image('default_'); |
278 |
|
|
279 |
|
} |
280 |
|
$cached_image = $cached_image.'/default_'.$get_vars['img']; |
281 |
|
|
282 |
|
} |
283 |
|
|
284 |
|
$image_size = GetImageSize($cached_image); |
285 |
|
|
286 |
|
extract_exif_data(); |
287 |
|
|
288 |
|
if(sizeof($exif_headers) > 0) { |
289 |
|
|
290 |
|
$exif_str .= sprintf("<span style=\"font-weight: bold; color:#333;\">EXIF</span> "); |
291 |
|
|
292 |
|
foreach($exif_headers as $exif_tag) { |
293 |
|
$exif_str .= sprintf("| %s ", $exif_tag); |
294 |
|
} |
295 |
|
|
296 |
|
echo <<<EOT |
297 |
|
<div id="exif_headers">\n |
298 |
|
<span>$exif_str</span>\n |
299 |
|
</div>\n |
300 |
|
EOT; |
301 |
|
|
302 |
|
} |
303 |
|
|
304 |
|
|
305 |
echo <<<EOT |
echo <<<EOT |
306 |
<div id="image">\n |
<div id="image" style="width: {$image_size[0]}px; height: {$image_size[1]}px;">\n |
307 |
<img src="$pwd/{$get_vars[img]}" alt=""> |
<a href="$image" target="_blank"><img src="$cached_image" alt=""></a> |
308 |
</div>\n |
</div>\n |
309 |
EOT; |
EOT; |
310 |
|
|
311 |
|
$image_index = get_image_index(); |
312 |
|
$next = get_next_image($image_index); |
313 |
|
$prev = get_prev_image($image_index); |
314 |
|
|
315 |
|
echo <<<EOT |
316 |
|
<span style="font-weight: bold;">Size:</span> |
317 |
|
EOT; |
318 |
|
|
319 |
|
foreach($global_var['image_sz']['valid_sizes'] as $new_size) { |
320 |
|
|
321 |
|
if($get_vars['width'] == $new_size) { |
322 |
|
echo $new_size; |
323 |
|
} elseif($cache_size[0] >= $src_image_size[0]) { |
324 |
|
} else { |
325 |
|
|
326 |
|
echo <<<EOT |
327 |
|
<a href="$php_self?dir=$pwd&img={$get_vars[img]}&width=$new_size">$new_size</a> |
328 |
|
EOT; |
329 |
|
} |
330 |
|
|
331 |
|
} |
332 |
|
|
333 |
|
echo <<<EOT |
334 |
|
<a href="$pwd/{$get_vars[img]}" target="_blank">{$src_image_size[0]}x{$src_image_size[1]}</a> |
335 |
|
EOT; |
336 |
|
|
337 |
|
echo <<<EOT |
338 |
|
<div>\n |
339 |
|
<a href="$php_self?dir=$pwd&img=$prev">prev</a> |
340 |
|
<a href="$php_self?dir=$pwd&img=$next">next</a>\n |
341 |
|
</div>\n |
342 |
|
EOT; |
343 |
|
|
344 |
} |
} |
345 |
} |
} |
346 |
|
|
347 |
|
|
348 |
|
|
349 |
|
|
350 |
function resize_image() |
function resize_image($prefix) |
351 |
{ |
{ |
352 |
|
global $global_var, $get_vars, $pwd; |
353 |
|
$src_image = $get_vars['img']; |
354 |
|
$cache_dir = $pwd.'/'.$global_var['path']['cache_dir']; |
355 |
|
|
356 |
|
if(isset($global_var['external']['magick'])) { |
357 |
|
if(file_exists($pwd.'/'.$src_image)) { |
358 |
|
|
359 |
|
$src_image_sz = GetImageSize($pwd.'/'.$src_image); |
360 |
|
$resize_aspect = round(($global_var['image_sz']['default']['y'] / $src_image_sz[1])*100, 2); |
361 |
|
$resize_quality = $global_var['image_sz']['default']['ql']; |
362 |
|
|
363 |
|
if(isset($get_vars['width'])) { |
364 |
|
$new_width = split("x", $get_vars['width']); |
365 |
|
$resize_aspect = round(($new_width[1] / $src_image_sz[1])*100, 2); |
366 |
|
} |
367 |
|
|
368 |
|
// DEBUG: print "Quality: ".$global_var['image_sz']['default']['ql'] ." Resize Aspect: ". $resize_aspect ."%"; |
369 |
|
|
370 |
|
if(!file_exists($cache_dir)) |
371 |
|
mkdir($cache_dir,0777); |
372 |
|
|
373 |
|
$debug = array(); |
374 |
|
|
375 |
|
exec($global_var['external']['magick'] |
376 |
|
.' -geometry '.$resize_aspect.'%' |
377 |
|
.' -quality '.$resize_quality |
378 |
|
.' '.$pwd.'/'.$src_image |
379 |
|
.' '.$pwd.'/'.$global_var['path']['cache_dir'].'/'.$prefix.$src_image, $debug, $ret_val |
380 |
|
); |
381 |
|
|
382 |
|
print_r($debug); |
383 |
|
} |
384 |
|
} |
385 |
} |
} |
386 |
|
|
387 |
|
|
388 |
|
|
389 |
|
|
390 |
|
function get_image_index() |
391 |
|
{ |
392 |
|
global $get_vars, $image_files; |
393 |
|
|
394 |
|
return array_search($get_vars['img'], $image_files); |
395 |
|
} |
396 |
|
|
397 |
|
function get_next_image($pos) |
398 |
|
{ |
399 |
|
global $get_vars, $image_files; |
400 |
|
|
401 |
|
$next = $pos + 1; |
402 |
|
|
403 |
|
if($next >= sizeof($image_files)) |
404 |
|
$next = 0; |
405 |
|
|
406 |
|
return $image_files[$next]; |
407 |
|
} |
408 |
|
|
409 |
|
function get_prev_image($pos) |
410 |
|
{ |
411 |
|
global $get_vars, $image_files; |
412 |
|
|
413 |
|
$prev = $pos - 1; |
414 |
|
|
415 |
|
if($prev < 0) |
416 |
|
$prev = sizeof($image_files) - 1; |
417 |
|
|
418 |
|
return $image_files[$prev]; |
419 |
|
} |
420 |
|
|
421 |
|
|
422 |
|
function get_split_path() |
423 |
|
{ |
424 |
|
global $pwd; |
425 |
|
|
426 |
|
$split_path = split('/', $pwd); |
427 |
|
|
428 |
|
return $split_path; |
429 |
|
} |
430 |
/** |
/** |
431 |
* Retirieves all filenames that are images exclude all |
* Retirieves all filenames that are images exclude all |
432 |
* other files. It's not recursive so it only examins the |
* other files. It's not recursive so it only examins the |
444 |
$pwd_dd = opendir($path); |
$pwd_dd = opendir($path); |
445 |
while(($file = readdir($pwd_dd)) !== false) { |
while(($file = readdir($pwd_dd)) !== false) { |
446 |
if(is_file($path."/".$file) |
if(is_file($path."/".$file) |
447 |
&& !eregi("^\.|^.*.php|^.*.css|^.*~",$file)) |
&& !eregi("^\.|^.*.php|^.*.css|^.*~|^.txt",$file)) |
448 |
array_push($images, $file); |
array_push($images, $file); |
449 |
} |
} |
450 |
} |
} |
453 |
|
|
454 |
|
|
455 |
|
|
456 |
|
|
457 |
/** |
/** |
458 |
* Retrieves all directory names present in $path. Using |
* Retrieves all directory names present in $path. Using |
459 |
* eregi we exclude names we don't want in the list. |
* eregi we exclude names we don't want in the list. |
477 |
|
|
478 |
|
|
479 |
|
|
480 |
|
|
481 |
|
|
482 |
|
|
483 |
|
function create_directory_browser() |
484 |
|
{ |
485 |
|
global $pwd, $dir_files; |
486 |
|
|
487 |
|
if(sizeof($dir_files)>0) { |
488 |
|
|
489 |
|
foreach($dir_files as $dir) { |
490 |
|
|
491 |
|
$dir_image = 'open.png'; |
492 |
|
|
493 |
|
if(file_exists($pwd.'/'.$dir.'/.htaccess')) |
494 |
|
$dir_image = 'protected.png'; |
495 |
|
|
496 |
|
echo <<<EOT |
497 |
|
<div style="text-align: center;">\n |
498 |
|
<a href="$php_self?dir=$pwd/$dir">\n |
499 |
|
<img src="../images/$dir_image" alt=""/><br/>$dir\n |
500 |
|
</a>\n |
501 |
|
</div>\n |
502 |
|
EOT; |
503 |
|
} |
504 |
|
} |
505 |
|
} |
506 |
|
|
507 |
|
|
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
|
512 |
if (isset($get_vars['dir']) && is_dir(rawurldecode($get_vars['dir']))) |
if (isset($get_vars['dir']) && is_dir(rawurldecode($get_vars['dir']))) |
513 |
{ |
{ |
514 |
$pwd = rawurldecode($get_vars['dir']); |
$pwd = rawurldecode($get_vars['dir']); |
523 |
// print the html header before continuing processing. |
// print the html header before continuing processing. |
524 |
html_template_header(); |
html_template_header(); |
525 |
|
|
526 |
|
//if($global_var['navigation_bar']) |
527 |
|
html_template_navbar(); |
528 |
|
|
529 |
if(sizeof($image_files) <= 0) { |
if(sizeof($image_files) <= 0) { |
530 |
if(sizeof($dir_files) > 0) { |
if(sizeof($dir_files) > 0) { |
531 |
|
create_directory_browser(); |
532 |
} else { |
} else { |
533 |
} |
} |
534 |
} else { |
} else { |
541 |
} |
} |
542 |
} |
} |
543 |
|
|
544 |
|
|
545 |
|
|
546 |
|
|
547 |
// print the html footer to make it nice and tidy. |
// print the html footer to make it nice and tidy. |
548 |
html_template_footer(); |
html_template_footer(); |
549 |
|
|
577 |
<meta name="description" content="{$global_var[metadata][description]}" /> |
<meta name="description" content="{$global_var[metadata][description]}" /> |
578 |
<meta name="robots" content="all" /> |
<meta name="robots" content="all" /> |
579 |
|
|
580 |
<title></title> |
<title>expose: </title> |
581 |
|
|
582 |
<style type="text/css"> |
<style type="text/css"> |
583 |
@import "/~ikea/style.css"; |
@import "./style.css"; |
584 |
</style> |
</style> |
585 |
|
|
586 |
<link rel="Shortcut Icon" type="image/x-icon" href="/img/favicon.ico" /> |
<link rel="Shortcut Icon" type="image/x-icon" href="/img/favicon.ico" /> |
588 |
</head> |
</head> |
589 |
|
|
590 |
<body> |
<body> |
591 |
|
<div id="header">\n |
592 |
|
<h1>expose:</h1> |
593 |
|
<span style="font-style: italic;"></span> |
594 |
|
</div>\n |
595 |
<div id="container">\n |
<div id="container">\n |
596 |
EOF; |
EOF; |
597 |
} |
} |
599 |
|
|
600 |
|
|
601 |
|
|
602 |
|
|
603 |
|
|
604 |
|
|
605 |
/** |
/** |
606 |
* Prints the html footer, this contains only closing |
* Prints the html footer, this contains only closing |
607 |
* tags for the html document and the copyright notice. |
* tags for the html document and the copyright notice. |
611 |
global $global_var; |
global $global_var; |
612 |
echo <<<EOF |
echo <<<EOF |
613 |
<div id="copyright">\n |
<div id="copyright">\n |
614 |
{$global_var[str_msg][copyright]} |
{$global_var[str_msg][copyright]}<br />\n |
615 |
</div> |
<span style="font-style: italic;">\$Revision$</span>\n |
616 |
</div> |
</div>\n\n |
617 |
</body> |
</div>\n |
618 |
</html> |
</body>\n |
619 |
|
</html>\n |
620 |
EOF; |
EOF; |
621 |
} |
} |
622 |
|
|
623 |
|
|
624 |
|
|
625 |
|
|
626 |
|
|
627 |
|
|
628 |
|
function html_template_navbar() |
629 |
|
{ |
630 |
|
global $get_vars; |
631 |
|
$split_path = get_split_path(); |
632 |
|
|
633 |
|
if(sizeof($split_path) > 0) { |
634 |
|
|
635 |
|
foreach($split_path as $dir) { |
636 |
|
if($dir!='') { |
637 |
|
$path .= $dir.'/'; |
638 |
|
echo <<<EOT |
639 |
|
<a style="text-decoration: none;" href="$php_self?dir=$path"> |
640 |
|
EOT; |
641 |
|
if($dir == '.') |
642 |
|
$dir = 'expose'; |
643 |
|
|
644 |
|
echo <<<EOT |
645 |
|
$dir</a> > \n |
646 |
|
EOT; |
647 |
|
} |
648 |
|
} |
649 |
|
if(isset($get_vars['img'])) { |
650 |
|
echo <<<EOT |
651 |
|
{$get_vars[img]} |
652 |
|
EOT; |
653 |
|
} |
654 |
|
} |
655 |
|
} |
656 |
|
|
657 |
?> |
?> |