[Mediawiki-l] PHP code inclusion

Rowan Collins rowan.collins at gmail.com
Tue Nov 9 23:07:33 UTC 2004


On Tue, 9 Nov 2004 08:21:25 -0700, Taneem A T <thezeropoint at gmail.com> wrote:
> So I was thinking, could we modify the hack so that you couldn't put
> in PHP directly into the Wiki but you could include an external PHP
> file whose code would be executed?

Perhaps this would be a good reason to implement the ability to
include [some?] Special: pages as templates, as requested at
http://bugzilla.wikipedia.org/show_bug.cgi?id=813

That way, the PHP code could only be written by someone with access to
the wiki's source directory, and there would be no need to validate
filenames, as none would ever be directly given (they would be
produced by Title.php, presumably).

I don't know how easy this would be to implement cleanly, though,
given the mixed wiki-text/raw html output of current Special pages.
Maybe SpecialPage.php could have an "executeAsTemplate()" method,
which returned wikitext to be included if the page was requested as an
inclusion. That way, it could return "" by default, and potentially
format things differently than accessing the page normally; and a site
administrator could create Special: pages to do custom bits of php,
even giving them parameters (either using the sub-page style, like
[[Special:Whatlinkshere/foo]], or by having template parameters passed
to exeuteAsTemplate() - in an associative array or somesuch. Hm, I
think I'll shove this suggestion on the bug report...

-- 
Rowan Collins BSc
[IMSoP]



More information about the MediaWiki-l mailing list