diff --git a/cron.php b/cron.php index 47a46b3b..8fcbb977 100644 --- a/cron.php +++ b/cron.php @@ -75,6 +75,10 @@ $config_log_retention = intval($row['config_log_retention']); // Set Currency Format $currency_format = numfmt_create($company_locale, NumberFormatter::CURRENCY); +// White label +$config_whitelabel_enabled = intval($row['config_whitelabel_enabled']); +$config_whitelabel_key = $row['config_whitelabel_key']; + $argv = $_SERVER['argv']; // Check cron is enabled @@ -137,6 +141,13 @@ mysqli_query($mysqli, "DELETE FROM logs WHERE log_created_at < CURDATE() - INTER * ############################################################################################################### */ +// Whitelabel - Disable if expired/invalid +if ($config_whitelabel_enabled && !validateWhitelabelKey($config_whitelabel_key)) { + mysqli_query($mysqli, "UPDATE settings SET config_whitelabel_enabled = 0, config_whitelabel_key = '' WHERE company_id = 1"); + mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Settings', notification = 'White-labelling was disabled due to expired/invalid key', notification_action = 'settings_modules.php'"); +} + + // GET NOTIFICATIONS // DOMAINS EXPIRING diff --git a/database_updates.php b/database_updates.php index 257b7c6b..1b581ca2 100644 --- a/database_updates.php +++ b/database_updates.php @@ -2131,10 +2131,17 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.4.5'"); } - // if (CURRENT_DATABASE_VERSION == '1.4.5') { - // // Insert queries here required to update to DB version 1.4.6 + if (CURRENT_DATABASE_VERSION == '1.4.5') { + mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_whitelabel_enabled` INT(11) NOT NULL DEFAULT '0' AFTER `config_phone_mask`"); + mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_whitelabel_key` TEXT NULL DEFAULT NULL AFTER `config_whitelabel_enabled`"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.4.6'"); + } + + // if (CURRENT_DATABASE_VERSION == '1.4.6') { + // // Insert queries here required to update to DB version 1.4.7 // // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.4.6'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.4.7'"); // } } else { diff --git a/database_version.php b/database_version.php index 02ae2a6a..21ed9407 100644 --- a/database_version.php +++ b/database_version.php @@ -5,4 +5,4 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "1.4.5"); +DEFINE("LATEST_DATABASE_VERSION", "1.4.6"); diff --git a/db.sql b/db.sql index 2b4ba70f..f775b60e 100644 --- a/db.sql +++ b/db.sql @@ -1509,6 +1509,8 @@ CREATE TABLE `settings` ( `config_timezone` varchar(200) NOT NULL DEFAULT 'America/New_York', `config_destructive_deletes_enable` tinyint(1) NOT NULL DEFAULT 0, `config_phone_mask` tinyint(1) NOT NULL DEFAULT 1, + `config_whitelabel_enabled` int(11) NOT NULL DEFAULT 0, + `config_whitelabel_key` text DEFAULT NULL, PRIMARY KEY (`company_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/functions.php b/functions.php index 3813981c..a233b393 100644 --- a/functions.php +++ b/functions.php @@ -1327,3 +1327,25 @@ function getDomainExpirationDate($domain) { return null; // Return null if expiration date is not found } + +function validateWhitelabelKey($key) +{ + $public_key = "-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr0k+4ZJudkdGMCFLx5b9 +H/sOozvWphFJsjVIF0vPVx9J0bTdml65UdS+32JagIHfPtEUTohaMnI3IAxxCDzl +655qmtjL7RHHdx9UMIKCmtAZOtd2u6rEyZH7vB7cKA49ysKGIaQSGwTQc8DCgsrK +uxRuX04xq9T7T+zuzROw3Y9WjFy9RwrONqLuG8LqO0j7bk5LKYeLAV7u3E/QiqNx +lEljN2UVJ3FZ/LkXeg8ORkV+IHs/toRIfPs/4VQnjEwk5BU6DX2STOvbeZnTqwP3 +zgjRYR/zGN5l+az6RB3+0mJRdZdv/y2aRkBlwTxx2gOrPbQAco4a/IOmkE3EbHe7 +6wIDAQAP +-----END PUBLIC KEY-----"; + + if (openssl_public_decrypt(base64_decode($key), $decrypted, $public_key)) { + $key_info = json_decode($decrypted, true); + if ($key_info['expires'] > date('Y-m-d H:i:s', strtotime('-7 day'))) { + return $key_info; + } + } + + return false; +} \ No newline at end of file diff --git a/get_settings.php b/get_settings.php index 5aa4e320..46902edd 100644 --- a/get_settings.php +++ b/get_settings.php @@ -130,6 +130,10 @@ $config_telemetry = intval($row['config_telemetry']); // Destructive Deletes $config_destructive_deletes_enable = intval($row['config_destructive_deletes_enable']); +// White label +$config_whitelabel_enabled = intval($row['config_whitelabel_enabled']); +$config_whitelabel_key = $row['config_whitelabel_key']; + // Select Arrays diff --git a/login.php b/login.php index edfeef33..d1d41b21 100644 --- a/login.php +++ b/login.php @@ -378,8 +378,8 @@ if (isset($_POST['login'])) { -
+ Powered by ITFlow'; +// } + ?> +
+ diff --git a/post/setting.php b/post/setting.php index 721a327d..9b562043 100644 --- a/post/setting.php +++ b/post/setting.php @@ -524,9 +524,17 @@ if (isset($_POST['edit_module_settings'])) { $config_module_enable_ticketing = intval($_POST['config_module_enable_ticketing']); $config_module_enable_accounting = intval($_POST['config_module_enable_accounting']); $config_client_portal_enable = intval($_POST['config_client_portal_enable']); + $config_whitelabel_key = $_POST['config_whitelabel_key']; mysqli_query($mysqli,"UPDATE settings SET config_module_enable_itdoc = $config_module_enable_itdoc, config_module_enable_ticketing = $config_module_enable_ticketing, config_module_enable_accounting = $config_module_enable_accounting, config_client_portal_enable = $config_client_portal_enable WHERE company_id = 1"); + // Validate white label key + if (!empty($config_whitelabel_key && validateWhitelabelKey($config_whitelabel_key))) { + mysqli_query($mysqli, "UPDATE settings SET config_whitelabel_enabled = 1, config_whitelabel_key = '$config_whitelabel_key' WHERE company_id = 1"); + } else { + mysqli_query($mysqli, "UPDATE settings SET config_whitelabel_enabled = 0, config_whitelabel_key = '' WHERE company_id = 1"); + } + //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Settings', log_action = 'Modify', log_description = '$session_name modified module settings', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id"); diff --git a/settings_modules.php b/settings_modules.php index a54661ac..fa0a6003 100644 --- a/settings_modules.php +++ b/settings_modules.php @@ -40,6 +40,37 @@ require_once "inc_all_admin.php";White-labelling is active - thank you for your support! :)
+