public function downloadAndInstall() { require_once JPATH_ADMINISTRATOR . '/components/com_zlmanager/helpers/download.php'; $url = JRequest::getVar('url', ''); $title = JRequest::getVar('title', ''); if (strlen($url)) { $url = 'https://www.zoolanders.com' . $url; $file = JPATH_SITE . '/tmp/zl_ext.zip'; require_once JPATH_ADMINISTRATOR . '/components/com_zlmanager/helpers/cparams.php'; $username = ZLManagerHelperCparams::getParam('username', ''); $password = ZLManagerHelperCparams::getParam('password', ''); $url .= '&username='******'&password='******'&task=download&controller=zooextensions'; $success = ZLManagerDownloadHelper::download($url, $file); if ($success && filesize($file) > 0) { jimport('joomla.installer.installer'); $lang = JFactory::getLanguage(); $lang->load(strtolower('com_installer'), JPATH_ADMINISTRATOR, null, false, false) || $lang->load(strtolower('com_installer'), JPATH_ADMINISTRATOR, $lang->getDefault(), false, false); jimport('joomla.installer.helper'); jimport('joomla.filesystem.archive'); $answer = $this->doInstall($file); } else { $answer = array('success' => false, 'errors' => array('Could not download the file')); } } else { $answer = array('success' => false, 'errors' => array('File url not specified')); } require_once JPATH_ADMINISTRATOR . '/components/com_zlmanager/helpers/extensions.php'; $exts = ZLManagerExtensionsHelper::getExtensionsAndVersions(); $versions = $exts['versions']; $answer['version'] = @$versions[$title]; echo json_encode($answer); die; }
public function __construct($config = array()) { parent::__construct($config); // make sure ZOO exist jimport('joomla.filesystem.file'); if (!JFile::exists(JPATH_ADMINISTRATOR . '/components/com_zoo/config.php') || !JComponentHelper::getComponent('com_zoo', true)->enabled) { return; } // load zoo require_once JPATH_ADMINISTRATOR . '/components/com_zoo/config.php'; $this->app = App::getInstance('zoo'); // Load from cache require_once JPATH_ADMINISTRATOR . '/components/com_zlmanager/helpers/cparams.php'; require_once JPATH_ADMINISTRATOR . '/components/com_zlmanager/helpers/download.php'; $username = ZLManagerHelperCparams::getParam('username', ''); $password = ZLManagerHelperCparams::getParam('password', ''); $key = md5($username . ':' . $password); $cache = $this->getCache($key); if (!$cache || !($json = $cache->get('json'))) { $url = 'https://www.zoolanders.com/index.php?option=com_zoo&controller=zooextensions&task=getList&format=raw&username='******'&password='******'/tmp/zlmanager.json'; ZLManagerDownloadHelper::download($url, $file); $json = JFile::read($file); JFile::delete($file); if ($cache) { $cache->set('json', $json)->save(); } } $this->_json = json_decode($json); $this->setState('limit', 50); }