function doStatamicVersionCheck($app)
{
    if (!extension_loaded('mcrypt')) {
        throw new FatalException('You must have the mcrypt PHP extension installed.');
    }
    // default values
    $app->config['latest_version_url'] = '';
    $app->config['latest_version'] = '';
    if (isCurlEnabled()) {
        $cookie = $app->getEncryptedCookie('stat_latest_version');
        if (!$cookie) {
            $license = Config::getLicenseKey();
            $site_url = Config::getSiteURL();
            $parts = parse_url($site_url);
            $domain = isset($parts['host']) ? $parts['host'] : '/';
            $url = "http://outpost.statamic.com/check?v=" . urlencode(STATAMIC_VERSION) . "&l=" . urlencode($license) . "&d=" . urlencode($domain);
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_TIMEOUT, '3');
            $content = trim(curl_exec($ch));
            curl_close($ch);
            if ($content != '') {
                $response = json_decode($content);
                if ($response && $response->status == 'ok') {
                    $app->setEncryptedCookie('stat_latest_version', $response->current_version);
                    $app->setEncryptedCookie('stat_latest_version_url', $response->url);
                    $app->config['latest_version_url'] = $response->current_version;
                    $app->config['latest_version'] = $response->current_version;
                } else {
                    $app->config['latest_version_url'] = '';
                    $app->config['latest_version'] = '';
                }
            }
        } else {
            $app->config['latest_version'] = $cookie;
            $app->config['latest_version_url'] = $app->getEncryptedCookie('stat_latest_version_url');
        }
    }
}
Example #2
0
File: statamic.php Project: nob/joi
 public static function get_license_key()
 {
     Log::warn("Use of Statamic::get_license_key() is deprecated. Use Config::getLicenseKey() instead.", "core", "Statamic");
     return Config::getLicenseKey();
 }