Use find and gzip from PATH

This commit is contained in:
Miraty 2023-05-24 18:57:21 +02:00
parent d3803e6a76
commit 396f83fa9f

View file

@ -7,9 +7,6 @@ if (php_sapi_name() !== 'cli')
const LF = "\n";
const FIND = '/usr/bin/find';
const GZIP = '/usr/bin/gzip';
define('ROOT', dirname($_SERVER['SCRIPT_FILENAME']));
if (isset($argv[1]))
@ -70,7 +67,7 @@ function clearnetOrOnion($clearnet_url, $onion_url) {
return (DESTINATION === 'onion') ? $onion_url : $clearnet_url;
}
exec(FIND . ' ' . SITE . "/src -name '*.gmi' -o -name '*.md'", $pages);
exec('find ' . SITE . "/src -name '*.gmi' -o -name '*.md'", $pages);
foreach ($pages as $page) {
@ -205,9 +202,7 @@ foreach ($pages as $page) {
if (extension_loaded('tidy')) {
$tidy = new tidy;
$tidy->parseString(
$pageContent,
[
$tidy->parseString($pageContent, [
'indent' => true,
'keep-tabs' => true,
'wrap' => 0
@ -222,8 +217,11 @@ foreach ($pages as $page) {
file_put_contents($pathParts['dirname'] . '/' . $pathParts['filename'] . '.html', $pageContent);
// Gzip compression
exec(GZIP . ' --keep --fast --force ' . $pathParts['dirname'] . '/' . $pathParts['filename'] . '.html');
exec('gzip --keep --fast --force ' . $pathParts['dirname'] . '/' . $pathParts['filename'] . '.html');
}
ob_start();
}
if ($config['css'] == true)
exec(GZIP . ' --keep --fast --force ' . SITE . '/css/' . CSS_FILENAME);
exec('gzip --keep --fast --force ' . SITE . '/css/' . CSS_FILENAME);