Fotoalbum

Gesperrt
saschar
Beiträge: 141
Registriert: Mo 21. Okt 2002, 14:37
Wohnort: Dornbirn, A
Kontaktdaten:

Beitrag von saschar »

ich weiss eigentlich auch nicht mehr genau, welche das war.
stelle hier einfach mal den code rein.

INPUT

Code: Alles auswählen

/********************editierbare variable ***************************/
$db_album = $cfg["tab"]["fotoalbum"];
$db_fotos = $cfg["tab"]["fotos"];
$upldir = "/cms/upload/galerie/";
//thumbnailgröße
$max_hoehe = "90";
$max_breite = "116";
//anzahl der angezeigten thumbnails
$bps = "9";

//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;
  $dbA->query($sqlA);
    if ($dbA->num_rows() == 1)  {
      $ToDo = "show";
    } else if ($dbA->num_rows() == 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 ($dbA->num_rows() != 0) { $fehler = "Für diesen Ordner existiert bereits ein Album.";  }
  }
  if (!$fehler)  {
    $img_path = dir($cfg['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);
    if (count($bild) <= 0)  {  $fehler = "Der Ordner enthält keine Bilder";  }
  }
  if (!$fehler)  {
        $dbA_update = "INSERT INTO ".$db_album." ".
            "(album_datum, album_title, idart, album_dir) ".
            "VALUES ('$album_datum','$album_title','$idart','$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;
    $dbA->query($sqlA);
      if ($dbA->num_rows() != 1) {
        $fehler = "Album zwar angelegt, aber nicht gefunden: ".$sqlA;
      } else  {
        $dbA->next_record();
        $album_id = $dbA->f("album_id");
      }
  }
  if (!$fehler)  {
  $thm_new_dir = $cfg['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($cfg['path']['frontend'].$upldir.$album_dir."/" .$einzelbild);
      list($src_width, $src_height) = getimagesize($cfg['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, 100)) {
        $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
  }

  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;
    $dbA->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;
  $dbA->query($sqlA);
    if ($dbA->num_rows() != 1) { $fehler = "Kein Album gefunden.";  }
    if (!$fehler)  {
       if ($album_dir == "delete_album")  {
         $sql_delete = "DELETE from ".$db_album." WHERE idart = $idart";
         if (!$db->query($sql_delete))  {
           echo "Beim Datenbankeintrag traten Probleme auf.";
           $ToDo = "show";
           $dbA->query($sqlA);
         }  else  {

           $sql_delete_fotos = "DELETE from ".$db_fotos." WHERE idart = $idart";
           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  {
         $dbA->next_record();
         $old_dir = $dbA->f("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->query($sqlA);
         }  else  {
           $sql_change = "UPDATE ".$db_album." ".
            "SET album_datum = '$album_datum',album_title='$album_title',album_dir ='$album_dir' ".
            "WHERE idart = $idart";
           if (!$db->query($sql_change))  {
             echo "Beim Datenbankeintrag traten Probleme auf.";
           }  else  {
             echo "Eintrag wurde geändert.";
           }
           $ToDo = "show";
           $dbA->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">';
  $dbA->next_record();
  $adatum = $dbA->f("album_datum");
  $atitle = $dbA->f("album_title");
  $adir = $dbA->f("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 *****************/

if ($d = @dir($cfg['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();
} else {

}
/************************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 = "/cms/upload/galerie/";

//anzahl der angezeigten thumbnails
$fps = "9";

/*********************************************************************/
//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=left colspan=2 class=klein bgcolor=#ffffff>";
if ($max >= $fps)  {
//  $nav1 .= "Fotos ".($eintrag+1)."-".($last)." von ".$alle_fotos;
  $nav2 .= '';
  $currpage = ($max / $fps);
  for ($i = 0; $i < $seiten; $i++)  {
    if (($i+1) == $currpage)  {
      $nav2 .= '</strong>|&nbsp;'.($i+1);
    }  else {
      $nav2 .= '</strong>|&nbsp;<strong><a href="'.$meineseite.'&eintrag='.(($i)*$fps).'">'.($i+1).'</a></strong>';
    }
  }//end for
  $nav2 .= '&nbsp;|';
//}  else  {
//  $nav1 .= "Fotos ".($eintrag+1)."-".($alle_fotos)." von ".$alle_fotos;
}

$nav1 .= "</strong></td></tr>";
$nav2 .= "</td></tr>";
//##########-HTML-Output-##########
echo '
  <table width="704"  border="0" cellspacing="0" cellpadding="0" style="padding-top:0px; margin-top:0px;">
  <tr>
    <td width="348" 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=0 src="'.$thumb.'"></a></td>';
    $count++;
    if ($count == 3)  {
      echo '</tr><tr>';
      $count = 0;
    }
  }
echo '</tr>'.$nav2.'
    </table></td>
    <td width="8"></td><td width="348" 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="285" width="348" scrolling="no" border="0" frameborder="0" style="background:#ffffff; padding:0px; margin-top:0px;">
    </iframe></td>
  </tr>
</table>
';
//##########-HTML-Output Ende-##########
?>
Und dann gibt es noch die

PICTURE.PHP

Code: Alles auswählen

<?php
include_once ("config.php");
include_once ($contenido_path . "includes/startup.php");

cInclude("includes", "functions.general.php");

cInclude("includes", "functions.i18n.php");
cInclude("includes", "functions.con.php");
cInclude("includes", "functions.con2.php");
cInclude("includes", "functions.api.php");
cInclude("includes", "functions.pathresolver.php");

cInclude("classes", "class.user.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">

<style type="text/css">
body  {
  margin: 0px;
  background: #ffffff;
}
</style>

<title>ANDY SILLABER . Photography + Video</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body>
<?php
echo '
  <table width="348px" cellpadding=0 cellspacing=0 border=0>
  <tr>
    <td colspan=2 align=center height=270><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.'">zur?ck</a></td>
        <td class="klein" style="width:50%; margin:0px; padding:0px; text-align:right;"><a href="'.$next_link.'">weiter</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="/contenido/external/backendedit/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:348px;" name=foto_text id=foto_text>'.$text.'</textarea></td>
      </tr>
      <tr>
        <td>Pos.:&nbsp;<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:red; color:#ffffff;"></td>
        <td>&nbsp;</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>
Für die Datenbank dann noch:


Hilft dir das weiter...

Code: Alles auswählen

$cfg["tab"]["fotoalbum"] = $cfg['sql']['sqlprefix']."_fotoalbum";
$cfg["tab"]["fotos"] = $cfg['sql']['sqlprefix']."_fotos";
Oder dann war es ursprünglich noch dieses Fotoalbum:


http://contenido.org/forum/viewtopic.ph ... =fotoalbum


Gruß
Sascha
Halchteranerin
Beiträge: 5478
Registriert: Di 2. Mär 2004, 21:11
Wohnort: Halchter, wo sonst? ;-)
Kontaktdaten:

Beitrag von Halchteranerin »

Ich habe keine Ahnung, zu welchem Thread das obige Posting gehoert, aber mit dem Thread "Terminübersicht für die Startseite einer Site" hat es garantiert nichts zu tun, deswegen habe ich es dort rausgenommen.
Gesperrt