...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.