Forum Moderators: coopster & phranque

Message Too Old, No Replies

My WhosOnline script: Is there a better way?

Perl script whos online

         

Perllover

10:55 am on Jan 28, 2008 (gmt 0)

10+ Year Member



Hello,

Ik use this whois online script set to 900 sec. 15 min ;-)

Is there a better way to do this?

<script>

my $sth = $dbh->prepare("select username from user_cookies");
$sth->execute;

$dbh->disconnect();

my $url = 'https://www.mydomain.nl/crm-bin/users.pl';

my $refresh = 900;

&refreshpage;
exit;

sub now {
local($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime;
local($tz) = "CST";
$tz =~ s/ST/DT/ if ($isdst);
$sec = "0".$sec if ($sec < 10);
$min = "0".$min if ($min < 10);
$mon++;
$year += 1900;
return "$mon/$mday/$year $hour:$min:$sec $tz";
}

sub &refreshpage {
local($date) = &now;
print "Content-type: text/html\n\n";

print qq¦<META HTTP-EQUIV=REFRESH CONTENT="$refresh; URL=$url">\n¦;

my $i = 0;
my $sep;

print qq¦
<html>
<body style="margin:0 0 0 0">
<span style="font-size:70%;font-family:verdana, arial, sans-serif;color:\#000099">Online: </span>
¦;
while (my ( $user ) = $sth->fetchrow_array() )
{
$i++;
print qq¦<span style="font-size:70%;font-family:verdana, arial, sans-serif;color:\#000099">$sep $user $sep </span>¦;
if ( $i >= 1){
$sep = "\¦";}
}
print qq¦
</body>
</html>
¦;

</script>

[edited by: Perllover at 10:56 am (utc) on Jan. 28, 2008]

Brett_Tabke

5:45 pm on Feb 7, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Does it work?

...i think that is all that matters.

Perllover

8:30 am on Feb 8, 2008 (gmt 0)

10+ Year Member



Hello Brett_Tabke,

Yes it works great, but I thought that the header-refresment maybe takes to much load and there are maybe other ways.

Greetings, MP

phranque

9:00 am on Feb 8, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



that's probably the lightest implementation you could do.
anything else would probably require javascript or flash.