Hallo, Gast! (Registrieren)

Letzte Ankündigung: MyBB 1.8.38 veröffentlicht (30.04.24)


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste
"User online" im Header Bereich
#4
Ist zwar alles andere als optimiert, aber probier es mal so:

Suche im Template header die Zeilen
Code:
<div class="menu">
<ul>
und setze darunter folgende Zeile ein
Code:
<li style="float:left;">User online: {$onlinecount}</li>
Dann gehe in die global.php und suche die Zeile
PHP-Code:
eval("\$header = \"".$templates->get("header")."\";"); 
setze davor die Zeile
PHP-Code:
getonlineusers(); 
ein. Ganz am Ende der global.php setzt Du anschließend vor dem "?>" folgende Zeilen ein
PHP-Code:
function getonlineusers(){
  global 
$mybb$db$cache$onlinecount;
    
  
// Get the online users.
    
$timesearch TIME_NOW $mybb->settings['wolcutoff'];
    
$comma '';
    
$query $db->query("
        SELECT s.sid, s.ip, s.uid, s.time, s.location, s.location1, u.username, u.invisible, u.usergroup, u.displaygroup
        FROM "
.TABLE_PREFIX."sessions s
        LEFT JOIN "
.TABLE_PREFIX."users u ON (s.uid=u.uid)
        WHERE s.time>'
$timesearch'
        ORDER BY u.username ASC, s.time DESC
    "
);
    
$onlinemembers '';
    
$forum_viewers $doneusers = array();
    
$botcount $membercount $anoncount $guestcount 0;

    
// Fetch spiders
    
$spiders $cache->read("spiders");

    
// Loop through all users.
    
while($user $db->fetch_array($query))
    {
        
// Create a key to test if this user is a search bot.
        
$botkey my_strtolower(str_replace("bot="''$user['sid']));

        
// Decide what type of user we are dealing with.
        
if($user['uid'] > 0)
        {
            
// The user is registered.
            
if(empty($doneusers[$user['uid']]) || $doneusers[$user['uid']] < $user['time'])
            {
                
// If the user is logged in anonymously, update the count for that.
                
if($user['invisible'] == 1)
                {
                    ++
$anoncount;
                }
                ++
$membercount;
                if(
$user['invisible'] != || $mybb->usergroup['canviewwolinvis'] == || $user['uid'] == $mybb->user['uid'])
                {
                    
// If this usergroup can see anonymously logged-in users, mark them.
                    
if($user['invisible'] == 1)
                    {
                        
$invisiblemark "*";
                    }
                    else
                    {
                        
$invisiblemark '';
                    }

                    
// Properly format the username and assign the template.
                    
$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
                    
$user['profilelink'] = build_profile_link($user['username'], $user['uid']);
                    
//eval("\$onlinemembers .= \"".$templates->get("index_whosonline_memberbit", 1, 0)."\";");
                    
$comma $lang->comma;
                }
                
// This user has been handled.
                
$doneusers[$user['uid']] = $user['time'];
            }
        }
        elseif(
my_strpos($user['sid'], "bot=") !== false && $spiders[$botkey])
        {
            
// The user is a search bot.
            
$onlinemembers .= $comma.format_name($spiders[$botkey]['name'], $spiders[$botkey]['usergroup']);
            
$comma $lang->comma;
            ++
$botcount;
        }
        else
        {
            
// The user is a guest.
            
++$guestcount;
        }

        if(
$user['location1'])
        {
            
$forum_viewers[$user['location1']]++;
        }
    }

    
// Build the who's online bit on the index page.
    
$onlinecount $membercount $guestcount $botcount;

Wenn Du die Bots nicht mit zählen möchtest, dann in der letzten einfach das "+ $botcount" weg.
viele Grüße
Jockl
übersetzte und eigene Plugins
Zitieren


Nachrichten in diesem Thema
"User online" im Header Bereich - von Line.Dev - 15.03.2014, 20:19
RE: "User online" im Header Bereich - von Jockl - 15.03.2014, 22:06
RE: "User online" im Header Bereich - von Jockl - 15.03.2014, 22:31
RE: "User online" im Header Bereich - von Jockl - 15.03.2014, 22:57
RE: "User online" im Header Bereich - von Jockl - 15.03.2014, 23:05
RE: "User online" im Header Bereich - von Jockl - 15.03.2014, 23:11
RE: "User online" im Header Bereich - von Jockl - 15.03.2014, 23:15
RE: "User online" im Header Bereich - von Jockl - 15.03.2014, 23:25
RE: "User online" im Header Bereich - von Jockl - 15.03.2014, 23:36
RE: "User online" im Header Bereich - von Jockl - 15.03.2014, 23:41