Skip to content

Commit

Permalink
Manual revert 6a19864.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hydriz committed Nov 12, 2012
1 parent 5d0cda7 commit 9b12743
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions SpecialHostStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,17 @@
*/

class SpecialHostStats extends SpecialPage {
protected $cmdwhitelist;

public function __construct() {
parent::__construct( 'HostStats' );
}

public function execute( $par ) {
global $wgHostStatsCommands;
$this->setHeaders();
$this->whitelistedcmds();
$commands = array();
foreach ( $wgHostStatsCommands as $cmd ) {
if ( in_array( $cmd, $this->cmdwhitelist ) ) {
array_push( $cmd, $commands );
} else {
# Reject those unsafe commands and log it to hoststats
wfDebugLog( "hoststats", "Rejected running command '" .
$cmd . "' as it is unsafe, please remove it from " .
"\$wgHostStatsCommands!" );
continue;
}
}
$this->getOutput()->setPageTitle( wfMessage( 'hoststats-title' )->escaped() );
$outpage = wfMessage( 'hoststats-intro' )->escaped();
$outpage .= "\n";
foreach ( $commands as $cmd ) {
foreach ( $wgHostStatsCommands as $cmd ) {
$outpage .= '<h3>' . $cmd . '</h3>';
$outpage .= "\n<pre>\n" . $this->query( $cmd ) . "</pre>";
}
Expand All @@ -43,12 +28,4 @@ protected function query( $query ) {
$output = wfShellExec( $query );
return $output;
}

protected function whitelistedcmds() {
$this->cmdwhitelist = array(
'df',
'whoami',
'hostname',
);
}
}

0 comments on commit 9b12743

Please sign in to comment.