#!/usr/bin/perl use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use CGI qw(:standard); use DBD::mysql; use POSIX qw(strftime); print header( -charset=>'iso-8859-7' ); print start_html( -style=>'/data/css/style.css', -title=>'Απόψεις Πνευματικών Αδελφών!', -background=>'/data/images/night.gif' ); my $name = param('name'); my $pray = param('pray'); my $remark = param('remark'); my $email = param('email'); my ($sth, $row); my $date = strftime( "%d %b, %H:%M", localtime ); my $host = gethostbyaddr (pack ("C4", split (/\./, $ENV{'REMOTE_ADDR'})), 2) || $ENV{REMOTE_ADDR}; $host = "dell" if ( ($host eq "dell") or ($host eq "localhost") or ($host =~ /vivodi.gr/) ); my $dbh = ($ENV{'SERVER_NAME'} ne 'nikolas.50free.net') ? DBI->connect('DBI:mysql:nikos_db', 'root', 'tiabhp2r') : DBI->connect('DBI:mysql:nikos_db:50free.net', 'nikos_db', 'tiabhp2r') or {RaiseError=>1}; #******************************************************************************* if( $name eq 'showlog' ) { $sth = $dbh->prepare( 'SELECT * FROM visitorlog ORDER BY id DESC' ); $sth->execute; while( $row = $sth->fetchrow_hashref ) { print table( {class=>'tip'}, Tr( td( {class=>'host'}, $row->{host} ), td( {class=>'date'}, $row->{date} ), td( {class=>'passage'}, $row->{passage} ), td( {class=>'counter'}, $row->{counter} ) ) ); } unless ($sth->rows ) { print font( {class=>'tip'}, "Κανένας επισκέπτης δεν μας τίμησε ακόμη με την παρουσία του!" ); } exit 0; } if( param('Εμφάνιση Guestbook!') ) { $sth = $dbh->prepare( 'SELECT * FROM guestbook' ); $sth->execute; while( $row = $sth->fetchrow_hashref ) { print table( {class=>'user_form'}, Tr( td( {-width=>'25%'}, {class=>'name'}, $row->{name} ), td( {-width=>'50%'}, {class=>'email'}, $row->{email} ), td( {-width=>'25%'}, {class=>'date'}, $row->{date} ) ), Tr( td( {class=>'host'}, "Ευχή του Ιησού" ), td( {colspan=>2}, {class=>'tip'}, $row->{pray} ) ), Tr( td( {class=>'tip'}, "Προσωπική Ορθοδοξοπνευματική Εμπειρία" ), td( {colspan=>2}, {class=>'remark'}, $row->{remark} ) ), Tr( td( {colspan=>3}, {class=>'host'}, $row->{host} ) ), ), br() x 2; } unless ($sth->rows ) { print span( {class=>'tip'}, "Δεν υπάρχουν νέες εγγραφές, yet!" ); } } if( param('Αποστολή') ) { if( ($name eq 'drop') and ($pray eq 'drop') and ($remark eq 'drop') and ($email eq 'drop')) { $dbh->do( 'DELETE FROM guestbook' ); print span( {class=>'tip'}, "Όλες οι εγγραφές διαγράφηκαν από τη βάση δεδομένων!" ); exit 0; } if( $name eq 'delete') { $dbh->do( 'DELETE FROM guestbook WHERE name=$pray' ); print span( {class=>'tip'}, "Μόλις διαγράψατε τον χρήστη => " ); print span( {class=>'tip'}, $pray ); exit 0; } if( $name eq 'deletelog') { $dbh->do( 'DELETE FROM visitorlog' ); print span( {class=>'tip'}, "Η βάση δεδομένων με τα logs μόλις διαγράφηκε!" ); exit 0; } my %error_msgs = ( name => "Ξέχασες να μας πείς ποιός είσαι!", pray => "Δεν σχολίασες την ευχή!", remark => "Δεν θα μας πείς για την εμπειρία σου?'", email => "Συμπλήρωσε το email σου!" ); my $error_found; for ( keys %error_msgs ) { unless ( $$_ ) { print div( {class=>'tip'}, $error_msgs{$_} ); $error_found++; } } exit 0 if $error_found; $sth = $dbh->prepare( 'INSERT INTO guestbook (name, pray, remark, email, date, host) VALUES (?, ?, ?, ?, ?, ?)' ); $sth->execute($name, $pray, $remark, $email, $date, $host); $sth = $dbh->prepare( 'SELECT count(*) FROM guestbook' ); $sth->execute; $row = $sth->fetchrow_hashref; print div( {class=>'tip'}, "Ευχαριστώ πολύ " ); print div( {class=>'tip'}, "$name
" ); print div( {class=>'tip'}, "Συνολικοί επισκέπτες: " ); print div( {class=>'tip'}, "$row->{'count(*)'}" ); } #### table.user_form { background-image: url(/data/images/swirl.jpg); width: 55%; color: lime; text-align: center; font: 18px times; border: 5px inset blue; border-collapse: collapse; } table.tip { background-image : url(/data/images/blue.jpg); width: 85%; color: lime; text-align: center; font: 18px comic; border: 3px inset red; border-collapse: collapse; } table.info { background-image : url(/data/images/blue.jpg); width: 20%; color: lime; text-align: center; font: 18px comic; border: 3px inset magenta; border-collapse: collapse; } table.games { background-image : url(/data/images/blue.jpg); width: 80%; color: lime; text-align: center; font: 18px comic; border: 8px ridge magenta; border-collapse: collapse; } table { margin-right: auto; margin-left: auto; text-align: center; } Tr { text-align: center; border: 2px inset blue; } td { border: 1px inset yellow; } td.tip { font: 18px times; color: white; } td.host { font: 18px comic; color: lime; } td.date { font: 18px comic; color: yellow; } td.passage { font: 18px orange; color: lime; } td.counter { font: 18px comic; color: cyan; }