Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hacker <dd0t@users.sourceforge.net>2010-01-20 20:33:53 +0300
committerStefan Hacker <dd0t@users.sourceforge.net>2010-01-20 20:38:22 +0300
commit02805c7693315756e3351c98bdd058801c65c8aa (patch)
treee91eb0aa0eadb91f13bcd1d437243240b91284ac /scripts
parent02160003290d45fa0b820bcf77af45142ca32d19 (diff)
Give phpBB3auth.py auth the ability to display username next to avatar
Diffstat (limited to 'scripts')
-rw-r--r--scripts/phpBB3auth.ini22
-rw-r--r--scripts/phpBB3auth.py37
2 files changed, 50 insertions, 9 deletions
diff --git a/scripts/phpBB3auth.ini b/scripts/phpBB3auth.ini
index d81e76946..7df726cb3 100644
--- a/scripts/phpBB3auth.ini
+++ b/scripts/phpBB3auth.ini
@@ -1,7 +1,7 @@
;Database configuration
[database]
;Only tested with MySQL at the moment
-lib = MySQLdb
+lib = MySQLdb
name = phpbb3
user = phpbb3
password = secret
@@ -12,16 +12,28 @@ port = 3306
;Player configuration
[user]
;If you do not already know what it is just leave it as it is
-id_offset = 1000000000
+id_offset = 1000000000
;If enabled avatars are automatically set as user textures
-avatar_enable = False
-avatar_path = http://host.tld/phpBB3/download/file.php?avatar=
+avatar_enable = False
+avatar_path = http://host.tld/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
port = 6502
-slice = Murmur.ice
+slice = Murmur.ice
;Murmur configuration
[murmur]
diff --git a/scripts/phpBB3auth.py b/scripts/phpBB3auth.py
index a0dabcdab..182180a63 100644
--- a/scripts/phpBB3auth.py
+++ b/scripts/phpBB3auth.py
@@ -52,8 +52,14 @@ default = {'database':(('lib', str, 'MySQLdb'),
('port', int, 3306)),
'user':(('id_offset', int, 1000000000),
- ('avatar_enable', x2bool, True),
- ('avatar_path', str, 'http://forum.tld/phpBB3/download.php?avatar=')),
+ ('avatar_enable', x2bool, False),
+ ('avatar_path', str, 'http://forum.tld/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')),
'ice':(('host', str, '127.0.0.1'),
('port', int, 6502),
@@ -224,6 +230,16 @@ 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):
"""
@@ -355,7 +371,7 @@ def do_main_program():
# Otherwise get the users texture from phpBB3
bbid = id - cfg.user.id_offset
try:
- sql = 'SELECT user_avatar, user_avatar_type FROM %susers WHERE (user_type = 0 OR user_type = 3) AND user_id = %%s' % cfg.database.prefix
+ sql = 'SELECT username, user_avatar, user_avatar_type FROM %susers WHERE (user_type = 0 OR user_type = 3) AND user_id = %%s' % cfg.database.prefix
cur = threadDB.execute(sql, bbid)
except threadDbException:
return FALL_THROUGH
@@ -365,7 +381,7 @@ def do_main_program():
if not res:
debug('idToTexture %d -> user unknown, fall through', id)
return FALL_THROUGH
- avatar_file, avatar_type = res
+ username, avatar_file, avatar_type = res
if avatar_type != 1 and avatar_type != 2:
debug('idToTexture %d -> no texture available for this user (%d), fall through', id, avatar_type)
return FALL_THROUGH
@@ -387,11 +403,21 @@ def do_main_program():
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)
@@ -635,6 +661,9 @@ if __name__ == '__main__':
# 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'