Extension talk:Runphp page

From MediaWiki.org
Jump to: navigation, search

/Archive

Contents

[edit] does not work for me

This extension does not work for me. It allows me to echo and print text and some basics, but it will not let me use variables, include functions, or connect to a database. I needed to print results from a database and managed to do so, but I had to create a non-wiki php page elsewhere and import the page in an iframe using html. (I have read all the warning about using php). Does anyone else have the same problem...or a solution? Damien (Mediaiwki 1.8.2)

1- What variables? The ones of Mediawiki? If they are global, then put the statement "global $varXYZ;" in the page to access them.
2- Database access: I have successfully access the MySQL database of MW through this function. Have you referred to the global variables correctly?
Jldupont 01:07, 14 January 2007 (UTC)

[edit] I tried the same

I tried the same: installed the runphp and tried to access to another database (not the mediawiki-db) to display data from "foreign" tables of another database with a usual php-script.

The question is: Is it possible to access other databases and display the results of the queries with php code as php codes are usual used? If this is possible, I would appreciate, if somebody would post some informations about that. I am searching to that topic for several weeks - but I didn't find anything about such a solution.

Thomas, 02 February 2007

[edit] How to use this to run javascript

This way is the perhaps the worst hack in the history of the planet, but it will let you run javascript.

<runphp>
global $unique_id;
$unique_id = mt_rand();
</runphp><div style="display:none;" id="<runphp>echo $GLOBALS['unique_id'];</runphp>">{{{1}}}</div><runphp>echo "<script>var id = ${GLOBALS['unique_id']}; var code = document.getElementById(id).textContent; eval(code)</script>";</runphp>

Call the above Template:Javascript and call it like

{{javascript|<pre>

alert(1);

< /pre>}} [ignore space]

The Pre-tag hack lets you pass things without the horrible wiki markup syntax junk. PHP runs and generates a unique id. The Pre-stuff gets dumped in an invisible Div which is read-from as text (unescaping the Pre's html-escape) and eval'd using javascript. The script tag can be written by writing it directly with a PHP echo. It can probably be improved by making unique_id a counter.


[edit] Runphp on Mac

have anyone ever test runphp extension using mac? i added that extension on my wiki but nothing happen on my wiki page if i added <runphp> tag. on special pages -> version i found that extension on it, so i assumed the extension is installed.

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox