News:

Wondering if this will always be free?  See why free is better.

Main Menu

Authentication Module

Started by Ipak, April 10, 2006, 01:55:45 PM

Previous topic - Next topic

Ipak

I was hoping that some on could help me convert this auth module for this website program: hxxp:evekill.sourceforge.net/ [nonactive]
I have tried on my own, and got to the point where I could get everything but the userid.. I am sure some one here can do it better than I can.. Here is a copy of the auth module for yabbse:
<?
// YabbSE Authentication Module //
// Created for version 1.55 //
// Programming by Shin //

define( 'USER_TABLE_NAME', $INT_Config->parentPrefix.'members' );
define( 'USER_TABLE_USERID_FIELD', 'ID_MEMBER' );
define( 'USER_TABLE_USERNAME_FIELD', 'memberName' );
define( 'USER_TABLE_PASSWORD_FIELD', 'passwd' );

define( 'GROUPS_TABLENAME', $INT_Config->parentPrefix.'membergroups' );
define( 'GROUPS_GROUPID_FIELD', 'ID_GROUP' );
define( 'GROUPS_GROUPNAME_FIELD', 'membergroup' );

define( 'THEME_TABLENAME_DISABLED', true );

define( 'MEMBER_OF_GROUP_TABLENAME', $INT_Config->parentPrefix.'members' );
define( 'MEMBER_OF_GROUP_GROUPID_FIELD', 'memberGroup' );
define( 'MEMBER_OF_GROUP_USERID_FIELD', 'ID_MEMBER' );

define( 'USERS_THEME_TABLENAME_DISABLED', true );

// login class - controls everything to do with login intergration //
class EVEkill_login
{
    var $User;
    var $ID;
    var $Username;
    var $LoggedIn = false;
    var $Permission = false;
   
   
    // Constructor function //
    function EVEkill_login( &$EVEkill, $BypassLogin = false )
    {   
if( !$BypassLogin )
{
        $this->User = $_REQUEST['YaBBSE155'];
       
        if( $this->is_user($EVEkill) )
        {
            $this->get_user($EVEkill);
            $this->LoggedIn = true;
        }
        else
        {
            $this->ID = 0;
            $this->Username = 'Guest';
        }
    }
    }
   
    function is_user(&$EVEkill)
{
// This is less than elegant code...       
        $bits = explode(":", $this->User);
    $rawuid = $bits[5]; // In the form of \"<uid>\"i
    // Cheesy way to get to the end of the uid...
    $index = 2;
    $len = strlen($rawuid);
    while ((substr($rawuid, $index, 1) != "\\") && ($index < $len))
    {
    $index = $index + 1;
    }
    $uid = substr($rawuid, 2, $index-2);
       
        $uid = addslashes($uid);
        $uid = intval($uid);
        if ( !empty( $uid ))
        {
           $result = $EVEkill->database->send_query("SELECT ID_MEMBER FROM ".$EVEkill->configFromFile->parentPrefix."members WHERE ID_MEMBER='$uid'");
       $row = $EVEkill->database->get_array($result);
       
       $id = $row['ID_MEMBER'];
       if($id == $uid && $id != "") {
               $this->ID = $uid;
           return 1;
       }
        }
        return 0;
    }
   
    function get_user(&$EVEkill)
    {   
        $Query = 'SELECT memberName FROM '.$EVEkill->configFromFile->parentPrefix.'members WHERE ID_MEMBER = "'.$this->ID.'"';
        $Array = $EVEkill->database->get_array( $EVEkill->database->send_query( $Query ) );
       
        $this->Username = $Array['memberName'];
    }
   
    function getMemberGroups(&$EVEkill, $LimitToID = true)
    {
$Array = array();
$Counter = 0;

if( $LimitToID )
{
    if( $this->ID == 0 )
    {
    // Load guest access //
    $Array[0] = GUEST_GROUP_ID;
    }
    else
    {
        $Query = $EVEkill->database->send_query( 'SELECT ID_GROUP
FROM '.$EVEkill->configFromFile->parentPrefix.'membergroups, '.$EVEkill->configFromFile->parentPrefix.'members
WHERE ID_MEMBER = "'.$this->ID.'"
AND '.$EVEkill->configFromFile->parentPrefix.'membergroups.membergroup = '.$EVEkill->configFromFile->parentPrefix.'members.membergroup');
       
        while( $Found = $EVEkill->database->get_array( $Query ) )
{
$Array[$Counter++] = $Found['ID_GROUP'];
}
}
        }
        else
        {
        $Query = $EVEkill->database->send_query( 'SELECT ID_GROUP, membergroup
FROM '.$EVEkill->configFromFile->parentPrefix.'membergroups
ORDER BY membergroup ASC' );
while( $Found = $EVEkill->database->get_array( $Query ) )
{
$Array[$Found['ID_GROUP']] = $Found['membergroup'];
}
        }
       
        return $Array;
    }
   
    function installGetSettings( $ParentRoot, $ParentWeb )
{
// The settings are stored in the conf_global.php file //
include_once( $ParentRoot.'Settings.php' );

// Extract settings from the info variable //
$Database['Host'] = $db_server;
$Database['Port'] = '';
$Database['Socket'] = '';
$Database['Username'] = $db_user;
$Database['Password'] = $db_passwd;
$Database['DBName'] = $db_name;
$Database['ParentPrefix'] = $db_prefix;
$Database['OurPrefix'] = 'EVEkill_';

return $Database;
}

function installValidateSettings( &$ParentRoot, &$ParentWeb, &$Error )
{
// Check for the existance of the index.php file //
if( !is_file( $ParentRoot.'index.php' ) )
{
$Error['Parent_Directory'] = 'Unable to find the index.php file in the folder "'.$ParentRoot.'"';
$ParentRoot = '';
$ParentWeb = '';
}

// Can't actually check the web address... //

// Return true to show everything is okay //
return true;
}

function appendSID( $URL )
{
return $URL;
}

function getSID( )
{
return '';
}

// yabbSE doesn't appear to support themes //
function getThemeData( &$EVEkill, $LimitToUser = true )
{
if( $LimitToUser )
{
// Return the user's active theme //
return 1;
}
else
{
// Return an array with all the possible theme ID's //
return array( '1' => 'Default Theme' );
}
}
}

?>

Ipak


Advertisement: