Lionel
01-10-2002, 03:50 AM
I found a free simple classifieds software that I would like to use with VB. Problem is, it is using a password text instead of MD5. I was able to encrypt the MD5 at registration. Now I have to be able to read it at login and set the cookie to be vb's cookie. Once I do that, then I can use VB login system.
How can I alter the below function to read MD5 instead of text?
I am also including portion of the login and setcookie of that other software
Function
function verifyUser()
{
global $ADMIN_EMAIL;
session_start();
global $email, $passwd;
if( session_is_registered( "email" ) && session_is_registered( "passwd" ) )
{
$result = mysql_query( "SELECT email, passwd FROM user WHERE email='$email' AND passwd LIKE BINARY '$passwd'" ) or error( "Login failed, please contact <a href=\"$ADMIN_EMAIL\">adminstrator</a>" );
if( mysql_num_rows( $result ) == 1 ) return true;
}
return false;
}
function verifyAdmin()
{
session_start();
global $ADMIN_NAME, $ADMIN_PASS, $adminPasswd, $adminName;
if( session_is_registered( "adminName" ) && session_is_registered( "adminPasswd" ) )
{
if( $adminName == $ADMIN_NAME && $adminPasswd == $ADMIN_PASS )
return true;
}
return false;
}
login.php
if( $action == "login" )
{
$email = trim( $email );
$passwd = trim( $passwd );
if( $email == "" ) error( "Please enter your e-mail" );
if( $passwd == "" ) error( "Please enter your password" );
dbConnect();
$result = mysql_query( "SELECT email FROM user WHERE email='$email'" ) or error( mysql_error() );
if( mysql_num_rows( $result ) != 1 ) error( "Sorry, e-mail doesn't exist" );
$result = mysql_query( "SELECT email FROM user WHERE email='$email' AND passwd LIKE BINARY '$passwd'" ) or error( mysql_error() );
if( mysql_num_rows( $result ) != 1 ) error( "Sorry, invalid password" );
else
{
session_register( "email" );
session_register( "passwd" );
setcookie( "email", $email, time()+3600*24*365 );
if( isset( $cat ) ) header( "Location: ./list.php?cat=$cat" );
if( $cat == "" ) header( "Location: ./account.php" );
}
}
}
How can I alter the below function to read MD5 instead of text?
I am also including portion of the login and setcookie of that other software
Function
function verifyUser()
{
global $ADMIN_EMAIL;
session_start();
global $email, $passwd;
if( session_is_registered( "email" ) && session_is_registered( "passwd" ) )
{
$result = mysql_query( "SELECT email, passwd FROM user WHERE email='$email' AND passwd LIKE BINARY '$passwd'" ) or error( "Login failed, please contact <a href=\"$ADMIN_EMAIL\">adminstrator</a>" );
if( mysql_num_rows( $result ) == 1 ) return true;
}
return false;
}
function verifyAdmin()
{
session_start();
global $ADMIN_NAME, $ADMIN_PASS, $adminPasswd, $adminName;
if( session_is_registered( "adminName" ) && session_is_registered( "adminPasswd" ) )
{
if( $adminName == $ADMIN_NAME && $adminPasswd == $ADMIN_PASS )
return true;
}
return false;
}
login.php
if( $action == "login" )
{
$email = trim( $email );
$passwd = trim( $passwd );
if( $email == "" ) error( "Please enter your e-mail" );
if( $passwd == "" ) error( "Please enter your password" );
dbConnect();
$result = mysql_query( "SELECT email FROM user WHERE email='$email'" ) or error( mysql_error() );
if( mysql_num_rows( $result ) != 1 ) error( "Sorry, e-mail doesn't exist" );
$result = mysql_query( "SELECT email FROM user WHERE email='$email' AND passwd LIKE BINARY '$passwd'" ) or error( mysql_error() );
if( mysql_num_rows( $result ) != 1 ) error( "Sorry, invalid password" );
else
{
session_register( "email" );
session_register( "passwd" );
setcookie( "email", $email, time()+3600*24*365 );
if( isset( $cat ) ) header( "Location: ./list.php?cat=$cat" );
if( $cat == "" ) header( "Location: ./account.php" );
}
}
}