$prefix = $focus->get_config_prefix($key); if (in_array($prefix[0], $focus->config_categories)) { if ($prefix[0] == "license") { if ($prefix[1] == "expire_date") { global $timedate; $val = $timedate->swap_formats($val, $timedate->get_date_format(), $timedate->dbDayFormat); } else { if ($prefix[1] == "key") { $val = trim($val); // bug 16860 tyoung - trim whitespace from the start and end of the licence key value } } } $focus->saveSetting($prefix[0], $prefix[1], $val); } } if (isset($_POST['license_key'])) { loadLicense(true); check_now(get_sugarbeat()); } unset($_SESSION['license_seats_needed']); unset($_SESSION['LICENSE_EXPIRES_IN']); unset($_SESSION['VALIDATION_EXPIRES_IN']); unset($_SESSION['HomeOnly']); apiLoadSystemStatus(true); // Lock down access to the application for sidecar modules until // we have a license validation available. if (!authenticateDownloadKey() && !ocLicense()) { $_SESSION['HomeOnly'] = true; } header("Location: index.php?action={$_POST['return_action']}&module={$_POST['return_module']}");
displayAdminError(translate('FATAL_LICENSE_REQUIRED', 'Administration')); } else { if ($_SESSION['LICENSE_EXPIRES_IN'] < 0) { if ($_SESSION['LICENSE_EXPIRES_IN'] < -30) { setSystemState('LICENSE_KEY'); displayAdminError(translate('FATAL_LICENSE_EXPIRED', 'Administration') . " [" . abs($_SESSION['LICENSE_EXPIRES_IN']) . " " . translate('LBL_DAYS', 'Administration') . " ] .<br> " . translate('FATAL_LICENSE_EXPIRED2', 'Administration')); } else { displayAdminError(translate('ERROR_LICENSE_EXPIRED', 'Administration') . abs($_SESSION['LICENSE_EXPIRES_IN']) . translate('ERROR_LICENSE_EXPIRED2', 'Administration')); } } else { if ($_SESSION['LICENSE_EXPIRES_IN'] >= 0) { displayAdminError(translate('WARN_LICENSE_EXPIRED', 'Administration') . $_SESSION['LICENSE_EXPIRES_IN'] . translate('WARN_LICENSE_EXPIRED2', 'Administration')); } } } } elseif (!ocLicense() && strcmp($_SESSION['VALIDATION_EXPIRES_IN'], 'valid') != 0) { if (strcmp($_SESSION['VALIDATION_EXPIRES_IN'], 'REQUIRED') == 0) { setSystemState('LICENSE_KEY'); displayAdminError(translate('FATAL_VALIDATION_REQUIRED', 'Administration')); } else { if ($_SESSION['VALIDATION_EXPIRES_IN'] < 0) { if ($_SESSION['VALIDATION_EXPIRES_IN'] < -30) { setSystemState('LICENSE_KEY'); displayAdminError(translate('FATAL_VALIDATION_EXPIRED', 'Administration') . " [" . abs($_SESSION['VALIDATION_EXPIRES_IN']) . " day(s) ] .<br> " . translate('FATAL_VALIDATION_EXPIRED2', 'Administration')); } else { displayAdminError(translate('ERROR_VALIDATION_EXPIRED', 'Administration') . abs($_SESSION['VALIDATION_EXPIRES_IN']) . translate('ERROR_VALIDATION_EXPIRED2', 'Administration')); } } else { if ($_SESSION['VALIDATION_EXPIRES_IN'] >= 0) { displayAdminError(translate('WARN_VALIDATION_EXPIRED', 'Administration') . $_SESSION['VALIDATION_EXPIRES_IN'] . translate('WARN_VALIDATION_EXPIRED2', 'Administration')); }
function loginLicense() { global $current_user, $license; loadLicense(true); if (isset($_SESSION['EXCEEDS_MAX_USERS']) && $_SESSION['EXCEEDS_MAX_USERS'] == 1 || empty($license->settings['license_key']) || !empty($license->settings['license_last_validation']) && $license->settings['license_last_validation'] == 'failed' && !empty($license->settings['license_last_validation_fail']) && (empty($license->settings['license_last_validation_success']) || $license->settings['license_last_validation_fail'] > $license->settings['license_last_validation_success'])) { if (!is_admin($current_user)) { $GLOBALS['login_error'] = $GLOBALS['app_strings']['ERROR_LICENSE_VALIDATION']; $_SESSION['login_error'] = $GLOBALS['login_error']; } else { if (empty($license->settings['license_key'])) { $_SESSION['VALIDATION_EXPIRES_IN'] = 'REQUIRED'; } else { $_SESSION['COULD_NOT_CONNECT'] = $license->settings['license_last_validation_fail']; } } } if (shouldCheckSugar()) { $last_check_date = get_last_check_date_config_setting(); $current_date_time = time(); $time_period = 3 * 23 * 3600; if ($current_date_time - $last_check_date > $time_period || empty($license->settings['license_last_validation_success'])) { $version = check_now(get_sugarbeat()); unset($_SESSION['license_seats_needed']); unset($_SESSION['LICENSE_EXPIRES_IN']); unset($_SESSION['VALIDATION_EXPIRES_IN']); unset($_SESSION['HomeOnly']); loadLicense(); set_last_check_date_config_setting("{$current_date_time}"); include 'sugar_version.php'; $newVersion = ''; if (!empty($version) && count($version) == 1) { $newVersion = $version[0]['version']; } if (version_compare($newVersion, $sugar_version, '>') && is_admin($current_user)) { //set session variables. $_SESSION['available_version'] = $version[0]['version']; $_SESSION['available_version_description'] = $version[0]['description']; set_last_check_version_config_setting($version[0]['version']); } } } // This section of code is a portion of the code referred // to as Critical Control Software under the End User // License Agreement. Neither the Company nor the Users // may modify any portion of the Critical Control Software. if (!authenticateDownloadKey() && !ocLicense()) { if (is_admin($current_user)) { $_SESSION['HomeOnly'] = true; } else { $_SESSION['login_error'] = $GLOBALS['app_strings']['ERROR_LICENSE_VALIDATION']; $GLOBALS['login_error'] = $GLOBALS['app_strings']['ERROR_LICENSE_VALIDATION']; } } //END REQUIRED CODE DO NOT MODIFY }
if (isset($app_strings[$_REQUEST['loginErrorMessage']])) { echo "<p align='center' class='error' > " . $app_strings[$_REQUEST['loginErrorMessage']] . "</p>"; } } } $query = "SELECT count(id) as total from users WHERE " . User::getLicensedUsersWhere(); // This section of code is a portion of the code referred // to as Critical Control Software under the End User // License Agreement. Neither the Company nor the Users // may modify any portion of the Critical Control Software. if (!isset($_SESSION['LICENSE_EXPIRES_IN'])) { checkSystemLicenseStatus(); } if (!ocLicense() && isset($_SESSION['LICENSE_EXPIRES_IN']) && $_SESSION['LICENSE_EXPIRES_IN'] != 'valid' && $_SESSION['LICENSE_EXPIRES_IN'] < -1) { echo " <p align='center' class='error' >" . $GLOBALS['app_strings']['ERROR_FULLY_EXPIRED'] . "</p>"; } elseif (!ocLicense() && isset($_SESSION['VALIDATION_EXPIRES_IN']) && $_SESSION['VALIDATION_EXPIRES_IN'] != 'valid' && $_SESSION['VALIDATION_EXPIRES_IN'] < -1) { echo "<p align='center' class='error' > " . $GLOBALS['app_strings']['ERROR_LICENSE_EXPIRED'] . "</p>"; } //END REQUIRED CODE DO NOT MODIFY // BEGIN CE-OD License User Limit Enforcement global $sugar_flavor; if (isset($sugar_flavor) && $sugar_flavor != null && ($sugar_flavor == 'CE' || isset($admin->settings['license_enforce_user_limit']) && $admin->settings['license_enforce_user_limit'] == 1)) { global $db; $result = $db->query($query, true, "Error filling in user array: "); $row = $db->fetchByAssoc($result); $admin = Administration::getSettings(); $license_users = $admin->settings['license_users']; $license_seats_needed = $row['total'] - $license_users; if ($license_seats_needed > 0) { $_SESSION['EXCEEDS_MAX_USERS'] = 1; echo "<p align='center' class='error' > " . $GLOBALS['app_strings']['WARN_LICENSE_SEATS_MAXED'] . $GLOBALS['app_strings']['WARN_ONLY_ADMINS'] . "</p>";