From: Lo?c C. <lo...@us...> - 2001-04-03 20:17:44
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat In directory usw-pr-cvs1:/tmp/cvs-serv6312/chat Added Files: tutorial_popup.php3 users.php3 Log Message: The first dev. version that works! Still many things to do, of course... --- NEW FILE --- <?php // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | This script displays the tutorial with the most appropriate language. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: tutorial_popup.php3,v 1.1 2001/04/03 20:17:40 loic1 Exp $ // // Launches the tutorial with the most appropriate language. // /** * Gets the extension for the php scripts */ if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; define('C_EXTENSION', (substr($PHP_SELF, -1) == 3) ? 'php3' : 'php'); /** * Gets some core files */ require('./config/config.lib.php3'); require('./lib/common.lib.php3'); /** * Gets the session id sent to this script * * Uses the 'pmcGrabGlobals()' function defined in the * 'chat/lib/common.lib.php3' library. */ pmcGrabGlobals('%GET'); /** * Defines the translation to be used */ if (empty($lang) || !file_exists('./localization/' . $lang . '/localized.tutorial.' . C_EXTENSION)) { $lang = ''; include('./localization/tutorial.lib.' . C_EXTENSION); } /** * Gets the tutorial */ require('./localization/'. $lang .'/localized.tutorial.' . C_EXTENSION); ?> --- NEW FILE --- <?php // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | This script defines the 'users' with DHTML enabled browsers. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: users.php3,v 1.1 2001/04/03 20:17:40 loic1 Exp $ // // The "standard" users frame. // /** * Gets the extension for the php scripts */ if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; define('C_EXTENSION', (substr($PHP_SELF, -1) == 3) ? 'php3' : 'php'); /** * Gets some core libraries */ require('./config/config.lib.' . C_EXTENSION); require('./lib/common.lib.' . C_EXTENSION); require('./lib/database/' . C_DB_TYPE . '.lib.' . C_EXTENSION); require('./lib/clean.lib.' . C_EXTENSION); /** * Gets the values of variables sent or posted to this script * * Uses the 'pmcGrabGlobals()' and the 'pmcHandleMagicQuotes()' functions * defined in the 'chat/lib/common.lib.php3' library. */ pmcGrabGlobals('dbSessionId'); /** * Start the session handler */ require('./lib/db_sessions.lib.' . C_EXTENSION); dbSessionInitIt( C_DB_TYPE, C_DB_HOST, C_DB_NAME, C_DB_USER, C_DB_PASS, C_SESS_TBL, C_REG_DEL, C_SESS_DEL * 60 ); dbSessionstart(); /** * Defines the language to be used */ require('./localization/' . $dbSessionVars['lang'] . '/localized.chat.' . C_EXTENSION); $textDirection = (L_CHARSET == 'windows-1256') ? 'rtl' : 'ltr'; /** * Sends HTTP headers * * The 'pmcHttpHeaders()' fonction is defined in the 'chat/lib/common.lib.php3' * library */ pmcHttpHeaders(L_CHARSET, true); /** * Add two slashes before single quotes * * @param string the string to be slashed * * @return string the slashed string * * @access public */ function pmcDoubleSlash($theString) { return str_replace('\'', '\\\\\'', $theString); } // end of the 'pmcDoubleSlash()' function /** * Format an username according to the status of the user * * The 'pmcSpecialChars()' fonction is defined in the * 'chat/lib/common.lib.php3' library * * @param string the username * @param boolean whether this username uses 'iso-8859-1' character set or * not * @param string the status of the user * * @return string the formatted username * * @access public */ function pmcFormatUsername($theUsername, $isUnLatin1, $theSatus) { $tagOpen = ($theSatus == 'a' || $theSatus == 'm') ? '<i>' : ''; $tagClose = ($tagOpen != '') ? '</i>' : ''; $theUsername = $tagOpen . pmcSpecialChars($theUsername, $isUnLatin1) . $tagClose; return $theUsername; } // end of the 'pmcFormatUsername()' function /** * Defines some variables */ $slashedNick = pmcSlashSingleQuotes($dbSessionVars['nick']); $currentRoomType = $dbSessionVars['roomType']; $slashedCurrentRoomName = pmcSlashSingleQuotes($dbSessionVars['targetRoom']); $usersList = array(); /** * Build the users list for the current room * * The 'pmcSlashSingleQuotes()', the 'pmcHandleMagicQuotes()' and the * 'pmcSpecialChars()' fonctions are defined in the 'chat/lib/common.lib.php3' * library */ if (C_DB_TYPE == 'mysql') { $currentRoomQuery = 'SELECT usr.username, usr.latin1, usr.status, reg.gender ' . 'FROM ' . C_USR_TBL . ' usr LEFT JOIN ' . C_REG_TBL . ' reg ON usr.username = reg.username ' . 'WHERE usr.room = \'' . $slashedCurrentRoomName . '\' ' . 'ORDER BY usr.username'; } else if (C_DB_TYPE == 'pgsql') { $currentRoomQuery = 'SELECT usr.username, usr.latin1, usr.status, reg.gender ' . 'FROM ' . C_USR_TBL . ' usr, ' . C_REG_TBL . ' reg ' . 'WHERE usr.room = \'' . $slashedCurrentRoomName . '\' ' . 'UNION ' . 'SELECT usr.username, usr.latin1, usr.status, NULL ' . 'FROM ' . C_USR_TBL . ' usr ' . 'WHERE usr.username NOT IN (SELECT reg.username FROM ' . C_REG_TBL . ' reg) AND usr.room = \'' . $slashedCurrentRoomName . '\' ' . 'ORDER BY usr.username'; } else { $currentRoomQuery = 'SELECT usr.username, usr.latin1, usr.status, NULL ' . 'FROM ' . C_USR_TBL . ' usr ' . 'WHERE usr.room = \'' . $slashedCurrentRoomName . '\' ' . 'ORDER BY usr.username'; } $usersCnt = 0; $usersList[] = '<b>' . htmlspecialchars($slashedCurrentRoomName) . '<b>' . '<span class="small">' . '<bdo dir="' . $textDirection . '"></bdo>' . ' (%NUMROWS%)' . '</span><br />'; $usersList[] = '<div style="margin-bottom: 10px">'; $currentRoomDb = new pmcDB; $currentRoomDb->query($currentRoomQuery); while (list($username, $latin1, $status, $gender) = $currentRoomDb->nextRecord()) { $usersCnt++; $username = pmcHandleMagicQuotes($username, '', 1, 'del'); // Define the icon to put for this user if ($gender == 0) $gender = 'undefined'; else if ($gender == 1) $gender = 'boy'; else if ($gender == 2) $gender = 'girl'; else $gender = 'none'; if ($status != 'u' && $status != 'k' && $status != 'd' && $status != 'b') { $tmpStr = '<a href="#" onclick="window.parent.pmcRunCmd(' . (($username == $dbSessionVars['nick']) ? '\'PROFILE\', \'\'' : '\'WHOIS\', \'' . pmcDoubleSlash(pmcSpecialChars($username, $latin1)) .'\'') . '); return false;" class="user">' . '<img src="images/gender_' . $gender . '.gif" width="14" height="14" border="0" alt="' . L_PROFILE . '" />' . '</a> '; } else { $tmpStr = '<img src="images/gender_none.gif" width="14" height="14" border="0" alt="' . L_NO_PROFILE . '" /> '; } // Define the format to be used for the username according to the status if ($username != $dbSessionVars['nick']) { $tmpStr .= '<a href="javascript:window.parent.pmcUserClick(\'' . pmcDoubleSlash(pmcSpecialChars($username, $latin1)) . '\', false)" class="user">' . pmcFormatUsername($username, $latin1, $status) . '</a><br />'; } else { $tmpStr .= pmcFormatUsername($username, $latin1, $status) . '<br />'; } $usersList[] = "\t" . $tmpStr; } $currentRoomDb->cleanResults(); $currentRoomDb->close(); $usersList[] = '</div>'; $usersList[] = ''; $usersList[] = ''; $usersList[0] = str_replace('%NUMROWS%', $usersCnt, $usersList[0]); /** * Build the users list for the others populated rooms * * The 'pmcSlashSingleQuotes()', the 'pmcHandleMagicQuotes()' and the * 'pmcSpecialChars()' fonctions are defined in the 'chat/lib/common.lib.php3' * library */ // 1. Get the list of rooms and users if (C_DB_TYPE == 'mysql') { $otherRoomsQuery = 'SELECT usr.username, usr.latin1, usr.status, reg.gender ' . 'FROM ' . C_USR_TBL . ' usr LEFT JOIN ' . C_REG_TBL . ' reg ON usr.username = reg.username ' . 'WHERE usr.room = \'%OTHER%\' ' . 'ORDER BY usr.username'; } else if (C_DB_TYPE == 'pgsql') { $otherRoomsQuery = 'SELECT usr.username, usr.latin1, usr.status, reg.gender ' . 'FROM ' . C_USR_TBL . ' usr, ' . C_REG_TBL . ' reg ' . 'WHERE usr.room = \'%OTHER%\' ' . 'UNION ' . 'SELECT usr.username, usr.latin1, usr.status, 0 ' . 'FROM ' . C_USR_TBL . ' usr ' . 'WHERE usr.username NOT IN (SELECT reg.username FROM ' . C_REG_TBL . ' reg) AND usr.room = \'%OTHER%\' ' . 'ORDER BY usr.username'; } else { $otherRoomsQuery = 'SELECT usr.username, usr.latin1, usr.status, 0 ' . 'FROM ' . C_USR_TBL . ' usr ' . 'WHERE usr.room = \'%OTHER%\' ' . 'ORDER BY usr.username'; } $othersRooms = array(); $otherRoomDb = new pmcDB; $otherRoomDb->query("SELECT DISTINCT room FROM " . C_MSG_TBL . " WHERE room != '$slashedCurrentRoomName' AND type = 1 ORDER BY room"); while (list($otherRoom) = $otherRoomDb->nextRecord()) $othersRooms[pmcHandleMagicQuotes($otherRoom, '', 1, 'del')] = ''; $otherRoomDb->cleanResults(); $filteredOtherRooms = array(); reset($othersRooms); while (list($roomName, $usersIn) = each($othersRooms)) { $usersDetails = array(); $slashedOther = pmcSlashSingleQuotes($roomName); $otherRoomDb->query(str_replace('%OTHER%', $slashedOther, $otherRoomsQuery)); while (list($otherUser, $latin1, $status, $gender) = $otherRoomDb->nextRecord()) { $usersDetails[] = array( pmcHandleMagicQuotes($otherUser, '', 1, 'del'), $latin1, $status, $gender ); } $otherRoomDb->cleanResults(); if (count($usersDetails) > 0) $filteredOtherRooms[$roomName] = $usersDetails; unset($usersDetails); } $otherRoomDb->close(); $othersRooms = $filteredOtherRooms; unset($roomName); unset($usersIn); unset($filteredOtherRooms); // 2. Format this list if (count($othersRooms) > 0) { $i = 0; $childCnt = array(); $joinUrl = $dbSessionVars['from'] . '?' . dbSessionSID('GET') . $pmcQueryArgSeparator . 'exitMode=2' . $pmcQueryArgSeparator . 'newTargetRoom=1%NEWROOM%'; reset($othersRooms); while (list($roomName, $usersIn) = each($othersRooms)) { $usersInCnt = count($usersIn); if ($usersInCnt > 0) { $i++; $id = md5($roomName); $childCnt[$id] = $usersInCnt; if ($i == 1) $firstOtherRoom = 'Parent' . $id; $usersList[] = '<div id="Parent' . $id . '" class="parent" style="margin-top: 5px; cursor: hand">'; $usersList[] = "\t" . '<a href="#" onclick="window.parent.pmcExpandRoom(\'' . $id . '\'); return false">' . '<img name="imEx" src="images/closed.gif" width="9" height="9" border="0" alt="' . L_EXPCOL . '\" /></a>' . ' ' . '<a href="' . str_replace('%NEWROOM%', urlencode($roomName), $joinUrl) . '" target="_parent">' . htmlspecialchars($roomName) . '</a>' . '<span class="small"><bdo dir="' . $textDirection . '"></bdo> ' . '(' . $usersInCnt . ')</span>'; $usersList[] = '</div>'; $usersList[] = '<div id="Child' . $id .'" class="child" style="margin-left: 12px">'; for (reset($usersIn); $userDetails = current($usersIn); next($usersIn)) { $otherUser = $userDetails[0]; $latin1 = $userDetails[1]; $status = $userDetails[2]; $gender = $userDetails[3]; // Put an icon when there is a profile for the user if ($gender == 0) $gender = 'undefined'; else if ($gender == 1) $gender = 'boy'; else if ($gender == 2) $gender = 'girl'; else $gender = 'none'; if ($status != 'u' && $status != 'k' && $status != 'd' && $status != 'b') $tmpStr = '<a href="#" onclick="window.parent.pmcRunCmd(\'WHOIS\', \''. pmcDoubleSlash(pmcSpecialChars($otherUser, $latin1)) . '\'); return false" class="user">' . '<img src="images/gender_' . $gender . '.gif" width="14" height="14" border="0" alt="' . L_PROFILE . '">' . '</a> '; else $tmpStr = '<img src="images/gender_none.gif" width="14" height="14" border="0" alt="' . L_NO_PROFILE . '"> '; $tmpStr .= '<a href="javascript:window.parent.pmcUserClick(\'' . pmcDoubleSlash(pmcSpecialChars($otherUser, $latin1)) . '\', false)" class="user">' . pmcFormatUsername($otherUser, $latin1, $status) . '</a><br />'; $usersList[] = "\t" . $tmpStr; } $usersList[] = '</div>'; $usersList[] = ''; } } unset($usersIn); $usersList[] = ''; } unset($othersRooms); /** * Build the list of empty default and public rooms * * The 'pmcSlashSingleQuotes()', the 'pmcHandleMagicQuotes()' and the * 'pmcSpecialChars()' fonctions are defined in the 'chat/lib/common.lib.php3' * library */ $joinUrl = $dbSessionVars['from'] . '?' . dbSessionSID('GET') . $pmcQueryArgSeparator . 'exitMode=2' . $pmcQueryArgSeparator . 'newTargetRoom=1%NEWROOM%'; for ($k = 0; $k < count($defaultChatRooms); $k++) { $tmpRoom = stripslashes($defaultChatRooms[$k]); $id = md5($tmpRoom); // Display this room name when it hadn't been displayed yet if (strcasecmp($tmpRoom, $dbSessionVars['targetRoom']) != 0 && (!isset($childCnt) || !isset($childCnt[$id]))) { if (!isset($firstOtherRoom)) $firstOtherRoom = 'Parent' . $id; $usersList[] = '<div id="Parent' . $id . '" class="parent" style="margin-top: 5px; cursor: hand">'; $usersList[] = "\t" . '<a href="' . str_replace('%NEWROOM%', urlencode($tmpRoom), $joinUrl) . '" target="_parent">' . htmlspecialchars($tmpRoom) . '</a>' . '<span class="small"><bdo dir="' . $textDirection . '"></bdo>' . ' (0)</span>'; $usersList[] = '</div>'; $usersList[] = ''; } } /** * Displays the frame */ // The url for the style sheet $cssUrl = pmcUrlForStyleSheet('style', L_CHARSET, (defined('L_FONT_NAME')) ? L_FONT_NAME : '', L_FONT_SIZE); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html dir="<?php echo($textDirection); ?>"> <head> <title><?php echo(APP_NAME); ?></title> <link rel="stylesheet" href="<?php echo($cssUrl); ?>" type="text/css" /> <script type="text/javascript" language="javascript1.2"> <!-- // Add styles for positioned layers; if (window.parent.jsIsVersion4) { document.write('<style type="text/css">'); if (window.parent.jsIsNS4) { document.write('.parent {position: absolute; visibility: visible}'); document.write('.child {position: absolute; visibility: visible}'); document.write('.regular {position: absolute; visibility: visible}') } else { document.write('.child {display: none}') } document.write('<\/style>'); } // Get the Y scrolling position of the users frame function pmcGetY() { window.parent.jsUsersY = (window.parent.jsIsNS4) ? window.pageYOffset : document.body.scrollTop; } // end of the 'pmcGetY()' function // Initialize the collapsible outline; onload = window.parent.pmcInitList; // --> </script> </head> <body class="frame" onunload="pmcGetY();"> <p> <?php reset($usersList); for ($i = 0; $i < count($usersList); $i++) { echo($usersList[$i] . "\n"); } ?> </p> <script type="text/javascript" language="javascript1.2"> <!-- window.parent.jsRoomsCnt = <?php echo(isset($childCnt) ? count($childCnt) : 0); ?>; window.parent.jsUsersFrame = window; window.parent.jsExitFrame = window.parent.frames['exit'].window; <?php if (isset($childCnt) && count($childCnt) > 0) { ?> // Set the table containing number of users per 'others' rooms window.parent.jsChildCnt = new Array; <?php while(list($key, $cnt) = each($childCnt)) { echo("\n"); echo('window.parent.jsChildCnt[\''. $key .'\'] = ' . $cnt . ';'); } unset($childCnt); } echo("\n"); ?> // Get the index of the first expandable/collapsible room under NS4+ if (window.parent.jsIsNS4) { <?php if (isset($firstOtherRoom)) { ?> jsFirstEl = '<?php echo($firstOtherRoom); ?>'; jsFirstInd = window.parent.pmcGetIndex(jsFirstEl); window.parent.pmcNsArrangeList(); <?php } else { ?> jsFirstInd = null; <?php } echo("\n"); ?> } // Scrolls to the position where the frame was before reloading if (window.parent.jsUsersY != null) { scrollTo(0, window.parent.jsUsersY); if (window.parent.jsIsIE4) scrollBy(0, window.parent.jsUsersY - document.body.scrollTop); } //--> </script> </body> </html> <?php ?> |