public function execute($target = '', $data = array(), $age = '')
 {
     $mod = cms_utils::get_module('ModuleManager');
     if (!$age) {
         $age = get_site_preference('browser_cache_expiry', 60);
     }
     if ($age) {
         $age = max(1, (int) $age);
     }
     // build a signature
     $this->_signature = md5(serialize(array($target, $data)));
     $fn = $this->_getCacheFile();
     if (!$fn) {
         return;
     }
     // check for the cached file
     $atime = time() - $age * 60;
     $status = '';
     $resutl = '';
     if ($mod->GetPreference('disable_caching', 0) || !file_exists($fn) || filemtime($fn) <= $atime) {
         // execute the request
         $req = new cms_http_request();
         if ($this->_timeout) {
             $req->setTimeout($this->_timeout);
         }
         $req->execute($target, '', 'POST', $data);
         $this->_status = $req->getStatus();
         $this->_result = $req->getResult();
         @unlink($fn);
         if ($this->_status == 200) {
             // create a cache file
             $fh = fopen($fn, 'w');
             fwrite($fh, serialize(array($this->_status, $this->_result)));
             fclose($fh);
         }
     } else {
         // get data from the cache.
         $data = unserialize(file_get_contents($fn));
         $this->_status = $data[0];
         $this->_result = $data[1];
     }
 }
Beispiel #2
0
 if (file_exists(dirname(dirname(__FILE__)) . '/install')) {
     $themeObject->AddNotification(1, 'Core', lang('installdirwarning'));
 }
 // Display a warning if safe mode is enabled
 if (ini_get_boolean('safe_mode') && get_site_preference('disablesafemodewarning', 0) == 0) {
     $themeObject->AddNotification(1, 'Core', lang('warning_safe_mode'));
 }
 // Display a warning sitedownwarning
 $sitedown_message = lang('sitedownwarning', TMP_CACHE_LOCATION . '/SITEDOWN');
 $sitedown_file = TMP_CACHE_LOCATION . '/SITEDOWN';
 if (file_exists($sitedown_file)) {
     $themeObject->AddNotification(1, 'Core', $sitedown_message);
 }
 $timelastchecked = get_site_preference('lastcmsversioncheck', 0);
 if (get_site_preference('checkversion', 1) && time() - $timelastchecked > 24 * 60 * 60 || isset($_GET['forceversioncheck'])) {
     $req = new cms_http_request();
     $req->setTimeout(10);
     $req->execute(CMS_DEFAULT_VERSIONCHECK_URL);
     if ($req->getStatus() == 200) {
         $remote_ver = trim($req->getResult());
         if (strpos($remote_ver, ':') !== FALSE) {
             list($tmp, $remote_ver) = explode(':', $remote_ver, 2);
             $remote_ver = trim($remote_ver);
         }
         if (version_compare(CMS_VERSION, $remote_ver) < 0) {
             set_site_preference('cms_is_uptodate', 0);
             $themeObject->AddNotification(1, 'Core', lang('new_version_available'));
             audit('', 'Core', 'CMSMS version ' . $remote_ver . ' is available');
         } else {
             set_site_preference('cms_is_uptodate', 1);
             audit('', 'Core', 'Tested for newer CMSMS Version. None Available.');
Beispiel #3
0
    $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('error_norepositoryurl'));
    return;
}
if (!isset($params['filename'])) {
    $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('error_nofilename'));
    return;
}
$xmlfile = $params['filename'];
$url = $this->GetPreference('module_repository');
if ($url == '') {
    $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('error_norepositoryurl'));
    return;
}
$url .= '/modulehelp';
$qparms = array('name' => $xmlfile);
$req = new cms_http_request();
$req->execute($url, '', 'POST', $qparms);
$status = $req->getStatus();
$result = $req->getResult();
if ($status != 200 || $result == '') {
    $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('error_request_problem'));
    return;
}
$help = json_decode($result, true);
if ($help[0] == false) {
    $this->_DisplayErrorPage($id, $params, $returnid, $help[1]);
    return;
}
$this->smarty->assign('title', $this->Lang('helptxt'));
$this->smarty->assign('moduletext', $this->Lang('nametext'));
$this->smarty->assign('vertext', $this->Lang('vertext'));
    $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('error_insufficientparams'));
    return;
}
$version = $params['version'];
$url = $this->GetPreference('module_repository');
if ($url == '') {
    $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('error_norepositoryurl'));
    return;
}
$url .= '/moduleabout';
if (!isset($params['filename'])) {
    $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('error_nofilename'));
    return;
}
$xmlfile = $params['filename'];
$req = new cms_http_request();
$req->execute($url, '', 'POST', array('name' => $xmlfile));
$status = $req->getStatus();
$result = $req->getResult();
if ($status != 200 || $result == '') {
    $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('error_request_problem'));
    return;
}
$about = json_decode($result, true);
if ($about[0] == false) {
    $this->_DisplayErrorPage($id, $params, $returnid, $about[1]);
    return;
}
$this->smarty->assign('title', $this->Lang('abouttxt'));
$this->smarty->assign('moduletext', $this->Lang('nametext'));
$this->smarty->assign('vertext', $this->Lang('vertext'));
 public static function get_module_md5($xmlfile)
 {
     $mod = cms_utils::get_module('ModuleManager');
     if (!$xmlfile) {
         return array(FALSE, $mod->Lang('error_nofilename'));
     }
     $url = $mod->GetPreference('module_repository');
     if ($url == '') {
         return array(FALSE, $mod->Lang('error_norepositoryurl'));
     }
     $url .= '/modulemd5sum';
     $req = new cms_http_request();
     $req->execute($url, '', 'POST', array('name' => $xmlfile));
     $status = $req->getStatus();
     $result = $req->getResult();
     if ($status != 200 || $result == '') {
         return array(FALSE, $mod->Lang('error_request_problem'));
     }
     $data = json_decode($result, true);
     return $data;
 }