Beispiel #1
0
	/**
	 * The default layout, shows a list of profiles
	 *
	 */
	function _default()
	{
		// Get reference to profiles model
		$model =& $this->getModel('profiles');

		// Load list of profiles
		$profiles = $model->getProfilesList();

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

		// Get profile name
		$model->setId($profileid);
		$profile_data = $model->getProfile();
		$this->assign('profilename', $profile_data->description);

		// Add toolbar buttons
		JToolBarHelper::back('AKEEBA_CONTROLPANEL', 'index.php?option='.JRequest::getCmd('option'));
		JToolBarHelper::spacer();
		JToolBarHelper::addNew();
		if(version_compare(JVERSION, '1.6.0', 'ge')) {
			JToolBarHelper::custom('copy', 'copy.png', 'copy_f2.png', 'JGLOBAL_BATCH_COPY', false);
		} else {
			JToolBarHelper::custom('copy', 'copy.png', 'copy_f2.png', 'Copy', false);
		}
		JToolBarHelper::spacer();
		JToolBarHelper::deleteList();
		JToolBarHelper::spacer();
	}
Beispiel #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();
	}
Beispiel #3
0
	public function display($tpl = null)
	{
		// Add toolbar buttons
		JToolBarHelper::title(JText::_('AKEEBA').': <small>'.JText::_('VIEWLOG').'</small>','akeeba');
		JToolBarHelper::back('AKEEBA_CONTROLPANEL', 'index.php?option='.JRequest::getCmd('option'));
		JToolBarHelper::spacer();
		$document =& JFactory::getDocument();
		$document->addStyleSheet(JURI::base().'../media/com_akeeba/theme/akeebaui.css?'.AKEEBAMEDIATAG);

		// Add live help
		AkeebaHelperIncludes::addHelp();

		// Get a list of log names
		akimport('models.log',true);
		$model = new AkeebaModelLog();
		$this->assign('logs', $model->getLogList());

		$tag = JRequest::getCmd('tag',null);
		if(empty($tag)) $tag = null;
		$this->assign('tag', $tag);

		// 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);

		AkeebaHelperIncludes::includeMedia(false);

		parent::display($tpl);
	}
Beispiel #4
0
	public function download()
	{
		AEPlatform::load_configuration(AEPlatform::get_active_profile());

		$tag = JRequest::getCmd('tag',null);

		$filename = AEUtilLogger::logName($tag);

		@ob_end_clean(); // In case some braindead plugin spits its own HTML
		header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
		header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
		header("Content-Description: File Transfer");
		header('Content-Type: text/plain');
		header('Content-Disposition: attachment; filename="Akeeba Backup Debug Log.txt"');
		echo "WARNING: Do not copy and paste lines from this file!\r\n";
		echo "You are supposed to ZIP and attach it in your support forum post.\r\n";
		echo "If you fail to do so, your support request will receive minimal priority.\r\n";
		echo "\r\n";
		echo "--- START OF RAW LOG --\r\n";
		@readfile($filename); // The at sign is necessary to skip showing PHP errors if the file doesn't exist or isn't readable for some reason
		echo "--- END OF RAW LOG ---\r\n";
		flush();
		JFactory::getApplication()->close();
	}
Beispiel #5
0
	protected function is_excluded_by_api($test, $root)
	{
		static $filter_switch;
		static $last_backup;

		if(is_null($filter_switch))
		{
			$config =& AEFactory::getConfiguration();
			$filter_switch = AEUtilScripting::getScriptingParameter('filter.incremental',0);
			$filter_switch = ($filter_switch == 1);

			$last_backup = $config->get('volatile.filter.last_backup', null);
			if(is_null($last_backup) && $filter_switch)
			{
				// Get a list of backups on this profile
				$backups = AEPlatform::get_statistics_list(0, 0, AEPlatform::get_active_profile() );

				// Find this backup's ID
				$model =& AEFactory::getStatistics();
				$id = $model->getId();
				if(is_null($id)) $id = -1;

				// Initialise
				jimport('joomla.utilities.date');
				$last_backup = time();
				$now = $last_backup;

				// Find the last time a successful backup with this profile was made
				if(count($backups)) foreach($backups as $backup)
				{
					// Skip the current backup
					if($backup['id'] == $id) continue;

					// Skip non-complete backups
					if($backup['status'] != 'complete') continue;

					$jdate = new JDate($backup['backupstart']);
					$backuptime = $jdate->toUnix();

					$last_backup = $backuptime;
					break;
				}

				if($last_backup == $now) {
					// No suitable backup found; disable this filter
					$config->set('volatile.scripting.incfile.filter.incremental',0);
					$filter_switch = false;
				} else {
					// Cache the last backup timestamp
					$config->set('volatile.filter.last_backup',$last_backup);
				}
			}
		}

		if(!$filter_switch) return false;

		// Get the filesystem path for $root
		$config =& AEFactory::getConfiguration();
		$fsroot = $config->get('volatile.filesystem.current_root','');
		$ds = ($fsroot == '') || ($fsroot == '/') ? '' : DS;
		$filename = $fsroot.$ds.$test;

		// Get the timestamp of the file
		$timestamp = @filemtime($filename);

		// If we could not get this information, include the file in the archive
		if($timestamp === false) return false;

		// Compare it with the last backup timestamp and exclude if it's older than the last backup
		if($timestamp <= $last_backup) {
			//AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Excluding $filename due to incremental backup restrictions");
			return true;
		}

		// No match? Just include the file!
		return false;
	}
Beispiel #6
0
	public function display()
	{
		$task = JRequest::getCmd('task','normal');

		// Add toolbar buttons
		JToolBarHelper::title(JText::_('AKEEBA').': <small>'.JText::_('FSFILTERS').'</small>','akeeba');
		JToolBarHelper::back('AKEEBA_CONTROLPANEL', 'index.php?option='.JRequest::getCmd('option'));
		
		// Add custom submenus
		JSubMenuHelper::addEntry(
			JText::_('FILTERS_LABEL_NORMALVIEW'),
			JURI::base().'index.php?option=com_akeeba&view='.JRequest::getCmd('view').'&task=normal',
			($task == 'normal')
		);
		JSubMenuHelper::addEntry(
			JText::_('FILTERS_LABEL_TABULARVIEW'),
			JURI::base().'index.php?option=com_akeeba&view='.JRequest::getCmd('view').'&task=tabular',
			($task == 'tabular')
		);

		// Add references to scripts and CSS
		AkeebaHelperIncludes::includeMedia(false);
		$media_folder = JURI::base().'../media/com_akeeba/';

		// Get the root URI for media files
		$this->assign( 'mediadir', AkeebaHelperEscape::escapeJS($media_folder.'theme/') );

		// Get a JSON representation of the available roots
		$filters =& AEFactory::getFilters();
		$root_info = $filters->getInclusions('dir');
		$roots = array();
		$options = array();
		if(!empty($root_info))
		{
			// Loop all dir definitions
			foreach($root_info as $dir_definition)
			{
				if(is_null($dir_definition[1]))
				{
					// Site root definition has a null element 1. It is always pushed on top of the stack.
					array_unshift($roots, $dir_definition[0]);
				}
				else
				{
					$roots[] = $dir_definition[0];
				}

				$options[] = JHTML::_('select.option', $dir_definition[0], $dir_definition[0] );
			}
		}
		$site_root = $roots[0];
		$attribs = 'onchange="akeeba_active_root_changed();"';
		$this->assign('root_select', JHTML::_('select.genericlist', $options, 'root', $attribs, 'value', 'text', $site_root, 'active_root') );
		$this->assign('roots', $roots);

		switch($task)
		{
			case 'normal':
			default:
				$tpl = null;

				// Get a JSON representation of the directory data
				$model = $this->getModel();
				$json = json_encode($model->make_listing($site_root, array(), ''));
				$this->assignRef( 'json', $json );
				break;

			case 'tabular':
				$tpl = 'tab';

				// Get a JSON representation of the tabular filter data
				$model = $this->getModel();
				$json = json_encode( $model->get_filters($site_root) );
				$this->assignRef( 'json', $json );

				break;
		}

		// Add live help
		AkeebaHelperIncludes::addHelp();

		// 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);

		parent::display($tpl);
	}
Beispiel #7
0
	/**
	 * Creates a dummy file of a given size. Remember to give the filesize
	 * query parameter in bytes!
	 */
	public function partsize()
	{
		$timer = AEFactory::getTimer();
		$blocks = JRequest::getInt('blocks', 1);
		
		$model = JModel::getInstance('Confwiz','AkeebaModel');
		$result = $model->createTempFile($blocks);

		if($result) {
			// Save the setting
			if($blocks > 200) $blocks = 16383; // Over 25Mb = 2Gb minus 128Kb limit (safe setting for PHP not running on 64-bit Linux)
			$profile_id = AEPlatform::get_active_profile();
			$config = AEFactory::getConfiguration();
			$config->set('engine.archiver.common.part_size', $blocks * 128 * 1024);
			AEPlatform::save_configuration($profile_id);
		}
		// Enforce the min exec time
		$timer->enforce_min_exec_time(false);
		
		return $result;
	}
Beispiel #8
0
	/**
	 * Implements the _run() abstract method
	 */
	protected function _run()
	{
		if( $this->getState() == 'postrun' )
		{
			AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__." :: Already finished");
			$this->setStep('');
			$this->setSubstep('');
			return;
		} else {
			$this->setState('running');
		}

		// Load the version defines
		AEPlatform::load_version_defines();

		$registry =& AEFactory::getConfiguration();

		// Write log file's header
		AEUtilLogger::WriteLog(_AE_LOG_INFO, "--------------------------------------------------------------------------------");
		AEUtilLogger::WriteLog(_AE_LOG_INFO, "Akeeba Backup ".AKEEBA_VERSION.' ('.AKEEBA_DATE.')');
		AEUtilLogger::WriteLog(_AE_LOG_INFO, "Got backup?");
		AEUtilLogger::WriteLog(_AE_LOG_INFO, "--------------------------------------------------------------------------------");
		// PHP configuration variables are tried to be logged only for debug and info log levels
		if ($registry->get('akeeba.basic.log_level') >= _AE_LOG_INFO ) {
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "--- System Information ---" );
			if( function_exists('phpversion'))
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "PHP Version        :" . phpversion() );
			if(function_exists('php_uname'))
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "OS Version         :" . php_uname('s') );
			$db =& AEFactory::getDatabase();
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "DB Version         :" . $db->getVersion() );
			if (isset($_SERVER['SERVER_SOFTWARE'])) {
				$server = $_SERVER['SERVER_SOFTWARE'];
			} else if (($sf = getenv('SERVER_SOFTWARE'))) {
				$server = $sf;
			} else {
				$server = 'n/a';
			}
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "Web Server         :" . $server );
			if(function_exists('php_sapi_name'))
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "PHP Interface      :" . php_sapi_name() );
			AEPlatform::getPlatformVersion( $platform, $version );
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "$platform version    :" . $version );
			if(isset($_SERVER['HTTP_USER_AGENT']))
				AEUtilLogger::WriteLog(_AE_LOG_INFO, "User agent         :" . phpversion() <= "4.2.1" ? getenv( "HTTP_USER_AGENT" ) : $_SERVER['HTTP_USER_AGENT'] );
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "Safe mode          :" . ini_get("safe_mode") );
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "Display errors     :" . ini_get("display_errors") );
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "Error reporting    :" . self::error2string() );
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "Error display      :" . self::errordisplay() );
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "Disabled functions :" . ini_get("disable_functions") );
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "open_basedir restr.:" . ini_get('open_basedir') );
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "Max. exec. time    :" . ini_get("max_execution_time") );
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "Memory limit       :" . ini_get("memory_limit") );
			if(function_exists("memory_get_usage"))
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "Current mem. usage :" . memory_get_usage() );
			if(function_exists("gzcompress")) {
				AEUtilLogger::WriteLog(_AE_LOG_INFO, "GZIP Compression   : available (good)" );
			} else {
				AEUtilLogger::WriteLog(_AE_LOG_INFO, "GZIP Compression   : n/a (no compression)" );
			}
			AEPlatform::log_platform_special_directories();
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "Output directory   :" . $registry->get('akeeba.basic.output_directory') );
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "Temporary directory:" . $registry->get('akeeba.basic.temporary_directory') );
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "--------------------------------------------------------------------------------");
		}

		// Quirks reporting
		$quirks = AEUtilQuirks::get_quirks(true);
		if( !empty($quirks) )
		{
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "Akeeba Backup has detected the following potential problems:" );
			foreach($quirks as $q)
			{
				AEUtilLogger::WriteLog(_AE_LOG_INFO, '- '.$q['code'].' '.$q['description'].' ('.$q['severity'].')' );
			}
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "You probably do not have to worry about them, but you should be aware of them." );
			AEUtilLogger::WriteLog(_AE_LOG_INFO, "--------------------------------------------------------------------------------");
		}

		// Report profile ID
		$profile_id = AEPlatform::get_active_profile();
		AEUtilLogger::WriteLog(_AE_LOG_INFO, "Loaded profile #$profile_id");

		// Get archive name
		AEUtilFilesystem::get_archive_name($relativeArchiveName, $absoluteArchiveName);

		// ==== Stats initialisation ===
		$origin = AEPlatform::get_backup_origin(); // Get backup origin
		$profile_id = AEPlatform::get_active_profile(); // Get active profile

		$registry =& AEFactory::getConfiguration();
		$backupType = $registry->get('akeeba.basic.backup_type');
		AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Backup type is now set to '" . $backupType . "'");

		// Substitute "variables" in the archive name
		$description = AEUtilFilesystem::replace_archive_name_variables($this->description);
		$comment = AEUtilFilesystem::replace_archive_name_variables($this->comment);

		if($registry->get('volatile.writer.store_on_server', true) )
		{
			// Archive files are stored on our server
			$stat_relativeArchiveName = $relativeArchiveName;
			$stat_absoluteArchiveName = $absoluteArchiveName;
		}
		else
		{
			// Archive files are not stored on our server (FTP backup, cloud backup, sent by email, etc)
			$stat_relativeArchiveName = '';
			$stat_absoluteArchiveName = '';
		}

		$kettenrad =& AEFactory::getKettenrad();
		$temp = array(
			'description'	=> $description,
			'comment'		=> $comment,
			'backupstart'	=> AEPlatform::get_timestamp_mysql(),
			'status'		=> 'run',
			'origin'		=> $origin,
			'type'			=> $backupType,
			'profile_id'	=> $profile_id,
			'archivename'	=> $stat_relativeArchiveName,
			'absolute_path'	=> $stat_absoluteArchiveName,
			'multipart'		=> 0,
			'filesexist'	=> 1,
			'tag'			=> $kettenrad->getTag()
		);
		// Save the entry
		$statistics =& AEFactory::getStatistics();
		$statistics->setStatistics($temp);
		if($statistics->getError())
		{
			$this->setError($statistics->getError());
			return;
		}

		$statistics->release_multipart_lock();

		// Initialize the archive.
		if (AEUtilScripting::getScriptingParameter('core.createarchive',true))
		{
			AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Expanded archive file name: " . $absoluteArchiveName);

			AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Initializing archiver engine");
			$archiver =& AEFactory::getArchiverEngine();
			$archiver->initialize($absoluteArchiveName);
			$archiver->setComment($comment); // Add the comment to the archive itself.
			$archiver->propagateToObject($this);
			if($this->getError())
			{
				return;
			}
		}

		$this->setState('postrun');
	}
Beispiel #9
0
	/**
	 * Sends an email to the administrators
	 * @return bool
	 */
	private function mail_administrators()
	{
		$this->setStep('Processing emails to administrators');
		$this->setSubstep('');
		// Skip email for back-end backups
		if(AEPlatform::get_backup_origin() == 'backend' ) return true;

		$must_email = AEPlatform::get_platform_configuration_option('frontend_email_on_finish', 0) != 0;
		if(!$must_email) return true;

		AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Preparing to send e-mail to administrators");

		$email = AEPlatform::get_platform_configuration_option('frontend_email_address', '');
		$email = trim($email);
		if( !empty($email) )
		{
			$emails = array($email);
		}
		else
		{
			$emails = AEPlatform::get_administrator_emails();
		}

		if(!empty($emails))
		{
			// Fetch user's preferences
			$subject = trim(AEPlatform::get_platform_configuration_option('frontend_email_subject',''));
			$body = trim(AEPlatform::get_platform_configuration_option('frontend_email_body',''));

			// Get the statistics
			$statistics =& AEFactory::getStatistics();
			$stat = $statistics->getRecord();
			$parts = AEUtilStatistics::get_all_filenames($stat, false);

			$profile_number = AEPlatform::get_active_profile();
			$profile_name = AEPlatform::get_profile_name($profile_number);
			$parts = AEUtilStatistics::get_all_filenames($stat, false);
			$stat = (object)$stat;
			$num_parts = $stat->multipart;
			if($num_parts == 0) $num_parts = 1; // Non-split archives have a part count of 0
			$parts_list = '';
			if(!empty($parts)) foreach($parts as $file) {
				$parts_list .= "\t".basename($file)."\n";
			}

			// Do we need a default subject?
			if(empty($subject)) {
				// Get the default subject
				$subject = AEPlatform::translate('EMAIL_SUBJECT_OK');
			} else {
				// Post-process the subject
				$subject = AEUtilFilesystem::replace_archive_name_variables($subject);
			}

			// Do we need a default body?
			if(empty($body)) {
				$body = AEPlatform::translate('EMAIL_BODY_OK');
				$info_source = AEPlatform::translate('EMAIL_BODY_INFO');
				$body .= "\n\n" . sprintf($info_source, $profile_number, $num_parts) . "\n\n";
				$body .= $parts_list;
			} else {
				// Post-process the body
				$body = AEUtilFilesystem::replace_archive_name_variables($body);
				$body = str_replace('[PROFILENUMBER]', $profile_number, $body);
				$body = str_replace('[PROFILENAME]', $profile_name, $body);
				$body = str_replace('[PARTCOUNT]', $num_parts, $body);
				$body = str_replace('[FILELIST]', $parts_list, $body);
			}
			// Sometimes $body contains literal \n instead of newlines
			$body = str_replace('\\n',"\n", $body);

			foreach($emails as $email)
			{
				AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Sending email to $email");
				AEPlatform::send_email($email, $subject, $body);
			}
		}

		return true;
	}