Need Help: Embeding php scripts in wiki pages.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Need Help: Embeding php scripts in wiki pages.

Mortico
I've made a parser hook extention that parses the tags <php> and </php> into the tags for actual php code.  it is working so far, but somthing in wikimedia keeps adding additional code to the closing bracket, rendering it non-functional.

This is my extention:
$wgExtensionFunctions[] = "wfembededphp";

function wfembededphp() {
    global $wgParser;
    $wgParser->setHook( "php", "renderscript" );
}

function renderscript( $input, $argv ) {
    $output = "<?php $input ?>";
    return $output;
}

This is the code i'm testing, it is simply typed into the wiki page like normal.
<php>
print "this is some php code";
</php>

This is what it shoudl look like in the page source:
<?php
print "this is some php code";
?>

This is what it ACTUALLY gives me:
<p><?
print "this is some php code";
</p>
<pre>?>
</pre>

The additional tags of </p> and <pre> contained within the php code are screwing it up and causing nothing to display, instead of running the script as it should.

I think that the wiki is parsing more tags into the final code, after the code has been rendered how i want it.  I would think that a solution would be to get my extention to run after all other rendering on the page is done.  But i don't know how to do that, and i think there must be an easier way.

I'm pretty new to php, so please don't be overly technical.  thanks!

Reply | Threaded
Open this post in threaded view
|

Re: Need Help: Embeding php scripts in wiki pages.

Brion Vibber
Mortico wrote:
> I've made a parser hook extention that parses the tags <php> and </php> into
> the tags for actual php code.

Don't do this unless you enjoy having your server compromised.

-- brion vibber (brion @ pobox.com)


_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l

signature.asc (257 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Need Help: Embeding php scripts in wiki pages.

Mortico
actually, jstu about all of my wiki is restricted to certain users, throguh some other code i've incorporated.  Once i get this basic part working, i intend to only allow php code on restricted pages.

Why is it restricted? the wiki is used for deveoloping a project that isn't yet public, but has several authors from around the country working on it.  So far only 3 people (who are very good friends of mine) have access to most of the wiki.

The only other solution is to write the code on seprate pages, and have that code generate the wiki-formatted pages, which can be cut and pasted into the pages when the page needs updated.  This is a pain in the ass however.
Reply | Threaded
Open this post in threaded view
|

Re: Need Help: Embeding php scripts in wiki pages.

Bugzilla from sy1234@gmail.com
I'm also interested in the solution to this, as I was thinking of
making a simple ruby extension.

Ruby could be set with very strong security settings, running all code
in a sandbox and only generating printable characters.  It would be
quite safe, especially as the technique is being used actively
elsewhere [1].

As an aside, making the extension optionally display the source code,
the result of running the code, or both, would be nice.  Throwing in
code colouring is also possible via another extension but I'd probably
do something myself for both source and the result.


[1]
* http://tryruby.hobix.com/
* http://pine.fm/LearnToProgram/
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Need Help: Embeding php scripts in wiki pages.

Mortico
In reply to this post by Mortico
WikiMedia was really designed so that anyone can write things, so it is understandable that there is very little support for this kind of feature.  For security reasons.

I've found some other wiki software that is actually much better suited for my project, which is a manual that is only being developed by about 3 people.  Many of the features (or lack thereof) MediaWiki offers are not suited for this kind of project.  Thanks for all the help, MediaWiki is awsome and very powerful, but just not well suited for a small-scale, private, low-member communites.

DokuWiki (http://wiki.splitbrain.org) seems much more geared towards my kind of project, and has built-in suppot for embeded php and html.

Again, thanks for all you help!