<?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'] = '';
}
?>