/**
  * method to run before an install/update/uninstall method
  *
  * @return void
  */
 public function preflight($type, $parent)
 {
     // $parent is the class calling this method
     //$parent->getParent()->setRedirectURL('index.php?option=com_ckeditor');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     jimport('joomla.installer.installer');
     $installer = JInstaller::getInstance();
     $source = $installer->getPath('source');
     $packages = $source . DS . 'packages';
     // Get editor package
     if (is_dir($packages)) {
         $editor = JFolder::files($packages, 'plg_ckeditor.zip', false, true);
     }
     if (!empty($editor) && is_file($editor[0])) {
         $confObject = JFactory::getApplication();
         $packagePath = dirname($editor[0]) . DS . 'ckeditor';
         if (!JArchive::extract($editor[0], $packagePath)) {
             $editor_result = JText::_('EDITOR EXTRACT ERROR');
         } else {
             $installer = JInstaller::getInstance();
             $c_manifest = $installer->getManifest();
             $c_root =& $c_manifest->document;
             if (JFolder::copy($packagePath, dirname($installer->getPath('extension_site')) . DS . '..' . DS . 'plugins' . DS . 'editors', '', true)) {
                 $editor_result = JText::_('Success');
             } else {
                 $editor_result = JText::_('Error');
             }
         }
     } else {
         $editor_result = JText::_('Error');
     }
     echo '<p>' . $editor_result . '</p>';
 }
Example #2
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 . '
';
    }
Example #3
0
 /**
  * Installs an Application from a user upload.
  *
  * @param array $userfile The userfile to install from
  * @return int 2 = update, 1 = install
  *
  * @throws InstallHelperException
  * @since 2.0
  */
 public function installApplicationFromUserfile($userfile)
 {
     // Make sure that file uploads are enabled in php
     if (!(bool) ini_get('file_uploads')) {
         throw new InstallHelperException('Fileuploads are not enabled in php.');
     }
     // If there is no uploaded file, we have a problem...
     if (!is_array($userfile)) {
         throw new InstallHelperException('No file selected.');
     }
     // Check if there was a problem uploading the file.
     if ($userfile['error'] || $userfile['size'] < 1) {
         throw new InstallHelperException('Upload error occured.');
     }
     // Temporary folder to extract the archive into
     $tmp_directory = $this->app->path->path('tmp:') . '/';
     $archivename = $tmp_directory . $userfile['name'];
     if (!JFile::upload($userfile['tmp_name'], $archivename)) {
         throw new InstallHelperException("Could not move uploaded file to ({$archivename})");
     }
     // Clean the paths to use for archive extraction
     $extractdir = $tmp_directory . uniqid('install_');
     jimport('joomla.filesystem.archive');
     // do the unpacking of the archive
     if (!JArchive::extract($archivename, $extractdir)) {
         throw new InstallHelperException("Could not extract zip file to ({$tmp_directory})");
     }
     return $this->installApplicationFromFolder($extractdir);
 }
Example #4
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();
 }
Example #5
0
 function getbackup()
 {
     global $mainframe;
     if (!JFile::exists(JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup' . DS . 'backup.php')) {
         JError::raiseWarning(304, 'Backup file doesn\'t exist!');
         $mainframe->redirect('index.php?option=com_yos_resources_manager&view=version');
         return false;
     }
     $version = JRequest::getCmd('version');
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup' . DS . 'backup.php';
     if (!JFile::exists($urlbackup)) {
         JError::raiseWarning(400, 'File backup doesn\'t exist!');
         $mainframe->redirect('index.php?option=com_yos_resources_manager&view=version');
         return false;
     }
     // do the unpacking of the archive
     $extractdir = JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup' . DS . uniqid($version . '_');
     $archivename = $urlbackup;
     JFolder::create($extractdir);
     $result = JArchive::extract($archivename, $extractdir);
     // Get Instance
     $autoupdate = new AutoupdateHelper($extractdir . DS . 'update.xml', false, true, false, $extractdir);
     $autoupdate->upgradeFile();
     $autoupdate->cleanFileUpdate();
     $mainframe->redirect('index.php?option=com_yos_resources_manager&view=version', $autoupdate->getReport());
 }
Example #6
0
 /**
  * Support Zip files for image galleries 
  * @see TiendaFile::upload()
  */
 function upload()
 {
     if ($result = parent::upload()) {
         // Check if it's a supported archive
         $allowed_archives = array('zip', 'tar', 'tgz', 'gz', 'gzip', 'tbz2', 'bz2', 'bzip2');
         if (in_array(strtolower($this->getExtension()), $allowed_archives)) {
             $dir = $this->getDirectory();
             jimport('joomla.filesystem.archive');
             JArchive::extract($this->full_path, $dir);
             JFile::delete($this->full_path);
             $this->is_archive = true;
             $files = JFolder::files($dir);
             // Thumbnails support
             if (count($files)) {
                 // Name correction
                 foreach ($files as &$file) {
                     $file = new TiendaImage($dir . '/' . $file);
                 }
                 $this->archive_files = $files;
                 $this->physicalname = $files[0]->getPhysicalname();
             }
         }
     }
     return $result;
 }
Example #7
0
 public function install()
 {
     // Request forgeries check
     JRequest::checkToken() or die('Invalid Token');
     $file = JRequest::getVar('rule', '', 'FILES');
     $app = JFactory::getApplication();
     $files = array();
     // @task: If there's no tmp_name in the $file, we assume that the data sent is corrupted.
     if (!isset($file['tmp_name'])) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_RULE_FILE'), DISCUSS_QUEUE_ERROR);
         $app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install');
         $app->close();
     }
     // There are various MIME type for compressed file. So let's check the file extension instead.
     if ($file['name'] && JFile::getExt($file['name']) == 'xml') {
         $files = array($file['tmp_name']);
     } else {
         $jConfig = DiscussHelper::getJConfig();
         $path = rtrim($jConfig->get('tmp_path'), '/') . '/' . $file['name'];
         // @rule: Copy zip file to temporary location
         if (!JFile::copy($file['tmp_name'], $path)) {
             DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_RULE_FILE'), DISCUSS_QUEUE_ERROR);
             $app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install');
             $app->close();
         }
         jimport('joomla.filesystem.archive');
         $tmp = md5(DiscussHelper::getDate()->toMysQL());
         $dest = rtrim($jConfig->get('tmp_path'), '/') . '/' . $tmp;
         if (!JArchive::extract($path, $dest)) {
             DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_RULE_FILE'), DISCUSS_QUEUE_ERROR);
             $app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install');
             $app->close();
         }
         $files = JFolder::files($dest, '.', true, true);
         if (empty($files)) {
             // Try to do a level deeper in case the zip is on the outer.
             $folder = JFolder::folders($dest);
             if (!empty($folder)) {
                 $files = JFolder::files($dest . '/' . $folder[0], true);
                 $dest = $dest . '/' . $folder[0];
             }
         }
         if (empty($files)) {
             DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_RULE_FILE'), DISCUSS_QUEUE_ERROR);
             $app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install');
             $app->close();
         }
     }
     if (empty($files)) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_RULE_INSTALL_FAILED'), DISCUSS_QUEUE_ERROR);
         $app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install');
         $app->close();
     }
     foreach ($files as $file) {
         $this->installXML($file);
     }
     DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_RULE_INSTALL_SUCCESS'), DISCUSS_QUEUE_SUCCESS);
     $app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install');
     $app->close();
 }
function civicrm_setup()
{
    global $adminPath, $compileDir;
    $adminPath = JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_civicrm';
    $jConfig = JFactory::getConfig();
    set_time_limit(4000);
    // Path to the archive
    $archivename = $adminPath . DIRECTORY_SEPARATOR . 'civicrm.zip';
    // a bit of support for the non-alternaive joomla install
    if (file_exists($archivename)) {
        // ensure that the site has native zip, else abort
        if (!function_exists('zip_open') || !function_exists('zip_read')) {
            echo "Your PHP version is missing  zip functionality. Please ask your system administrator / hosting provider to recompile PHP with zip support.<p>";
            echo "If this is a new install, you will need to uninstall CiviCRM from the Joomla Extension Manager.<p>";
            exit;
        }
        $extractdir = $adminPath;
        JArchive::extract($archivename, $extractdir);
    }
    $scratchDir = JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'civicrm';
    if (!is_dir($scratchDir)) {
        JFolder::create($scratchDir, 0777);
    }
    $compileDir = $scratchDir . DIRECTORY_SEPARATOR . 'templates_c';
    if (!is_dir($compileDir)) {
        JFolder::create($compileDir, 0777);
    }
    $db = JFactory::getDBO();
    $db->setQuery(' SELECT count( * )
FROM information_schema.tables
WHERE table_name LIKE "civicrm_domain"
AND table_schema = "' . $jConfig->getValue('config.db') . '" ');
    global $civicrmUpgrade;
    $civicrmUpgrade = $db->loadResult() == 0 ? FALSE : TRUE;
}
Example #9
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;
 }
Example #11
0
 public function extract()
 {
     $session = JFactory::getSession();
     $target = $session->get('target', '', 'liveupdate');
     $tempdir = $session->get('tempdir', '', 'liveupdate');
     jimport('joomla.filesystem.archive');
     return JArchive::extract($target, $tempdir);
 }
 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();
 }
Example #13
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;
 }
Example #14
0
 function install()
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.archive');
     $tmp = JPATH_ROOT . '/tmp/kinstall/';
     $dest = KPATH_SITE . '/template/';
     $file = JRequest::getVar('install_package', NULL, 'FILES', 'array');
     if (!JRequest::checkToken()) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->app->redirect(KunenaRoute::_($this->baseurl, false));
     }
     if (!$file || !is_uploaded_file($file['tmp_name'])) {
         $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_INSTALL_EXTRACT_MISSING', $file['name']), 'notice');
     } else {
         $success = JFile::upload($file['tmp_name'], $tmp . $file['name']);
         $success = JArchive::extract($tmp . $file['name'], $tmp);
         if (!$success) {
             $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_INSTALL_EXTRACT_FAILED', $file['name']), 'notice');
         }
         // Delete the tmp install directory
         if (JFolder::exists($tmp)) {
             $templates = KunenaTemplateHelper::parseXmlFiles($tmp);
             if (!empty($templates)) {
                 foreach ($templates as $template) {
                     // Never overwrite default template
                     if ($template->directory == 'default') {
                         continue;
                     }
                     if (is_dir($dest . $template->directory)) {
                         if (is_file($dest . $template->directory . '/params.ini')) {
                             if (is_file($tmp . $template->directory . '/params.ini')) {
                                 JFile::delete($tmp . $template->directory . '/params.ini');
                             }
                             JFile::move($dest . $template->directory . '/params.ini', $tmp . $template->directory . '/params.ini');
                         }
                         JFolder::delete($dest . $template->directory);
                     }
                     $error = JFolder::move($tmp . $template->directory, $dest . $template->directory);
                     if ($error !== true) {
                         $this->app->enqueueMessage(JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE') . ': ' . $error, 'notice');
                     }
                 }
                 $retval = JFolder::delete($tmp);
                 $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_INSTALL_EXTRACT_SUCCESS', $file['name']));
             } else {
                 JError::raiseWarning(100, JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE_MISSING_FILE'));
                 $retval = false;
             }
         } else {
             JError::raiseWarning(100, JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE') . ' ' . JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_UNINSTALL') . ': ' . JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_DIR_NOT_EXIST'));
             $retval = false;
         }
     }
     $this->app->redirect(KunenaRoute::_($this->baseurl, false));
 }
Example #15
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);
 }
Example #16
0
 public function extract($archive)
 {
     $destination = JPath::clean(dirname($archive) . '/' . uniqid('social_install_'));
     $archive = JPath::clean($archive);
     jimport('joomla.filesystem.archive');
     if (JArchive::extract($archive, $destination)) {
         return $destination;
     }
     return false;
 }
Example #17
0
 function _install($file)
 {
     $AG_resourceType = JRequest::getVar('AG_resourceType');
     // Current resource type
     $config = JFactory::getConfig();
     $tmp_dest = $config->get('tmp_path');
     $resourceType = substr($AG_resourceType, 0, strlen($AG_resourceType) - 1);
     $file_type = "zip";
     if (isset($file) && !empty($file['name'])) {
         //Clean up filename to get rid of strange characters like spaces etc
         $filename = JFile::makeSafe($file['name']);
         $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
         $src = $file['tmp_name'];
         $dest = $tmp_dest . DIRECTORY_SEPARATOR . $filename;
         //First check if the file has the right extension
         if ($ext == $file_type) {
             if (JFile::upload($src, $dest)) {
                 if (JArchive::extract($tmp_dest . DIRECTORY_SEPARATOR . $filename, $tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType)) {
                     JFile::delete($tmp_dest . DIRECTORY_SEPARATOR . $filename);
                 }
                 // TEMPLATE DETAILS PARSING
                 if (JFIle::exists($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType . DIRECTORY_SEPARATOR . JFile::stripExt($filename) . DIRECTORY_SEPARATOR . 'details.xml')) {
                     $ag_resourceManager_xml =& JFactory::getXML($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType . DIRECTORY_SEPARATOR . JFile::stripExt($filename) . DIRECTORY_SEPARATOR . 'details.xml');
                     if (isset($ag_resourceManager_xml->type)) {
                         $ag_resourceManager_type = $ag_resourceManager_xml->type;
                     } else {
                         JFolder::delete($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType);
                         JFactory::getApplication()->enqueueMessage(JText::_('AG_ZIP_PACKAGE_IS_NOT_VALID_RESOURCE_TYPE') . "&nbsp;" . $filename, 'error');
                         return;
                     }
                 } else {
                     JFolder::delete($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType);
                     JFactory::getApplication()->enqueueMessage(JText::_('AG_ZIP_PACKAGE_IS_NOT_VALID_RESOURCE_TYPE') . "&nbsp;" . $filename, 'error');
                     return;
                 }
                 if ($ag_resourceManager_type && $ag_resourceManager_type == $resourceType) {
                     $result = JFolder::move($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType . DIRECTORY_SEPARATOR . JFile::stripExt($filename), JPATH_SITE . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'content' . DIRECTORY_SEPARATOR . 'admirorgallery' . DIRECTORY_SEPARATOR . 'admirorgallery' . DIRECTORY_SEPARATOR . $AG_resourceType . DIRECTORY_SEPARATOR . JFile::stripExt($filename));
                     if ($result) {
                         JFactory::getApplication()->enqueueMessage(JText::_('AG_ZIP_PACKAGE_IS_INSTALLED') . "&nbsp;" . $filename, 'message');
                     } else {
                         JFactory::getApplication()->enqueueMessage(JText::_('AG_CANNOT_MOVED_ITEM') . "&nbsp;" . $result, 'message');
                     }
                 } else {
                     JFolder::delete($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType);
                     JFactory::getApplication()->enqueueMessage(JText::_('AG_ZIP_PACKAGE_IS_NOT_VALID_RESOURCE_TYPE') . "&nbsp;" . $filename, 'error');
                 }
             } else {
                 JFactory::getApplication()->enqueueMessage(JText::_('AG_CANNOT_UPLOAD_FILE_TO_TEMP_FOLDER_PLEASE_CHECK_PERMISSIONS'), 'error');
             }
         } else {
             JFactory::getApplication()->enqueueMessage(JText::_('AG_ONLY_ZIP_ARCHIVES_CAN_BE_INSTALLED'), 'error');
         }
     }
 }
Example #18
0
 function installLanguage($parent, $tag, $name)
 {
     $exists = false;
     $success = true;
     $source = $parent->getParent()->getPath('source') . '/language';
     $destinations = array('site' => JPATH_SITE . '/components/com_kunena', 'admin' => JPATH_ADMINISTRATOR . '/components/com_kunena');
     $version = Kunena::version();
     $file = "com_kunena.en-GB.site_v{$version}";
     if (file_exists("{$source}/{$file}.zip")) {
         $ext = "zip";
     } elseif (file_exists("{$source}/{$file}.tar")) {
         $ext = "tar";
     } elseif (file_exists("{$source}/{$file}.tar.gz")) {
         $ext = "tar.gz";
     } elseif (file_exists("{$source}/{$file}.tar.bz2")) {
         $ext = "tar.bz2";
     }
     foreach ($destinations as $key => $dest) {
         if ($success != true) {
             continue;
         }
         // If we are installing Kunena from archive, we need to unzip language file
         $file = "{$source}/com_kunena.{$tag}.{$key}_v{$version}.{$ext}";
         $installdir = "{$dest}/language/{$tag}";
         if (file_exists($file)) {
             if (!JFolder::exists($installdir)) {
                 $success = JFolder::create($installdir);
             }
             if ($success) {
                 $success = JArchive::extract($file, $installdir);
             }
         }
         // Install language from dest/language/xx-XX
         if ($success == true && is_dir($installdir)) {
             $exists = true;
             // Older versions installed language files into main folders
             // Those files need to be removed to bring language up to date!
             jimport('joomla.filesystem.folder');
             $files = JFolder::files($installdir, '\\.ini$');
             foreach ($files as $filename) {
                 if (file_exists(JPATH_SITE . "/language/{$tag}/{$filename}")) {
                     JFile::delete(JPATH_SITE . "/language/{$tag}/{$filename}");
                 }
                 if (file_exists(JPATH_ADMINISTRATOR . "/language/{$tag}/{$filename}")) {
                     JFile::delete(JPATH_ADMINISTRATOR . "/language/{$tag}/{$filename}");
                 }
             }
         }
     }
     if ($exists && $name) {
         return sprintf('Installing %s - %s ... ', $tag, $name) . ($success ? sprintf('%s DONE %s', '<span style="color:darkgreen">', '</span>') : sprintf('%s FAILED %s', '<span style="color:darkred">', '</span>')) . '<br />';
     }
 }
Example #19
0
 /**
  * Uncompress zip file using pclzip library
  *
  * @param $zipFile  string path to zip file
  * @param $extractPath  string path to location which will be extract to
  *
  * @return  boolean true if success, false if failure
  */
 public static function unZip($zipFile, $extractPath)
 {
     jimport('joomla.filesystem.archive');
     $result = JArchive::extract($zipFile, $extractPath);
     if ($result === false) {
         return false;
     }
     return true;
     /*$pcl = new PclZip($zipFile);
     	 if(empty($pcl)) {
     		return false;
     		}
     		$retVal = $pcl->extract(PCLZIP_OPT_PATH, $extractPath);
     		$pcl->privCloseFd();
     		return $retVal;*/
 }
Example #20
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;
 }
Example #21
0
 /**
  * Tests extracting TAR.
  *
  * @group	JArchive
  * @covers	JArchive::extract
  * @return void
  */
 public function testExtractTar()
 {
     if (!is_dir(self::$outputPath)) {
         $this->markTestSkipped("Couldn't create folder.");
         return;
     }
     if (!JArchiveTar::isSupported()) {
         $this->markTestSkipped('Tar files can not be extracted.');
         return;
     }
     JArchive::extract(__DIR__ . '/archive/logo.tar', self::$outputPath);
     $this->assertTrue(is_file(self::$outputPath . '/logo-tar.png'));
     if (is_file(self::$outputPath . '/logo-tar.png')) {
         unlink(self::$outputPath . '/logo-tar.png');
     }
 }
 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;
 }
Example #23
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;
 }
Example #24
0
 /**
  * Perform installation of SQL queries
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function execute()
 {
     // Get the temporary path from the server.
     $tmpPath = $this->input->get('path', '', 'default');
     // There should be a queries.zip archive in the archive.
     $tmpQueriesPath = $tmpPath . '/queries.zip';
     // Extract the queries
     $path = $tmpPath . '/queries';
     // If on development mode, skip this
     if ($this->isDevelopment()) {
         return $this->output($this->getResultObj('COM_EASYBLOG_INSTALLATION_DEVELOPER_MODE', true));
     }
     // Check if this folder exists.
     if (JFolder::exists($path)) {
         JFolder::delete($path);
     }
     // Extract the archive now
     $state = JArchive::extract($tmpQueriesPath, $path);
     if (!$state) {
         $this->setInfo('COM_EASYBLOG_INSTALLATION_ERROR_UNABLE_EXTRACT_QUERIES', false);
         return $this->output();
     }
     // Get the list of files in the folder.
     $queryFiles = JFolder::files($path, '.', true, true);
     // When there are no queries file, we should just display a proper warning instead of exit
     if (!$queryFiles) {
         $this->setInfo('COM_EASYBLOG_INSTALLATION_ERROR_EMPTY_QUERIES_FOLDER', false);
         return $this->output();
     }
     $db = JFactory::getDBO();
     $total = 0;
     foreach ($queryFiles as $file) {
         // Get the contents of the file
         $contents = JFile::read($file);
         $queries = JInstallerHelper::splitSql($contents);
         foreach ($queries as $query) {
             $query = trim($query);
             if (!empty($query)) {
                 $db->setQuery($query);
                 $state = $db->execute();
             }
         }
         $total += 1;
     }
     $this->setInfo(JText::sprintf('COM_EASYBLOG_INSTALLATION_SQL_EXECUTED_SUCCESS', $total), true);
     return $this->output();
 }
Example #25
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;
 }
Example #26
0
 public static function add($archive, $url = null, $replace = null)
 {
     // Application
     $application = JFactory::getApplication();
     // Session
     $session = JFactory::getSession();
     // Generate gallery name
     $gallery = uniqid();
     // Random temporary path
     $newTempGalleryPath = $application->getCfg('tmp_path') . '/' . $gallery;
     // Create the folder
     JFolder::create($newTempGalleryPath);
     // Upload the file to the temporary folder
     if ($archive) {
         $name = $archive['name'];
         JFile::upload($archive['tmp_name'], $newTempGalleryPath . '/' . $name);
     } else {
         if ($url) {
             // Download the file to the temporary folder
             $buffer = file_get_contents($url);
             $name = basename($url);
             JFile::write($newTempGalleryPath . '/' . $name, $buffer);
         }
     }
     // Extract the archive
     JArchive::extract($newTempGalleryPath . '/' . $name, $newTempGalleryPath);
     // Delete the archive
     JFile::delete($newTempGalleryPath . '/' . $name);
     // Add the temporary folder to session so we can perform clean up when needed
     $galleries = $session->get('k2.galleries', array());
     $galleries[] = $gallery;
     $session->set('k2.galleries', $galleries);
     // Handle previous temporary folder
     if ($replace && JFolder::exists($application->getCfg('tmp_path') . '/' . $replace)) {
         // Remove from file system
         JFolder::delete($application->getCfg('tmp_path') . '/' . $replace);
         // Remove from session
         if (($key = array_search($replace, $galleries)) !== false) {
             unset($galleries[$key]);
             $session->set('k2.galleries', $galleries);
         }
     }
     // return
     return $gallery;
 }
Example #27
0
 /**
  * Display the view
  *
  * @return void
  */
 public function _actionDisplay(KCommandContext $context)
 {
     if (!JFolder::exists(JPATH_COMPONENT_ADMINISTRATOR . '/packages/')) {
         return;
     }
     $model = $this->getModel();
     $data = array();
     if (KRequest::has('get.folder', 'cmd')) {
         $package = JPATH_COMPONENT_ADMINISTRATOR . '/packages/' . KRequest::get('get.folder', 'cmd') . '/';
         $installer = JInstaller::getInstance();
         $installer->install($package);
         $data['html'] = $installer->get('extension.message');
         JFolder::delete($package);
     } elseif (KRequest::has('get.file', 'filename')) {
         $package = JPATH_COMPONENT_ADMINISTRATOR . '/packages/' . KRequest::get('get.file', 'filename');
         $data['package'] = JFile::stripExt(basename($package));
         JArchive::extract($package, JPATH_COMPONENT_ADMINISTRATOR . '/packages/' . $data['package']);
         JFile::delete($package);
         $files = JFolder::files(JPATH_COMPONENT_ADMINISTRATOR . '/packages/' . $data['package'], '\\.xml$', 1, true);
         $xml = is_array($files) ? end($files) : $files;
         $xml = simplexml_load_file($xml);
         $attribs = $xml->attributes();
         $data['package_name'] = (string) $xml->name . ': ' . ucfirst($attribs['type']);
         $data['package_version'] = (string) '<strong>' . JText::_('OK') . '</strong> - ' . $xml->version . @$xml->version['status'];
         ob_start();
         echo KFactory::get('admin::com.extensions.view.packages.html')->set('i', KRequest::get('get.i', 'int', 0))->set('package', $xml->name . ' ' . $xml->version . @$xml->version['status'])->setLayout('installing')->display();
         $data['html'] = ob_get_clean();
     } else {
         ob_start();
         echo KFactory::get('admin::com.extensions.view.packages.html')->setLayout('default')->display();
         $data['html'] = ob_get_clean();
         $packages = $model->getList();
         sort($packages);
         foreach ($packages as $i => $package) {
             $data['packages'][] = $package;
             ob_start();
             echo KFactory::get('admin::com.extensions.view.packages.html')->set('i', ++$i)->set('package', $package)->setLayout('unpacking')->display();
             $data['layouts'][] = ob_get_clean();
         }
         if ($model->getTotal() < 1) {
             $data['html'] = null;
         }
     }
     return json_encode($data);
 }
function com_install()
{
    $db =& JFactory::getDBO();
    $query = 'delete from #__plugins WHERE `element`=' . $db->Quote('activitycomment') . ' and `folder`=' . $db->Quote('community');
    $db->setQuery($query);
    $db->Query();
    JArchive::extract(JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_activitycomment' . DS . 'activitycomment.zip', JPATH_PLUGINS . DS . 'community');
    $language = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_activitycomment' . DS . 'en-GB.plg_activitycomment.ini';
    JFile::copy($language, JPATH_ROOT . DS . 'administrator' . DS . 'language' . DS . 'en-GB' . DS . 'en-GB.plg_activitycomment.ini');
    $query = "insert into #__plugins set name='JS Activity comments',element='activitycomment',folder='community',access='0',ordering='0',published='1'";
    $db->setQuery($query);
    $db->query();
    $content = "<div>Installation completed</div>";
    $content .= '<div>Please remember to run the <a href="index.php?option=com_activitycomment">patch first</a>.</div>';
    $content .= '<div><b>To Uninstall</b> you must first return to this page, and restore your template. You may then Uninstall the Plugin, then the Component. The reason - if you don\'t restore your template, after install your Community page could display incorrect</div>';
    $content .= '<div><b>If you are upgrading, please make sure to uninstall the plugin and component and then reinstall again with the component</b>,/div>';
    echo $content;
}
Example #29
0
 public function updateBaforms()
 {
     $target = $_POST['target'];
     $config = JFactory::getConfig();
     $path = $config->get('tmp_path') . '/com_baforms.zip';
     copy($target, $path);
     JArchive::extract($path, $config->get('tmp_path') . '/com_baforms');
     $installer = JInstaller::getInstance();
     $result = $installer->update($config->get('tmp_path') . '/com_baforms');
     JFile::delete($path);
     JFolder::delete($config->get('tmp_path') . '/com_baforms');
     $verion = baformsHelper::aboutUs();
     if ($result) {
         echo new JResponseJson($result, $verion->version);
     } else {
         echo new JResponseJson($result, '', true);
     }
     jexit();
 }
Example #30
0
 /**
  * Installs a new theme
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function install($file)
 {
     $source = $file['tmp_name'];
     $fileName = md5($file['name'] . Foundry::date()->toMySQL());
     $fileExtension = '_themes_install.zip';
     $destination = JPATH_ROOT . '/tmp/' . $fileName . $fileExtension;
     // Upload the zip archive
     $state = JFile::upload($source, $destination);
     if (!$state) {
         $this->setError(JText::_('COM_EASYBLOG_THEMES_INSTALLER_ERROR_COPY_FROM_PHP'));
         return false;
     }
     // Extract the zip
     $extracted = dirname($destination) . '/' . $fileName . '_themes_install';
     $state = JArchive::extract($destination, $extracted);
     // Once it is extracted, delete the zip file
     JFile::delete($destination);
     // Get the configuration file.
     $manifest = $extracted . '/config/template.json';
     $manifest = JFile::read($manifest);
     // Get the theme object
     $theme = json_decode($manifest);
     // Move it to the appropriate folder
     $themeDestination = EBLOG_THEMES . '/' . strtolower($theme->element);
     $exists = JFolder::exists($themeDestination);
     // If folder exists, overwrite it. For now, just throw an error.
     if ($exists) {
         // Delete teh etracted folder
         JFolder::delete($extracted);
         $this->setError(JText::sprintf('COM_EASYBLOG_THEMES_INSTALLER_ERROR_SAME_THEME_FOLDER_EXISTS', $theme->element));
         return false;
     }
     // Move extracted folder
     $state = JFolder::move($extracted, $themeDestination);
     if (!$state) {
         // Delete the etracted folder
         JFolder::delete($extracted);
         $this->setError(JText::_('COM_EASYBLOG_THEMES_INSTALLER_ERROR_MOVING_FOLDER_TO_THEMES_FOLDER'));
         return false;
     }
     return true;
 }