PHP in mailman templates
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Mailman |
New
|
Medium
|
Unassigned |
Bug Description
Here's a way to force html produced from mailman
templates to execute PHP code when they're served from
a mailman CGI. This idea needs a lot of development,
and although I'm using it on a production system, it's
mainly a proof of concept.
I don't claim much credit for this. I stole the idea
quite blatantly from Fredrik Lundh's "Python Standard
Library" (pub. by O'Reilly).
~mailman/
lines of code:
--- private.py.orig 2006-09-18 14:00:19.000000000 -0500
+++ private.py 2006-10-08 18:36:35.000000000 -0500
@@ -29,6 +29,7 @@
from Mailman import i18n
from Mailman.htmlformat import *
from Mailman.
+from php_redirect import Redirect
# Set up i18n. Until we know which list is being
requested, we use the
# server's default.
@@ -123,6 +124,8 @@
realname = mlist.real_name
message = ''
+ sys.stdout = Redirect(
+
if not mlist.WebAuthen
mm_cfg.
The Redirect class, in php_redirect.py, is as follows:
class Redirect:
"""Redirect stdout to PHP command line interpreter.
Usage: sys.stdout = Redirect(
def __init__(self, stdout):
self.stdout = stdout
import os
self.os = os
def write(self, s):
if self.os.
wpipe = self.os.
else:
Any output after the sys.stdout = Redirect(
line in private.py will be passed through the PHP
command line interpreter if it's present.
This solution doesn't cover the situation where an
archive index.html is public and is accessed directly
by the web server rather than by a mailman CGI. For
this, the quick and dirty hack is to tell apache to
'AddType application/
archive directory, but mailman might look at the
filename on a template and create the working file with
the same extension. e.g. if, say,
~mailman/
it would be used to create
~mailman/
other hand, if the same template were called
archtocnombox.php, then it would be used to create
index.php in the proper archive directory.
[http://
Since the tracker munged my code a bit, I'm attaching a
couple of files.