FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » Single Login with a CMS
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Single Login with a CMS [message #23392 is a reply to message #23322] Tue, 15 March 2005 08:10 Go to previous messageGo to previous message
LastQuark   United States
Messages: 12
Registered: August 2003
Karma:
Junior Member
...one day later...

How am I going to execute this file? Should I use 'onsubmit' to the form name to execute it like:

/* filename = fudlogin.xd */

<form action="&xar-modurl-roles-user-login;" method="post" enctype="application/x-www-form-urlencoded" onsubmit="forum_login.php">
<div>
    <div style="text-align: left; margin: 3px;"><label for="uname#$blockid#"><xar:mlstring>Username</xar:mlstring>:</label></div>
    <div style="text-align: right; margin: 3px;"><input type="text" name="uname" id="uname#$blockid#" maxlength="64" size="10" /></div>
</div>
<div>
    <div style="text-align: left; margin: 3px;"><label for="pass#$blockid#"><xar:mlstring>Password</xar:mlstring>:</label></div>
    <div style="text-align: right; margin: 3px;"><input type="password" name="pass" id="pass#$blockid#" maxlength="64" size="10" /></div>
</div>

<xar:if condition="xarConfigGetVar('Site.Session.SecurityLevel') ne 'High'">
    <div style="text-align: center; margin: 3px;"><input type="checkbox" name="rememberme" id="rememberme#$blockid#" value="1" />
    <label for="rememberme#$blockid#"><xar:mlstring>Remember me</xar:mlstring></label></div>
</xar:if>

<input type="hidden" name="redirecturl" id="returnurl#$blockid#" value="#$return_url#" />
<div style="text-align: center; margin: 3px;"><input type="submit" value="#$signinlabel#" /></div>

<xar:if condition="$showregister eq 1">
    <div style="text-align: center; margin: 3px;"><xar:mlstring>Need an account?</xar:mlstring><br />
    <a href="#$registerurl#"><xar:mlstring>Register here</xar:mlstring></a>.</div>
</xar:if>
</form>


...or should I execute it in the function as follows as soon as the user is authenticated (see arrows):

<?php
/* filename = authenticate_user.php */

function authfud__get_fud_userdata($connect,$username,$pass)
{
    $prefix = xarModGetVar('authfud','prefix');
    $password = md5($pass);
    $table = $prefix.'users';

    if($connect)  //just double-checking the connection.
    {
        // connect to the FUDforum database and get the user data
        //$inv_db = mysql_select_db($database, $connect);
        $query = "SELECT * FROM " . $table . " WHERE login=? AND passwd=?";
        
        $connect->SetFetchMode(ADODB_FETCH_ASSOC);
        
        $bindvars = array($username, $password);
        $result =& $connect->Execute($query,$bindvars);
    
        if (!$result) {
            //error
            $msg = "FUDforum: Query to $table has failed: " . $connect->ErrorMsg();
            xarErrorSet(XAR_SYSTEM_EXCEPTION, 'SQL_ERROR',
                new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
            error_log("FUDforum Error: Query to $table failed");
            return false;
        } 
        if ($result->EOF)
        {
            //incorrect login
        $msg = xarML('Wrong username (#(1)) or pass (not shown).', $username);
            xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM',
                new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
            $result->Close();
            return false;
        }
        else {
            //correct login.  return uid.
                if ($result->fields['users_opt']=='0')
                {
                    //user inactive
                    $msg = xarML('User #(1) not activated.', $username);
                    xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM',
                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
                    $result->Close();
                    return false;    
                }
                else
                {
                    $user_data=$result->fields;
                    $result->Close();
                    return $user_data;
                }
        }
        INCLUDE('forum_login.php');  <<<<<<<========
    }
}

?>


Attached is the zip file that contains the files of the FUDforum module that was created specifically to work with Xaraya.

Pardon my ignorance. Several PHP books for Dummies are on the way...I can't wait to get this mod working before the books arrive.

  • Attachment: authfud.zip
    (Size: 24.16KB, Downloaded 727 times)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Renaming index.php and wrapping forums
Next Topic: Why store message body a textfile?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 27 07:32:55 GMT 2024

Total time taken to generate the page: 0.04201 seconds