コード例 #1
0
ファイル: Autoload.class.php プロジェクト: Superbeest/Core
 private static final function checkModuleManifestLoaded(array $finalParts)
 {
     //we want to prohibit the access of modules before they are loaded.
     //but in order to do that, we need to make sure the module system is loaded.
     //if the module system is not loaded, extra modules cannot be loaded aswell, so we can safely continue in this case.
     //we dont autoload the module system, this whould cause an infinite recursive loop
     if (!self::$moduleSystemLoaded) {
         if (class_exists('\\System\\Module\\Module', false)) {
             self::$moduleSystemLoaded = true;
         } else {
             return true;
         }
     }
     //here we can check if the $class variable is in a module namespace
     if ($finalParts[0] == 'module' && mb_strtolower(end($finalParts)) != 'module') {
         //$class
         $modules = \System\Module\Module::getAllModules();
         $fullClassName = implode('\\', $finalParts);
         foreach ($modules as $module) {
             $loadedModuleManifest = implode('\\', array_slice(explode('\\', strtolower($module->manifest)), 0, 2)) . '\\';
             $moduleNameParts = array_slice($finalParts, 0, 2);
             $moduleName = implode('\\', $moduleNameParts);
             if (strpos($fullClassName, $loadedModuleManifest) === 0) {
                 return true;
             }
         }
         return false;
     }
     return true;
 }
コード例 #2
0
ファイル: bootloader.php プロジェクト: Superbeest/Core
/**
* This function checks the requirements for the system. Should not be called manually.
*/
function __requirements()
{
    \System\Version::registerRequiredConfigDirective('DATABASE_HOST');
    \System\Version::registerRequiredConfigDirective('DATABASE_USER');
    \System\Version::registerRequiredConfigDirective('DATABASE_PASS');
    \System\Version::registerRequiredConfigDirective('DATABASE_NAME');
    \System\Version::registerRequiredConfigDirective('DATABASE_PORT');
    \System\Version::registerRequiredConfigDirective('DATABASE_PERSISTANT');
    \System\Version::registerRequiredConfigDirective('PERMABAN_HOST');
    \System\Version::registerRequiredConfigDirective('PERMABAN_USER');
    \System\Version::registerRequiredConfigDirective('PERMABAN_PASS');
    \System\Version::registerRequiredConfigDirective('PERMABAN_NAME');
    \System\Version::registerRequiredConfigDirective('PERMABAN_PORT');
    \System\Version::registerRequiredConfigDirective('SITE_IDENTIFIER');
    \System\Version::registerRequiredConfigDirective('SITE_EMAIL');
    \System\Version::registerRequiredConfigDirective('SITE_NAMESPACE');
    \System\Version::registerRequiredConfigDirective('PUBLIC_ROOT');
    \System\Version::registerRequiredConfigDirective('DEFAULT_MODULES');
    \System\Version::registerRequiredConfigDirective('MINIFY_ENABLE');
    \System\Version::registerRequiredConfigDirective('AVAILABLE_LANGUAGES');
    \System\Version::registerRequiredConfigDirective('DEFAULT_LANGUAGE');
    if (version_compare(PHP_VERSION, SYSTEM_MINIMUM_PHP_VERSION) < 0) {
        throw new \System\Error\Exception\SystemException('The configuration is invalid: We need at least PHP ' . SYSTEM_MINIMUM_PHP_VERSION . ' in order to run.');
    }
    if (mb_strlen(SITE_IDENTIFIER) < 3 || mb_strlen(SITE_IDENTIFIER) > 4) {
        throw new \System\Error\Exception\SystemException('The configuration is invalid: SITE_IDENTIFIER must be 3 or 4 chars.');
    }
    if (!defined('LUTCACHE_CACHE')) {
        define('LUTCACHE_CACHE', \System\Cache\LUTCache\Types::CACHE_NONE);
    } else {
        if (LUTCACHE_CACHE != \System\Cache\LUTCache\Types::CACHE_NONE && LUTCACHE_CACHE != \System\Cache\LUTCache\Types::CACHE_MEMCACHE && LUTCACHE_CACHE != \System\Cache\LUTCache\Types::CACHE_APC) {
            throw new \System\Error\Exception\SystemException('The configuration is invalid: LUTCACHE_CACHE is invalid.');
        }
    }
    if (!function_exists('curl_init')) {
        throw new \System\Error\Exception\SystemException('This system requires the cURL PHP module to be present. Please reconfigure your PHP.');
    }
    if (!class_exists('\\XSLTProcessor')) {
        throw new \System\Error\Exception\SystemException('This system required the XSL PHP module to be present. Please reconfigure your PHP.');
    }
    //load the modules from the config file
    $defaultModules = unserialize(DEFAULT_MODULES);
    if (\System\Type::getType($defaultModules) != \System\Type::TYPE_ARRAY) {
        throw new \System\Error\Exception\SystemException('The configuration is invalid: DEFAULT_MODULES not set or invalid.');
    }
    foreach ($defaultModules as $defaultModule) {
        \System\Module\Module::load($defaultModule);
    }
}
コード例 #3
0
ファイル: APIGen.class.php プロジェクト: Superbeest/Core
 /**
  * Generates the API documentation for the System and the Module namespace.
  * It only includes PHP classes and will output PHP files in the given target directory.
  * This function is also applicable on a running system.
  * The target folder will be cleared!
  * @param \System\IO\Directory The target folder to use. This folder must be writable
  */
 public static final function generateAPIDoc(\System\IO\Directory $targetFolder)
 {
     //delete all files before actual adding, so we dont append to old files
     $files = \System\IO\Directory::walkDir($targetFolder->getCurrentPath(), new \System\Collection\Vector('php'));
     foreach ($files as $file) {
         $file->delete();
     }
     //first we have to load all the php files in the current System and Module folders
     $systemFiles = \System\IO\Directory::walkDir(PATH_SYSTEM, new \System\Collection\Vector('php'));
     foreach ($systemFiles as $systemFile) {
         if (!in_array($systemFile->getFilename(), self::$excludeFiles)) {
             require_once $systemFile->getFullPath();
         }
     }
     $vec = \System\Module\Module::getAllModules();
     //echo '<pre>';
     $moduleList = new \System\Collection\Vector();
     foreach ($vec as $module) {
         $manifest = strtolower(str_ireplace('Module\\', '', str_ireplace('\\Module', '', $module->manifest))) . '\\';
         $moduleList[] = $manifest;
     }
     $moduleFiles = \System\IO\Directory::walkDir(PATH_MODULES, new \System\Collection\Vector('php'));
     foreach ($moduleFiles as $moduleFile) {
         $base = $moduleFile->stripBase(PATH_MODULES);
         $found = false;
         foreach ($moduleList as $entry) {
             if (stripos(str_replace('\\', '/', $base), str_replace('\\', '/', $entry)) === 0) {
                 $found = true;
                 break;
             }
         }
         if ($found) {
             require_once $moduleFile->getFullPath();
         }
     }
     foreach (get_declared_interfaces() as $interface) {
         $reflectionClass = new \ReflectionClass($interface);
         if ($reflectionClass->getFileName() != '' && (strpos(\System\IO\Directory::normalize($reflectionClass->getFileName()), \System\IO\Directory::normalize(PATH_MODULES)) !== false || strpos(\System\IO\Directory::normalize($reflectionClass->getFileName()), \System\IO\Directory::normalize(PATH_SYSTEM)) !== false)) {
             self::generateClassDocumentation($targetFolder, $reflectionClass);
         }
     }
     foreach (get_declared_classes() as $class) {
         $reflectionClass = new \ReflectionClass($class);
         if ($reflectionClass->getFileName() != '' && (strpos(\System\IO\Directory::normalize($reflectionClass->getFileName()), \System\IO\Directory::normalize(PATH_MODULES)) !== false || strpos(\System\IO\Directory::normalize($reflectionClass->getFileName()), \System\IO\Directory::normalize(PATH_SYSTEM)) !== false)) {
             self::generateClassDocumentation($targetFolder, $reflectionClass);
         }
     }
     /*$constants = get_defined_constants(true);
     		echo '<pre>';
     		$moduleConstants = new \System\Collection\Map();
     		$systemConstants = new \System\Collection\Map();
     		foreach ($constants['user'] as $key=>$value)
     		{
     			switch (true)
     			{
     				case stripos($key, 'system\\') === 0:
     					$systemConstants[$key] = $value;
     					break;
     				case stripos($key, 'module\\') === 0:
     					$moduleConstants[$key] = $value;
     					break;
     				default:
     					//dont do anything
     			}
     		}
     
     		foreach ($systemConstants as $key=>$value)
     		{
     			self::writeConstant($targetFolder, $key, $value);
     		}
     
     		foreach ($moduleConstants as $key=>$value)
     		{
     			self::writeConstant($targetFolder, $key, $value);
     		}*/
     //copy the copy extensions
     $vec = new \System\Collection\Vector(self::$copyExtensions);
     self::copyFiles($targetFolder, PATH_MODULES, $vec, 'module');
     self::copyFiles($targetFolder, PATH_SYSTEM, $vec, 'system');
 }
コード例 #4
0
ファイル: Version.class.php プロジェクト: Superbeest/Core
 /**
  * Outputs the systeminfo in a human readable format.
  * This function outputs html styled information and should only be used for displaying information.
  * @return string The html styled system information
  */
 public static final function getSystemInfo()
 {
     $output = '';
     $output .= '<table style="margin: 10px; font-family: Verdana; font-size: 12px; width: 600px; border: 1px solid black; background-color: #9999cc;">
                     <tr><td colspan="2">
                     <p style="font-size: 14px; font-weight: bold;">SYSTEM INFORMATION</p>
                     <p style="font-size: 10px;">
                         Notice: This file is copyrighted and unauthorized use is strictly prohibited.<br />
                         The file contains proprietary information and may not be distributed, modified<br />
                         or altered in any way, without written perimission.<br />
                         Copyright: SUPERHOLDER B.V. ' . date('Y') . '
                     </p>
                     </td></tr>
                 </table>';
     $info = new \System\Collection\Vector();
     $system = new \System\Collection\Map();
     $system->name = 'SYSTEM Namespace';
     $system->manifest = 'N/A';
     $system->major = self::getMajor();
     $system->minor = self::getMinor();
     $system->revision = self::getSourceRevision();
     $map = new \System\Collection\Map();
     $map->PHP = self::getPHPVersion();
     $map->hasSlowQueryListener = \System\Event\EventHandler::hasListeners('\\System\\Event\\Event\\OnSlowMySQLQueryEvent') ? 'true' : 'false';
     if (self::$configDirectives == null) {
         self::$configDirectives = new \System\Collection\Vector();
     }
     $map->requiredConfigDirectives = implode(', ', self::$configDirectives->getArrayCopy());
     $map->PATH_PROJECT = PATH_PROJECT;
     $map->PATH_SYSTEM = PATH_SYSTEM;
     $map->PATH_CONFIG = PATH_CONFIG;
     $map->PATH_TEMP = PATH_TEMP;
     $map->PATH_LOGS = PATH_LOGS;
     $map->PATH_MODULES = PATH_MODULES;
     $map->installedCaches = 'LUTCache, Memcache, APCCache';
     $system->additional = $map;
     $info[] = $system;
     $info->combine(\System\Module\Module::getAllModules());
     foreach ($info as $module) {
         $output .= '<table style="margin: 10px; font-family: Verdana; font-size: 12px; width: 600px; border: 1px solid black; background-color: #9999cc;">';
         $output .= '<tr><td colspan="2" style="text-align: center; font-weight: bold; font-size: 14px;">' . $module->name . '</td></tr>';
         $output .= '<tr><td style="background-color: #ccccff; width: 200px;">Manifest</td><td style="background-color: #cccccc; width: 400px;">' . $module->manifest . '</td></tr>';
         $output .= '<tr><td style="background-color: #ccccff; width: 200px;">Version</td><td style="background-color: #cccccc; width: 400px;">' . $module->major . "." . $module->minor . "." . $module->revision . '</td></tr>';
         foreach ($module->additional as $index => $value) {
             $output .= '<tr><td style="background-color: #ccccff; width: 200px;">' . $index . '</td><td style="background-color: #cccccc; width: 400px;">' . $value . '</td></tr>';
         }
         $output .= '</table>';
     }
     return $output;
 }
コード例 #5
0
 /**
  * Gets all the loaded modules. Listens to the EVENT_GET_LOADED_MODULES message
  * @param OnInteractionEvent The event to listen to
  */
 public static final function getLoadedModules(\System\System\Interaction\Event\OnInteractionEvent $event)
 {
     $msg = $event->getMessage();
     if ($msg->getType() == \System\System\Interaction\MessageType::TYPE_SYSTEM && $msg->getMessage() == SystemInteractionEventEvent::EVENT_GET_LOADED_MODULES) {
         $response = new \System\System\Interaction\Response($msg, \System\Module\Module::getAllModules());
         $event->addResponse($response);
     }
 }