'; print_r($variables); echo ''; $m= ob_get_contents(); ob_end_clean(); return $m; } /** * list all columns of each given table * * @return array of array */ static public function Get_columns_of($table){ $columns_of = array(); $query = 'DESC '.$table.';'; $result = mysql_query($query); $columns_of[$table] = array(); if ($result) while ($row = mysql_fetch_row($result)) array_push($columns_of[$table], $row[0]); return $columns_of; } } class cl_edit_controler { static public function add_meta_gps($new_ps_file_info_array,$image){ global $nom_fichier,$erreur_message, $info_message; // $exif = @read_exif_data( $exif ); // $exif = @array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) ); foreach( $new_ps_file_info_array['selection'] as $filename ) { //====================================================== if($new_ps_file_info_array['lat']=='') { $erreur_message .= "Error - lon or lat = null : $filename
\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) { 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 ; //==================================================================== $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] ; } //====================================================== /* * */ 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') . " " . 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; } /* * */ function cl_edit_Get_Options() { global $conf,$EDIT_CL_parametres; $EDIT_CL_parametres = unserialize($conf['cl_edit']); $EDIT_CL_parametres = cl_edit_Set_Options(); return $EDIT_CL_parametres; } /* * */ function cl_edit_Set_Options() { global $EDIT_CL_parametres; //============================================================================= $my_para=$EDIT_CL_parametres; $my_para->type=(isset($_POST['type']))? $_POST['type']: ((isset($my_para->type)) ? $my_para->type: 'Ty') ; //=============================================================================== if ( isset($_POST['selectAction'] ) && $_POST['selectAction'] == l10n('cl_edit_save') ) { $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : "off" ; }else{ $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : ( ( isset($my_para->check_desc_v) ) ? $my_para->check_desc_v : 'off') ; } return $my_para; } /* * */ function cl_edit_sauve_options_inf() { global $options,$infos_message,$conf,$EDIT_CL_parametres ; $infos_message .=l10n("cl_edit_save_config")."
"; $EDIT_CL_parametres=cl_edit_Set_Options(); if ( isset($EDIT_CL_parametres) ) { $query = ' UPDATE '.CONFIG_TABLE.' SET value="'.addslashes(serialize($EDIT_CL_parametres)).'" WHERE param = "cl_EDIT_CL" LIMIT 1'; pwg_query($query); } } } // class ?>