Welcome, Guest. Please Login or Register.
May 04, 2025, 01:00:29 PM
Home Help Search Log in Register
News: SMF is the next generation in forum software, almost completely re-written from the ground up, make sure you don't fall for cheap imitations that suffer from feature bloat!

YaBB SE Community  |  Development  |  Mod Ideas and Creation  |  show user online for a defined user class « previous next »
Pages: [1] Reply Ignore Print
Author Topic: show user online for a defined user class  (Read 411 times)
sPoOL
Noobie
*
Posts: 8


I'm a llama!

show user online for a defined user class
« on: June 17, 2002, 08:12:30 AM »
Reply with quote

how it sounds to schow online useres online to one or more defined user groups?
Logged
Jedi~
Eric
Beta Tester
YaBB God
*****
Posts: 1284


WWW
Re:show user online for a defined user class
« Reply #1 on: June 17, 2002, 11:22:12 AM »
Reply with quote

Go into BoardIndex.php and fine this bit of code:

$guests = 0;
   $tmpusers = array();
   $request3 = mysql_query("SELECT lo.identity, m.realName, m.memberGroup FROM {$db_prefix}log_online AS lo LEFT JOIN {$db_prefix}members AS m ON (m.memberName=lo.identity) WHERE 1 ORDER BY logTime DESC");
   while ($tmp = mysql_fetch_array($request3))
   {
      $identity = $tmp['identity'];
      $euser=urlencode($identity);

      if ($tmp['realName'] != '')
      {
         if ($tmp['memberGroup']=="Administrator")
   $tmpusers[] = "<a href=\"$scripturl?action=viewprofile;user=$euser\"><font color=\"red\">$tmp[realName]</font></a>";
elseif ($tmp['memberGroup']=="Global Moderator")
   $tmpusers[] = "<a href=\"$scripturl?action=viewprofile;user=$euser\"><font color=\"blue\">$tmp[realName]</font></a>";
elseif ($tmp['memberGroup']=="Beta Tester")
   $tmpusers[] = "<a href=\"$scripturl?action=viewprofile;user=$euser\"><font color=\"orange\">$tmp[realName]</font></a>";
else
   $tmpusers[] = "<a href=\"$scripturl?action=viewprofile;user=$euser\">$tmp[realName]</a>";
      }
      else
         $guests ++;
   }
    //change here
   $users = "<font size=1>".implode(", ",$tmpusers)."</font>";
   $numusersonline = sizeof($tmpusers);

    //Determines most user online - both all time and per day
    $total_users=$guests+$numusersonline;
    $tot_date=time();
    if (($modSettings['trackStats'] == 1) && ($total_users > $modSettings['mostOnline']))
    {
     $result=mysql_query("UPDATE {$db_prefix}settings SET value='$total_users' WHERE variable='mostOnline'");
     $result=mysql_query("UPDATE {$db_prefix}settings SET value='$tot_date' WHERE variable='mostDate'");
    }

   if ($modSettings['trackStats'] == 1)
   {
      $mdate = getdate(time());
      $monthquery = mysql_query("SELECT MAX(mostOn) as mostOn FROM {$db_prefix}log_activity WHERE month = $mdate[mon] AND day = $mdate[mday] AND year = $mdate[year]");
      echo mysql_error();
      $temp = mysql_fetch_row($monthquery);
      $oldMost = $temp[0];
      if ($total_users>$oldMost){
       $statsquery = mysql_query("UPDATE {$db_prefix}log_activity SET mostOn = $total_users WHERE month = $mdate[mon] AND day = $mdate[mday] AND year = $mdate[year]");
                 if(mysql_affected_rows() == 0)
                  $statsquery = mysql_query("INSERT INTO {$db_prefix}log_activity (month, day, year, mostOn) VALUES ($mdate[mon], $mdate[mday], $mdate[year], $total_users)");
               }

      //End most users online
   }

It's around line 239. Then add on top of it:
if (($settings[7] == "memberGroup") OR ($settings[7] == "Global Moderator") OR ($settings[7] == "Administrator")) {

After it add this: }
This will show it to admins, global moderators and whatever membergroup you replace memberGroup with. If you need to add more: before the second ) on the end, add: OR ($settings[7] == "memberGroup")Still replacing memberGroup with the desired member group. You need to do a similar thing on another line, however.

Now find this line:
 </tr><tr>
    <td class="windowbg" width="20" valign="middle" align="center"><img src="$imagesdir/online.gif" border="0" alt=""></td>
    <td class="windowbg2" width="100%">$guests $txt[141], $numusersonline $txt[142]<br>$users $stats</td>
  </tr>
Around 422 somewhere.
Before it, add as you did above:
if (($settings[7] == "memberGroup") OR ($settings[7] == "Global Moderator") OR ($settings[7] == "Administrator")) {
print <<<EOT

Don't forget to put that print <<<EOT in there, if you dont' it will not work.
After the code, add this:
EOT;
}

It is very important that the EOT; has no spaces in front of it!
Logged
iamdamnsam
Full Member
***
Posts: 225


RamchargerCentral.Com

WWW
Re:show user online for a defined user class
« Reply #2 on: June 17, 2002, 10:12:07 PM »
Reply with quote

I went at it a little differentely, I show each group broken down with the number and names of the members of the group online.
Logged

sPoOL
Noobie
*
Posts: 8


I'm a llama!

Re:show user online for a defined user class
« Reply #3 on: June 19, 2002, 10:43:58 AM »
Reply with quote

thx for your help... only on problem... must be a mistake i`ve made

two things are wrong...

1. if the user is a guest the logon promt @ the bottom of the index site does not work... :( the other login does!

2. a user which have the permission to watch the online list will see -> 'if ((FdA == "memberGroup") OR (FdA == "Global Moderator") OR (FdA == "Administrator") OR (FdA == "Moderator") OR (FdA == "FdA")) { print <<'

above the latest postings listing...

can see it in action @ www.verspoolt.org/fdaforum
login-> test-joshi
pass-> 1GVTZQxEXA

1. edited source

if (($settings[7] == "memberGroup") OR ($settings[7] == "Global Moderator") OR ($settings[7] == "Administrator") OR ($settings[7] == "Moderator") OR ($settings[7] == "FdA")) {
        // load the number of users online right now
        $guests = 0;
        $tmpusers = array();
        $request3 = mysql_query("SELECT lo.identity, m.realName, m.memberGroup FROM {$db_prefix}log_online AS lo LEFT JOIN {$db_prefix}members AS m ON (m.memberName=lo.identity) WHERE 1 ORDER BY logTime DESC");
        while ($tmp = mysql_fetch_array($request3))
        {
                $identity = $tmp['identity'];
                $euser=urlencode($identity);

                if ($tmp['realName'] != '')
                {
                        if ($tmp['memberGroup']=="Administrator")
   $tmpusers[] = "<a href=\"$scripturl?action=viewprofile;user=$euser\"><font color=\"red\">$tmp[realName]</font></a>";
elseif ($tmp['memberGroup']=="Global Moderator")
   $tmpusers[] = "<a href=\"$scripturl?action=viewprofile;user=$euser\"><font color=\"blue\">$tmp[realName]</font></a>";
elseif ($tmp['memberGroup']=="YaBB SE Developer")
   $tmpusers[] = "<a href=\"$scripturl?action=viewprofile;user=$euser\"><font color=\"green\">$tmp[realName]</font></a>";
elseif ($tmp['memberGroup']=="Mod Team")
   $tmpusers[] = "<a href=\"$scripturl?action=viewprofile;user=$euser\"><font color=\"orange\">$tmp[realName]</font></a>";
else
   $tmpusers[] = "<a href=\"$scripturl?action=viewprofile;user=$euser\">$tmp[realName]</a>";
                }
                else
                        $guests ++;
        }
    //change here
        $users = "<font size=1>".implode(", ",$tmpusers)."</font>";
        $numusersonline = sizeof($tmpusers);

    //Determines most user online - both all time and per day
    $total_users=$guests+$numusersonline;
    $tot_date=time();
    if (($modSettings['trackStats'] == 1) && ($total_users > $modSettings['mostOnline']))
    {
     $result=mysql_query("UPDATE {$db_prefix}settings SET value='$total_users' WHERE variable='mostOnline'");
     $result=mysql_query("UPDATE {$db_prefix}settings SET value='$tot_date' WHERE variable='mostDate'");
    }

        if ($modSettings['trackStats'] == 1)
        {
                $mdate = getdate(time());
                $monthquery = mysql_query("SELECT MAX(mostOn) as mostOn FROM {$db_prefix}log_activity WHERE month = $mdate[mon] AND day = $mdate[mday] AND year = $mdate[year]");
                echo mysql_error();
                $temp = mysql_fetch_row($monthquery);
                $oldMost = $temp[0];
                if ($total_users>$oldMost){
                 $statsquery = mysql_query("UPDATE {$db_prefix}log_activity SET mostOn = $total_users WHERE month = $mdate[mon] AND day = $mdate[mday] AND year = $mdate[year]");
                                          if(mysql_affected_rows() == 0)
                                                $statsquery = mysql_query("INSERT INTO {$db_prefix}log_activity (month, day, year, mostOn) VALUES ($mdate[mon], $mdate[mday], $mdate[year], $total_users)");
                                        }

                //End most users online
        }

2. edited source

if (($settings[7] == "memberGroup") OR ($settings[7] == "Global Moderator") OR ($settings[7] == "Administrator") OR ($settings[7] == "Moderator") OR ($settings[7] == "FdA")) {
print <<<EOT
  <tr>
    <td class="windowbg" width="20" valign="middle" align="center"><img src="$imagesdir/online.gif" border="0" alt=""></td>
    <td class="windowbg2" width="100%">$guests $txt[141], $numusersonline $txt[142]<br>$users $stats</td>
  </tr>
EOT;
  }
« Last Edit: June 19, 2002, 10:45:37 AM by sPoOL » Logged
Jedi~
Eric
Beta Tester
YaBB God
*****
Posts: 1284


WWW
Re:show user online for a defined user class
« Reply #4 on: June 19, 2002, 03:36:13 PM »
Reply with quote

2nd edited source, try this:
EOT;
if (($settings[7] == "Global Moderator") OR ($settings[7] == "Administrator") OR ($settings[7] == "Moderator") OR ($settings[7] == "FdA")) {
print <<<EOT
 <tr>
   <td class="windowbg" width="20" valign="middle" align="center"><img src="$imagesdir/online.gif" border="0" alt=""></td>
   <td class="windowbg2" width="100%">$guests $txt[141], $numusersonline $txt[142]<br>$users $stats</td>
 </tr>
EOT;
 }
If that works, it was my fault, not yours. Also,  you don't need the
($settings[7] == "memberGroup") in either of them, I meant for you to replace memberGroup with the one you wanted, and then add any extras on at the end (like you did), it wouldn't make a differance though.
« Last Edit: June 19, 2002, 03:38:09 PM by Jedi~ » Logged
sPoOL
Noobie
*
Posts: 8


I'm a llama!

Re:show user online for a defined user class
« Reply #5 on: June 20, 2002, 11:38:09 AM »
Reply with quote

hm... if i insert 'EOT;' in front of

if (($settings[7] == "Global Moderator") OR ($settings[7] == "Administrator") OR ($settings[7] == "Moderator") OR ($settings[7] == "FdA")) {

i get a parse error:

Parse error: parse error, unexpected $ in /www/htdocs/v029029/testforum/Sources/BoardIndex.php on line 599

Fatal error: Call to undefined function: boardindex() in /www/htdocs/v029029/testforum/index.php on line 310

Logged
Pages: [1] Reply Ignore Print 
YaBB SE Community  |  Development  |  Mod Ideas and Creation  |  show user online for a defined user class « previous - next »
 


Powered by MySQL Powered by PHP YaBB SE Community | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.
SMF 2.1.4 © 2023, Simple Machines
Valid XHTML 1.0! Valid CSS

Page created in 0.785 seconds with 21 queries.