viewing paste user_counter.txt | PHP

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
-   script  user_counter    -1,{
OnPCLoginEvent:
query_sql("SELECT value FROM mapreg WHERE varname='userOnline'",.@lastOnline);
if(getarraysize(.@lastOnline) == 0) {
    query_sql("INSERT INTO mapreg(varname,value) VALUE('userOnline',1)");
    set .@userOnline,1;
} else {
    query_sql("UPDATE mapreg SET value=value+1 WHERE varname='userOnline'");
    set .@userOnline,.@lastOnline[0]+1;
}
query_sql("SELECT value FROM mapreg WHERE varname='userPeak'",.@userPeak);
if((.@userOnline > .@userPeak[0]) || (getarraysize(.@userPeak) == 0)) {
    if(getarraysize(.@userPeak) == 0)
        .@newPeak$ = "INSERT INTO mapreg(varname,value) VALUE('userPeak',"+.@userOnline+")";
    else
        .@newPeak$ = "UPDATE mapreg SET value="+.@userOnline+" WHERE varname='userPeak'";
    query_sql(.@newPeak$);
    .@peak = .@userOnline;
} else {
    .@peak = .@userPeak[0];
}
end;
OnPCLogoutEvent:
query_sql("SELECT value FROM mapreg WHERE varname='userOnline'",.@lastOnlineB);
if(.@lastOnlineB[0] > 1)
    query_sql("UPDATE mapreg SET value=value-1 WHERE varname='userOnline'");
else
    query_sql("DELETE FROM mapreg WHERE varname='userOnline'");
end;
}
Viewed 721 times, submitted by Guest.