SpecialManPage/code/SpecialManPage.main.php

includable( TRUE ); } function execute( $par ) { global $wgUser;

$this->setHeaders; $this->GetArgs($par); if ($wgUser->isAllowed('editinterface')) { $this->doAdmin; } else { $this->doUser; } }  public function doAdmin { global $wgOut; /*	PURPOSE: do stuff that only admins are allowed to do For now, admins have no special powers, so just call doUser. $this->doUser; // display menu } /*	PURPOSE: do only stuff that regular users are allowed to do  */ public function doUser { global $wgOut; $page = nzArr($this->args,'page'); $sect = nzArr($this->args,'section');

if (is_null($page)) { $this->ShowHelp; } else {

$carg = $page; if (!is_null($sect)) { $carg = $sect.' '.$carg; }

$txtCmd = 'man --html=cat '.$carg; exec($txtCmd,$arCmdOut,$intCmdStat); $intLines = count($arCmdOut); $wgOut->AddHTML(' '); $wgOut->AddHTML('Page: '.$page.' | '); $wgOut->AddHTML('Status: '.$intCmdStat.'| '); $wgOut->AddHTML('Lines: '.$intLines.' | '); $wgOut->AddHTML('Command: '.$txtCmd.' '); foreach($arCmdOut as $txtLine) { $txtLine = str_replace(' ',NULL,$txtLine); $txtLine = str_replace(' ',NULL,$txtLine); $txtLine = str_replace(' ',NULL,$txtLine); $txtLine = str_replace(' ',NULL,$txtLine); $wgOut->AddHTML($txtLine."\n"); }	} }  public function ShowHelp { global $wgOut;

$out = 'Format: '.$this->BaseURL.'/page:man-page-name'; $wgOut->AddHtml($out); } } function nzArr($iArr=NULL,$iKey,$iDefault=NULL) { if (is_null($iArr)) { return $iDefault; } else { if (array_key_exists($iKey,$iArr)) { return $iArr[$iKey]; } else { return $iDefault; }   } }