 |
 |
 |
 |
#314084 - 05/13/07 03:33 AM
Re: FlashChat w UBBT7.1 fixed login name issue
[Re: Gizmo]
|
Power User
Registered: 12/17/02
Posts: 71
Add to del.icio.us
Digg it
|
Ok, this is so simple there must be something wrong with it, but in ubb71CMS.php I changed the guts of function UBBCMS () to the following, basically subbing USER_DISPLAY_NAME for USER_LOGIN_NAME: $this->loginStmt = new Statement("SELECT USER_DISPLAY_NAME, USER_MEMBERSHIP_LEVEL, USER_PASSWORD,USER_IS_APPROVED,USER_IS_BANNED,USER_ID FROM {$GLOBALS['config']['TABLE_PREFIX']}USERS WHERE USER_DISPLAY_NAME = ? LIMIT 1");
$this->getUserStmt = new Statement("SELECT USER_DISPLAY_NAME as login, USER_MEMBERSHIP_LEVEL as status FROM {$GLOBALS['config']['TABLE_PREFIX']}USERS WHERE USER_ID = ? LIMIT 1");
$this->getUsersStmt = new Statement("SELECT USER_DISPLAY_NAME as login, USER_ID as id FROM {$GLOBALS['config']['TABLE_PREFIX']}USERS");
Then I expired my site cookies and it shows my username rather than my login name. Violá! I'll have to warn all my users to expire their cookies, otherwise it they will not be autologged in the first time. To log in manually using this code, you have to log in with your display name and password, rather than login name and password. As long as autologin is working, this process will be transparent and your users won't know it's even happening. All my users will hit it in the morning, and we'll see what happens. I'll report back if any probs.
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#314098 - 05/14/07 04:41 PM
Re: FlashChat with UBB.Threads 7.0.2
[Re: Gizmo]
|
Power User
Registered: 12/17/02
Posts: 71
|
Ok, this is so simple there must be something wrong with it, but in ubb71CMS.php I changed the guts of function UBBCMS () to the following, basically subbing USER_DISPLAY_NAME for USER_LOGIN_NAME: $this->loginStmt = new Statement("SELECT USER_DISPLAY_NAME, USER_MEMBERSHIP_LEVEL, USER_PASSWORD,USER_IS_APPROVED,USER_IS_BANNED,USER_ID FROM {$GLOBALS['config']['TABLE_PREFIX']}USERS WHERE USER_DISPLAY_NAME = ? LIMIT 1");
$this->getUserStmt = new Statement("SELECT USER_DISPLAY_NAME as login, USER_MEMBERSHIP_LEVEL as status FROM {$GLOBALS['config']['TABLE_PREFIX']}USERS WHERE USER_ID = ? LIMIT 1");
$this->getUsersStmt = new Statement("SELECT USER_DISPLAY_NAME as login, USER_ID as id FROM {$GLOBALS['config']['TABLE_PREFIX']}USERS");
Then I expired my site cookies and it shows my username rather than my login name. Violá! I'll have to warn all my users to expire their cookies, otherwise it they will not be autologged in the first time. To log in manually using this code, you have to log in with your display name and password, rather than login name and password. As long as autologin is working, this process will be transparent and your users won't know it's even happening. All my users will hit it in the morning, and we'll see what happens. I'll report back if any probs.
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#316736 - 02/19/08 04:12 PM
Re: FlashChat with UBB.Threads 7.1
[Re: jgeoff]
|
Power User
Registered: 04/05/01
Posts: 93
Loc: NJ
|
If anyone wants to try it, here's my ubb71CMS integration script for FlashChat 4.7. I can't attach the file apparently, so here it is -- rename it ubb71CMS.php and save it to \FLASHCHAT_DIR\inc\cmsesI have not tried this with a later version of UBB.t than 7.1. I will test with 7.3 once it's released...
<?php
if ( !defined( 'INC_DIR' ) ) {
die( 'hacking attempt' );
}
$ubb_root_path = realpath(dirname(__FILE__) . '/../../../') . '/';
require_once($ubb_root_path . 'includes/config.inc.php');
class UBBCMS {
var $loginStmt;
var $updateSessionStmt;
var $getUserStmt;
var $getUsersStmt;
var $userid;
function UBBCMS() {
$this->loginStmt = new Statement("SELECT USER_DISPLAY_NAME, USER_MEMBERSHIP_LEVEL, USER_PASSWORD,USER_IS_APPROVED,USER_IS_BANNED,USER_ID FROM {$GLOBALS['config']['TABLE_PREFIX']}USERS WHERE USER_DISPLAY_NAME = ? LIMIT 1");
$this->getUserStmt = new Statement("SELECT USER_DISPLAY_NAME as login, USER_MEMBERSHIP_LEVEL as status FROM {$GLOBALS['config']['TABLE_PREFIX']}USERS WHERE USER_ID = ? LIMIT 1");
$this->getUsersStmt = new Statement("SELECT USER_DISPLAY_NAME as login, USER_ID as id FROM {$GLOBALS['config']['TABLE_PREFIX']}USERS");
$this->userid = isset($_COOKIE[$GLOBALS["config"]["COOKIE_PREFIX"] ."ubbt_myid"]) ? $_COOKIE[$GLOBALS["config"]["COOKIE_PREFIX"] ."ubbt_myid"] : NULL;
}
function isLoggedIn() {
return $this->userid;
}
function getRoles($status) {
$rv = NULL;
if ($status == "Administrator" || $status == "Moderator")
$rv = ROLE_ADMIN;
elseif ($status == "User")
$rv = ROLE_USER;
else
$rv = ROLE_SPY;
return $rv;
}
function getUserProfile($userid) {
if ($userid == SPY_USERID) $rv = NULL;
elseif ($user = $this->getUser($userid))
{
$id = $this->isLoggedIn();
if( $id && ($id == $userid) )
{
toLog("true",true);
$rv = $GLOBALS["config"]["FULL_URL"] . "/ubbthreads.php?ubb=showprofile&User={$userid}";
}
else
{
toLog("false",false);
$rv = $GLOBALS["config"]["FULL_URL"] . "/ubbthreads.php?ubb=login";
}
}
toLog("rv_prof",$rv);
return $rv;
}
function getUser($userid) {
$rs = $this->getUserStmt->process($userid);
$rv = $rs->next();
if($rv) {
$rv["roles"] = $this->getRoles($rv["status"]);
}
return $rv;
}
function login($login, $password) {
$goodPassword = false;
$rs = $this->loginStmt->process(addslashes($login));
$rec = $rs->next();
if ($rec) {
if ($rec["USER_IS_BANNED"]) return NULL;
if (md5($password) != $rec["USER_PASSWORD"]) return NULL;
return $rec['USER_ID'];
}
}
function userInRole($userid, $role) {
if($user = $this->getUser($userid)) {
return ($user['roles'] == $role);
}
return false;
}
function logout() {
}
function getUsers() {
return $this->getUsersStmt->process();
}
function getGender($userid) {
return NULL;
}
}
$GLOBALS['fc_config']['db'] = array(
'host' => $GLOBALS["config"]["DATABASE_SERVER"],
'user' => $GLOBALS["config"]["DATABASE_USER"],
'pass' => $GLOBALS["config"]["DATABASE_PASSWORD"],
'base' => $GLOBALS["config"]["DATABASE_NAME"],
'pref' => $GLOBALS["config"]["TABLE_PREFIX"] . 'fc_',
);
$GLOBALS['fc_config']['cms'] = new UBBCMS();
foreach($GLOBALS['fc_config']['languages'] as $k => $v) {
$GLOBALS['fc_config']['languages'][$k]['dialog']['login']['moderator'] = '';
}
?>
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#316737 - 02/19/08 05:14 PM
Re: FlashChat with UBB.Threads 7.1
[Re: jgeoff]
|
Power User
Registered: 04/05/01
Posts: 93
Loc: NJ
|
Has anyone figured out how to add a "Who's Chatting" custom island into Threads? Edit: Never mind, I found this download (just a php file) in the Tufat resources: New "Who's Chatting" file for CMS systems Edit Again: Haven't gotten it working in a custom island yet, but it works as a stand-alone page. Getting errors when put in a custom island. Here's the code...
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
include_once('inc/common.php');
ChatServer::purgeExpired(); 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();
}
$rec = $rs->next();
return $rec?$rec['numb']:0;
}
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;
}
function roomlist()
{
$list = array();
$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;
return $list;
}
$rooms = roomlist();
$roomnumb = sizeof($rooms);
$usernumb = numusers();
$body = <<<EOF
<BR>><a href="/threads/chat/flashchat.php" target="_blank">Chatroom</a> (<?= $usernumb ?> user<? if ($usernumb != 1) echo "s" ?> in <?=$roomnumb ?> room<? if ($roomnumb != 1) echo "s"; ?>)
<ul id="roomList">
<?php if($roomnumb) { ?>
<?php foreach($rooms as $room) { ?>
<li><strong><a href="#" onclick="javascript:toggleUserList('room_<?=$room[id]?>')"><?=$room[name]?> (<?= numusers($room[id]) ?>)</a></strong>
<?php
$users = usersinroom($room[id]);
if ($users) {
echo "<ul class=\"userList\" id=\"room_".$room[id]."\">";
foreach( $users as $user ) {
echo "<li>".$user[login] . "</li>";
}
echo "</ul>";
}
?> </li>
<?php } ?>
<?php } ?>
</ul>
EOF;
Edited by jgeoff (02/19/08 06:10 PM) Edit Reason: Ugh
|
|
Top
|
|
|
|
 |
 |
 |
 |
| |