"""Create a message for posting and/or mailing.""" # meoWWW # Copyright 1999 G.J. Andruk # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at # your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. import config, os, sys, string, cgi, urllib, rfc822, mimetools, re from mimify import mime_decode_header from StringIO import StringIO OF=sys.stdout cfg = config.config() NL = '\015\012' scriptname = os.environ['SCRIPT_NAME'] reqinfo = string.split(urllib.unquote_plus(os.environ['QUERY_STRING'])) reqhash = {} for opt in ('group', 'article', 'msgid', 'mail'): reqhash[opt] = '' for option in reqinfo: if option[0:2] == 'g=': reqhash['group'] = string.split(option[2:], ',')[0] elif option[0:2] == 'a=': reqhash['article'] = option[2:] elif option[0:2] == 'm=': reqhash['msgid'] = option[2:] elif option == 'mail': reqhash['mail'] = 'yup' rh = cfg.connect() if reqhash['msgid'] or (reqhash['article'] and reqhash['group']): if reqhash['msgid']: art = rh.article('<%s>' % reqhash['msgid'])[3] else: rh.group(reqhash['group']) art = rh.article(reqhash['article'])[3] inhead = 1 for line in range(len(art)): if inhead: if art[line] == '': inhead = 0 else: if art[line]: art[line] = '> ' + art[line] artbuf = StringIO(string.join(art, '\n')) artmsg = rfc822.Message(artbuf) else: art = '' artmsg = None if artmsg: replyaddr = artmsg.getheader('reply-to') if not replyaddr: replyaddr = artmsg.getheader('from') else: replyaddr = '' replyaddr = cgi.escape(string.replace(replyaddr, '\n', ''), 1) if reqhash['mail']: dopost = '' domail = ' checked' else: dopost = ' checked' domail = '' OF.write('Content-Type: text/html' + NL + NL + '