Beispiel #1
0
 /**
  * getSystemInfo
  *
  * @return	array
  */
 public function getSystemInfo()
 {
     static $sysdata = null;
     if (!$sysdata) {
         $sysdata = UpdateNgHelper::getSystemInfo();
         if (!$sysdata) {
             $this->setError('No system info available!');
             return null;
         }
     }
     return $sysdata;
 }
Beispiel #2
0
 /**
  * loadINI
  *
  * @return	bool
  */
 protected static function loadINI()
 {
     if (self::$_compinfo && self::$_pluginfo) {
         return true;
     }
     self::$_compinfo = array();
     self::$_pluginfo = array();
     self::$_thirdparty = array();
     // Get component parameter
     $version_check = EParameter::getComponentParam(CAUTOTWEETNG, 'version_check', 1);
     $remoteFile = self::SERVER_INI_PATH . self::SERVER_INI_FILE;
     $localFile = JPATH_AUTOTWEET_HELPERS . '/' . self::SERVER_INI_FILE;
     $file = $localFile;
     if ($version_check) {
         try {
             $ch = curl_init($remoteFile);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, self::CXN_TIMEOUT);
             curl_setopt($ch, CURLOPT_TIMEOUT, self::EXEC_TIMEOUT);
             $data = curl_exec($ch);
             curl_close($ch);
             file_put_contents($localFile, $data);
         } catch (Exception $e) {
             $msg = $e->getMessage();
             $logger->log(JLog::ERROR, 'AutoTweetNG - ' . $msg);
         }
     }
     jimport('joomla.error.error');
     jimport('joomla.registry.registry');
     $registry = new JRegistry();
     if (!$registry->loadFile($file, 'INI', array('processSections' => 'true'))) {
         $logger->log(JLog::ERROR, 'AutoTweetNG - error reading INI file ' . $file);
         return false;
     }
     // Init logging
     $logger = AutotweetLogger::getInstance();
     $db = JFactory::getDBO();
     // Get component info and remove from array
     $data = JApplicationHelper::parseXMLInstallFile(JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . self::COMP_INSTALL_FILE);
     self::$_compinfo = array('id' => $registry->get('component.id'), 'name' => $registry->get('component.name'), 'server_version' => $registry->get('component.version'), 'client_version' => $data['version'], 'home' => $registry->get('component.home'), 'faq' => $registry->get('component.faq'), 'download' => $registry->get('component.download'), 'support' => $registry->get('component.support'), 'products' => $registry->get('component.products'), 'twitter' => $registry->get('component.twitter'), 'jed' => $registry->get('component.jed'), 'message' => $registry->get('component.message'), 'news' => $registry->get('component.news'));
     $extensions = TextUtil::listToArray($registry->get('component.extensions'));
     foreach ($extensions as $extension) {
         $state = self::EXT_NOTINSTALLED;
         $config = '';
         $client_version = '';
         $type = $registry->get($extension . '.type');
         $id = $registry->get($extension . '.id');
         $source = $registry->get($extension . '.source');
         if ('module' == $type) {
             $mod_filename = 'mod_' . $id;
             // Get the module id and set url for config
             $pluginsModel = F0FModel::getTmpInstance('Extensions', 'ExtlyModel');
             $pluginsModel->savestate(false)->setState('element', $mod_filename);
             $rows = $pluginsModel->getItemList();
             if (!empty($rows)) {
                 $row = $rows[0];
                 if ($row->client_id) {
                     $path = JPATH_ADMINISTRATOR . '/modules/' . $mod_filename . DIRECTORY_SEPARATOR . $mod_filename . '.xml';
                 } else {
                     $path = JPATH_ROOT . '/modules/' . $mod_filename . DIRECTORY_SEPARATOR . $mod_filename . '.xml';
                 }
                 $data = JApplicationHelper::parseXMLInstallFile($path);
                 $client_version = $data['version'];
                 if (self::_isEnabled($mod_filename)) {
                     $state = self::EXT_ENABLED;
                 } else {
                     $state = self::EXT_DISABLED;
                 }
                 // $config = 'index.php?option=com_modules&task=module.edit&id=' . $row->extension_id;
             }
         } else {
             // Get the plugin id and set url for config
             $pluginsModel = F0FModel::getTmpInstance('Plugins', 'AutoTweetModel');
             $pluginsModel->savestate(false)->set('element_id', $id);
             $rows = $pluginsModel->getItemList();
             if (!empty($rows)) {
                 $row = $rows[0];
                 $path = JPATH_PLUGINS . DIRECTORY_SEPARATOR . $row->folder . DIRECTORY_SEPARATOR . $row->element . DIRECTORY_SEPARATOR . $row->element . '.xml';
                 $data = JApplicationHelper::parseXMLInstallFile($path);
                 $client_version = $data['version'];
                 if (JPluginHelper::isEnabled($row->folder, $row->element)) {
                     $state = self::EXT_ENABLED;
                 } else {
                     $state = self::EXT_DISABLED;
                 }
                 $config = 'index.php?option=com_plugins&task=plugin.edit&extension_id=' . $row->id;
             }
         }
         // Append plugin state to result arrays
         if (self::FM_EXT_SOURCE == $source) {
             self::$_pluginfo[] = array('id' => $id, 'name' => $registry->get($extension . '.name'), 'state' => $state, 'client_version' => $client_version, 'server_version' => $registry->get($extension . '.version'), 'message' => $registry->get($extension . '.message'), 'config' => $config);
         } else {
             self::$_thirdparty[] = array('id' => $id, 'name' => $registry->get($extension . '.name'), 'state' => $state, 'client_version' => $client_version, 'message' => $registry->get($extension . '.message'), 'config' => $config, 'source' => $source, 'download' => $registry->get($extension . '.download'));
         }
     }
     // Add installed plugins without entry in ini file to 3rd party list
     $pluginsModel = F0FModel::getTmpInstance('Plugins', 'AutoTweetModel');
     $pluginsModel->savestate(false);
     $plugins = $pluginsModel->getItemList();
     foreach ($plugins as $plugin) {
         $id = $plugin->element;
         $type = $plugin->folder;
         if (!self::in_array_recursive($id, self::$_pluginfo) && !self::in_array_recursive($id, self::$_thirdparty)) {
             $path = JPATH_PLUGINS . DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR . $id . DIRECTORY_SEPARATOR . $id . '.xml';
             $data = JApplicationHelper::parseXMLInstallFile($path);
             $client_version = $data['version'];
             if (JPluginHelper::isEnabled($type, $id)) {
                 $state = self::EXT_ENABLED;
             } else {
                 $state = self::EXT_DISABLED;
             }
             $config = 'index.php?option=com_plugins&task=plugin.edit&extension_id=' . $plugin->id;
             if (!empty($data['authorUrl'])) {
                 $source = $data['authorUrl'];
                 $download = $data['authorUrl'];
             } else {
                 $source = self::EXT_UNKNOWN;
                 $download = '';
             }
             self::$_thirdparty[] = array('id' => $id, 'name' => $plugin->name, 'state' => $state, 'client_version' => $client_version, 'message' => 'unknown extension plugin', 'config' => $config, 'source' => $source, 'download' => $download);
         }
     }
     return true;
 }