#!/usr/bin/perl use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use CGI qw(:standard); use CGI::Cookie; use DBD::mysql; use DBI; print header( -charset=>'iso-8859-7' ); print start_html( -style=>'../data/css/style.css', -title=>'Ψυχωφελή Πνευματικά Κείμενα!', -background=>'../data/images/night.gif' ); my @months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime; my $date = "$mday $months[$mon], $hour:$min"; my $ip = $ENV{'REMOTE_ADDR'}; my @numbers = split (/\./,$ip); my $address = pack ("C4", @numbers); my $host = gethostbyaddr ($address, 2) || $ip; $host = "Νίκος" if ( ($host eq "dell") or ($host eq "localhost") or ($host eq "dslcustomer-221-228.vivodi.gr") ); my ($sth, $row) = (); my $dbh = ($ENV{'SERVER_NAME'} ne 'nikolas.50free.net') ? DBI->connect('DBI:mysql:nikos_db', 'root', '********') : DBI->connect('DBI:mysql:nikos_db:50free.net', 'nikos_db', '********') or die $DBI::errstr; #******************************************************************************* my @files = <../data/text/*.txt>; my @display_files = map( /([^\/]+)\.txt/, @files ); print start_form(-action=>'index.pl'); print p( {-align=>'center'}, font( {-size=>5, -color=>'Lime'}, 'Διάλεξε ένα από τα κείμενα για να διαβάσεις => ' ), popup_menu( -name=>'select', -values=>\@display_files ), submit('Επιλογή')); print end_form(), br(); my $script = param('select') or "Αρχική Σελίδα!"; $sth = $dbh->prepare( "SELECT host FROM guestlog" ); $sth->execute(); while( $row = $sth->fetchrow_hashref ) { if( $host eq $row->{host} ) { my $hostmatch = 1; } } if( param('select') and param('select') !~ /\.\./ ) { open(FILE, "<../data/text/$script.txt") or die $!; my @data = ; close(FILE); my $data = join('', @data); $dbh->do( "UPDATE guestlog SET script='$script' WHERE host='$host'" ) or die $dbh->errstr; } elsif( $hostmatch == 1 ) { $dbh->do( "UPDATE guestlog SET hostcount = hostcount + 1 WHERE host='$host'" ) or die $dbh->errstr; $sth = $dbh->prepare( "SELECT * FROM guestlog WHERE host='$host'" ); $sth->execute(); $row = $sth->fetchrow_hashref; $data = "Καλώς ήλθες " .$host. "! Χαίρομαι που βρίσκες την σελίδα ενδιαφέρουσα!\n" . "Τελευταία φορά ήρθες εδώ ως " .$row->{host}. " στις " .$row->{date}. " !!\n" . "Σύνολικές ήρθες εδώ " .$row->{hostcount}. " φορές!!!\n" . "Τελευταία είδες το κείμενο { " .$row->{script}. " }\n" . "Ποιό κείμενο θα μελετήσεςι αυτήν την φορά !?"; } elsif( $hostmatch != 1 ) { if ( $host ne "Νίκος" ) { $data = "Γειά σου " .$host. "!\n" . "Έρχεσαι για 1η φορά εδώ !!\n" . "Ελπίζω να βρείς τα κείμενα ενδιαφέροντα :-)"; $dbh->do( "INSERT INTO guestlog VALUES (null, '$host', '$date', '$script', 1, 1)" ) or die $dbh->errstr; } else { $data = "Γειά σου Νικόλα, τι χαμπάρια?! Όλα δεξιά να σου πάνε πάντα! ;-)"; } } $data =~ s/\n/\\n/g; $data =~ s/"/\\"/g; $data =~ tr/\cM//d; #******************************************************************************* print <
'show.pl'); print table( {class=>'user'}, Tr( td( 'Πώς σε λένε αδελφε?' ), td( textfield( 'name' ))), Tr( td( 'Ποιά είναι η γνώμη σου για την ευχούλα »Κύριε Ιησού Χριστέ, Ελέησον Με« ?' ), td( textarea( -name=>'pray', -rows=>4, -columns=>25 ))), Tr( td( 'Περιέγραψε μας μια προσωπική σου πνευματική εμπειρία από κάποιον γέροντα προς ώφελος των υπολοίπων αδελφών ( αν φυσικά έχεις :-)' ), td( textarea( -name=>'remark', -rows=>6, -columns=>25 ))), Tr( td( 'Ποιό είναι το email σου?' ), td( textfield( 'email' ))), Tr( td( submit( 'Εμφάνιση όλων των απόψεων' )), td( submit( 'Αποστολή' ))), ); print end_form(), br(), br(); open(FILE, "<../data/text/tips") or die $!; my @tips = ; close(FILE); @tips = grep { !/^\s*\z/s } @tips; my $tip = $tips[int(rand(@tips))]; print table( {class=>'quote'}, Tr( td( {class=>'tip'}, $tip )) ); $dbh->do( "UPDATE guestlog SET pagecount = pagecount + 1" ) if ($host ne "Νίκος"); $sth = $dbh->prepare( "SELECT pagecount FROM guestlog" ); $sth->execute(); $row = $sth->fetchrow_hashref; print br(); print table( {class=>'info'}, Tr( td( {class=>'host'}, $host )), Tr( td( {class=>'date'}, $date )), Tr( td( {class=>'hostcount'}, $row->{hostcount} )), Tr( td( {class=>'pagecount'}, $row->{pagecount} )) ); print br(), a( {href=>'games.pl'}, img{src=>'../data/images/games.gif'} ); print p( {-align=>'right'}, a( {href=>'show.pl?name=showlog'}, font( {-size=>2, -color=>'Lime'}, b( 'Last Update: 29/4/2005' )))); #### Global symbol "$hostmatch" requires explicit package name at D:\www\cgi-bin\index.pl line 61. Global symbol "$data" requires explicit package name at D:\www\cgi-bin\index.pl line 68. Global symbol "$hostmatch" requires explicit package name at D:\www\cgi-bin\index.pl line 74. Global symbol "$data" requires explicit package name at D:\www\cgi-bin\index.pl line 78. Global symbol "$data" requires explicit package name at D:\www\cgi-bin\index.pl line 86. Global symbol "$data" requires explicit package name at D:\www\cgi-bin\index.pl line 90. Global symbol "$data" requires explicit package name at D:\www\cgi-bin\index.pl line 91. Global symbol "$data" requires explicit package name at D:\www\cgi-bin\index.pl line 92. Global symbol "$data" requires explicit package name at D:\www\cgi-bin\index.pl line 95. Execution of D:\www\cgi-bin\index.pl aborted due to compilation errors.