I need to check the user database and determine is the password entered is correct, then extract the user group permissions. This will allow me to interace the program with Imagefolio. Any help would be appreciated! I'll pay a reasonable fee for assistance in getting this working - anyone? This is over my head, any help would be appreciated.
Here is a rough script I'm starting from - I highlighted the areas I could use a bit of assistance with:
sub read_user_db {
$dbh=DBI->connect("DBI:$sql_db:$db_name:$db_host:$db_port",$db_user_name,$db_password) or die $DBI::errstr;
$form_password = $dbh->quote($FORM{'if_password'});
$form_username = $dbh->quote($FORM{'if_username'});
$db_query = "SELECT $db_field_username, $db_field_password, $db_field_email, MD5($form_password)"; #use PASSWORD($form_password) if you used mySQL to encrypt password
how do you check against the encrypted password?
$db_query .= ", $db_field_firstname" if $db_field_firstname;
$db_query .= ", $db_field_lastname" if $db_field_lastname;
$db_query .= ", $db_field_group_permissions" if $db_field_group_permissions;
I'll have to do a SELECT to find the user group permissions?
gforum_UserGroup contains the grouping details in here:
if ($dbh) {
$sth = $dbh->prepare($db_query) or die $DBI::errstr;
$sth->execute or die $DBI::errstr;
@row = $sth->fetchrow_array;
$found_this_user = 1 if @row;
$sth->finish();
}
if ($found_this_user) {
if (($row[1] eq $row[3])) {
$found_this_pass = 1;
}
elsif (lc($row[1]) eq lc($FORM{'if_password'})) {
$found_this_pass = 1;
}
$ifusername = $row[0]; # This is the username
$ifemail = $row[2]; # This is the email
$next_field = 4;
if ($db_field_firstname) {
$iffirstname = $row[$next_field]; # This is the first name
$next_field++;
}
if ($db_field_lastname) {
$iflastname = $row[$next_field]; # This is the last name
$next_field++;
}
if ($db_field_group_permissions) {
$ifgroup = $row[$next_field]; # This is the ImageFolio group
}
}
}
1;
Here is a rough script I'm starting from - I highlighted the areas I could use a bit of assistance with:
sub read_user_db {
$dbh=DBI->connect("DBI:$sql_db:$db_name:$db_host:$db_port",$db_user_name,$db_password) or die $DBI::errstr;
$form_password = $dbh->quote($FORM{'if_password'});
$form_username = $dbh->quote($FORM{'if_username'});
$db_query = "SELECT $db_field_username, $db_field_password, $db_field_email, MD5($form_password)"; #use PASSWORD($form_password) if you used mySQL to encrypt password
how do you check against the encrypted password?
$db_query .= ", $db_field_firstname" if $db_field_firstname;
$db_query .= ", $db_field_lastname" if $db_field_lastname;
$db_query .= ", $db_field_group_permissions" if $db_field_group_permissions;
I'll have to do a SELECT to find the user group permissions?
gforum_UserGroup contains the grouping details in here:
so you'd have to determine the users number, then cross reference it to determine what groups they belonged to, then goto Gforum_Grouping extract the group name from the details here:
group_id group_name group_moderator_fk
$db_query .= " FROM $db_table WHERE $db_field_username = $form_username";
if ($dbh) {
$sth = $dbh->prepare($db_query) or die $DBI::errstr;
$sth->execute or die $DBI::errstr;
@row = $sth->fetchrow_array;
$found_this_user = 1 if @row;
$sth->finish();
}
if ($found_this_user) {
if (($row[1] eq $row[3])) {
$found_this_pass = 1;
}
elsif (lc($row[1]) eq lc($FORM{'if_password'})) {
$found_this_pass = 1;
}
$ifusername = $row[0]; # This is the username
$ifemail = $row[2]; # This is the email
$next_field = 4;
if ($db_field_firstname) {
$iffirstname = $row[$next_field]; # This is the first name
$next_field++;
}
if ($db_field_lastname) {
$iflastname = $row[$next_field]; # This is the last name
$next_field++;
}
if ($db_field_group_permissions) {
$ifgroup = $row[$next_field]; # This is the ImageFolio group
}
}
}
1;