| Code: |
|
<?php /* Block de test suite post http://www.phpnuke-europe.org/ftopicp-12010.html#12010 Pour afficher les infos des users présents dans les rooms ! 16/03/2005 09:01:04 */ // sécur de phpnuke ! // penses à renomer block-User_Info.php par ce que tu souhaites // et a activer le block via l'admin ! if (eregi("block-User_Info.php",$_SERVER['PHP_SELF'])) { Header("Location: index.php"); } // a verifier au niveau du chemin // il faut certainement indiquer le chemin du mod en question include_once('inc/common.php'); // appel d'une fonction dans une classe // certainement lié au fichier common.php ! ChatServer::purgeExpired(); /** Retrieves the number of users who are chatting in any room. Leave the $room parameter empty to return the number of users in all room. */ function numusers( $room = "" ) { if($room) { $stmt = new Statement("SELECT COUNT(*) AS numb FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL AND roomid=?"); $rs = $stmt->process($room); } else { $stmt = new Statement("SELECT COUNT(*) AS numb FROM {$GLOBALS['fc_config']['db']['pref']}connections,{$GLOBALS['fc_config']['db']['pref']}rooms WHERE userid IS NOT NULL AND ispublic IS NOT NULL AND {$GLOBALS['fc_config']['db']['pref']}connections.roomid = {$GLOBALS['fc_config']['db']['pref']}rooms.id"); $rs = $stmt->process(); } //while($rec = $rs->next()) toLog('usr',$rec); $rec = $rs->next(); return $rec?$rec['numb']:0; } /** Retrieves a list of the users (by login ID) who are in $room. Leave the $room parameter empty to return a list of all users in all rooms. */ function usersinroom( $room = "" ) { $cms = $GLOBALS['fc_config']['cms']; $list = array(); if($room) { $stmt = new Statement("SELECT userid, state, color, lang, roomid FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL AND roomid=?"); $rs = $stmt->process($room); } else { $stmt = new Statement("SELECT userid, state, color, lang, roomid FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL"); $rs = $stmt->process(); } while($rec = $rs->next()) $list[] = array_merge($cms->getUser($rec['userid']), $rec); return $list; } /** Retrieves a list of all available rooms, as an array. */ function roomlist() { $list = array(); // populate $list with the names of all available rooms $stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}rooms WHERE ispublic IS NOT NULL order by ispermanent"); $rs = $stmt->process(); while($rec = $rs->next()) $list[] = $rec; //result will be an array of arrays like ('id' => <room id>, 'updated' = <timestamp>, 'created' => <timestamp>, 'name' => <room name>, 'ispublic' => <public flag>, 'ispermanent' => <autoclose flag>) return $list; } $rooms = roomlist(); $roomnumb = sizeof($rooms); $numusers = numusers(); $content = '<div align="center">'; // phrase ci-dessous a mettre en FR ??? $content .= "There are $numusers users in $roomnumb rooms.</div>"; if($roomnumb) { $content .= ' <div align="center"> <table border="1" cellpadding="1" class="normal"> <tr> <th>ID</th> <th>Name</th> <th>Count</th> <th>Users</th> </tr> '; foreach($rooms as $room) { $content .= "\n"; $content .= " <tr>\n"; $content .= " <td>".$room['id']."</td>\n"; $content .= " <td>".$room['name']."</td>\n"; $content .= " <td>".numusers($room['id'])."</td>\n"; $content .= " <td>\n"; $users = usersinroom($room['id']); foreach($users as $user ) { $content .= "".$user['login'].". <br />"; } // End foreach $users $content .= " </td>\n"; $content .= " </tr>\n"; } // End foreach $rooms $content .= " </table></div>\n"; } // ENF if room ?> |
| Code: |
|
$content .= " <td>$room['id']</td>\n"; $content .= " <td>$room['name']</td>\n"; |
| Code: |
|
$content .= " <td>".$room['id']."</td>\n"; $content .= " <td>".$room['name']."</td>\n"; |
Toutes les heures sont au format GMT + 2 Heures