Esempio n. 1
0
	/**
	 * Returns a hash list of Akeeba engines and their data. Each entry has the engine
	 * name as key and contains two arrays, under the 'information' and 'parameters' keys.
	 * @param string $engine_type The engine type to return information for
	 * @return array
	 */
	public static function getEnginesList($engine_type)
	{
		// This is a static cache which persists between subsequent calls, but not
		// between successive page loads.
		static $engine_list = array();

		// Try to serve cached data first
		if(isset($engine_list[$engine_type])) return $engine_list[$engine_type];

		// Find absolute path to normal and plugins directories
		$ds = DIRECTORY_SEPARATOR;
		$path_list = array(
			AEFactory::getAkeebaRoot().$ds.'engines'.$ds.$engine_type,
			AEFactory::getAkeebaRoot().$ds.'plugins'.$ds.'engines'.$ds.$engine_type
		);

		// Initialize the array where we store our data
		$engine_list[$engine_type] = array();

		// Loop for the paths where engines can befound
		foreach($path_list as $path)
		{
			if(is_dir($path))
			{
				if(is_readable($path))
				{
					if( $handle = @opendir($path) )
					{
						while(false !== $filename = @readdir($handle))
						{
							if( (strtolower(substr($filename, -4)) == '.ini') && @is_file($path.$ds.$filename) )
							{
								$information = array();
								$parameters = array();
								AEUtilINI::parseEngineINI($path.$ds.$filename, $information, $parameters);
								$engine_name = substr($filename, 0, strlen($filename) - 4);
								$engine_list[$engine_type][$engine_name] = array(
									'information' => $information,
									'parameters' => $parameters
								);
							}
						} // while readdir
						@closedir($handle);
					} // if opendir
				} // if readable
			} // if is_dir
		}

		return $engine_list[$engine_type];
	}
Esempio n. 2
0
 /**
  * Returns a hash list of Akeeba engines and their data. Each entry has the engine
  * name as key and contains two arrays, under the 'information' and 'parameters' keys.
  *
  * @param string $engine_type The engine type to return information for
  *
  * @return array
  */
 public static function getEnginesList($engine_type)
 {
     // This is a static cache which persists between subsequent calls, but not
     // between successive page loads.
     static $engine_list = array();
     // Try to serve cached data first
     if (isset($engine_list[$engine_type])) {
         return $engine_list[$engine_type];
     }
     // Find absolute path to normal and plugins directories
     $temp = static::getPaths('engine');
     $path_list = array();
     foreach ($temp as $path) {
         $path_list[] = $path . '/' . $engine_type;
     }
     // Initialize the array where we store our data
     $engine_list[$engine_type] = 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)) {
                     while (false !== ($filename = @readdir($handle))) {
                         if (strtolower(substr($filename, -4)) == '.ini' && @is_file($path . '/' . $filename)) {
                             $bare_name = strtolower(basename($filename, '.ini'));
                             // 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
                             if (preg_match('/[^a-z0-9]/', $bare_name)) {
                                 continue;
                             }
                             $information = array();
                             $parameters = array();
                             AEUtilINI::parseEngineINI($path . '/' . $filename, $information, $parameters);
                             $engine_name = substr($filename, 0, strlen($filename) - 4);
                             $engine_list[$engine_type][$engine_name] = array('information' => $information, 'parameters' => $parameters);
                         }
                     }
                     @closedir($handle);
                 }
             }
         }
     }
     return $engine_list[$engine_type];
 }