Exemple #1
0
 /**
  * Parse an INI file and return an associative array. Since PHP versions before 5.1 are
  * bitches with regards to INI parsing, I use a PHP-only solution to overcome this
  * obstacle.
  *
  * @param string $file The file to process
  * @param bool $process_sections True to also process INI sections
  * @return array An associative array of sections, keys and values
  */
 function parse_ini_file($file, $process_sections)
 {
     if (version_compare(PHP_VERSION, '5.1.0', '>=')) {
         if (function_exists('parse_ini_file')) {
             return parse_ini_file($file, $process_sections);
         } else {
             return JoomlapackHelperUtils::_parse_ini_file($file, $process_sections);
         }
     } else {
         return JoomlapackHelperUtils::_parse_ini_file($file, $process_sections);
     }
 }
 /**
  * Gets an object with the latest version information, taken from the update.ini data
  * @return JObject|bool An object holding the data, or false on failure 
  */
 function _getLatestVersion($force = false)
 {
     jpimport('helpers.utils', true);
     JoomlapackHelperUtils::getJoomlaPackVersion();
     if (substr(_JP_VERSION, 0, 3) == 'svn') {
         $this->_update_url = $this->_update_svn;
     } else {
         $this->_update_url = $this->_update_stable;
     }
     // Make sure we ask the server at most every 24 hrs (unless $force is true)
     $inidata = false;
     jimport('joomla.utilities.date');
     $curdate = new JDate();
     $lastdate = $this->_lastUpdateCheck();
     $difference = ($curdate->toUnix(false) - $lastdate->toUnix(false)) / 3600;
     if ($difference < 24 && JoomlapackCUBETables::CountVar('updateini') >= 1 && !$force) {
         $inidata = $this->_getUpdateINIcached();
     }
     // Prefer to use cURL if it exists and we don't have cached data
     if ($inidata == false && $this->_hascURL()) {
         $inidata = $this->_getUpdateINIcURL();
     }
     // If cURL doesn't exist, or if it returned an error, try URL fopen() wrappers
     if ($inidata == false && $this->_hasURLfopen()) {
         $inidata = $this->_getUpdateINIfopen();
     }
     // If we have a valid update.ini, update the cache and read the version information
     if ($inidata != false) {
         $this->_setUpdateINIcached($inidata);
         $parsed = JoomlapackHelperUtils::_parse_ini_file($inidata, true, true);
         foreach ($parsed as $version => $data) {
             $status = isset($data['status']) ? $data['status'] : 'beta';
             $reldate_text = isset($data['reldate']) ? $data['reldate'] : 'now';
             $reldate = new JDate($reldate_text);
             $free = $data['free'];
             $special = $data['special'];
         }
         $ret = new JObject();
         $ret->version = $version;
         $ret->status = $status;
         $ret->reldate = $reldate;
         $ret->free = $free;
         $ret->special = $special;
         return $ret;
     }
     return false;
 }