Firefox PHP

Display moderators for the forum

Posted by easyexpat 
Display moderators for the forum
June 14, 2003 07:32AM
Hi,
I wrote a simple function to display the list of moderators for each forum.
Tested on Phorum 3.4.3a - index.php
-------------------
in the if(!$rec["folder"]){ section about line 150
-----------------
//MODIF->Add list of moderators
$pho_mod = $PHORUM['mod_table'];
$sSQL="Select moderation from $pho_main where id=$num";
$mq = new query($DB, $sSQL);
$mrec=$mq->getrow();
$mod=$mrec["moderation"];
if($mod != "n")
{
$modnames = "";
$sSQL="SELECT user_id FROM $pho_mod WHERE forum_id=$num";
$mq= new query($DB, $sSQL);
$i=0;
$sep = "";
while($mrec=$mq->getrow())
{
$i++;
$pho_auth = $PHORUM['auth_table'];
$modo_id = $mrec['user_id'];
$sSQL = "SELECT username from $pho_auth WHERE id=$modo_id";
$zq = new query($DB, $sSQL);
$zrec=$zq->getrow();
$modo_name = $zrec["username"];
if ($i > 1)
$sep = ", ";
$modnames .= $sep."<a href='profile.$ext?f=$num&id=$modo_id$GetVars'>$modo_name</a>";
}
}
------------------
And about line 220 in the text:
------------------
<!--MODIF: display the moderators-->
<?php
if(!empty($modnames))
{
?>
<tr>
<td colspan=3 bgcolor="<?php echo $table_body_color_1; ?>"><FONT color="<?php echo $ForumNavFontColor; ?>"><blockquote><?php echo $lModerator; ?>: <b><?php echo $modnames ?><b></blockquote></font></td>
</tr>
<?php
}



Post Edited (06-14-03 07:07)
me
Re: Display moderators for the forum
July 24, 2003 09:40AM
doesn't seem to work, where exactly do I have to paste the last part to?
Re: Display moderators for the forum
August 01, 2003 04:39PM
I attached the file to the post.
Because I've done some URL rewriting and other changes, you will see other comments. Just ignore them and focus on the comments for moderators (the line number is not always correct because lines moved when I make the changes, but it gives you an idea where to look at).
In addition in your lang file I added the variable: $lModeratorp = "Moderators"; for the plurial of moderator when needed.

If you want to see the results go to my forum: [www.easyexpat.com]

Cyril

Attachments:
open | download - index.php (9.1 KB)
I...
December 31, 2003 02:00PM
Have 3.4.5, but I couldn't find the proper things to put that in...could you email me your index.php file, and I can test it that way, and if it works, I'll use it? Email is cliekid@the-barracks.org . Thanks!
Thanks! It works perfectly in 3.4.5! =)
Re: Display moderators for the forum
February 06, 2004 07:03AM
Hi,

I'm going to install it with 3.4.6., but when I look at your site I see a cool Who's online hack...is it possible to send also that code ?

I mean this one : [www.easyexpat.com]

grtz,
sammy
I second that! The 'who's online' feature is excellent...if you could share it that'd be great! :-)
Re: Display moderators for the forum
February 07, 2004 05:43AM
Great to see that others find it useful :-)
Give me today (I'm too busy currently as I migrate to a dedicated server the all website) and I will give you the info...
BTW, I think I found some tips for displaying the moderators on this forum...can't remember but it's likely.
Thanks easyexpat!
I look forward to that script!

:-D
Re: Display moderators for the forum
February 14, 2004 06:59AM
Hi,
Sorry to be so long to answer but we had tremendous problems with our hosting provider and finally it was fixed by ...changing to an new one hopefully more relliable on a dedicated server.

The code for the Who's on line has been given by Vulpes here: [phorum.org].

The only thing that I did is to change it a bit to make it similar to phpBB.
You will find attached my index.php with the functions.

In addition at the same level I've got the Whosonline.php and callscript.php.

Eventually you need to had in your include/footer.php the following:
======
footer.php
======
<?php
//MODIF-> add the whoisoline plugin
include "callscript.php";
?>
=======

Of course you need also to modify your lang scritps, with additional variable. I give an example in english:
======
langen.php
=======
$lWho_title = "Who is Online?";
$lWho_nbposts1 = "Our users have posted a total of";
$lWho_nbposts2 = "messages";
$lWho_nbuser1 = "We have";
$lWho_nbuser2 = "registered users";
$lWho_newest = "The newest registered user is";
$lWho_on1 = "In total there are";
$lWho_on2 = "users online :: ";
$lWho_on3 = "Registered,";
$lWho_on4 = "Guests";
$lWho_most = "Most users ever online at the same time was";
$lWho_reg = "Registered Users:";
$lWho_elapsed = "This data is based on users active over the past 3 minutes";
==========

Voila, I think that's it.

Good luck

Cyril



Post Edited (02-14-04 05:59)
Attachments:
open | download - index.php (9.7 KB)
open | download - whoisonline.php (3.4 KB)
open | download - callscript.php (4.2 KB)
I tried to install all on 3.4.6.....bùt it didn't work.....I will try again tomorrow.....
Re: Display moderators for the forum
February 16, 2004 06:34PM
I've got some prob. when i use the callscript. Then the whole forum won't work anymore.

Without the callscript no problems. Tommorow I will look at it, but my php isn't very...so don't expect to much from me
Works great for me, though i had to deleate a line to get it to work.
Thanks Easyexpat!
Re: Display moderators for the forum
February 17, 2004 01:14PM
what version do you use ?

I use 3.4.6 and don't know why it doesn't work, tried a few things to change in the callscript.

Is it possible to upload your callscript.php ?
I just deleted this line in callscript.php -

$who_username = get_regonline($f);
Re: Display moderators for the forum
February 18, 2004 04:20PM
Sorry guys, but I forgot that a lot of my functions are actually in common.php. This includes the get_regonline function that you are missing Sammy.

It might sort out also other problems.

Check line 218->Whoisonline script with the 2 get_ fucntions afterwards...

Cyril



Post Edited (02-19-04 02:08)
ù're link don't work cyril !!!....bùt if i delete the line $who_username = get_regonline($f); in callscript.php , i have an other pb with index.php on line 163.....maybe y langen.php isn't in the good place ??....I look for the pb....
Re: Display moderators for the forum
February 19, 2004 03:09AM
Sorry for the link, I tried to put it again but it doesn't work... maybe it's too big.
Anywway the functions to add in your common.php are below:
---------
//MODIF->Whoisonline script
function get_location($PHP_SELF,$REQUEST_URI,$title,$ForumName)
{
switch(basename($PHP_SELF))
{
case "post.php":
$pagename="Posting Now Topic in <b><a href=\"$REQUEST_URI\">".$ForumName."</a></b>";
break;
case "whoisonline.php":
$pagename="Viewing this page";
break;
case "index.php":
$pagename="Viewing: <b><a href=\"$REQUEST_URI\">".$title."</a></b>";
break;
case "list.php":
$pagename="Reading: <b><a href=\"$REQUEST_URI\">".$ForumName."</a></b> Forum";
break;
case "read.php":
$readtitle=$title;
$readtitle=str_replace("-"," ",$readtitle);
$pagename="Reading: <b><a href=\"$REQUEST_URI\">".$readtitle."</a></b> in <b>".$ForumName."</b> Forum";
break;
}
return $pagename;
}

function get_whosonline($IP, $username, $pagename)
{
global $DB,$q;
//Kill Old guys
$sql="delete from whosonline where ts < DATE_SUB(NOW(), INTERVAL 3 MINUTE) and ip!='record'";
$q->query($DB, $sql);
//Replace each entry with new one...if it doest exist it creates new one
$sql="replace INTO whosonline (ip, username, forum) VALUES('$IP', '$username', '$pagename')";
$q->query($DB, $sql);
//count them
$sql="SELECT count(*) as total FROM whosonline where ip!='record'";
$q->query($DB, $sql);
$users=$q->field("total", 0);
//count guest number
$sql="SELECT count(*) as total FROM whosonline where ip!='record' and (username='Guest' or username='')";
$q->query($DB, $sql);
$guests=$q->field("total", 0);
//count member number
$sql="SELECT count(*) as total FROM whosonline where ip!='record' and username<>'Guest'";
$q->query($DB, $sql);
$members=$q->field("total", 0);

$userframe[users]=$users;
$userframe[guests]=$guests;
$userframe[members]=$members;

//check record table
$sql="SELECT username FROM whosonline WHERE ip='record'";
$q->query($DB, $sql);
$record=$q->getrow();
if($record[username] < $users)
{
$sql="UPDATE whosonline set username='$users' WHERE ip='record'";
$q->query($DB, $sql);
}
return $userframe;
}

function get_regonline($f)
{
global $DB, $q, $ext;

$sSQL="SELECT ip, username FROM whosonline WHERE username<>\"Guest\" and ip<>\"record\"";
$q->query($DB, $sSQL);
$sep = "";
while($record=$q->getrow())
{
$i++;
if ($i > 1)
$sep = ", ";
$id=$record['ip'];
$name=$record['username'];
$members .= $sep."<a href='profile.$ext?f=$f&id=$id$GetVars'>$name</a>";
}
return $members;
}
--------------
The stuff won't work without them, so put them in the file, it's not complicated.

Cyril



Post Edited (02-19-04 02:13)
Attachments:
open | download - common.php (16.7 KB)
Re: Display moderators for the forum
February 19, 2004 04:38AM
great job it works perfectly after some searching beacause i'am not very good in php.

some additions to the comments for beginner like me:

do not forget to create the table whoisonline ;-)


CREATE TABLE whosonline (
ip char(15) NOT NULL default '',
ts timestamp(14) NOT NULL,
username char(255) NOT NULL default '',
forum char(250) NOT NULL default '',
PRIMARY KEY (ip),
KEY ts (ts),
KEY forum (forum)
) TYPE=MyISAM;

INSERT INTO whosonline VALUES ('record', 20011118030340, '1', 'Whatever');




if you read 0 registered user and not last registered user ...
.....check in the callscript.php it was forum_auth intead of phorum_auth for me ....

$tsql="SELECT count(*) as total FROM phorum_auth";
$q->query($DB, $tsql);
$who_nbusers=$q->field("total", 0);

$usql="SELECT username, id FROM phorum_auth ORDER BY id DESC";
$q->query($DB, $usql);
$record2=$q->getrow();
$who_lastid=$record2['id'];
$who_lastuser=$record2['username'];


now it's working great !!! at:
<www.mammillarias.net/phorum/>
thanks to all !!!

Franck
(from France)
Who is online like BB
February 19, 2004 04:40AM
I just change the subjet line for that this thread will be be easy searchable ....beacause i have search this script 2 days .......
Sorry, you do not have permission to post/reply in this forum.