Ignore:
Timestamp:
Sep 10, 2011, 5:02:19 PM (13 years ago)
Author:
cljosse
Message:

[extensions] edit_gmaps add functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/edit_gmaps/admin/admin_edit.php

    r10060 r12126  
    1 <?php 
     1<?php
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    33global $lang;
     
    66
    77if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    8  
     8
    99/***********************************************************************************/
    1010if (!defined('TOOL_KIT_PATH')) define(  'TOOL_KIT_PATH',   EDIT_CL_PATH."admin/");
    11 if (!defined('INCLUDE_PATH')) define(  'INCLUDE_PATH',   TOOL_KIT_PATH.'include/' );                     
    12 $Toolkit_Dir =INCLUDE_PATH           ;   
    13  
     11if (!defined('INCLUDE_PATH')) define(  'INCLUDE_PATH',   TOOL_KIT_PATH.'include/' );
     12
     13$Toolkit_Dir =INCLUDE_PATH           ;
     14
    1415include $Toolkit_Dir . 'fonctions.php';
    15 /***********************************************************************************/
     16//==========================================================
     17if (!defined('EDIT_CL_PATH')) define(  'EDIT_CL_PATH',  EDIT_CL_PATH .'admin/' );
     18$path = EDIT_CL_PATH;
     19$plg_data = implode( '', file($path.'main.inc.php') );
     20if (preg_match("|Version: (.*)|", $plg_data, $val)) {
     21  $EDIT_CL_PATH_plugin['version'] = trim($val[1]); 
     22}
     23$EDIT_CL_PATH_plugin = array_map('htmlspecialchars', $EDIT_CL_PATH_plugin);
     24$version= $EDIT_CL_PATH_plugin['version'] ;
     25$icon_path = 'themes/default/icon/help.png';
     26$path_js=  'themes/default/js/' ;
     27/****************************************************************/
    1628$info_message="" ;
    17 $error_message="";
    18  
    19 /************* Mise à jour des meta données ***************/
    20 if ( isset($_POST['update']) && $_POST['update']==l10n('update_exif')){
    21   $exif = @read_exif_data( $exif );     
    22   $exif = @array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) );
    23 
    24   // error_reporting ( 0 );
    25   // Hide any unknown EXIF tags       
    26   $GLOBALS['HIDE_UNKNOWN_TAGS'] = FALSE;
    27   include $Toolkit_Dir.'Toolkit_Version.php';   // Change: added as of version 1.11
    28     // Include the required files for reading and writing Photoshop File Info
    29   include  $Toolkit_Dir.'JPEG.php';
    30   include  $Toolkit_Dir.'XMP.php';
    31   include  $Toolkit_Dir.'Photoshop_IRB.php';
    32   include  $Toolkit_Dir.'EXIF.php';
    33   include  $Toolkit_Dir.'GPS_File_Info.php';
    34   $GLOBALS['HTTP_POST_VARS']=$_POST ;
    35   // Copy all of the HTML Posted variables into an array
    36   $new_ps_file_info_array = $GLOBALS['HTTP_POST_VARS'];
    37   // Some characters are escaped with backslashes in HTML Posted variable
    38   // Cycle through each of the HTML Posted variables, and strip out the slashes '
    39   foreach( $new_ps_file_info_array as $var_key => $var_val ){
    40     if ($var_key !="selection")
    41         $new_ps_file_info_array[ $var_key ] = stripslashes( $var_val );                           
    42   }         
    43   $new_ps_file_info_array['selection'] = explode(";",$new_ps_file_info_array['filename']);
    44   foreach( $new_ps_file_info_array['selection']  as $filename )   {
    45     //======================================================
    46     //= $new_ps_file_info_array[ 'filename' ];
    47     if($filename!="") {   // Protect against hackers editing other files                               
    48       // copy( $filename,  $filename.".bak" ); 
    49       $path_parts = pathinfo( $filename );   
    50       if(1) {
    51         if ( strcasecmp( $path_parts["extension"], "jpg" ) != 0 ) {
    52           $error_message .= $filename ;                                 
    53           $error_message .="Incorrect File Type - JPEG Only\n";
    54           $filename="";
    55           //  exit( );
    56          }
    57         // Change: removed limitation on file being in current directory - as of version 1.11
    58         // Retrieve the header information
    59         $jpeg_header_data = get_jpeg_header_data( $filename );
    60         // Retreive the EXIF, XMP and Photoshop IRB information from
    61         // the existing file, so that it can be updated
    62         $Exif_array = get_EXIF_JPEG( $filename );
    63         $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) );
    64         $IRB_array = get_Photoshop_IRB( $jpeg_header_data );
    65 
    66         // Update the JPEG header information with the new Photoshop File Info
    67         $jpeg_header_data = put_GPS_file_info( $jpeg_header_data, $new_ps_file_info_array, $Exif_array, $XMP_array, $IRB_array );
    68         // Check if the Update worked
    69         if ( $jpeg_header_data == FALSE ) {
    70             // Update of file info didn''t work - output error message
    71             $error_message .= "jpeg_header_data
    72             Error - Failure update Photoshop File Info : $filename <br>\n";
    73             // Output HTML with the form and data which was
    74             // sent, to allow the user to fix it
    75           }else if ( FALSE == put_jpeg_header_data(  $filename, $filename, $jpeg_header_data ) ) {
    76             // Attempt to write the new JPEG file
    77             // Writing of the new file didn''t work - output error message
    78             $error_message .= "Error - Failure to write new JPEG : $filename <br>\n";
    79             // Output HTML with the form and data which was
    80             // sent, to allow the user to fix it
    81           }else{
    82             $info_message .= l10n('update') . " Exif: " . $filename . " " .  l10n('OK') ."<br />" ;
    83           }   
    84           $_POST['submit']= l10n('update_database') ;
    85         }
    86       }
    87     }
    88     $_POST['update'] ="ok";
    89   }
     29$erreur_message="";
    9030/****************************************************************/
    9131if ( !isset($_GET['cat']) )   $_GET['cat'] = 'caddie';
    9232$_GET['mode'] = 'map';
    93 if (PHPWG_VERSION < 2.2 ) {
    94  include (PHPWG_ROOT_PATH.'admin/element_set.php');                             
    95  } else {
    96 if (!isset($page['title'])) $page['title']="";
    97     include (PHPWG_ROOT_PATH.'admin/batch_manager.php');                 
     33    if (PHPWG_VERSION < 2.2 ) {
     34      include (PHPWG_ROOT_PATH.'admin/element_set.php');
     35    } else {
     36      if (!isset($page['title'])) $page['title']="";
     37      include (PHPWG_ROOT_PATH.'admin/batch_manager.php');
    9838    $template->concat('TABSHEET_TITLE', ' '.l10n_dec('%d image', '%d images', count($page['cat_elements_id'])).' - '.$page['title']);
    99    }   
    100 
    101 if ( isset($_POST['submit'])  ) {
    102         $collection = array();
    103                 if( !isset ($_POST['target'])) {
    104                     $_POST['submit'] = l10n('Submit') ;
    105                     $_POST['target']='selection';
    106                     $collection = $_POST['selection'];
    107                }
    108 
    109   switch ($_POST['target'])
    110   {
     39  }
     40//===============================================================
     41$collection = array();
     42if(!isset($_POST['target'])) $_POST['target']="";
     43
     44  switch ($_POST['target']){
    11145    case 'all' :
    11246      $collection = $page['cat_elements_id'];
    113       break;
     47    break;
    11448    case 'selection' :
    11549      if (!isset($_POST['selection']) or count($_POST['selection']) == 0)
     
    11751      else
    11852        $collection = $_POST['selection'];
    119       break;
    120   }
    121 
     53    break;
     54  }
     55if (isset($_POST['selection'])){}
     56//===============================================================       
     57  $images=array();   
     58if (!empty($_GET['display']))
     59{
     60  if ('all' == $_GET['display'])
     61    $page['nb_images'] = count($page['cat_elements_id']);
     62  else
     63    $page['nb_images'] = intval($_GET['display']);
     64}
     65else
     66  $page['nb_images'] = 20;
     67
     68if ( !empty($page['cat_elements_id']) )
     69{
     70  $query='
     71SELECT id,tn_ext,name,path,file,lat,lon,alt FROM '.IMAGES_TABLE.'
     72  WHERE id IN ('.implode(',',$page['cat_elements_id']).')
     73  '.$conf['order_by'].'
     74  LIMIT '.$page['start'].', '.   $page['nb_images'] .'
     75;';
     76  $result = pwg_query($query);
     77  while ( $row=mysql_fetch_assoc($result) )
     78    $images[] = $row;
     79}
     80//===============================================================
     81global $lang_info;
     82if (date_default_timezone_get()) {
     83  $adresse =  date_default_timezone_get()   ;
     84}else{
     85
     86}
     87$adresse =  $lang_info['country'];   ;
     88$adresse=str_replace("/",", ",$adresse);
     89 
     90if (count($collection)>0 )
     91//=============================================================
     92  if (isset($_POST['update']) && $_POST['update']==l10n('update_exif')){
     93  /************* Mise à jour des meta données ***************/
     94    // error_reporting ( 0 );
     95    // Hide any unknown EXIF tags   
     96    $GLOBALS['HIDE_UNKNOWN_TAGS'] = FALSE;
     97    include $Toolkit_Dir.'Toolkit_Version.php';   // Change: added as of version 1.11
     98      // Include the required files for reading and writing Photoshop File Info
     99    include  $Toolkit_Dir.'JPEG.php';
     100    include  $Toolkit_Dir.'XMP.php';
     101    include  $Toolkit_Dir.'Photoshop_IRB.php';
     102    include  $Toolkit_Dir.'EXIF.php';
     103    include  $Toolkit_Dir.'GPS_File_Info.php';
     104
     105    $GLOBALS['HTTP_POST_VARS']=$_POST ;
     106    // Copy all of the HTML Posted variables into an array
     107    $new_ps_file_info_array = $GLOBALS['HTTP_POST_VARS'];
     108
     109    // Some characters are escaped with backslashes in HTML Posted variable
     110    // Cycle through each of the HTML Posted variables, and strip out the slashes '
     111
     112    foreach( $new_ps_file_info_array as $var_key => $var_val ){
     113      if ($var_key !="selection")
     114          $new_ps_file_info_array[ $var_key ] = stripslashes( $var_val );
     115    }
     116   
     117      $init_info =true;
     118      $first_image="";   
     119      $_POST['submit']="";
     120
     121      foreach ($collection as $id_0){
     122          foreach ($images as $image) { 
     123            if (array_search($id_0,$image)) {   
     124              //=================================================================
     125              // Donnée base de donnée
     126              //=================================================================
     127         //     $info_message .= "<div style='border:2px solid red'>$id_0 Image:" . cl_edit_functions::Memo_vars($image)."</div>" ;
     128               
     129              //=================================================================
     130              // Meta donnée
     131              //=================================================================
     132                $infos_gps  = array();
     133                $infos_gps  = cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ;
     134                if($image['lat']=='' || $image['lon']==''){
     135                    $image['lat']=$infos_gps['lat'];
     136                    $image['lon']=$infos_gps['lon'];
     137                    $image['alt']=$infos_gps['alt'];
     138                }     
     139
     140                if($image['lat']!=''){
     141                      $new_ps_file_info_array=  base_to_meta($image);
     142                  }
     143
     144                $new_ps_file_info_array['filename'] =  $image['path'];
     145                $new_ps_file_info_array['selection'] = explode(";",$new_ps_file_info_array['filename']);
     146   //   
     147          if( $image['lat']=="" ){
     148              $image['lat']=  $new_ps_file_info_array['lat'] ;
     149              $image['lon']=  $new_ps_file_info_array['lon'] ;
     150              $image['alt']=  $new_ps_file_info_array['alt'] ;
     151          }
     152        if($_POST['update']==l10n('update_exif')) unset($_POST['submit']);
     153        if(1) {
     154 
     155           if(  cl_edit_controler::add_meta_gps($new_ps_file_info_array,$image)){
     156             
     157                $exif = @read_exif_data( $image['path']);
     158                 $infos_gps  = cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ;
     159                $info_message .= $image['path'] . " : " . $image['file'] . " : ok<BR />";
     160                }else{
     161
     162                }
     163           }
     164        }else{
     165         
     166        } // fin search
     167      }   // fin id_0
     168    }     // fin collection     
     169    $_POST['update'] ="ok";
     170  }
     171
     172if ( isset($_POST['submit'])  ) {
    122173  /******** Mise à jour base de données *****/
    123174   if (   $_POST['submit'] == l10n('update_database') ){
    124         if ( count($collection)>0 ){
    125     $lat = trim($_POST['lat']);
    126     $lon = trim($_POST['lon']);
    127         $alt = trim($_POST['alt']);
    128 
    129     if ( strlen($lat)>0 and strlen($lon)>0 ) {
    130       if ( (double)$lat<=90 and (double)$lat>=-90
    131           and (double)$lon<=180 and (double)$lat>=-180 )
    132         $update_query = 'lat='.$lat.', lon='.$lon;
    133       else
    134         $page['errors'][] = 'Invalid lat or lon value';
     175    if ( count($collection)>0 ){
     176        $lat = trim($_POST['lat']);
     177        $lon = trim($_POST['lon']);
     178        $alt = trim($_POST['alt']);
     179        //===============================================================
     180       if($lat !="") cl_edit_controler::add_data_base($collection,$lat,$lon,$alt) ;
     181        $_POST['submit'] = l10n('Submit') ;
     182            foreach ($collection as $id_0){
     183          foreach ($images as $image) { 
     184            if (array_search($id_0,$image)) { 
     185              $image['lat'] =    $lat ;
     186              $image['lon']= $lon  ;
     187              $image['alt'] =$alt  ;
     188           }
     189          }
     190        } 
     191      }
    135192    }
    136     elseif ( strlen($lat)==0 and strlen($lon)==0 )
    137       $update_query = 'lat=NULL, lon=NULL';
    138     else
    139       $page['errors'][] = 'Both lat/lon must be empty or not empty';
    140 
    141               if ( strlen($alt)==0)
    142                      $update_query .= ', alt=NULL';
    143                   else
    144                      $update_query .= ', alt=' .$alt ;
    145 
    146         if (isset($update_query)){
    147       $update_query = '
    148                 UPDATE '.IMAGES_TABLE.' SET '.$update_query.'
    149                 WHERE id IN ('.implode(',',$collection).')';
    150         pwg_query($update_query);
    151                 cl_meta_invalidate_cache();
    152                 $info_message .= l10n('update') . " " . IMAGES_TABLE . " : " .  l10n('OK') ;
    153                 $_POST['submit'] = l10n('Submit') ;
    154      }
    155     }
    156   }
    157193 }
    158194/**************************************/
     195
    159196$specials_selected = null;
    160 foreach( array('caddie'=>'Caddie', 'recent'=>'Recent photos') as $k => $v)
    161 {
    162         $link = $admin_url.get_query_string_diff(array('start','cat')).'&amp;cat='.$k;
    163         $template->append(
    164                 'specials',
    165                 array(
    166                         $link => l10n($v),
    167                         ),
    168                 true
    169                 );
    170         if ($k == $_GET['cat']) $specials_selected = $link;
    171 }
     197foreach( array('caddie'=>'Caddie', 'recent'=>'Recent photos') as $k => $v){
     198    $link = $admin_url.get_query_string_diff(array('start','cat')).'&amp;cat='.$k;
     199    $template->append(
     200        'specials',
     201        array(
     202            $link => l10n($v),
     203            ),
     204        true
     205        );
     206    if ($k == $_GET['cat']) $specials_selected = $link;
     207}
     208
     209
    172210$template->assign('specials_selected', $specials_selected);
    173211/****************************************/
     
    179217$categories = array();
    180218$selecteds = array();
    181 if (!empty($result))
    182 {
    183   while ($row = mysql_fetch_assoc($result))
    184   {
     219if (!empty($result)){
     220  while ($row = mysql_fetch_assoc($result))  {
    185221    $url = $admin_url.get_query_string_diff(array('start','cat')).'&amp;cat='.$row['id'];
    186222    if ( $row['id']==$_GET['cat'] ) $selecteds[] = $url;
     
    192228display_select_categories($categories, $selecteds, 'categories', false);
    193229
    194 if (!empty($_GET['display']))
    195 {
    196   if ('all' == $_GET['display'])
    197     $page['nb_images'] = count($page['cat_elements_id']);
    198   else
    199     $page['nb_images'] = intval($_GET['display']);
    200 }
    201 else
    202   $page['nb_images'] = 20;
    203 
    204 if ( !empty($page['cat_elements_id']) )
    205 {
     230
     231if ( !empty($page['cat_elements_id']) ){
    206232  $nav_bar = create_navigation_bar(
    207233    $admin_url.get_query_string_diff(array('start')),
     
    212238  $template->assign('navbar', $nav_bar);
    213239}
    214 
    215 $images=array();
    216 if ( !empty($page['cat_elements_id']) )
    217 {
    218   $query='
    219 SELECT id,tn_ext,name,path,file,lat,lon,alt FROM '.IMAGES_TABLE.'
    220   WHERE id IN ('.implode(',',$page['cat_elements_id']).')
    221   '.$conf['order_by'].'
    222   LIMIT '.$page['start'].', '.$page['nb_images'].'
    223 ;';
    224   $result = pwg_query($query);
    225   while ( $row=mysql_fetch_assoc($result) )
    226     $images[] = $row;
    227 }
    228 
    229 foreach ($images as $image)
    230 {
    231         $tpl_var = array_merge( $image,
     240//========================================================================
     241  $v_exif="";
     242foreach ($images as $image){ 
     243 
     244    $infos_gps  = array();
     245    $infos_gps  =  cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ;
     246    $v_exif=$infos_gps['is_exif']?true:false ;   
     247    $v_db=false  ;
     248    $v_db=$image['lat']!=0 && $image['lon']!=0;
     249
     250    if(  $infos_gps['lat'] !=0  || $infos_gps['lon'] !=0 ) { 
     251   
     252      $new= ( !isset($image['lat'])? true: $image['lat']!=$infos_gps['lat'] ) ;
     253      $image['lat']=$infos_gps['lat'];
     254      $image['lon']=$infos_gps['lon'];
     255      $image['alt']=$infos_gps['alt'];
     256      $sel_img= array($image['id']);
     257      if ($new) cl_edit_controler::add_data_base( $sel_img,$image['lat'],$image['lon'],$image['alt']) ;             
     258   }         
     259   //=================================================
     260   $tpl_var = array_merge( $image,
    232261      array(
     262        'U_EXIF' => $v_exif,
     263        'U_DB' => $v_db,
    233264        'U_TN' => get_thumbnail_url($image),
    234265        'TITLE' => get_thumbnail_title($image)
    235       )
    236     );
    237   if ( isset($image['lat']) )
    238     $tpl_var['U_MAP'] = cl_make_map_picture_url( array('image_id'=>$image['id'], 'image_file'=>$image['file']) );
    239         $template->append('thumbnails', $tpl_var);
    240 }
     266      ) );
     267
     268  if ( isset($image['lat']) ){
     269    $tpl_var['U_MAP'] = cl_make_map_picture_url(
     270    array('image_id'=>$image['id'],
     271          'image_file'=>$image['file']) );
     272         }
     273           
     274    $template->append('thumbnails', $tpl_var);
     275}
     276
    241277
    242278$template->assign(
    243279    array(
    244280      'U_DISPLAY'=> $admin_url.get_query_string_diff(array('display'))
    245     ) 
     281    )
    246282  );
    247283
    248 //==========================================================
    249         if (!defined('EDIT_CL_PATH')) define(  'EDIT_CL_PATH',  EDIT_CL_PATH .'admin/' );
    250         $path = EDIT_CL_PATH;
    251     $plg_data = implode( '', file($path.'main.inc.php') );
    252          if (preg_match("|Version: (.*)|", $plg_data, $val))
    253           { $EDIT_CL_PATH_plugin['version'] = trim($val[1]);  } 
    254             $EDIT_CL_PATH_plugin = array_map('htmlspecialchars', $EDIT_CL_PATH_plugin);
    255             $version= $EDIT_CL_PATH_plugin['version'] ;
    256             $icon_path = 'themes/default/icon/help.png';
    257             $path_js=  'themes/default/js/' ;
    258284
    259285//==================================================================================
    260 $match="";
    261      
    262 if ( isset($_POST['submit'])   )
    263 {       
    264   if ($_POST['submit']==l10n('Submit') )
    265    {
    266       $_POST['selection']=array(); 
    267       $collection =array();
    268           unset($collection);
    269   }
    270  
    271 
    272  if ($_POST['submit']==l10n('reset' ) )
    273                 {
    274                         $_POST['selection']=array();
    275                         unset($collection);
    276                 }
    277  
    278  }
     286$match="";
     287if ( isset($_POST['submit'])   ) {
     288  if ($_POST['submit']==l10n('Submit') ) {
     289    $_POST['selection']=array();
     290    $collection =array();
     291    unset($collection);
     292  }
     293  if ($_POST['submit']==l10n('reset' ) ) {
     294    $_POST['selection']=array();
     295    unset($collection);
     296  }
     297}
    279298//=================================================================================
    280299$src="";
    281 
    282300$template->assign(
    283     array(      'EDIT_CL_PATH' => EDIT_CL_PATH,
    284                 'path_js' => $path_js,
     301    array(  'EDIT_CL_PATH' => EDIT_CL_PATH,
     302            'path_js' => $path_js,
    285303            'VERSION'=> $version,
    286304            'EDIT_CL_PATH_ABS' => dirname(__FILE__).'/',
    287               )
     305          )
    288306  );
    289   global $lang_info;
    290     if (date_default_timezone_get()) {
    291             $adresse =  date_default_timezone_get()   ;
    292         }else{
    293 
    294         }
    295     $adresse =  $lang_info['country'];   ;
    296     $adresse=str_replace("/",", ",$adresse);
    297     $template->assign( 'coordinates',
    298                                         array(  'FILE' => '',
    299                                 'LAT' => '100',
    300                                                                 'LON' => '100',
    301                                                                 'ADRESSE' => $adresse,
    302                                                                 'ZOOM' => 18,
    303                                 'ALT' => 0
    304                                                         )
    305                                                 );   
    306 
    307 if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' ))
    308 {
    309   if (isset($collection)) { 
    310     $lat =1000;$first_image="";                           
     307 
     308$template->assign( 'coordinates',
     309                    array(  'FILE' => '',
     310                            'LAT' => '100',
     311                            'LON' => '100',
     312                            'ADRESSE' => $adresse,
     313                            'ZOOM' => 18,
     314                            'ALT' => 0
     315                        )
     316                    );
     317//======================================================================
     318if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' )){
     319  if (isset($collection)) {
     320    $init_info =true;
     321    $first_image="";
     322    $_POST['selection'] = $collection ;
    311323    foreach ($collection as $id_0)  {
    312                 foreach ($images as $image) {
    313                         if (array_search($id_0,$image)) {
    314             $_POST['selection'] = $collection ;   
    315             $infos_gps=  Get_exif_gps( $image['path'],$image) ;   
    316             $image['lat']=$infos_gps['lat'];
    317             $image['lon']=$infos_gps['lon'];
    318             $image['alt']=$infos_gps['alt'];
    319             if ($lat==1000) {
    320                                 $lat= ($image['lat'] <> '') ? $image['lat'] : '100'  ;
    321                                       $lon= ($image['lon']  <> '') ? $image['lon'] : '3.0'  ;
    322               $alt= ($image['alt']  <> '') ? $image['alt'] : '0'  ;
    323                                       if($lat != '100') $lat=$image['lat'];
    324                                       //=====================================================
    325                                       $template->assign( 'coordinates',
    326                                              array('FILE' => $image['path'],
    327                      'LAT' =>   $lat  ,
    328                                                                                  'LON' =>   $lon  ,
    329                                                                                  'ADRESSE' =>  $adresse ,
    330                                                                                  'ZOOM' => 4,
    331                      'ALT' =>   $alt ,
    332                                                                                 )
    333                                                                         );
    334                                 }
    335                                                
     324        foreach ($images as $image) {
     325            if (array_search($id_0,$image)) {   
     326              $infos_gps  = array();   
     327              if($image['lat']=='' || $image['lon']==''){    }
     328              $infos_gps  =array();
     329              $infos_gps  =  cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ;
     330              if(isset($infos_gps['lat']) && $infos_gps['is_exif']){       
     331                $image['lat']=$infos_gps['lat'];
     332                $image['lon']=$infos_gps['lon'];
     333                $image['alt']=$infos_gps['alt'];
     334              }                   
     335              if ( $init_info && $image['lat'] <> '' ) {
     336                $init_info = false ;
     337                $lat = ($image['lat'] <> '') ? $image['lat'] : '100'  ;
     338                $lon = ($image['lon']  <> '') ? $image['lon'] : '3.0'  ;
     339                $alt = ($image['alt']  <> '') ? $image['alt'] : '0'  ;
     340                     
     341                //=====================================================
     342                $template->assign( 'coordinates',
     343                        array(
     344                            'FILE' => $image['path'],
     345                            'LAT' =>   $lat  ,
     346                            'LON' =>   $lon  ,
     347                            'ADRESSE' =>  $adresse ,
     348                            'ZOOM' => 4,
     349                            'ALT' =>  $alt ,
     350                              )
     351                          );                             
     352              }
     353              //=====================================================
    336354                    $lon=$image['lon'];
    337                     $lat=$image['lat'];   
    338                     if($infos_gps['is_exif'])   $info_message .='EXIF';   
    339 
    340                 $lonDMS= dec2dms($lon) ;
    341                 $latDMS= dec2dms($lat) ;
    342 
    343 
    344                             $tpl_var = array_merge(
    345                                     $image,
    346                                         array(
     355                    $lat=$image['lat'];
     356                    if($infos_gps['is_exif']) {                                       
     357                     $info_message .='EXIF';
     358                    }
     359                    $lonDMS= dec2dms($lon) ;
     360                    $latDMS= dec2dms($lat) ;
     361
     362                        $v_db=false  ;
     363    $v_db=$lon!=0 && $lat!=0;
     364
     365                $tpl_var = array_merge(
     366                        $image,
     367                        array(
    347368                  'filename' =>  $image['path'],
    348                   'exif' => $infos_gps['is_exif'] ,
     369                  'exif' => '"'.$infos_gps['is_exif'].'"' ,
    349370                  'lat'  =>    $image['lat']    ,
    350371                  'lon' =>     $image['lon']    ,
    351                   'alt' =>     $image['alt']    , 
     372                  'alt' =>     $image['alt']    ,
    352373                  'latDMS' =>    $latDMS[3]     ,
    353                   'lonDMS' =>   "-->".$lonDMS[3]     ,
     374                  'lonDMS' =>   $lonDMS[3]     ,
    354375                  'adresse' =>  $adresse   ,
    355376                  'U_TN' => get_thumbnail_url($image),
    356377                  'TITLE' => get_thumbnail_title($image),
    357                                                             'U_MAP' => cl_make_map_picture_url(
    358                                                                                             array(
    359                                                                                                  'image_id'=>$image['id'],
    360                                                                                                  'image_file'=>$image['file'],
    361                                                                                                  )
    362                                                                                     ),
    363                                                                   )                                                             
    364                                                 );       
    365                                 $template->append('Selectthumbnails', $tpl_var);                       
    366                         }
    367                 }       
    368         }
    369   }
    370 
    371 }
    372 
    373 
    374  if ( !empty($first_image))
    375  { $error_message .= cl_edit_controler::Memo_Vars($first_image);
    376  if (isset($_POST['update'])) {
    377 // document.Envoie.latDMS.value
    378         $image= first_image ;
    379         $filename=$image['path'] ;
    380         $Val_exif="";
    381         $Val_XMP="";           
    382    /*  */   
    383      if (!empty($infos_gps))
    384      $Position = $infos_gps ;
    385      else  $Position =  Get_exif_gps($filename,$image) ;
    386 
    387   $jpeg_header_data = get_jpeg_header_data($filename );
    388      $template->assign( array(
    389       'filename_abs' =>   $filename ,
    390       'filename' => $filename,
    391      'datas'    =>    array(
    392 /*       'Val_JPEG_APP'=> Generate_JPEG_APP_Segment_HTML( $jpeg_header_data ),
     378                  'U_EXIF' =>  $infos_gps['is_exif'] ,
     379                  'U_BD' =>  $v_db ,
     380                  'U_MAP' => cl_make_map_picture_url(
     381                                                array(
     382                                                      'image_id'=>$image['id'],
     383                                                      'image_file'=>$image['file'],
     384                                                      )
     385                                                    ),
     386                                  )
     387                            );
     388          $template->append('Selectthumbnails', $tpl_var);
     389        }
     390      }
     391    }
     392  }
     393}
     394
     395//============================================================
     396 if ( !empty($first_image)) {
     397   $erreur_message .= cl_edit_functions::Memo_Vars($first_image);
     398   
     399   if (isset($_POST['update'])) {
     400          // document.Envoie.latDMS.value
     401          $image= first_image ;
     402          $filename=$image['path'] ;
     403          $Val_exif="";
     404          $Val_XMP="";
     405   /*  */
     406     if (!empty($infos_gps))
     407         $Position = $infos_gps ;
     408     else  $Position =  cl_edit_controler::Get_exif_gps($filename,$image,false) ;
     409
     410      $jpeg_header_data = get_jpeg_header_data($filename );
     411      $template->assign( array(
     412      'filename_abs' =>   $filename ,
     413      'filename' => $filename,
     414      'datas'    =>    array(
     415/*       
     416        'Val_JPEG_APP'=> Generate_JPEG_APP_Segment_HTML( $jpeg_header_data ),
    393417        'Val_intrinsic'=> Interpret_intrinsic_values_to_HTML( get_jpeg_intrinsic_values( $jpeg_header_data ) ),
    394         'Val_Comment'=> Interpret_Comment_to_HTML( $jpeg_header_data ), 
     418        'Val_Comment'=> Interpret_Comment_to_HTML( $jpeg_header_data ),
    395419        'Val_JFIF'=> Interpret_JFIF_to_HTML( get_JFIF( $jpeg_header_data ), $filename ),
    396         'Val_JFXX'=>Interpret_JFXX_to_HTML( get_JFXX( $jpeg_header_data ), $filename ), 
    397         'Val_App12' => Interpret_App12_Pic_Info_to_HTML( $jpeg_header_data ),         
    398         'Val_IRB' => Interpret_IRB_to_HTML( get_Photoshop_IRB( $jpeg_header_data ), $filename ), 
     420        'Val_JFXX'=>Interpret_JFXX_to_HTML( get_JFXX( $jpeg_header_data ), $filename ),
     421        'Val_App12' => Interpret_App12_Pic_Info_to_HTML( $jpeg_header_data ),
     422        'Val_IRB' => Interpret_IRB_to_HTML( get_Photoshop_IRB( $jpeg_header_data ), $filename ),
    399423
    400424        'Val_exif'=>  Interpret_EXIF_to_HTML( get_EXIF_JPEG( $filename ), $filename),
    401425        'Val_XMP' =>  Interpret_XMP_to_HTML( read_XMP_array_from_text( get_XMP_text( $jpeg_header_data) ) ),
    402426          */
    403      // 
     427     //
    404428         ),
    405  'Datadase' =>  ($Position) ,
     429          'Datadase' =>  ($Position) ,
    406430          ) );
    407        
    408 
    409           }
     431  }
    410432}
    411433
     
    414436function cl_make_map_picture_url($params)
    415437{
    416         global $conf;
    417         /*if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' )
    418                 return "";*/
    419         $map_url = make_picture_url($params);
    420         return add_url_params($map_url, array('map'=>null) );
     438    global $conf;
     439    /*if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' )
     440        return "";*/
     441    $map_url = make_picture_url($params);
     442    return add_url_params($map_url, array('map'=>null) );
    421443}
    422444$v1=0;
     
    424446
    425447
    426 function Get_exif_gps($firt_image,$image)
    427 {
    428 
    429  error_reporting ( 1 );
    430  $filename=$firt_image;
    431  
    432   $datas = array();
    433   $errors = array();
    434  
    435 
    436   $exif = @read_exif_data( $filename ); 
    437 global $errors;global $template ;
    438 
    439       if ( empty($exif) ) return;
    440          $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) );
    441 
    442 //====================================================================
    443     $lat = $image['lat'] ;         
    444     $lon = $image['lon'] ;
    445     $alt = $image['alt'];
    446     global $info_message ;
    447 
    448 $is_exif = "'".(is_array($exif['GPSLatitude']) and is_array($exif['GPSLongitude']) )."'" ;
    449  if ($is_exif) {
    450      $lat_exif = parse_lat_lon( $exif['GPSLatitude'] );         
    451      $lon_exif = parse_lat_lon( $exif['GPSLongitude'] );
    452      $alt_exif = Parse_Fract( $exif['GPSAltitude'] ); 
    453  }
    454 
    455 if ($lat =="")
    456 {   
    457   $lat = Parse_Lat_Lon( $exif['GPSLatitude'] ); 
    458   if ( $exif['GPSLatitudeRef']=='S' ) $lat = -$lat;
    459  
    460 }else{
    461     $is_exif="false" ;
    462     if($lat<0)      $exif['GPSLatitudeRef']='S' ;
    463         else        $exif['GPSLatitudeRef']='N' ;
    464        
    465      
    466 }   
    467 if ($lon =="") {
    468        
    469                 $lon = parse_lat_lon( $exif['GPSLongitude'] );
    470                 if ( $exif['GPSLongitudeRef']=='W' ) $lon = -$lon;
    471            }else{
    472              if ($lon<0) $exif['GPSLongitudeRef'] ='W' ;
    473              else $exif['GPSLongitudeRef'] ='E' ;
    474                  
    475            }
    476 
    477    
    478  
    479 //=======================================================================         
    480            $altref = 0;
    481 
    482 if (!is_array($exif['GPSAltitude']) or !is_array($exif['GPSAltitudeRef']) )
    483                 {
    484                          $exif['GPSAltitude']=$alt;
    485              $exif['GPSAltitudeRef']=0;
    486                 }       else {
    487                 $alt =           $exif['GPSAltitude'];
    488             $altref = $exif['GPSAltitudeRef'];
    489         }
    490  //========================================================================     
    491                 $datas[] = array (
    492             'is_exif' => $is_exif,
    493             ' filename=' => $filename ,
    494                         'id' =>    $image['id'] ,
    495                         'lat' =>   $lat ,
    496                         'lon' =>   $lon ,
    497                         'latDMS' =>     $exif['GPSLatitude'][0]['Numerator']  . "/" .
    498                             $exif['GPSLatitude'][0]['Denominator'] . " " .   
    499                             $exif['GPSLatitude'][1]['Numerator'] . "/" .
    500                             $exif['GPSLatitude'][1]['Denominator']. " " .   
    501                             $exif['GPSLatitude'][2]['Numerator'] . "/" .
    502                             $exif['GPSLatitude'][2]['Denominator'],
    503                         'lonDMS' =>     $exif['GPSLongitude'][0]['Numerator']  . "/" .
    504                             $exif['GPSLongitude'][0]['Denominator'] . " " .   
    505                             $exif['GPSLongitude'][1]['Numerator'] . "/" .
    506                             $exif['GPSLongitude'][1]['Denominator']. " " .   
    507                             $exif['GPSLongitude'][2]['Numerator'] . "/" .
    508                             $exif['GPSLongitude'][2]['Denominator'],
    509             'altref' => $exif['GPSAltitudeRef'],
    510             'alt' =>   $exif['GPSAltitude'] ,
    511 
    512                         ); 
    513 
    514 return $datas[0] ;
    515 }
     448
    516449if ($info_message!="")
    517450$template->assign('infos',$info_message);
    518 if ($error_message!="")
    519 $template->assign('errors',$error_message);
     451if ($erreur_message!="")
     452$template->assign('errors',$erreur_message);
     453
     454
    520455?>
Note: See TracChangeset for help on using the changeset viewer.