Previous Thread
Next Thread
Print Thread
Hop To
Is 6.5.2 just too new? #128560 05/01/2006 9:08 PM
Joined: Apr 2006
Posts: 116
fatalpapercut Offline OP
member
OP Offline
member
Joined: Apr 2006
Posts: 116
I am trying to integrate flashchat http://www.tufat.com with my .threads CMS and the good thing is that someone has already written an integration module for 6.5.??? threads. It half works and causes errors when trying to add AI bot to the chat which runs but doesn't do anything. If however one specifies not to integrate with .threads the bot works. Rick, here is the ubbCMS module. I appreciate if you could have a quick glance and tell me if you think there is something there that shouldn't be there, cheers! (the errors seem to occure when requests involve the word 'user')

Code
  

<?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 UBB.Threads (www.ubbcentral.com/ubbthreads/)


$ubb_root_path = realpath(dirname(__FILE__) . '/../../../') . '/';

require_once($ubb_root_path . 'includes/config.inc.php');

class UBBCMS {

    function UBBCMS() {

        $this->loginStmt = new Statement("SELECT U_Username, U_Laston, U_Password,U_Number,U_Language,U_TempPass,U_Approved,U_Banned,U_CoppaUser FROM   {$GLOBALS['config']['tbprefix']}Users WHERE  U_LoginName = ? LIMIT 1");
        $this->updateSessionStmt = new Statement("UPDATE {$GLOBALS['config']['tbprefix']}Users SET    U_Laston   = ?, U_SessionId = ? WHERE  U_Username = ?");
        $this->getUserStmt = new Statement("SELECT U_Username as login, U_Number as id, U_Status as status FROM {$GLOBALS['config']['tbprefix']}Users WHERE  U_Number = ? LIMIT 1");
        $this->getUsersStmt = new Statement("SELECT U_Username as login, U_Number as id FROM {$GLOBALS['config']['tbprefix']}Users");
        $this->userid = isset($_COOKIE["w3t_myid"]) ? $_COOKIE["w3t_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)) {
            $rv = ($id = $this->isLoggedIn() && ($id == $userid)) ? $GLOBALS["config"]["phpurl"] . "/login.php?Cat=0&myhome=1" : $GLOBALS["config"]["phpurl"] . "/showprofile.php?Cat=0&User={$userid}";
        }

        return $rv;
    }


    function getUser($userid) {

        $rs = $this->getUserStmt->process($userid);
        $rv = $rs->next();

        if($rv) {
            $rv["roles"] = $this->getRoles($rv["status"]);
        }
        return $rv;
    }

    // taken from ubbt.inc.php

    function ubbt_setcookie($name,$value="",$time=0,$cookiepath="") {

        if (!$cookiepath) {
            $cookiepath = $GLOBALS['config']['cookiepath'];
            if ($GLOBALS['config']['search_urls'] && !$cookiepath) {
                $cookiepath = "/";
            }
        }
        if (($GLOBALS['config']['tracking'] == "cookies") || ($name == "{$GLOBALS['config']['tbprefix']}ubbt_pass") || ($name == "{$GLOBALS['config']['tbprefix']}ubbt_dob")) {
            setcookie("$name","$value",$time,$cookiepath);
        }
        else {
            session_register($name);
            $name = $value;
        }

    }

    function login($login, $password) {

        $goodPassword = false;

        $rs = $this->loginStmt->process(addslashes($login));
        $rec = $rs->next();

        if ($rec) {
            // check if user is banned
            if ($rec["U_Banned"]) return NULL;

            // allow login only with permanent password. Ignore the temporary password
            if (md5($password) != $rec["U_Password"]) return NULL;

            if (!$rec["U_Laston"]) {
                $laston = time() + $GLOBALS["config"]["adjustime"] * 3600;
            }
            $this->ubbt_setcookie("{$GLOBALS['config']['cookieprefix']}w3t_myid",$rec['U_Number'],time()+$GLOBALS['config']['cookieexp']);

            $this->updateSessionStmt->process(time() + $GLOBALS["config"]["adjustime"] * 3600, md5(rand(0,32767)), addslashes($login));


            return $rec['U_Number'];

        }

    }

	function userInRole($userid, $role) {
		if($user = $this->getUser($userid)) {
			return ($user['roles'] == $role);
		}
		return false;
	}

    function logout() {

    }

    function getUsers() {
        $this->getUsersStmt->process();
    }

	function getGender($userid) {
        // 'M' for Male, 'F' for Female, NULL for undefined
        return NULL;
    }
}

$GLOBALS['fc_config']['db'] = array(
                'host' => $GLOBALS["config"]["dbserver"],
                'user' => $GLOBALS["config"]["dbuser"],
                'pass' => $GLOBALS["config"]["dbpass"],
                'base' => $GLOBALS["config"]["dbname"],
                'pref' => $GLOBALS["config"]["tbprefix"] . 'fc_',
                );

$GLOBALS['fc_config']['cms'] = new UBBCMS();


foreach($GLOBALS['fc_config']['languages'] as $k => $v) {
    $GLOBALS['fc_config']['languages'][$k]['dialog']['login']['moderator'] = '';
}

?>



Re: Is 6.5.2 just too new? #128561 05/02/2006 1:12 PM
Joined: Apr 2006
Posts: 116
fatalpapercut Offline OP
member
OP Offline
member
Joined: Apr 2006
Posts: 116
Ahahahaha just found the bug in this code that was responsible. Can you find it? <img src="https://www.ubbcentral.com/boards/images/graemlins/grin.gif" alt="" /> <img src="https://www.ubbcentral.com/boards/images/graemlins/grin.gif" alt="" /> <img src="https://www.ubbcentral.com/boards/images/graemlins/grin.gif" alt="" />

Re: Is 6.5.2 just too new? #128562 05/02/2006 7:50 PM
Joined: Jun 2006
Posts: 9,243
Rick Offline
Former Developer
Offline
Former Developer
Joined: Jun 2006
Posts: 9,243
Blah, I have trouble debugging my own code let alone someone elses <img src="https://www.ubbcentral.com/boards/images/graemlins/laugh.gif" alt="" />

Re: Is 6.5.2 just too new? #128563 05/03/2006 11:38 AM
Joined: Apr 2006
Posts: 116
fatalpapercut Offline OP
member
OP Offline
member
Joined: Apr 2006
Posts: 116
I am not really a programmer, but yeah, I know what you mean <img src="https://www.ubbcentral.com/boards/images/graemlins/wink.gif" alt="" />

function getUsers() returns nothing, you call it and expect an array but in fact get silence...because someone forgot to type "return". <img src="https://www.ubbcentral.com/boards/images/graemlins/shocked.gif" alt="" />

Re: Is 6.5.2 just too new? #128564 05/03/2006 6:35 PM
Joined: Jun 2006
Posts: 23
misho Offline
stranger
Offline
stranger
Joined: Jun 2006
Posts: 23
I am not PHP programmer, but in Perl if you don't have return it will return the value of the variable that happens to be on the last line of the subroutine.


Forum Search
ShoutChat Box
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
Having issue with redirects to UBB classic URLs
by amciotola - 10/16/2019 1:11 AM
Unable to save General settings
by amciotola - 10/13/2019 4:23 AM
I see signature line images, but no avatars
by Morgan - 10/12/2019 2:21 PM
Show PDF
by Geoff - 10/09/2019 1:33 AM
Subscription’s Auto Return URL for PayPal
by Geoff - 09/27/2019 12:10 AM
Who's Online Now
2 registered members (JAISP, isaac), 91 guests, and 426 spiders.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Artistic structures
Artistic structures
by isaac, August 29
Stones
Stones
by isaac, August 19
Amusing Terain Scenics
Amusing Terain Scenics
by isaac, August 19
Sky places
Sky places
by isaac, August 19
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Snapshot build 20190930)