Changeset 12126 for extensions/edit_gmaps/edit_gmaps.inc.php
- Timestamp:
- Sep 10, 2011, 5:02:19 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/edit_gmaps/edit_gmaps.inc.php
r9446 r12126 66 66 class cl_edit_controler { 67 67 68 static public function add_meta_gps($new_ps_file_info_array,$image){ 69 global $nom_fichier,$erreur_message, $info_message; 70 71 72 // $exif = @read_exif_data( $exif ); 73 // $exif = @array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) ); 74 75 foreach( $new_ps_file_info_array['selection'] as $filename ) { 76 //====================================================== 77 if($new_ps_file_info_array['lat']=='') { 78 $erreur_message .= "Error - lon or lat = null : $filename <br>\n"; 79 }else{ 80 if($filename!="") { 81 //= $new_ps_file_info_array[ 'filename' ]; 82 // Protect against hackers editing other files 83 // copy( $filename, $filename.".bak" ); 84 $path_parts = pathinfo( $filename ); 85 86 if ( strcasecmp( $path_parts["extension"], "jpg" ) != 0 ) { 87 $erreur_message .= $filename ; 88 $erreur_message .="Incorrect File Type - JPEG Only\n"; 89 $filename=""; 90 return; 91 } 92 // Change: removed limitation on file being in current directory - as of version 1.11 93 // Retrieve the header information 94 95 $nom_fichier=$filename; 96 $jpeg_header_data = get_jpeg_header_data( $filename ); 97 // Retreive the EXIF, XMP and Photoshop IRB information from 98 // the existing file, so that it can be updated 99 $Exif_array = get_EXIF_JPEG( $filename ); 100 $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); 101 $IRB_array = get_Photoshop_IRB( $jpeg_header_data ); 102 // Update the JPEG header information with the new Photoshop File Info 103 104 $jpeg_header_data = put_GPS_file_info( $jpeg_header_data, $new_ps_file_info_array, $Exif_array, $XMP_array, $IRB_array ); 105 // Check if the Update worked 106 if ( $jpeg_header_data == FALSE ) { 107 // Update of file info didn''t work - output error message 108 $erreur_message .= "jpeg_header_data 109 Error - Failure update Photoshop File Info : $filename <br>\n"; 110 return false; 111 // Output HTML with the form and data which was 112 // sent, to allow the user to fix it 113 }else if ( FALSE == put_jpeg_header_data( $filename, $filename, $jpeg_header_data ) ) { 114 // Attempt to write the new JPEG file 115 // Writing of the new file didn''t work - output error message 116 $erreur_message .= "Error - Failure to write new JPEG : $filename <br>\n"; 117 return false; 118 // Output HTML with the form and data which was 119 // sent, to allow the user to fix it 120 }else{ 121 return true; 122 } 123 }// test filename} 124 } //for each 125 126 } 127 128 129 } 130 //========================================================== 131 static public function Get_exif_gps($firt_image,$image,$hight_gps) { 132 global $errors;global $template ; 133 global $info_message ; 134 error_reporting ( 1 ); 135 $filename=$firt_image; 136 137 $datas = array(); 138 $errors = array(); 139 $exif = @read_exif_data( $filename ); 140 if ( empty($exif) ) return; 141 142 $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) ); 143 if(count($exif)==0 || $hight_gps ){ 144 $path_parts = pathinfo( $filename ); 145 $exif = @read_exif_data( $path_parts['dirname']."/pwg_high/".$path_parts['basename']); 146 $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) ); 147 } 148 if(count($exif)==0) return ; 149 //==================================================================== 150 $lat = $image['lat'] ; 151 $lon = $image['lon'] ; 152 $alt = $image['alt']; 153 154 $p1=base_to_meta($image); 155 156 if($exif['GPSLatitude'][0]=="1/1" && $lat!=""){ 157 $exif['GPSLatitudeRef'] = $p1['GPSLatitudeRef'] ; 158 $exif['GPSLatitude']=$p1['GPSLatitude']; 159 $exif['GPSLongitudeRef'] = $p1['GPSLongitudeRef']; 160 $exif['GPSLongitude']=$p1['GPSLongitude']; 161 $exif['GPSAltitudeRef'] =$p1['GPSAltitudeRef']; 162 $exif['GPSAltitude']= $p1['GPSAltitude']; 163 164 } 165 166 $is_exif = is_array($exif['GPSLatitude']) && $exif['GPSLatitude']!='' ; 167 $is_exif = is_array($exif['GPSLongitude']) && $exif['GPSLongitude']!='' & $is_exif ; 168 169 if ($is_exif) { 170 $lat_exif = Parse_Lat_Lon( $exif['GPSLatitude'] ); 171 $lon_exif = Parse_Lat_Lon( $exif['GPSLongitude'] ); 172 $alt_exif = Parse_Fract( $exif['GPSAltitude'] ); 173 } 174 175 $is_exif = $lat_exif!=0; 176 //============================== 177 if ($lat =="" || $hight_gps){ 178 $lat = Parse_Lat_Lon( $exif['GPSLatitude'] ); 179 if ( $exif['GPSLatitudeRef']=='S' ) $lat = -$lat; 180 }else{ 181 if($lat<0) $exif['GPSLatitudeRef']='S' ; 182 else $exif['GPSLatitudeRef']='N' ; 183 } 184 //============================== 185 if ($lon =="" || $hight_gps) { 186 $lon = Parse_Lat_Lon( $exif['GPSLongitude'] ); 187 if ( $exif['GPSLongitudeRef']=='W' ) $lon = -$lon; 188 }else{ 189 if ($lon<0) $exif['GPSLongitudeRef'] ='W' ; 190 else $exif['GPSLongitudeRef'] ='E' ; 191 } 192 //======================================================================= 193 $altref = 0; 194 if (!is_array($exif['GPSAltitude']) or !is_array($exif['GPSAltitudeRef']) ){ 195 $exif['GPSAltitude']=$alt; 196 $exif['GPSAltitudeRef']=0; 197 } else { 198 $alt = $exif['GPSAltitude']; 199 $altref = $exif['GPSAltitudeRef']; 200 } 201 //======================================================================== 202 $datas[] = array ( 203 'is_exif' => $is_exif , 204 ' filename=' => $filename , 205 'id' => $image['id'] , 206 'lat' => $lat , 207 'lon' => $lon , 208 'latDMS' => $exif['GPSLatitude'][0]." ". 209 $exif['GPSLatitude'][1]." ". 210 $exif['GPSLatitude'][2]." ". 211 $exif['GPSLatitudeRef'], 212 'lonDMS' => $exif['GPSLongitude'][0]." ". 213 $exif['GPSLongitude'][1]." ". 214 $exif['GPSLongitude'][2]." ". 215 $exif['GPSLongitudeRef'], 216 'altref' => $exif['GPSAltitudeRef'], 217 'alt' => $exif['GPSAltitude'] 218 ); 219 220 return $datas[0] ; 221 } 222 //====================================================== 223 /* 224 * 225 */ 226 static public function add_data_base($sel,$lat,$lon,$alt){ 227 global $page,$info_message,$erreur_message ; 228 229 if ( strlen($lat)>0 and strlen($lon)>0 ) { 230 if ( (double)$lat<=90 and (double)$lat>=-90 231 and (double)$lon<=180 and (double)$lat>=-180 ) 232 $update_query = 'lat='.$lat.', lon='.$lon; 233 else 234 $erreur_message .= 'Invalid lat or lon value'; 235 } 236 elseif ( strlen($lat)==0 and strlen($lon)==0 ) 237 $update_query = 'lat=NULL, lon=NULL'; 238 else 239 $erreur_message .= 'Both lat/lon must be empty or not empty'; 240 if ( strlen($alt)==0) 241 $update_query .= ', alt=NULL'; 242 else 243 $update_query .= ', alt=' .$alt ; 244 245 if (isset($update_query)){ 246 $update_query = ' 247 UPDATE '.IMAGES_TABLE.' SET '.$update_query.' 248 WHERE id IN ('.implode(',',$sel).')'; 249 pwg_query($update_query) ; 250 cl_meta_invalidate_cache(); 251 $info_message .= l10n('update') . " " . implode(',',$sel) . " ". IMAGES_TABLE . " : " . l10n('OK') ."<br />"; 252 } 253 } 254 //====================================================== 68 255 static public function cl_edit_admin_menu($menu) 69 256 { … … 77 264 return $menu; 78 265 } 79 80 81 82 83 84 85 266 /* 86 267 *
Note: See TracChangeset
for help on using the changeset viewer.