summaryrefslogtreecommitdiff
path: root/index.php
blob: ad16995a61d6dd15953d8c694bc4454f2fc9b3f1 (plain)
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
53
54
55
56
57
58
59
60
61
62
<?php
// What directory are we in on the server.
define('BASEPATH', dirname(__FILE__));

$xss_file = BASEPATH.'/xss-check.php';
if (file_exists($xss_file)) {
	require($xss_file);
	if (xss_attack()) {
		echo "execution halted to prevent XSS attack.";
		exit();
	}
}

// Decide where to look for things
define('LIBPATH',        BASEPATH.'/src/lib'.PATH_SEPARATOR.BASEPATH.'/src/ext');
define('MODELPATH',      BASEPATH.'/src/models');
define('VIEWPATH',       BASEPATH.'/src/views');// views are not objects
define('CONTROLLERPATH', BASEPATH.'/src/controllers');
define('PLUGINPATH',     BASEPATH.'/src/plugins');

// Modify our include path to catch our class files.
set_include_path(get_include_path()
                 .PATH_SEPARATOR.LIBPATH
                 .PATH_SEPARATOR.MODELPATH
                 .PATH_SEPARATOR.CONTROLLERPATH
                 .PATH_SEPARATOR.PLUGINPATH
                 );

// Figure what page is trying to be loaded.  Don't worry if we're
// looking for a real file, if the requested page exists as a real
// file, .htaccess won't even let us load this file.
@$PAGE_RAW = $_GET['p'];
$PAGE_PARTS = explode('/', $PAGE_RAW);
$FILE = array_pop($PAGE_PARTS);
$regex = '@([^.]*)\\.(.*)@';
if (preg_match($regex, $FILE, $matches)) {
	@$FILE = $matches[1];
	@$EXT  = $matches[2];
	array_push($PAGE_PARTS, $FILE);
	$PAGE = implode('/', $PAGE_PARTS);
} else {
	$PAGE = $PAGE_RAW;
}
if ($PAGE=='') $PAGE = 'index';
define('PAGE', $PAGE); unset($PAGE);
define('PAGE_EXT', $EXT); unset($EXT);

// Get ready
//require_once('Model.class.php');
require_once('Controller.class.php');
require_once('Router.class.php');

require_once('ContactMethod.class.php');
require('conf-contacts.php');

global $mm;
require_once('MessageManager.class.php');
$mm = new MessageManager(BASEPATH.'/conf.php');

// Actually do stuff
$router = new Router(CONTROLLERPATH);
$router->route(PAGE);