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 |
Résultat | boolean | command successfull or not |
public static function rfts($strFileName, &$strRet, $intLines = 0, $intBytes = 4096, $booErrorRep = true)
{
if (defined('PSI_LOG') && is_string(PSI_LOG) && strlen(PSI_LOG) > 0 && (substr(PSI_LOG, 0, 1) == "-" || substr(PSI_LOG, 0, 1) == "+")) {
$out = self::_parse_log_file("Reading: " . $strFileName);
if ($out == false) {
if (substr(PSI_LOG, 0, 1) == "-") {
$strRet = '';
return false;
}
} else {
$strRet = $out;
return true;
}
}
$strFile = "";
$intCurLine = 1;
$error = PSI_Error::singleton();
if (file_exists($strFileName)) {
if (is_readable($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;
if (defined('PSI_LOG') && is_string(PSI_LOG) && strlen(PSI_LOG) > 0 && substr(PSI_LOG, 0, 1) != "-" && substr(PSI_LOG, 0, 1) != "+") {
if (strlen($strRet) > 0 && substr($strRet, -1) != "\n") {
error_log("---" . gmdate('r T') . "--- Reading: " . $strFileName . "\n" . $strRet . "\n", 3, PSI_LOG);
} else {
error_log("---" . gmdate('r T') . "--- Reading: " . $strFileName . "\n" . $strRet, 3, PSI_LOG);
}
}
} else {
if ($booErrorRep) {
$error->addError('fopen(' . $strFileName . ')', 'file can not read by phpsysinfo');
}
return false;
}
} else {
if ($booErrorRep) {
$error->addError('fopen(' . $strFileName . ')', 'file permission error');
}
return false;
}
} else {
if ($booErrorRep) {
$error->addError('file_exists(' . $strFileName . ')', 'the file does not exist on your machine');
}
return false;
}
return true;
}
public function __construct() { parent::__construct(); switch (defined('PSI_SENSOR_SPEEDFAN_ACCESS') ? strtolower(PSI_SENSOR_SPEEDFAN_ACCESS) : 'command') { case 'command': if (CommonFunctions::executeProgram("SpeedFanGet.exe", "", $buffer, PSI_DEBUG) && strlen($buffer) > 0) { if (preg_match("/^Temperatures:\\s+(.+)\$/m", $buffer, $out)) { $this->_filecontent["temp"] = $out[1]; } if (preg_match("/^Fans:\\s+(.+)\$/m", $buffer, $out)) { $this->_filecontent["fans"] = $out[1]; } if (preg_match("/^Voltages:\\s+(.+)\$/m", $buffer, $out)) { $this->_filecontent["volt"] = $out[1]; } } break; case 'data': if (CommonFunctions::rfts(APP_ROOT . '/data/speedfan.txt', $buffer) && strlen($buffer) > 0) { if (preg_match("/^Temperatures:\\s+(.+)\$/m", $buffer, $out)) { $this->_filecontent["temp"] = $out[1]; } if (preg_match("/^Fans:\\s+(.+)\$/m", $buffer, $out)) { $this->_filecontent["fans"] = $out[1]; } if (preg_match("/^Voltages:\\s+(.+)\$/m", $buffer, $out)) { $this->_filecontent["volt"] = $out[1]; } } break; default: $this->error->addConfigError('__construct()', 'PSI_SENSOR_SPEEDFAN_ACCESS'); break; } }