Check if User is mod and if he is online
Skiilz Offline
Member
***
Posts: 198
Joined: Nov 2010
Post: #1
Check if User is mod and if he is online
Hey guys, I'm willing to check if there are any moderator online and display the username of these mods.

How can I do it? It will be displayed in portal. What code I need to use?

Thank you.

[Image: 468x602b.png]
(This post was last modified: 01-09-2011 09:45 AM by Skiilz.)
01-08-2011 11:12 PM
Find all posts by this user Quote this message in a reply
Skiilz Offline
Member
***
Posts: 198
Joined: Nov 2010
Post: #2
RE: Check if User is mod and if he is online
Anyone can help me please!

[Image: 468x602b.png]
01-10-2011 12:21 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #3
RE: Check if User is mod and if he is online
Skillz - is this for portal or Pro_portal?


[Image: leelink.gif]
MYBB1.6 & XThreads
01-10-2011 03:06 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Skiilz Offline
Member
***
Posts: 198
Joined: Nov 2010
Post: #4
RE: Check if User is mod and if he is online
I have ProPortal installed but I'm unable to access my FTP for some reason. So if it can be done using the <if> would be better for me. But if it can't... I would like to see the code for ProPortal.

[Image: 468x602b.png]
01-10-2011 03:09 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #5
RE: Check if User is mod and if he is online
Do you have an example of a Pro_portal custom block? I don't use pro_portal, but I have it on my test board. I don't know if the block needs a plugin file to activate it. I am interested in helping you (if I can) but as the pro_portal site is now a parked domain, I need some help from you Smile

The whos in Ajax chat block would be a start.


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 01-10-2011 04:04 AM by leefish.)
01-10-2011 04:02 AM
Visit this user's website Find all posts by this user Quote this message in a reply
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
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #7
RE: Check if User is mod and if he is online
I have a working sample on my testboard:

http://www.leefish.nl/testfish/portal.php


[Image: leelink.gif]
MYBB1.6 & XThreads
01-10-2011 02:46 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Imran Offline
Member
***
Posts: 204
Joined: Apr 2010
Post: #8
RE: Check if User is mod and if he is online
(01-10-2011 02:46 PM)leefish Wrote:  I have a working sample on my testboard:

http://www.leefish.nl/testfish/portal.php

Did you added another query for searching [moderators] online ?

[Image: logo.png]

[Image: twitter.png]
01-11-2011 03:13 AM
Visit this user's website Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #9
RE: Check if User is mod and if he is online
Yes, I remade the query and the whole block_file from scratch.

I now have a shoutbox on the pro_portal - its NOT a block, and its a non-awesome shoutbox (no sound support) - but it IS there

Block now on leefish Custom Block

As usual, no need to register to download. A thanks comment would be nice though Tongue


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 01-11-2011 08:22 PM by leefish.)
01-11-2011 05:36 AM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: