<title>Bild-Details</title> <meta name="GENERATOR" content="Quanta Plus"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Style-Type" content="text/css"> <link rel=stylesheet type="text/css" href='../css/format1.css'> <link rel="shortcut icon" href="images/favicon.ico"> </head> <body style='background-color:#999999'> <?php // verwendet als Popup-Fenster mit den Detail-Infos zum Bild include_once 'global_config.php'; include_once 'db_connect1.php'; include_once $sr . '/bin/share/functions/main_functions.php'; $result0 = mysql_query("SELECT * FROM {$table1} WHERE id = '{$uid}' AND aktiv = '1'"); $username = mysql_result($result0, isset($i0), 'username'); $exiftool = buildExiftoolCommand($sr); //var_dump($_GET); if (array_key_exists('pic_id', $_GET)) { $pic_id = $_GET['pic_id']; } $result0 = mysql_query("SELECT * FROM {$table2} WHERE pic_id = '{$pic_id}'"); $num0 = mysql_num_rows($result0); $row = mysql_fetch_array($result0); $FileNameOri = $row['FileNameOri']; $Owner = $row['Owner']; $result2 = mysql_query("SELECT * FROM {$table1} WHERE id = '{$Owner}'"); $row = mysql_fetch_array($result2); $vorname = $row['vorname']; $name = $row['name']; //$u_name = $row['username']; $lang = $row['language'];
function createPreviewAjax($pic_id, $max_size, $quality) { //Erzeugung einer Bildvorschau unter optimaler Nutzung des Bildschirmes; //Qualitaeten: 1 - Vorschaubild; 2 - HQ-Bild; 3 - Original-Bild include '../share/global_config.php'; include $sr . '/bin/share/db_connect1.php'; $exiftool = buildExiftoolCommand($sr); $res0 = mysql_query("SELECT * FROM {$table2} WHERE pic_id='{$pic_id}'"); $row = mysql_fetch_array($res0); $FileNameV = $row['FileNameV']; $FileNameHQ = $row['FileNameHQ']; $FileName = $row['FileName']; $FileNameOri = $row['FileNameOri']; $Width = $row['ExifImageWidth']; $Height = $row['ExifImageHeight']; $Orientation = $row['Orientation']; $FileNameOri_ext = explode('.', $FileNameOri); $ext = strtolower(isset($FileNameOri_ext[1])); //Extension des Original-Bildes //abgeleitete Groessen: $parameter_v = getimagesize($sr . '/images/vorschau/thumbs/' . $FileNameV); $parameter_hq = getimagesize($sr . '/images/vorschau/hq-preview/' . $FileNameHQ); $parameter_o = getimagesize($sr . '/images/originale/' . $FileName); switch ($quality) { case '1': $breite = $parameter_v[0]; $hoehe = $parameter_v[1]; $bildname = 'http://' . $sr . '/images/vorschau/thumbs/' . $FileNameV; break; case '2': $breite = $parameter_hq[0]; $hoehe = $parameter_hq[1]; $bildname = 'http://' . $sr . '/images/vorschau/hq-preview/' . $FileNameHQ; break; case '3': $breite = $parameter_o[0]; $hoehe = $parameter_o[1]; switch ($Orientation) { case '': case 0: case 1: $bildname = 'http://' . $_SERVER['SERVER_NAME'] . $inst_path . '/pic2base/images/originale/' . $FileName; break; default: //wenn das bild nicht landscape ist wird geprueft, ob es dieses Bild schon in gedrehter Form gibt: $verz = opendir($sr . '/images/originale/rotated'); $n = 0; while ($bilddatei = readdir($verz)) { if ($bilddatei != "." && $bilddatei != "..") { //$bildd=$bilder_verzeichnis."/".$bilddatei; //echo "Bild: ".$bilddatei."; Datei: ".$file_name."<BR>"; if ($bilddatei == $FileName) { $n++; } } } // echo "N: ".$n."<BR>"; if ($n > '0') { //wenn ein bereits gedrehtes Bild gefunden wurde, verwende dies: $bildname = 'http://' . $_SERVER['SERVER_NAME'] . $inst_path . '/pic2base/images/originale/rotated/' . $FileName; } else { //wenn keins gefunden wurde wird es gedreht und dann angezeigt: $bildname = 'http://' . $_SERVER['SERVER_NAME'] . $inst_path . '/pic2base/images/originale/' . $FileName; if ($ext == 'nef') { copy("{$pic_path}/{$FileName}", "{$pic_rot_path}/{$FileName}"); clearstatcache(); chmod($pic_rot_path . "/" . $FileName, 0700); clearstatcache(); } else { switch ($Orientation) { case 3: //Das Vorschaubild muss 180 gedreht werden: $command = "/usr/bin/convert " . $pic_path . "/" . $FileName . " -rotate 180 " . $pic_rot_path . "/" . $FileName . ""; $output = shell_exec($command); break; case 6: //Das Vorschaubild muss 90 im Uhrzeigersinn gedreht werden: $command = "/usr/bin/convert " . $pic_path . "/" . $FileName . " -rotate 90 " . $pic_rot_path . "/" . $FileName . ""; //echo $command; $output = shell_exec($command); break; case 8: //Das Vorschaubild muss 90 entgegen dem Uhrzeigersinn gedreht werden: $command = "/usr/bin/convert " . $pic_path . "/" . $FileName . " -rotate 270 " . $pic_rot_path . "/" . $FileName . ""; $output = shell_exec($command); break; } } } $parameter_o_r = getimagesize($sr . '/images/originale/rotated/' . $FileName); $breite = $parameter_o_r[0]; $hoehe = $parameter_o_r[1]; break; } //echo $bildname; break; } $ratio_pic = $breite / $hoehe; switch ($Orientation) { case '': case '0': case '1': case '3': $Height = $row['ExifImageHeight']; $Width = $row['ExifImageWidth']; break; case '6': case '8': $Height = $row['ExifImageWidth']; $Width = $row['ExifImageHeight']; break; } $breite_v = $parameter_v[0]; $hoehe_v = $parameter_v[1]; if ($breite_v >= $hoehe_v) { $Breite = $max_size; $Hoehe = number_format($Breite * $hoehe_v / $breite_v, 0, ',', '.'); } else { $Hoehe = $max_size; $Breite = number_format($Hoehe * $breite_v / $hoehe_v, 0, ',', '.'); } echo "<a href='#' onclick=\"ZeigeBild('{$bildname}', '{$Width}', '{$Height}', '{$ratio_pic}', 'ori', '');return false\" title='Ansicht in optimaler Qualität'><div class='shadow_1'><img src='{$inst_path}/pic2base/images/vorschau/thumbs/{$FileNameV}' alt='Vorschaubild' width={$Breite} height={$Hoehe} z='5' border='0'></div></a>"; }
function extractExifData($pic_id, $sr, $Orientation) { include $sr . '/bin/share/global_config.php'; include $sr . '/bin/share/db_connect1.php'; $exiftool = buildExiftoolCommand($sr); $result6 = mysql_query("SELECT * FROM {$table14} WHERE pic_id = '{$pic_id}'"); if (mysql_num_rows($result6) == 0) { //nur wenn es noch keinen Eintrag in der meta_data-Tabelle fuer dieses Bild gibt, wird die Erfassung ausgefuehrt: $result7 = mysql_query("INSERT INTO {$table14} (pic_id) VALUES ('{$pic_id}')"); //Ermittlung des Original-Dateinamens mit eindeutiger Bezeichnung (z.B. 12345.nef): $FN = $pic_path . "/" . restoreOriFilename($pic_id, $sr); $result8 = mysql_query("SHOW COLUMNS FROM {$table14}"); $i = 0; if ($result8 != false) { while ($liste = mysql_fetch_row($result8)) { $tab_fieldname[$i] = $liste[0]; //vorh. Tabellen-Feldname $i++; } } else { die('Fehler bei der Datenbankabfrage'); } // Fuer jedes Feld der Meta-Daten-Tabelle wird ein evtl. vorhandener Datenwert aus dem Bild // ausgelesen und in die Tabelle geschrieben: $text = shell_exec($exiftool . " " . $FN); $inf_arr = explode(chr(10), $text); //Zerlegung des Textes am Zeilenumbruch //echo count($inf_arr)." Meta-Angaben im Bild ".$FN."<BR><BR>";; foreach ($inf_arr as $IA) { $F_W = explode(' : ', $IA); //Zerlegung der Zeilen in Feld und Wert $fieldname = $F_W[0]; //Bereinigung des Feldnamen: $fieldname = str_replace(" ", "", $fieldname); //Leerzeichen entfernen $fieldname = str_replace("/", "", $fieldname); //Schraegstriche entfernen $fieldname = str_replace("-", "_", $fieldname); //Bindestrich des Meta-Tags durch Unterstrich ersetzen, da Tabellen-Feldnamen nur Unterstriche aufweisen duerfen if (count($F_W) > 1) { $value = trim($F_W[1]); } else { $value = ''; } if (in_array($fieldname, $tab_fieldname)) { //$value = formatValues($fieldname,$FN,$et_path); switch ($fieldname) { case 'DateTimeOriginal': $tmp_value = explode(" ", $value); $value = str_replace(':', '-', $tmp_value[0]) . " " . $tmp_value[1]; break; case 'FileSize': $value = shell_exec($exiftool . " -FileSize -n " . $FN); $fs_arr = explode(' : ', $value); $value = trim($fs_arr[1]); break; case 'GPSLatitude': $value = shell_exec($exiftool . " -c '%.11f' -GPSLatitude -n -s -s -s " . $FN); break; case 'GPSLongitude': $value = shell_exec($exiftool . " -c '%.11f' -GPSLongitude -n -s -s -s " . $FN); break; case 'GPSAltitude': $value = shell_exec($exiftool . " -c '%.11f' -GPSAltitude -n -s -s -s " . $FN); break; } //echo ">>> Feld ".$fieldname." hat den Wert ".$value."<BR>"; //Bildbreite- und Hoehe werden zur Sicherheit in 2 Felder (ExifImageHeight (Width) UND ImageHeight (WIdth)) geschrieben: if (($fieldname == 'ExifImageHeight' or $fieldname == 'ImageHeight') and ($value !== '0' and $value !== '')) { $result4 = mysql_query("UPDATE {$table14} SET ExifImageHeight = '{$value}', ImageHeight = '{$value}' WHERE pic_id = '{$pic_id}'"); } elseif (($fieldname == 'ExifImageWidth' or $fieldname == 'ImageWidth') and ($value !== '0' and $value !== '')) { $result4 = mysql_query("UPDATE {$table14} SET ExifImageWidth = '{$value}', ImageWidth = '{$value}' WHERE pic_id = '{$pic_id}'"); } elseif (($fieldname == 'ExifImageHeight' or $fieldname == 'ImageHeight' or $fieldname == 'ExifImageWidth' or $fieldname == 'ImageWidth') and ($value == '0' or $value == '')) { //keine Aktualisierung! } else { $value = utf8_decode($value); $result4 = mysql_query("UPDATE {$table14} SET {$fieldname} = '{$value}' WHERE pic_id = '{$pic_id}'"); $statement = "UPDATE {$table14} SET {$fieldname} = '{$value}' WHERE pic_id = '{$pic_id}'"; } if (mysql_error() !== '') { echo "Fehler beim speichern der Meta-Daten (" . $fieldname . ", " . $value . ", " . $statement . "): " . mysql_error() . "<BR>~~~~~~~~~~~~~~~~~~~~~~~~~~~<BR>"; } } } // Wenn Breite, Hoehe oder Dateigroesse nicht aus den EXIF-Daten ermittelt werden konnte, // wird versucht, dies per PHP-Routinen zu erledigen: $result9 = mysql_query("SELECT * FROM {$table14} WHERE pic_id = '{$pic_id}'"); $row = mysql_fetch_array($result9); $ImageWidth = $row['ImageWidth']; $ImageHeight = $row['ImageHeight']; $FileSize = $row['FileSize']; @($params = getimagesize($FN)); $breite = $params[0]; $hoehe = $params[1]; clearstatcache(); $FileSize = filesize($FN); //Dateigroesse der Originaldatei in Byte if ($ImageWidth == '0' or $ImageWidth == '') { $result10 = mysql_query("UPDATE {$table14} SET ImageWidth = '{$breite}' WHERE pic_id = '{$pic_id}'"); } if ($ImageHeight == '0' or $ImageHeight == '') { $result11 = mysql_query("UPDATE {$table14} SET ImageHeight = '{$hoehe}' WHERE pic_id = '{$pic_id}'"); } if ($FileSize == '0' or $FileSize == '') { $result12 = mysql_query("UPDATE {$table14} SET FileSize = '{$FileSize}' WHERE pic_id = '{$pic_id}'"); } $result13 = mysql_query("UPDATE {$table14} SET Orientation = '{$Orientation}' WHERE pic_id = '{$pic_id}'"); //echo mysql_error(); } //Wenn alle Meta-Daten in table14 uebernommen wurden, wird geprueft, ob Geo-Koordinaten dabei waren. //Wenn ja, wird eine neue location angelegt (in table12) und diese mit dem Bild referenziert: $result14 = mysql_query("SELECT * FROM {$table14} WHERE pic_id = '{$pic_id}'"); @($GPSLatitude = mysql_result($result14, 0, 'GPSLatitude')); @($GPSLongitude = mysql_result($result14, 0, 'GPSLongitude')); @($GPSAltitude = mysql_result($result14, 0, 'GPSAltitude')); if ($GPSLongitude !== NULL and $GPSLatitude !== NULL) { $result15 = mysql_query("INSERT INTO {$table12} (longitude, latitude, altitude) VALUES ('{$GPSLongitude}', '{$GPSLatitude}', '{$GPSAltitude}')"); echo mysql_error(); $loc_id = mysql_insert_id(); echo mysql_error(); $result16 = mysql_query("UPDATE {$table2} SET loc_id = '{$loc_id}' WHERE pic_id = '{$pic_id}'"); echo mysql_error(); } }
echo "Die Datenbank-Reorganisation wurde erfolgreich abgeschlossen."; //abschliessender Software-Check: checkSoftware($sr); //Bild-Ausrichtung in der Tabelle meta_data korrigieren: $res100 = mysql_query("SELECT {$table14}.*, {$table2}.pic_id, {$table2}.FileNameOri \n\t\t\t\t\t\t\t\t\t\tFROM {$table2}, {$table14} \n\t\t\t\t\t\t\t\t\t\tWHERE {$table2}.pic_id = {$table14}.pic_id"); $num100 = mysql_num_rows($res100); for ($i100 = 0; $i100 < $num100; $i100++) { $FNO = mysql_result($res100, $i100, 'FileNameOri'); //Bestimmung der Dateinamen-Extension $FN_elements = explode(".", $FNO); $anz = count($FN_elements); $FNO_extension = strtolower($FN_elements[$anz - 1]); //################################### $pic_id = mysql_result($res100, $i100, 'pic_id'); $FN = $pic_id . "." . $FNO_extension; $ETC = buildExiftoolCommand($sr); $command = $ETC . " -Orientation -n " . $pic_path . "/" . $FN; $or = shell_exec($command); $Ori_arr = preg_split('# : #', $or); if ($or !== NULL) { $Ori = $Ori_arr[1]; } else { $Ori = 0; } //echo $FN." / ".$Ori."<BR>"; //Ausrichtung in Tabelle meta_data speichern: $res101 = mysql_query("UPDATE {$table14} SET Orientation = '{$Ori}' WHERE pic_id = '{$pic_id}'"); if (mysql_error() == '') { //echo "Datensatz ".($i100 + 1)." von ".$num100."; Datei ".$FN." / Ausrichtung: ".$Ori."<BR>"; } else { echo "Es ist ein Fehler bei Datensatz " . ($i100 + 1) . " aufgetreten!:<BR>";