/** * Loads the scripting.ini and returns an array with the domains, the scripts and * the raw data * @return array */ public static function loadScripting() { static $scripting = null; if (empty($scripting)) { $ds = DIRECTORY_SEPARATOR; $ini_file_name = AEFactory::getAkeebaRoot() . $ds . 'core' . $ds . 'scripting.ini'; if (@file_exists($ini_file_name)) { $raw_data = AEUtilINI::parse_ini_file($ini_file_name, false); $domain_keys = explode('|', $raw_data['volatile.akeebaengine.domains']); $domains = array(); foreach ($domain_keys as $key) { $record = array('domain' => $raw_data['volatile.domain.' . $key . '.domain'], 'class' => $raw_data['volatile.domain.' . $key . '.class'], 'text' => $raw_data['volatile.domain.' . $key . '.text']); $domains[$key] = $record; } $script_keys = explode('|', $raw_data['volatile.akeebaengine.scripts']); $scripts = array(); foreach ($script_keys as $key) { $record = array('chain' => explode('|', $raw_data['volatile.scripting.' . $key . '.chain']), 'text' => $raw_data['volatile.scripting.' . $key . '.text']); $scripts[$key] = $record; } $scripting = array('domains' => $domains, 'scripts' => $scripts, 'data' => $raw_data); } else { $scripting = array(); } } return $scripting; }
/** * Get the paths for a specific section * * @param string $section The section to get the path list for (engine, installer, gui, filter) * * @return array */ public static function getPaths($section = 'gui') { // Create the key if it's not already present if (!array_key_exists($section, static::$paths)) { static::$paths[$section] = array(); } // Add the defaults if the list is empty if (empty(static::$paths[$section])) { switch ($section) { case 'engine': static::$paths[$section] = array(AEUtilFilesystem::TranslateWinPath(AEFactory::getAkeebaRoot() . '/engines'), AEUtilFilesystem::TranslateWinPath(AEFactory::getAkeebaRoot() . '/plugins/engines')); break; case 'installer': static::$paths[$section] = array(AEUtilFilesystem::TranslateWinPath(AEPlatform::getInstance()->get_installer_images_path())); break; case 'gui': // Add core GUI definitions static::$paths[$section] = array(AEUtilFilesystem::TranslateWinPath(AEFactory::getAkeebaRoot() . '/core')); // Add additional core GUI definitions if (AKEEBA_PRO) { AEUtilFilesystem::TranslateWinPath(static::$paths[$section][] = AEFactory::getAkeebaRoot() . '/plugins/core'); } // Add platform GUI definition files $platform_paths = AEPlatform::getInstance()->getPlatformDirectories(); foreach ($platform_paths as $p) { static::$paths[$section][] = AEUtilFilesystem::TranslateWinPath($p . '/config'); } break; case 'filter': static::$paths[$section] = array(AEUtilFilesystem::TranslateWinPath(AEFactory::getAkeebaRoot() . '/platform/filters/stack'), AEUtilFilesystem::TranslateWinPath(AEFactory::getAkeebaRoot() . '/filters/stack'), AEUtilFilesystem::TranslateWinPath(AEFactory::getAkeebaRoot() . '/plugins/filters/stack')); $platform_paths = AEPlatform::getInstance()->getPlatformDirectories(); foreach ($platform_paths as $p) { static::$paths[$section][] = AEUtilFilesystem::TranslateWinPath($p . '/filters/stack'); } break; } } return static::$paths[$section]; }
/** * 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 } } } }
/** * Parses the GUI INI files and returns an array of groups and their data * @return array */ public static function getGUIGroups() { // This is a static cache which persists between subsequent calls, but not // between successive page loads. static $gui_list = array(); // Try to serve cached data first if (!empty($gui_list) && is_array($qui_list)) { if (count($gui_list) > 0) { return $gui_list; } } // Find absolute path to normal and plugins directories $ds = DIRECTORY_SEPARATOR; $path_list = array(AEFactory::getAkeebaRoot() . '/core'); if (AKEEBA_PRO) { $path_list[] = AEFactory::getAkeebaRoot() . '/plugins/core'; } // Initialize the array where we store our data $gui_list = array(); // Loop for the paths where engines can be found foreach ($path_list as $path) { if (is_dir($path)) { if (is_readable($path)) { if ($handle = @opendir($path)) { // Store INI names in temp array because we'll sort based on filename (GUI order IS IMPORTANT!!) $allINIs = array(); while (false !== ($filename = @readdir($handle))) { if (strtolower(substr($filename, -4)) == '.ini' && @is_file($path . $ds . $filename)) { $allINIs[] = $path . $ds . $filename; } } // while readdir @closedir($handle); if (!empty($allINIs)) { // Sort GUI files alphabetically asort($allINIs); // Include each GUI def file foreach ($allINIs as $filename) { $information = array(); $parameters = array(); AEUtilINI::parseInterfaceINI($filename, $information, $parameters); // This effectively skips non-GUI INIs (e.g. the scripting INI) if (!empty($information['description'])) { $group_name = substr(basename($filename), 0, -4); $gui_list[$group_name] = array('information' => $information, 'parameters' => $parameters); } } } } // if opendir } // if readable } // if is_dir } ksort($gui_list); // Push stack filter settings to the 03.filters section $path_list = array(AEFactory::getAkeebaRoot() . $ds . 'platform' . $ds . 'filters' . $ds . 'stack', AEFactory::getAkeebaRoot() . $ds . 'filters' . $ds . 'stack', AEFactory::getAkeebaRoot() . $ds . 'plugins' . $ds . 'filters' . $ds . 'stack'); // Loop for the paths where optional filters can be found foreach ($path_list as $path) { if (is_dir($path)) { if (is_readable($path)) { if ($handle = @opendir($path)) { // Store INI names in temp array because we'll sort based on filename (GUI order IS IMPORTANT!!) $allINIs = array(); while (false !== ($filename = @readdir($handle))) { if (strtolower(substr($filename, -4)) == '.ini' && @is_file($path . $ds . $filename)) { $allINIs[] = $path . $ds . $filename; } } // while readdir @closedir($handle); if (!empty($allINIs)) { // Sort filter files alphabetically asort($allINIs); // Include each filter def file foreach ($allINIs as $filename) { $information = array(); $parameters = array(); AEUtilINI::parseInterfaceINI($filename, $information, $parameters); if (!empty($gui_list['03.filters']['parameters'])) { $gui_list['03.filters']['parameters'][] = array('title' => '', 'description' => '', 'type' => 'separator', 'default' => ''); } $gui_list['03.filters']['parameters'] = array_merge($gui_list['03.filters']['parameters'], $parameters); } } } // if opendir } // if readable } // if is_dir } return $gui_list; }
/** * 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 } } } }