mirror of https://github.com/itflow-org/itflow
Initial implementation of whitelabelling
This commit is contained in:
parent
0f6ed69008
commit
4458c87463
11
cron.php
11
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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
2
db.sql
2
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 */;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['login'])) {
|
|||
|
||||
<?php
|
||||
if (!empty($config_smtp_host)) { ?>
|
||||
<h6 class="text-center"><a href="login_reset.php">Forgot password?</a></h6>
|
||||
<h5 class="text-center"><a href="login_reset.php">Forgot password?</a></h5>
|
||||
<?php } ?>
|
||||
|
||||
</form>
|
||||
|
|
@ -178,6 +178,12 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['login'])) {
|
|||
</div>
|
||||
<!-- /.login-box -->
|
||||
|
||||
<?php
|
||||
//if (!$config_whitelabel_enabled) {
|
||||
// echo '<small class="text-muted">Powered by ITFlow</small>';
|
||||
//}
|
||||
?>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="../plugins/jquery/jquery.min.js"></script>
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,15 @@
|
|||
<br>
|
||||
<hr>
|
||||
|
||||
<p class="text-center"><?php echo nullable_htmlentities($session_company_name); ?></p>
|
||||
<p class="text-center">
|
||||
<?php
|
||||
echo nullable_htmlentities($session_company_name);
|
||||
// if (!$config_whitelabel_enabled) {
|
||||
// echo '<br><small class="text-muted">Powered by ITFlow</small>';
|
||||
// }
|
||||
?>
|
||||
</p>
|
||||
|
||||
|
||||
<?php require_once "../inc_confirm_modal.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");
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,37 @@ require_once "inc_all_admin.php";
|
|||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" disabled class="custom-control-input" name="config_whitelabel_enabled" <?php if ($config_whitelabel_enabled == 1) { echo "checked"; } ?> value="1" id="customSwitch5">
|
||||
<label class="custom-control-label" for="customSwitch5">White-label <small class="text-secondary">(Hides 'Powered by ITFlow' banner)</small></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>White-label key</label>
|
||||
<textarea class="form-control" name="config_whitelabel_key" rows="2" placeholder="Enter a key to enable white-labelling the client portal"><?php echo nullable_htmlentities($config_whitelabel_key); ?></textarea>
|
||||
</div>
|
||||
|
||||
<?php if ($config_whitelabel_enabled == 1 && validateWhitelabelKey($config_whitelabel_key)) {
|
||||
$key_info = validateWhitelabelKey($config_whitelabel_key);
|
||||
$key_desc = $key_info["description"];
|
||||
$key_org = $key_info["organisation"];
|
||||
$key_expires = $key_info["expires"];
|
||||
?>
|
||||
<div class="form-group">
|
||||
<p>White-labelling is active - thank you for your support! :)</p>
|
||||
<ul>
|
||||
<li>Key: <?php echo $key_desc ?></li>
|
||||
<li>Org: <?php echo $key_org ?></li>
|
||||
<li>Expires: <?php echo $key_expires; if ($key_expires < date('Y-m-d H:i:s')) { echo " (expiring) "; } ?></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<hr>
|
||||
|
||||
<button type="submit" name="edit_module_settings" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Save</button>
|
||||
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Reference in New Issue