$v) if (!defined($k)) define($k, $v); ob_start(); ob_clean(); header("Content-Type: text/html"); $strResource = $_SERVER["REQUEST_URI"]; if (strlen($strResource) > 0) $strResource = substr($strResource, 1); $strPluginsDirectory = "plugins"; $varPaths = array("."); if (is_dir($strPluginsDirectory)) foreach (scandir($strPluginsDirectory) as $strPluginName) { if ($strPluginName == ".") continue; if ($strPluginName == "..") continue; $strPluginDirectory = "{$strPluginsDirectory}/{$strPluginName}"; if (is_dir($strPluginDirectory)) $varPaths[] = "{$strPluginDirectory}"; } foreach ($varPaths as $strPath) { $strTargetFilePath = "{$strPath}/{$strResource}"; if (is_file($strTargetFilePath)) { $intValid = 0; $varMimeTypes = array( array("/\.css$/", "text/css"), array("/\.js$/", "application/javascript"), array("/\.png$/", "image/png"), array("/\.jpg$/", "image/jpeg"), array("/\.jpeg$/", "image/jpeg"), ); foreach ($varMimeTypes as $varMimeType) if (preg_match($varMimeType[0], $strTargetFilePath)) { header("Content-Type: {$varMimeType[1]}"); $intValid = 1; } if ($intValid) { Framework::log("Sending file {$strTargetFilePath}"); ob_clean(); echo file_get_contents($strTargetFilePath); ob_end_flush(); exit; } } } $varCollection = array( "lib" => array(), "init.php" => array(), "head.php" => array(), "header.php" => array(), "footer.php" => array(), ); foreach ($varPaths as $strPath) { $x = null; if (is_dir($x = "{$strPath}/lib")) $varCollection["lib"][] = $x; foreach (["init.php", "head.php", "header.php", "footer.php"] as $strScript) if (is_file($x = "{$strPath}/{$strScript}")) $varCollection[$strScript][] = $x; } foreach ($varCollection["lib"] as $strLibraryDirPath) foreach (scandir($strLibraryDirPath) as $strLibraryFileName) { $strLibraryFilePath = "{$strLibraryDirPath}/{$strLibraryFileName}"; if (preg_match("/\.php$/", $strLibraryFilePath)) if (is_file($strLibraryFilePath)) { Framework::log("Requiring library {$strLibraryFilePath}"); require $strLibraryFilePath; } } $strBodyTagAttributes = ""; function requireAll($strScriptName) { global $varCollection; foreach ($varCollection[$strScriptName] as $strScript) { if (is_file($strScript)) { Framework::log("Requiring {$strScript}"); require $strScript; } } } // Require all init scripts found: requireAll("init.php"); ?>