예제 #1
0
 /**
  * Processes the install by uploading
  *
  * @since	1.0
  * @access	public
  * @param	null
  * @return	null
  *
  * @author	Mark Lee <*****@*****.**>
  **/
 public function installFromUpload()
 {
     // Check for request forgeries.
     FD::checkToken();
     $package = $this->input->files->get('package');
     // Test for empty packages.
     if (!isset($package['tmp_name']) || !$package['tmp_name']) {
         $this->view->setMessage('COM_EASYSOCIAL_APPS_PLEASE_UPLOAD_INSTALLER', SOCIAL_MSG_ERROR);
         return $this->view->install();
     }
     $source = $package['tmp_name'];
     $jConfig = ES::config('joomla');
     // Construct the destination path
     $destination = $jConfig->getValue('tmp_path') . '/' . $package['name'];
     // Get the installer library
     $installer = ES::get('Installer');
     // Now try to upload the installer
     $state = $installer->upload($source, $destination);
     if (!$state) {
         $this->view->setMessage('COM_EASYSOCIAL_APPS_UNABLE_TO_COPY_UPLOADED_FILE', SOCIAL_MSG_ERROR);
         return $this->view->install();
     }
     // Unpack the archive.
     $path = $installer->extract($destination);
     // When something went wrong with the installation, just display the error
     if ($path === false) {
         $error = ES::get('Errors')->getErrors('installer.extract');
         $this->info->set($error, SOCIAL_MSG_ERROR);
         $this->app->redirect('index.php?option=com_easysocial&view=applications&layout=error');
         return $this->app->close();
     }
     return $this->installFromDirectory($path);
 }