diff options
Diffstat (limited to 'index.py')
-rwxr-xr-x | index.py | 54 |
1 files changed, 18 insertions, 36 deletions
@@ -1,28 +1,12 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- -import sys, os, re -from web import template, form, application, ctx, wsgi, config -from socket import gethostbyaddr, gethostbyname +# own modules +import config, util -sys.path += ['/usr/lib/mailman'] -import Mailman.Utils - -valid_ips = [ - r'^160\.0?45\.', - r'^130\.133\.', - r'^87\.77\.', - r'^2001:6f8:1c3c:67f0:', - ] - -reserved_names = [ - r'-admin$', - r'-join$', - r'-leave$', - r'-owner$', - r'-request$', - ] - -proxy = gethostbyname('squid.fu-berlin.de') +import sys, os, re, time, socket, subprocess +from web import template, form, application, ctx, wsgi, config, sendmail +from Mailman.Utils import list_exists urls = ( r'/', 'index', @@ -35,26 +19,23 @@ urls = ( render = template.render('templates/', base='layout'); app = application(urls, globals(), autoreload=False) -def validate_name(name): - for regex in reserved_names: - if re.search(regex, name): - return False - return True - create_form = form.Form( form.Textbox('name', form.notnull, form.regexp(r'^[a-zA-Z0-9+.-]{2,}$', 'This name should least be two characters long ' + 'and may only consist of letters, digits, plus (+), minus (-), and underlines (_).'), form.Validator('This name ends with a reserved suffix. Please choose another name.', - validate_name), + util.validate_listname), form.Validator('A list with this name allready exists. Please choose another name.', - lambda name: Mailman.Utils.list_exists(name) == False), + lambda name: list_exists(name) == False), description = 'Name of your list'), + form.Textbox('email', form.notnull, - form.regexp(r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\b', 'This should be a valid email address.'), - form.regexp(r'.*fu-berlin\.de', 'E-mail address should end with fu-berlin.de'), + form.regexp(r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\b', + 'This should be a valid email address.'), + form.regexp(r'.*fu-berlin\.de', + 'E-mail address should end with fu-berlin.de'), description = 'Your E-mail address'), ) @@ -76,10 +57,11 @@ class unsubscribe: class new: def validate(self, ip): - if ip == proxy: - return False + for regex in config.invalid_ips: + if re.match(regex, ip): + return False - for regex in valid_ips: + for regex in config.valid_ips: if re.match(regex, ip): return True @@ -87,7 +69,7 @@ class new: def get_user_information(self): try: - host = gethostbyaddr(ctx.ip)[0] + host = socket.gethostbyaddr(ctx.ip)[0] except: host = ctx.ip |