#! /usr/bin/perl
$pfad=$ENV{SCRIPT_FILENAME};
$pfad=~ s/^(.*\/)(.*?)$/\1/g;
if ($pfad eq "") {$pfad='./'};
#print "Pfad $pfad\n";
require("$pfad/fotoblog_module.cgi");
use Encode qw(encode decode);
$enc='utf-8';
&writeheader;
&config;
$EINGABE=$ENV{'QUERY_STRING'};
@REWRITE=split(/\-/,$EINGABE);
$anzahl = @REWRITE;
$BILDNR=$REWRITE[$anzahl-1];
#$BILDNR=$REWRITE[0];
$BILDNR=$BILDNR*1;
$content="";
### == 0 -> Uebersicht)
if ($BILDNR == 0)
{
#&adsense728;
$content=$content.'
'.$FOTOBLOG_NAME.'
';
$content=$content.'';
#date_format(date(datum),'%d.%m.%Y'), date_format(uhrzeit,'%H:%i'),
$query=$dbh->prepare("select id, titel, story,date_format(datumzeit,'%d.%m.%Y') from fotoblog_data where aktiv='J' order by id desc");
#Layout waehlen
if ($GALERIE_SPALTEN == 1) {&layout1};
if ($GALERIE_SPALTEN == 2) {&layout2};
if ($GALERIE_SPALTEN == 3) {&layout3};
if ($GALERIE_SPALTEN == 4) {&layout4};
if ($GALERIE_SPALTEN == 5) {&layout5};
if ($GALERIE_SPALTEN == 6) {&layout6};
$content=$content.'
';
$LAYOUT=~s /\@\@TITLE\@\@/$FOTOBLOG_NAME/ig;
$head=&header('','','','','');
$LAYOUT=~s /\@\@HEADER\@\@/$head/ig;
#&adsense728;
#Bei Galerieansicht kein Bilddatum, also HEUTE
$query=$dbh->prepare("select date_format(now(),'%d.%m.%Y')");
$query->execute || print DBI::errstr;
while (@abfrage=$query->fetchrow_array)
{
$HEUTE=$abfrage[0];
}
$LAYOUT=~s /\@\@IMGDATE\@\@/($HEUTE)/ig;
}
# > 0 -> Einzelbild
if ($BILDNR != 0)
{
#date_format(date(datum),'%d.%m.%Y'), date_format(uhrzeit,'%H:%i'),
$query=$dbh->prepare("select id,titel,story,date_format(datumzeit,'%d.%m.%Y'),keywords,description,geo_region, geo_placename,geo_latitude,geo_longitude from fotoblog_data where id='$BILDNR'");
$query->execute || print DBI::errstr;
while (@abfrage=$query->fetchrow_array)
{
$ID=$abfrage[0];
$dbtitel=encode($enc,$abfrage[1]);
$pinterest_desc=encode($enc,$abfrage[1]);
$pinterest_desc=&noentity($pinterest_desc);
$dbstory="";
if ($abfrage[2] ne "") {$dbstory=encode($enc,$abfrage[2])};
$dbkeywords=encode($enc,$abfrage[4]);
$dbdescription=encode($enc,$abfrage[5]);
$dbdatum=$abfrage[3];
$dbgeoregion=$abfrage[6];
$dbgeoplacename=encode($enc,$abfrage[7]);
$db_lat=$abfrage[8];
$db_long=$abfrage[9];
}
$query->finish;
$LAYOUT=~s /\@\@TITLE\@\@/$dbtitel/ig;
$head=&header($dbkeywords,$dbdescription,$dbgeoregion,$dbgeoplacename,$db_lat,$db_long);
$LAYOUT=~s /\@\@HEADER\@\@/$head/ig;
$LAYOUT=~s /\@\@IMGDATE\@\@/($dbdatum)/ig;
#Alt-Tag des Bildes mit oder ohne Datum
#$alttext=$dbtitel." ".$dbdatum;
$alttext=$dbtitel;
$alttext=~s /\"//ig;
$vollbild=$FOTOBLOG_URL.'/'.$FULLSIZE_DIR.'/'.sprintf('%06d',$ID).'.jpg';
$preview=$FOTOBLOG_URL.'/'.$PREVIEW_DIR.'/'.sprintf('%06d',$ID).'.jpg';
$content=$content.''.$dbtitel.'
';
$content=$content.'';
#anzeige kleines Bild
#$content=$content.' Vollbild / Zoom | '.$dbtitel.'
'.$dbstory.' ('.$dbdatum.') |
';
#anzeige grosses Bild
$content=$content.'
|
'.$dbstory.' ('.$dbdatum.') |
';
$content=$content.'
';
$content=$content.&prevpic($BILDNR);
$content=$content.' Zurück zur Galerie ';
$content=$content.&nextpic($BILDNR);
$content=$content.'
';
#etwas socializing
$url=&talkingurl($ID,$dbtitel);
# per Email
$content=$content.'Foto per Email weiterempfehlen ';
#per Facebook
$content=$content.&facebook_share($url,$preview);
#per Google+
$content=$content.&google_share($url);
#per Twitter
$content=$content.&twitter_share($url);
#per Pinterest
$content=$content.&pinterest_share($url,$preview,$pinterest_desc);
###MAPS $content=$content.'
$content=$content.'
';
}
#Werbung aktivieren
#&adsense728;
$LAYOUT=~s /\@\@CONTENT\@\@/$content/ig;
print $LAYOUT;
#####################################################
sub nextpic
{
my $picid, $nextid,$nexttitel;
$picid=$_[0];
$nextid="";
$query=$dbh->prepare("select id,titel from fotoblog_data where id>'$picid' and aktiv='J' order by id limit 0,1");
$query->execute || print DBI::errstr;
while (@abfrage=$query->fetchrow_array)
{
$nextid=$abfrage[0];
$nexttitel=encode($enc,$abfrage[1]);
}
$query->finish;
#wenn es ein Bild mit einer hoeheren ID gibt....
if ($nextid ne "")
{
$htmlcode=' »'.$nexttitel.' ';
}
else
{
#wenn es kein Bild mit einer hoeheren ID gibt, nimm die niedrigste Bildnummer als naechstes
$query=$dbh->prepare("select id,titel from fotoblog_data where aktiv='J' order by id limit 0,1");
$query->execute || print DBI::errstr;
while (@abfrage=$query->fetchrow_array)
{
$nextid=$abfrage[0];
$nexttitel=encode($enc,$abfrage[1]);
}
$query->finish;
#wenn es ein Bild gibt....
if ($nextid ne "")
{
$htmlcode=' »'.$nexttitel.' ';
}
}
return $htmlcode;
}
###################################################
sub prevpic
{
my $picid, $nextid,$nexttitel;
$picid=$_[0];
$nextid="";
$query=$dbh->prepare("select id,titel from fotoblog_data where id<'$picid' and aktiv='J' order by id desc limit 0,1");
$query->execute || print DBI::errstr;
while (@abfrage=$query->fetchrow_array)
{
$nextid=$abfrage[0];
$nexttitel=encode($enc,$abfrage[1]);
}
$query->finish;
#wenn es ein Bild mit einer hoeheren ID gibt....
if ($nextid ne "")
{
$htmlcode=''.$nexttitel.'« ';
}
else
{
#wenn es kein Bild mit einer hoeheren ID gibt, nimm die niedrigste Bildnummer als naechstes
$query=$dbh->prepare("select id,titel from fotoblog_data where aktiv='J' order by id desc limit 0,1");
$query->execute || print DBI::errstr;
while (@abfrage=$query->fetchrow_array)
{
$nextid=$abfrage[0];
$nexttitel=encode($enc,$abfrage[1]);
}
$query->finish;
#wenn es ein Bild gibt....
if ($nextid ne "")
{
$htmlcode=''.$nexttitel.'« ';
}
}
return $htmlcode;
}
####################################################
sub adsense728
{
$dummycode='';
#
#
#
#
';
$dummycode="";
$LAYOUT=~s /\@\@728x90\@\@/$dummycode/ig;
}
################################################
# Einfaches, einspaltiges Layout
sub layout1
{
$query->execute || print DBI::errstr;
while (@abfrage=$query->fetchrow_array)
{
$ID=$abfrage[0];
$dbtitel=&entity($abfrage[1]);
$dbdatum=&mysqldatumuhrzeit($abfrage[3]);
$alttext=$abfrage[1]." ".$dbdatum;
$alttext=~s /\"//ig;
$dbstory="";
if ($abfrage[2] ne "") {$dbstory=&entity(&vorschautext($abfrage[2],$STORY_PREVIEW))."..."};
$vollbild=$FULLSIZE_DIR.'/'.sprintf('%06d',$ID).'.jpg';
$preview=$PREVIEW_DIR.'/'.sprintf('%06d',$ID).'.jpg';
$url=&talkingurl($ID,$dbtitel);
$content=$content.' | '.$dbtitel.'
'.$dbstory.' ('.$dbdatum.') |
';
}
}
################################################
# Einfaches, zweispaltiges Layout
sub layout2
{
$query->execute || print DBI::errstr;
$spalte=1;
while (@abfrage=$query->fetchrow_array)
{
if ($spalte==1) {$content=$content.''};
$ID=$abfrage[0];
$dbtitel=&entity($abfrage[1]);
$dbstory="";
if ($abfrage[2] ne "") {$dbstory=&entity(&vorschautext($abfrage[2],$STORY_PREVIEW))."..."};
$dbdatum=&mysqldatumuhrzeit($abfrage[3]);
$vollbild=$FULLSIZE_DIR.'/'.sprintf('%06d',$ID).'.jpg';
$preview=$PREVIEW_DIR.'/'.sprintf('%06d',$ID).'.jpg';
$url=&talkingurl($ID,$dbtitel);
$content=$content.''.$dbtitel.' '.$dbstory.' ('.$dbdatum.') | '."\n";;
$spalte++;
if ($spalte>2)
{
$content=$content.'
';
$spalte=1;
}
}
#leere Restspalten auffuellen - bei allen anderen muss gerechnet werden
if ($spalte>1 && spalte<3 ) {$content=$content.' | '};
$content=$content.'';
}
################################################
# Einfaches, dreispaltiges Layout
sub layout3
{
$query->execute || print DBI::errstr;
$spalte=1;
while (@abfrage=$query->fetchrow_array)
{
if ($spalte==1) {$content=$content.''};
$ID=$abfrage[0];
$dbtitel=&entity($abfrage[1]);
$dbstory=&entity($abfrage[2]);
$vollbild=$FULLSIZE_DIR.'/'.sprintf('%06d',$ID).'.jpg';
$preview=$PREVIEW_DIR.'/'.sprintf('%06d',$ID).'.jpg';
$url=&talkingurl($ID,$dbtitel);
$spalte++;
if ($spalte>3)
{
$content=$content.'
';
$spalte=1;
}
}
#leere Restspalten auffuellen
$content=$content.'';
}
################################################
# Einfaches, vierspaltiges Layout
sub layout4
{
$query->execute || print DBI::errstr;
$spalte=1;
while (@abfrage=$query->fetchrow_array)
{
if ($spalte==1) {$content=$content.''};
$ID=$abfrage[0];
$dbtitel=&entity($abfrage[1]);
$dbstory=&entity($abfrage[2]);
$vollbild=$FULLSIZE_DIR.'/'.sprintf('%06d',$ID).'.jpg';
$preview=$PREVIEW_DIR.'/'.sprintf('%06d',$ID).'.jpg';
$url=&talkingurl($ID,$dbtitel);
$content=$content.' '.$dbtitel.' | ';
$spalte++;
if ($spalte>4)
{
$content=$content.'
';
$spalte=1;
}
}
$content=$content.'';
}
################################################
# Einfaches, fuenfspaltiges Layout
sub layout5
{
$query->execute || print DBI::errstr;
$spalte=1;
while (@abfrage=$query->fetchrow_array)
{
if ($spalte==1) {$content=$content.''};
$ID=$abfrage[0];
$dbtitel=&entity($abfrage[1]);
$dbstory=&entity($abfrage[2]);
$vollbild=$FULLSIZE_DIR.'/'.sprintf('%06d',$ID).'.jpg';
$preview=$PREVIEW_DIR.'/'.sprintf('%06d',$ID).'.jpg';
$url=&talkingurl($ID,$dbtitel);
$content=$content.' '.$dbtitel.' | ';
$spalte++;
if ($spalte>5)
{
$content=$content.'
';
$spalte=1;
}
}
$content=$content.'';
}
################################################
# Einfaches, sechsspaltiges Layout
sub layout6
{
$query->execute || print DBI::errstr;
$spalte=1;
while (@abfrage=$query->fetchrow_array)
{
if ($spalte==1) {$content=$content.''};
$ID=$abfrage[0];
$dbtitel=encode($enc,$abfrage[1]);
$dbstory=encode($enc,$abfrage[2]);
$vollbild=$FULLSIZE_DIR.'/'.sprintf('%06d',$ID).'.jpg';
$preview=$PREVIEW_DIR.'/'.sprintf('%06d',$ID).'.jpg';
$url=&talkingurl($ID,$dbtitel);
$alttext=&entity($dbtitel);
$content=$content.' '.$dbtitel.' | ';
$spalte++;
if ($spalte>6)
{
$content=$content.'
';
$spalte=1;
}
}
#Leere TD erzeugen, wenn Tabelle nicht aufgeht
while ($spalte >1 && $spalte < 7)
{
$content=$content.' | ';
$spalte++;
}
$content=$content.'';
}