diff --git a/admin_debug.php b/admin_debug.php index 5309b25e..8d15d408 100644 --- a/admin_debug.php +++ b/admin_debug.php @@ -9,10 +9,10 @@ require_once "config.php"; $checks = []; // Execute the git command to get the latest commit hash -$commitHash = exec('git log -1 --format=%H'); +$commitHash = shell_exec('git log -1 --format=%H'); // Get branch info -$gitBranch = exec('git rev-parse --abbrev-ref HEAD'); +$gitBranch = shell_exec('git rev-parse --abbrev-ref HEAD'); // Section: System Information $systemInfo = []; diff --git a/scripts/cron.php b/scripts/cron.php index d87a0b9b..d88c2950 100644 --- a/scripts/cron.php +++ b/scripts/cron.php @@ -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 diff --git a/scripts/cron_certificate_refresher.php b/scripts/cron_certificate_refresher.php index 76fd03a9..52fba4da 100644 --- a/scripts/cron_certificate_refresher.php +++ b/scripts/cron_certificate_refresher.php @@ -3,11 +3,15 @@ // 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"; @@ -17,20 +21,12 @@ $row = mysqli_fetch_array($sql_settings); // Company Settings $config_enable_cron = intval($row['config_enable_cron']); -$config_cron_key = $row['config_cron_key']; - -$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.."); -} - /* * ############################################################################################################### * UPDATE CERTIFICATE EXPIRY DATE diff --git a/scripts/cron_domain_refresher.php b/scripts/cron_domain_refresher.php index 441265eb..048dea54 100644 --- a/scripts/cron_domain_refresher.php +++ b/scripts/cron_domain_refresher.php @@ -3,34 +3,29 @@ // 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_settings = mysqli_query($mysqli, "SELECT * FROM settings WHERE settings.company_id = 1"); $row = mysqli_fetch_array($sql_settings); // Company Settings $config_enable_cron = intval($row['config_enable_cron']); -$config_cron_key = $row['config_cron_key']; - -$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.."); -} - /* * ############################################################################################################### * REFRESH DATA diff --git a/scripts/cron_mail_queue.php b/scripts/cron_mail_queue.php index efc9fbf0..f5f0d9a5 100644 --- a/scripts/cron_mail_queue.php +++ b/scripts/cron_mail_queue.php @@ -3,11 +3,14 @@ // Set working directory to the directory this cron script lives at. chdir(dirname(__FILE__)); -require_once "../config.php"; +// 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_settings = mysqli_query($mysqli, "SELECT * FROM settings WHERE company_id = 1"); @@ -16,27 +19,18 @@ $row = mysqli_fetch_array($sql_settings); // Company Settings $config_enable_cron = intval($row['config_enable_cron']); -$config_cron_key = $row['config_cron_key']; $config_smtp_host = $row['config_smtp_host']; $config_smtp_username = $row['config_smtp_username']; $config_smtp_password = $row['config_smtp_password']; $config_smtp_port = intval($row['config_smtp_port']); $config_smtp_encryption = $row['config_smtp_encryption']; -$argv = $_SERVER['argv']; - // Check cron is enabled if ($config_enable_cron == 0) { error_log("Mail queue error - Cron is not enabled"); exit("Cron: is not enabled -- Quitting.."); } -// Check Cron Key -if ($argv[1] !== $config_cron_key) { - error_log("Mail queue error - Invalid cron key supplied"); - exit("Cron Key invalid -- Quitting.."); -} - // Get system temp directory $temp_dir = sys_get_temp_dir(); diff --git a/scripts/cron_ticket_email_parser.php b/scripts/cron_ticket_email_parser.php index 80008d75..2c534f7a 100644 --- a/scripts/cron_ticket_email_parser.php +++ b/scripts/cron_ticket_email_parser.php @@ -10,6 +10,11 @@ $script_start_time = microtime(true); // unComment when Debugging Execution time // 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"); +} + // Get ITFlow config & helper functions require_once "../config.php"; @@ -35,13 +40,6 @@ if ($config_ticket_email_parse == 0) { exit("Email Parser: Feature is not enabled - check Settings > Ticketing > Email-to-ticket parsing. See https://docs.itflow.org/ticket_email_parse -- Quitting.."); } -$argv = $_SERVER['argv']; - -// Check Cron Key -if ($argv[1] !== $config_cron_key) { - exit("Cron Key invalid -- Quitting.."); -} - // Get system temp directory $temp_dir = sys_get_temp_dir();