#!/usr/bin/perl

require "pfade.pl";
$pfad=&pfadcgi;
$pfadw=&pfadhtm;
$pfadg=&pfadhtmg;
require "vorlagen.pl";
%jede=&jede;

&zaehler('guest');

$kette=&einlesen;
%uebergabe=&aufbereiten($kette);

$papst=&papst;

@cabelle=&dateitabelle("guescontrol.dat");

if($uebergabe{'gues'} eq "")
{
@tabelle=&dateitabelle('guest.dat');
}
else
{
%ceile=&aufbereiten($cabelle[$uebergabe{'gues'}]);
@tabelle=&dateitabelle($ceile{'file'});
}


@tabelle=reverse(@tabelle);

print "Content-type: text/html\n\n";

print "<html>\n";
print "<head>\n";
print "<title>$jede{'titel'}</title>\n";
print "<link rel=stylesheet type=\"text/css\" href=\"$pfadw/schriften.css\">\n";

print "<script language=\"JavaScript\">\n";
print "  <!--\n";

print "function poss()\n";
print "{\n";
print "document.ein.name.focus();\n";
print "}\n";

print "function comeon(a)\n";
print "{\n";
print "eval('fenetre=window.open(\"$pfad/loeschen.pl?intern=$uebergabe{'intern'}&datei=guest&zeile='+a+'\",\"ausschenken\",\"width=300,height=150,screenX=10,screenY=10,resizable=yes,scrollbars=yes\")');\n";
print "fenetre.focus();\n";
print "}\n";

print "function cds()\n";
print "{\n";
print "if(document.ein.name.value == \"\")\n";
print "{\n";
print "alert(\"Wer bisch du ?\");\n";
print "document.ein.name.focus();\n";
print "return false;\n";
print "}\n";
print "if(document.ein.massage.value == \"\")\n";
print "{\n";
print "alert(\"Was isch deine Meinung ?\");\n";
print "document.ein.massage.focus();\n";
print "return false;\n";
print "}\n";
print "}\n";

print <<"ENDE";

function abfahrt()
{
poss();
if(document.cookie)
{

var setzen=document.cookie;
var tabelle=setzen.split(";");

var fname="";
var femail="";
var fhome="http://";
var ficq="";

ziel=tabelle.length;

var z=0;

while(z<ziel)
{
var zeile=tabelle[z].split("=");

if(zeile[0] == " name" && typeof(zeile[1]) != 'undefined') {fname=zeile[1];}
if(zeile[0] == " email" && typeof(zeile[1]) != 'undefined') {femail=zeile[1];}
if(zeile[0] == " home" && typeof(zeile[1]) != 'undefined') {fhome=zeile[1];}
if(zeile[0] == " icq" && typeof(zeile[1]) != 'undefined') {ficq=zeile[1];}

if(zeile[0] == "name" && typeof(zeile[1]) != 'undefined') {fname=zeile[1];}
if(zeile[0] == "email" && typeof(zeile[1]) != 'undefined') {femail=zeile[1];}
if(zeile[0] == "home" && typeof(zeile[1]) != 'undefined') {fhome=zeile[1];}
if(zeile[0] == "icq" && typeof(zeile[1]) != 'undefined') {ficq=zeile[1];}

z++;
}

document.ein.name.value=fname;
document.ein.email.value=femail;
document.ein.home.value=fhome;
document.ein.icq.value=ficq;

}
}
ENDE


print "//-->\n";
print "</script>\n";

print "</head>\n";
print "<body bgcolor=$jede{'back'} text=$jede{'text'} link=$jede{'text'} alink=$jede{'text'} vlink=$jede{'text'} onload=\"abfahrt()\">\n";

print "&nbsp;<font class=\"main\">G&auml;stebuch</font>\n";

print "<p>";

print "<form name=\"ein\" action=\"$pfad/guesteintragen.pl\" method=post onSubmit=\"return cds()\">\n";

print "<input type=hidden name=\"intern\" value=\"$uebergabe{'intern'}\">\n";
print "<input type=hidden name=\"zeile\" value=\"canceld\">\n";
$zeit=time();
print "<input type=hidden name=\"date\" value=\"$zeit\">\n";

print "<table>\n";

print "<tr>\n";
print "<td align=right><font class=\"guestwhat\">Name:&nbsp;</font></td>\n";
print "<td><input type=text name=\"name\" size=30></td>\n";
print "</tr>\n";

print "<tr>\n";
print "<td align=right><font class=\"guestwhat\">Password:&nbsp;</font></td>\n";
print "<td><input type=text name=\"password\" size=30></td>\n";
print "</tr>\n";

print "<tr>\n";
print "<td align=right><font class=\"guestwhat\">e-mail:&nbsp;</font></td>\n";
print "<td><input type=text name=\"email\" size=30></td>\n";
print "</tr>\n";

print "<tr>\n";
print "<td align=right><font class=\"guestwhat\">Homepage:&nbsp;</font></td>\n";
print "<td><input type=text name=\"home\" value=\"http://\" size=30></td>\n";
print "</tr>\n";

print "<tr>\n";
print "<td align=right><font class=\"guestwhat\">ICQ:&nbsp;</font></td>\n";
print "<td><input type=text name=\"icq\" size=30></td>\n";
print "</tr>\n";

print "<tr>\n";
print "<td align=right><font class=\"guestwhat\">Bsoffene&nbsp;Moschtkepf:&nbsp;</font></td>\n";
print "<td valign=middle>\n";
print "<input type=radio name=\"most\" value=\"1\"><img src=\"$pfadg/most1.gif\" border=0>\n";
print "&nbsp;&nbsp;&nbsp;&nbsp;<input type=radio name=\"most\" value=\"2\"><img src=\"$pfadg/most2.gif\" border=0>\n";
print "&nbsp;&nbsp;&nbsp;&nbsp;<input type=radio name=\"most\" value=\"3\"><img src=\"$pfadg/most3.gif\" border=0>\n";
print "&nbsp;&nbsp;&nbsp;&nbsp;<input type=radio name=\"most\" value=\"4\"><img src=\"$pfadg/most4.gif\" border=0>\n";
print "</td>\n";
print "</tr>\n";

print "<tr>\n";
print "<td align=right valign=top><font class=\"guestwhat\">Massage:&nbsp;</font></td>\n";
print "<td><textarea name=\"massage\" rows=10 cols=60></textarea></td>\n";
print "</tr>\n";

print "<tr>\n";
print "<td colspan=2 align=center><input type=submit value=\" eintragen \"></td>\n";
print "</tr>\n";

print "</table>\n";

print "<p>\n";

print "<table width=100%>\n";

$z=0;
while($z<@tabelle)
{
$zz=@tabelle-$z-1;
%zeile=&aufbereiten($tabelle[$z]);
$zeile{'name'}=&schluessel($zeile{'name'});
$zeile{'email'}=&schluessel($zeile{'email'});
$zeile{'home'}=&schluessel($zeile{'home'});
$br="<br>";
$zeile{'massage'} =~ s/\%0[Dd]\%0[Aa]/$br/ge;
$zeile{'massage'}=&schluessel($zeile{'massage'});
$zeile{'date'}=&datum($zeile{'date'});
print "<tr><td colspan=3 bgcolor=$jede{'text'}>\n";
print "<table width=90%><tr><td><font class=\"guestname\"><font color=$jede{'back'}>$zeile{'name'}</font></font></td><td align=right><font class=\"guestdate\"><font color=$jede{'back'}>$zeile{'date'}</font></font></td></tr></table>\n";
print "</td></tr>\n";

if ($zeile{'icq'} ne "" || $zeile{'home'} ne "" || $zeile{'email'} ne "" || $zeile{'most'} ne "")
{
print "<tr>\n";
print "<td rowspan=3 align=center valign=middle>\n";
if ($zeile{'most'} ne "")
{print "<img src=\"$pfadg/most$zeile{'most'}.gif\" border=0>\n";}
else
{print "&nbsp;";}
print "</td>\n";
$was=""; if ($zeile{'email'} ne "") {$was="e-mail:";}
$wer="&nbsp;"; if ($zeile{'email'} ne "") {$wer="<a href=\"mailto:$zeile{'email'}\">$zeile{'email'}</a>";}
print "<td align=right><font class=\"guestdata\">$was&nbsp;</font></td>\n";
print "<td><font class=\"guestdata\">$wer</font></td>\n";
print "</tr>\n";

print "<tr>\n";
$was=""; if ($zeile{'home'} ne "") {$was="Homepage:";}
$wer="&nbsp;"; if ($zeile{'home'} ne "") {$wer="<a href=\"$zeile{'home'}\" target=\"_blank\">$zeile{'home'}</a>";}
print "<td align=right><font class=\"guestdata\">$was&nbsp;</font></td>\n";
print "<td><font class=\"guestdata\">$wer</font></td>\n";
print "</tr>\n";

print "<tr>\n";
$was=""; if ($zeile{'icq'} ne "") {$was="ICQ:";}
print "<td align=right><font class=\"guestdata\">$was&nbsp;</font></td>\n";
print "<td>\n";
if ($zeile{'icq'} ne "" && substr($pfad,7,3) ne "loc")
{print "<img src=\"http://wwp.icq.com/scripts/online.dll?icq=$zeile{'icq'}&img=2\">&nbsp;&nbsp;<font class=\"guestdata\">$zeile{'icq'}</font>";}
else
{print "&nbsp;";}
print "</td>\n";
print "</tr>\n";
}

print "<tr>\n";
print "<td colspan=3><font class=\"guesttext\">$zeile{'massage'}</font></td>\n";
print "</tr>\n";

print "<tr>\n";
print "<td colspan=3>&nbsp;";
if ($uebergabe{'intern'} eq "ja" && $papst eq "ja")
{
if($uebergabe{'gues'} eq "")
{
print "<a href=\"$pfad/guestaendern.pl?intern=$uebergabe{'intern'}&zeile=$zz\"><font class=\"text\">&auml;ndern</font></a>";
print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
print "<a href=\"javascript:comeon('$zz')\"><font class=\"text\">l&ouml;schen</font></a>";
}
}
print "</td></tr>\n";

$z++;
}

print "</table>\n";

if($uebergabe{'gues'} ne "")
{
$uebergabe{'gues'}="";
 $setzen = "";
 while (@array=each(%uebergabe)) 
 {
 $setzen="$setzen&$array[0]=$array[1]";
 } 
 $setzen=substr($setzen,1,length($setzen)-1);
$czz=$cz+1;
print "<center><a href=\"$pfad/guest.pl?$setzen\"><font class=\"main\">G&auml;stebuch orginal</font></a></center>\n";
}

$cz=0;
foreach $sau (@cabelle)
{
$uebergabe{'gues'}=$cz;
 $setzen = "";
 while (@array=each(%uebergabe)) 
 {
 $setzen="$setzen&$array[0]=$array[1]";
 } 
 $setzen=substr($setzen,1,length($setzen)-1);
$czz=$cz+1;
print "<center><a href=\"$pfad/guest.pl?$setzen\"><font class=\"main\">G&auml;stebuch Archiv $czz</font></a></center>\n";
$cz++;
}

print "<p>\n";
print "<table width=100%><tr><td align=right><a href=\"mailto:$jede{'email'}\"><font class=\"email\">$jede{'email'}</font></a></td></tr></table>\n";

print "</body>\n";
print "</html>\n";
