Finally a better script!
- From: Nikos <hackeras@xxxxxxxxx>
- Date: Fri, 29 Apr 2005 22:07:54 +0300
You understand very quickly what i wanted to do and you helped me write the correct way.
After all of the guys suggestions here is how the script transformed:
========================================================= my $script = param('select') || "Welcome Page!"; my ($data, @data);
if (param('select') and param('select') ne '..') { open(FILE, "<../data/text/$script.txt") or die $!; @data = <FILE>; close(FILE);
$data = join('', @data);$dbh->do( "UPDATE guestlog SET script='$script' WHERE host='$host'" ) or die $dbh->errstr;
}
else
{
$sth = $dbh->prepare( "SELECT host FROM guestlog WHERE host=?" );
$sth->execute($host);
if ($sth->rows)
{
$sth = $dbh->prepare( "UPDATE guestlog SET hostcount=hostcount+1 WHERE host=?" );
$sth->execute($host);
$sth = $dbh->prepare( "SELECT * FROM guestlog WHERE host=?" );
$sth->execute($host);
$row = $sth->fetchrow_hashref;$data = "Êáëþò Þëèåò " .$host. "! ×áßñïìáé ðïõ âñßóêåò ôçí óåëßäá åíäéáöÝñïõóá!\n" .
"Ôåëåõôáßá öïñÜ Þñèåò åäþ ùò " .$row->{host}. " óôéò " ..$row->{date}. " !!\n" .
"ÓýíïëéêÝò Þñèåò åäþ " .$row->{hostcount}. " öïñÝò!!!\n" .
"Ôåëåõôáßá åßäåò ôï êåßìåíï { " .$row->{script}. " }\n" .
"Ðïéü êåßìåíï èá ìåëåôÞóåòé áõôÞí ôçí öïñÜ !?";
}
else
{
if ($host ne "Íßêïò")
{
$data = "ÃåéÜ óïõ " .$host. "!\n" .
"¸ñ÷åóáé ãéá 1ç öïñÜ åäþ !!\n" .
"Åëðßæù íá âñåßò ôá êåßìåíá åíäéáöÝñïíôá :-)";
$sth = $dbh->prepare("SELECT * FROM guestlog WHERE host=?");
$sth->execute($host);$sth = $dbh->prepare( "INSERT INTO guestlog (host, date, script, hostcount, pagecount) VALUES (?, ?, ?, ?, ?)" );
$sth->execute($host, $date, $script, $hostcount, $pagecount);
}
else
{
$data = "ÃåéÜ óïõ Íéêüëá, ôé ÷áìðÜñéá?! ¼ëá äåîéÜ íá óïõ ðÜíå ðÜíôá! ;-)";
}
}
}
=========================================================
I wish i can test ti but iam currently having a mysql problem but thing it will work :-)
If we still can make it shorter please let me know!
.
- Follow-Ups:
- Re: Finally a better script!
- From: Nikos
- Re: Finally a better script!
- From: A. Sinan Unur
- Re: Finally a better script!
- From: Henry Law
- Re: Finally a better script!
- Prev by Date: Re: Can this be rewritten better?
- Next by Date: Re: Can this be rewritten better?
- Previous by thread: Getting the text from a Win32 Application
- Next by thread: Re: Finally a better script!
- Index(es):
Relevant Pages
|