Great!
Looks like I don't have the hole zip file anymore so i just post the code:
mod_whosonline_ext.php
[code:1]<?php
/**
* @version $Id: mod_whosonline_ext.php,v 1.0 2005/06/23 11:49:45 cowboy Exp $
* @package MamboHacks
* @copyright (C) 2000 - 2005 MamboHacks.com
* @license
www.gnu.org/copyleft/gpl.html
GNU/GPL
* Mambo is Free Software
*/
/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
$showmode = $params->get( 'showmode' );
$moduleclass_sfx = $params->get( 'moduleclass_sfx' );
global $profilelink, $displayrealname, $liststyle, $pmlink;
$displayrealname = $params->get( 'displayrealname' );
$liststyle = $params->get( 'liststyle' );
$showchatters = $params->get( 'showchatters' );
$flashchaturl = $params->get( 'flashchaturl' );
$chatroomempty = $params->get( 'chatroomempty' );
$profilelink = $params->get( 'profilelink' );
$pmlink = $params->get( 'pmlink' );
$content="";
if ($showmode==0 || $showmode==2) {
$query1 = "SELECT count(session_id) as guest_online FROM #__session WHERE guest=1 AND (usertype is NULL OR usertype='')";
$database->setQuery($query1);
$guest_array = $database->loadResult();
$query2 = "SELECT DISTINCT count(username) as user_online FROM #__session WHERE guest=0 AND usertype <> 'administrator' AND usertype <> 'superadministrator'";
$database->setQuery($query2);
$user_array = $database->loadResult();
if ($guest_array<>0 && $user_array==0) {
if ($guest_array==1) {
$content.=_WE_HAVE;
$content.=_GUEST_COUNT;
$content.=_ONLINE;
eval ("\$content = \"$content\";"«»);
} else {
$content.=_WE_HAVE;
$content.=_GUESTS_COUNT;
$content.=_ONLINE;
eval ("\$content = \"$content\";"«»);
}
}
if ($guest_array==0 && $user_array<>0) {
if ($user_array==1) {
$content.=_WE_HAVE;
$content.=_MEMBER_COUNT;
$content.=_ONLINE;
eval ("\$content = \"$content\";"«»);
} else {
$content.=_WE_HAVE;
$content.=_MEMBERS_COUNT;
$content.=_ONLINE;
eval ("\$content = \"$content\";"«»);
}
}
if ($guest_array<>0 && $user_array<>0) {
if ($guest_array==1) {
$content.=_WE_HAVE;
$content.=_GUEST_COUNT;
$content.=_AND;
eval ("\$content = \"$content\";"«»);
} else {
$content.=_WE_HAVE;
$content.=_GUESTS_COUNT;
$content.=_ONLINE;
$content.=_AND;
eval ("\$content = \"$content\";"«»);
}
if ($user_array==1) {
$content.=_MEMBER_COUNT;
$content.=_ONLINE;
eval ("\$content = \"$content\";"«»);
} else {
$content.=_MEMBERS_COUNT;
$content.=_ONLINE;
eval ("\$content = \"$content\";"«»);
}
}
}
if ($showmode==1 || $showmode==2) {
$query = "SELECT DISTINCT a.username, a.userid, b.name "
."\n FROM #__session AS a, #__users AS b"
."\n WHERE (a.guest=0) AND b.id = a.userid GROUP BY b.id";
$database->setQuery($query);
$rows = $database->loadObjectList();
$content .= "<br/>";
foreach($rows as $row) {
$content .= ListStyle(LinkIt($row->username, $row->name, $row->userid));
}
if ($content == ""«») {
echo _NONE ."\n";
}
}
if ($showchatters) {
$content .= "<br/><a href=\"#\" onclick=\"javascript: window.open('http://".$flashchaturl."/flashchat.php', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">
";
$chatters = '';
$database->setQuery("SELECT #__users.username, #__users.id, #__users.name from #__users, #__fc_connections where #__fc_connections.userid = #__users.id order by updated desc"«»);
if ($this->_result = $database->query()) {
$rows = $database->loadObjectList();
foreach($rows as $row) {
$chatters .= ListStyle(LinkIt($row->username, $row->name, $row->id));
}
if ($chatters == ""«») {
$content .= "<img src=\"".$mosConfig_live_site."/images/M_images/arrow.png\" border=\"0\" alt=\"\"/>".($chatroomempty != '' ? $chatroomempty : "The chatroom is quite..."«»);
}
else {
$content .= $chatters;
}
}
}
function ListStyle($item) {
global $liststyle;
if ($liststyle) {
return "<img src=\"".$mosConfig_live_site."/images/M_images/arrow.png\" border=\"0\" alt=\"\"/>".$item." ";
}
else {
return "<ul><li>" . $item . "</li></ul>\n";
}
}
function LinkIt($username, $name, $id) {
global $database, $mosConfig_absolute_path, $smf_prefix, $mosConfig_sef;
global $profilelink, $displayrealname, $pmlink;
if ($profilelink == 0) {
$link = ($displayrealname ? $name : $username);
}
if ($profilelink == 1 || $pmlink == 1) {
$smfclass = $mosConfig_absolute_path."/administrator/components/com_smf/smf.class.php";
if (!file_exists($smfclass)) {
return "Please install <a href=\"http://www.mambohacks.com\" alt=\"Mambo-SMF Forum\">Mambo-SMF Forum.";
}
require_once($smfclass);
$mosSMF =& new mosSMF();
if (!isset($mosSMF->MAMBOHACKS)) {
return "Please install <a href=\"http://www.mambohacks.com\" alt=\"Mambo-SMF Forum\">Mambo-SMF Forum.";
}
/* get SMF itemid */
$database->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_smf'"«»);
if ($this->_result = $database->query()) {
$row = mysql_fetch_object($this->_result);
$smfItemid = $row->id;
}
/* get user smf id */
$database->setQuery("SELECT ID_MEMBER FROM {$smf_prefix}members WHERE memberName='$username'"«»);
if ($this->_result = $database->query()) {
$row = mysql_fetch_object($this->_result);
$memberid = $row->ID_MEMBER;
}
$link = "<a href=\"".sefRelToAbs("index.php?option=com_smf&Itemid=".$smfItemid."&action=profile;u=".$memberid)."\">".($displayrealname ? $name : $username)."</a>\n";
$link = str_replace(";u,",";u=",$link);
}
if ($profilelink == 2) {
$link = "<a href=\"". sefRelToAbs('index.php?option=com_comprofiler&task=userProfile&user='. $id)."\">".($displayrealname ? $name : $username)."</a>\n";
}
if ($pmlink == 1) {
$link .= " <a href=\"".sefRelToAbs("index.php?option=com_smf&Itemid=".$smfItemid."&action=pm;sa=send;u=".$memberid)."\"><img src=\"".$mosConfig_live_site."/images/M_images/emailButton.png\" border=\"0\" height=\"10\"></a>\n";
if ($mosConfig_sef) {
$link = str_replace("pm;sa","pm/sa",$link);
$link = str_replace("send;u","send/u",$link);
}
}
if ($pmlink == 2) {
$link .= " <a href=\"". sefRelToAbs('index.php?option=com_pms&page=new&id='. $username)."\"><img src=\"".$mosConfig_live_site."/images/M_images/emailButton.png\" border=\"0\" height=\"10\"></a>\n";
}
return $link;
}
?>[/code:1]
Tell me if you need the xml file too.
EDIT: What you could also add is the way how they count members. Because in your module when there is one guest it shows: "There are 1 guests online..."
Post edited by: irgendwer, at: 2006/06/22 17:01