/**
  * Creates a new database definition
  * @param string $uuid
  * @param array $data
  * @return bool
  */
 public function setFilter($uuid, $data)
 {
     $filter = AEFactory::getFilterObject('extradirs');
     $success = $filter->set($uuid, $data);
     $filters = AEFactory::getFilters();
     if ($success) {
         $filters->save();
     }
     return array('success' => $success, 'newstate' => false);
 }
Exemplo n.º 2
0
 /**
  * Creates a new regec filter
  * @param string $type Filter type
  * @param string $root The filter's root
  * @param string $string The filter string to remove
  * @return bool True on success
  */
 public function setFilter($type, $root, $string)
 {
     $filter = AEFactory::getFilterObject($type);
     $success = $filter->set($root, $string);
     if ($success) {
         $filters = AEFactory::getFilters();
         $filters->save();
     }
     return $success;
 }
 /**
  * Creates a new database definition
  * @param string $root
  * @param array $data
  * @return bool
  */
 public function setFilter($root, $data)
 {
     $filter = AEFactory::getFilterObject('multidb');
     $success = $filter->set($root, $data);
     $filters = AEFactory::getFilters();
     if ($success) {
         $filters->save();
     }
     return $success;
 }
 public function onBrowse($tpl = null)
 {
     $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);
     $tpl = null;
     // Get a JSON representation of the directory data
     $model = $this->getModel();
     $json = json_encode($model->get_regex_filters($site_root));
     $this->assignRef('json', $json);
     // Add live help
     AkeebaHelperIncludes::addHelp('regexfsfilter');
     // Get profile ID
     $profileid = AEPlatform::getInstance()->get_active_profile();
     $this->assign('profileid', $profileid);
     // Get profile name
     $pmodel = FOFModel::getAnInstance('Profiles', 'AkeebaModel');
     $pmodel->setId($profileid);
     $profile_data = $pmodel->getItem();
     $this->assign('profilename', $profile_data->description);
     return true;
 }
Exemplo n.º 5
0
 /**
  * Populates database_list with the list of databases in the settings
  *
  */
 private function populate_database_list()
 {
     // Get database inclusion filters
     $filters = AEFactory::getFilters();
     $this->database_list = $filters->getInclusions('db');
     // Error propagation
     $this->propagateFromObject($filters);
     if ($this->getError()) {
         return false;
     }
     if (AEUtilScripting::getScriptingParameter('db.skipextradb', 0)) {
         // On database only backups we prune extra databases
         AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__ . " :: Adding only main database");
         if (count($this->database_list) > 1) {
             $this->database_list = array_slice($this->database_list, 0, 1);
         }
     }
 }
Exemplo n.º 6
0
 /**
  * Resets the filters
  * @param string $root Root directory
  * @return array
  */
 public function resetFilters($root)
 {
     // Get a reference to the global Filters object
     $filters = AEFactory::getFilters();
     $filter = AEFactory::getFilterObject('directories');
     $filter->reset($root);
     $filter = AEFactory::getFilterObject('files');
     $filter->reset($root);
     $filter = AEFactory::getFilterObject('skipdirs');
     $filter->reset($root);
     $filter = AEFactory::getFilterObject('skipfiles');
     $filter->reset($root);
     $filters->save();
     return $this->make_listing($root);
 }
Exemplo n.º 7
0
 /**
  * Populates the _tables array with the metadata of each table
  */
 private function get_tables_data_without_dependencies()
 {
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__ . " :: Pushing table data (without dependency tracking)");
     // Reset internal tables
     $this->tables_data = array();
     $this->dependencies = array();
     // Get filters and filter root
     $registry = AEFactory::getConfiguration();
     $root = $registry->get('volatile.database.root', '[SITEDB]');
     $filters = AEFactory::getFilters();
     foreach ($this->table_name_map as $table_name => $table_abstract) {
         $new_entry = array('type' => 'table', 'dump_records' => true);
         // Table Data Filter - skip dumping table contents of filtered out tables
         if ($filters->isFiltered($table_abstract, $root, 'dbobject', 'content')) {
             $new_entry['dump_records'] = false;
         }
         $this->tables_data[$table_name] = $new_entry;
         $this->tables[] = $table_name;
     }
     // foreach
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__ . " :: Got table list");
 }
Exemplo n.º 8
0
 public function onBrowse($tpl = null)
 {
     $model = $this->getModel();
     $task = $model->getState('browse_task', 'normal');
     // Add custom submenus
     $toolbar = F0FToolbar::getAnInstance($this->input->get('option', 'com_foobar', 'cmd'), $this->config);
     $toolbar->appendLink(JText::_('FILTERS_LABEL_NORMALVIEW'), JURI::base() . 'index.php?option=com_akeeba&view=fsfilter&task=normal', $task == 'normal');
     $toolbar->appendLink(JText::_('FILTERS_LABEL_TABULARVIEW'), JURI::base() . 'index.php?option=com_akeeba&view=fsfilter&task=tabular', $task == 'tabular');
     $media_folder = JURI::base() . '../media/com_akeeba/';
     // Get the root URI for media files
     $this->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->root_select = JHTML::_('select.genericlist', $options, 'root', $attribs, 'value', 'text', $site_root, 'active_root');
     $this->roots = $roots;
     switch ($task) {
         case 'normal':
         default:
             $this->setLayout('default');
             // Get a JSON representation of the directory data
             $model = $this->getModel();
             $json = json_encode($model->make_listing($site_root, array(), ''));
             $this->json = $json;
             break;
         case 'tabular':
             $this->setLayout('tabular');
             // Get a JSON representation of the tabular filter data
             $model = $this->getModel();
             $json = json_encode($model->get_filters($site_root));
             $this->json = $json;
             break;
     }
     // Add live help
     AkeebaHelperIncludes::addHelp('fsfilter');
     // Get profile ID
     $profileid = AEPlatform::getInstance()->get_active_profile();
     $this->profileid = $profileid;
     // Get profile name
     $pmodel = F0FModel::getAnInstance('Profiles', 'AkeebaModel');
     $pmodel->setId($profileid);
     $profile_data = $pmodel->getItem();
     $this->profilename = $profile_data->description;
     return true;
 }
 public function toggleTemplateFilter($root, $item)
 {
     $filter = AEFactory::getFilterObject('templates');
     $filter->toggle($root, $item, $newStatus);
     $filters = AEFactory::getFilters();
     $filters->save();
 }
Exemplo n.º 10
0
 /**
  * Scans a directory for files and directories, updating the directory_list and file_list
  * private fields
  *
  * @return bool True if more work has to be done, false if the dirextory stack is empty
  */
 private function scan_directory()
 {
     // Are we supposed to scan for more files?
     if ($this->done_scanning) {
         return true;
     }
     // Get the next directory to scan, if the folders and files of the last directory
     // have been scanned.
     if ($this->done_subdir_scanning && $this->done_file_scanning) {
         if (count($this->directory_list) == 0) {
             // No directories left to scan
             return false;
         } else {
             // Get and remove the last entry from the $directory_list array
             $this->current_directory = array_pop($this->directory_list);
             $this->setStep($this->current_directory);
             $this->done_subdir_scanning = false;
             $this->done_file_scanning = false;
             $this->processed_files_counter = 0;
         }
     }
     $engine = AEFactory::getScanEngine();
     // Break directory components
     if (AEFactory::getConfiguration()->get('akeeba.platform.override_root', 0)) {
         $siteroot = AEFactory::getConfiguration()->get('akeeba.platform.newroot', '[SITEROOT]');
     } else {
         $siteroot = '[SITEROOT]';
     }
     $root = $this->root;
     if ($this->root == $siteroot) {
         $translated_root = AEUtilFilesystem::translateStockDirs($siteroot, true);
     } else {
         $translated_root = $this->remove_path_prefix;
     }
     $dir = AEUtilFilesystem::TrimTrailingSlash($this->current_directory);
     if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
         $translated_root = AEUtilFilesystem::TranslateWinPath($translated_root);
         $dir = AEUtilFilesystem::TranslateWinPath($dir);
     }
     if (substr($dir, 0, strlen($translated_root)) == $translated_root) {
         $dir = substr($dir, strlen($translated_root));
     } elseif (in_array(substr($translated_root, -1), array('/', '\\'))) {
         $new_translated_root = rtrim($translated_root, '/\\');
         if (substr($dir, 0, strlen($new_translated_root)) == $new_translated_root) {
             $dir = substr($dir, strlen($new_translated_root));
         }
     }
     if (substr($dir, 0, 1) == '/') {
         $dir = substr($dir, 1);
     }
     // get a filters instance
     $filters = AEFactory::getFilters();
     // Scan subdirectories, if they have not yet been scanned.
     if (!$this->done_subdir_scanning) {
         // Apply DEF (directory exclusion filters)
         // Note: the !empty($dir) prevents the site's root from being filtered out
         if ($filters->isFiltered($dir, $root, 'dir', 'all') && !empty($dir)) {
             AEUtilLogger::WriteLog(_AE_LOG_INFO, "Skipping directory " . $this->current_directory);
             $this->done_subdir_scanning = true;
             $this->done_file_scanning = true;
             return true;
         }
         // Apply Skip Contained Directories Filters
         if ($filters->isFiltered($dir, $root, 'dir', 'children')) {
             AEUtilLogger::WriteLog(_AE_LOG_INFO, "Skipping subdirectories of directory " . $this->current_directory);
             $this->done_subdir_scanning = true;
         } else {
             AEUtilLogger::WriteLog(_AE_LOG_INFO, "Scanning directories of " . $this->current_directory);
             // Get subdirectories
             $subdirs = $engine->getFolders($this->current_directory);
             // Error propagation
             $this->propagateFromObject($engine);
             // If the list contains "too many" items, please break this step!
             $registry = AEFactory::getConfiguration();
             if ($registry->get('volatile.breakflag', false)) {
                 // Log the step break decision, for debugging reasons
                 AEUtilLogger::WriteLog(_AE_LOG_INFO, "Large directory " . $this->current_directory . " while scanning for subdirectories; I will resume scanning in next step.");
                 // Return immediately, marking that we are not done yet!
                 return true;
             }
             // Error control
             if ($this->getError()) {
                 return false;
             }
             if (!empty($subdirs) && is_array($subdirs)) {
                 $registry = AEFactory::getConfiguration();
                 $dereferencesymlinks = $registry->get('engine.archiver.common.dereference_symlinks');
                 if ($dereferencesymlinks) {
                     // Treat symlinks to directories as actual directories
                     foreach ($subdirs as $subdir) {
                         $this->directory_list[] = $subdir;
                         $this->progressAddFolder();
                     }
                 } else {
                     // Treat symlinks to directories as simple symlink files (ONLY WORKS WITH CERTAIN ARCHIVERS!)
                     foreach ($subdirs as $subdir) {
                         if (is_link($subdir)) {
                             // Symlink detected; apply file filters to it
                             if (empty($dir)) {
                                 $dirSlash = $dir;
                             } else {
                                 $dirSlash = $dir . '/';
                             }
                             $check = $dir . basename($subdir);
                             if (_AKEEBA_IS_WINDOWS) {
                                 $check = AEUtilFilesystem::TranslateWinPath($check);
                             }
                             // Do I need this? $dir contains a path relative to the root anyway...
                             $check = ltrim(str_replace($translated_root, '', $check), '/');
                             if ($filters->isFiltered($check, $root, 'file', 'all')) {
                                 AEUtilLogger::WriteLog(_AE_LOG_INFO, "Skipping directory symlink " . $check);
                             } else {
                                 AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Adding symlink to folder as file: ' . $check);
                                 $this->file_list[] = $subdir;
                                 $this->progressAddFile();
                             }
                         } else {
                             $this->directory_list[] = $subdir;
                             $this->progressAddFolder();
                         }
                     }
                 }
             }
         }
         $this->done_subdir_scanning = true;
         return true;
         // Break operation
     }
     // If we are here, we have not yet scanned the directory for files, so there
     // is no need to test for done_file_scanning (saves a tiny amount of CPU time)
     // Apply Skipfiles
     if ($filters->isFiltered($dir, $root, 'dir', 'content')) {
         AEUtilLogger::WriteLog(_AE_LOG_INFO, "Skipping files of directory " . $this->current_directory);
         // Try to find and include .htaccess and index.htm(l) files
         // # Fix 2.4: Do not add DIRECTORY_SEPARATOR if we are on the site's root and it's an empty string
         $ds = $this->current_directory == '' || $this->current_directory == '/' ? '' : DIRECTORY_SEPARATOR;
         $checkForTheseFiles = array($this->current_directory . $ds . '.htaccess', $this->current_directory . $ds . 'index.html', $this->current_directory . $ds . 'index.htm', $this->current_directory . $ds . 'robots.txt');
         $this->processed_files_counter = 0;
         foreach ($checkForTheseFiles as $fileName) {
             if (@file_exists($fileName)) {
                 // Fix 3.3 - We have to also put them through other filters, ahem!
                 if (!$filters->isFiltered($fileName, $root, 'file', 'all')) {
                     $this->file_list[] = $fileName;
                     $this->processed_files_counter++;
                 }
             }
         }
         $this->done_file_scanning = true;
     } else {
         AEUtilLogger::WriteLog(_AE_LOG_INFO, "Scanning files of " . $this->current_directory);
         // Get file listing
         $fileList = $engine->getFiles($this->current_directory);
         // Error propagation
         $this->propagateFromObject($engine);
         // If the list contains "too many" items, please break this step!
         $registry = AEFactory::getConfiguration();
         if ($registry->get('volatile.breakflag', false)) {
             // Log the step break decision, for debugging reasons
             AEUtilLogger::WriteLog(_AE_LOG_INFO, "Large directory " . $this->current_directory . " while scanning for files; I will resume scanning in next step.");
             // Return immediately, marking that we are not done yet!
             return true;
         }
         // Error control
         if ($this->getError()) {
             return false;
         }
         $this->processed_files_counter = 0;
         if ($fileList === false) {
             // A non-browsable directory; however, it seems that I never get FALSE reported here?!
             $this->setWarning('Unreadable directory ' . $this->current_directory);
         } else {
             if (is_array($fileList) && !empty($fileList)) {
                 // Add required trailing slash to $dir
                 if (!empty($dir)) {
                     $dir .= '/';
                 }
                 // Scan all directory entries
                 foreach ($fileList as $fileName) {
                     $check = $dir . basename($fileName);
                     if (_AKEEBA_IS_WINDOWS) {
                         $check = AEUtilFilesystem::TranslateWinPath($check);
                     }
                     // Do I need this? $dir contains a path relative to the root anyway...
                     $check = ltrim(str_replace($translated_root, '', $check), '/');
                     $skipThisFile = $filters->isFiltered($check, $root, 'file', 'all');
                     if ($skipThisFile) {
                         AEUtilLogger::WriteLog(_AE_LOG_INFO, "Skipping file {$fileName}");
                     } else {
                         $this->file_list[] = $fileName;
                         $this->processed_files_counter++;
                         $this->progressAddFile();
                     }
                 }
                 // end foreach
             }
             // end if
         }
         // end filelist not false
         $this->done_file_scanning = true;
     }
     // Check to see if there were no contents of this directory added to our search list
     if ($this->processed_files_counter == 0) {
         $archiver = AEFactory::getArchiverEngine();
         if ($this->current_directory != $this->remove_path_prefix) {
             $archiver->addFile($this->current_directory, $this->remove_path_prefix, $this->path_prefix);
         }
         // Error propagation
         $this->propagateFromObject($archiver);
         if ($this->getError()) {
             return false;
         }
         AEUtilLogger::WriteLog(_AE_LOG_INFO, "Empty directory " . $this->current_directory);
         unset($archiver);
         $this->done_scanning = false;
         // Because it was an empty dir $file_list is empty and we have to scan for more files
     } else {
         // Next up, add the files to the archive!
         $this->done_scanning = true;
     }
     // We're done listing the contents of this directory
     unset($engine);
     return true;
 }
Exemplo n.º 11
0
 /**
  * Reverse engineers the View definitions of this database
  *
  * @param   AEAbstractDriver  $dbi  Database connection to INFORMATION_SCHEMA
  */
 protected function reverse_engineer_views(&$dbi)
 {
     // @TODO - THIS IS NOT PORTED TO SQL SERVER YET!
     $schema_name = $this->database;
     $sql = 'SELECT * FROM `views` WHERE `table_schema` = ' . $dbi->quote($schema_name);
     $dbi->setQuery($sql);
     $all_views = $dbi->loadObjectList();
     $registry = AEFactory::getConfiguration();
     $root = $registry->get('volatile.database.root', '[SITEDB]');
     // If we have filters, make sure the tables pass the filtering
     $filters = AEFactory::getFilters();
     // First pass: populate the table_name_map
     if (!empty($all_views)) {
         foreach ($all_views as $table_object) {
             // Extract the table name
             $table_name = $table_object->TABLE_NAME;
             // Filter and convert
             if (substr($table_name, 0, 3) == '#__') {
                 AEUtilLogger::WriteLog(_AE_LOG_WARNING, __CLASS__ . " :: Table {$table_name} has a prefix of #__. This would cause restoration errors; table skipped.");
                 continue;
             }
             $table_abstract = $this->getAbstract($table_name);
             if (substr($table_abstract, 0, 4) != 'bak_') {
                 // Apply exclusion filters
                 if (!$filters->isFiltered($table_abstract, $root, 'dbobject', 'all')) {
                     AEUtilLogger::WriteLog(_AE_LOG_INFO, __CLASS__ . " :: Adding {$table_name} (internal name {$table_abstract})");
                     $this->table_name_map[$table_name] = $table_abstract;
                 } else {
                     AEUtilLogger::WriteLog(_AE_LOG_INFO, __CLASS__ . " :: Skipping {$table_name} (internal name {$table_abstract})");
                     continue;
                 }
             } else {
                 AEUtilLogger::WriteLog(_AE_LOG_INFO, __CLASS__ . " :: Backup table {$table_name} automatically skipped.");
                 continue;
             }
         }
     }
     // Second pass: get the create commands
     if (!empty($all_views)) {
         foreach ($all_views as $table_object) {
             // Extract the table name
             $table_name = $table_object->TABLE_NAME;
             if (!in_array($table_name, $this->table_name_map)) {
                 // Skip any views which have been filtered out
                 continue;
             }
             $table_abstract = $this->getAbstract($table_name);
             // Still here? The view is added. We now have to store its
             // create command, dependency info and so on
             $new_entry = array('type' => 'view', 'dump_records' => false);
             $dependencies = array();
             $table_sql = 'CREATE OR REPLACE VIEW `' . $table_name . '` AS ' . $table_object->VIEW_DEFINITION;
             $old_table_sql = $table_sql;
             foreach ($this->table_name_map as $ref_normal => $ref_abstract) {
                 if ($pos = strpos($table_sql, "`{$ref_normal}`")) {
                     // Add a reference hit
                     $this->dependencies[$ref_normal][] = $table_name;
                     // Add the dependency to this table's metadata
                     $dependencies[] = $ref_normal;
                     // Do the replacement
                     $table_sql = str_replace("`{$ref_normal}`", "`{$ref_abstract}`", $table_sql);
                 }
             }
             // On DB only backup we don't want any replacing to take place, do we?
             if (!AEUtilScripting::getScriptingParameter('db.abstractnames', 1)) {
                 $table_sql = $old_table_sql;
             }
             // Replace newlines with spaces
             $table_sql = str_replace("\n", " ", $table_sql) . ";\n";
             $table_sql = str_replace("\r", " ", $table_sql);
             $table_sql = str_replace("\t", " ", $table_sql);
             $new_entry['create'] = $table_sql;
             $new_entry['dependencies'] = $dependencies;
             $this->tables_data[$table_name] = $new_entry;
         }
     }
 }
 /**
  * Implements the _finalize() abstract method
  *
  */
 protected function _finalize()
 {
     static $addedExtraSQL = false;
     // This makes sure that we don't re-add the extra SQL if the archiver needed more time
     // to include our file in the archive...
     if (!$addedExtraSQL) {
         AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Adding any extra SQL statements imposed by the filters");
         $filters = AEFactory::getFilters();
         $this->writeline($filters->getExtraSQL($this->databaseRoot));
     }
     // Close the file pointer (otherwise the SQL file is left behind)
     $this->closeFile();
     // If we are not just doing a main db only backup, add the SQL file to the archive
     $finished = true;
     $configuration = AEFactory::getConfiguration();
     if (AEUtilScripting::getScriptingParameter('db.saveasname', 'normal') != 'output') {
         $archiver = AEFactory::getArchiverEngine();
         $configuration = AEFactory::getConfiguration();
         if ($configuration->get('volatile.engine.archiver.processingfile', false)) {
             // We had already started archiving the db file, but it needs more time
             AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Continuing adding the SQL dump to the archive");
             $archiver->addFile(null, null, null);
             if ($this->getError()) {
                 return;
             }
             $finished = !$configuration->get('volatile.engine.archiver.processingfile', false);
         } else {
             // We have to add the dump file to the archive
             AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Adding the final SQL dump to the archive");
             $archiver->addFileRenamed($this->tempFile, $this->saveAsName);
             if ($this->getError()) {
                 return;
             }
             $finished = !$configuration->get('volatile.engine.archiver.processingfile', false);
         }
     } else {
         // We just have to move the dump file to its final destination
         AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Moving the SQL dump to its final location");
         $result = AEPlatform::getInstance()->move($this->tempFile, $this->saveAsName);
         if (!$result) {
             $this->setError('Could not move the SQL dump to its final location');
         }
     }
     // Make sure that if the archiver needs more time to process the file we can supply it
     if ($finished) {
         AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Removing temporary file of final SQL dump");
         AEUtilTempfiles::unregisterAndDeleteTempFile($this->tempFile, true);
         if ($this->getError()) {
             return;
         }
         $this->setState('finished');
     }
 }
Exemplo n.º 13
0
 /**
  * Returns a list of filter strings for the given root. Used by MySQLDump engine.
  *
  * @param string $root
  *
  * @return array
  */
 public final function getFilters($root)
 {
     $dummy = array();
     if (!$this->enabled) {
         return $dummy;
     }
     switch ($this->method) {
         default:
         case 'api':
             // API filters never have a list
             return $dummy;
             break;
         case 'direct':
         case 'regex':
             // Get a local reference of the filter data, if necessary
             if (is_null($this->filter_data)) {
                 $filters = AEFactory::getFilters();
                 $this->filter_data = $filters->getFilterData($this->filter_name);
             }
             if (is_null($root)) {
                 // When NULL is passed as the root, we return all roots
                 return $this->filter_data;
             } elseif (array_key_exists($root, $this->filter_data)) {
                 // The root exists, return its data
                 return $this->filter_data[$root];
             } else {
                 // The root doesn't exist, return an empty array
                 return $dummy;
             }
             break;
     }
 }
Exemplo n.º 14
0
 /**
  * Steps the files scanning of the current directory
  *
  * @return  boolean  True on success, false on fatal error
  */
 private function scanFiles()
 {
     $engine = AEFactory::getScanEngine();
     list($root, $translated_root, $dir) = $this->getCleanDirectoryComponents();
     // Get a filters instance
     $filters = AEFactory::getFilters();
     if (is_null($this->getFiles_position)) {
         AEUtilLogger::WriteLog(_AE_LOG_INFO, "Scanning files of " . $this->current_directory);
         $this->processed_files_counter = 0;
     } else {
         AEUtilLogger::WriteLog(_AE_LOG_INFO, "Resuming scanning files of " . $this->current_directory);
     }
     // Get file listing
     $fileList = $engine->getFiles($this->current_directory, $this->getFiles_position);
     // Error propagation
     $this->propagateFromObject($engine);
     // If the list contains "too many" items, please break this step!
     if (AEFactory::getConfiguration()->get('volatile.breakflag', false)) {
         // Log the step break decision, for debugging reasons
         AEUtilLogger::WriteLog(_AE_LOG_INFO, "Large directory " . $this->current_directory . " while scanning for files; I will resume scanning in next step.");
         // Return immediately, marking that we are not done yet!
         return true;
     }
     // Error control
     if ($this->getError()) {
         return false;
     }
     // Do I have an unreadable directory?
     if ($fileList === false) {
         $this->setWarning('Unreadable directory ' . $this->current_directory);
         $this->done_file_scanning = true;
     } else {
         if (is_array($fileList) && !empty($fileList)) {
             // Add required trailing slash to $dir
             if (!empty($dir)) {
                 $dir .= '/';
             }
             // Scan all directory entries
             foreach ($fileList as $fileName) {
                 $check = $dir . basename($fileName);
                 if (_AKEEBA_IS_WINDOWS) {
                     $check = AEUtilFilesystem::TranslateWinPath($check);
                 }
                 // Do I need this? $dir contains a path relative to the root anyway...
                 $check = ltrim(str_replace($translated_root, '', $check), '/');
                 $byFilter = '';
                 $skipThisFile = $filters->isFilteredExtended($check, $root, 'file', 'all', $byFilter);
                 if ($skipThisFile) {
                     AEUtilLogger::WriteLog(_AE_LOG_INFO, "Skipping file {$fileName} (filter: {$byFilter})");
                 } else {
                     $this->file_list[] = $fileName;
                     $this->processed_files_counter++;
                     $this->progressAddFile();
                 }
             }
         }
     }
     // If the scanner engine nullified the next position we are done
     // scanning for files
     if (is_null($this->getFiles_position)) {
         $this->done_file_scanning = true;
     }
     // If the directory was genuinely empty we will have to add an empty
     // directory entry in the archive, otherwise this directory will never
     // be restored.
     if ($this->done_file_scanning && $this->processed_files_counter == 0) {
         AEUtilLogger::WriteLog(_AE_LOG_INFO, "Empty directory " . $this->current_directory);
         $archiver = AEFactory::getArchiverEngine();
         if ($this->current_directory != $this->remove_path_prefix) {
             $archiver->addFile($this->current_directory, $this->remove_path_prefix, $this->path_prefix);
         }
         // Error propagation
         $this->propagateFromObject($archiver);
         // Check for errors
         if ($this->getError()) {
             return false;
         }
         unset($archiver);
     }
     return true;
 }
Exemplo n.º 15
0
 /**
  * Resets the filters
  * @param string $root Root directory
  * @return array
  */
 public function reset($root)
 {
     // Get a reference to the global Filters object
     $filters =& AEFactory::getFilters();
     $filter =& AEFactory::getFilterObject('tables');
     $filter->reset($root);
     $filter =& AEFactory::getFilterObject('tabledata');
     $filter->reset($root);
     $filters->save();
     return $this->make_listing($root);
 }
Exemplo n.º 16
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);
	}