diff options
author | Stefan Hacker <dd0t@users.sourceforge.net> | 2010-02-12 01:47:07 +0300 |
---|---|---|
committer | Stefan Hacker <dd0t@users.sourceforge.net> | 2010-02-12 01:47:07 +0300 |
commit | 5da1dc21ae1a39719dd7b51a9dae5dc04999c8c4 (patch) | |
tree | 6189a3a5a996c2ad5a21bae6a3ee22cf57c4c133 /Authenticators/phpBB3 | |
parent | 40bb6b1d3d4e2f4b11a1582a2f54c472683565bb (diff) |
Update smfauth.py and phpBB3auth.py for Murmur 1.2.2 avatar capabilities.
WARNING: This breaks backwards compatibility with Murmur <1.2.2 . If you plan to use these scripts in this version or any newer version please update Murmur to at least version 1.2.2.
Diffstat (limited to 'Authenticators/phpBB3')
-rw-r--r-- | Authenticators/phpBB3/phpBB3auth.ini | 14 | ||||
-rw-r--r-- | Authenticators/phpBB3/phpBB3auth.py | 73 |
2 files changed, 7 insertions, 80 deletions
diff --git a/Authenticators/phpBB3/phpBB3auth.ini b/Authenticators/phpBB3/phpBB3auth.ini index d33a295..b97b849 100644 --- a/Authenticators/phpBB3/phpBB3auth.ini +++ b/Authenticators/phpBB3/phpBB3auth.ini @@ -13,22 +13,10 @@ port = 3306 [user] ;If you do not already know what it is just leave it as it is id_offset = 1000000000 -;If enabled avatars are automatically set as user textures +;If enabled avatars are automatically set as user avatars avatar_enable = False avatar_path = http://localhost/phpBB3/download/file.php?avatar= -;If avatar fetching is enabled and the following options are configured -;the username will be overlayed over the avatar from the board. -;The font can be any truetype font (default is verdana), the x,y variables -;define the offset and fill the color used to draw the text -avatar_username_enable = True -avatar_username_font = verdana.ttf -avatar_username_fontsize = 30 -avatar_username_x = 65 -avatar_username_y = 10 -avatar_username_fill = #FFCC01 - - ;Ice configuration [ice] host = 127.0.0.1 diff --git a/Authenticators/phpBB3/phpBB3auth.py b/Authenticators/phpBB3/phpBB3auth.py index 8d23f6f..cd6b772 100644 --- a/Authenticators/phpBB3/phpBB3auth.py +++ b/Authenticators/phpBB3/phpBB3auth.py @@ -36,7 +36,6 @@ # Requirements: # * python >=2.4 and the following python modules: # * ice-python -# * PIL >=1.1.5 (only if avatar import is enabled) # * MySQLdb # * daemon (when run as a daemon) # @@ -44,6 +43,7 @@ import sys import Ice import thread +import urllib2 import logging import ConfigParser @@ -71,7 +71,6 @@ def x2bool(s): #--- Default configuration values # cfgfile = 'phpBB3auth.ini' -user_texture_resolution = (600,60) default = {'database':(('lib', str, 'MySQLdb'), ('name', str, 'phpbb3'), ('user', str, 'phpbb3'), @@ -82,13 +81,7 @@ default = {'database':(('lib', str, 'MySQLdb'), 'user':(('id_offset', int, 1000000000), ('avatar_enable', x2bool, False), - ('avatar_path', str, 'http://localhost/phpBB3/download.php?avatar='), - ('avatar_username_enable', x2bool, True), - ('avatar_username_font', str, 'verdana.ttf'), - ('avatar_username_fontsize', int, 30), - ('avatar_username_x', int, 65), - ('avatar_username_y', int, 10), - ('avatar_username_fill', str, '#FF0000')), + ('avatar_path', str, 'http://localhost/phpBB3/download.php?avatar=')), 'ice':(('host', str, '127.0.0.1'), ('port', int, 6502), @@ -259,17 +252,6 @@ def do_main_program(): Murmur.ServerUpdatingAuthenticator.__init__(self) self.server = server - if cfg.user.avatar_enable and cfg.user.avatar_username_enable: - # Load font - try: - self.font = ImageFont.truetype(cfg.user.avatar_username_font, cfg.user.avatar_username_fontsize) - except IOError, e: - error("Could not load font for username texture overlay from '%s': %s", cfg.user.avatar_username_font, e) - self.font = None - else: - self.font = None - - def authenticate(self, name, pw, certlist, certhash, strong, current = None): """ This function is called to authenticate a user @@ -425,39 +407,15 @@ def do_main_program(): try: handle = urllib2.urlopen(url) - file = StringIO.StringIO(handle.read()) + file = handle.read() handle.close() except urllib2.URLError, e: warning('Image download for "%s" (%d) failed: %s', url, id, str(e)) return FALL_THROUGH - try: - # Load image and scale it - img = Image.open(file).convert("RGBA") - img.thumbnail((user_texture_resolution[0],user_texture_resolution[1]), Image.ANTIALIAS) - img = img.transform(user_texture_resolution, - Image.EXTENT, - (0, 0, user_texture_resolution[0], user_texture_resolution[1])) - - if cfg.user.avatar_username_enable and self.font: - # Insert user name into picture - draw = ImageDraw.Draw(img) - draw.text((cfg.user.avatar_username_x, cfg.user.avatar_username_y), - username, - fill = cfg.user.avatar_username_fill, - font = self.font) - - r,g,b,a = img.split() - raw = Image.merge('RGBA', (b, g, r, a)).tostring() - comp = compress(raw) - res = pack('>L', len(raw)) + comp - except Exception, e: - warning('Image manipulation for "%s" (%d) failed', url, id) - debug(e) - return FALL_THROUGH - - self.texture_cache[avatar_file] = res - return res + self.texture_cache[avatar_file] = file + + return self.texture_cache[avatar_file] def registerUser(self, name, current = None): @@ -684,25 +642,6 @@ if __name__ == '__main__': except Exception, e: print>>sys.stderr, 'Fatal error, could not load config file from "%s"' % cfgfile sys.exit(1) - - # Do conditional imports - if cfg.user.avatar_enable: - # If we use avatars we need PIL to manipulate it and some other stuff for working with them - try: - import Image - if cfg.user.avatar_username_enable: - import ImageFont - import ImageDraw - except ImportError, e: - print>>sys.stderr, 'Error, could not import PIL library, '\ - 'please install the missing dependency and restart the authenticator' - sys.exit(1) - - import urllib2 - import StringIO - - from zlib import compress - from struct import pack try: db = __import__(cfg.database.lib) |