#! /usr/bin/python import cgitb; cgitb.enable() import cgi import os import sys import glob import re import smtplib f = cgi.FieldStorage() l = f.getfirst('l') if not l: l = os.environ.get('PATH_INFO', '/')[1:] desc_re = re.compile(r'List-Id: "?([^<]*)"? <') def getdesc(d): fn = '%s/control/customheaders' % d try: hdrs = file(fn).read() except IOError: return '(none)' ret = desc_re.search(hdrs) if ret: return ret.group(1) else: return '(none)' listdir = '/var/spool/mlmmj/%s' % l if l and os.path.isdir(os.path.join(listdir, 'control')): title = '%s membership' % l a = f.getfirst('a') addr = f.getfirst('addr') if ((a == 'subscribe') or (a == 'unsubscribe')) and addr: server = smtplib.SMTP('localhost') faddr = addr taddr = '%s-%s@woozle.org' % (l, a) try: server.sendmail(faddr, [taddr], 'From: %s\nTo: %s\n\n' % (faddr, taddr)) content = '
I have sent a confirmation message to %s. ' % addr content += 'It should be in your mailbox shortly.
' except Exception, err: content = "Uh oh. That didn't work.
" content += "%s" % cgi.escape(str(err)) else: desc = getdesc(listdir) content = '
To subscribe to or unsubscribe from the %s list,' % l content += ' just enter your email address in this handy dandy form!
' content += '' if os.path.exists(os.path.join(listdir, 'control', 'archive')): content += " " % l else: title = 'Email lists' content = 'list | ' content += 'description | ' content += 'actions | ' content += '
---|---|---|
%s | ' % (l, l) content += '%s | ' % getdesc(d) content += '' if os.path.exists('%s/control/archive' % d): content += 'view archive' % l content += ' |