Hallo all!
I d like to use the Mysql database of phpbb v3.08 for authentication.
I found one script but it doesn't work, because it isn' t made directly for the phpbb-database:
#!/usr/bin/perl
# Mysql external auth script
# Features: auth isUser and change password
# Password is an encrypted password !!
# Settings
my $sDatabaseHost='localhost'; # The hostname of the database server
my $sDatabaseUser="*********"; # The username to connect to mysql
my $sDatabasePass='*********'; # The password to connect to mysql
my $sDatabaseName="forum"; # The name of the database contain the user table
my $sUserTable="phpbb_users"; # The name of the table containing the username and password
my $sUsernameTableField="username"; # The name of the field that holds jabber user names
my $sPasswordTableField="user_password"; # The name of the field that holds jabber passwords
# Libs
use DBI;
use DBD::mysql;
use Digest::MD5 qw(md5 md5_hex md5_base64);
while(1) {
my $sBuffer = "";
my $readBuffer = sysread STDIN,$sBuffer,2;
my $iBufferLength = unpack "n",$sBuffer;
my $readBuffer = sysread STDIN,$sBuffer,$iBufferLength;
my ($sOperation,$sUsername,$sDomain,$sPassword) = split /:/,$sBuffer;
my $bResult;
SWITCH: {
$sOperation eq 'auth' and do {
$bResult = 0;
$connect = DBI->connect('DBI:mysql:'.$sDatabaseName, $sDatabaseUser, $sDatabasePass) || die "Could not connect to database: $DBI::errstr";
$query = "SELECT $sPasswordTableField FROM $sUserTable WHERE $sUsernameTableField='$sUsername';";
$statement = $connect->prepare($query);
$statement->execute();
while ($row = $statement->fetchrow_hashref()) {
$sCryptstring = md5($sPassword,$row->{$sPasswordTableField});
if ($row->{$sPasswordTableField} eq $sCryptstring) {
$bResult = 1;
}
}
},last SWITCH;
$sOperation eq 'setpass' and do {
$connect = DBI->connect('DBI:mysql:'.$sDatabaseName, $sDatabaseUser, $sDatabasePass) || die "Could not connect to database: $DBI::errstr";
$myquery = "UPDATE $sUserTable SET $sPasswordTableField=ENCRYPT('$sPassword') WHERE $sUsernameTableField='$sUsername';";
$statement = $connect->prepare($myquery);
$statement->execute();
$bResult = 1;
},last SWITCH;
$sOperation eq 'isuser' and do {
$bResult = 0;
$connect = DBI->connect('DBI:mysql:'.$sDatabaseName, $sDatabaseUser, $sDatabasePass) || die "Could not connect to database: $DBI::errstr";
$myquery = "SELECT count(*) AS iCount FROM $sUserTable WHERE $sUsernameTableField='$sUsername';";
$statement = $connect->prepare($myquery);
$statement->execute();
$row = $statement->fetchrow_hashref();
if($row->{'iCount'} >= 1){
$bResult = 1;
}
},last SWITCH;
};
my $sOutput = pack "nn",2,$bResult ? 1 : 0;
syswrite STDOUT,$sOutput;
}
closelog;
Maybee there is a talented coder in this forum who could make the needed changes?
There a some more people who need a working script and would be happy to get help!
friendly greetings
Andreas
Hallo, the problem doesn't
Hallo,
the problem doesn't exist any more.
Greetings
Andreas