From 4cf754ca57ef2e904082e105fcd4b78f97ed00a9 Mon Sep 17 00:00:00 2001 From: viega Date: Sat, 30 May 1998 06:06:53 +0000 Subject: Integrated Scott's cookie code into the distribution. Note that it does have one problem... If you have cookies off, you have to log in every time, plus your changes don't take effect! That definitely needs to be fixed. --- cgi/admin | 392 ++++++++++++++++++++++++++++++++++++++++++------------------ cgi/private | 22 ---- 2 files changed, 274 insertions(+), 140 deletions(-) (limited to 'cgi') diff --git a/cgi/admin b/cgi/admin index 69f3d9b5d..b0c7457db 100755 --- a/cgi/admin +++ b/cgi/admin @@ -21,12 +21,12 @@ To run stand-alone for debugging, set env var PATH_INFO to name of list and, optionally, options category.""" -__version__ = "$Revision: 564 $" +__version__ = "$Revision: 635 $" import sys -import os, cgi, string, crypt, types +import os, cgi, string, crypt, types, time import paths # path hacking -import mm_utils, maillist, mm_cfg, mm_err +import mm_utils, maillist, mm_cfg, mm_err, mm_mailcmd, Cookie from htmlformat import * try: @@ -44,12 +44,63 @@ CATEGORIES = [('general', "General Options"), ('archive', "Archival Options")] +LOGIN_PAGE = """ + +
+(Note that you can, alternately, set the subscriber's no-delivery - option to inhibit delivery of their messages, if you want to only - temporarily disable their delivery.)
""" - % lst.GetScriptURL('roster')) + user_table = Table(width="90%") + user_table.AddRow([Center(Header(4, "Membership List"))]) + user_table.AddCellInfo(user_table.GetCurrentRowIndex(), + user_table.GetCurrentCellIndex(), + bgcolor="#cccccc", colspan=8) + + members = {} + digests = {} + for member in lst.members: + members[member] = 1 + for member in lst.digest_members: + digests[member] = 1 + all = lst.members + lst.digest_members + if len(all) > mm_cfg.ADMIN_MEMBER_CHUNKSIZE: + chunks = mm_utils.chunkify(all) + if not cgi_data.has_key("chunk"): + chunk = 0 + else: + chunk = string.atoi(cgi_data["chunk"].value) + all = chunks[chunk] + footer = ("
To View other sections, " + "click on the appropriate range listed below") + chunk_indices = range(len(chunks)) + chunk_indices.remove(chunk) + buttons = [] + pi = os.environ["PATH_INFO"] + for ci in chunk_indices: + start, end = chunks[ci][0], chunks[ci][-1] + buttons.append(" from %s to %s " % \ + ( pi, ci, start, end)) + buttons = apply(UnorderedList, tuple(buttons)) + footer = footer + buttons.Format() + "
" + else: + all.sort() + footer = "
" + for member in all: + cells = [member + "" % (member), + "subscribed " +CheckBox(member + "_subscribed", "on", 1).Format(), + ] + if members.get(member): + cells.append("digest " + CheckBox(member + "_digest", "off", 0).Format()) + else: + cells.append("digest " + CheckBox(member + "_digest", "on", 1).Format()) + for opt in ("hide", "nomail", "ack", "norcv", "plain"): + if lst.GetUserOption(member, mm_mailcmd.option_info[opt]): + value = "on" + checked = 1 + else: + value = "off" + checked = 0 + box = CheckBox("%s_%s" % (member, opt), value, checked) + cells.append("%s %s" % (opt, box.Format())) + user_table.AddRow(cells) + container.AddItem(Center(user_table)) + container.AddItem(footer) + t = Table(width="90%") + t.AddRow([Center(Header(4, "Mass Subscribe Members"))]) + t.AddCellInfo(t.GetCurrentRowIndex(), + t.GetCurrentCellIndex(), + bgcolor="#cccccc", colspan=8) + container.AddItem(Center(t)) + container.AddItem(Center(TextArea(name='subscribees', rows=10,cols=60,wrap=None))) + container.AddItem(Center(" Enter One address per line
")) return container def FormatPasswordStuff(): - password_submit = Table(bgcolor="#99cccc", - border=0, cellspacing=0, cellpadding=2) - password_submit.AddRow([Center(Bold('To Submit Your Changes'))]) - password_submit.AddCellInfo(password_submit.GetCurrentRowIndex(), 0, - colspan=2) - password_submit.AddRow(['
") + password_stuff.AddItem(submit) return password_stuff # XXX klm - looks like turn_on_moderation is orphaned. @@ -582,7 +659,38 @@ def GetValidValue(lst, prop, my_type, val, dependant): def ChangeOptions(lst, category, cgi_info, document): dirty = 0 - if category != 'members': + confirmed = 0 + if cgi_info.has_key('newpw'): + if cgi_info.has_key('confirmpw'): + if cgi_info.has_key('adminpw'): + try: + lst.ConfirmAdminPassword(cgi_info['adminpw'].value) + confirmed = 1 + except mm_err.MMBadPasswordError: + m = "Error: incorrect administrator password" + document.AddItem(Header(3, Italic(FontAttr(m, color="ff5060")))) + confirmed = 0 + if confirmed: + new = cgi_info['newpw'].value + confirm = cgi_info['confirmpw'].value + if new == confirm: + lst.password = crypt.crypt(new, mm_utils.GetRandomSeed()) + dirty = 1 + else: + m = 'Error: Passwords did not match.' + document.AddItem(Header(3, Italic(FontAttr(m, color="ff5060")))) + + else: + m = 'Error: You must type in your new password twice.' + document.AddItem( + Header(3, Italic(FontAttr(m, color="ff5060")))) + # + # for some reason, the login page mangles important values for the list + # such as .real_name so we only process these changes if the category + # is not "members" and the request is not from the login page + # -scott 19980515 + # + if category != 'members' and not cgi_info.has_key("request_login"): opt_list = GetConfigOptions(lst, category) for item in opt_list: if len(item) < 5: @@ -600,37 +708,85 @@ def ChangeOptions(lst, category, cgi_info, document): val = cgi_info[property].value value = GetValidValue(lst, property, kind, val, deps) if getattr(lst, property) != value: + print "property: ", property, "value: ", value setattr(lst, property, value) dirty = 1 + # + # mass subscription processing for members category + # if cgi_info.has_key('subscribees'): name_text = cgi_info['subscribees'].value - names = string.split(name_text, '\r\n') - for new_name in names: + name_text = string.replace(name_text, '\r', '') + names = string.split(name_text, '\n') + if '' in names: + names.remove('') + subscribe_success = [] + subscribe_errors = [] + for new_name in map(string.strip,names): + digest = 0 + if not lst.digestable: + digest = 0 + if not lst.nondigestable: + digest = 1 try: -#FIXME: The admin needs to be able to specify subscribe options - lst.AddMember(new_name, (mm_utils.GetRandomSeed() + - mm_utils.GetRandomSeed())) - dirty = 1 -#FIXME: Give some sort of an indication of which names didn't work, -# and why they didn't work... - except: - pass - if cgi_info.has_key('newpw'): - if cgi_info.has_key('confirmpw'): - new = cgi_info['newpw'].value - confirm = cgi_info['confirmpw'].value - if new == confirm: - lst.password = crypt.crypt(new, mm_utils.GetRandomSeed()) + lst.ApprovedAddMember(new_name, (mm_utils.GetRandomSeed() + + mm_utils.GetRandomSeed()), digest) + subscribe_success.append(new_name) + except mm_err.MMAlreadyAMember: + subscribe_errors.append((new_name, 'Already a member')) + + except mm_err.MMBadEmailError: + subscribe_errors.append((new_name, "Bad/Invalid email address")) + except mm_err.MMHostileAddress: + subscribe_errors.append((new_name, "Hostile Address (illegal characters)")) + if subscribe_success: + document.AddItem(Header(5, "Successfully Subscribed:")) + document.AddItem(apply(UnorderedList, tuple((subscribe_success)))) + document.AddItem("
") + if subscribe_errors: + document.AddItem(Header(5, "Error Subscribing:")) + items = map(lambda x: "%s -- %s" % (x[0], x[1]), subscribe_errors) + document.AddItem(apply(UnorderedList, tuple((items)))) + document.AddItem("
") + # + # do the user options for members category + # + if cgi_info.has_key('user'): + user = cgi_info["user"] + if type(user) is type([]): + users = [] + for ui in range(len(user)): + users.append(user[ui].value) + else: + users = [user.value] + for user in users: + if not cgi_info.has_key('%s_subscribed' % (user)): + lst.DeleteMember(user) dirty = 1 - else: - m = 'Error: Passwords did not match.' - document.AddItem( - Header(3, Italic(FontAttr(m, color="ff5060")))) + continue + if not cgi_info.has_key("%s_digest" % (user)): + if user in lst.digest_members: + list.digest_members.remove(user) + dirty = 1 + if user not in lst.members: + lst.members.append(user) + dirty = 1 + else: + if user not in lst.digest_members: + lst.digest_members.append(user) + dirty = 1 + if user in lst.members: + lst.members.remove(user) + dirty = 1 + + for opt in ("hide", "nomail", "ack", "norcv", "plain"): + if cgi_info.has_key("%s_%s" % (user, opt)): + lst.SetUserOption(user, mm_mailcmd.option_info[opt], 1) + dirty = 1 + else: + lst.SetUserOption(user, mm_mailcmd.option_info[opt], 0) + dirty = 1 - else: - m = 'Error: You must type in your new password twice.' - document.AddItem( - Header(3, Italic(FontAttr(m, color="ff5060")))) if dirty: lst.Save() diff --git a/cgi/private b/cgi/private index 72d5c6031..facca81bc 100755 --- a/cgi/private +++ b/cgi/private @@ -74,7 +74,6 @@ PAGE = ''' login_attempted = 0 _list = None -# XXX: This looks broken, should investigate name_pat = re.compile(r""" (?: / (?: \d{4} q \d\. )? # Match "/", and, optionally, 1998q1." ( [^/]* ) /? # The SIG name @@ -88,20 +87,6 @@ name_pat = re.compile(r""" ) """, re.VERBOSE) -# " XXX: Emacs turd -# the following is a potentially better rewrite - -## name_pat = re.compile( -## r'(?: / (?: \d{4} q \d\. )?' # Match "/", and, optionally, 1998q1." -## r'( [^/]* ) /?' # The SIG name -## r'/[^/]*$' # The trailing 12345.html portion -## r') | (?:' -## r'/ ( [^/.]* )' # Match matrix-sig -## r'(?:\.html)?' # Optionally match .html -## r'/?' # Optionally match a trailing slash -## r'$)' # Must match to end of string -## , re.VERBOSE) - def getListName(path): match = name_pat.search(path) if match is None: return @@ -109,13 +94,6 @@ def getListName(path): if match.group(2): return match.group(2) raise ValueError, "Can't identify SIG name" -#for i in ['/matrix-sig.html', '/1998q1.c++-sig/index.html', -# '/1998q1.string-sig/foobar.html', -# '/psa-members.html']: -# print i, `getListName(i)` -#sys.exit(0) - -## sys.exit(0) def GetListobj(list_name): """Return an unlocked instance of the named maillist, if found.""" -- cgit v1.2.3-70-g09d2