1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | global $lang; |
---|
4 | load_language('lang', dirname(__FILE__).'/../'); |
---|
5 | $admin_url = PHPWG_ROOT_PATH.'admin.php'; |
---|
6 | |
---|
7 | |
---|
8 | /***********************************************************************************/ |
---|
9 | if (!defined('TOOL_KIT_PATH')) define( 'TOOL_KIT_PATH', EDIT_CL_PATH."admin/"); |
---|
10 | if (!defined('INCLUDE_PATH')) define( 'INCLUDE_PATH', TOOL_KIT_PATH.'include/' ); |
---|
11 | |
---|
12 | $Toolkit_Dir =INCLUDE_PATH ; |
---|
13 | |
---|
14 | include $Toolkit_Dir . 'fonctions.php'; |
---|
15 | //========================================================== |
---|
16 | if (!defined('EDIT_CL_PATH')) define( 'EDIT_CL_PATH', EDIT_CL_PATH .'admin/' ); |
---|
17 | $path = EDIT_CL_PATH; |
---|
18 | $plg_data = implode( '', file($path.'main.inc.php') ); |
---|
19 | if (preg_match("|Version: (.*)|", $plg_data, $val)) { |
---|
20 | $EDIT_CL_PATH_plugin['version'] = trim($val[1]); |
---|
21 | } |
---|
22 | $EDIT_CL_PATH_plugin = array_map('htmlspecialchars', $EDIT_CL_PATH_plugin); |
---|
23 | $version= $EDIT_CL_PATH_plugin['version'] ; |
---|
24 | $icon_path = 'themes/default/icon/help.png'; |
---|
25 | $path_js= 'themes/default/js/' ; |
---|
26 | |
---|
27 | $global_tpl=realpath(PHPWG_ROOT_PATH).'\\admin\\themes\\default\\template\\batch_manager_global.tpl' ; |
---|
28 | |
---|
29 | $template->assign( |
---|
30 | array( 'EDIT_CL_PATH' => EDIT_CL_PATH, |
---|
31 | 'path_js' => $path_js, |
---|
32 | 'VERSION'=> $version, |
---|
33 | 'EDIT_CL_PATH_ABS' => dirname(__FILE__).'/', |
---|
34 | 'GLOBAL_TPL' => $global_tpl |
---|
35 | ) |
---|
36 | ); |
---|
37 | |
---|
38 | /****************************************************************/ |
---|
39 | $info_message="" ; |
---|
40 | $erreur_message=""; |
---|
41 | /****************************************************************/ |
---|
42 | if ( !isset($_GET['mode']) ) $_GET['mode'] = 'global'; |
---|
43 | if(!isset($_GET['cat'])) $_GET['cat']="" ; |
---|
44 | if(isset($_POST['filter_prefilter'])){ |
---|
45 | $_GET['cat'] = $_POST['filter_prefilter']; |
---|
46 | } |
---|
47 | |
---|
48 | if (!isset($page['title'])) $page['title']=""; |
---|
49 | if(!isset($_POST['selectAction'])) $_POST['selectAction']="" ; |
---|
50 | //$info_message .= cl_edit_functions::Memo_Vars($_POST); |
---|
51 | //========== Mode GLOBAL ================================ |
---|
52 | check_input_parameter('selection', $_POST, true, PATTERN_ID); |
---|
53 | include (PHPWG_ROOT_PATH.'admin/batch_manager.php'); |
---|
54 | $tabsheet = new tabsheet(); |
---|
55 | $tabsheet->assign(); |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | if(isset($page['cat_elements_id'])) |
---|
61 | $template->concat('TABSHEET_TITLE', ' '.l10n_dec('%d image', '%d images', count($page['cat_elements_id'])).' - '.$page['title']); |
---|
62 | |
---|
63 | |
---|
64 | if(isset($_POST)){ |
---|
65 | // $info_message .= cl_edit_functions::Memo_Vars($_POST); |
---|
66 | |
---|
67 | //=============================================================== |
---|
68 | $collection = array(); |
---|
69 | if(isset($_POST['selection'])) |
---|
70 | $collection = $_POST['selection']; |
---|
71 | //=============================================================== |
---|
72 | $images=array(); |
---|
73 | if (!empty($_GET['display'])){ |
---|
74 | if ('all' == $_GET['display']) |
---|
75 | $page['nb_images'] = count($page['cat_elements_id']); |
---|
76 | else |
---|
77 | $page['nb_images'] = intval($_GET['display']); |
---|
78 | } |
---|
79 | else |
---|
80 | $page['nb_images'] = 20; |
---|
81 | |
---|
82 | if ( !empty($page['cat_elements_id']) ){ |
---|
83 | $query=' |
---|
84 | SELECT * FROM '.IMAGES_TABLE.' |
---|
85 | WHERE id IN ('.implode(',',$page['cat_elements_id']).') |
---|
86 | '.$conf['order_by'].' |
---|
87 | LIMIT '.$page['start'].', '. $page['nb_images'] .' |
---|
88 | ;'; |
---|
89 | $result = pwg_query($query); |
---|
90 | while ( $row=mysql_fetch_assoc($result) ) |
---|
91 | $images[] = $row; |
---|
92 | |
---|
93 | } |
---|
94 | //=============================================================== |
---|
95 | global $lang_info; |
---|
96 | if (date_default_timezone_get()) { |
---|
97 | $adresse = date_default_timezone_get() ; |
---|
98 | }else{ |
---|
99 | |
---|
100 | } |
---|
101 | $adresse = $lang_info['country']; ; |
---|
102 | $adresse=str_replace("/",", ",$adresse); |
---|
103 | |
---|
104 | if (count($collection)>0 ) |
---|
105 | if (isset($_POST['update']) && $_POST['update']==l10n('update_exif')){ |
---|
106 | /******************************* |
---|
107 | * Mise à jour des meta données |
---|
108 | *******************************/ |
---|
109 | // error_reporting ( 0 ); |
---|
110 | // Hide any unknown EXIF tags |
---|
111 | $GLOBALS['HIDE_UNKNOWN_TAGS'] = FALSE; |
---|
112 | include $Toolkit_Dir.'Toolkit_Version.php'; // Change: added as of version 1.11 |
---|
113 | // Include the required files for reading and writing Photoshop File Info |
---|
114 | include $Toolkit_Dir.'JPEG.php'; |
---|
115 | include $Toolkit_Dir.'XMP.php'; |
---|
116 | include $Toolkit_Dir.'Photoshop_IRB.php'; |
---|
117 | include $Toolkit_Dir.'EXIF.php'; |
---|
118 | include $Toolkit_Dir.'GPS_File_Info.php'; |
---|
119 | |
---|
120 | $GLOBALS['HTTP_POST_VARS']=$_POST ; |
---|
121 | // Copy all of the HTML Posted variables into an array |
---|
122 | $new_ps_file_info_array = $GLOBALS['HTTP_POST_VARS']; |
---|
123 | |
---|
124 | // Some characters are escaped with backslashes in HTML Posted variable |
---|
125 | // Cycle through each of the HTML Posted variables, and strip out the slashes ' |
---|
126 | |
---|
127 | foreach( $new_ps_file_info_array as $var_key => $var_val ){ |
---|
128 | if ($var_key !="selection") |
---|
129 | $new_ps_file_info_array[ $var_key ] = stripslashes( $var_val ); |
---|
130 | } |
---|
131 | |
---|
132 | $init_info =true; |
---|
133 | $first_image=""; |
---|
134 | $_POST['submit']=""; |
---|
135 | |
---|
136 | foreach ($collection as $id_0){ |
---|
137 | foreach ($images as $image) { |
---|
138 | if (array_search($id_0,$image)) { |
---|
139 | //================================================================= |
---|
140 | // Meta donnée |
---|
141 | //================================================================= |
---|
142 | $infos_gps = array(); |
---|
143 | $infos_gps = cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ; |
---|
144 | if($image['lat']=='' || $image['lon']==''){ |
---|
145 | $image['lat']=$infos_gps['lat']; |
---|
146 | $image['lon']=$infos_gps['lon']; |
---|
147 | $image['alt']=$infos_gps['alt']; |
---|
148 | } |
---|
149 | |
---|
150 | if($image['lat']!=''){ |
---|
151 | $new_ps_file_info_array= base_to_meta($image); |
---|
152 | } |
---|
153 | |
---|
154 | $new_ps_file_info_array['filename'] = $image['path']; |
---|
155 | $new_ps_file_info_array['selection'] = explode(";",$new_ps_file_info_array['filename']); |
---|
156 | // |
---|
157 | if( $image['lat']=="" ){ |
---|
158 | $image['lat']= $new_ps_file_info_array['lat'] ; |
---|
159 | $image['lon']= $new_ps_file_info_array['lon'] ; |
---|
160 | $image['alt']= $new_ps_file_info_array['alt'] ; |
---|
161 | } |
---|
162 | if($_POST['update']==l10n('update_exif')) unset($_POST['submit']); |
---|
163 | if(1) { |
---|
164 | |
---|
165 | if( cl_edit_controler::add_meta_gps($new_ps_file_info_array,$image)){ |
---|
166 | $exif = @read_exif_data( $image['path']); |
---|
167 | $infos_gps = cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ; |
---|
168 | $info_message .=l10n('update_exif') . ": " . $image['path'] . " : " . $image['file'] . " : ok<BR />"; |
---|
169 | }else{ |
---|
170 | |
---|
171 | } |
---|
172 | } |
---|
173 | }else{ |
---|
174 | |
---|
175 | } // fin search |
---|
176 | } // fin id_0 |
---|
177 | } // fin collection |
---|
178 | $_POST['update'] ="ok"; |
---|
179 | } |
---|
180 | //====================================================================== |
---|
181 | if ( isset($_POST['submit']) ) { |
---|
182 | if ( $_POST['submit'] == l10n('update_database') ){ |
---|
183 | /************************************************** |
---|
184 | * Uniquement Mise à jour de la base de données |
---|
185 | **************************************************/ |
---|
186 | if ( count($collection)>0 ){ |
---|
187 | $lat = trim($_POST['lat']); |
---|
188 | $lon = trim($_POST['lon']); |
---|
189 | $alt = trim($_POST['alt']); |
---|
190 | //=============================================================== |
---|
191 | if($lat !="") cl_edit_controler::add_data_base($collection,$lat,$lon,$alt) ; |
---|
192 | $_POST['submit'] = l10n('selectAction') ; |
---|
193 | foreach ($collection as $id_0){ |
---|
194 | foreach ($images as $image) { |
---|
195 | if (array_search($id_0,$image)) { |
---|
196 | $image['lat'] = $lat ; |
---|
197 | $image['lon']= $lon ; |
---|
198 | $image['alt'] =$alt ; |
---|
199 | } |
---|
200 | } |
---|
201 | } |
---|
202 | } |
---|
203 | } |
---|
204 | } |
---|
205 | /****************************************/ |
---|
206 | $query = ' |
---|
207 | SELECT id,name,uppercats,global_rank |
---|
208 | FROM '.CATEGORIES_TABLE.' |
---|
209 | ;'; |
---|
210 | $result = pwg_query($query); |
---|
211 | $categories = array(); |
---|
212 | $selecteds = array(); |
---|
213 | if (!empty($result)){ |
---|
214 | while ($row = mysql_fetch_assoc($result)) { |
---|
215 | $url = $admin_url.get_query_string_diff(array('start','cat')).'&cat='.$row['id']; |
---|
216 | if ( $row['id']==$_GET['cat'] ) $selecteds[] = $url; |
---|
217 | $row['id']=$url; |
---|
218 | array_push($categories, $row); |
---|
219 | } |
---|
220 | } |
---|
221 | usort($categories, 'global_rank_compare'); |
---|
222 | display_select_categories($categories, $selecteds, 'categories', false); |
---|
223 | |
---|
224 | |
---|
225 | if ( !empty($page['cat_elements_id']) ){ |
---|
226 | $nav_bar = create_navigation_bar( |
---|
227 | $admin_url.get_query_string_diff(array('start')), |
---|
228 | count($page['cat_elements_id']), |
---|
229 | $page['start'], |
---|
230 | $page['nb_images'] |
---|
231 | ); |
---|
232 | $template->assign('navbar', $nav_bar); |
---|
233 | } |
---|
234 | //======================================================================== |
---|
235 | $v_exif=""; |
---|
236 | $current = $template->get_template_vars('thumbnails'); |
---|
237 | $j=0; |
---|
238 | $thumbnails= array(); |
---|
239 | foreach ($images as $image){ |
---|
240 | $infos_gps = array(); |
---|
241 | $infos_gps = cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ; |
---|
242 | $v_exif=$infos_gps['is_exif']?"EXIF":"NO" ; |
---|
243 | $v_db=false ; |
---|
244 | $v_db=$image['lat']!=0 && $image['lon']!=0; |
---|
245 | $v_db=$v_db?"BD":"NO"; |
---|
246 | //==== GPS infos -> image infos ==== |
---|
247 | if( $infos_gps['lat'] !=0 || $infos_gps['lon'] !=0 ) { |
---|
248 | $new= ( !isset($image['lat'])? true: $image['lat']!=$infos_gps['lat'] ) ; |
---|
249 | $image['lat']=$infos_gps['lat']; |
---|
250 | $image['lon']=$infos_gps['lon']; |
---|
251 | $image['alt']=$infos_gps['alt']; |
---|
252 | $sel_img= array($image['id']); |
---|
253 | if ($new){ |
---|
254 | |
---|
255 | cl_edit_controler::add_data_base( $sel_img,$image['lat'],$image['lon'],$image['alt']) ; |
---|
256 | } |
---|
257 | } |
---|
258 | //================================================= |
---|
259 | $name = render_element_name($image); |
---|
260 | $desc = render_element_description($image); |
---|
261 | if (!in_array($image['id'],$current[$j])) { |
---|
262 | $j =0; |
---|
263 | foreach($current as $rK => $rV){ |
---|
264 | if (!in_array($image['id'],$rV)) { |
---|
265 | $j++ ; |
---|
266 | } else{ |
---|
267 | // $info_message .= cl_edit_functions::Memo_Vars($current[$j]); |
---|
268 | break ; |
---|
269 | } |
---|
270 | } |
---|
271 | } |
---|
272 | //================================================= |
---|
273 | |
---|
274 | $TN_SRC= $current[$j]['TN_SRC']; |
---|
275 | $TITLE=$current[$j]['TITLE'] ; |
---|
276 | |
---|
277 | $tpl_var = array( |
---|
278 | 'ID' =>$image['id'], |
---|
279 | 'TN_SRC' => $TN_SRC, |
---|
280 | 'FILE' => $current[$j]['FILE'], |
---|
281 | 'TITLE' => $TITLE, |
---|
282 | 'LEVEL' => $current[$j]['LEVEL'], |
---|
283 | 'FILE_SRC' => $current[$j]['FILE_SRC'], |
---|
284 | 'U_EDIT' => $current[$j]['U_EDIT'], |
---|
285 | 'lat' => $image['lat'] , |
---|
286 | 'lon' => $image['lon'] , |
---|
287 | 'alt' => $image['alt'] , |
---|
288 | 'U_EXIF' => $v_exif , |
---|
289 | 'U_BD' => $v_db |
---|
290 | ); |
---|
291 | |
---|
292 | |
---|
293 | $thumbnails[]=$tpl_var; |
---|
294 | $j++; |
---|
295 | } |
---|
296 | |
---|
297 | $template->assign('thumbnails', $thumbnails); |
---|
298 | |
---|
299 | |
---|
300 | $template->assign( |
---|
301 | array( |
---|
302 | 'U_DISPLAY'=> $admin_url.get_query_string_diff(array('display')) |
---|
303 | ) |
---|
304 | ); |
---|
305 | |
---|
306 | //================================================================================== |
---|
307 | $match=""; |
---|
308 | if ( isset($_POST['submit']) ) { |
---|
309 | |
---|
310 | if ($_POST['submit']==l10n('selection') ) { |
---|
311 | $collection =$_POST['selection']; |
---|
312 | } |
---|
313 | if ($_POST['submit']==l10n('add') ) { |
---|
314 | $_POST['selection']=array(); |
---|
315 | $collection =array(); |
---|
316 | unset($collection); |
---|
317 | } |
---|
318 | if ($_POST['submit']==l10n('reset' ) ) { |
---|
319 | $_POST['selection']=array(); |
---|
320 | $collection =array(); |
---|
321 | unset($collection); |
---|
322 | } |
---|
323 | } |
---|
324 | //================================================================================= |
---|
325 | $src=""; |
---|
326 | $template->assign( 'coordinates', |
---|
327 | array( 'FILE' => '', |
---|
328 | 'LAT' => '100', |
---|
329 | 'LON' => '100', |
---|
330 | 'ADRESSE' => $adresse, |
---|
331 | 'ZOOM' => 18, |
---|
332 | 'ALT' => 0 |
---|
333 | ) |
---|
334 | ); |
---|
335 | //====================================================================== |
---|
336 | if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' )){ |
---|
337 | $collection=$_POST['selection'] ; |
---|
338 | |
---|
339 | if (isset($collection)) { |
---|
340 | /********************************* |
---|
341 | * Affichage de la selection |
---|
342 | *********************************/ |
---|
343 | $init_info =true; |
---|
344 | $first_image=""; |
---|
345 | $_POST['selection'] = $collection ; |
---|
346 | foreach ($collection as $id_0) { |
---|
347 | foreach ($images as $image) { |
---|
348 | if (array_search($id_0,$image)) { |
---|
349 | $infos_gps = array(); |
---|
350 | if($image['lat']=='' || $image['lon']==''){ } |
---|
351 | $infos_gps =array(); |
---|
352 | $infos_gps = cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ; |
---|
353 | if(isset($infos_gps['lat']) && $infos_gps['is_exif']){ |
---|
354 | $image['lat']=$infos_gps['lat']; |
---|
355 | $image['lon']=$infos_gps['lon']; |
---|
356 | $image['alt']=$infos_gps['alt']; |
---|
357 | } |
---|
358 | if ( $init_info && $image['lat'] <> '' ) { |
---|
359 | $init_info = false ; |
---|
360 | $lat = ($image['lat'] <> '') ? $image['lat'] : '100' ; |
---|
361 | $lon = ($image['lon'] <> '') ? $image['lon'] : '3.0' ; |
---|
362 | $alt = ($image['alt'] <> '') ? $image['alt'] : '0' ; |
---|
363 | |
---|
364 | //===================================================== |
---|
365 | $template->assign( 'coordinates', |
---|
366 | array( |
---|
367 | 'FILE' => $image['path'], |
---|
368 | 'LAT' => $lat , |
---|
369 | 'LON' => $lon , |
---|
370 | 'ADRESSE' => $adresse , |
---|
371 | 'ZOOM' => 4, |
---|
372 | 'ALT' => $alt , |
---|
373 | ) |
---|
374 | ); |
---|
375 | } |
---|
376 | //===================================================== |
---|
377 | $lon=$image['lon']; |
---|
378 | $lat=$image['lat']; |
---|
379 | if($infos_gps['is_exif']) { |
---|
380 | $info_message .='EXIF'; |
---|
381 | } |
---|
382 | $lonDMS= dec2dms($lon) ; |
---|
383 | $latDMS= dec2dms($lat) ; |
---|
384 | $v_db=false ; |
---|
385 | $v_db=$lon!=0 && $lat!=0; |
---|
386 | |
---|
387 | $tpl_var = array_merge( |
---|
388 | $image, |
---|
389 | array( |
---|
390 | 'filename' => $image['path'], |
---|
391 | 'exif' => '"'.$infos_gps['is_exif'].'"' , |
---|
392 | 'lat' => $image['lat'] , |
---|
393 | 'lon' => $image['lon'] , |
---|
394 | 'alt' => $image['alt'] , |
---|
395 | 'latDMS' => $latDMS[3] , |
---|
396 | 'lonDMS' => $lonDMS[3] , |
---|
397 | 'adresse' => $adresse , |
---|
398 | 'TN_SRC' => get_thumbnail_url($image), |
---|
399 | 'TITLE' => get_thumbnail_title($image), |
---|
400 | 'U_EXIF' => $infos_gps['is_exif'] , |
---|
401 | 'U_BD' => $v_db , |
---|
402 | 'U_MAP' => cl_make_map_picture_url( |
---|
403 | array( |
---|
404 | 'image_id'=>$image['id'], |
---|
405 | 'image_file'=>$image['file'], |
---|
406 | ) |
---|
407 | ), |
---|
408 | ) |
---|
409 | ); |
---|
410 | $template->append('Selectthumbnails', $tpl_var); |
---|
411 | } |
---|
412 | } |
---|
413 | } |
---|
414 | } |
---|
415 | } |
---|
416 | |
---|
417 | //============================================================ |
---|
418 | if ( !empty($first_image)) { |
---|
419 | $erreur_message .= cl_edit_functions::Memo_Vars($first_image); |
---|
420 | |
---|
421 | if (isset($_POST['update'])) { |
---|
422 | // document.Envoie.latDMS.value |
---|
423 | $image= first_image ; |
---|
424 | $filename=$image['path'] ; |
---|
425 | $Val_exif=""; |
---|
426 | $Val_XMP=""; |
---|
427 | /* */ |
---|
428 | if (!empty($infos_gps)) |
---|
429 | $Position = $infos_gps ; |
---|
430 | else $Position = cl_edit_controler::Get_exif_gps($filename,$image,false) ; |
---|
431 | |
---|
432 | $jpeg_header_data = get_jpeg_header_data($filename ); |
---|
433 | $template->assign( array( |
---|
434 | 'filename_abs' => $filename , |
---|
435 | 'filename' => $filename, |
---|
436 | 'datas' => array( |
---|
437 | /* |
---|
438 | 'Val_JPEG_APP'=> Generate_JPEG_APP_Segment_HTML( $jpeg_header_data ), |
---|
439 | 'Val_intrinsic'=> Interpret_intrinsic_values_to_HTML( get_jpeg_intrinsic_values( $jpeg_header_data ) ), |
---|
440 | 'Val_Comment'=> Interpret_Comment_to_HTML( $jpeg_header_data ), |
---|
441 | 'Val_JFIF'=> Interpret_JFIF_to_HTML( get_JFIF( $jpeg_header_data ), $filename ), |
---|
442 | 'Val_JFXX'=>Interpret_JFXX_to_HTML( get_JFXX( $jpeg_header_data ), $filename ), |
---|
443 | 'Val_App12' => Interpret_App12_Pic_Info_to_HTML( $jpeg_header_data ), |
---|
444 | 'Val_IRB' => Interpret_IRB_to_HTML( get_Photoshop_IRB( $jpeg_header_data ), $filename ), |
---|
445 | |
---|
446 | 'Val_exif'=> Interpret_EXIF_to_HTML( get_EXIF_JPEG( $filename ), $filename), |
---|
447 | 'Val_XMP' => Interpret_XMP_to_HTML( read_XMP_array_from_text( get_XMP_text( $jpeg_header_data) ) ), |
---|
448 | */ |
---|
449 | // |
---|
450 | ), |
---|
451 | 'Datadase' => ($Position) , |
---|
452 | ) ); |
---|
453 | } |
---|
454 | } |
---|
455 | |
---|
456 | |
---|
457 | //======================================================================= |
---|
458 | |
---|
459 | $v1=0; |
---|
460 | |
---|
461 | |
---|
462 | } |
---|
463 | |
---|
464 | if ($info_message!="") |
---|
465 | $template->assign('infos',$info_message); |
---|
466 | if ($erreur_message!="") |
---|
467 | $template->assign('errors',$erreur_message); |
---|
468 | |
---|
469 | function cl_make_map_picture_url($params) |
---|
470 | { |
---|
471 | global $conf; |
---|
472 | /*if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' ) |
---|
473 | return "";*/ |
---|
474 | $map_url = make_picture_url($params); |
---|
475 | return add_url_params($map_url, array('map'=>null) ); |
---|
476 | } |
---|
477 | ?> |
---|