addError('find_program(' . $strProgramname . ')', 'program not found on the machine'); } return false; } // see if we've gotten a |, if we have we need to do patch checking on the cmd if ($strArgs) { $arrArgs = split(' ', $strArgs); for ($i = 0;$i < count($arrArgs);$i++) { if ($arrArgs[$i] == '|') { $strCmd = $arrArgs[$i+1]; $strNewcmd = find_program($strCmd); $strArgs = ereg_replace("\| " . $strCmd, "| " . $strNewcmd, $strArgs); } } } // no proc_open() below php 4.3 $descriptorspec = array(0 => array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will write to 2 => array("pipe", "w") // stderr is a pipe that the child will write to ); $process = proc_open($strProgram . " " . $strArgs, $descriptorspec, $pipes); if (is_resource($process)) { while (!feof($pipes[1])) { $strBuffer.= fgets($pipes[1], 1024); } fclose($pipes[1]); while (!feof($pipes[2])) { $strError.= fgets($pipes[2], 1024); } fclose($pipes[2]); } $return_value = proc_close($process); $strError = trim($strError); $strBuffer = trim($strBuffer); //if( ! empty( $strError ) || $return_value <> 0 ) { if (!empty($strError)) { if ($booErrorRep) { $error->addError($strProgram, $strError . "\nReturn value: " . $return_value); } return false; } return true; } // Check if a string exist in the global $hide_mounts. // Return true if this is the case. function hide_mount($strMount) { global $hide_mounts; if (isset($hide_mounts) && is_array($hide_mounts) && in_array($strMount, $hide_mounts)) { return true; } else { return false; } } // Check if a string exist in the global $hide_fstypes. // Return true if this is the case. function hide_fstype($strFSType) { global $hide_fstypes; if (isset($hide_fstypes) && is_array($hide_fstypes) && in_array($strFSType, $hide_fstypes)) { return true; } else { return false; } } // find duplicate entrys and count them, show this value befor the duplicated name function finddups($arrInput) { $arrResult = array(); if (is_array($arrInput)) { $arrBuffer = array_count_values($arrInput); foreach($arrBuffer as $strKey => $intValue) { if ($intValue > 1) { $arrResult[] = "(" . $intValue . "x) " . $strKey; } else { $arrResult[] = $strKey; } } } return $arrResult; } function rfts($strFileName, &$strRet, $intLines = 0, $intBytes = 4096, $booErrorRep = true) { $error = Error::singleton(); $strFile = ""; $intCurLine = 1; if (file_exists($strFileName)) { if ($fd = fopen($strFileName, 'r')) { while (!feof($fd)) { $strFile.= fgets($fd, $intBytes); if ($intLines <= $intCurLine && $intLines != 0) { break; } else { $intCurLine++; } } fclose($fd); $strRet = $strFile; } else { if ($booErrorRep) { $error->addError('fopen(' . $strFileName . ')', 'file can not read by phpsysinfo'); } return false; } } else { if ($booErrorRep) { $error->addError('file_exists(' . $strFileName . ')', 'the file does not exist on your machine'); } return false; } return true; } function gdc($strPath, $booErrorRep = true) { $error = Error::singleton(); $arrDirectoryContent = array(); if (is_dir($strPath)) { if ($handle = opendir($strPath)) { while (($strFile = readdir($handle)) !== false) { if ($strFile != "." && $strFile != ".." && $strFile != "CVS") { $arrDirectoryContent[] = $strFile; } } closedir($handle); } else { if ($booErrorRep) { $error->addError('opendir(' . $strPath . ')', 'directory can not be read by phpsysinfo'); } } } else { if ($booErrorRep) { $error->addError('is_dir(' . $strPath . ')', 'directory does not exist on your machine'); } } return $arrDirectoryContent; } function __autoload($class_name) { $dirs = array('/plugins/' . $class_name . '/', '/includes/'); foreach($dirs as $dir) { if (file_exists(APP_ROOT . $dir . 'class.' . $class_name . '.inc.php')) { require_once (APP_ROOT . $dir . 'class.' . $class_name . '.inc.php'); return; } } } /** * Check for the SimpleXML fuction. * * We need that extension for almost everything, * even our error class needs this to output the errors. * Because of that this function willreturn a hard coded * XML string (with headers) if the SimpleXML extension isn't loaded. * Then it will terminate the script. * See bug #1787137 * * @access public * */ function checkForExtensions() { $extensions = array('simplexml', 'pcre', 'xml'); $text = ""; $error = false; $text.= "\n"; $text.= "\n"; $text.= " \n"; foreach($extensions as $extension) { if (!extension_loaded($extension)) { $text.= " checkForExtensions\n"; $text.= " phpSysInfo requires the " . $extension . " extension to php in order to work properly.\n"; $error = true; } } $text.= " \n"; $text.= ""; if ($error) { header("Content-Type: text/xml\n\n"); echo $text; die(); } } function uptime( $intTimestamp ) { $strUptime = ''; $intMin = $intTimestamp / 60; $intHours = $intMin / 60; $intDays = floor( $intHours / 24 ); $intHours = floor( $intHours - ( $intDays * 24 ) ); $intMin = floor( $intMin - ( $intDays * 60 * 24 ) - ( $intHours * 60 ) ); if( $intDays != 0 ) { $strUptime .= $intDays. " " . 'days' . " "; } if( $intHours != 0 ) { $strUptime .= $intHours . " " . 'hours' . " "; } $strUptime .= $intMin . " " . 'minutes'; return $strUptime; } // A helper function, when passed a number representing KB, // and optionally the number of decimal places required, // it returns a formated number string, with unit identifier. function format_bytesize ($intKbytes, $intDecplaces = 2) { global $text; $strSpacer = ' '; if( $intKbytes > 1048576 ) { $strResult = sprintf( '%.' . $intDecplaces . 'f', $intKbytes / 1048576 ); $strResult .= $strSpacer . 'GB'; } elseif( $intKbytes > 1024 ) { $strResult = sprintf( '%.' . $intDecplaces . 'f', $intKbytes / 1024); $strResult .= $strSpacer . 'MB'; } else { $strResult = sprintf( '%.' . $intDecplaces . 'f', $intKbytes ); $strResult .= $strSpacer . 'KB'; } return $strResult; } function format_speed( $intHz ) { $strResult = ""; if( $intHz < 1000 ) { $strResult = $intHz . " Mhz"; } else { $strResult = round( $intHz / 1000, 2 ) . " GHz"; } return $strResult; } ?>