Enabling PHP tags in MediaWiki

For internal Wiki’s for personal or small business use, it’s very useful to enable raw php. This of course, is a security nightmare so make sure you set it so that only people who have accounts can edit pages.

To prevent the creation of new accounts put the following into LocalSettings.php

$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['edit'] = false;
$wgShowIPinHeader = false;

Then add this simple PHP tag parser to includes/Setup.php

function ParsePHPTag($Content)
 global $wgOut;
 $Result = ob_get_contents();

That tells Mediawiki to pass the <php> tag’s contents to the function ParsePHPTag which will execute the code.

I use it for advanced page building as well as simple hacks such as getting around some of the other filters with code like

<php>echo "<iframe src='somepage.php' />"; </php>

If you want your privacy, you can disable anonymous page views with the following inside of LocalSettings.php

$wgGroupPermissions['*']['read'] = false;
$wgWhitelistRead = array ("Special:Userlogin");

That disables anonymous viewing of all pages except the login page.

And finally, if for some reason you need TeX support for math symbols or neat graphs, you can enable it with a rather complicated process.

  1. Make sure you have LaTeX, dvips, and ImageMagick installed on the server. You also need machine with GNU Make and Ocaml
  2. Run make in the /math directory of MediaWiki on the system with Ocaml. This will build texvc. If you can’t get access to a machine with a build process, you can try this one which I built on dreamhost so it should work there. Drop it into your MediaWiki’s /math directory
  3. set $wgUseTeX to true in your LocalSettings.php

This should enable <math> tags inside of your MediaWiki, allowing you to create stuff like
ax^2+bx+c=0 \Rightarrow x = \frac{-b \pm \sqrt{b^2 -4ac}}{2a}

209 Responses to “Enabling PHP tags in MediaWiki”

  1. 高さが調整できるそばがら枕 まくら 枕 日本製 国産 そばがら そば殻 蕎麦 Says:

    高さが調整できるそばがら枕 まくら 枕 日本製 国産 そばがら そば殻 蕎…


  2. alain mikli アランミクリAL1126 カラーG049 al1126_g049【楽ギフ_包装】 メンズ メガネ サングラス Says:

    alain mikli アランミクリAL1126 カラーG049 al1126_g049【楽ギフ_包装】 メンズ メガネ サングラ…

    私はこれが好き状況は}読み取りと受信 情報。 。「高期待がすべての鍵…

  3. 【14時までのご注文は即日発送】【レイバン国内正規品販売認定店】RX7046F 5364 Says:



  4. ブレーキパッド D6100 純正同等 社外品 左右セット ミラ ムーヴ eKワゴン タント Says:

    ブレーキパッド D6100 純正同等 社外品 左右セット ミラ ムーヴ eKワゴン タン…


  5. 【カレラ サングラス】CARRERA CHAMPION DL5JJ【あす楽対応】【到着後レビューで送料無 Says:

    【カレラ サングラス】CARRERA CHAMPION DL5JJ【あす楽対応】【到着後レビューで送料…


  6. facts about minnesota state fair Says:

    Fat played the classical music his mother
    cultivated love for in Carnegie Hall.

  7. best binocular size for deer hunting Says:

    The best binocular size for deer hunting head has dioptric modification,
    fantastic for accommodating various eye strength distinctions.

  8. dietas para bajar de peso en un mes 15 kilos,dietas para bajar de peso rapidamente en 7 dias,dietas para bajar de peso en 3 dias,dietas para bajar de pesos rapido,dietas para bajar de peso en una semana gratis,dietas para bajar de peso rapido en una seman Says:

    La efectividad del suplemento queda patente cuando conocemos que en Estados Unidos llegaron a quedarse sin stock debido a la inmensa demanda que había.

  9. Leslie Says:

    Healthy binocular reviews cnet – Leslie, vision produces vital visual affective abilities which belong
    to typical human vision: binocular depth perception and stereopsis.

Leave a Reply