Ejemplo n.º 1
0
 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;
     }
 }
Ejemplo n.º 2
0
 /**
  * Arrays are walked through using the key as a the name.  Arrays
  * of Arrays are emitted as repeated fields consistent with such things
  * as checkboxes.
  *
  * @desc Return data as a post string.
  * @param mixed by reference data to be written.
  * @param string [optional] name of the datum.
  * @access public
  */
 function &asPostString(&$theData, $theName = NULL)
 {
     $thePostString = '';
     $thePrefix = $theName;
     if (is_array($theData)) {
         foreach ($theData as $theKey => $theValue) {
             if ($thePrefix === NULL) {
                 $thePostString .= '&' . jTipsCurl::asPostString($theValue, $theKey);
             } else {
                 $thePostString .= '&' . jTipsCurl::asPostString($theValue, $thePrefix . '[' . $theKey . ']');
             }
         }
     } else {
         $thePostString .= '&' . urlencode((string) $thePrefix) . '=' . urlencode($theData);
     }
     $xxx =& substr($thePostString, 1);
     return $xxx;
 }