\n"; }else{ if($filename!="") { //= $new_ps_file_info_array[ 'filename' ]; // Protect against hackers editing other files // copy( $filename, $filename.".bak" ); $path_parts = pathinfo( $filename ); if ( strcasecmp( $path_parts["extension"], "jpg" ) != 0 ) { $erreur_message .= $filename ; $erreur_message .="Incorrect File Type - JPEG Only\n"; $filename=""; return; } // Change: removed limitation on file being in current directory - as of version 1.11 // Retrieve the header information $nom_fichier=$filename; $jpeg_header_data = get_jpeg_header_data( $filename ); // Retreive the EXIF, XMP and Photoshop IRB information from // the existing file, so that it can be updated $Exif_array = get_EXIF_JPEG( $filename ); $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); $IRB_array = get_Photoshop_IRB( $jpeg_header_data ); // Update the JPEG header information with the new Photoshop File Info $jpeg_header_data = put_GPS_file_info( $jpeg_header_data, $new_ps_file_info_array, $Exif_array, $XMP_array, $IRB_array ); // Check if the Update worked if ( $jpeg_header_data == FALSE ) { // Update of file info didn''t work - output error message $erreur_message .= "jpeg_header_data Error - Failure update Photoshop File Info : $filename
\n"; return false; // Output HTML with the form and data which was // sent, to allow the user to fix it }else if ( FALSE == put_jpeg_header_data( $filename, $filename, $jpeg_header_data ) ) { // Attempt to write the new JPEG file // Writing of the new file didn''t work - output error message $erreur_message .= "Error - Failure to write new JPEG : $filename
\n"; return false; // Output HTML with the form and data which was // sent, to allow the user to fix it }else{ return true; } }// test filename} } //for each } } //========================================================== static public function Get_exif_gps($firt_image,$image,$hight_gps,$lecture_exif) { global $errors;global $template ; global $info_message ; error_reporting ( 1 ); $filename=$firt_image; $datas = array(); $errors = array(); $exif = @read_exif_data( $filename ); if ( empty($exif) ) return; $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) ); if(count($exif)==0 || $hight_gps ){ $path_parts = pathinfo( $filename ); $exif = @read_exif_data( $path_parts['dirname']."/pwg_high/".$path_parts['basename']); $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) ); } if(count($exif)==0) return ; //==================================================================== if(!$lecture_exif){ $lat = $image['lat'] ; $lon = $image['lon'] ; $alt = $image['alt']; } $p1=base_to_meta($image); if($exif['GPSLatitude'][0]=="1/1" && $lat!=""){ $exif['GPSLatitudeRef'] = $p1['GPSLatitudeRef'] ; $exif['GPSLatitude']=$p1['GPSLatitude']; $exif['GPSLongitudeRef'] = $p1['GPSLongitudeRef']; $exif['GPSLongitude']=$p1['GPSLongitude']; $exif['GPSAltitudeRef'] =$p1['GPSAltitudeRef']; $exif['GPSAltitude']= $p1['GPSAltitude']; } $is_exif = is_array($exif['GPSLatitude']) && $exif['GPSLatitude']!='' ; $is_exif = is_array($exif['GPSLongitude']) && $exif['GPSLongitude']!='' & $is_exif ; if ($is_exif) { $lat_exif = Parse_Lat_Lon( $exif['GPSLatitude'] ); $lon_exif = Parse_Lat_Lon( $exif['GPSLongitude'] ); $alt_exif = Parse_Fract( $exif['GPSAltitude'] ); } $is_exif = $lat_exif!=0; //============================== if ($lat =="" || $hight_gps){ $lat = Parse_Lat_Lon( $exif['GPSLatitude'] ); if ( $exif['GPSLatitudeRef']=='S' ) $lat = -$lat; }else{ if($lat<0) $exif['GPSLatitudeRef']='S' ; else $exif['GPSLatitudeRef']='N' ; } //============================== if ($lon =="" || $hight_gps) { $lon = Parse_Lat_Lon( $exif['GPSLongitude'] ); if ( $exif['GPSLongitudeRef']=='W' ) $lon = -$lon; }else{ if ($lon<0) $exif['GPSLongitudeRef'] ='W' ; else $exif['GPSLongitudeRef'] ='E' ; } //======================================================================= $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 ( 'is_exif' => $is_exif , ' filename=' => $filename , 'id' => $image['id'] , 'lat' => $lat , 'lon' => $lon , 'latDMS' => $exif['GPSLatitude'][0]." ". $exif['GPSLatitude'][1]." ". $exif['GPSLatitude'][2]." ". $exif['GPSLatitudeRef'], 'lonDMS' => $exif['GPSLongitude'][0]." ". $exif['GPSLongitude'][1]." ". $exif['GPSLongitude'][2]." ". $exif['GPSLongitudeRef'], 'altref' => $exif['GPSAltitudeRef'], 'alt' => $exif['GPSAltitude'] ); return $datas[0] ; } /************************************************ * add_data_base ************************************************/ static public function add_data_base($sel,$lat,$lon,$alt){ global $page,$info_message,$erreur_message ; 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 $erreur_message .= 'Invalid lat or lon value'; } elseif ( strlen($lat)==0 and strlen($lon)==0 ) $update_query = 'lat=NULL, lon=NULL'; else $erreur_message .= '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(',',$sel).')'; pwg_query($update_query) ; cl_meta_invalidate_cache(); $info_message .= l10n('update') . "[DB] " . implode(',',$sel) . " ". IMAGES_TABLE . " : " . l10n('OK') ."
"; } } //====================================================== static public function cl_edit_admin_menu($menu) { include_once( dirname(__FILE__) .'/include/functions.php'); add_event_handler('invalidate_user_cache', 'cl_meta_invalidate_cache' ); array_push($menu, array( 'NAME' => 'EDIT Maps & Earth', 'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/admin.php') ) ); return $menu; } /**************************** * *****************************/ static public function cl_edit_Get_Options(){ global $conf,$EDIT_CL_parametres,$infos_message ; if (!isset($conf['edit_gmaps'])){ $q = ' INSERT INTO '.CONFIG_TABLE.' (param, value, comment) VALUES ("edit_gmaps","","Parametres du plugin edit_gmaps") ;'; pwg_query($q); } $EDIT_CL_parametres = unserialize($conf['edit_gmaps']); if (!isset($EDIT_CL_parametres->lat )){ $EDIT_CL_parametres= cl_edit_controler::cl_edit_Set_Options(); } return $EDIT_CL_parametres; } /* * */ static public function cl_edit_Set_Options(){ global $EDIT_CL_parametres; //============================================================================= $my_para=$EDIT_CL_parametres; $lon= isset($my_para->lon)? $my_para->lon:'' ; $lat= isset($my_para->lat)? $my_para->lat:'' ; $alt= isset($my_para->alt)? $my_para->alt:'0' ; $my_para->lon = (isset($_POST['lon']))? $_POST['lon']: $lon ; $my_para->lat = (isset($_POST['lat']))? $_POST['lat']: $lat ; $my_para->alt = (isset($_POST['alt']))? $_POST['alt']: $alt ; $my_para->adress = (isset($_POST['match']))? $_POST['match']: '' ; //=============================================================================== if ( isset($_POST['selectAction'] ) && $_POST['selectAction'] == l10n('cl_edit_save') ) { $my_para->check_exif = isset($_POST['check_exif']) ? $_POST['check_exif'] : "off" ; }else{ $my_para->check_exif = isset($_POST['check_exif']) ? $_POST['check_exif'] : ( ( isset($my_para->check_exif) ) ? $my_para->check_exif : 'off') ; } $EDIT_CL_parametres=$my_para; return $my_para; } /********************** * **********************/ static public function cl_edit_sauve_options_inf() { global $options,$infos_message,$conf,$EDIT_CL_parametres ; // $infos_message .=l10n("cl_edit_save_config")."
". cl_print_var($EDIT_CL_parametres); // cl_aff_infos_plus(); if ( isset($EDIT_CL_parametres) ){ $query = ' UPDATE '.CONFIG_TABLE.' SET value="'.addslashes(serialize($EDIT_CL_parametres)).'" WHERE param = "edit_gmaps" LIMIT 1'; pwg_query($query); } } } // class /************************* * *************************/ if(!function_exists("cl_print_var")){ function cl_print_var($variables){ ob_start(); echo '
';
    print_r($variables);
    echo '
'; $m= ob_get_contents(); ob_end_clean(); return $m; } } /****************** * ******************/ if(!function_exists("cl_aff_infos_plus")){ function cl_aff_infos_plus() { global $template,$infos_message,$error_message,$warnings_message, $user ; global $conf,$lang,$page ; //============================================================== if (isset($error_message)) { if ($error_message <> ""){ $error_message=str_replace("\n",'
',$error_message) ; $template->assign('errors',$error_message); $error_message=""; } } //============================================================== if (isset($warnings_message)) { if ($warnings_message <> ""){ $warnings_message=str_replace("\n",'
',$warnings_message) ; $template->assign('warnings',$warnings_message); $warnings_message=""; } } //============================================= if (isset($infos_message)){ if ($infos_message <> ""){ $infos_message=str_replace("\n",'
',$infos_message) ; $template->assign('infos',$infos_message); $infos_message=""; } } //============================================================= return; } // function cl_autosize_aff_infos_plus //=============================================================== } ?>