Select Git revision
plugins_shellcmd_request.class.php
plugins_shellcmd_request.class.php 3.12 KiB
<?php
/**
* GENERAL CLASS TO FETCH DATA FROM A SHELL COMMAND
* FOR THE WEB UI
*
* Used in ../plugins/shellcmd/getdata.php
*
*/
require_once('plugins.class.php');
class req_shellcmd {
protected $_sPlugin=false;
protected $_oPlugin=false;
protected $_aReturn=false;
protected $_aPluginConfig=[];
protected $_aResult=[];
protected $_debug=false;
/**
* plugins class instance
* @var object
*/
protected $CI_plugins=false;
// ---------------------------------------------------------------
// CONSTRUCTOR
// ---------------------------------------------------------------
/**
* constructor
* @return bool
*/
public function __construct(){
return $this->detectPlugin();
}
// ---------------------------------------------------------------
// PRIVATE METHODS
// ---------------------------------------------------------------
/**
* helper execute a given command and return array with executed
* command, returncode, output
* @return
*/
protected function _execCommand($sCmd){
exec("$sCmd", $aOut, $iResult);
return [
'command'=>$sCmd,
'exitcode'=>$iResult,
'time'=>date("H:i:s"),
'output'=>$aOut,
];
}
/**
* initialize the shellcmd plugin
* @returm boolean
*/
protected function _loadPlugin(){
$this->CI_plugins=new ciplugins();
$this->CI_plugins->setPlugin($this->_sPlugin, 'shellcmd');
$sPluginclass=$this->CI_plugins->getPluginClassname();
$this->_oPlugin=new $sPluginclass();