Home
>
Outdated forums
>
Phorum 3 forums (READ ONLY)
>
Finished Mods and Plug-ins (READ ONLY)
>
Topic
<b>[code] Who's Online</b>
Posted by <b>Vulpes</b>
<b>[code] Who's Online</b> January 22, 2002 12:03AM |
AgeM
Re: [code] Who's Online January 24, 2002 06:36PM |
Re: [code] Who's Online January 30, 2002 05:05PM |
Jules
Re: [code] Who's Online February 02, 2002 02:57PM |
Re: [code] Who's Online February 02, 2002 04:50PM |
Jules
Re: [code] Who's Online February 03, 2002 05:31AM |
Re: [code] Who's Online February 03, 2002 08:03AM |
<b>Re: [code] Who's Online</b> February 03, 2002 04:00PM |
C'mon Guys... February 04, 2002 09:23PM |
Jules
Re: C'mon Guys... February 06, 2002 12:51AM |
ok..lets see....the functions were made basically for this "who is online feature" to work with the forum system only since the files defined in them are the post.php, read.php, list.php, index.php and the script page (whoisonline.php)....and i guess its a little more complicated to get it working with the whole site...i havent thought about playing around with that yet..have no time....but i guess its possible...well lets get to it...
this is what i did...dunno if its the best way, but it seems to work for me...
the functions go in the common.php since that file is loaded in the post.php, read.php, list.php, etc....can put them after all the functions around line 273 (in version 332a) ....the call script is what calls these functions, so if you wanna see people on your site you must call from each of the files mentioned in the functions (post.php, read.php, list.php, index.php and the whoisonline.php) so include in each file after the call for the header(towards the middle of the files), the call script...or put
include "callscript.php";
and in the call script you place the code:
if(!empty($phorum_auth)){
$whoisuser="<a href=\"profile.php?id=$phorum_user[id]\" class=\"topmed\">$phorum_user[name]</a>";
}else{
$name_cookie="phorum_name";
if(isset($$name_cookie) && empty($author)){
$whoisuser=$$name_cookie;
}
elseif(!isset($user)){
$whoisuser="Guest";
}
}
$IP=$REMOTE_ADDR;
$ssql="SELECT username FROM whosonline where ip='record'";
$q->query($DB, $ssql);
$record=$q->getrow();
$pagename=get_location($PHP_SELF,$REQUEST_URI,$title,$ForumName);
get_whosonline($IP, $whoisuser, $pagename);
this way if needed to make any modification, you change it only once =P
and unlike the original code, on this last line you are calling the function that records to the database what the user is doing, deletes the old peeps and/or updates....you are not printing the results on the screen like done here on this site (ex: 1 now/17 max)...the call script here on this site is placed in the header and prints out directly the info...i placed mine in each of those files and calling only the function making no output....
if you put the original code, you will get the online info on top of everything you do, the forum list, while reading msgs..etc...not nice...thats good to go on the header only, but since i only have it displayed in one place (index.php) i placed the original code there and didnt make the call for the call script...i placed it there cuz its diferent from the call script and its printing out the online info (ex: 3 now/17 max)...
ok, now make the whoisonline.php, tweak the html to your taste and run it in the same dir as phorum and the other files...
but make sure you have created the table and included that entry so the max function can work...dont delete that line...
create links to the whoisonline.php on your site and you are all set....
and if you want to enhance the functions, you can add this to the get_location function in its proper place:
case "profile.php":
$pagename="Viewing a profile.";
break;
its just one more thing someone might be doing =P maybe someone could enhance this to show which profile they are viewing? =P
you can create others i guess, but dont forget to "include" the call script...or else makes no diference..no one will know you are there =P
an example of this script running at my site...if you wanna see it..just dont mind the portuguese =P
[forum.aliennation.com.br]
and
[forum.aliennation.com.br]
Jules
this is what i did...dunno if its the best way, but it seems to work for me...
the functions go in the common.php since that file is loaded in the post.php, read.php, list.php, etc....can put them after all the functions around line 273 (in version 332a) ....the call script is what calls these functions, so if you wanna see people on your site you must call from each of the files mentioned in the functions (post.php, read.php, list.php, index.php and the whoisonline.php) so include in each file after the call for the header(towards the middle of the files), the call script...or put
include "callscript.php";
and in the call script you place the code:
if(!empty($phorum_auth)){
$whoisuser="<a href=\"profile.php?id=$phorum_user[id]\" class=\"topmed\">$phorum_user[name]</a>";
}else{
$name_cookie="phorum_name";
if(isset($$name_cookie) && empty($author)){
$whoisuser=$$name_cookie;
}
elseif(!isset($user)){
$whoisuser="Guest";
}
}
$IP=$REMOTE_ADDR;
$ssql="SELECT username FROM whosonline where ip='record'";
$q->query($DB, $ssql);
$record=$q->getrow();
$pagename=get_location($PHP_SELF,$REQUEST_URI,$title,$ForumName);
get_whosonline($IP, $whoisuser, $pagename);
this way if needed to make any modification, you change it only once =P
and unlike the original code, on this last line you are calling the function that records to the database what the user is doing, deletes the old peeps and/or updates....you are not printing the results on the screen like done here on this site (ex: 1 now/17 max)...the call script here on this site is placed in the header and prints out directly the info...i placed mine in each of those files and calling only the function making no output....
if you put the original code, you will get the online info on top of everything you do, the forum list, while reading msgs..etc...not nice...thats good to go on the header only, but since i only have it displayed in one place (index.php) i placed the original code there and didnt make the call for the call script...i placed it there cuz its diferent from the call script and its printing out the online info (ex: 3 now/17 max)...
ok, now make the whoisonline.php, tweak the html to your taste and run it in the same dir as phorum and the other files...
but make sure you have created the table and included that entry so the max function can work...dont delete that line...
create links to the whoisonline.php on your site and you are all set....
and if you want to enhance the functions, you can add this to the get_location function in its proper place:
case "profile.php":
$pagename="Viewing a profile.";
break;
its just one more thing someone might be doing =P maybe someone could enhance this to show which profile they are viewing? =P
you can create others i guess, but dont forget to "include" the call script...or else makes no diference..no one will know you are there =P
an example of this script running at my site...if you wanna see it..just dont mind the portuguese =P
[forum.aliennation.com.br]
and
[forum.aliennation.com.br]
Jules
Re: C'mon Guys... February 06, 2002 05:12PM |
Thanks Jules for the instructions! This should really help getting this hack working. I do have a few questions...
1. The two functions are get_location and Get_whosonline.
2. I am assuming that the "CREATE TABLE whosonline" should be run in MySQL to create the table and it's parms. As well as the "INSERT INTO" statement to populate an initial value as you stated above.
3. It is my understanding of your instructions that your code for the call script is meant to replace the original call script.
3.a. The value for $name_cookie of "phorum_name" is that the actual value or the value of the forum that the code is being used in? For example if I have three forums with the names of Public, Private, and Admin, the value for $name_cooke would be Public on the public forum and so on.
4. From the looks of the whosonline.php and your instructions it appears to be it's own web page (ie. it has include footer.php).
Thanks again for providing some instructions on this hack I will be testing it out tonight!
Thanks!
1. The two functions are get_location and Get_whosonline.
2. I am assuming that the "CREATE TABLE whosonline" should be run in MySQL to create the table and it's parms. As well as the "INSERT INTO" statement to populate an initial value as you stated above.
3. It is my understanding of your instructions that your code for the call script is meant to replace the original call script.
3.a. The value for $name_cookie of "phorum_name" is that the actual value or the value of the forum that the code is being used in? For example if I have three forums with the names of Public, Private, and Admin, the value for $name_cooke would be Public on the public forum and so on.
4. From the looks of the whosonline.php and your instructions it appears to be it's own web page (ie. it has include footer.php).
Thanks again for providing some instructions on this hack I will be testing it out tonight!
Thanks!
Here is where I am at February 06, 2002 06:49PM |
I followed your instructions and I only placed the include for the callscript.php in index.php and here is what I get...
if(!empty($phorum_auth)){ $whoisuser="$phorum_user[name]"; }else{ $name_cookie="phorum_name"; if(isset($$name_cookie) && empty($author)){ $whoisuser=$$name_cookie; } elseif(!isset($user)){ $whoisuser="Guest"; } } $IP=$REMOTE_ADDR; $ssql="SELECT username FROM whosonline where ip='record'"; $q->query($DB, $ssql); $record=$q->getrow(); $pagename=get_location($PHP_SELF,$REQUEST_URI,$title,$ForumName); get_whosonline($IP, $whoisuser, $pagename);
The above code is displayed on the page.......
Any ideas?
if(!empty($phorum_auth)){ $whoisuser="$phorum_user[name]"; }else{ $name_cookie="phorum_name"; if(isset($$name_cookie) && empty($author)){ $whoisuser=$$name_cookie; } elseif(!isset($user)){ $whoisuser="Guest"; } } $IP=$REMOTE_ADDR; $ssql="SELECT username FROM whosonline where ip='record'"; $q->query($DB, $ssql); $record=$q->getrow(); $pagename=get_location($PHP_SELF,$REQUEST_URI,$title,$ForumName); get_whosonline($IP, $whoisuser, $pagename);
The above code is displayed on the page.......
Any ideas?
Some Progress... February 06, 2002 07:15PM |
OK, I have made some progress...
I made the following changes to the original callscript.php code but the link to whosonline.php still does not work....
In the callscript.php file I added <?PHP and ?> tags see below.
------here is the <?PHP addition -------------
<?PHP
if(!empty($phorum_auth)){
$whoisuser="<a href=\"profile.php?id=$phorum_user[id]\" class=\"topmed\">$phorum_user[name]</a>";
}else{
$name_cookie="phorum_name";
if(isset($$name_cookie) && empty($author)){
$whoisuser=$$name_cookie;
}
elseif(!isset($user)){
$whoisuser="Guest";
}
}
$IP=$REMOTE_ADDR;
------------ HERE IS THE ?> ADDITION ----------------
?>
<br><a href="whoisonline.php?f=<?php echo $f; ?>"class='topmed'><font color =white>Who's Online</a>
<?PHP
$ssql="SELECT username FROM whosonline where ip='record'";
$q->query($DB, $ssql);
$record=$q->getrow();
$pagename=get_location($PHP_SELF,$REQUEST_URI,$title,$ForumName);
echo "<br> <font color =white> ".get_whosonline($IP, $whoisuser, $pagename)." now/".$record['username']; ?> Max
</font>
I made the following changes to the original callscript.php code but the link to whosonline.php still does not work....
In the callscript.php file I added <?PHP and ?> tags see below.
------here is the <?PHP addition -------------
<?PHP
if(!empty($phorum_auth)){
$whoisuser="<a href=\"profile.php?id=$phorum_user[id]\" class=\"topmed\">$phorum_user[name]</a>";
}else{
$name_cookie="phorum_name";
if(isset($$name_cookie) && empty($author)){
$whoisuser=$$name_cookie;
}
elseif(!isset($user)){
$whoisuser="Guest";
}
}
$IP=$REMOTE_ADDR;
------------ HERE IS THE ?> ADDITION ----------------
?>
<br><a href="whoisonline.php?f=<?php echo $f; ?>"class='topmed'><font color =white>Who's Online</a>
<?PHP
$ssql="SELECT username FROM whosonline where ip='record'";
$q->query($DB, $ssql);
$record=$q->getrow();
$pagename=get_location($PHP_SELF,$REQUEST_URI,$title,$ForumName);
echo "<br> <font color =white> ".get_whosonline($IP, $whoisuser, $pagename)." now/".$record['username']; ?> Max
</font>
<b>Re: Some Progress...</b> February 06, 2002 07:18PM |
Other non forum applications? February 08, 2002 12:58AM |
Re: Here is where I am at February 16, 2002 08:46PM |
Now I have used 3 hours on this script and it still not work :o(
What is wrong?
I am using Phorum version: 3.3.2a
In the top of index.php I have insert this linie:
<? include "callscript.php";?>
I have make two new files:
callscript.php and whosonline.php
---- inside the callscript.php-----
<?PHP
if(!empty($phorum_auth)){
$whoisuser="<a href=\"/debat/profile.php?id=$phorum_user[id]\" class=\"topmed\">$phorum_user[name]</a>";
}else{
$name_cookie="phorum_name";
if(isset($$name_cookie) && empty($author)){
$whoisuser=$$name_cookie;
}
elseif(!isset($user)){
$whoisuser="Guest";
}
}
$IP=$REMOTE_ADDR;
?>
<br><a href="/debat/whoisonline.php?f=<?php echo $f; ?>"class='topmed'><font color =white>Who's Online</a>
<?PHP
$ssql="SELECT username FROM whosonline where ip='record'";
$q->query($DB, $ssql);
$record=$q->getrow();
$pagename=get_location($PHP_SELF,$REQUEST_URI,$title,$ForumName);
echo "<br> <font color =white> ".get_whosonline($IP, $whoisuser, $pagename)." now/".$record['username']; ?> Max
</font>
------- inside whosonline.php --------
<?php require "./common.php"; if(file_exists("$include_path/header_$ForumConfigSuffix.$ext")){ include "$include_path/header_$ForumConfigSuffix.$ext"; } else{ include "$include_path/header.$ext"; } if($f!=0){ $table_width=$ForumTableWidth; $table_header_color=$cell_color_2; $table_header_font_color=$ForumTableHeaderFontColor; $table_body_color_1=$ForumTableBodyColor1; $table_body_font_color_1=$ForumTableBodyFontColor1; $nav_color=$ForumNavColor; } else{ $table_width=$default_table_width; $table_header_color=$cell_color_2; $table_header_font_color=$default_table_header_font_color; $table_body_color_1=$default_table_body_color_1; $table_body_font_color_1=$default_table_body_font_color_1; $nav_color=$default_nav_color; } $title = "Who's Online"; $ForumName="Who's Online"; ?> <table cellpadding=2 cellspacing=1 border=0 width="100%" Bgcolor="#F5F5F5"><tr><td> <table border=0 cellpadding=0 cellspacing=0 width="100%"><tr><td bgcolor="#000000"> <table cellpadding=3 cellspacing=1 border=0 width="100%"> <TR <?PHP echo bgcolor($table_header_color); ?> ALIGN="LEFT"> <TD><FONT color="<?PHP echo $table_header_font_color; ?>" nowrap>Name</FONT></TD> <TD><FONT color="<?PHP echo $table_header_font_color; ?>" width="100%">Place On Website</FONT></TD> </TR> <?php $sql = "SELECT * FROM whosonline where ip!='record'"; $q->query($DB,$sql); $rec=$q->getrow(); while(is_array($rec)){ echo "<TR bgcolor='$table_body_color_1' ALIGN=\"LEFT\">"; echo "<td nowrap bgcolor=$cell_color_1>$rec[username]</td><td width=\"100%\">$rec[forum]</td>"; echo "</tr>"; $rec=$q->getrow(); } ?> </TABLE> </TD></TR> </TABLE> </td></tr> </table> <?PHP if(file_exists("$include_path/footer_$ForumConfigSuffix.php")){ include "$include_path/footer_$ForumConfigSuffix.php"; } else{ include "$include_path/footer.php"; } ?>
And add the dump to the mysql.
But noting happens.
I'am on a Apache server with mysql.
Cheers
Jesper
What is wrong?
I am using Phorum version: 3.3.2a
In the top of index.php I have insert this linie:
<? include "callscript.php";?>
I have make two new files:
callscript.php and whosonline.php
---- inside the callscript.php-----
<?PHP
if(!empty($phorum_auth)){
$whoisuser="<a href=\"/debat/profile.php?id=$phorum_user[id]\" class=\"topmed\">$phorum_user[name]</a>";
}else{
$name_cookie="phorum_name";
if(isset($$name_cookie) && empty($author)){
$whoisuser=$$name_cookie;
}
elseif(!isset($user)){
$whoisuser="Guest";
}
}
$IP=$REMOTE_ADDR;
?>
<br><a href="/debat/whoisonline.php?f=<?php echo $f; ?>"class='topmed'><font color =white>Who's Online</a>
<?PHP
$ssql="SELECT username FROM whosonline where ip='record'";
$q->query($DB, $ssql);
$record=$q->getrow();
$pagename=get_location($PHP_SELF,$REQUEST_URI,$title,$ForumName);
echo "<br> <font color =white> ".get_whosonline($IP, $whoisuser, $pagename)." now/".$record['username']; ?> Max
</font>
------- inside whosonline.php --------
<?php require "./common.php"; if(file_exists("$include_path/header_$ForumConfigSuffix.$ext")){ include "$include_path/header_$ForumConfigSuffix.$ext"; } else{ include "$include_path/header.$ext"; } if($f!=0){ $table_width=$ForumTableWidth; $table_header_color=$cell_color_2; $table_header_font_color=$ForumTableHeaderFontColor; $table_body_color_1=$ForumTableBodyColor1; $table_body_font_color_1=$ForumTableBodyFontColor1; $nav_color=$ForumNavColor; } else{ $table_width=$default_table_width; $table_header_color=$cell_color_2; $table_header_font_color=$default_table_header_font_color; $table_body_color_1=$default_table_body_color_1; $table_body_font_color_1=$default_table_body_font_color_1; $nav_color=$default_nav_color; } $title = "Who's Online"; $ForumName="Who's Online"; ?> <table cellpadding=2 cellspacing=1 border=0 width="100%" Bgcolor="#F5F5F5"><tr><td> <table border=0 cellpadding=0 cellspacing=0 width="100%"><tr><td bgcolor="#000000"> <table cellpadding=3 cellspacing=1 border=0 width="100%"> <TR <?PHP echo bgcolor($table_header_color); ?> ALIGN="LEFT"> <TD><FONT color="<?PHP echo $table_header_font_color; ?>" nowrap>Name</FONT></TD> <TD><FONT color="<?PHP echo $table_header_font_color; ?>" width="100%">Place On Website</FONT></TD> </TR> <?php $sql = "SELECT * FROM whosonline where ip!='record'"; $q->query($DB,$sql); $rec=$q->getrow(); while(is_array($rec)){ echo "<TR bgcolor='$table_body_color_1' ALIGN=\"LEFT\">"; echo "<td nowrap bgcolor=$cell_color_1>$rec[username]</td><td width=\"100%\">$rec[forum]</td>"; echo "</tr>"; $rec=$q->getrow(); } ?> </TABLE> </TD></TR> </TABLE> </td></tr> </table> <?PHP if(file_exists("$include_path/footer_$ForumConfigSuffix.php")){ include "$include_path/footer_$ForumConfigSuffix.php"; } else{ include "$include_path/footer.php"; } ?>
And add the dump to the mysql.
But noting happens.
I'am on a Apache server with mysql.
Cheers
Jesper
Re: Here is where I am at February 16, 2002 08:46PM |
See my site: etc: [www.jjnet.dk]
Hello there, after having this great addon working for a few months I have decided to find out how come some of the users had a link to their profile from the whoisonline page and some didn't (I was among those who didn't...).
After removing my cookie I found out that the who's online is not fully compatible with the latest stable phorum as for some reason $phorum_auth is empty (It's initialized correctly on other pages other than the who's online page...)
also - it fails to take phorum_name from the cookie, so it says I am a guest.
When I am on other pages it reports everything correctly (I have looked on the DB directly since watching the who's online script resets everything...)
What do you say?
After removing my cookie I found out that the who's online is not fully compatible with the latest stable phorum as for some reason $phorum_auth is empty (It's initialized correctly on other pages other than the who's online page...)
also - it fails to take phorum_name from the cookie, so it says I am a guest.
When I am on other pages it reports everything correctly (I have looked on the DB directly since watching the who's online script resets everything...)
What do you say?
Jules
Re: A bug? February 20, 2002 01:23AM |
yes i noticed that also....before i noticed that when the users name has no link, its becuz they are not logged on...but with the latest stable version of phorum, i logged in and went to the whoisonline page and im there as if i were logged out...something to do with cookie handling i guess...
besides that everything else is fine...
besides that everything else is fine...
<b>Re: A bug?</b> February 20, 2002 06:05PM |
Sorry, you do not have permission to post/reply in this forum.