public function onAdd($tpl = null)
 {
     $media_folder = JURI::base() . '../media/com_akeeba/';
     // Get a JSON representation of GUI data
     $json = AkeebaHelperEscape::escapeJS(AEUtilInihelper::getJsonGuiDefinition(), '"\\');
     $this->assignRef('json', $json);
     // Get profile ID
     $profileid = AEPlatform::getInstance()->get_active_profile();
     $this->assign('profileid', $profileid);
     // Get profile name
     $profileName = FOFModel::getTmpInstance('Profiles', 'AkeebaModel')->setId($profileid)->getItem()->description;
     $this->assign('profilename', $profileName);
     // Get the root URI for media files
     $this->assign('mediadir', AkeebaHelperEscape::escapeJS($media_folder . 'theme/'));
     // Are the settings secured?
     if (AEPlatform::getInstance()->get_platform_configuration_option('useencryption', -1) == 0) {
         $this->assign('securesettings', -1);
     } elseif (!AEUtilSecuresettings::supportsEncryption()) {
         $this->assign('securesettings', 0);
     } else {
         JLoader::import('joomla.filesystem.file');
         $filename = JPATH_COMPONENT_ADMINISTRATOR . '/akeeba/serverkey.php';
         if (JFile::exists($filename)) {
             $this->assign('securesettings', 1);
         } else {
             $this->assign('securesettings', 0);
         }
     }
     // Add live help
     AkeebaHelperIncludes::addHelp('config');
 }
Exemplo n.º 2
0
	function display()
	{
		// Toolbar buttons
		JToolBarHelper::title(JText::_('AKEEBA').':: <small>'.JText::_('CONFIGURATION').'</small>','akeeba');
		JToolBarHelper::preferences('com_akeeba', '500', '660');
		JToolBarHelper::spacer();
		JToolBarHelper::apply();
		JToolBarHelper::save();
		JToolBarHelper::cancel();
		JToolBarHelper::spacer();
		
		// Add references to scripts and CSS
		AkeebaHelperIncludes::includeMedia(false);
		$media_folder = JURI::base().'../media/com_akeeba/';

		// Get a JSON representation of GUI data
		$json = AkeebaHelperEscape::escapeJS(AEUtilInihelper::getJsonGuiDefinition(),'"\\');
		$this->assignRef( 'json', $json );

		// Get profile ID
		$profileid = AEPlatform::get_active_profile();
		$this->assign('profileid', $profileid);

		// Get profile name
		akimport('models.profiles',true);
		$model = new AkeebaModelProfiles();
		$model->setId($profileid);
		$profile_data = $model->getProfile();
		$this->assign('profilename', $profile_data->description);

		// Get the root URI for media files
		$this->assign( 'mediadir', AkeebaHelperEscape::escapeJS($media_folder.'theme/') );
		
		// Are the settings secured?
		if( AEPlatform::get_platform_configuration_option('useencryption', -1) == 0 ) {
			$this->assign('securesettings', -1);
		} elseif( !AEUtilSecuresettings::supportsEncryption() ) {
			$this->assign('securesettings', 0);
		} else {
			jimport('joomla.filesystem.file');
			$filename = JPATH_COMPONENT_ADMINISTRATOR.'/akeeba/serverkey.php';
			if(JFile::exists($filename)) {
				$this->assign('securesettings', 1);
			} else {
				$this->assign('securesettings', 0);
			}
		}
		
		// Add live help
		AkeebaHelperIncludes::addHelp();

		parent::display();
	}
 /**
  * Public constructor
  * @return AECoreDomainInstaller
  */
 public function __construct()
 {
     parent::__construct();
     // Fetch the installer settings
     $this->installerSettings = (object) array('installerroot' => 'installation', 'sqlroot' => 'installation/sql', 'databasesini' => 1, 'readme' => 1, 'extrainfo' => 1, 'password' => 0);
     $config = AEFactory::getConfiguration();
     $installerKey = $config->get('akeeba.advanced.embedded_installer');
     $installerDescriptors = AEUtilInihelper::getInstallerList();
     if (array_key_exists($installerKey, $installerDescriptors)) {
         // The selected installer exists, use it
         $this->installerSettings = (object) $installerDescriptors[$installerKey];
     } elseif (array_key_exists('abi', $installerDescriptors)) {
         // The selected installer doesn't exist, but ABI exists; use that instead
         $this->installerSettings = (object) $installerDescriptors['abi'];
     }
     // If no installer was found, we are using "safe defaults", which are
     // pretty much what ABI is using, and hope for the best!
 }
 /**
  * Find where to store the backup files
  * @param $partNumber int The SQL part number, default is 0 (.sql)
  */
 protected function getBackupFilePaths($partNumber = 0)
 {
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__ . " :: Getting temporary file");
     $this->tempFile = AEUtilTempfiles::registerTempFile(dechex(crc32(microtime())) . '.sql');
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__ . " :: Temporary file is {$this->tempFile}");
     // Get the base name of the dump file
     $partNumber = intval($partNumber);
     $baseName = $this->dumpFile;
     if ($partNumber > 0) {
         // The file names are in the format dbname.sql, dbname.s01, dbname.s02, etc
         if (strtolower(substr($baseName, -4)) == '.sql') {
             $baseName = substr($baseName, 0, -4) . '.s' . sprintf('%02u', $partNumber);
         } else {
             $baseName = $baseName . '.s' . sprintf('%02u', $partNumber);
         }
     }
     if (empty($this->installerSettings)) {
         // Fetch the installer settings
         $this->installerSettings = (object) array('installerroot' => 'installation', 'sqlroot' => 'installation/sql', 'databasesini' => 1, 'readme' => 1, 'extrainfo' => 1);
         $config = AEFactory::getConfiguration();
         $installerKey = $config->get('akeeba.advanced.embedded_installer');
         $installerDescriptors = AEUtilInihelper::getInstallerList();
         if (array_key_exists($installerKey, $installerDescriptors)) {
             // The selected installer exists, use it
             $this->installerSettings = (object) $installerDescriptors[$installerKey];
         } elseif (array_key_exists('abi', $installerDescriptors)) {
             // The selected installer doesn't exist, but ABI exists; use that instead
             $this->installerSettings = (object) $installerDescriptors['abi'];
         }
     }
     switch (AEUtilScripting::getScriptingParameter('db.saveasname', 'normal')) {
         case 'output':
             // The SQL file will be stored uncompressed in the output directory
             $statistics = AEFactory::getStatistics();
             $statRecord = $statistics->getRecord();
             $this->saveAsName = $statRecord['absolute_path'];
             break;
         case 'normal':
             // The SQL file will be stored in the SQL root of the archive, as
             // specified by the particular embedded installer's settings
             $this->saveAsName = $this->installerSettings->sqlroot . '/' . $baseName;
             break;
         case 'short':
             // The SQL file will be stored on archive's root
             $this->saveAsName = $baseName;
             break;
     }
     if ($partNumber > 0) {
         AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "AkeebaDomainDBBackup :: Creating new SQL dump part #{$partNumber}");
     }
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "AkeebaDomainDBBackup :: SQL temp file is " . $this->tempFile);
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "AkeebaDomainDBBackup :: SQL file location in archive is " . $this->saveAsName);
 }
Exemplo n.º 5
0
 /**
  * Transforms a JPA archive (containing an installer) to the native archive format
  * of the class. It actually extracts the source JPA in memory and instructs the
  * class to include each extracted file.
  *
  * @param   integer  $index  The index in the source JPA archive's list currently in use
  * @param   integer  $offset The source JPA archive's offset to use
  *
  * @return  boolean  False if an error occurred, true otherwise
  */
 public final function transformJPA($index, $offset)
 {
     static $totalSize = 0;
     // Do we have to open the file?
     if (!$this->_xform_fp) {
         // Get the source path
         $registry = AEFactory::getConfiguration();
         $embedded_installer = $registry->get('akeeba.advanced.embedded_installer');
         // Fetch the name of the installer image
         $installerDescriptors = AEUtilInihelper::getInstallerList();
         $xform_source = AEPlatform::getInstance()->get_installer_images_path() . DIRECTORY_SEPARATOR . 'foobar.jpa';
         // We need this as a "safe fallback"
         if (array_key_exists($embedded_installer, $installerDescriptors)) {
             $packages = $installerDescriptors[$embedded_installer]['package'];
             if (empty($packages)) {
                 // No installer package specified. Pretend we are done!
                 $retArray = array("filename" => '', "data" => '', "index" => 0, "offset" => 0, "skip" => false, "done" => true, "filesize" => 0);
                 return $retArray;
             } else {
                 $packages = explode(',', $packages);
                 $totalSize = 0;
                 $pathPrefix = AEPlatform::getInstance()->get_installer_images_path() . DIRECTORY_SEPARATOR;
                 foreach ($packages as $package) {
                     $filePath = $pathPrefix . $package;
                     $totalSize += (int) @filesize($filePath);
                 }
                 if (count($packages) < $index) {
                     $this->setError(__CLASS__ . ":: Installer package index {$index} not found for embedded installer {$embedded_installer}");
                     return false;
                 }
                 $package = $packages[$index];
                 // A package is specified, use it!
                 $xform_source = $pathPrefix . $package;
             }
         }
         // 2.3: Try to use sane default if the indicated installer doesn't exist
         if (!file_exists($xform_source) && basename($xform_source) != 'angie.jpa') {
             if ($index == 0) {
                 $this->setWarning(__CLASS__ . ":: Selected embedded installer not found, using ANGIE instead");
                 $xform_source = dirname($xform_source) . '/angie.jpa';
             } else {
                 $this->setError(__CLASS__ . ":: Installer package {$xform_source} not found.");
                 return false;
             }
         }
         // Try opening the file
         if (file_exists($xform_source)) {
             $this->_xform_fp = @fopen($xform_source, 'r');
             if ($this->_xform_fp === false) {
                 $this->setError(__CLASS__ . ":: Can't seed archive with installer package " . $xform_source);
                 return false;
             }
         } else {
             $this->setError(__CLASS__ . ":: Installer package " . $xform_source . " does not exist!");
             return false;
         }
     }
     $headerDataLength = 0;
     if (!$offset) {
         // First run detected!
         AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Initializing with JPA package ' . $xform_source);
         $offset = 0;
         // Skip over the header and check no problem exists
         $offset = $this->_xformReadHeader();
         if ($offset === false) {
             $this->setError('JPA package file was not read');
             return false;
             // Oops! The package file doesn't exist or is corrupt
         }
         $headerDataLength = $offset;
     }
     $ret = $this->_xformExtract($offset);
     $ret['index'] = $index;
     if (is_array($ret)) {
         $ret['chunkProcessed'] = $headerDataLength + $ret['offset'] - $offset;
         $offset = $ret['offset'];
         if (!$ret['skip'] && !$ret['done']) {
             AEUtilLogger::WriteLog(_AE_LOG_DEBUG, '  Adding ' . $ret['filename'] . '; Next offset:' . $offset);
             $this->addVirtualFile($ret['filename'], '', $ret['data']);
             if ($this->getError()) {
                 return false;
             }
         } elseif ($ret['done']) {
             $registry = AEFactory::getConfiguration();
             $embedded_installer = $registry->get('akeeba.advanced.embedded_installer');
             $installerDescriptors = AEUtilInihelper::getInstallerList();
             $packages = $installerDescriptors[$embedded_installer]['package'];
             $packages = explode(',', $packages);
             AEUtilLogger::WriteLog(_AE_LOG_DEBUG, '  Done with package ' . $packages[$index]);
             if (count($packages) > $index + 1) {
                 $ret['done'] = false;
                 $ret['index'] = $index + 1;
                 $ret['offset'] = 0;
                 $this->_xform_fp = null;
             } else {
                 AEUtilLogger::WriteLog(_AE_LOG_DEBUG, '  Done with installer seeding.');
             }
         } else {
             $reason = '  Skipping ' . $ret['filename'];
             AEUtilLogger::WriteLog(_AE_LOG_DEBUG, $reason);
         }
     } else {
         $this->setError('JPA extraction returned FALSE. The installer image is corrupt.');
         return false;
     }
     if ($ret['done']) {
         // We are finished! Close the file
         fclose($this->_xform_fp);
         AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Initializing with JPA package has finished');
     }
     $ret['filesize'] = $totalSize;
     return $ret;
 }
Exemplo n.º 6
0
 /**
  * Transforms a JPA archive (containing an installer) to the native archive format
  * of the class. It actually extracts the source JPA in memory and instructs the
  * class to include each extracted file.
  *
  * @param   integer  $offset The source JPA archive's offset to use
  *
  * @return  boolean  False if an error occurred, true otherwise
  */
 public final function transformJPA($offset)
 {
     // Do we have to open the file?
     if (!$this->_xform_fp) {
         // Get the source path
         $registry = AEFactory::getConfiguration();
         $embedded_installer = $registry->get('akeeba.advanced.embedded_installer');
         // Fetch the name of the installer image
         $installerDescriptors = AEUtilInihelper::getInstallerList();
         $xform_source = AEPlatform::getInstance()->get_installer_images_path() . DIRECTORY_SEPARATOR . 'foobar.jpa';
         // We need this as a "safe fallback"
         if (array_key_exists($embedded_installer, $installerDescriptors)) {
             $package = $installerDescriptors[$embedded_installer]['package'];
             if (empty($package)) {
                 // No installer package specified. Pretend we are done!
                 $retArray = array("filename" => '', "data" => '', "offset" => 0, "skip" => false, "done" => true, "filesize" => 0);
                 return $retArray;
             } else {
                 // A package is specified, use it!
                 $xform_source = AEPlatform::getInstance()->get_installer_images_path() . DIRECTORY_SEPARATOR . $package;
             }
         }
         // 2.3: Try to use sane default if the indicated installer doesn't exist
         if (!file_exists($xform_source) && basename($xform_source) != 'abi.jpa') {
             $this->setWarning(__CLASS__ . ":: Selected embedded installer not found, using ABI instead");
             $xform_source = dirname($xform_source) . '/abi.jpa';
         }
         // Try opening the file
         if (file_exists($xform_source)) {
             $this->_xform_fp = @fopen($xform_source, 'r');
             if ($this->_xform_fp === false) {
                 $this->setError(__CLASS__ . ":: Can't seed archive with installer package " . $xform_source);
                 return false;
             }
         } else {
             $this->setError(__CLASS__ . ":: Installer package " . $xform_source . " does not exist!");
             return false;
         }
     }
     if (!$offset) {
         // First run detected!
         AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Initializing with JPA package ');
         $offset = 0;
         // Skip over the header and check no problem exists
         $offset = $this->_xformReadHeader();
         if ($offset === false) {
             $this->setError('JPA package file was not read');
             return false;
             // Oops! The package file doesn't exist or is corrupt
         }
     }
     $ret = $this->_xformExtract($offset);
     if (is_array($ret)) {
         $offset = $ret['offset'];
         if (!$ret['skip'] && !$ret['done']) {
             AEUtilLogger::WriteLog(_AE_LOG_DEBUG, '  Adding ' . $ret['filename'] . '; Next offset:' . $offset);
             $this->addVirtualFile($ret['filename'], '', $ret['data']);
             if ($this->getError()) {
                 return false;
             }
         } else {
             $reason = $ret['done'] ? 'Done' : '  Skipping ' . $ret['filename'];
             AEUtilLogger::WriteLog(_AE_LOG_DEBUG, $reason);
         }
     } else {
         $this->setError('JPA extraction returned FALSE');
         return false;
     }
     if ($ret['done']) {
         // We are finished! Close the file
         fclose($this->_xform_fp);
         AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Initializing with JPA package has finished');
     }
     $ret['filesize'] = isset($xform_source) ? @filesize($xform_source) : 0;
     return $ret;
 }