/** * Build the memcache object and prepare it for storing information */ public final function __construct() { if (self::$memcache == null) { \System\Version::registerRequiredConfigDirective('MEMCACHED_HOST'); \System\Version::registerRequiredConfigDirective('MEMCACHED_PORT'); \System\Version::registerRequiredConfigDirective('MEMCACHED_USE_COMPRESSION'); } if (!defined('MEMCACHED_HOST') || !defined('MEMCACHED_PORT') || !defined('MEMCACHED_USE_COMPRESSION')) { throw new \System\Error\Exception\SystemException('Invalid Memcache settings found. Please check your configuration.'); } //by only checking for the initial null and not for false, we only try to boot the memcache once. if (self::$memcache === null) { try { //check if we want the memcache disabled if (MEMCACHED_HOST != '') { if (!class_exists('\\Memcache', false)) { self::$memcache = false; } else { self::$memcache = new \Memcache(); //we get all the servers and initialize those $hosts = $ports = array(); $this->getServers($hosts, $ports); //add all the servers to the pool foreach ($hosts as $index => $host) { //we dont use persistant connections $connected = self::$memcache->addServer($host, $ports[$index], false); if (!$connected) { //when one of the servers are not connected we stop self::$memcache = false; break; } } if (MEMCACHED_USE_COMPRESSION) { //compression system self::$memcache->setCompressThreshold(self::MINIMUM_VALUE_LENGTH_FOR_COMPRESSION, self::COMPRESSION); } } } else { self::$memcache = false; } } catch (\Exception $e) { self::$memcache = false; throw new \System\Error\Exception\MemcacheInvalidOperationException('Could not connect to the memcached server, or normal operation could not be resumed.'); } } }
/** * Boots the system and reads the configuration files. Should not be called manually. */ function __bootloader() { //get the current path $currentPath = getcwd(); //we make sure the last character of the current path is a separator if (substr($currentPath, -1) != '/') { $currentPath .= '/'; } //these definitions must be present if (!defined('PATH_SYSTEM')) { throw new \Exception('PATH_SYSTEM is not set in paths.inc'); } if (!defined('PATH_CONFIG')) { throw new \Exception('PATH_CONFIG is not set in paths.inc'); } if (!defined('PATH_TEMP')) { throw new \Exception('PATH_TEMP is not set in paths.inc'); } if (!defined('PATH_LOGS')) { throw new \Exception('PATH_LOGS is not set in paths.inc'); } if (!defined('PATH_MODULES')) { throw new \Exception('PATH_MODULES is not set in paths.inc'); } if (!defined('PATH_PAGECACHE_CACHE')) { throw new \Exception('PATH_PAGECACHE_CACHE is not set in paths.inc'); } //define the security locks so we can include files define('InSite', null); define('System', null); //we define the default character sets to utf8 mb_internal_encoding("UTF-8"); //load the autoloader. After this call, all the classes can be called. $autoloader = PATH_SYSTEM . 'Autoload.class.php'; if (file_exists($autoloader)) { require_once $autoloader; } else { throw new \Exception('Could not load ' . $autoloader . '. Please check the PATH_SYSTEM constant in your configuration!'); } //debug parameters when the platform is our development platform if (\System\Server\OS::getOS() == \System\Server\OS::OS_WINDOWS) { defined('DEBUG') || define('DEBUG', null); } register_shutdown_function('\\System\\Db\\Database::handleShutdown'); //boot the errorhandler and register the exception and error handlers \System\Error\ErrorHandler::getInstance(); //set the timezone values defined('TIMEZONE_IDENTIFIER') || define('TIMEZONE_IDENTIFIER', 'Europe/Amsterdam'); \System\Version::registerRequiredConfigDirective('TIMEZONE_IDENTIFIER'); date_default_timezone_set(TIMEZONE_IDENTIFIER); //register $register = \System\Register\Register::getInstance(); //we set the start timer \System\Calendar\Timer::getSystemExecutionTime(); //config require_once PATH_CONFIG . 'site.inc'; //initialize the language subsystem \System\Internationalization\Language::init(); //initialize the system interaction system \System\System\Interaction\Event\SystemInteractionEvent::registerListeners(); //register extra handlers if needed if (file_exists(PATH_CONFIG . 'handlers.inc')) { require_once PATH_CONFIG . 'handlers.inc'; } //turn the displaying of errors off, when we are in production environment defined('DEBUG') || ini_set('display_errors', 0); //verify the required configuration variables __requirements(); //check if the visitors ip address is allowed. if (!\System\HTTP\Visitor\PermaBan\PermaBan::isIPAllowed(\System\HTTP\Visitor\IP::getClientIP())) { header('HTTP/1.0 403 Forbidden'); header('Status: 403 Forbidden'); header('HTTP/1.1 403 Forbidden'); exit; } //database $register->defaultDb = \System\Db\Database::getConnection(); //we dont want to cache our output, as this allows access without revalidating header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); //requestshizzle \System\Version::registerRequiredConfigDirective('DEFAULT_CONTROLLER'); if (!defined('DEFAULT_CONTROLLER')) { throw new \System\Error\Exception\SystemException('The configuration is invalid: DEFAULT_CONTROLLER not set or invalid.'); } $controller = \System\Web\Controller::callController(); //do buffered output rendering if needed if ($controller->getRenderSetting() == \System\Web\Controller::RENDERER_ENABLED) { //render the surface $renderSurface = $controller->getRenderSurface(); if (!$renderSurface) { throw new \System\Error\Exception\SystemException('Please make sure your controller action sets a RenderSurface!'); } $controller->getRenderSurface()->execute(); } //shutdown the system to prevent further execution of code exit; }
/** * Returns a \System\Collection\Vector containing all the information about all the currently loaded * modules. This information is using a default format and displays any information from the iModule interface * and outputs additional information retrieval function. * @return \System\Collection\Vector A Vector containing a listing of all loaded modules */ public static final function getAllModules() { $register = self::getRegistryModuleEntry(); $map = new \System\Collection\Vector(); foreach ($register->modules as $moduleName => $module) { $mod = new \System\Collection\Map(); $mod->name = $module->getModuleName(); $mod->manifest = $moduleName; $mod->major = $module->getMajor(); $mod->minor = $module->getMinor(); $mod->revision = \System\Version::transformRevStringToInt($module->getSourceRevision()); $additional = $module->getModuleInformation(); $additional->requiredConfigDirectives = implode(', ', $module->getRequiredConfigDirectives()->getArrayCopy()); $mod->additional = $additional; $map->add($mod); } return $map; }