1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
|
<?php
/************************************************************************/
//!!! IMPORTANT NOTE
//!!! FlashChat 4.4.0 and higher support a new user role: ROLE_MODERATOR
//!!! Please edit the getUser and getRoles function if you need use of
//!!! the new moderator role. This change has not yet been applied.
/************************************************************************/
// integration class for WotLab Burning Board
// chdir hack for allowing wotlab global.php to include files
$curdir = getcwd();
$wbb_root_path = realpath(dirname(__FILE__) . '/../../../') . '/';
chdir($wbb_root_path);
require_once($wbb_root_path . 'global.php');
include($wbb_root_path . 'acp/lib/config.inc.php');
require_once($wbb_root_path . 'acp/lib/options.inc.php');
chdir($curdir);
// endofhack
$pu = parse_url($GLOBALS['url2board']);
$GLOBALS['cookiepath'] = $pu['path'] . '/';
class WBBCMS {
function WBBCMS() {
$this->userid = isset($_COOKIE['wbb2_userid']) ? $_COOKIE['wbb2_userid'] : null;
}
function isLoggedIn() {
return $this->userid;
}
function getUserProfile($userid) {
global $CFG;
if ($userid == SPY_USERID) $rv = NULL;
elseif ($this->userid == $userid) $rv = $GLOBALS['url2board']."/usercp.php?sid={$_COOKIE[$GLOBALS['cookieprefix'].'cookiehash']}";
else $rv = $GLOBALS['url2board'] . "/profile.php?userid={$userid}";
return $rv;
}
function getUser($userid) {
$rv = NULL;
$u = getwbbuserdata($userid);
if ($u) {
$rv['id'] = $u['userid'];
$rv['login'] = $u['username'];
$rv['roles'] = $this->getRoles($u);
$rv['gender'] = $u['gender'];
}
return $rv;
}
function getRoles($userdata) {
$rv = ROLE_USER;
if ($userdata['groupcombinationid'] == 1 ) $rv = ROLE_ADMIN;
if ($userdata['groupcombinationid'] == 3 ) $rv = ROLE_MODERATOR;
return $rv;
}
function login($login, $password) {
global $db, $session, $sid, $n;
$rv = NULL;
$result = getwbbuserdata($login, "username");
$wbbuserpassword = $result['password'];
if ($result['userid'] && $wbbuserpassword == md5($password)) {
if ($result['usecookies'] == 1) {
setcookie($GLOBALS['cookieprefix']."userid", $result['userid'], time() + 3600 * 24 * 365, $GLOBALS['cookiepath']);
setcookie($GLOBALS['cookieprefix']."userpassword", $wbbuserpassword, time() + 3600 * 24 * 365, $GLOBALS['cookiepath']);
}
$db->unbuffered_query("DELETE FROM bb".$n."_sessions WHERE userid = '$result[userid]'", 1);
$db->unbuffered_query("UPDATE bb".$n."_sessions SET userid = '$result[userid]', authentificationcode='', styleid='".$result['styleid']."' WHERE sessionhash = '$sid'", 1);
unset($session['authentificationcode']);
$rv = $result['userid'];
}
return $rv;
}
function userInRole($userid, $role) {
if($user = $this->getUser($userid)) {
return ($user['roles'] == $role);
}
return false;
}
function logout() {
}
function getUsers() {
global $db, $n;
$rv = array();
$result = $db->query("SELECT * FROM bb".$n."_users WHERE userid= '$this->userid'");
$row = mysql_fetch_array($result);
$t['roles'] = $this->getRoles($row);
$t['login'] = $row['username'];
$t['id'] = $row['userid'];
$rv[] = $t;
return $rv;
}
function getGender($userid){
// 'M' for Male, 'F' for Female, NULL for undefined
$rv = NULL;
if($user = $this->getUser($userid)) {
if ($user['gender'] == "1") { $rv = "M"; }
if ($user['gender'] == "2") { $rv = "F"; }
if ($user['gender'] == "0") { $rv = NULL ; }
}
return $rv;
}
}
$GLOBALS['fc_config']['db'] = array(
'host' => $GLOBALS['sqlhost'],
'user' => $GLOBALS['sqluser'],
'pass' => $GLOBALS['sqlpassword'],
'base' => $GLOBALS['sqldb'],
'pref' => 'bb'.$GLOBALS['n']."_fc_",
);
$GLOBALS['fc_config']['cms'] = new WBBCMS();
foreach($GLOBALS['fc_config']['languages'] as $k => $v) {
$GLOBALS['fc_config']['languages'][$k]['dialog']['login']['moderator'] = '';
}
?>
|