Großen Dank und Respekt an Oma, djw, Joey und all die anderen, die bei dieser tollen Bildergalerie mitgewirkt haben.
Ich habe mir aus allen threads eine lauffähige Version für 4.4.5 gebastelt.
Die Bilder liegen bei mir unter upload/galerie/galerie01, upload/galerie/galerie02 usw. In den Unterordnern galerie01 usw befindet sich jeweils ein Ordner thm für die thumbs.
Contenido liegt im Verzeichnis 44 im root. Siehe:
http://www.jubec.de/44/cms siehe Fotoalbum
Meine Bilder haben derzeit eine Größe von 500x375
picture.php in das Verzecihnis cms auf Ebene wie front_content.php
Code: Alles auswählen
<?php
include_once ("config.php");
include_once ($contenido_path . "includes/config.php");
cInclude("includes", "cfg_sql.inc.php");
cInclude("includes", "functions.general.php");
cInclude("includes", "functions.i18n.php");
cInclude("includes", "functions.tpl.php");
cInclude("includes", "functions.con.php");
cInclude("includes", "functions.mod.php");
cInclude("includes", "functions.api.php");
cInclude("classes", 'class.inuse.php');
cInclude("classes", 'class.user.php');
cInclude("classes", 'class.notification.php');
cInclude("classes", 'class.table.php');
//config-variable verwenden!
$db_album = $cfg["tab"]["fotoalbum"];
$db_fotos = $cfg["tab"]["fotos"];
if (!$album) {
$db_album = new DB_contenido;
$sqlC = "SELECT * FROM ".$cfg["tab"]["fotoalbum"]." WHERE idart = ".$idart;
$db_album->query($sqlC);
$db_album->next_record();
$album = $db_album->f("album_id");
$img_dir = "upload/galerie/".$db_album->f("album_dir")."/";
}
//echo "Gewähltes Album: ".$album."<br>";
$dbA = new DB_contenido;
$sqlA = "SELECT * from ".$cfg["tab"]["fotos"]." WHERE album_id = ".$album." ORDER by foto_pos";
$dbA->query($sqlA);
$x = $dbA->num_rows();
//echo "Anzahl Bilder: ".$x."<br>";
$bilder = array();
$i = 0;
while ($dbA->next_record()) {
$img_id = $dbA->f("foto_id");
$img_filename = $dbA->f("filename");
array_push($bilder, $img_id."-".$img_filename);
if (($picture) && ($img_id == $picture)) { $img_to_show = $i; }
$i++;
}
if (!$img_to_show) { $img_to_show = 0; }
$prev = ($img_to_show - 1);
if ($prev < 0) { $prev = ($x - 1); }
$next = ($img_to_show + 1);
if ($next > $x) { $next = 0; }
$curr_img = split("-", $bilder[$img_to_show]);
//$curr_img = $curr_img[1];
$next_img = split("-", $bilder[$next]);
$next_img = $next_img[0];
$prev_img = split("-", $bilder[$prev]);
$prev_img = $prev_img[0];
if ($contenido) {
$next_link = 'picture.php?idart='.$idart.'&picture='.$next_img.'&contenido='.$contenido;
$prev_link = 'picture.php?idart='.$idart.'&picture='.$prev_img.'&contenido='.$contenido;
} else {
$next_link = 'picture.php?idart='.$idart.'&picture='.$next_img;
$prev_link = 'picture.php?idart='.$idart.'&picture='.$prev_img;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/format.css">
<link rel="stylesheet" type="text/css" href="css/content.css">
<style type="text/css">
body {
margin: 0px;
background: #eeeeee;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
echo '
<table width="100%" cellpadding=0 cellspacing=0 border=0>
<tr>
<td colspan=2 align=center height=287><img src = "'.$img_dir.$curr_img[1].'"></td>
</tr>
<tr>
<td class=klein style="width:50%; margin:0px; padding:0px; text-align:left"><a href="'.$prev_link.'"><img align=absmiddle src="upload/images/arrow_l.gif" border=0 style="margin:5px;">zurück</a></td>
<td class="klein" style="width:50%; margin:0px; padding:0px; text-align:right;"><a href="'.$next_link.'">weiter<img align=absmiddle src="upload/images/arrow_r.gif" border=0 style="margin:5px;"></a></td>
</tr>
';
$dbF = new DB_contenido;
$sqlF = "SELECT * from ".$cfg["tab"]["fotos"]." WHERE foto_id = ".$curr_img[0];
$dbF->query($sqlF);
if ($dbF->num_rows() != 1) {
echo "Unbekannter Fehler!";
} else {
$dbF->next_record();
$fotopos = $dbF->f("foto_pos");
$text = $dbF->f("foto_text");
}
if ($contenido) {
echo '<tr><td colspan=2><form method="post" action="front_content.php?changeview=edit&client=1&lang=1&action=con_editart&idartlang=89&type=&typenr=&idart='.$idart.'" target="right_bottom">
<input type="hidden" name="picture" id="picture" value="'.$curr_img[0].'">
<input type="hidden" name="contenido" id="contenido" value="'.$contenido.'">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan=4 align=center><textarea class=box style="height:100px; width:380px;" name=foto_text id=foto_text>'.$text.'</textarea></td>
</tr>
<tr>
<td>Pos.: <input class=field style="width:30px;" type=text name=foto_pos id=foto_pos value="'.$fotopos.'"></td>
<td><input type="submit" class=button name="Absenden" id="Absenden" value="Ändern"></td>
<td><input type="submit" class=button name="Absenden" id="Absenden" value="Löschen" style=background:#bb0000; color:#ffffff;"></td>
<td> </td>
</tr>
</table></form>
</td></tr>';
} else {
echo '<tr><td colspan=2><p style="padding-left:5px; padding_right:5px; margin:0px; margin-top:15px;">'.$text.'</p></td></tr>';
}
echo '</table>
';
?>
</body>
</html>
input
Code: Alles auswählen
/********************editierbare variable ***************************/
$db_album = $cfg["tab"]["fotoalbum"];
$db_fotos = $cfg["tab"]["fotos"];
$upldir = "upload/galerie/";
//thumbnailgröße
$max_hoehe = "70";
$max_breite = "93";
//anzahl der angezeigten thumbnails
$bps = "10";
//ToDo: Datenbankname ersetzen
//To Do: Auswahl Thumnailanzeige und Größe in Konfiguration
/********************************************************************/
//ToDo-Abfrage 1
if ((!$ToDo) || ($ToDo == "")) {
$dbA = new DB_contenido;
$sqlA = "SELECT * from $db_album WHERE idart = ".$idart." AND idcat = ".$idcat;
$dbA = mysql_query($sqlA);
if (mysql_num_rows($dbA) == 1) {
$ToDo = "show";
} else if (mysql_num_rows($dbA) == 0) {
$ToDo = "neu";
} else {
$ToDo = "error";
}
}//end if (!ToDo);
//ToDo-Abfrage 2
if ($ToDo == "new_album") {
if (($album_dir == "nix") || ($album_dir == "delete_album")) { $fehler = "Sie müssen einen Ordner auswählen!"; }
if ((!$fehler) && ((!$album_title) || ($album_title == ""))) { $fehler = "Die Fotogalerie braucht einen Namen!"; }
if ((!$fehler) && ((!$album_datum) || ($album_datum == ""))) { $fehler = "Bitte geben sie ein Datum an."; }
if (!fehler) {
$dbA = new DB_contenido;
$sqlA = "SELECT * from $db_album WHERE album_dir = '".$album_dir."'";
$dbA->query($sqlA);
if (mysql_num_rows($dbA) != 0) { $fehler = "Für diesen Ordner existiert bereits ein Album."; }
}
if (!$fehler) {
$img_path = dir($cfgClient[$client]["path"]["frontend"].$upldir.$album_dir);
$alle = array();
while ($ergebnis=$img_path->read()) {
if ($ergebnis != "." and $ergebnis != "..") {
array_push($alle, $ergebnis);
}
}
//$bild = preg_grep("/.+\.(gif)|(jpg)/",$alle);
$bild = preg_grep("/.+\.(jpg)/i",$alle);
if (count($bild) <= 0) { $fehler = "Der Ordner enthält keine Bilder"; }
}
if (!$fehler) {
$dbA_update = "INSERT INTO ".$db_album." ".
"(album_datum, album_title, idart, idcat, album_dir) ".
"VALUES ('$album_datum','$album_title','$idart','$idcat','$album_dir')";
if (!$db->query($dbA_update)) {
$fehler = "Beim Datenbankeintrag traten Probleme auf.";
}
}
if (!$fehler) {
$dbA = new DB_contenido;
$sqlA = "SELECT * from $db_album WHERE idart = ".$idart." AND idcat = ".$idcat;
$dbA = mysql_query($sqlA);
if (mysql_num_rows($dbA) != 1) {
$fehler = "Album zwar angelegt, aber nicht gefunden: ".$sqlA;
} else {
$ausgabe = mysql_fetch_array($dbA);
$album_id = $ausgabe[album_id];
}
}
if (!$fehler) {
$thm_new_dir = $cfgClient[$client]["path"]["frontend"].$upldir.$album_dir."/thm";
if(!$thm_dir = is_dir($thm_new_dir)) {
$thm_dir = mkdir($thm_new_dir, 0777);
}
if(!thm_dir) { $fehler = "Konnte Thumbnail-Verzeichnis nicht erstellen: ".$thm_new_dir; }
}
/*
//thumnails erzeugen
if (!$fehler) {
foreach ($bild as $einzelbild) {
$im = imagecreatefromjpeg($cfgClient[$client]["path"]["frontend"].$upldir.$album_dir."/" .$einzelbild);
list($src_width, $src_height) = getimagesize($cfgClient[$client]["path"]["frontend"].$upldir.$album_dir."/" .$einzelbild);
if($src_width > $src_height) {
$new_image_width = $max_breite;
$new_image_height = $src_height * $max_breite / $src_width;
}
if($src_width <= $src_height) {
$new_image_height = $max_hoehe;
$new_image_width = $src_width * $max_hoehe / $src_height;
}
$new_image = imagecreatetruecolor($new_image_width, $new_image_height);
imagecopyresampled($new_image, $im, 0, 0, 0, 0, $new_image_width,$new_image_height, $src_width, $src_height);
if (!imagejpeg($new_image, $thm_new_dir."/".$einzelbild, 40)) {
$fehler = "Konnte Thumb nicht erstellen: ".$thm_new_dir."/".$einzelbild."<br>";
} else {
$dbA_entry = "INSERT INTO ".$db_fotos." ".
"(filename, album_id, album_dir, idart) ".
"VALUES ('$einzelbild', '$album_id', '$album_dir', '$idart')";
if (!$db->query($dbA_entry)) { $fehler = "Beim Datenbankeintrag traten Fehler auf: ".$sql_entry; }
}
}//end foreach
}
*/
//thumnails erzeugen
if (!$fehler) {
foreach ($bild as $einzelbild) {
$im = imagecreatefromjpeg($cfgClient[$client]["path"]["frontend"].$upldir.$album_dir."/" .$einzelbild);
list($src_width, $src_height) = getimagesize($cfgClient[$client]["path"]["frontend"].$upldir.$album_dir."/" .$einzelbild);
if($src_width > $src_height) {
$new_image_width = $max_breite;
$new_image_height = $src_height * $max_breite / $src_width;
}
if($src_width <= $src_height) {
$new_image_height = $max_hoehe;
$new_image_width = $src_width * $max_hoehe / $src_height;
}
$new_image = imagecreatetruecolor($new_image_width, $new_image_height);
imagecopyresized($new_image, $im, 0, 0, 0, 0, $new_image_width,$new_image_height, $src_width, $src_height);
if (!imagejpeg($new_image, $thm_new_dir."/".$einzelbild, 40)) {
$fehler = "Konnte Thumb nicht erstellen: ".$thm_new_dir."/".$einzelbild."<br>";
} else {
$dbA_entry = "INSERT INTO ".$db_fotos." ".
"(filename, album_id, album_dir, idart, idcat) ".
"VALUES ('$einzelbild', '$album_id', '$album_dir', '$idart', '$idcat')";
if (!$db->query($dbA_entry)) { $fehler = "Beim Datenbankeintrag traten Fehler auf: ".$sql_entry; }
}
}//end foreach
}
if ($fehler) {
echo '<span style="color:red; font-weight: bold;">'.$fehler.'</span>';
$ToDo = "neu";
} else {
echo "Galerie erfolgreich angelegt!";
$dbA = new DB_contenido;
$sqlA = "SELECT * from $db_album WHERE idart = ".$idart." AND idcat = ".$idcat;
$dbA = mysql_query($sqlA);
$ToDo = "show";
}
}//ende if $ToDo == new_album
if ($ToDo == "update_album") {
$dbA = new DB_contenido;
$sqlA = "SELECT * from $db_album WHERE idart = ".$idart." AND idcat = ".$idcat;
$dbA = mysql_query($sqlA);
if (mysql_num_rows($dbA) != 1) { $fehler = "Kein Album gefunden."; }
if (!$fehler) {
if ($album_dir == "delete_album") {
$sql_delete = "DELETE from ".$db_album." WHERE idart = $idart"." AND idcat = ".$idcat;
if (!$db->query($sql_delete)) {
echo "Beim Datenbankeintrag traten Probleme auf.";
$ToDo = "show";
$dbA = mysql_query($sqlA);
} else {
$sql_delete_fotos = "DELETE from ".$db_fotos." WHERE idart = $idart"." AND idcat = ".$idcat;
if (!$db->query($sql_delete_fotos)) {
echo "Beim Löschen der Fotoeinträge traten Probleme auf!";
} else {
echo "Album und Fotoeinträge wurden gelöscht.";
$ToDo = "neu";
}
}
} else if ($album_dir == "nix") {
echo "Kein Albumverzeichnis angegeben!";
$ToDo = "show";
} else {
$ausgabe = mysql_fetch_array($dbA);
$old_dir = $ausgabe[album_dir];
if ($old_dir != $album_dir) {
echo "Um das Verzeichnis eines Albums zu ändern, bitte Album löschen und neu anlegen!";
$ToDo = "show";
$dbA = mysql_query($sqlA);
} else {
$sql_change = "UPDATE ".$db_album." ".
"SET album_datum = '$album_datum',album_title='$album_title',album_dir ='$album_dir' ".
"WHERE idart = $idart"." AND idcat = ".$idcat;
if (!$db->query($sql_change)) {
echo "Beim Datenbankeintrag traten Probleme auf.";
} else {
echo "Eintrag wurde geändert.";
}
$ToDo = "show";
$dbA = mysql_query($sqlA);
}
}
} else {
echo '<span style="color:red; font-weight: bold;">'.$fehler.'</span>';
}
}//ende toDo = update_album
if ($ToDo == "show") {
echo '<br>Für diesen Artikel ist folgende Galerie angelegt:
<input type="hidden" name="ToDo" id="ToDo" value="update_album">';
$ausgabe = mysql_fetch_array($dbA);
$adatum = $ausgabe[album_datum];
$atitle = $ausgabe[album_title];
$adir = $ausgabe[album_dir];
} else if ($ToDo == "neu") {
echo '<br>Neue Fotogalerie anlegen:
<input type="hidden" name="ToDo" id="ToDo" value="new_album">';
$adatum = date(Y).'-'.date(m).'-'.date(d);
$atitle = "Neues Album";
$adir = "nix";
} else if ($ToDo == "error") {
echo '<p> Ein Fehler ist aufgetreten.</p>';
}
echo' <table width="100%" border="0" cellpadding="5">
<tr>
<td class="normal">Datum</td>
<td class="normal">Name</td>
<td class="normal">Pfad: upload/galerie/... </td>
</tr>';
/**************************start input ************************/
echo'
<tr>
<td valign="top"><input name="album_datum" type="text" class="field" value="'.$adatum.'"><br>
<span style="color:red;">Bitte auf das <br>Datumsformat achten!</span></td>
<td valign="top"><input name="album_title" type="text" class="field2" value="'.$atitle.'"></td>
<td valign="top"><select name="album_dir" class="field">
<option value="nix">Ordner wählen</option>';
/**************************directory auslesen *****************/
$d = dir($cfgClient[$client]["path"]["frontend"].$upldir);
while($entry=$d->read()) {
if ($entry != "." and $entry !="..") {
echo '<option value="'.$entry.'"';
if ($adir == $entry) { echo ' selected'; }
echo '>'.$entry.'</option>';
}
}
$d->close();
/************************ende directory auslesen ***************/
echo'<option value="delete_album">Galerie löschen</option></select></td>
</tr>
</table>
';
output
Code: Alles auswählen
<?php
/******************** editierbare variable ***************************/
$db_album = $cfg["tab"]["fotoalbum"];
$db_fotos = $cfg["tab"]["fotos"];
$upldir = "upload/galerie/";
//anzahl der angezeigten thumbnails
$fps = "10";
/*********************************************************************/
//fotoupdate
if ($Absenden = "Ändern") {
$sql_update = "UPDATE ".$cfg["tab"]["fotos"]." SET foto_pos='$foto_pos',foto_text='$foto_text' WHERE foto_id = '".$picture."'";
$db->query($sql_update);
}
//galerie finden
$dbA = new DB_contenido;
$sqlA = "SELECT * from $db_album WHERE idart = ".$idart;
$dbA = mysql_query($sqlA);
if (mysql_num_rows($dbA) != 1) {
$fehler = "Keine Fotogalerie gefunden";
} else {
$album = mysql_fetch_array($dbA);
$album_id = $album[album_id];
$img_dir = $upldir.$album[album_dir]."/";
$thm_dir = $img_dir."thm/";
}
if (!$fehler) {
$dbF = new DB_contenido;
$sqlF = "SELECT * from $db_fotos WHERE album_id = ".$album_id;
$dbF->query($sqlF);
if ($dbF->num_rows() < 1) {
$fehler = "Keine Fotos zu dieser Galerie gespeichert.";
} else {
$alle_fotos = $dbF->num_rows();
}
}
if ($fehler) {
exit ('<p style="color:red; font-weight: bold;">'.$fehler.'</span>');
}
//##########-Navigation-###########
$meineseite=$auth->url();
$seiten = ceil($alle_fotos / $fps);
switch ($eintrag) { // das erste mal beim aufruf ist $eintrag undefiniert
case "";
$eintrag = "0"; // deswegen wertzuweisung 0
}
$max = ($eintrag + $fps);
if ($max > $alle_fotos) {
$last = $alle_fotos;
} else {
$last = $max;
}
//##########-Output-##########
$nav1 = "<tr><td colspan=2 height=20 align=center class=klein bgcolor=#ffcc00><strong>";
$nav2 = "<tr><td align=center colspan=2 class=klein bgcolor=#ffcc00><strong>";
if ($max >= $fps) {
$nav1 .= "Fotos ".($eintrag+1)."-".($last)." von ".$alle_fotos;
$nav2 .= 'Seite';
$currpage = ($max / $fps);
for ($i = 0; $i < $seiten; $i++) {
if (($i+1) == $currpage) {
$nav2 .= '</strong> | '.($i+1);
} else {
$nav2 .= '</strong> | <strong><a href="'.$meineseite.'&eintrag='.(($i)*$fps).'">'.($i+1).'</a></strong>';
}
}//end for
$nav2 .= ' |';
} else {
$nav1 .= "Fotos ".($eintrag+1)."-".($alle_fotos)." von ".$alle_fotos;
}
$nav1 .= "</strong></td></tr>";
$nav2 .= "</td></tr>";
//##########-HTML-Output-##########
echo '
<table width="708" border="0" cellspacing="0" cellpadding="0" style="padding-top:0px; margin-top:0px;">
<tr>
<td width="208" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="fotos">
';
echo $nav1.'<tr>';
//ausgabe thumbnails
$dbF_limited = new DB_contenido;
$sqlF_limited = "SELECT * from $db_fotos WHERE album_id = ".$album_id." ORDER by foto_pos LIMIT ".$eintrag.",".$fps;
$dbF_limited->query($sqlF_limited);
$count = "0";
while ($dbF_limited->next_record()) {
$link = "idart=".$idart."&picture=".$dbF_limited->f("foto_id");
if ($contenido) { $link .= '&contenido='.$contenido; }
$img = $img_dir.$dbF_limited->f("filename");
$thumb = $thm_dir.$dbF_limited->f("filename");
echo '<td align="center"><a href="picture.php?'.$link.'" target="hauptbild"><img border=0 vspace=3 src="'.$thumb.'"></a></td>';
$count++;
if ($count == 2) {
echo '</tr><tr>';
$count = 0;
}
}
echo '</tr>'.$nav2.'
</table></td>
<td width="500" align="right" valign="top"><iframe name="hauptbild" src="picture.php?client=1&lang=1&idcat='.$idcat.'&idart='.$idart;
if ($contenido) { echo '&contenido='.$contenido; }
if ($picture) { echo '&picture='.$picture; }
echo '" height="538" width="500" scrolling="no" border="0" frameborder="0" style="background:#eeeeee; padding:0px; margin-top:0px;">
</iframe></td>
</tr>
</table>
';
//##########-HTML-Output Ende-##########
?>
Zusatzeintrag in cfg_sql.inc.php in contenido/includes:
Code: Alles auswählen
$cfg["tab"]["fotoalbum"] = $cfg['sql']['sqlprefix']."_fotoalbum";
$cfg["tab"]["fotos"] = $cfg['sql']['sqlprefix']."_fotos";
SQL insert. Damit neue Tabellen anlegen:
Code: Alles auswählen
CREATE TABLE `con_fotos` (
`foto_id` int(1) NOT NULL auto_increment,
`foto_pos` int(1) NOT NULL default '99',
`filename` varchar(40) NOT NULL default '',
`foto_text` text NOT NULL,
`album_id` int(1) NOT NULL default '0',
`album_dir` varchar(40) NOT NULL default '',
`idart` int(1) NOT NULL default '0',
`idcat` int(6) NOT NULL default '0',
PRIMARY KEY (`foto_id`)
) TYPE=MyISAM AUTO_INCREMENT=144 ;
CREATE TABLE `con_fotoalbum` (
`album_id` int(1) NOT NULL auto_increment,
`album_title` varchar(200) NOT NULL default '',
`album_dir` varchar(40) NOT NULL default '',
`album_datum` date NOT NULL default '0000-00-00',
`idart` int(1) NOT NULL default '0',
`idcat` int(6) NOT NULL default '0',
PRIMARY KEY (`album_id`)
) TYPE=MyISAM AUTO_INCREMENT=3 ;
Vielleicht kann ich durch meine Fleißarbeit einigen anderen Anfängern (so wie ich) helfen.
Gruß Mc