Page 1 of 1
whoisonline script
Posted: Thu Jan 22, 2004 4:25 am
by doggy
Code: Select all
function online() {
global $admin, $user, $cookie, $prefix, $db;
cookiedecode($user);
$ip = $_SERVER["REMOTE_ADDR"];
$uname = $cookie[1];
if (!isset($uname)) {
$uname = "$ip";
$guest = 1;
}
if (is_admin($admin)) {
$admin = base64_decode($admin);
// this line is giving me problims //
$admin = explode(":", $admin);
// end problim //
$uname = "$admin[0]";
$guest = 2;
}
$past =time()-600;
$sql = "DELETE FROM ".$prefix."_session WHERE time < $past";
$db->sql_query($sql);
$sql = "SELECT time FROM ".$prefix."_session WHERE uname='$uname'";
$result = $db->sql_query($sql);
$ctime = time();
if ($row = $db->sql_fetchrow($result)) {
$sql = "UPDATE ".$prefix."_session SET uname='$uname', time='$ctime', host_addr='$ip', guest='$guest' WHERE uname='$uname'";
$db->sql_query($sql);
} else {
$sql = "INSERT INTO ".$prefix."_session (uname, time, host_addr, guest) VALUES ('$uname', '$ctime', '$ip', '$guest')";
$db->sql_query($sql);
}
}
Warning: base64_decode() expects parameter 1 to be string, array given in C:\FoxServ\www\atlas-php\mainfile.php on line 414
i have no idea what is going on ... please help
Posted: Thu Jan 22, 2004 4:35 am
by twigletmac
What do you get if you do:
Mac
Posted: Thu Jan 22, 2004 4:39 am
by doggy
array(1) { [0]=> string(0) "" }
Posted: Thu Jan 22, 2004 5:07 am
by twigletmac
There's the problem then, $admin is an array not a string. This will cause you problems with the explode() function too. What were you expecting to be in $admin?
Mac
Posted: Thu Jan 22, 2004 6:02 am
by doggy
i have installed phpnuke and i making it now for a company so i wanne make the whois online that people can see how many administrators are online and what administrators are online ( nicknames ) so that is why i need to explode the $admin thingy to see what is the administrators nickname ,,,, but i am not that good with php so thats why i really need help ,,,
Posted: Thu Jan 22, 2004 6:07 am
by malcolmboston
i dont know if you have thought of doing it this way but here goes
<--user3 logs in
<--a value is set in there myswl row (update record)or set a flag
<--user3 exits
<-- a value is changed back again (or changed back at set interval to ensure the person hasnt just exited without clicking logout
on the CMS
<-- run a query checking values in a database equivalent to the va;lue you decide to create when someone has logged in
<-- run
mysql_affected_rows() to see how many people are logged in currently
i dont know whether this is the way forums do it, but this is the way i envision it to be
Posted: Thu Jan 22, 2004 6:15 am
by doggy
amm dude sounds cool but i don`t really know or anderstand what you are saying. could you maybe reword. i am not that good of a web developer and i don`t know so much about php scripting.
Posted: Thu Jan 22, 2004 6:24 am
by malcolmboston
ok
i will try and explain it, as thoroughly as i can
- user1 goes into the login area and successfully logs in
- a session is created using
Code: Select all
$_SESSION[username] = $_POST[username]
//i think thats right, im tired!
insert data into the database so that you can check for it later
Code: Select all
"INSERT logged_in INTO users_status WHERE username = '$_SESSION[username]'"
in the CMS section
to see how many people have there status set as logged_in use........
Code: Select all
mysql_query = "SELECT * FROM mytable WHERE users_status = 'logged_in'";
print mysql_affected_rows();
this should give you a value of how many people matching that description so you do what you want to do
hope that helps