Exemplo n.º 1
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 $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);
 }
 /**
  * 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;
 }
Exemplo n.º 4
0
 private function createPluginFilters()
 {
     // Base plugins path
     $plugins_path = 'plugins';
     // Get all plug-in filters
     $filter = AEFactory::getFilterObject('plugins');
     $types = $filter->getFilters(null);
     if (!empty($types)) {
         // Loop all plug-in types
         foreach ($types as $type => $items) {
             if (!empty($items)) {
                 // Base path for this plugin type
                 $base_path = $plugins_path . '/' . $type;
                 // Loop all plugins of this type and add a directory exclusion
                 foreach ($items as $item) {
                     $this->set('[SITEROOT]', $base_path . '/' . $item);
                 }
             }
         }
     }
 }
Exemplo n.º 5
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);
 }
 public function toggleTemplateFilter($root, $item)
 {
     $filter = AEFactory::getFilterObject('templates');
     $filter->toggle($root, $item, $newStatus);
     $filters = AEFactory::getFilters();
     $filters->save();
 }
Exemplo n.º 7
0
 /**
  * Public constructor, loads filter data and filter classes
  */
 public final function __construct()
 {
     static $initializing = false;
     parent::__construct();
     // Call parent's constructor
     // Load filter data from platform's database
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Fetching filter data from database');
     $this->filter_registry =& AEPlatform::getInstance()->load_filters();
     // Load platform, plugin and core filters
     $this->filters = array();
     $locations = array(AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'platform' . DIRECTORY_SEPARATOR . AKEEBAPLATFORM . DIRECTORY_SEPARATOR . 'filters', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'filters', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'filters');
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Loading filters');
     foreach ($locations as $folder) {
         $is_platform = $folder == AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'platform' . DIRECTORY_SEPARATOR . AKEEBAPLATFORM . DIRECTORY_SEPARATOR . 'filters';
         $files = AEUtilScanner::getFiles($folder);
         if ($files === false) {
             continue;
         }
         // Skip inexistent folders
         if (empty($files)) {
             continue;
         }
         // Skip no-match folders
         // Loop all files
         foreach ($files as $file) {
             if (substr($file, -4) != '.php') {
                 continue;
             }
             // Skip non-PHP files
             if (in_array(substr($file, 0, 1), array('.', '_'))) {
                 continue;
             }
             // Skip filter files starting with dot or dash
             $filter_name = ($is_platform ? 'Platform' : '') . ucfirst(basename($file, '.php'));
             // Extract filter base name
             if (array_key_exists($filter_name, $this->filters)) {
                 continue;
             }
             // Skip already loaded filters
             AEUtilLogger::WriteLog(_AE_LOG_DEBUG, '-- Loading filter ' . $filter_name);
             $this->filters[$filter_name] =& AEFactory::getFilterObject($filter_name);
             // Add the filter
         }
     }
     // Load platform, plugin and core stacked filters
     $locations = array(AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'platform' . DIRECTORY_SEPARATOR . AKEEBAPLATFORM . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack');
     $config =& AEFactory::getConfiguration();
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Loading optional filters');
     foreach ($locations as $folder) {
         $is_platform = $folder == AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'platform' . DIRECTORY_SEPARATOR . AKEEBAPLATFORM . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack';
         $files = AEUtilScanner::getFiles($folder);
         if ($files === false) {
             continue;
         }
         // Skip inexistent folders
         if (empty($files)) {
             continue;
         }
         // Skip no-match folders
         // Loop all files
         foreach ($files as $file) {
             if (substr($file, -4) != '.php') {
                 continue;
             }
             // Skip non-PHP files
             $bare_name = strtolower(basename($file, '.php'));
             $filter_name = 'Stack' . ($is_platform ? 'Platform' : '') . ucfirst(basename($file, '.php'));
             // Extract filter base name
             if (array_key_exists($filter_name, $this->filters)) {
                 continue;
             }
             // Skip already loaded filters
             if (!file_exists(substr($file, 0, -4) . '.ini')) {
                 continue;
             }
             // Make sure the INI file also exists
             $key = "core.filters.{$bare_name}.enabled";
             if ($config->get($key, 0)) {
                 AEUtilLogger::WriteLog(_AE_LOG_DEBUG, '-- Loading optional filter ' . $filter_name);
                 $this->filters[$filter_name] =& AEFactory::getFilterObject($filter_name);
                 // Add the filter
             }
         }
     }
 }
Exemplo n.º 8
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.º 9
0
 /**
  * Public constructor, loads filter data and filter classes
  */
 public final function __construct()
 {
     static $initializing = false;
     parent::__construct();
     // Call parent's constructor
     // Load filter data from platform's database
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Fetching filter data from database');
     $this->filter_registry = AEPlatform::getInstance()->load_filters();
     // Load platform, plugin and core filters
     $this->filters = array();
     $locations = array(AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'filters', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'filters');
     $platform_paths = AEPlatform::getInstance()->getPlatformDirectories();
     foreach ($platform_paths as $p) {
         $locations[] = $p . '/filters';
     }
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Loading filters');
     foreach ($locations as $folder) {
         $is_platform = $this->isPlatformDirectory($folder);
         $files = AEUtilScanner::getFiles($folder);
         if ($files === false) {
             continue;
         }
         // Skip inexistent folders
         if (empty($files)) {
             continue;
         }
         // Skip no-match folders
         // Loop all files
         foreach ($files as $file) {
             if (substr($file, -4) != '.php') {
                 continue;
                 // Skip non-PHP files
             }
             if (in_array(substr($file, 0, 1), array('.', '_'))) {
                 continue;
                 // Skip filter files starting with dot or dash
             }
             // Some hosts copy .ini and .php files, renaming them (ie foobar.1.php)
             // We need to exclude them, otherwise we'll get a fatal error for declaring the same class twice
             $bare_name = strtolower(basename($file, '.php'));
             if (preg_match('/[^a-z0-9]/', $bare_name)) {
                 continue;
             }
             $filter_name = ($is_platform ? 'Platform' : '') . ucfirst(basename($file, '.php'));
             // Extract filter base name
             if (array_key_exists($filter_name, $this->filters)) {
                 continue;
                 // Skip already loaded filters
             }
             AEUtilLogger::WriteLog(_AE_LOG_DEBUG, '-- Loading filter ' . $filter_name);
             $this->filters[$filter_name] = AEFactory::getFilterObject($filter_name);
             // Add the filter
         }
     }
     // Load platform, plugin and core stacked filters
     $locations = array(AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack');
     $platform_paths = AEPlatform::getInstance()->getPlatformDirectories();
     $platform_stack_paths = array();
     foreach ($platform_paths as $p) {
         $locations[] = $p . '/filters';
         $locations[] = $p . '/filters/stack';
         $platform_stack_paths[] = $p . '/filters/stack';
     }
     $config = AEFactory::getConfiguration();
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Loading optional filters');
     foreach ($locations as $folder) {
         $is_platform = $this->isPlatformDirectory($folder);
         $files = AEUtilScanner::getFiles($folder);
         if ($files === false) {
             continue;
         }
         // Skip inexistent folders
         if (empty($files)) {
             continue;
         }
         // Skip no-match folders
         // Loop all files
         foreach ($files as $file) {
             if (substr($file, -4) != '.php') {
                 continue;
             }
             // Skip non-PHP files
             // Some hosts copy .ini and .php files, renaming them (ie foobar.1.php)
             // We need to exclude them, otherwise we'll get a fatal error for declaring the same class twice
             $bare_name = strtolower(basename($file, '.php'));
             if (preg_match('/[^a-z0-9]/', $bare_name)) {
                 continue;
             }
             $filter_name = 'Stack' . ($is_platform ? 'Platform' : '') . ucfirst(basename($file, '.php'));
             // Extract filter base name
             if (array_key_exists($filter_name, $this->filters)) {
                 continue;
             }
             // Skip already loaded filters
             if (!file_exists($folder . '/' . substr($file, 0, -4) . '.ini')) {
                 continue;
             }
             // Make sure the INI file also exists
             $key = "core.filters.{$bare_name}.enabled";
             if ($config->get($key, 0)) {
                 AEUtilLogger::WriteLog(_AE_LOG_DEBUG, '-- Loading optional filter ' . $filter_name);
                 $this->filters[$filter_name] = AEFactory::getFilterObject($filter_name);
                 // Add the filter
             }
         }
     }
 }