/[cvs]/expose/index.php
ViewVC logotype

Diff of /expose/index.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by cam, Wed Nov 5 13:50:57 2003 UTC revision 1.8 by cam, Fri Nov 7 22:39:24 2003 UTC
# Line 20  Line 20 
20  | Version 2 along with this program; if not, visit GNU's Home Page  | Version 2 along with this program; if not, visit GNU's Home Page
21  | http://www.gnu.org/  | http://www.gnu.org/
22  +----------------------------------------------------------------------+  +----------------------------------------------------------------------+
23    $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>";
# Line 40  $global_var['image_sz']['thumb'] = array Line 52  $global_var['image_sz']['thumb'] = array
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,
# Line 60  $global_var['image_sz']['1024'] = array Line 71  $global_var['image_sz']['1024'] = array
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 {
# Line 77  if (isset($_GET)) { Line 97  if (isset($_GET)) {
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: Off');
140                                                                            break;
141                                                                    case '1':
142                                                                            array_push($exif_headers, 'Flash: On');
143                                                                            break;
144                                                            }
145                                                            break;
146                                                    case 'ISOSpeedRatings';
147                                                            array_push($exif_headers, 'ISO: '.$exif_value);
148                                                            break;
149                                                    default:
150                                                            break;
151                                            }
152                            }
153                    }
154                    if(sizeof($exif_headers)>0)     {
155                            ksort($exif_headers);
156                            reset($exif_headers);
157                    }
158            }
159  }  }
160    
161    
# Line 116  function print_thumbnails() Line 187  function print_thumbnails()
187          if(!file_exists($pwd.'/'.$global_var['path']['thumb_dir']))          if(!file_exists($pwd.'/'.$global_var['path']['thumb_dir']))
188                  mkdir($pwd.'/'.$global_var['path']['thumb_dir'],0777);                  mkdir($pwd.'/'.$global_var['path']['thumb_dir'],0777);
189    
190            echo <<<EOT
191                    <div id="thumbnails_container">\n
192                    
193    EOT;
194    
195          foreach($image_files as $image) {          foreach($image_files as $image) {
196    
197                    $thumb_image = $pwd.'/'.$global_var['path']['thumb_dir'].'/'.$image;
198    
199                  // check if a thumbnail for current image exists, if not create one.                                                      // check if a thumbnail for current image exists, if not create one.                                    
200                  if(!file_exists($pwd.'/'.$global_var['path']['thumb_dir'].'/'.$image))                  if(!file_exists($thumb_image))
201                          create_thumbnail($image);                          create_thumbnail($image);
202    
203                    $thumb_sz = GetImageSize($thumb_image);
204            
205                  echo <<<EOT                  echo <<<EOT
206                  <div class="thumbnail">\n                          <div class="thumbnail" style="width: {$thumb_sz[0]}px; height: {$thumb_sz[1]}px;">\n
207                          <a href="$php_self?dir=$pwd&img=$image">                                  <a href="$php_self?dir=$pwd&img=$image">
208                                  <img src="$pwd/{$global_var[path][thumb_dir]}/$image" alt=""/>                                          <img src="$thumb_image" alt=""/>
209                          </a>                                  </a>
210                  </div>\n                          </div>\n
211  EOT;  EOT;
212          }          }
213    
214            echo <<<EOT
215                    </div>\n                
216                    <div style="clear: both;"><br/></div>\n
217    EOT;
218  }  }
219    
220    
# Line 137  EOT; Line 222  EOT;
222    
223  function show_image()  function show_image()
224  {  {
225          global $global_var, $get_vars, $pwd;          global $global_var, $get_vars, $pwd, $exif_headers;
226    
227            $image = $pwd.'/'.$get_vars['img'];
228    
229            $cached_image = $pwd.'/'.$global_var['path']['cache_dir'];
230    
231          if(file_exists($pwd.'/'.$get_vars['img'])) {          if(file_exists($image)) {
232    
233                    $image_size = GetImageSize($image);
234                    $src_image_size = $image_size;
235    
236                    if(isset($get_vars['width'])) {
237                            
238                            $cache_size = split("x",$get_vars['width']);
239                            
240                            if($cache_size[0] >= $src_image_size[0]) {
241                                    $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 {
254                            if(!file_exists($cached_image.'/default_'.$get_vars['img'])) {
255                                    resize_image('default_');
256    
257                            }
258                            $cached_image = $cached_image.'/default_'.$get_vars['img'];
259                            
260                    }
261    
262                    $image_size = GetImageSize($cached_image);
263                    
264                    extract_exif_data();
265            
266                    if(sizeof($exif_headers) > 0) {
267    
268                            $exif_str .= sprintf("<span style=\"font-weight: bold; color:#333;\">EXIF</span> ");
269    
270                            foreach($exif_headers as $exif_tag) {
271                                    $exif_str .= sprintf("| %s ", $exif_tag);
272                            }
273    
274                            echo <<<EOT
275                                    <div id="exif_headers">\n
276                                            <span>$exif_str</span>\n
277                                    </div>\n
278    EOT;
279    
280                    }
281                    
282            
283                  echo <<<EOT                  echo <<<EOT
284                          <div id="image">\n                          <div id="image" style="width: {$image_size[0]}px; height: {$image_size[1]}px;">\n
285                                  <img src="$pwd/{$get_vars[img]}" alt="">                                  <a href="$image" target="_blank"><img src="$cached_image" alt=""></a>
286                          </div>\n                          </div>\n
287  EOT;  EOT;
288    
289                    $image_index = get_image_index();
290                    $next = get_next_image($image_index);
291                    $prev = get_prev_image($image_index);
292    
293                    echo <<<EOT
294                            <span style="font-weight: bold;">Size:</span>&nbsp;
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>&nbsp;
306    EOT;
307                            }
308    
309                    }
310                    
311                    echo <<<EOT
312                            <a href="$pwd/{$get_vars[img]}" target="_blank">{$src_image_size[0]}x{$src_image_size[1]}</a>
313    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;
321                    
322          }          }
323  }  }
324    
325    
326    
327    
328  function resize_image()  function resize_image($prefix)
329  {  {
330            global $global_var, $get_vars, $pwd;
331            $src_image = $get_vars['img'];
332            $cache_dir = $pwd.'/'.$global_var['path']['cache_dir'];
333    
334            if(isset($global_var['external']['magick'])) {
335                    if(file_exists($pwd.'/'.$src_image)) {
336    
337                            $src_image_sz = GetImageSize($pwd.'/'.$src_image);
338                            $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                            // DEBUG: print "Quality: ".$global_var['image_sz']['default']['ql'] ." Resize Aspect: ". $resize_aspect ."%";
347    
348                            if(!file_exists($cache_dir))
349                                    mkdir($cache_dir,0777);
350    
351                            $debug = array();
352    
353                            exec($global_var['external']['magick']
354                                    .' -geometry '.$resize_aspect.'%'
355                                    .' -quality '.$resize_quality
356                                    .' '.$pwd.'/'.$src_image
357                                    .' '.$pwd.'/'.$global_var['path']['cache_dir'].'/'.$prefix.$src_image, $debug, $ret_val
358                                    );
359    
360                            print_r($debug);
361                    }      
362            }      
363  }  }
364    
365    
366    
367    
368    function get_image_index()
369    {
370            global $get_vars, $image_files;
371    
372            return array_search($get_vars['img'], $image_files);
373    }
374    
375    function get_next_image($pos)
376    {
377            global $get_vars, $image_files;
378    
379            $next = $pos + 1;
380            
381            if($next >= sizeof($image_files))
382                    $next = 0;
383    
384            return $image_files[$next];
385    }
386    
387    function get_prev_image($pos)
388    {
389            global $get_vars, $image_files;
390    
391            $prev = $pos - 1;
392            
393            if($prev < 0)
394                    $prev = sizeof($image_files) - 1;
395    
396            return $image_files[$prev];
397    }
398    
399    
400    function get_split_path()
401    {
402            global $pwd;
403    
404            $split_path = split('/', $pwd);
405    
406            return $split_path;
407    }
408  /**  /**
409   * Retirieves all filenames that are images exclude all   * Retirieves all filenames that are images exclude all
410   * other files. It's not recursive so it only examins the   * other files. It's not recursive so it only examins the
# Line 173  function &get_image_filenames($path) Line 422  function &get_image_filenames($path)
422                  $pwd_dd = opendir($path);                  $pwd_dd = opendir($path);
423                  while(($file = readdir($pwd_dd)) !== false) {                                    while(($file = readdir($pwd_dd)) !== false) {                  
424                          if(is_file($path."/".$file)                          if(is_file($path."/".$file)
425                                  && !eregi("^\.|^.*.php|^.*.css|^.*~",$file))                                  && !eregi("^\.|^.*.php|^.*.css|^.*~|^.txt",$file))
                                 //&& $file != '.' && $file != '..')  
426                                          array_push($images, $file);                                          array_push($images, $file);
427                  }                  }
428          }          }
# Line 183  function &get_image_filenames($path) Line 431  function &get_image_filenames($path)
431    
432    
433    
434    
435  /**  /**
436   * Retrieves all directory names present in $path. Using   * Retrieves all directory names present in $path. Using
437   * eregi we exclude names we don't want in the list.   * eregi we exclude names we don't want in the list.
# Line 196  function &get_directory_names($path) Line 445  function &get_directory_names($path)
445                  $pwd_dd = opendir($path);                  $pwd_dd = opendir($path);
446                  while(($file = readdir($pwd_dd)) !== false) {                                    while(($file = readdir($pwd_dd)) !== false) {                  
447                          if(is_dir($path."/".$file)                          if(is_dir($path."/".$file)
448                                  && !eregi("^\.|^\..|^". $global_var['path']['thumb_dir']                                  && !eregi("^\.|^\..|^CVS|^". $global_var['path']['thumb_dir']
449                                                          ."|^". $global_var['path']['cache_dir'],$file))                                                          ."|^". $global_var['path']['cache_dir'],$file))
450                                  array_push($dirs, $file);                                  array_push($dirs, $file);
451                  }                  }
# Line 206  function &get_directory_names($path) Line 455  function &get_directory_names($path)
455    
456    
457    
458    
459    
460    
461    function create_directory_browser()
462    {
463            global $pwd, $dir_files;
464    
465            if(sizeof($dir_files)>0) {
466                    
467                    foreach($dir_files as $dir)  {
468    
469                            $dir_image = 'open.png';
470            
471                            if(file_exists($pwd.'/'.$dir.'/.htaccess'))
472                                    $dir_image = 'protected.png';
473    
474                            echo <<<EOT
475                                    <div style="text-align: center;">\n
476                                            <a href="$php_self?dir=$pwd/$dir">\n
477                                                    <img src="../images/$dir_image" alt=""/><br/>$dir\n
478                                            </a>\n
479                                    </div>\n
480    EOT;
481                    }      
482            }
483    }
484    
485    
486    
487    
488    
489    
490  if (isset($get_vars['dir']) && is_dir(rawurldecode($get_vars['dir'])))  if (isset($get_vars['dir']) && is_dir(rawurldecode($get_vars['dir'])))
491  {  {
492          $pwd = rawurldecode($get_vars['dir']);          $pwd = rawurldecode($get_vars['dir']);
# Line 220  $dir_files =& get_directory_names($pwd); Line 501  $dir_files =& get_directory_names($pwd);
501  // print the html header before continuing processing.  // print the html header before continuing processing.
502  html_template_header();  html_template_header();
503    
504    //if($global_var['navigation_bar'])
505            html_template_navbar();
506    
507  if(sizeof($image_files) <= 0) {  if(sizeof($image_files) <= 0) {
508          if(sizeof($dir_files) > 0) {          if(sizeof($dir_files) > 0) {
509                    create_directory_browser();
510          } else {          } else {
511          }          }
512  } else {  } else {
# Line 235  if(sizeof($image_files) <= 0) { Line 519  if(sizeof($image_files) <= 0) {
519          }          }
520  }  }
521    
522    
523    
524    
525  // print the html footer to make it nice and tidy.  // print the html footer to make it nice and tidy.
526  html_template_footer();  html_template_footer();
527    
# Line 268  echo <<<EOF Line 555  echo <<<EOF
555          <meta name="description" content="{$global_var[metadata][description]}" />          <meta name="description" content="{$global_var[metadata][description]}" />
556          <meta name="robots" content="all" />          <meta name="robots" content="all" />
557                    
558          <title></title>          <title>expose: </title>
559                    
560          <style type="text/css">          <style type="text/css">
561                  @import "/~ikea/style.css";                  @import "./style.css";
562          </style>          </style>
563                    
564          <link rel="Shortcut Icon" type="image/x-icon" href="/img/favicon.ico" />                  <link rel="Shortcut Icon" type="image/x-icon" href="/img/favicon.ico" />        
# Line 279  echo <<<EOF Line 566  echo <<<EOF
566  </head>  </head>
567    
568  <body>  <body>
569    <div id="header">\n
570            <h1>expose:</h1>
571            <span style="font-style: italic;"></span>
572    </div>\n
573  <div id="container">\n  <div id="container">\n
574  EOF;  EOF;
575  }  }
# Line 287  EOF; Line 577  EOF;
577    
578    
579    
580    
581    
582    
583  /**  /**
584   * Prints the html footer, this contains only closing   * Prints the html footer, this contains only closing
585   * tags for the html document and the copyright notice.   * tags for the html document and the copyright notice.
# Line 296  function html_template_footer() Line 589  function html_template_footer()
589          global $global_var;          global $global_var;
590  echo <<<EOF  echo <<<EOF
591          <div id="copyright">\n          <div id="copyright">\n
592                  {$global_var[str_msg][copyright]}                  {$global_var[str_msg][copyright]}<br />\n
593          </div>                  <span style="font-style: italic;">\$Revision$</span>\n
594  </div>          </div>\n\n
595  </body>  </div>\n
596  </html>  </body>\n
597    </html>\n
598  EOF;  EOF;
599  }  }
600    
601    
602    
603    
604    
605    
606    function html_template_navbar()
607    {
608            global $get_vars;
609            $split_path = get_split_path();
610    
611            if(sizeof($split_path) > 0) {
612    
613                    foreach($split_path as $dir) {
614                            if($dir!='') {
615                                    $path .= $dir.'/';
616                                    echo <<<EOT
617                                            <a style="text-decoration: none;" href="$php_self?dir=$path">
618    EOT;
619                                    if($dir == '.')
620                                            $dir = 'expose';
621    
622                                    echo <<<EOT
623                                            $dir</a> &gt;&nbsp;\n
624    EOT;
625                            }
626                    }
627                    if(isset($get_vars['img'])) {
628                            echo <<<EOT
629                                    {$get_vars[img]}
630    EOT;
631                    }
632            }
633    }
634    
635  ?>  ?>

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.8

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26