50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* Cron job, ran every minute.
|
|
*/
|
|
$now = time();
|
|
|
|
// Log the time of the cron job
|
|
file_put_contents(__DIR__ . '/cron.log', date('Y-m-d H:i:s', $now) . ' - Cron job started' . PHP_EOL, FILE_APPEND);
|
|
|
|
// Include the required files
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
require_once __DIR__ . '/config.php';
|
|
|
|
// Run the full cron task scheduler (includes economic transfer queue worker)
|
|
try {
|
|
require_once __DIR__ . '/cron/Cron.php';
|
|
} catch (\Throwable $e) {
|
|
file_put_contents(
|
|
__DIR__ . '/cron.log',
|
|
date('Y-m-d H:i:s', time()) . ' - Cron scheduler failed: ' . $e->getMessage() . PHP_EOL,
|
|
FILE_APPEND
|
|
);
|
|
}
|
|
|
|
// Set the .htaccess file
|
|
$htaccess = "
|
|
# php -- BEGIN cPanel-generated handler, do not edit
|
|
# Set the “ea-php80” package as the default “PHP” programming language.
|
|
<IfModule mod_rewrite.c>
|
|
RewriteEngine On
|
|
RewriteCond %{REQUEST_FILENAME} !-f
|
|
RewriteCond %{REQUEST_FILENAME} !-d
|
|
RewriteRule ^(.*)$ index.php [QSA,L]
|
|
</IfModule>
|
|
|
|
<IfModule mime_module>
|
|
AddHandler application/x-httpd-ea-php80 .php .php8 .phtml
|
|
</IfModule>
|
|
# php -- END cPanel-generated handler, do not edit
|
|
";
|
|
|
|
// Keep the compatibility rewrite file stable without rewriting it every minute.
|
|
$htaccessPath = __DIR__ . '/.htaccess';
|
|
if (!is_file($htaccessPath) || file_get_contents($htaccessPath) !== $htaccess) {
|
|
file_put_contents($htaccessPath, $htaccess);
|
|
}
|
|
|
|
// Log the time of the cron job
|
|
file_put_contents(__DIR__ . '/cron.log', date('Y-m-d H:i:s', $now) . ' - Cron job executed in ' . (time() - $now) . ' seconds ( ' . (microtime(true) - $now) . 'ms )' . PHP_EOL, FILE_APPEND);
|