Code Update: step 2.1) 3.); 16.02.2013
EXIF Daten werden auch in die Datenbank geschrieben, wenn die Bilder über das Member Uploadformular hoch geladen werden.
Member können mittels einer Google Map den Bilder Geo Koordinaten hinzufügen.
1.) suche in der member.php im abschnitt($action == "updateimage"):
$image_keywords = implode(',', array_unique(array_filter($image_keywords_arr)));
füge darunter ein:
//####################### Start Googlemap ############################
$image_GPSLatitude = intval($HTTP_POST_VARS['image_GPSLatitude']);
$image_GPSLongitude = intval($HTTP_POST_VARS['image_GPSLongitude']);
//####################### End Googlemap ##############################
1.1) suche in der member.php im abschnitt($action == "updateimage"):
$additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'"
füge darüber ein:
//########################## Start Google map ##########################################
if($HTTP_POST_VARS['image_GPSLatitude'] != 0 && $HTTP_POST_VARS['image_GPSLongitude'] != 0){
if($key == 'image_GPSLatitude'){
if($HTTP_POST_VARS['image_GPSLatitude']< 0 ){
$additional_sql .= ", image_GPSLatitudeRef = 'Süd'";
}else{
$additional_sql .= ", image_GPSLatitudeRef = 'Nord'";
}
$additional_sql .= ", $key = '".(round(un_htmlspecialchars(trim($HTTP_POST_VARS[$key])),4))."'";
}
elseif($key == 'image_GPSLongitude'){
if($HTTP_POST_VARS['image_GPSLongitude'] < 0 ){
$additional_sql .= ", image_GPSLongitudeRef = 'West'";
}else{
$additional_sql .= ", image_GPSLongitudeRef = 'Ost'";
}
$additional_sql .= ", $key = '".(round(un_htmlspecialchars(trim($HTTP_POST_VARS[$key])),4))."'";
}
}else{
$additional_sql .= ", image_GPSLatitudeRef = ''";
$additional_sql .= ", image_GPSLongitudeRef = ''";
}
//########################## End Google map #############################################
1.2) suche in der member.php im abschnitt($action == "editimage"):
$txt_clickstream = get_category_path($image_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\"
füge darüber ein:
//######################### IPTC EXIF #########################################
foreach ($image_row as $key => $val) {
if ($val && (!is_numeric($key))) {
$hidden_fields .= "<input type=\"hidden\" name=\"$key\" value=\"$val\" />\n";
}
}
//######################### IPTC EXIF #########################################
1.3) suche:
$site_template->register_vars(array(
"image_id" => $image_id,
"image_name" => format_text($image_name, 2),
ersetze es mit:
//################# Start Google map ##############################################################################
$image_GPSLatitude = (isset($HTTP_POST_VARS['image_GPSLatitude'])) ? intval($HTTP_POST_VARS['image_GPSLatitude']) : ((($image_row['image_GPSLatitude'])) ? $image_row['image_GPSLatitude'] :"''");
$image_GPSLongitude = (isset($HTTP_POST_VARS['image_GPSLongitude'])) ? intval($HTTP_POST_VARS['image_GPSLongitude']) : ((($image_row['image_GPSLongitude'])) ? $image_row['image_GPSLongitude'] :"''");
$google_map = "
<script type='text/javascript' src='./js/googlemap.js'></script>
<script type='text/javascript'>
var GPSLatitude = $image_GPSLatitude;
var GPSLongitude = $image_GPSLongitude;
var latlng = '1';
</script>
";
//################# End Google map #################################################
$site_template->register_vars(array(
"hidden_fields" => $hidden_fields, //########## IPTC EXIF ######################
"google_map" => $google_map, //################# Google map ####################
"image_id" => $image_id,
"image_name" => format_text($image_name, 2),
1.4) suche:
if (!$uploaderror) {
$additional_field_sql = "";
$additional_value_sql = "";
if (!empty($additional_image_fields)) {
$table = ($direct_upload) ? IMAGES_TABLE : IMAGES_TEMP_TABLE;
$table_fields = $site_db->get_table_fields($table);
foreach ($additional_image_fields as $key => $val) {
if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
$additional_field_sql .= ", $key";
$additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
}
}
}
ersetze es mit:
if (!$uploaderror) {
if(!empty($additional_image_fields)) {
//$additional_field_sql = ""; // bei exif auskommentieren
//$additional_value_sql = ""; // bei exif auskommentieren
//############################### Start Exif ############################################
//$src_file = ($big_file) ? MEDIA_PATH."/".$cat_id."/".$big_folder."/".$big_file : $file;
$src_file = $src;
$size = getimagesize ($src_file, $info);
if(function_exists('exif_read_data') && $exif_data = @exif_read_data($src_file, 'EXIF')) {
$exif_array = get_exif_info($exif_data);
foreach ($exif_array as $key => $val) {
$additional_field_sql .= ',image_'.$key;
$additional_value_sql .= ",'".$val."'";
}
}
if(isset($exif_array['GPSLatitude'])){
unset($additional_image_fields['image_GPSLatitude']);
unset($additional_image_fields['image_GPSLongitude']);
}
$table = ($direct_upload) ? IMAGES_TABLE : IMAGES_TEMP_TABLE;
$table_fields = $site_db->get_table_fields($table);
foreach ($additional_image_fields as $key => $val) {
if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
if(($key == 'image_GPSLatitude') && !empty($HTTP_POST_VARS['image_GPSLatitude'])){
if($HTTP_POST_VARS['image_GPSLatitude'] < 0 ){
$additional_field_sql .= ", image_GPSLatitudeRef";
$additional_value_sql .= ", 'Süd'";
}else{
$additional_field_sql .= ", image_GPSLatitudeRef";
$additional_value_sql .= ", 'Nord'";
}
$additional_field_sql .= ", $key";
$additional_value_sql .= ", '".(round(un_htmlspecialchars(trim($HTTP_POST_VARS[$key])),4))."'";
}
elseif(($key == 'image_GPSLongitude') && !empty($HTTP_POST_VARS['image_GPSLongitude'])){
if($HTTP_POST_VARS['image_GPSLongitude'] < 0 ){
$additional_field_sql .= ", image_GPSLongitudeRef";
$additional_value_sql .= ", 'West'";
}else{
$additional_field_sql .= ", image_GPSLongitudeRef";
$additional_value_sql .= ", 'Ost'";
}
$additional_field_sql .= ", $key";
$additional_value_sql .= ", '".(round(un_htmlspecialchars(trim($HTTP_POST_VARS[$key])),4))."'";
}
else{ // Google map
$additional_field_sql .= ", $key";
$additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
} // Google map
}
}
}
1.5)suche:
}
add_searchwords($image_id, $search_words);
füge darunter ein:
//######################### Start Exif IPTC #########################
$sql = "SELECT image_id".$additional_field_sql."
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id
";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$additional_search_words = array();
foreach ($search_match_fields as $image_column => $match_column) {
if (isset($row[$image_column])) {
$additional_search_words[$image_column] = $row[$image_column];
}
}
add_searchwords($image_id, $additional_search_words);
};
//####################### End Exif IPTC #########################
1.6)suche:
$site_template->register_vars(array(
"cat_id" => $cat_id,
"cat_name" => ($cat_id != 0) ? format_text($cat_cache[$cat_id]['cat_name'],
ersetze es mit:
//################# Start Google map #####################################################
$google_map = "
<script type='text/javascript' src='./js/googlemap.js'></script>
<script type='text/javascript'>
var latlng = '1';
</script>
";
//################# End Google map #####################################################
$site_template->register_vars(array(
"google_map" => $google_map, //googlemap
"cat_id" => $cat_id,
"cat_name" => ($cat_id != 0) ? format_text($cat_cache[$cat_id]['cat_name'], 2) : get_category_dropdown($cat_id),
2.) suche in deinen template/member_editimage.html:
<form method="post" action="{url_member}" onsubmit="uploadbutton.disabled=true;">
füge darunter ein:
{hidden_fields}
2.1) suche:
<textarea name="image_keywords" cols="30" rows="10" wrap="virtual" class="textarea">{image_keywords}</textarea>
</td>
</tr>
füge darunter ein:
<tr>
<td class="row1"><b>{lang_image_GPSLatitude}</b></td>
<td class="row1"><input type="text" name="image_GPSLatitude" id="lat" size="30" value="{image_GPSLatitude}" class="input" /></td>
</tr>
<tr>
<td class="row2"><b>{lang_image_GPSLongitude}</b></td>
<td class="row2"><input type="text" name="image_GPSLongitude" id="lng" size="30" value="{image_GPSLongitude}" class="input" /></td>
</tr>
<tr>
<td class="row1"valign="top"><b>Map:</b></td>
<td class="row1"> <div id="map_canvas" style="width: 450px; height: 300px"></div>
{google_map}
</td>
</tr>
3.) suche in deinen template/member_uploadform.html:
<textarea cols="30" class="textarea" rows="10" name="image_keywords">{image_keywords}</textarea>
</td>
</tr>
füge darunter ein:
<tr>
<td class="row1"><b>{lang_image_GPSLatitude}</b></td>
<td class="row1"><input type="text" name="image_GPSLatitude" id="lat" size="30" value="{image_GPSLatitude}" class="input" /></td>
</tr>
<tr>
<td class="row2"><b>{lang_image_GPSLongitude}</b></td>
<td class="row2"><input type="text" name="image_GPSLongitude" id="lng" size="30" value="{image_GPSLongitude}" class="input" /></td>
</tr>
<tr>
<td class="row1"valign="top"><b>Map:</b></td>
<td class="row1">
<div id="map_canvas" style="width: 450px; height: 300px"></div>
{google_map}
</td>
</tr>
mfg Andi