vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   reading MD5 password in php (https://vborg.vbsupport.ru/showthread.php?t=33973)

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" );
}
}

}

Admin 01-10-2002 09:33 AM

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 '".md5($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 '".md5($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" );
}
}

}

Lionel 01-10-2002 10:56 AM

login.php does not let me in...

Admin 01-10-2002 01:09 PM

Are you sure the passwords are really encrypted in the database?
Make sure that your password is (maybe only the newer passwords are and not all of them).

Lionel 01-10-2002 01:23 PM

they are. Anyway I got around it by leaving it as is and parse bbuserinfo[username] and bbuserinfo[password] just like you helped with the other album code. I made it such a way that I removed all login info, switch registration to VB form, updates that database from register.php and member.php. Then in welcometext template I placed the links. As a result, non members can view albums (if not private or if provided password to view) and ads from main menu, members access their controls to manipulate private albums and ads by parsing the required info directly from the welcometext. The whole thing is nice. I have not put up the ads yet because it requires gd which I installed, but am afraid to recompile php so I do not mess up site which got a lot of traffic.

I saw your answer at .com in the html section and I am going to try it in the usercpnav. There I had simulated it with a transparent gif but it bothered my eyes a little because it was not aligning with other menuitems.

Thanks for all help!


All times are GMT. The time now is 11:19 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01504 seconds
  • Memory Usage 1,727KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete