Esempio n. 1
0
    /**
     * Entry point for CLI script
     *
     * @return  void
     *
     * @since   3.0
     */
    public function doExecute()
    {
        ini_set("max_execution_time", 300);
        jimport('joomla.filesystem.archive');
        jimport('joomla.filesystem.folder');
        jimport('joomla.filesystem.file');
        $config = JFactory::getConfig();
        $username = $config->get('user');
        $password = $config->get('password');
        $database = $config->get('db');
        echo 'Exporting database...
';
        exec("mysqldump --user={$username} --password={$password} --quick --add-drop-table --add-locks --extended-insert --lock-tables --all {$database} > " . JPATH_SITE . "/database-backup.sql");
        $zipFilesArray = array();
        $dirs = JFolder::folders(JPATH_SITE, '.', true, true);
        array_push($dirs, JPATH_SITE);
        echo 'Collecting files...
';
        foreach ($dirs as $dir) {
            $files = JFolder::files($dir, '.', false, true);
            foreach ($files as $file) {
                $data = JFile::read($file);
                $zipFilesArray[] = array('name' => str_replace(JPATH_SITE . '/', '', $file), 'data' => $data);
            }
        }
        $zip = JArchive::getAdapter('zip');
        echo 'Creating zip...
';
        $archive = JPATH_SITE . '/backups/' . date('Ymd') . '-backup.zip';
        $zip->create($archive, $zipFilesArray);
        echo 'Backup created ' . $archive . '
';
    }
Esempio n. 2
0
 /**
  * Read content files
  *
  * @return void
  *
  * @throws Exception
  */
 public function readContentElementFile()
 {
     NenoLog::log('Method readContentElementFile of NenoControllerGroupsElements called', 3);
     jimport('joomla.filesystem.file');
     NenoLog::log('Trying to move content element files', 3);
     $input = JFactory::getApplication()->input;
     $fileData = $input->files->get('content_element');
     $destFile = JFactory::getConfig()->get('tmp_path') . '/' . $fileData['name'];
     $extractPath = JFactory::getConfig()->get('tmp_path') . '/' . JFile::stripExt($fileData['name']);
     // If the file has been moved successfully, let's work with it.
     if (JFile::move($fileData['tmp_name'], $destFile) === true) {
         NenoLog::log('Content element files moved successfully', 2);
         // If the file is a zip file, let's extract it
         if ($fileData['type'] == 'application/zip') {
             NenoLog::log('Extracting zip content element files', 3);
             $adapter = JArchive::getAdapter('zip');
             $adapter->extract($destFile, $extractPath);
             $contentElementFiles = JFolder::files($extractPath);
         } else {
             $contentElementFiles = array($destFile);
         }
         // Add to each content file the path of the extraction location.
         NenoHelper::concatenateStringToStringArray($extractPath . '/', $contentElementFiles);
         NenoLog::log('Parsing element files for readContentElementFile', 3);
         // Parse element file(s)
         NenoHelperBackend::parseContentElementFile(JFile::stripExt($fileData['name']), $contentElementFiles);
         NenoLog::log('Cleaning temporal folder for readContentElementFile', 3);
         // Clean temporal folder
         NenoHelperBackend::cleanFolder(JFactory::getConfig()->get('tmp_path'));
     }
     NenoLog::log('Redirecting to groupselements view', 3);
     $this->setRedirect('index.php?option=com_neno&view=groupselements')->redirect();
 }
Esempio n. 3
0
 function packageUnzip($file, $target)
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.path');
     $extract1 =& JArchive::getAdapter('zip');
     $result = @$extract1->extract($file, $target);
     if ($result != true) {
         require_once PATH_ROOT . DS . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclzip.lib.php';
         require_once PATH_ROOT . DS . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclerror.lib.php';
         if (substr(PHP_OS, 0, 3) == 'WIN') {
             if (!defined('OS_WINDOWS')) {
                 define('OS_WINDOWS', 1);
             }
         } else {
             if (!defined('OS_WINDOWS')) {
                 define('OS_WINDOWS', 0);
             }
         }
         $extract2 = new PclZip($file);
         $result = @$extract2->extract(PCLZIP_OPT_PATH, $target);
     }
     unset($extract1, $extract2);
     return $result;
 }
 function _extract($package, $target)
 {
     // First extract files
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.path');
     $adapter =& JArchive::getAdapter('zip');
     $result = $adapter->extract($package, $target);
     if (!is_dir($target)) {
         require_once PATH_ROOT . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclzip.lib.php';
         require_once PATH_ROOT . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclerror.lib.php';
         $extract = new PclZip($package);
         if (substr(PHP_OS, 0, 3) == 'WIN') {
             if (!defined('OS_WINDOWS')) {
                 define('OS_WINDOWS', 1);
             }
         } else {
             if (!defined('OS_WINDOWS')) {
                 define('OS_WINDOWS', 0);
             }
         }
         $result = $extract->extract(PCLZIP_OPT_PATH, $target);
     }
     return $result;
 }
 public function download()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationAdministrator */
     $type = $this->input->get->getCmd('type');
     $model = $this->getModel();
     try {
         switch ($type) {
             case 'locations':
                 $output = $model->getLocations();
                 $fileName = 'locations.xml';
                 break;
             case 'countries':
                 $output = $model->getCountries();
                 $fileName = 'countries.xml';
                 break;
             case 'states':
                 $output = $model->getStates();
                 $fileName = 'states.xml';
                 break;
             default:
                 // Error
                 $output = '';
                 $fileName = 'error.xml';
                 break;
         }
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_SOCIALCOMMUNITY_ERROR_SYSTEM'));
     }
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.path');
     jimport('joomla.filesystem.archive');
     $tmpFolder = JPath::clean($app->get('tmp_path'));
     $date = new JDate();
     $date = $date->format('d_m_Y_H_i_s');
     $archiveName = JFile::stripExt(basename($fileName)) . '_' . $date;
     $archiveFile = $archiveName . '.zip';
     $destination = $tmpFolder . DIRECTORY_SEPARATOR . $archiveFile;
     // compression type
     $zipAdapter = JArchive::getAdapter('zip');
     $filesToZip[] = array('name' => $fileName, 'data' => $output);
     $zipAdapter->create($destination, $filesToZip, array());
     $filesize = filesize($destination);
     JFactory::getApplication()->setHeader('Content-Type', 'application/octet-stream', true);
     JFactory::getApplication()->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
     JFactory::getApplication()->setHeader('Content-Transfer-Encoding', 'binary', true);
     JFactory::getApplication()->setHeader('Pragma', 'no-cache', true);
     JFactory::getApplication()->setHeader('Expires', '0', true);
     JFactory::getApplication()->setHeader('Content-Disposition', 'attachment; filename=' . $archiveFile, true);
     JFactory::getApplication()->setHeader('Content-Length', $filesize, true);
     $doc = JFactory::getDocument();
     $doc->setMimeEncoding('application/octet-stream');
     $app->sendHeaders();
     echo file_get_contents($destination);
     $app->close();
 }
Esempio n. 6
0
 function process()
 {
     $this->installDir = JPATH_SITE . '/media/' . uniqid('rsinstall_');
     $adapter = JArchive::getAdapter('zip');
     if (!$adapter->extract($this->archive, $this->installDir)) {
         return false;
     }
     return true;
 }
Esempio n. 7
0
 /**
  * Extract ZIP-file
  *
  * @param	string	$path	The ZIP-file
  * @param	string	$dest	The destination
  *
  * @return	boolean		True on success, false otherwise
  */
 public static function extract($path, $dest = '')
 {
     if (!JFile::exists($path) || JFile::getExt($path) != "zip") {
         return false;
     }
     if ($dest = '') {
         $dest = JFile::stripExt($files);
     }
     return JArchive::getAdapter('zip')->extract($path, $dest);
 }
 public function extractFile($file, $destFolder)
 {
     $filePath = "";
     // extract type
     $zipAdapter = JArchive::getAdapter('zip');
     $zipAdapter->extract($file, $destFolder);
     $dir = new DirectoryIterator($destFolder);
     foreach ($dir as $fileinfo) {
         $fileExtension = JFile::getExt($fileinfo->getFilename());
         if (!$fileinfo->isDot() and strcmp('xml', $fileExtension) === 0) {
             $filePath = JPath::clean($destFolder . DIRECTORY_SEPARATOR . JFile::makeSafe($fileinfo->getFilename()));
             break;
         }
     }
     return $filePath;
 }
Esempio n. 9
0
 public function extractFile($file, $destFolder)
 {
     // extract type
     $zipAdapter = JArchive::getAdapter('zip');
     $zipAdapter->extract($file, $destFolder);
     $dir = new DirectoryIterator($destFolder);
     $filePath = '';
     foreach ($dir as $fileinfo) {
         $currentFileName = JString::strtolower($fileinfo->getFilename());
         if (!$fileinfo->isDot() and !in_array($currentFileName, $this->ignoredFiles, true)) {
             $filePath = JPath::clean($destFolder . DIRECTORY_SEPARATOR . JFile::makeSafe($fileinfo->getFilename()));
             break;
         }
     }
     return $filePath;
 }
Esempio n. 10
0
 public function extractFile($file, $destFolder)
 {
     // extract type
     $zipAdapter = JArchive::getAdapter('zip');
     $zipAdapter->extract($file, $destFolder);
     $dir = new DirectoryIterator($destFolder);
     $fileName = JFile::stripExt(basename($file));
     foreach ($dir as $fileinfo) {
         $currentFileName = JFile::stripExt($fileinfo->getFilename());
         if (!$fileinfo->isDot() and strcmp($fileName, $currentFileName) == 0) {
             $filePath = $destFolder . DIRECTORY_SEPARATOR . JFile::makeSafe($fileinfo->getFilename());
             break;
         }
     }
     return $filePath;
 }
Esempio n. 11
0
 /**
  * Install component
  *
  * @param	string	$file		Path to extension archive
  * @param	boolean	$update		True if extension should be updated, false if it is new
  */
 public static function install($file, $update = false)
 {
     $installer = JInstaller::getInstance();
     $tmp = JDeveloperINSTALL . "/" . JFile::stripExt(JFile::getName($file));
     JArchive::getAdapter('zip')->extract($file, $tmp);
     if ($update) {
         if (!$installer->update($tmp)) {
             return false;
         }
     } else {
         if (!$installer->install($tmp)) {
             return false;
         }
     }
     self::cleanInstallDir();
     return true;
 }
Esempio n. 12
0
 /**
  * Method to export features tables as CSV
  */
 public function export()
 {
     $features = JRequest::getVar('cid', array(), 'post', 'array');
     if (!empty($features)) {
         $config = JFactory::getConfig();
         $exportPath = $config->get('tmp_path') . DS . 'jea_export';
         if (JFolder::create($exportPath) === false) {
             $msg = JText::_('JLIB_FILESYSTEM_ERROR_FOLDER_CREATE') . ' : ' . $exportPath;
             $this->setRedirect('index.php?option=com_jea&view=features', $msg, 'warning');
         } else {
             $xmlPath = JPATH_COMPONENT . '/models/forms/features/';
             $xmlFiles = JFolder::files($xmlPath);
             $model = $this->getModel();
             $files = array();
             foreach ($xmlFiles as $filename) {
                 if (preg_match('/^[0-9]{2}-([a-z]*).xml/', $filename, $matches)) {
                     $feature = $matches[1];
                     if (in_array($feature, $features)) {
                         $form = simplexml_load_file($xmlPath . DS . $filename);
                         $table = (string) $form['table'];
                         $files[] = array('data' => $model->getCSVData($table), 'name' => $table . '.csv');
                     }
                 }
             }
             $zipFile = $exportPath . DS . 'jea_export_' . uniqid() . '.zip';
             $zip = JArchive::getAdapter('zip');
             $zip->create($zipFile, $files);
             JResponse::setHeader('Content-Type', 'application/zip');
             JResponse::setHeader('Content-Disposition', 'attachment; filename="jea_features.zip"');
             JResponse::setHeader('Content-Transfer-Encoding', 'binary');
             JResponse::setBody(readfile($zipFile));
             echo JResponse::toString();
             // clean tmp files
             JFile::delete($zipFile);
             JFolder::delete($exportPath);
             Jexit();
         }
     } else {
         $msg = JText::_('JERROR_NO_ITEMS_SELECTED');
         $this->setRedirect('index.php?option=com_jea&view=features', $msg);
     }
 }
Esempio n. 13
0
function com_install()
{
    if (!defined('DS')) {
        define('DS', DIRECTORY_SEPARATOR);
    }
    $path_root = dirname(dirname(dirname(dirname(__FILE__))));
    $path_app_admin = $path_root . DS . 'administrator' . DS . 'components' . DS . 'com_s2framework' . DS;
    $package = $path_app_admin . 's2framework.s2';
    $target = $path_root . DS . 'components' . DS . 'com_s2framework' . DS;
    jimport('joomla.filesystem.file');
    jimport('joomla.filesystem.folder');
    jimport('joomla.filesystem.archive');
    jimport('joomla.filesystem.path');
    $adapter =& JArchive::getAdapter('zip');
    $result = $adapter->extract($package, $target);
    if ($result) {
        $version = new JVersion();
        if ($version->RELEASE == 1.6) {
            ?>
            <script type="text/javascript">                        
            window.addEvent('domready', function() { 
                var req = new Request({ 
                  method: 'get', 
                  url: '<?php 
            echo JURI::base();
            ?>
index.php?option=com_s2framework&tmpl=component&format=raw&install=1', 
                }).send();
            });
            </script>
            <?php 
        }
        echo "The S2 Framework has been successfully installed.";
    } else {
        echo "There was a problem installing the framework. You need to extract and rename the s2framework.s2 file inside the component zip you just tried to install to s2framework.zip. Then extract it locally and upload via ftp to the /components/com_s2framework/ directory.";
    }
}
Esempio n. 14
0
 function upload()
 {
     $app = JFactory::getApplication();
     // Check that the zlib is available
     if (!extension_loaded('zlib')) {
         $app->redirect("index.php?option=com_adsmanager&c=plugins", "The installer can't continue before zlib is installed", 'message');
     }
     $userfile = JRequest::getVar('userfile', null, "FILES");
     //$_FILES
     $name = substr($userfile['name'], 0, strpos($userfile['name'], '.'));
     if (eregi('.zip$', $userfile['name'])) {
         // Extract functions
         jimport('joomla.filesystem.archive');
         $zip = JArchive::getAdapter('zip');
         $ret = $zip->extract($userfile['tmp_name'], JPATH_ROOT . "/images/com_adsmanager/plugins/" . $name);
         if ($ret != true) {
             JError::raiseError(500, 'Extract Error');
             return false;
         }
     } else {
         JError::raiseError(500, 'Extract Error');
         return false;
     }
     if (file_exists(JPATH_ROOT . "/images/com_adsmanager/plugins/" . $name . "/plug.php")) {
         require_once JPATH_ROOT . "/images/com_adsmanager/plugins/" . $name . "/plug.php";
         foreach ($plugins as $plug) {
             $plug->install();
         }
     } else {
         if (is_file(JPATH_ROOT . "/images/com_adsmanager/plugins/" . $name)) {
             JFolder::delete(JPATH_ROOT . "/images/com_adsmanager/plugins/" . $name);
         }
         JError::raiseError(500, 'This is not an adsmanager plugin');
         return false;
     }
     $app->redirect("index.php?option=com_adsmanager&c=plugins", JText::_('ADSMANAGER_PLUGIN_SAVED'), 'message');
 }
 /**
  * Installs the JReviews Content Plugin
  * 
  */
 function _installPlugin()
 {
     $package = PATH_ROOT . 'administrator' . DS . 'components' . DS . 'com_jreviews' . DS . 'jreviews.plugin.s2';
     if ($this->cmsVersion == CMS_JOOMLA16) {
         @mkdir(PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content' . DS . 'jreviews');
         $target = PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content' . DS . 'jreviews';
     } else {
         $target = PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content';
     }
     $target_file = $target . DS . 'jreviews.php';
     $first_pass = false;
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.path');
     $adapter =& JArchive::getAdapter('zip');
     $result = $adapter->extract($package, $target);
     if (!file_exists($target_file)) {
         $plugin_install = false;
     } else {
         $plugin_install = true;
         if ($this->cmsVersion == CMS_JOOMLA16) {
             // Add/create plugin db entry
             $query = "\n                    SELECT \n                        extension_id, enabled\n                    FROM \n                        #__extensions \n                    WHERE \n                        type = 'plugin' AND element = 'jreviews' AND folder = 'content'\n                ";
             $this->_db->setQuery($query);
             $result = $this->_db->loadAssoc();
             if (empty($result) || !$result['extension_id']) {
                 $query = "\n                        INSERT INTO \n                            #__extensions \n                                (`name`, `type`,`element`, `folder`, `access`, `ordering`, `enabled`, `client_id`, `checked_out`, `checked_out_time`, `params`)\n                            VALUES \n                                ('JReviews Plugin', 'plugin', 'jreviews', 'content', 1, 0, 1, 0, 0, '0000-00-00 00:00:00', '');\n                    ";
                 $this->_db->setQuery($query);
                 $plugin_install = $this->_db->query();
             } elseif (!empty($result) && $result['extension_id'] && !$result['enabled']) {
                 $query = "UPDATE #__extensions SET enabled = 1 WHERE extension_id = " . $result['extension_id'];
                 $this->_db->setQuery($query);
                 $plugin_install = $this->_db->query();
             }
         } else {
             // Add/create plugin db entry
             $query = "\n                    SELECT \n                        id, published \n                    FROM \n                        #__plugins \n                    WHERE \n                        element = 'jreviews' AND folder = 'content'\n                ";
             $this->_db->setQuery($query);
             $result = $this->_db->loadAssoc();
             if (empty($result) || !$result['id']) {
                 $query = "\n                        INSERT INTO #__plugins \n                            (`name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`)\n                        VALUES \n                            ('JReviews Plugin', 'jreviews', 'content', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '');\n                    ";
                 $this->_db->setQuery($query);
                 $plugin_install = $this->_db->query();
             } elseif (!empty($result) && $result['id'] && !$result['published']) {
                 $query = "UPDATE #__plugins SET published = 1 WHERE id = " . $result['id'];
                 $this->_db->setQuery($query);
                 $plugin_install = $this->_db->query();
             }
         }
     }
     return $plugin_install;
 }
Esempio n. 16
0
 /**
  * Extract an archive file to a directory.
  *
  * @param   string  $archivename  The name of the archive file
  * @param   string  $extractdir   Directory to unpack into
  *
  * @return  boolean  True for success
  *
  * @since   11.1
  */
 public static function extract($archivename, $extractdir)
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $untar = false;
     $result = false;
     $ext = JFile::getExt(strtolower($archivename));
     // Check if a tar is embedded...gzip/bzip2 can just be plain files!
     if (JFile::getExt(JFile::stripExt(strtolower($archivename))) == 'tar') {
         $untar = true;
     }
     switch ($ext) {
         case 'zip':
             $adapter = JArchive::getAdapter('zip');
             if ($adapter) {
                 $result = $adapter->extract($archivename, $extractdir);
             }
             break;
         case 'tar':
             $adapter = JArchive::getAdapter('tar');
             if ($adapter) {
                 $result = $adapter->extract($archivename, $extractdir);
             }
             break;
         case 'tgz':
             // This format is a tarball gzip'd
             $untar = true;
         case 'gz':
         case 'gzip':
             // This may just be an individual file (e.g. sql script)
             $adapter = JArchive::getAdapter('gzip');
             if ($adapter) {
                 $config = JFactory::getConfig();
                 $tmpfname = $config->get('tmp_path') . '/' . uniqid('gzip');
                 $gzresult = $adapter->extract($archivename, $tmpfname);
                 if ($gzresult instanceof Exception) {
                     @unlink($tmpfname);
                     return false;
                 }
                 if ($untar) {
                     // Try to untar the file
                     $tadapter = JArchive::getAdapter('tar');
                     if ($tadapter) {
                         $result = $tadapter->extract($tmpfname, $extractdir);
                     }
                 } else {
                     $path = JPath::clean($extractdir);
                     JFolder::create($path);
                     $result = JFile::copy($tmpfname, $path . '/' . JFile::stripExt(JFile::getName(strtolower($archivename))), null, 1);
                 }
                 @unlink($tmpfname);
             }
             break;
         case 'tbz2':
             // This format is a tarball bzip2'd
             $untar = true;
         case 'bz2':
         case 'bzip2':
             // This may just be an individual file (e.g. sql script)
             $adapter = JArchive::getAdapter('bzip2');
             if ($adapter) {
                 $config = JFactory::getConfig();
                 $tmpfname = $config->get('tmp_path') . '/' . uniqid('bzip2');
                 $bzresult = $adapter->extract($archivename, $tmpfname);
                 if ($bzresult instanceof Exception) {
                     @unlink($tmpfname);
                     return false;
                 }
                 if ($untar) {
                     // Try to untar the file
                     $tadapter = JArchive::getAdapter('tar');
                     if ($tadapter) {
                         $result = $tadapter->extract($tmpfname, $extractdir);
                     }
                 } else {
                     $path = JPath::clean($extractdir);
                     JFolder::create($path);
                     $result = JFile::copy($tmpfname, $path . '/' . JFile::stripExt(JFile::getName(strtolower($archivename))), null, 1);
                 }
                 @unlink($tmpfname);
             }
             break;
         default:
             JError::raiseWarning(10, JText::_('JLIB_FILESYSTEM_UNKNOWNARCHIVETYPE'));
             return false;
             break;
     }
     if (!$result || $result instanceof Exception) {
         return false;
     }
     return true;
 }
Esempio n. 17
0
    function processLanguageFiles($code = 'en-GB', $method = '', $params = array())
    {
        jimport('joomla.filesystem.file');
        jimport('joomla.filesystem.archive');
        $prefix = $code . '.';
        $suffix = '.ini';
        $missing = array();
        $namea = '';
        $names = '';
        $adminpath = JPATH_ADMINISTRATOR . DS . 'language' . DS . $code . DS;
        $refadminpath = JPATH_ADMINISTRATOR . DS . 'language' . DS . 'en-GB' . DS;
        $adminfiles = array('com_flexicontent', FLEXI_J16GE ? 'com_flexicontent.sys' : '', 'plg_flexicontent_fields_addressint', 'plg_flexicontent_fields_checkbox', 'plg_flexicontent_fields_checkboximage', 'plg_flexicontent_fields_core', 'plg_flexicontent_fields_date', 'plg_flexicontent_fields_email', 'plg_flexicontent_fields_extendedweblink', 'plg_flexicontent_fields_fcloadmodule', 'plg_flexicontent_fields_fcpagenav', 'plg_flexicontent_fields_file', 'plg_flexicontent_fields_groupmarker', 'plg_flexicontent_fields_image', 'plg_flexicontent_fields_linkslist', 'plg_flexicontent_fields_minigallery', 'plg_flexicontent_fields_phonenumbers', 'plg_flexicontent_fields_radio', 'plg_flexicontent_fields_radioimage', 'plg_flexicontent_fields_relation', 'plg_flexicontent_fields_relation_reverse', 'plg_flexicontent_fields_select', 'plg_flexicontent_fields_selectmultiple', 'plg_flexicontent_fields_shareaudio', 'plg_flexicontent_fields_sharevideo', 'plg_flexicontent_fields_text', 'plg_flexicontent_fields_textarea', 'plg_flexicontent_fields_textselect', 'plg_flexicontent_fields_toolbar', 'plg_flexicontent_fields_weblink', FLEXI_J16GE ? 'plg_finder_flexicontent' : '', FLEXI_J16GE ? 'plg_finder_flexicontent.sys' : '', 'plg_content_flexibreak', 'plg_flexicontent_flexinotify', 'plg_search_flexiadvsearch', 'plg_search_flexisearch', 'plg_system_flexiadvroute', 'plg_system_flexisystem');
        $sitepath = JPATH_SITE . DS . 'language' . DS . $code . DS;
        $refsitepath = JPATH_SITE . DS . 'language' . DS . 'en-GB' . DS;
        $sitefiles = array('com_flexicontent', 'mod_flexiadvsearch', 'mod_flexicontent', 'mod_flexitagcloud', 'mod_flexifilter');
        $targetfolder = JPATH_SITE . DS . 'tmp' . DS . $code . "_" . time();
        if ($method == 'zip') {
            if (count($adminfiles)) {
                JFolder::create($targetfolder . DS . 'admin', 0755);
            }
            if (count($sitefiles)) {
                JFolder::create($targetfolder . DS . 'site', 0755);
            }
        }
        foreach ($adminfiles as $file) {
            if (!$file) {
                continue;
            }
            if (!JFile::exists($adminpath . $prefix . $file . $suffix)) {
                $missing['admin'][] = $file;
                if ($method == 'create') {
                    JFile::copy($refadminpath . 'en-GB.' . $file . $suffix, $adminpath . $prefix . $file . $suffix);
                }
            } else {
                if ($method == 'zip') {
                    JFile::copy($adminpath . $prefix . $file . $suffix, $targetfolder . DS . 'admin' . DS . $prefix . $file . $suffix);
                    $namea .= "\n" . '			            <filename>' . $prefix . $file . $suffix . '</filename>';
                }
            }
        }
        foreach ($sitefiles as $file) {
            if (!$file) {
                continue;
            }
            if (!JFile::exists($sitepath . $prefix . $file . $suffix)) {
                $missing['site'][] = $file;
                if ($method == 'create') {
                    JFile::copy($refsitepath . 'en-GB.' . $file . $suffix, $sitepath . $prefix . $file . $suffix);
                }
            } else {
                if ($method == 'zip') {
                    JFile::copy($sitepath . $prefix . $file . $suffix, $targetfolder . DS . 'site' . DS . $prefix . $file . $suffix);
                    $names .= "\n" . '			            <filename>' . $prefix . $file . $suffix . '</filename>';
                }
            }
        }
        if ($method == 'zip') {
            $mailfrom = @$params['email'] ? $params['email'] : '*****@*****.**';
            $fromname = @$params['name'] ? $params['name'] : 'Emmanuel Danan';
            $website = @$params['web'] ? $params['web'] : 'http://www.flexicontent.org';
            // prepare the manifest of the language archive
            $date = JFactory::getDate();
            $xmlfile = $targetfolder . DS . 'install.xml';
            $xml = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
			<install type="language" version="1.5" client="both" method="upgrade">
			    <name>FLEXIcontent ' . $code . '</name>
			    <tag>' . $code . '</tag>
			    <creationDate>' . (FLEXI_J16GE ? $date->format('Y-M-d', $local = true) : $date->toFormat("%Y-%m-%d")) . '</creationDate>
			    <author>' . $fromname . '</author>
			    <authorEmail>' . $mailfrom . '</authorEmail>
			    <authorUrl>' . $website . '</authorUrl>
			    <copyright>(C) ' . (FLEXI_J16GE ? $date->format('Y', $local = true) : $date->toFormat("%Y")) . ' ' . $fromname . '</copyright>
			    <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
			    <description>' . $code . ' language pack for FLEXIcontent</description>
			    <administration>
			        <files folder="admin">' . $namea . '
			        </files>
			    </administration>
			    <site>
			        <files folder="site">' . $names . '
			        </files>
			    </site>
			</install>';
            // save xml manifest
            JFile::write($xmlfile, $xml);
            $fileslist = JFolder::files($targetfolder, '.', true, true, array('.svn', 'CVS', '.DS_Store'));
            $archivename = $targetfolder . '.com_flexicontent' . (FLEXI_J16GE ? '.zip' : '.tar.gz');
            // Create the archive
            echo JText::_('FLEXI_SEND_LANGUAGE_CREATING_ARCHIVE') . "<br>";
            if (!FLEXI_J16GE) {
                JArchive::create($archivename, $fileslist, 'gz', '', $targetfolder);
            } else {
                $app = JFactory::getApplication('administrator');
                $files = array();
                foreach ($fileslist as $i => $filename) {
                    $files[$i] = array();
                    $files[$i]['name'] = preg_replace("%^(\\\\|/)%", "", str_replace($targetfolder, "", $filename));
                    // STRIP PATH for filename inside zip
                    $files[$i]['data'] = implode('', file($filename));
                    // READ contents into string, here we use full path
                    $files[$i]['time'] = time();
                }
                $packager = JArchive::getAdapter('zip');
                if (!$packager->create($archivename, $files)) {
                    echo JText::_('FLEXI_OPERATION_FAILED');
                    return false;
                }
            }
            // Remove temporary folder structure
            if (!JFolder::delete($targetfolder)) {
                echo JText::_('FLEXI_SEND_DELETE_TMP_FOLDER_FAILED');
            }
        }
        // messages
        if ($method == 'zip') {
            return '<h3 class="lang-success">' . JText::_('FLEXI_SEND_LANGUAGE_ARCHIVE_SUCCESS') . '</span>';
        }
        return count($missing) > 0 ? $missing : '<span class="fc-mssg fc-success">' . JText::sprintf('FLEXI_SEND_LANGUAGE_NO_MISSING', $code) . '</span>';
    }
Esempio n. 18
0
 /**
  * Zip up the plugins used by the package
  *
  * @param   object  $row       package
  * @param   array   &$plugins  plugins to zip
  *
  * @return  void
  */
 protected function zipPlugins($row, &$plugins)
 {
     $archive = JArchive::getAdapter('zip');
     JFolder::create($this->outputPath . 'packages');
     foreach ($plugins as &$plugin) {
         $filenames = array(JPATH_ROOT . '/plugins/' . $plugin->group . '/' . $plugin->name);
         $files = array();
         $root = JPATH_ROOT . '/plugins/' . $plugin->group . '/' . $plugin->name . '/';
         $this->addFiles($filenames, $files, $root);
         $plugin->file = str_replace('{version}', $row->version, $plugin->file);
         $pluginZipPath = $this->outputPath . 'packages/' . $plugin->file;
         $ok = $archive->create($pluginZipPath, $files);
         $plugin->fullfile = $pluginZipPath;
         if (!$ok) {
             throw new RuntimeException('Unable to create zip in ' . $pluginZipPath, 500);
         }
     }
 }
Esempio n. 19
0
 /**
  * Backup Generate Process
  *
  * @param str $option
  */
 function backupDownload()
 {
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rsform' . DS . 'helpers' . DS . 'backup.php';
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     // Get the selected items
     $cid = JRequest::getVar('cid', array(0), 'post', 'array');
     // Force array elements to be integers
     JArrayHelper::toInteger($cid, array(0));
     $tmpdir = uniqid('rsformbkp');
     $path = JPATH_SITE . DS . 'media' . DS . $tmpdir;
     if (!JFolder::create($path, 0777)) {
         JError::raiseWarning(500, JText::_('Could not create directory ') . $path);
         return $this->setRedirect('index.php?option=com_rsform&task=backup.restore');
     }
     $export_submissions = JRequest::getInt('submissions');
     if (!RSFormProBackup::create($cid, $export_submissions, $path . DS . 'install.xml')) {
         JError::raiseWarning(500, JText::_('Could not write to ') . $path);
         return $this->setRedirect('index.php?option=com_rsform&task=backup.restore');
     }
     $name = 'rsform_backup_' . date('Y-m-d_His') . '.zip';
     $files = array(array('data' => JFile::read($path . DS . 'install.xml'), 'name' => 'install.xml'));
     $adapter =& JArchive::getAdapter('zip');
     if (!$adapter->create($path . DS . $name, $files)) {
         JError::raiseWarning(500, JText::_('Could not create archive ') . $path . DS . $name);
         return $this->setRedirect('index.php?option=com_rsform&task=backup.restore');
     }
     $this->setRedirect(JURI::root() . 'media/' . $tmpdir . '/' . $name);
 }
Esempio n. 20
0
 /**
  * zip up the plugins used by the package
  * @param object $row
  * @param array $plugins
  */
 protected function zipPlugins($row, &$plugins)
 {
     $archive = JArchive::getAdapter('zip');
     JFolder::create($this->outputPath . DS . 'packages');
     foreach ($plugins as &$plugin) {
         $filenames = array(JPATH_ROOT . DS . 'plugins' . DS . $plugin->group . DS . $plugin->name);
         $files = array();
         $root = JPATH_ROOT . DS . 'plugins' . DS . $plugin->group . DS . $plugin->name . DS;
         $this->addFiles($filenames, $files, $root);
         $plugin->file = str_replace('{version}', $row->version, $plugin->file);
         $pluginZipPath = $this->outputPath . DS . 'packages' . DS . $plugin->file;
         $ok = $archive->create($pluginZipPath, $files);
         $plugin->fullfile = $pluginZipPath;
         if (!$ok) {
             JError::raiseError(500, 'Unable to create zip in ' . $pluginZipPath);
         }
     }
 }
Esempio n. 21
0
 /**
  * Method to extract template zip
  *
  * @access	public
  */
 public function extractTplFiles($file)
 {
     echo '<h4>' . JText::_('COM_BWPOSTMAN_TPL_INSTALL_EXTRACT') . '</h4>';
     // Import filesystem libraries. Perhaps not necessary, but does not hurt
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $filename = JFile::makeSafe($file['name']);
     $ext = JFile::getExt($filename);
     $tempPath = JFactory::getConfig()->get('tmp_path');
     $archivename = $tempPath . '/tmp_bwpostman_installtpl.' . $ext;
     $extractdir = $tempPath . '/tmp_bwpostman_installtpl/';
     $new_filename = '/tmp_bwpostman_installtpl.' . $ext;
     $adapter = JArchive::getAdapter('zip');
     $result = $adapter->extract($archivename, $extractdir);
     if (!$result || $result instanceof Exception) {
         $this->_delMessage();
         echo '<p class="bw_tablecheck_error">' . JText::_('COM_BWPOSTMAN_TPL_INSTALL_ERROR_EXTRACT') . '</p>';
         return false;
     }
     echo '<p class="bw_tablecheck_ok">' . JText::_('COM_BWPOSTMAN_TPL_INSTALL_EXTRACT_OK') . '</p>';
     return true;
 }
 public function JSNISDownloadPackageAuth()
 {
     $this->_tmpFolder = JPATH_ROOT . DS . 'tmp' . DS;
     $this->_downloadURL = JSN_IMAGESHOW_AUTOUPDATE_URL;
     $this->_jarchiveZip = JArchive::getAdapter('zip');
 }
Esempio n. 23
0
 protected function _getJoomlaArchiveError($archive)
 {
     $error = '';
     if (version_compare(JVERSION, '1.6', '<')) {
         // Joomla 1.5: Unfortunately we need this rather ugly hack to get the error message
         $ext = JFile::getExt(strtolower($archive));
         $adapter = null;
         switch ($ext) {
             case 'zip':
                 $adapter = JArchive::getAdapter('zip');
                 break;
             case 'tar':
                 $adapter = JArchive::getAdapter('tar');
                 break;
             case 'tgz':
             case 'gz':
                 // This may just be an individual file (e.g. sql script)
             // This may just be an individual file (e.g. sql script)
             case 'gzip':
                 $adapter = JArchive::getAdapter('gzip');
                 break;
             case 'tbz2':
             case 'bz2':
                 // This may just be an individual file (e.g. sql script)
             // This may just be an individual file (e.g. sql script)
             case 'bzip2':
                 $adapter = JArchive::getAdapter('bzip2');
                 break;
             default:
                 $adapter = null;
                 break;
         }
         if ($adapter) {
             $error .= $adapter->get('error.message') . ': ' . $archive;
         }
         // End of Joomla 1.5 error message hackathon
     } else {
         // J1.6 and beyond - Not yet implemented
     }
     return $error;
 }
Esempio n. 24
0
 /**
  * @todo Implement testGetAdapter().
  */
 public function testGetAdapter()
 {
     $zip = JArchive::getAdapter('zip');
     $this->assertEquals('JArchiveZip', get_class($zip));
     $bzip2 = JArchive::getAdapter('bzip2');
     $this->assertEquals('JArchiveBzip2', get_class($bzip2));
     $gzip = JArchive::getAdapter('gzip');
     $this->assertEquals('JArchiveGzip', get_class($gzip));
     $tar = JArchive::getAdapter('tar');
     $this->assertEquals('JArchiveTar', get_class($tar));
 }
Esempio n. 25
0
 public function saveOds()
 {
     file_put_contents($this->strTmpDir . '/mimetype', 'application/vnd.oasis.opendocument.spreadsheet');
     file_put_contents($this->strTmpDir . '/meta.xml', $this->getMeta('en-US'));
     file_put_contents($this->strTmpDir . '/styles.xml', $this->getStyle());
     file_put_contents($this->strTmpDir . '/settings.xml', $this->getSettings());
     if (!is_dir($this->strTmpDir . '/META-INF/')) {
         mkdir($this->strTmpDir . '/META-INF/');
         mkdir($this->strTmpDir . '/Configurations2/');
         mkdir($this->strTmpDir . '/Configurations2/acceleator/');
         mkdir($this->strTmpDir . '/Configurations2/images/');
         mkdir($this->strTmpDir . '/Configurations2/popupmenu/');
         mkdir($this->strTmpDir . '/Configurations2/statusbar/');
         mkdir($this->strTmpDir . '/Configurations2/floater/');
         mkdir($this->strTmpDir . '/Configurations2/menubar/');
         mkdir($this->strTmpDir . '/Configurations2/progressbar/');
         mkdir($this->strTmpDir . '/Configurations2/toolbar/');
     }
     file_put_contents($this->strTmpDir . '/META-INF/manifest.xml', $this->getManifest());
     // create the zip archive
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $files = $this->_prepareZIPFiles(JFolder::files($this->strTmpDir, '.', true, true));
     $adapter = JArchive::getAdapter('zip');
     if ($adapter->create($this->strTmpDir . '.ods', $files)) {
         $this->cleanUp();
     }
 }
Esempio n. 26
0
 /**
  * Helper wrapper method for getAdapter
  *
  * @param   string  $type  The type of adapter (bzip2|gzip|tar|zip).
  *
  * @return  JArchiveExtractable  Adapter for the requested type
  *
  * @see     JUserHelper::getAdapter()
  * @since   3.4
  */
 public function getAdapter($type)
 {
     return JArchive::getAdapter($type);
 }
Esempio n. 27
0
 function upload_theme(&$msg)
 {
     $themecode = JRequest::getVar('themecode', '');
     if ($themecode != '') {
         $themecode = urldecode($_POST['themecode']);
         $themecode = str_replace('\\"', '"', $themecode);
         $themecode = str_replace('\\\'', '\'', $themecode);
         return $this->createTheme($themecode, $msg);
     }
     $file = JRequest::getVar('themefile', '', 'files', 'array');
     if (!isset($file['name'])) {
         $msg = 'No file has bee uploaded.';
         return false;
         //wrong file format, expecting .zip
     }
     $uploadedfile = basename($file['name']);
     echo 'Uploaded file: "' . $uploadedfile . '"<br/>';
     $folder_name = $this->getFolderNameOnly($file['name']);
     if ($folder_name == '') {
         $msg = 'Wrong file format, expecting ".zip"';
         return false;
         //wrong file format, expecting .zip
     }
     $this->prepareFolderYG();
     $path = JPATH_SITE . DS . 'tmp' . DS . 'youtubegallery' . DS;
     if (file_exists($path . $uploadedfile)) {
         echo 'Existing "' . $uploadedfile . '" file deleted.<br/>';
         unlink($path . $uploadedfile);
     }
     if (!move_uploaded_file($file['tmp_name'], $path . $uploadedfile)) {
         $msg = 'Cannot Move File';
         return false;
     }
     echo 'File "' . $uploadedfile . '" moved form temporary location.<br/>';
     $folder_name_created = $this->prepareFolder($folder_name, $path);
     echo 'Folder "tmp' . DS . 'youtubegallery' . DS . $folder_name_created . '" created.<br/>';
     //echo '$folder_name='.$folder_name.'<br/>';
     $zip = JArchive::getAdapter('zip');
     $zip->extract($path . $uploadedfile, $path . $folder_name_created);
     echo 'File "' . $uploadedfile . '" extracted.<br/>';
     unlink($path . $uploadedfile);
     echo 'File "' . $uploadedfile . '" deleted.<br/>';
     if (file_exists($path . $folder_name_created . DS . 'theme.txt')) {
         //Ok archive is fine, looks like it is really YG theme.
         $filedata = file_get_contents($path . $folder_name_created . DS . 'theme.txt');
         if ($filedata == '') {
             //Archive doesn't containe Gallery Data
             $msg = 'Gallery Data file is empty';
             JFolder::delete($path . 'youtubegallery');
             return false;
         }
         $theme_row = unserialize($filedata);
         $theme_row->themedescription = file_get_contents($path . $folder_name_created . DS . 'about.txt');
         echo 'Theme Data Found<br/>';
         if ($theme_row->mediafolder != '') {
             //prepare media folder
             $theme_row->mediafolder = $this->prepareFolder($theme_row->mediafolder, JPATH_SITE . DS . 'images' . DS);
             echo 'Media Folder "' . $theme_row->mediafolder . '" created.<br/>';
             //move files
             $this->moveFiles('tmp' . DS . 'youtubegallery' . DS . $folder_name_created, 'images' . DS . $theme_row->mediafolder);
         }
     } else {
         $msg = 'Archive doesnt containe Gallery Data';
         return false;
     }
     JFolder::delete($path);
     //Add record to database
     $theme_row->themename = $this->getThemeName(str_replace('"', '', $theme_row->themename));
     echo 'Theme Name: ' . $theme_row->themename . '<br/>';
     $this->saveTheme($theme_row);
     echo 'Theme Imported<br/>';
     return true;
 }
 protected function archiveExtension(JObject $extension)
 {
     $temp = $this->getTempPath();
     $files = $this->_getFiles($extension);
     if (!(bool) $this->input->get('not-archive')) {
         $adapter = $this->input->get('adapter', 'zip');
         $xml = $extension->get('xml');
         if ($extension->get('archive')) {
             $path = $extension->get('archive');
         } else {
             $name = $extension->get('name', (string) $xml->name);
             $path = sprintf('%s/%s', $temp, $name);
             if ($this->input->get('with-version')) {
                 $path .= '_' . $extension->get('version', (string) $xml->version);
             }
             $path .= '.' . $adapter;
         }
         $path = JPath::clean($path);
         if (!JArchive::getAdapter($adapter)->create($path, $files)) {
             throw new Exception(sprintf('File "%s" does not crated.', $path));
         }
         $extension->set('archive', basename($path));
         $this->out('Created archive: ' . basename($path));
     }
     if ($this->input->get('list')) {
         foreach ($files as $file) {
             $this->out($file['name']);
         }
     }
 }
Esempio n. 29
0
 /**
  * Test...
  *
  * @covers  JArchive::getAdapter
  * @expectedException  UnexpectedValueException
  *
  * @return mixed
  */
 public function testGetAdapterException()
 {
     $zip = JArchive::getAdapter('unknown');
 }
Esempio n. 30
0
 /**
  * Get the content
  *
  * @return	string	The content.
  * @since	1.6
  */
 public function getContent()
 {
     if (!isset($this->content)) {
         $this->content = '';
         $this->content .= '"' . str_replace('"', '""', JText::_('COM_BANNERS_HEADING_NAME')) . '","' . str_replace('"', '""', JText::_('COM_BANNERS_HEADING_CLIENT')) . '","' . str_replace('"', '""', JText::_('JCATEGORY')) . '","' . str_replace('"', '""', JText::_('COM_BANNERS_HEADING_TYPE')) . '","' . str_replace('"', '""', JText::_('COM_BANNERS_HEADING_COUNT')) . '","' . str_replace('"', '""', JText::_('JDATE')) . '"' . "\n";
         foreach ($this->getItems() as $item) {
             $this->content .= '"' . str_replace('"', '""', $item->name) . '","' . str_replace('"', '""', $item->client_name) . '","' . str_replace('"', '""', $item->category_title) . '","' . str_replace('"', '""', $item->track_type == 1 ? JText::_('COM_BANNERS_IMPRESSION') : JText::_('COM_BANNERS_CLICK')) . '","' . str_replace('"', '""', $item->count) . '","' . str_replace('"', '""', $item->track_date) . '"' . "\n";
         }
         if ($this->getState('compressed')) {
             $app = JFactory::getApplication('administrator');
             $files = array();
             $files['track'] = array();
             $files['track']['name'] = $this->getBasename() . '.csv';
             $files['track']['data'] = $this->content;
             $files['track']['time'] = time();
             $ziproot = $app->getCfg('tmp_path') . '/' . uniqid('banners_tracks_') . '.zip';
             // run the packager
             jimport('joomla.filesystem.folder');
             jimport('joomla.filesystem.file');
             jimport('joomla.filesystem.archive');
             $delete = JFolder::files($app->getCfg('tmp_path') . '/', uniqid('banners_tracks_'), false, true);
             if (!empty($delete)) {
                 if (!JFile::delete($delete)) {
                     // JFile::delete throws an error
                     $this->setError(JText::_('COM_BANNERS_ERR_ZIP_DELETE_FAILURE'));
                     return false;
                 }
             }
             if (!($packager = JArchive::getAdapter('zip'))) {
                 $this->setError(JText::_('COM_BANNERS_ERR_ZIP_ADAPTER_FAILURE'));
                 return false;
             } elseif (!$packager->create($ziproot, $files)) {
                 $this->setError(JText::_('COM_BANNERS_ERR_ZIP_CREATE_FAILURE'));
                 return false;
             }
             $this->content = file_get_contents($ziproot);
         }
     }
     return $this->content;
 }