public function setPortPermissions() { $shell = new PHPsh(); ob_clean(); //Clean (erase) the output buffer (does not destroy the output buffer) ob_start(); //Turn on output buffering $shell->execCommand("sh /var/www/shell_file", $OutputEscapeFlag); $value = ob_get_contents(); //Return the contents of the output buffer ob_end_clean(); //Clean (erase) the output buffer and turn off output buffering echo $value; }
public function execPerlON() { $port = $this->getPortNumber("fcall"); $shell = new PHPsh(); ob_clean(); //Clean (erase) the output buffer (does not destroy the output buffer) ob_start(); //Turn on output buffering $shell->execCommand("./z-waver.pl '{$port}' switch 3 on", $OutputEscapeFlag); $value = ob_get_contents(); //Return the contents of the output buffer ob_end_clean(); //Clean (erase) the output buffer and turn off output buffering $status = "ON"; echo json_encode(array("output" => $value, "status" => $status)); }
/* Oh, how I loathe 'magic' !! */ /* P.S. this request to disable the magic ** doesn't seem to work very well... ** code above uses stripslashes if its still on */ set_magic_quotes_runtime(0); ini_set('magic_quotes_gpc', 0); /* Important security check!! */ $allowAccess = FALSE; if (array_key_exists('REMOTE_ADDR', $_SERVER)) { foreach ($PHPshConfig['allowedIPs'] as $ip) { if ($ip == $_SERVER['REMOTE_ADDR']) { $allowAccess = TRUE; } } } $shell = new PHPsh(); $CurDir = $shell->currentDir(); $Command = NULL; $OutputEscapeFlag = TRUE; $MySess =& $shell->getSession(); if (array_key_exists($PHPshConfig['sesskeys']['escape'], $MySess)) { $OutputEscapeFlag = $MySess[$PHPshConfig['sesskeys']['escape']]; } /* Take care of getfile requests right away, using the escape flag from session */ if ($allowAccess) { if (is_array($_GET)) { if (array_key_exists('getfile', $_GET)) { $shell->showFile($_GET['getfile'], $OutputEscapeFlag); exit(1); } }