$var_val ){
if ($var_key !="selection")
$new_ps_file_info_array[ $var_key ] = stripslashes( $var_val );
}
$new_ps_file_info_array['selection'] = explode(";",$new_ps_file_info_array['filename']);
foreach( $new_ps_file_info_array['selection'] as $filename ) {
//======================================================
//= $new_ps_file_info_array[ 'filename' ];
if($filename!="") { // Protect against hackers editing other files
// copy( $filename, $filename.".bak" );
$path_parts = pathinfo( $filename );
if(1) {
if ( strcasecmp( $path_parts["extension"], "jpg" ) != 0 ) {
$error_message .= $filename ;
$error_message .="Incorrect File Type - JPEG Only\n";
$filename="";
// exit( );
}
// Change: removed limitation on file being in current directory - as of version 1.11
// Retrieve the header information
$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
$error_message .= "jpeg_header_data
Error - Failure update Photoshop File Info : $filename
\n";
// 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
$error_message .= "Error - Failure to write new JPEG : $filename
\n";
// Output HTML with the form and data which was
// sent, to allow the user to fix it
}else{
$info_message .= l10n('update') . " Exif: " . $filename . " " . l10n('OK') ."
" ;
}
$_POST['submit']= l10n('update_database') ;
}
}
}
$_POST['update'] ="ok";
}
/****************************************************************/
if ( !isset($_GET['cat']) ) $_GET['cat'] = 'caddie';
$_GET['mode'] = 'map';
if (PHPWG_VERSION < 2.2 ) {
include (PHPWG_ROOT_PATH.'admin/element_set.php');
} else {
if (!isset($page['title'])) $page['title']="";
include (PHPWG_ROOT_PATH.'admin/batch_manager.php');
$template->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 photo'));
else
$collection = $_POST['selection'];
break;
}
/******** Mise à jour 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';
}
elseif ( 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();
$info_message .= l10n('update') . " " . IMAGES_TABLE . " : " . l10n('OK') ;
$_POST['submit'] = l10n('Submit') ;
}
}
}
}
/**************************************/
$specials_selected = null;
foreach( array('caddie'=>'Caddie', 'recent'=>'Recent photos') as $k => $v)
{
$link = $admin_url.get_query_string_diff(array('start','cat')).'&cat='.$k;
$template->append(
'specials',
array(
$link => l10n($v),
),
true
);
if ($k == $_GET['cat']) $specials_selected = $link;
}
$template->assign('specials_selected', $specials_selected);
/****************************************/
$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('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( 'FILE' => '',
'LAT' => '100',
'LON' => '100',
'ADRESSE' => $adresse,
'ZOOM' => 18,
'ALT' => 0
)
);
if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' ))
{
if (isset($collection)) {
$lat =1000;$first_image="";
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) ;
$image['lat']=$infos_gps['lat'];
$image['lon']=$infos_gps['lon'];
$image['alt']=$infos_gps['alt'];
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('FILE' => $image['path'],
'LAT' => $lat ,
'LON' => $lon ,
'ADRESSE' => $adresse ,
'ZOOM' => 4,
'ALT' => $alt ,
)
);
}
$lon=$image['lon'];
$lat=$image['lat'];
if($infos_gps['is_exif']) $info_message .='EXIF';
$lonDMS= dec2dms($lon) ;
$latDMS= dec2dms($lat) ;
$tpl_var = array_merge(
$image,
array(
'filename' => $image['path'],
'exif' => $infos_gps['is_exif'] ,
'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($first_image))
{ $error_message .= cl_edit_controler::Memo_Vars($first_image);
if (isset($_POST['update'])) {
// document.Envoie.latDMS.value
$image= first_image ;
$filename=$image['path'] ;
$Val_exif="";
$Val_XMP="";
/* */
if (!empty($infos_gps))
$Position = $infos_gps ;
else $Position = Get_exif_gps($filename,$image) ;
$jpeg_header_data = get_jpeg_header_data($filename );
$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 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($firt_image,$image)
{
error_reporting ( 1 );
$filename=$firt_image;
$datas = array();
$errors = array();
$exif = @read_exif_data( $filename );
global $errors;global $template ;
if ( empty($exif) ) return;
$exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) );
//====================================================================
$lat = $image['lat'] ;
$lon = $image['lon'] ;
$alt = $image['alt'];
global $info_message ;
$is_exif = "'".(is_array($exif['GPSLatitude']) and is_array($exif['GPSLongitude']) )."'" ;
if ($is_exif) {
$lat_exif = parse_lat_lon( $exif['GPSLatitude'] );
$lon_exif = parse_lat_lon( $exif['GPSLongitude'] );
$alt_exif = Parse_Fract( $exif['GPSAltitude'] );
}
if ($lat =="")
{
$lat = Parse_Lat_Lon( $exif['GPSLatitude'] );
if ( $exif['GPSLatitudeRef']=='S' ) $lat = -$lat;
}else{
$is_exif="false" ;
if($lat<0) $exif['GPSLatitudeRef']='S' ;
else $exif['GPSLatitudeRef']='N' ;
}
if ($lon =="") {
$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]['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] ;
}
if ($info_message!="")
$template->assign('infos',$info_message);
if ($error_message!="")
$template->assign('errors',$error_message);
?>