예제 #1
0
파일: licence.php 프로젝트: joomux/jTips
 function revalidate($force = false)
 {
     global $database, $jTips, $mosConfig_absolute_path;
     $this_file = $mosConfig_absolute_path . '/administrator/components/com_jtips/licence.php';
     $jTipsUser = new jTipsUser($database);
     $jSeason = new jSeason($database);
     $seasons = array('end_time' => array('type' => 'query', 'query' => ">= '" . gmdate('Y-m-d') . "'"));
     //BUG 127 - Optionally use an unsecure connection
     if ($jTips['SSLValidation'] == 0 or $jTips['SSLValidation'] == '0') {
         $this->host = preg_replace('/https/', 'http', $this->host);
         jTipsLogger::_log('validating license through unsecure connection');
     }
     $params = array('total_users' => $this->getActiveUserCount(), 'total_seasons' => $jSeason->getCount($seasons), 'license_key' => $jTips['ActivationKey'], 'activation_email' => $jTips['ActivationEmail'], 'domain_name' => preg_replace('/(www\\.)|(www)/i', '', $_SERVER['SERVER_NAME']), 'current_version' => getFullVersion());
     $encoded = serialize($params);
     jTipsLogger::_log('Preparing to revalidate license', 'INFO');
     if ($this->hasError() or $this->licence['license_expiry'] <= gmdate('Y-m-d H:i:s', time() - 3600 * 24) or $force) {
         jTipsLogger::_log('connecting to ' . $this->host);
         $curl = new jTipsCurl($this->host);
         $licence_params = array('data' => $params, 'license' => base64_encode(serialize($this->licence)));
         $data['key'] = base64_encode(serialize($licence_params));
         //$fields = $curl->asPostString($licence_params);
         $fields = $curl->asPostString($data);
         //jTipsDebug($fields);
         $curl->setopt(CURLOPT_POST, TRUE);
         $curl->setopt(CURLOPT_POSTFIELDS, $fields);
         $curl->setopt(CURLOPT_CONNECTTIMEOUT, 60);
         jTipsLogger::_log('Sending validation request', 'INFO');
         $result = $curl->exec();
         if ($curl->hasError()) {
             jTipsLogger::_log('curl error validation license: ' . $curl->hasError(), 'ERROR');
             //Return the current license data if there was an error in the connection
             return $curl->hasError();
         }
         jTipsLogger::_log('License validation request result:');
         jTipsLogger::_log($result);
         //jTipsDebug($result);
         //die();
         jTipsLogger::_log('Decoding license response', 'INFO');
         $decoded = $result == '-1' ? -1 : @unserialize(base64_decode($result));
         //jTipsDebug($result);
         //die();
         if ($decoded == -1) {
             jTipsLogger::_log('error in response', 'ERROR');
             return false;
         } else {
             jTipsLogger::_log('all is well with license ', 'INFO');
             $this->licence = $decoded;
             $this->writeLicenceFile();
             //jTipsDebug($this->licence);
             return $this->licence;
         }
     } else {
         jTipsLogger::_log('license still current', 'INFO');
         return $this->licence;
     }
 }
예제 #2
0
파일: version.php 프로젝트: joomux/jTips
function getLatestVersion()
{
    jTipsLogger::_log('Checking for latest version', 'INFO');
    if (!extension_loaded('curl')) {
        jTipsLogger::_log('curl not loaded in php', 'ERROR');
        return 'N/A';
    }
    $release = str_replace('.', '', getFullVersion());
    $curl = new jTipsCurl("http://www.jtips.com.au/update.php?version=10&release={$release}");
    $curl->setopt(CURLOPT_CONNECTTIMEOUT, 10);
    $result = $curl->exec();
    if ($theError = $curl->hasError()) {
        return $theError;
        jTipsLogger::_log($result, 'ERROR');
    }
    $curl->close();
    $response = unserialize(base64_decode($result));
    return !empty($response) ? $response : "N/A";
}