Skip to content

Commit

Permalink
New 'phpnuke_phpbb_mysql' storage module (contributed by Matthew Trout)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpm committed Aug 1, 2004
1 parent 665d41d commit 53d6166
Show file tree
Hide file tree
Showing 3 changed files with 830 additions and 1 deletion.
37 changes: 37 additions & 0 deletions auth/phpnuke_phpbb_mysql_users.py
@@ -0,0 +1,37 @@
#!/usr/bin/env python
# Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information.
import MySQLdb
import settings
import md5

class Papercut_Auth:
"""
Authentication backend interface for the nuke port of phpBB (http://www.phpnuke.org)
This backend module tries to authenticate the users against the nuke_users table.
"""

def __init__(self):
self.conn = MySQLdb.connect(host=settings.dbhost, db=settings.dbname, user=settings.dbuser, passwd=settings.dbpass)
self.cursor = self.conn.cursor()

def is_valid_user(self, username, password):
stmt = """
SELECT
user_password
FROM
%susers
WHERE
username='%s'
""" % (settings.nuke_table_prefix, username)
num_rows = self.cursor.execute(stmt)
if num_rows == 0 or num_rows is None:
settings.logEvent('Error - Authentication failed for username \'%s\' (user not found)' % (username))
return 0
db_password = self.cursor.fetchone()[0]
if db_password != md5.new(password).hexdigest():
settings.logEvent('Error - Authentication failed for username \'%s\' (incorrect password)' % (username))
return 0
else:
return 1

14 changes: 13 additions & 1 deletion settings.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information.
# $Id: settings.py,v 1.17 2002-12-13 07:32:10 jpm Exp $
# $Id: settings.py,v 1.18 2004-08-01 01:03:22 jpm Exp $
import time
import sys
import os
Expand Down Expand Up @@ -99,6 +99,18 @@
phpbb_table_prefix = "phpbb_"


#
# PHPNUKE PHPBB STORAGE MODULE OPTIONS
#

# if you're running PHPNuke, set this for the nuke tables and phpbb_table_prefix
# for the bb tables.
nuke_table_prefix = "nuke_"

# the prefix for the phpBB tables
phpbb_table_prefix = "nuke_bb"


#
# MBOX STORAGE MODULE OPTIONS
#
Expand Down

0 comments on commit 53d6166

Please sign in to comment.