Exemplo n.º 1
0
function check_now($send_usage_info = true, $get_request_data = false, $response_data = false, $from_install = false)
{
    global $sugar_config, $timedate;
    global $db, $license;
    // 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 (ocLicense()) {
        return array();
    }
    // END REQUIRED CODE
    $return_array = array();
    if (!$from_install && empty($license)) {
        loadLicense(true);
    }
    if (!$response_data) {
        $systemInfo = SugarSystemInfo::getInstance();
        SugarAutoLoader::requireWithCustom('include/SugarHeartbeat/SugarHeartbeatClient.php', true);
        $sclientClass = SugarAutoLoader::customClass('SugarHeartbeatClient');
        $sclient = new $sclientClass();
        if ($from_install) {
            $info = $systemInfo->getBaseInfo();
        } else {
            $info = $systemInfo->getInfo();
        }
        // 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 (!empty($license->settings['license_key'])) {
            $key = $license->settings['license_key'];
        } else {
            //END REQUIRED CODE
            $key = '4829482749329';
        }
        $encoded = sugarEncode($key, serialize($info));
        if ($get_request_data) {
            $request_data = array('key' => $key, 'data' => $encoded);
            return serialize($request_data);
        }
        $encodedResult = $sclient->sugarHome($key, $info);
    } else {
        $encodedResult = $response_data['data'];
        $key = $response_data['key'];
    }
    if ($response_data || !$sclient->getError()) {
        $serializedResultData = sugarDecode($key, $encodedResult);
        $resultData = unserialize($serializedResultData);
        if ($response_data && empty($resultData)) {
            $resultData = array();
            $resultData['validation'] = 'invalid validation key';
        }
    } else {
        $resultData = array();
        $resultData['versions'] = array();
    }
    if (!isset($resultData['validation'])) {
        $resultData['validation'] = 'invalid';
    }
    if ($response_data || !$sclient->getError()) {
        // 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.
        checkDownloadKey($resultData['validation']);
        //END REQUIRED CODE
        if (!empty($resultData['msg'])) {
            if (!empty($resultData['msg']['admin'])) {
                $license->saveSetting('license', 'msg_admin', base64_encode($resultData['msg']['admin']));
            } else {
                $license->saveSetting('license', 'msg_admin', '');
            }
            if (!empty($resultData['msg']['all'])) {
                $license->saveSetting('license', 'msg_all', base64_encode($resultData['msg']['all']));
            } else {
                $license->saveSetting('license', 'msg_all', '');
            }
        } else {
            $license->saveSetting('license', 'msg_admin', '');
            $license->saveSetting('license', 'msg_all', '');
        }
        $license->saveSetting('license', 'last_validation', 'success');
        unset($_SESSION['COULD_NOT_CONNECT']);
    } else {
        $resultData = array();
        $resultData['versions'] = array();
        $license->saveSetting('license', 'last_connection_fail', TimeDate::getInstance()->nowDb());
        $license->saveSetting('license', 'last_validation', 'no_connection');
        if (empty($license->settings['license_last_validation_success']) && empty($license->settings['license_last_validation_fail']) && empty($license->settings['license_vk_end_date'])) {
            $license->saveSetting('license', 'vk_end_date', TimeDate::getInstance()->nowDb());
            $license->saveSetting('license', 'validation_key', base64_encode(serialize(array('verified' => false))));
        }
        $_SESSION['COULD_NOT_CONNECT'] = TimeDate::getInstance()->nowDb();
    }
    if (!empty($resultData['versions'])) {
        $license->saveSetting('license', 'latest_versions', base64_encode(serialize($resultData['versions'])));
    } else {
        $resultData['versions'] = array();
        $license->saveSetting('license', 'latest_versions', '');
    }
    include 'sugar_version.php';
    if (sizeof($resultData) == 1 && !empty($resultData['versions'][0]['version']) && compareVersions($sugar_version, $resultData['versions'][0]['version'])) {
        $resultData['versions'][0]['version'] = $sugar_version;
        $resultData['versions'][0]['description'] = "You have the latest version.";
    }
    return $resultData['versions'];
}
Exemplo n.º 2
0
 * All Rights Reserved.
 * Contributor(s): ______________________________________..
 ********************************************************************************/
global $timedate;
global $mod_strings;
global $app_list_strings;
global $app_strings;
global $current_user;
if (!is_admin($current_user)) {
    sugar_die("Unauthorized access to administration.");
}
if (isset($GLOBALS['sugar_config']['hide_admin_licensing']) && $GLOBALS['sugar_config']['hide_admin_licensing']) {
    sugar_die(translate('LBL_LICENSE_UNAUTHORIZED_ACCESS', 'Administration'));
}
if (isset($_REQUEST['validate'])) {
    checkDownloadKey();
}
$focus = Administration::getSettings();
if (!empty($_FILES['VKFile'])) {
    $response_data = array();
    $response_data['key'] = $focus->settings['license_key'];
    $response_data['data'] = file_get_contents($_FILES['VKFile']['tmp_name']);
    check_now(false, true, $response_data);
    $focus->retrieveSettings(false, true);
}
if (!empty($_REQUEST['exportKey'])) {
    $content = check_now(get_sugarbeat(), true);
    header("Content-Disposition: attachment; filename=sugarkey.lic");
    header("Content-Type: text/plain; charset={$app_strings['LBL_CHARSET']}");
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . TimeDate::httpTime());