PHP Class CommonFunctions, phpsysinfo

显示文件 Open project: phpsysinfo/phpsysinfo Class Usage Examples

Public Methods

Method Description
checkForExtensions ( array $arrExt = [] ) : void Check for needed php extensions
executeProgram ( string $strProgramname, string $strArgs, &$strBuffer, boolean $booErrorRep = true ) : boolean Execute a system program. return a trim()'d result.
fileexists ( string $strFileName ) : boolean file exists
gdc ( string $strPath, boolean $booErrorRep = true ) : array reads a directory and return the name of the files and directorys in it
getPlugins ( ) : array get all configured plugins from phpsysinfo.ini (file must be included and processed before calling this function)
getWMI ( $wmi, string $strClass, array $strValue = [] ) : array function for getting a list of values in the specified context optionally filter this list, based on the list from third parameter
rfts ( string $strFileName, &$strRet, integer $intLines, integer $intBytes = 4096, boolean $booErrorRep = true ) : boolean read a file and return the content as a string

Private Methods

Method Description
_findProgram ( string $strProgram ) : string Find a system program, do also path checking when not running on WINNT on WINNT we simply return the name with the exe extension to the program name
_parse_log_file ( $string )
_timeoutfgets ( array $pipes, &$out, &$err, integer $timeout = 30 ) : void get the content of stdout/stderr with the option to set a timeout for reading

Method Details

checkForExtensions() public static method

We need that extensions for almost everything This function will return a hard coded XML string (with headers) if the SimpleXML extension isn't loaded. Then it will terminate the script. See bug #1787137
public static checkForExtensions ( array $arrExt = [] ) : void
$arrExt array additional extensions for which a check should run
return void

executeProgram() public static method

does very crude pipe checking. you need ' | ' for it to work ie $program = CommonFunctions::executeProgram('netstat', '-anp | grep LIST'); NOT $program = CommonFunctions::executeProgram('netstat', '-anp|grep LIST');
public static executeProgram ( string $strProgramname, string $strArgs, &$strBuffer, boolean $booErrorRep = true ) : boolean
$strProgramname string name of the program
$strArgs string arguments to the program
$booErrorRep boolean en- or disables the reporting of errors which should be logged
return boolean command successfull or not

fileexists() public static method

file exists
public static fileexists ( string $strFileName ) : boolean
$strFileName string name of the file which should be check
return boolean command successfull or not

gdc() public static method

reads a directory and return the name of the files and directorys in it
public static gdc ( string $strPath, boolean $booErrorRep = true ) : array
$strPath string path of the directory which should be read
$booErrorRep boolean en- or disables the reporting of errors which should be logged
return array content of the directory excluding . and ..

getPlugins() public static method

get all configured plugins from phpsysinfo.ini (file must be included and processed before calling this function)
public static getPlugins ( ) : array
return array

getWMI() public static method

function for getting a list of values in the specified context optionally filter this list, based on the list from third parameter
public static getWMI ( $wmi, string $strClass, array $strValue = [] ) : array
$wmi holds the COM object that we pull the WMI data from
$strClass string name of the class where the values are stored
$strValue array filter out only needed values, if not set all values of the class are returned
return array content of the class stored in an array

rfts() public static method

read a file and return the content as a string
public static rfts ( string $strFileName, &$strRet, integer $intLines, integer $intBytes = 4096, boolean $booErrorRep = true ) : boolean
$strFileName string name of the file which should be read
$intLines integer control how many lines should be read
$intBytes integer control how many bytes of each line should be read
$booErrorRep boolean en- or disables the reporting of errors which should be logged
return boolean command successfull or not