public
Description: Midgard Components Framework 3rd generation
Homepage: http://www.midgard-project.org
Clone URL: git://github.com/bergie/midcom.git
midcom / midcom_core / framework.php
100644 52 lines (43 sloc) 1.532 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* @package midcom_core
* @author The Midgard Project, http://www.midgard-project.org
* @copyright The Midgard Project, http://www.midgard-project.org
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
*/
error_reporting(E_ALL);
 
if (!defined('MIDCOM_ROOT'))
{
    define('MIDCOM_ROOT', realpath(dirname(__FILE__) . '/../'));
}
 
if (!defined('MIDCOM_STATIC_URL'))
{
    define('MIDCOM_STATIC_URL', '/midcom-static');
}
 
if (!defined('MIDCOM_TEST_RUN'))
{
    define('MIDCOM_TEST_RUN', false);
}
 
/**
* Make sure the URLs not having query string (or midcom-xxx- -method signature)
* have trailing slash or some extension in the "filename".
*
* This makes life much, much better when making static copies for whatever reason
*/
if ( isset($_SERVER['REQUEST_URI'])
    && !preg_match('%\?|/$|midcom-.+-|/.+\..+$%', $_SERVER['REQUEST_URI'])
    && $_SERVER['REQUEST_METHOD'] == 'GET')
{
    header('HTTP/1.0 301 Moved Permanently');
    header("Location: {$_SERVER['REQUEST_URI']}/");
 
    header('Content-type: text/html; charset=utf-8'); // just to be sure, that the browser interprets fallback right
    echo "301: new location <a href='{$_SERVER['REQUEST_URI']}/'>{$_SERVER['REQUEST_URI']}/</a>";
    exit();
}
 
// Advertise the fact that this is a Midgard server
header('X-Powered-By: Midgard/' . mgd_version());
 
// Load the exception handler
require(MIDCOM_ROOT . '/midcom_core/exceptionhandler.php');
 
// Start up MidCOM
require(MIDCOM_ROOT . '/midcom_core/midcom.php');
?>