<?php
/*
 * Copyright (c) 2013, webvariants GbR, http://www.webvariants.de
 *
 * This file is released under the terms of the MIT license. You can find the
 * complete text in the attached LICENSE file or online at:
 *
 * http://www.opensource.org/licenses/mit-license.php
 */

// remove magic_quotes and register_globals side effects
// You can safely remove this if your server is properly configured.
require 'sally/core/request-filter.php';

// determine application (try both REDIRECT_SLYAPP and REDIRECT_REDIRECT_SLYAPP)
$slyApp     = isset($_SERVER['REDIRECT_SLYAPP']) ? $_SERVER['REDIRECT_SLYAPP'] : (isset($_SERVER['REDIRECT_REDIRECT_SLYAPP']) ? $_SERVER['REDIRECT_REDIRECT_SLYAPP'] : null);
$slyAppName = $slyApp ? strtolower($slyApp) : 'frontend';

if (isset($_SERVER['REDIRECT_SLYBASE'])) {
	$slyAppBase = $_SERVER['REDIRECT_SLYBASE'];
}
elseif (isset($_SERVER['REDIRECT_REDIRECT_SLYBASE'])) {
	$slyAppBase = $_SERVER['REDIRECT_REDIRECT_SLYBASE'];
}
else {
	// deduct from app name
	$slyAppBase = $slyApp ? $slyApp : '';
}

// start output buffering
ob_start();
ob_implicit_flush(0);

// boot Core system
$loader    = require 'sally/core/autoload.php';
$container = sly_Core::boot($loader, null, $slyAppName, $slyAppBase);

// boot the requested application
require 'sally/'.$slyAppName.'/boot.php';
