47 lines
1.6 KiB
PHP
47 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
|
|
";
|
|
|
|
// Write the .htaccess file (This is not really ideal, but it works for now. This is because the .htaccess file is changed by cPanel, and it's not going to be kept there anyway.)
|
|
file_put_contents(__DIR__ . '/.htaccess', $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);
|