concat('TABSHEET_TITLE', ' '.l10n_dec('%d image', '%d images', count($page['cat_elements_id'])).' - '.$page['title']); if ( isset($_POST['submit']) ) { $collection = array(); if( !isset ($_POST['target'])) { $_POST['submit'] == l10n('Submit') ; $_POST['target']='selection'; $collection = $_POST['selection']; } switch ($_POST['target']) { case 'all' : $collection = $page['cat_elements_id']; break; case 'selection' : if (!isset($_POST['selection']) or count($_POST['selection']) == 0) array_push($page['errors'], l10n('Select at least one picture')); else $collection = $_POST['selection']; break; } //**************** mise a jour de la base de données ************************** if ( $_POST['submit'] == l10n('update_database') ) { if ( count($collection)>0 ) { $lat = trim($_POST['lat']); $lon = trim($_POST['lon']); $alt = trim($_POST['alt']); if ( strlen($lat)>0 and strlen($lon)>0 ) { if ( (double)$lat<=90 and (double)$lat>=-90 and (double)$lon<=180 and (double)$lat>=-180 ) $update_query = 'lat='.$lat.', lon='.$lon; else $page['errors'][] = 'Invalid lat or lon value'; }else if ( strlen($lat)==0 and strlen($lon)==0 ) $update_query = 'lat=NULL, lon=NULL'; else $page['errors'][] = 'Both lat/lon must be empty or not empty'; if ( strlen($alt)==0) $update_query .= ', alt=NULL'; else $update_query .= ', alt=' .$alt ; if (isset($update_query)) { $update_query = ' UPDATE '.IMAGES_TABLE.' SET '.$update_query.' WHERE id IN ('.implode(',',$collection).')'; pwg_query($update_query); cl_meta_invalidate_cache(); } } }// fin test update } // fin post $template->append( 'specials', array( $admin_url.get_query_string_diff(array('start','cat')).'&cat=caddie' => l10n('Caddie') ), true ); $query = ' SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' ;'; $result = pwg_query($query); $categories = array(); $selecteds = array(); if (!empty($result)) { while ($row = mysql_fetch_assoc($result)) { $url = $admin_url.get_query_string_diff(array('start','cat')).'&cat='.$row['id']; if ( $row['id']==$_GET['cat'] ) $selecteds[] = $url; $row['id']=$url; array_push($categories, $row); } } usort($categories, 'global_rank_compare'); display_select_categories($categories, $selecteds, 'categories', false); if (!empty($_GET['display'])) { if ('all' == $_GET['display']) $page['nb_images'] = count($page['cat_elements_id']); else $page['nb_images'] = intval($_GET['display']); } else $page['nb_images'] = 20; if ( !empty($page['cat_elements_id']) ) { $nav_bar = create_navigation_bar( $admin_url.get_query_string_diff(array('start')), count($page['cat_elements_id']), $page['start'], $page['nb_images'] ); $template->assign('navbar', $nav_bar); } $images=array(); if ( !empty($page['cat_elements_id']) ) { $query=' SELECT id,tn_ext,name,path,file,lat,lon,alt FROM '.IMAGES_TABLE.' WHERE id IN ('.implode(',',$page['cat_elements_id']).') '.$conf['order_by'].' LIMIT '.$page['start'].', '.$page['nb_images'].' ;'; $result = pwg_query($query); while ( $row=mysql_fetch_assoc($result) ) $images[] = $row; } foreach ($images as $image) { $tpl_var = array_merge( $image, array( 'U_TN' => get_thumbnail_url($image), 'TITLE' => get_thumbnail_title($image) ) ); if ( isset($image['lat']) ) $tpl_var['U_MAP'] = cl_make_map_picture_url( array('image_id'=>$image['id'], 'image_file'=>$image['file']) ); $template->append('thumbnails', $tpl_var); } $template->assign( array( 'U_DISPLAY'=> $admin_url.get_query_string_diff(array('display')) ) ); //========================================================== if (!defined('EDIT_CL_PATH')) define( 'EDIT_CL_PATH', EDIT_CL_PATH .'admin/' ); $path = EDIT_CL_PATH; $plg_data = implode( '', file($path.'main.inc.php') ); if (preg_match("|Version: (.*)|", $plg_data, $val)) { $EDIT_CL_PATH_plugin['version'] = trim($val[1]); } $EDIT_CL_PATH_plugin = array_map('htmlspecialchars', $EDIT_CL_PATH_plugin); $version= $EDIT_CL_PATH_plugin['version'] ; $icon_path = 'themes/default/icon/help.png'; $path_js= 'themes/default/js/' ; //================================================================================== $match=""; if ( isset($_POST['submit']) ) { if ($_POST['submit']==l10n('update') ) { $_POST['selection']=array(); $collection =array(); unset($collection); } if ($_POST['submit']==l10n('Submit') ) { $_POST['selection']=array(); $collection =array(); unset($collection); } if ($_POST['submit']==l10n('reset' ) ) { $_POST['selection']=array(); unset($collection); } } //================================================================================= $src=""; $template->assign( array( 'EDIT_CL_PATH' => EDIT_CL_PATH, 'path_js' => $path_js, 'VERSION'=> $version, 'EDIT_CL_PATH_ABS' => dirname(__FILE__).'/', ) ); global $lang_info; if (date_default_timezone_get()) { $adresse = date_default_timezone_get() ;} else{ } $adresse = $lang_info['country']; ; $adresse=str_replace("/",", ",$adresse); $template->assign( 'coordinates', array('LAT' => '100', 'LON' => '100', 'ADRESSE' => $adresse, 'ZOOM' => 18, 'ALT' => 0 ) ); $filename =""; if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' )) { if (isset($collection)) { $lat =1000; foreach ($collection as $id_0) { foreach ($images as $image) { if (array_search($id_0,$image)) { $_POST['selection'] = $collection ; $infos_gps= Get_exif_gps( $image['path'],$image) ; if( $image['lat'] == ''){ $image['lat']=$infos_gps['lat']; $image['lon']=$infos_gps['lon']; $image['alt']=$infos_gps['alt']; }else { $image['lat']=$infos_gps['lat']; $image['lon']=$infos_gps['lon']; $image['alt']=$infos_gps['alt']; } $filename= $image; if ($lat==1000) { $lat= ($image['lat'] <> '') ? $image['lat'] : '100' ; $lon= ($image['lon'] <> '') ? $image['lon'] : '3.0' ; $alt= ($image['alt'] <> '') ? $image['alt'] : '0' ; if($lat != '100') $lat=$image['lat']; //===================================================== $template->assign( 'coordinates', array('LAT' => $lat , 'LON' => $lon , 'ADRESSE' => $adresse , 'ZOOM' => 4, 'ALT' => $alt , ) ); } $lonDMS= dec2dms($lon) ; $latDMS= dec2dms($lat) ; if ($infos_gps['lat']=="") $icon='icon/minus.png'; else $icon='icon/minus.png'; $tpl_var = array_merge( $image, array( 'icon' => $icon , 'lat' => $image['lat'] , 'lon' => $image['lon'] , 'alt' => $image['alt'] , 'latDMS' => $latDMS[3] , 'lonDMS' => $lonDMS[3] , 'adresse' => $adresse , 'U_TN' => get_thumbnail_url($image), 'TITLE' => get_thumbnail_title($image), 'U_MAP' => cl_make_map_picture_url( array( 'image_id'=>$image['id'], 'image_file'=>$image['file'], ) ), ) ); $template->append('Selectthumbnails', $tpl_var); } } } } } if ( !empty($filename)) { // document.Envoie.latDMS.value $image= $filename ; $filename= $filename['path'] ; $Val_exif=""; $Val_XMP=""; // error_reporting ( 0 ); // Hide any unknown EXIF tags /* $GLOBALS['HIDE_UNKNOWN_TAGS'] = FALSE; include $Toolkit_Dir . 'Toolkit_Version.php'; // Change: added as of version 1.11 include $Toolkit_Dir . 'JPEG.php'; // Change: Allow this example file to be easily relocatable - as of version 1.11 include $Toolkit_Dir . 'JFIF.php'; include $Toolkit_Dir . 'PictureInfo.php'; include $Toolkit_Dir . 'XMP.php'; include $Toolkit_Dir . 'Photoshop_IRB.php'; include $Toolkit_Dir . 'EXIF.php'; $jpeg_header_data = get_jpeg_header_data($filename ); */ if (!empty($infos_gps)) $Position = $infos_gps ; else $Position = Get_exif_gps($filename,$image) ; $template->assign( array( 'filename_abs' => $filename , 'filename' => $filename, 'datas' => array( /* 'Val_JPEG_APP'=> Generate_JPEG_APP_Segment_HTML( $jpeg_header_data ), 'Val_intrinsic'=> Interpret_intrinsic_values_to_HTML( get_jpeg_intrinsic_values( $jpeg_header_data ) ), 'Val_Comment'=> Interpret_Comment_to_HTML( $jpeg_header_data ), 'Val_JFIF'=> Interpret_JFIF_to_HTML( get_JFIF( $jpeg_header_data ), $filename ), 'Val_JFXX'=>Interpret_JFXX_to_HTML( get_JFXX( $jpeg_header_data ), $filename ), 'Val_App12' => Interpret_App12_Pic_Info_to_HTML( $jpeg_header_data ), 'Val_IRB' => Interpret_IRB_to_HTML( get_Photoshop_IRB( $jpeg_header_data ), $filename ), 'Val_exif'=> Interpret_EXIF_to_HTML( get_EXIF_JPEG( $filename ), $filename), 'Val_XMP' => Interpret_XMP_to_HTML( read_XMP_array_from_text( get_XMP_text( $jpeg_header_data) ) ), */ // ), 'Datadase' => ($Position) , ) ); } function Memo_vars($variables) { ob_start(); echo '
';
		print_r($variables);
		echo '
'; $m= ob_get_contents(); ob_end_clean(); return $m; } //======================================================================= function cl_make_map_picture_url($params) { global $conf; /*if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' ) return "";*/ $map_url = make_picture_url($params); return add_url_params($map_url, array('map'=>null) ); } $v1=0; function Get_exif_gps($filename,$image) { error_reporting ( 1 ); $datas = array(); $errors = array(); // // $Exif_array = get_EXIF_JPEG( $filename ); // if ( empty($Exif_array) ) return; $exif = @read_exif_data( $filename ); if ( empty($exif) ) return; $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) ); error_reporting ( 1 ); /* if ( count($exif)<4) return; if ( !in_array($exif['GPSLatitudeRef'], array('S', 'N') ) ) { $errors[] = $filename. ': GPSLatitudeRef not S or N'; return; } if ( !in_array($exif['GPSLongitudeRef'], array('W', 'E') ) ) { $errors[] = $filename. ': GPSLongitudeRef not W or E'; return; } if (!is_array($exif['GPSLatitude']) or !is_array($exif['GPSLongitude']) ) { $errors[] = $filename. ': GPSLatitude and GPSLongitude are not arrays'; return; } */ $lat = $image['lat'] ; $lon = $image['lon'] ; $alt=$image['alt']; if ($lat =="") { $lat = Parse_Lat_Lon( $exif['GPSLatitude'] ); if ( $exif['GPSLatitudeRef']=='S' )$lat = -$lat; $latDMS=$exif['GPSLatitude'][0] . " | " . $exif['GPSLatitude'][1]. " | " . $exif['GPSLatitude'][2] ; }else{ if($lat<0) $exif['GPSLatitudeRef']='S' ; else $exif['GPSLatitudeRef']='N' ; $latDMS=dec2dms($lat); $exif['GPSLatitude']= $latDMS ; } global $errors; if (!is_array($exif['GPSLatitude']) or !is_array($exif['GPSLongitude']) ) { $errors[] = $filename. ': GPSLatitude and GPSLongitude are not arrays'; //return; } if ($lon =="") { $lon = parse_lat_lon( $exif['GPSLongitude'] ); $lonDMS= $exif['GPSLongitude'][0] . " | " . $exif['GPSLongitude'][1] . " | " . $exif['GPSLongitude'][2] ; if ( $exif['GPSLongitudeRef']=='W' ) $lon = -$lon; }else{ if ($lon<0) $exif['GPSLongitudeRef'] ='W' ; else $exif['GPSLongitudeRef'] ='E' ; $lonDMS=dec2dms($lon); $exif['GPSLongitude']=$lonDMS ; } //======================================================================= $altref = 0; if (!is_array($exif['GPSAltitude']) or !is_array($exif['GPSAltitudeRef']) ) { $exif['GPSAltitude']=$alt; $exif['GPSAltitudeRef']=0; } else { $alt = $exif['GPSAltitude']; $altref = $exif['GPSAltitudeRef']; } //======================================================================== $datas[] = array ( ' filename=' => $filename , 'id' => $image['id'] , 'lat' => $lat , 'lon' => $lon , 'latDMS' => $exif['GPSLatitude'][0]['Numerator'] . "/" . $exif['GPSLatitude'][0]['Denominator'] . " " . $exif['GPSLatitude'][1]['Numerator'] . "/" . $exif['GPSLatitude'][1]['Denominator']. " " . $exif['GPSLatitude'][2]['Numerator'] . "/" . $exif['GPSLatitude'][2]['Denominator'], 'lonDMS' => $exif['GPSLongitude'][0]['Numerator'] . "/" . $exif['GPSLongitude'][0]['Denominator'] . " " . $exif['GPSLongitude'][1]['Numerator'] . "/" . $exif['GPSLongitude'][1]['Denominator']. " " . $exif['GPSLongitude'][2]['Numerator'] . "/" . $exif['GPSLongitude'][2]['Denominator'], 'altref' => $exif['GPSAltitudeRef'], 'alt' => $exif['GPSAltitude'] , ); return $datas[0] ; } ?>