示例#1
0
 /**
  * Initialize the PHP globals necessary for legacy mode and backward compatibility
  * for standard applications.
  *
  * @return void
  */
 protected function initGlobals()
 {
     $request = $this->getRequest();
     $requestContext = $this->getRequestContext();
     // Init the actual globals storage and make sure to generate it anew
     $globals = array();
     // initialize the globals
     $globals['server'] = $requestContext->getServerVars();
     $globals['env'] = array_merge((array) $requestContext->getEnvVars(), appserver_get_envs());
     $globals['request'] = $request->getParams();
     // init post / get. default init vars as GET method case
     if ($requestContext->getServerVar(ServerVars::REQUEST_METHOD) === Protocol::METHOD_GET) {
         // clear post array
         $globals['post'] = array();
         // set all params to get
         $globals['get'] = $request->getParams();
     }
     // check if method post was given
     if ($request->getMethod() === Protocol::METHOD_POST) {
         // set raw request if post method is going on
         $globals['httpRawPostData'] = $request->getBodyContent();
         // set params to post
         $globals['post'] = $request->getParams();
         $globals['get'] = array();
         // set params given in query string to get if query string exists
         if ($requestContext->hasServerVar(ServerVars::QUERY_STRING)) {
             parse_str($requestContext->getServerVar(ServerVars::QUERY_STRING), $getArray);
             $globals['get'] = $getArray;
         }
     }
     // set cookie globals
     $cookies = array();
     // iterate all cookies and set them in globals if exists
     if ($cookieHeaderValue = $request->getHeader(Protocol::HEADER_COOKIE)) {
         foreach (explode(';', $cookieHeaderValue) as $cookieLine) {
             list($key, $value) = explode('=', $cookieLine);
             $cookies[trim($key)] = trim($value);
         }
     }
     $globals['cookie'] = $cookies;
     // set files globals
     $globals['files'] = $this->initFileGlobals($request);
     $this->globals = $globals;
 }
示例#2
0
 * @license    http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * @link       http://github.com/appserver-io/meta
 * @link       http://www.appserver.io
 */
namespace TechDivision\ApplicationServer;

use TechDivision\ApplicationServer\Utilities\DirectoryKeys;
declare (ticks=1);
error_reporting(~E_NOTICE);
set_time_limit(0);
// set the session timeout to unlimited
ini_set('session.gc_maxlifetime', 0);
ini_set('zend.enable_gc', 0);
ini_set('max_execution_time', 0);
// set environmental variables in $_ENV globals per default
$_ENV = appserver_get_envs();
// load core functions to override in runtime environment
require __DIR__ . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'scripts' . DIRECTORY_SEPARATOR . 'core_functions.php';
// bootstrap the application
require __DIR__ . DIRECTORY_SEPARATOR . 'bootstrap.php';
// initialize configuration and schema file name
$configurationFileName = DirectoryKeys::realpath(sprintf('%s/%s/appserver.xml', APPSERVER_BP, DirectoryKeys::CONF));
$schemaFileName = DirectoryKeys::realpath(sprintf('%s/resources/schema/appserver.xsd', APPSERVER_BP));
// initialize the DOMDocument with the configuration file to be validated
$configurationFile = new \DOMDocument();
$configurationFile->load($configurationFileName);
// activate internal error handling, necessary to catch errors with libxml_get_errors()
libxml_use_internal_errors(true);
// validate the configuration file with the schema
if ($configurationFile->schemaValidate($schemaFileName) === false) {
    foreach (libxml_get_errors() as $error) {