Exemple #1
0
 function unregisterAndDeleteTempFile($fileName, $removePrefix = false)
 {
     $configuration =& JoomlapackModelRegistry::getInstance();
     if ($removePrefix) {
         $fileName = str_replace($configuration->getTemporaryDirectory(), '', $fileName);
         if (substr($fileName, 1, 1) == '/' || substr($fileName, 1, 1) == '\\') {
             $fileName = substr($fileName, 2, strlen($fileName) - 1);
         }
     }
     if (JoomlapackCUBETables::CountVar('CUBETempFiles') >= 1) {
         $serialized = JoomlapackCUBETables::ReadVar('CUBETempFiles');
         $tempFiles = unserialize($serialized);
         $newTempFiles = array();
         if (is_array($tempFiles)) {
             $aFile = array_shift($tempFiles);
             while (!is_null($aFile)) {
                 if ($aFile != $fileName) {
                     $newTempFiles[] = $aFile;
                 }
                 $aFile = array_shift($tempFiles);
             }
         }
         if (count($newTempFiles) == 0) {
             JoomlapackCUBETables::DeleteVar('CUBETempFiles');
         } else {
             $serialized = serialize($newTempFiles);
             JoomlapackCUBETables::WriteVar('CUBETempFiles', $serialized);
         }
     }
     $file = $configuration->getTemporaryDirectory() . DS . $fileName;
     return file_exists($file) ? @unlink($file) : false;
 }
 /**
  * Adds an entry to the engine includes table
  *
  * @param string $dottedNotation Dotted notation of class file to add to the list
  */
 function _addEngineInclude($dottedNotation)
 {
     if (JoomlapackCUBETables::CountVar('CUBEEngineIncludes') >= 1) {
         // There is a db entry. Load, and unserialize
         $includes = JoomlapackCUBETables::UnserializeVar('CUBEEngineIncludes');
     } else {
         // Start a new array
         $includes = array();
     }
     // Append to the array
     $includes[] = $dottedNotation;
     // Serialize and save
     JoomlapackCUBETables::SerializeVar('CUBEEngineIncludes', $includes);
 }
 /**
  * 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;
 }
 /**
  * Reads and unserializes a packvar variable (combo function)
  *
  * @param string $varName The variable name to read
  * @param mixed $default The default unserialized data to return if the $varName doesn't exist
  * @return mixed The unserialized value read from database
  */
 function UnserializeVar($varName, $default = null)
 {
     if ($varName == 'CUBEObject') {
         if (JoomlapackCUBETables::_isSetCUBEInFile()) {
             return JoomlapackCUBETables::_loadCUBEObjectFromFile();
         }
     }
     $count = JoomlapackCUBETables::CountVar($varName);
     if ($count >= 1) {
         $serialized = JoomlapackCUBETables::ReadVar($varName);
         return unserialize($serialized);
     } else {
         return $default;
     }
 }
Exemple #5
0
 /**
  * Reads and unserializes a packvar variable (combo function)
  *
  * @param string $varName The variable name to read
  * @param mixed $default The default unserialized data to return if the $varName doesn't exist
  * @return mixed The unserialized value read from database
  */
 function UnserializeVar($varName, $default = null)
 {
     $count = JoomlapackCUBETables::CountVar($varName);
     if ($count >= 1) {
         $serialized = JoomlapackCUBETables::ReadVar($varName);
         return unserialize($serialized);
     } else {
         return $default;
     }
 }
Exemple #6
0
 /**
  * Singleton pattern. It tries to load the CUBE off the database if it's not
  * found in memory. If it fails too, it creates a new object.
  *
  * @return JoomlapackCUBE
  */
 function &getInstance()
 {
     static $instance;
     if (!is_object($instance)) {
         // Try loading from database
         if (JoomlapackCUBETables::CountVar('CUBEObject') == 1) {
             JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBE::getInstance - Loading from database");
             // Get the includes first!
             JoomlapackCUBEProvisioning::retrieveEngineIncludes();
             // Then load the object
             $instance = JoomlapackCUBETables::UnserializeVar('CUBEObject');
             if (!is_object($instance)) {
                 // Damn! We have some broken crap in the db. Gotta retry :(
                 JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBE::getInstance - Broken in database, creating new instance");
                 $instance = new JoomlapackCUBE();
             }
         } else {
             // No stored object, we are forced to create a fresh object or something really
             // odd is going on with MySQL!
             JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBE::getInstance - Not found in database, creating new instance");
             $instance = new JoomlapackCUBE();
         }
     }
     return $instance;
 }