Exemple #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;
     }
 }
Exemple #2
0
global $jTips, $database, $jLang, $mosConfig_absolute_path;
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jseason.class.php';
$jSeason = new jSeason($database);
//can add in an ordering field here in the params
$direction = jTipsGetParam($_REQUEST, 'filter_order_Dir', 'asc');
if (empty($direction)) {
    $direction = 'asc';
}
$orderby = jTipsGetParam($_REQUEST, 'filter_order', 'name');
if (empty($orderby)) {
    $orderby = 'name';
}
$parameters = array('order' => array('type' => 'order', 'direction' => $direction, 'by' => $orderby));
$limit = jTipsGetParam($_REQUEST, 'limit', 25);
$limitstart = jTipsGetParam($_REQUEST, 'limitstart', 0);
$pageNav = new mosPageNav($jSeason->getCount(), $limitstart, $limit);
$jSeasons = forceArray($jSeason->loadByParams($parameters, $limit, $limitstart));
$formData = array('title' => $jLang['_ADMIN_SEASON_TITLE'], 'editTask' => 'edit', 'module' => 'Seasons', 'icon' => 'seasons');
$currentDir = jTipsGetParam($_REQUEST, 'filter_order_Dir', 'asc');
if ($currentDir == 'asc') {
    $dir = 'desc';
} else {
    $dir = 'asc';
}
//The header row
$header = array('', "<a href='javascript:tableOrdering(\"name\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_SEASON_NAME'] . "</a>", "<a href='javascript:tableOrdering(\"start_time\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_SEASON_START'] . "</a>", "<a href='javascript:tableOrdering(\"end_time\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_SEASON_END'] . "</a>");
//The row data for each for
$data = array();
$i = 0;
foreach ($jSeasons as $jSeason) {
    $data[$jSeason->id] = array(makeListLink($jSeason->name, $i++), $jSeason->start_time, $jSeason->end_time);