N
Nikos
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 = <FILE>;
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 = "ÃåéÜ óïõ Ãéêüëá, ôé ÷áìðÜñéá?! ¼ëá äåîéÜ Ãá óïõ ðÜÃÃ¥
ðÜÃôá! ;-)";
}
}
ok with the above script iam trying to see if the current hostname of a
visitor exists in guestlog mysql database.
If it does then i just update the existing record,
if it does not i just welcome the user.
Please you asked me to ask specific questions and here i ask one:
Is the above logic correct?
Is there any betetr that i can write it?
ps. Sorry about the Greek folks but although i use UTF-8 it still being
displayed like shit. I hate seeing it myself too but i donw know how can
they be displayed correctly.
$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 = <FILE>;
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 = "ÃåéÜ óïõ Ãéêüëá, ôé ÷áìðÜñéá?! ¼ëá äåîéÜ Ãá óïõ ðÜÃÃ¥
ðÜÃôá! ;-)";
}
}
ok with the above script iam trying to see if the current hostname of a
visitor exists in guestlog mysql database.
If it does then i just update the existing record,
if it does not i just welcome the user.
Please you asked me to ask specific questions and here i ask one:
Is the above logic correct?
Is there any betetr that i can write it?
ps. Sorry about the Greek folks but although i use UTF-8 it still being
displayed like shit. I hate seeing it myself too but i donw know how can
they be displayed correctly.