Check if User is mod and if he is online
Skiilz Offline
Member
***
Posts: 198
Joined: Nov 2010
Post: #6
RE: Check if User is mod and if he is online
ORIGINAL WHOS_ONLINE block:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
/***************************************************************
 * ProPortal
 * Copyright © 2010 ProMyBB, All Rights Reserved
 *
 * Website: http://www.promybb.com/
 * License: http://creativecommons.org/licenses/by-nc-sa/3.0/
 ***************************************************************/
 
if (!defined("IN_PORTAL")) {
	die("<div style=\"border:1px solid #CC0000; padding:3px; margin:0; font-family:Tahoma; width:250px; font-size:12px;\"><strong>Error:</strong> This file cannot be viewed directly!</div>");
}

$timesearch = TIME_NOW - $mybb->settings['wolcutoff'];
$comma = '';
$guestcount = 0;
$membercount = 0;
$onlinemembers = '';
$query = $db->query("
	SELECT s.sid, s.ip, s.uid, s.time, s.location, 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
");
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']));
	
	if($user['uid'] == "0")
	{
		++$guestcount;
	}
	elseif(my_strpos($user['sid'], "bot=") !== false && $session->bots[$botkey])
	{
		// The user is a search bot.
		$onlinemembers .= $comma.format_name($session->bots[$botkey], $session->botgroup);
		$comma = ", ";
		++$botcount;
	}
	else
	{
		if($doneusers[$user['uid']] < $user['time'] || !$doneusers[$user['uid']])
		{
			++$membercount;
			
			$doneusers[$user['uid']] = $user['time'];
			
			// If the user is logged in anonymously, update the count for that.
			if($user['invisible'] == 1)
			{
				++$anoncount;
			}
			
			if($user['invisible'] == 1)
			{
				$invisiblemark = "*";
			}
			else
			{
				$invisiblemark = '';
			}
			
			if(($user['invisible'] == 1 && ($mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid'])) || $user['invisible'] != 1)
			{
				$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
				$user['profilelink'] = get_profile_link($user['uid']);
				$onlinemembers .= "{$comma}<a href=\"{$mybb->settings['bburl']}/{$user['profilelink']}\">{$user['username']}</a>{$invisiblemark}";
				$comma = ", ";
			}
		}
	}
}

$onlinecount = $membercount + $guestcount + $botcount;

// If we can see invisible users add them to the count
if($mybb->usergroup['canviewwolinvis'] == 1)
{
	$onlinecount += $anoncount;
}

// If we can't see invisible users but the user is an invisible user incriment the count by one
if($mybb->usergroup['canviewwolinvis'] != 1 && $mybb->user['invisible'] == 1)
{
	++$onlinecount;
}

// Most users online
$mostonline = $cache->read("mostonline");
if($onlinecount > $mostonline['numusers'])
{
	$time = TIME_NOW;
	$mostonline['numusers'] = $onlinecount;
	$mostonline['time'] = $time;
	$cache->update("mostonline", $mostonline);
}
$recordcount = $mostonline['numusers'];
$recorddate = my_date($mybb->settings['dateformat'], $mostonline['time']);
$recordtime = my_date($mybb->settings['timeformat'], $mostonline['time']);

if($onlinecount == 1)
{
  $lang->online_users = $lang->online_user;
}
else
{
  $lang->online_users = $lang->sprintf($lang->online_users, $onlinecount);
}
$lang->online_counts = $lang->sprintf($lang->online_counts, $membercount, $guestcount);
echo "<table border=\"0\" cellspacing=\"".$theme['borderwidth']."\" cellpadding=\"".$theme['tablespace']."\" class=\"tborder\">
		<tr>
			<td class=\"thead\"><div class=\"expcolimage\"><img src=\"{$theme['imgdir']}/{$expcolimage}\" id=\"block_{$result_blocks['id']}_img\" class=\"expander\" alt=\"{$expaltext}\" title=\"{$expaltext}\" /></div><strong><a href=\"{$mybb->settings['bburl']}/online.php\">{$lang->online}: {$onlinecount}</a></strong></td>
		</tr>
		<tbody style=\"{$expdisplay}\" id=\"block_{$result_blocks['id']}_e\">
		<tr>
			<td class=\"tcat\"><span class=\"smalltext\">{$lang->online_counts}</span></td>
		</tr>
		<tr>
			<td class=\"trow1\">{$onlinemembers}</td>
		</tr>
		</tbody>
	</table>";
?>


MODIFIED BLOCK: (I think something is messed up.. But I can't test it because I can't access my FTP account for some reason :/. The query is wrong too it needed to b changed to fit our needs.)

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/***************************************************************
 * ProPortal
 * Copyright © 2010 ProMyBB, All Rights Reserved
 *
 * Website: http://www.promybb.com/
 * License: http://creativecommons.org/licenses/by-nc-sa/3.0/
 ***************************************************************/
 
if (!defined("IN_PORTAL")) {
	die("<div style=\"border:1px solid #CC0000; padding:3px; margin:0; font-family:Tahoma; width:250px; font-size:12px;\"><strong>Error:</strong> This file cannot be viewed directly!</div>");
}

$timesearch = TIME_NOW - $mybb->settings['wolcutoff'];
//$space = '';
$staffcount = 0;
$onlinestaff = '';
$query = $db->query("
	SELECT s.sid, s.ip, s.uid, s.time, s.location, u.username, 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
");
while($user = $db->fetch_array($query))
{
		if($doneusers[$user['uid']] < $user['time'] || !$doneusers[$user['uid']])
		{
			++$staffcount;
			
			$doneusers[$user['uid']] = $user['time'];
			
			if($mybb->usergroup['canmodcp'] == 1 || $user['uid'] == $mybb->user['uid'])
			{
				$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
				$user['profilelink'] = get_profile_link($user['uid']);
				$onlinestaff .= "<a href=\"{$mybb->settings['bburl']}/{$user['profilelink']}\">{$user['username']}</a>";
				//$space = "<br />";
			}
		}
	}
}

$onlinestaff = $staffcount;

echo "<table border=\"0\" cellspacing=\"".$theme['borderwidth']."\" cellpadding=\"".$theme['tablespace']."\" class=\"tborder\">
		<tr>
			<td class=\"thead\" colspan=\"2\"><div class=\"expcolimage\"><img src=\"{$theme['imgdir']}/{$expcolimage}\" id=\"block_{$result_blocks['id']}_img\" class=\"expander\" alt=\"{$expaltext}\" title=\"{$expaltext}\" /></div>
			<strong>Online Staff: {$staffcount}</td>
		</tr>
		<tbody style=\"{$expdisplay}\" id=\"block_{$result_blocks['id']}_e\">
		<tr>
			<td class=\"trow1\" align=\"center\" valign=\"middle\" width=\"35%\"><img src=\"".$mybb->user['avatar']."\" alt=\"".$mybb->user['avatar']."'s Avatar\" width=\"50px\" height=\"50px\" border=\"0\" /></td>
			<td class=\"trow2\" valign=\"middle\">{$onlinestaff}</td>
		</tr>
		</tbody>
	</table>";

//<table border=\"0\" cellspacing=\"".$theme['borderwidth']."\" cellpadding=\"".$theme['tablespace']."\" class=\"tborder\">
//		<tr>
//			<td class=\"thead\"><div class=\"expcolimage\"><img src=\"{$theme['imgdir']}/{$expcolimage}\" id=\"block_{$result_blocks['id']}_img\" class=\"expander\" alt=\"{$expaltext}\" title=\"{$expaltext}\" /></div><strong><a href=\"{$mybb->settings['bburl']}/online.php\">{$lang->online}: {$onlinestaff}</a></strong></td>
//		</tr>
//		<tbody style=\"{$expdisplay}\" id=\"block_{$result_blocks['id']}_e\">
//		<tr>
//			<td class=\"tcat\"><span class=\"smalltext\">Online Staff</span></td>
//		</tr>
//		<tr>
//			<td class=\"trow1\">{$onlinestaff}</td>
//		</tr>
//		</tbody>
//	</table>";
?>


[Image: 468x602b.png]
01-10-2011 07:13 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
RE: Check if User is mod and if he is online - Skiilz - 01-10-2011 07:13 AM

 Standard Tools
Forum Jump: