Автор: Shurik
Дата сообщения: 29.04.2003 21:37
вот мой whosonline:
Код:
sub whosonline {
local($instruct) = @_;
($tempusername, $where, $method) = split(/\|/, $instruct);
$guests = 0;
$members = 0;
$currenttime = time;
$membergone = 30;
$userexpire = $currenttime - ($membergone * 60);
$ipaddresstowo = $ENV{'REMOTE_ADDR'};
#$logname = $tempusername;
&getmember("$inmembername");
#$tempusername = "$ibtxt{'0043'} $ipaddress" if ($tempusername eq "$ibtxt{'0043'}");
if ($tempusername eq "Guest" || $userregistered eq "no") { $tempusername = "Guest"; }
$filetoopen = "$ikondir" . "data/onlinedata.dat";
$filetoopen = &stripMETA($filetoopen);
open(FILE,"$filetoopen");
flock(FILE,1);
@onlinedata = <FILE>;
close(FILE);
open(FILE,">$filetoopen");
flock(FILE, 2);
$memberprinted = "no";
foreach $line (@onlinedata) {
chomp $line;
($savedusername, $savedtime, $savedwhere, $savedip) = split(/\|/, $line);
$savedusername =~ s/ /_/g;
$tempusername =~ s/ /_/g;
unless ("$userexpire" > "$savedtime") {
if ($tempusername eq $savedusername) {
if ($savedusername eq "Guest" && $savedip eq $ipaddresstowo) {
print FILE "$tempusername|$currenttime|$where|$ipaddresstowo\n";
$memberprinted = "yes";
}
elsif ($savedusername eq "Guest" && $savedip ne $ipaddresstowo) {
print FILE "$line\n";
}
elsif ($savedusername ne "Guest") {
print FILE "$tempusername|$currenttime|$where|$ipaddresstowo\n";
$memberprinted = "yes";
}
} else { print FILE "$line\n"; }
}
} # end foreach
if ($memberprinted eq "no") { print FILE "$tempusername|$currenttime|$where|$ipaddresstowo\n";}
close(FILE);
if ($method eq "$ibtxt{'0016'}") {
$filetoopen = "$ikondir" . "data/onlinedata.dat";
$filetoopen = &stripMETA($filetoopen);
open(FILE,"$filetoopen");
@onlinedata = <FILE>;
close(FILE);
foreach $line (@onlinedata) {
chomp $line;
($savedusername, $savedtime, $savedwhere, $savedipadr) = split(/\|/, $line);
$lookfor = substr($savedusername, 0, 5);
if ($lookfor eq "$ibtxt{'0043'}") { $guests++; }
else {
$members++;
$cleanmember = $savedusername;
$cleanmember =~ s/\_/ /g;
$savedusername = $cleanmember;
$savedusername = substr($savedusername,0,20) if length $savedusername > 19;
$memberoutput .= qq~» <a href="$profileprog?action=show&member=$cleanmember">$savedusername </a>~;
}
}
}
} # end routine