|
From: Lo?c C. <lo...@us...> - 2001-05-31 19:56:36
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat/lib In directory usw-pr-cvs1:/tmp/cvs-serv5411/chat/lib Added Files: connected_users.lib.php3 Log Message: Initial commit --- NEW FILE --- <?php // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html | // +--------------------------------------------------------------------------+ // | This library is used to display in a web page the list or number of | // | users currently connected to the chat (see 'chat_activity.php3' at the | // | root of the phpMyChat package). | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <te...@ph...> | // +--------------------------------------------------------------------------+ // // $Id: connected_users.lib.php3,v 1.1 2001/05/31 19:56:33 loic1 Exp $ // // Display the chat activity on a web page. // /** * Get some core libraries */ require('./' . CA_CHAT_PATH . 'config/config.lib.' . C_EXTENSION); require('./' . CA_CHAT_PATH . 'lib/common.lib.' . C_EXTENSION); require('./' . CA_CHAT_PATH . 'lib/database/' . C_DB_TYPE . '.lib.' . C_EXTENSION); require('./' . CA_CHAT_PATH . '/lib/clean.lib.' . C_EXTENSION); /** * Get the number or build the list of users currently chatting * * The 'pmcHandleMagicQuotes()' function is defined in the * 'chat/lib/common.lib.php3' library * * @param boolean whether to show users in private room or not * @param boolean whether to show users list or only their number * * @return string the string(s) to be displayed at your page * * @access public */ function pmcDisplayConnected($doGetPrivate = 0, $isFullList = 1) { $theList = ''; $theString = ''; // Build the query and send it if ($doGetPrivate) { $what = ($isFullList) ? 'username, latin1' : 'COUNT(*)'; $query = "SELECT $what FROM " . C_USR_TBL . ' GROUP BY username'; } else { $what = ($isFullList) ? 'u.username, u.latin1' : 'COUNT(u.*)'; $query = "SELECT $what FROM " . C_USR_TBL . ' u, ' . C_MSG_TBL . ' m WHERE u.room = m.room AND m.type = 1 GROUP BY u.username'; } $chatActivityLink = new pmcDB; $chatActivityLink->query($query); // Prepare the string to display $usersCnt = 0; if ($isFullList) { while(list($nick,$latin1) = $chatActivityLink->nextRecord()) { $usersCnt++; $nick = ($latin1) ? htmlentities(pmcHandleMagicQuotes($nick, '', 1, 'del')) : pmcHandleMagicQuotes($nick, '', 1, 'del'); $theList .= (empty($theList)) ? $nick : ', ' . $nick; } if ($usersCnt > 0) { $theString = sprintf(CA_USERS_ON, $usersCnt) . '<br />' . "\n" . $theList . "\n"; } else { $theString = CA_USERS_OFF . "\n"; } } else { list($usersCnt) = $chatActivityLink->nextRecord(); if ($usersCnt > 0) { $theString = sprintf(CA_USERS_ON, $usersCnt) . "\n"; } else { $theString = CA_USERS_OFF . "\n"; } } // end of computing the string to return $chatActivityLink->cleanResults(); // Commented because of the way Apache handle multiple database links // $chatActivityLink->close(); return $theString; } // end of the 'pmcDisplayConnected()' function ?> |