Remove Cron Key Requirement from cron scripts in /scripts folder and set to only run on the cli

This commit is contained in:
johnnyq
2025-01-23 14:01:15 -05:00
parent c8e3e37d87
commit 70dd3ab5c8
6 changed files with 27 additions and 49 deletions

View File

@@ -3,14 +3,17 @@
// Set working directory to the directory this cron script lives at.
chdir(dirname(__FILE__));
// Ensure we're running from command line
if (php_sapi_name() !== 'cli') {
die("This setup script must be run from the command line.\n");
}
require_once "../config.php";
// Set Timezone
require_once "../inc_set_timezone.php";
require_once "../functions.php";
$sql_companies = mysqli_query($mysqli, "SELECT * FROM companies, settings WHERE companies.company_id = settings.company_id AND companies.company_id = 1");
$row = mysqli_fetch_array($sql_companies);
@@ -28,7 +31,6 @@ $company_currency = sanitizeInput($row['company_currency']);
// Company Settings
$config_enable_cron = intval($row['config_enable_cron']);
$config_cron_key = $row['config_cron_key'];
$config_invoice_overdue_reminders = $row['config_invoice_overdue_reminders'];
$config_invoice_prefix = sanitizeInput($row['config_invoice_prefix']);
$config_invoice_from_email = sanitizeInput($row['config_invoice_from_email']);
@@ -88,18 +90,11 @@ $config_stripe_expense_category = intval($row['config_stripe_expense_category'])
$config_stripe_percentage_fee = floatval($row['config_stripe_percentage_fee']);
$config_stripe_flat_fee = floatval($row['config_stripe_flat_fee']);
$argv = $_SERVER['argv'];
// Check cron is enabled
if ($config_enable_cron == 0) {
exit("Cron: is not enabled -- Quitting..");
}
// Check Cron Key
if ( $argv[1] !== $config_cron_key ) {
exit("Cron Key invalid -- Quitting..");
}
/*
* ###############################################################################################################
* STARTUP ACTIONS