Exemple #1
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());
 }
 /**
  * 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>';
 }
Exemple #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);
 }
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;
}
Exemple #5
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();
 }
Exemple #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;
 }
 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);
 }
Exemple #8
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));
 }
Exemple #9
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;
 }
 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');
         }
     }
 }
Exemple #11
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 />';
     }
 }
Exemple #12
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');
     }
 }
Exemple #13
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;*/
 }
Exemple #14
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();
 }
Exemple #15
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);
 }
 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;
 }
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;
}
Exemple #18
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();
 }
Exemple #19
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;
 }
 function _install($file)
 {
     $AG_resourceType = JRequest::getVar('AG_resourceType');
     // Current resource type
     $config =& JFactory::getConfig();
     $tmp_dest = $config->getValue('config.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 . DS . $filename;
         //First check if the file has the right extension
         if ($ext == $file_type) {
             if (JFile::upload($src, $dest)) {
                 if (JArchive::extract($tmp_dest . DS . $filename, JPATH_SITE . DS . 'plugins' . DS . 'content' . DS . 'AdmirorGallery' . DS . $AG_resourceType)) {
                     JFile::delete($tmp_dest . DS . $filename);
                 }
                 // TEMPLATE DETAILS PARSING
                 if (JFIle::exists(JPATH_SITE . DS . 'plugins' . DS . 'content' . DS . 'AdmirorGallery' . DS . $AG_resourceType . DS . JFile::stripExt($filename) . DS . 'details.xml')) {
                     $ag_resourceManager_xml =& JFactory::getXMLParser('simple');
                     $ag_resourceManager_xml->loadFile(JPATH_SITE . DS . 'plugins' . DS . 'content' . DS . 'AdmirorGallery' . DS . $AG_resourceType . DS . JFile::stripExt($filename) . DS . 'details.xml');
                     if (isset($ag_resourceManager_xml->document->type[0])) {
                         $ag_resourceManager_type = $ag_resourceManager_xml->document->type[0]->data();
                     }
                 }
                 if ($ag_resourceManager_type == $resourceType) {
                     JFactory::getApplication()->enqueueMessage(JText::_('ZIP PACKAGE IS INSTALLED:') . "&nbsp;" . $filename, 'message');
                 } else {
                     JFolder::delete(JPATH_SITE . DS . 'plugins' . DS . 'content' . DS . 'AdmirorGallery' . DS . $AG_resourceType . DS . JFile::stripExt($filename));
                     JFactory::getApplication()->enqueueMessage(JText::_('ZIP PACKAGE IS NOT VALID RESOURCE TYPE:') . "&nbsp;" . $filename, 'error');
                 }
             } else {
                 JFactory::getApplication()->enqueueMessage(JText::_('CANNOT UPLOAD FILE TO TEMP FOLDER. PLEASE CHECK PERMISSIONS.'), 'error');
             }
         } else {
             JFactory::getApplication()->enqueueMessage(JText::_('ONLY ZIP ARCHIVES CAN BE INSTALLED.'), 'error');
         }
     }
 }
 /**
  * For users who uploaded the installer and needs a manual extraction
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function execute()
 {
     // Check the api key from the request
     $key = $this->input->get('apikey', '');
     // Get the package
     $package = $this->input->get('package', '');
     // Get information about the current release.
     $info = $this->getInfo();
     // If on developer mode, we skip the extraction
     if ($this->isDevelopment()) {
         return $this->output($this->getResultObj('COM_EASYBLOG_INSTALLATION_DEVELOPER_MODE', true));
     }
     // Construct storage path
     $storage = EB_PACKAGES . '/' . $package;
     $exists = JFile::exists($storage);
     // Test if package really exists
     if (!$exists) {
         $this->setInfo('COM_EASYBLOG_INSTALLATION_ERROR_PACKAGE_DOESNT_EXIST', false);
         return $this->output();
     }
     // Check if the temporary folder exists
     if (!JFolder::exists(EB_TMP)) {
         JFolder::create(EB_TMP);
     }
     // Extract files to a temporary location
     $tmp = EB_TMP . '/com_easyblog_v' . $info->version;
     // Delete any folders that already exists
     if (JFolder::exists($tmp)) {
         JFolder::delete($tmp);
     }
     // Try to extract the files
     $state = JArchive::extract($storage, $tmp);
     // Regardless of the extraction state, delete the zip file.
     @JFile::delete($storage);
     if (!$state) {
         $this->setInfo('COM_EASYBLOG_INSTALLATION_ERROR_EXTRACT_ERRORS', false);
         return $this->output();
     }
     $this->setInfo('COM_EASYBLOG_INSTALLATION_EXTRACT_SUCCESS', true, array('path' => $tmp));
     return $this->output();
 }
Exemple #22
0
 public function unpackFileArray($array)
 {
     jimport('joomla.filesystem.archive');
     foreach ($array as $file) {
         if (!empty($file[3])) {
             if ($file[3] == 2) {
                 $basepath = JPATH_SITE . '/media/' . _EUCA_APP_COMPNAME . '/js/';
             } elseif ($file[2]) {
                 $basepath = JPATH_SITE . '/media/' . _EUCA_APP_COMPNAME . '/images/admin/';
             } else {
                 $basepath = JPATH_SITE . '/media/' . _EUCA_APP_COMPNAME . '/images/site/';
             }
             $fullpath = $basepath . $file[0];
             $deploypath = $basepath . $file[1];
         } else {
             if ($file[2]) {
                 $basepath = JPATH_SITE . '/administrator/components/' . _EUCA_APP_COMPNAME . '/';
             } else {
                 $basepath = JPATH_SITE . '/components/' . _EUCA_APP_COMPNAME . '/';
             }
             $fullpath = $basepath . $file[0];
             $deploypath = $basepath . $file[1];
         }
         if (!@is_dir($deploypath)) {
             // Borrowed from php.net page on mkdir. Created by V-Tec (vojtech.vitek at seznam dot cz)
             $folder_path = array(strstr($deploypath, '.') ? dirname($deploypath) : $deploypath);
             while (!@is_dir(dirname(end($folder_path))) && dirname(end($folder_path)) != '/' && dirname(end($folder_path)) != '.' && dirname(end($folder_path)) != '') {
                 array_push($folder_path, dirname(end($folder_path)));
             }
             while ($parent_folder_path = array_pop($folder_path)) {
                 @mkdir($parent_folder_path, 0644);
             }
         }
         if (JArchive::extract($fullpath, $deploypath) !== 0) {
             @unlink($fullpath);
         } else {
             $this->setError(array('Extraction Error', 'the file ' . $file[0] . ' could not be extracted to ' . $deploypath . '. You can try to unpack the files yourself.'));
         }
     }
 }
Exemple #23
0
 function upload_theme()
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.path');
     if ($_FILES["zip_file"]["name"]) {
         $filename = $_FILES["zip_file"]["name"];
         $source = $_FILES["zip_file"]["tmp_name"];
         $type = $_FILES["zip_file"]["type"];
         $name = explode(".", $filename);
         $foldername = $name[0];
         $accepted_types = array('application/x-zip', 'application/zip', 'application/octet-stream', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed');
         if (in_array($type, $accepted_types)) {
             // clean up filename to get rid of strange characters like spaces etc
             $filename = JFile::makeSafe($_FILES["zip_file"]["name"]);
             // folder where unzipped contents will go
             $destination = JPATH_SITE . DS . 'components' . DS . 'com_awdwall' . DS . 'images';
             // make the folder to stored the extracted files
             JFolder::create($destination, 0777);
             // place zip file in new directory
             if (!JFile::upload($_FILES["zip_file"]['tmp_name'], JPATH_SITE . DS . 'tmp' . DS . $filename)) {
                 JError::raiseError(500, 'Error uploading file to ' . JPATH_SITE . DS . 'tmp');
             }
             chmod(JPATH_SITE . DS . 'tmp' . DS . $filename, 0777);
             // unzip file
             $result = JArchive::extract(JPath::clean(JPATH_SITE . DS . 'tmp' . DS . $filename), JPath::clean($destination));
             if ($result === false) {
                 JError::raiseError(500, 'Error unzipping file.');
             }
             $message = "Your theme was uploaded and unpacked.";
         } else {
             $message = "The file you are trying to upload is not a zip file. Please try again.";
         }
     } else {
         $message = "The file you are trying to upload is not a zip file. Please try again.";
     }
     $this->setMessage($message);
     $this->setRedirect('index.php?option=com_awdwall&controller=config');
 }
Exemple #24
0
 function importFile()
 {
     $getFileUpload = $this->upload();
     switch ($this->compress) {
         case 1:
         case 2:
             $extractdir = JPath::clean(dirname($getFileUpload));
             $archivename = JPath::clean($getFileUpload);
             $result = JArchive::extract($archivename, $extractdir);
             break;
         case 0:
             break;
     }
     if (!$result) {
         return false;
     } else {
         $this->_setDocument();
         $attributeDocument = $this->_document->attributes();
         $versionRestore = (double) $attributeDocument['version'];
         $versionCheck = (double) '2.3.0';
         $versionCheckMigrate = (double) '3.0.0';
         if ($versionRestore < $versionCheck) {
             return 'outdated';
         }
         if ($versionRestore < $versionCheckMigrate) {
             $queries[] = $this->_migrateShowcase();
         } else {
             $queries[] = $this->_restoreShowcase();
             $queries[] = $this->_restoreShowcaseTheme();
         }
         $queries[] = $this->_restoreParameter();
         $queries[] = $this->_restoreShowlist();
         $queries[] = $this->_restoreConfiguration();
         $this->executeQuery($queries);
         $arrayFileDelte = array($archivename, $this->_fileRestore);
         JFile::delete($arrayFileDelte);
         return true;
     }
 }
Exemple #25
0
 function installphpexcell()
 {
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loader.php';
     $data = OPCloader::fetchUrl('http://www.rupostel.com/gpl/phpexcell.zip');
     if (!empty($data)) {
         $zip = JPATH_ROOT . DS . 'libraries' . DS . 'PHPExcel' . DS . 'phpexcel.zip';
         $dest = JPATH_ROOT . DS . 'libraries' . DS . 'PHPExcel';
         jimport('joomla.filesystem.file');
         jimport('joomla.filesystem.folder');
         jimport('joomla.filesystem.archive');
         jimport('joomla.archive.archive');
         if (JFolder::create($dest) !== false) {
             if (JFile::write($zip, $data) !== false) {
                 if (JArchive::extract($zip, $dest . DS) !== false) {
                     $msg = JText::_('COM_ONEPAGE_OK');
                 }
             }
         }
     }
     if (empty($msg)) {
         $msg = 'Error';
     }
     $data = JRequest::get('post');
     if (isset($data['limitstart'])) {
         $limitstart = $data['limitstart'];
     } else {
         $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
     }
     $mainframe = JFactory::getApplication();
     if (isset($data['limit'])) {
         $limit = $data['limit'];
     }
     if (empty($limit)) {
         $limit = $mainframe->getUserStateFromRequest("{$option}.limit", 'limit', 50, 'int');
     }
     $link = 'index.php?option=com_onepage&view=orders&limitstart=' . $limitstart . '&limit=' . $limit;
     $this->setRedirect($link, $msg);
 }
Exemple #26
0
 /**
  * Get a Autoupdate's object
  *
  * @return Autoupdatehelper's object 
  */
 function getInstance()
 {
     $docURL = new YOS_Yadis_PlainHTTPFetcher();
     //trying to set limit to 4.5 minutes, because I will run the cronjob every 5 minutes
     @set_time_limit(60 * 4.5);
     // Get content file
     $file = $docURL->get("http://{$this->_url}/index.php?option=com_yos_checkversion&view=update&pc={$this->_pc}&version={$this->_version}&s=" . base64_encode($this->_host) . "&lic={$this->_licence}&auto=1");
     // Check update data
     if ($file->body == 'yos_ver' || $file->body == 'yos_db') {
         if ($file->body == 'yos_ver') {
             JError::raiseWarning(304, "May be your version is latest or your update's licence has expired or your current version doesn't exist !");
         } else {
             JError::raiseWarning(304, "May be your update's licence is not exist or your current version doesn't exist !");
         }
         return false;
     }
     $filename = uniqid($this->_pc . '_') . '.zip';
     // if component doesn't contain backup folder so create it!
     if (!JFolder::exists(JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup')) {
         JFolder::create(JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup');
     }
     // Write file zip
     if (!JFile::write(JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup' . DS . $filename, $file->body)) {
         JError::raiseWarning(304, "Can't create zip file");
         return false;
     }
     // do the unpacking of the archive
     $extractdir = JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup' . DS . uniqid($this->_pc . '_');
     $archivename = JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup' . DS . $filename;
     JFolder::create($extractdir);
     $result = JArchive::extract($archivename, $extractdir);
     // Clean file archivename;
     JFile::delete($archivename);
     // Get Instance
     $autoupdate = new AutoupdateHelper($extractdir . DS . 'update.xml', false, true, false, $extractdir, JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup' . DS . uniqid('backup_'));
     return $autoupdate;
 }
Exemple #27
0
 public function postflight($type, $parent)
 {
     $src = $parent->getParent()->getPath('source');
     $_lib_zip = $src . '/library.zip';
     $_lib_gzip = $src . '/library.tar.gz';
     $_dir = JPath::clean(JPATH_ROOT . '/components/com_mijoshop/opencart');
     if (JFile::exists($_lib_zip)) {
         $_file = JPath::clean($_lib_zip);
     } else {
         if (JFile::exists($_lib_gzip)) {
             $_file = JPath::clean($_lib_gzip);
         }
     }
     JArchive::extract($_file, $_dir);
     if (JFile::exists(JPATH_ROOT . '/components/com_mijoshop/library.zip')) {
         JFile::delete(JPATH_ROOT . '/components/com_mijoshop/library.zip');
     }
     if (JFile::exists(JPATH_ROOT . '/components/com_mijoshop/mijoshoplibrary.xml')) {
         JFile::delete(JPATH_ROOT . '/components/com_mijoshop/mijoshoplibrary.xml');
     }
     if (JFile::exists(JPATH_ROOT . '/components/com_mijoshop/script.php')) {
         JFile::delete(JPATH_ROOT . '/components/com_mijoshop/script.php');
     }
 }
 /**
  * Tests extracting bzip2.
  *
  * @group    JArchive
  * @covers    JArchive::extract
  * @return  void
  */
 public function testExtractBzip2()
 {
     if (!is_dir(self::$outputPath)) {
         $this->markTestSkipped("Couldn't create folder.");
         return;
     }
     if (!is_writable(self::$outputPath) || !is_writable(JFactory::getConfig()->get('tmp_path'))) {
         $this->markTestSkipped("Folder not writable.");
         return;
     }
     if (!JArchiveBzip2::isSupported()) {
         $this->markTestSkipped('Bzip2 files can not be extracted.');
         return;
     }
     JArchive::extract(__DIR__ . '/logo.bz2', self::$outputPath . '/logo-bz2.png');
     $this->assertTrue(is_file(self::$outputPath . '/logo-bz2.png'));
     if (is_file(self::$outputPath . '/logo-bz2.png')) {
         unlink(self::$outputPath . '/logo-bz2.png');
     }
 }
Exemple #29
0
 public function extract($path, $filename, $dest = null, $silent = false)
 {
     $success = null;
     if (!$dest) {
         $dest = $path;
     }
     $file = "{$path}/{$filename}";
     $text = '';
     if (file_exists($file)) {
         $success = true;
         if (!JFolder::exists($dest)) {
             $success = JFolder::create($dest);
         }
         if ($success) {
             $success = JArchive::extract($file, $dest);
         }
         if (!$success) {
             $text .= JText::sprintf('COM_KUNENA_INSTALL_EXTRACT_FAILED', $file);
             $text .= $this->_getJoomlaArchiveError($file);
         }
     } else {
         $success = true;
         $text .= JText::sprintf('COM_KUNENA_INSTALL_EXTRACT_MISSING', $file);
     }
     if ($success !== null && !$silent) {
         $this->addStatus(JText::sprintf('COM_KUNENA_INSTALL_EXTRACT_STATUS', $filename), $success, $text);
     }
     return $success;
 }
Exemple #30
0
 /**
  * Helper wrapper method for extract
  *
  * @param   string  $archivename  The name of the archive file
  * @param   string  $extractdir   Directory to unpack into
  *
  * @return  boolean  True for success
  *
  * @see     JArchive::extract()
  * @since   3.4
  * @throws InvalidArgumentException
  */
 public function extract($archivename, $extractdir)
 {
     return JArchive::extract($archivename, $extractdir);
 }