avoid out-of-memory serving large logfiles

large logfiles previously resulted in out-of-memory errors, see https://github.com/hestiacp/hestiacp/issues/2736

hestacp PR: https://github.com/hestiacp/hestiacp/pull/2741

and no, removing the php end tag was not an accident, it was intentional. end tags, ideally, should only be used when they're absolutely required, because they can easily introduce bugs like printing a newline after the end tag.
This commit is contained in:
divinity76 2022-07-09 11:16:02 +02:00 committed by GitHub
commit b13b82112a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,11 +25,18 @@ $v_domain = escapeshellarg($_GET['domain']);
if ($_GET['type'] == 'access') $type = 'access';
if ($_GET['type'] == 'error') $type = 'error';
exec (VESTA_CMD."v-list-web-domain-".$type."log $user ".$v_domain." 5000", $output, $return_var);
if ($return_var == 0 ) {
foreach($output as $file) {
echo $file . "\n";
}
$cmd = implode(" ", array(
escapeshellarg(HESTIA_CMD . "v-list-web-domain-" . $type . "log"),
escapeshellarg($user),
escapeshellarg($v_domain),
"5000",
));
passthru($cmd, $return_var);
if ($return_var != 0) {
$errstr = "Internal server error: command returned non-zero: {$return_var}: {$cmd}";
echo $errstr;
throw new Exception($errstr); // make sure it ends up in an errorlog somewhere
}
?>