forked from Cotonti/Cotonti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
99 lines (88 loc) · 1.84 KB
/
index.php
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* Index loader
*
* @package Cotonti
* @version 0.9.4
* @author Cotonti Team
* @copyright Copyright (c) Cotonti Team 2008-2012
* @license BSD
*/
// Redirect to install if config is missing
if (!file_exists('./datas/config.php'))
{
header('Location: install.php');
exit;
}
// Let the include files know that we are Cotonti
define('COT_CODE', true);
// Load vital core configuration from file
require_once './datas/config.php';
// If it is a new install, redirect
if (isset($cfg['new_install']) && $cfg['new_install'])
{
header('Location: install.php');
exit;
}
// Load the Core API, the template engine
require_once $cfg['system_dir'] . '/functions.php';
require_once $cfg['system_dir'] . '/cotemplate.php';
// Bootstrap
require_once $cfg['system_dir'] . '/common.php';
// Support for ajax and popup hooked plugins
if (empty($_GET['e']) && !empty($_GET['r']))
{
$_GET['e'] = $_GET['r'];
}
if (empty($_GET['e']) && !empty($_GET['o']))
{
$_GET['e'] = $_GET['o'];
}
// Detect selected extension
if (empty($_GET['e']))
{
// Default environment for index module
define('COT_MODULE', true);
$env['type'] = 'module';
$env['ext'] = 'index';
}
else
{
$found = false;
if (preg_match('`^\w+$`', $_GET['e']))
{
if (file_exists($cfg['modules_dir'] . '/' . $_GET['e']))
{
$found = true;
$env['type'] = 'module';
define('COT_MODULE', true);
}
elseif (file_exists($cfg['plugins_dir'] . '/' . $_GET['e']))
{
$found = true;
$env['type'] = 'plug';
$env['location'] = 'plugins';
define('COT_PLUG', true);
}
}
if ($found)
{
$env['ext'] = $_GET['e'];
}
else
{
// Error page
cot_die_message(404);
exit;
}
}
// Load the requested extension
if ($env['type'] == 'plug')
{
require_once $cfg['system_dir'] . '/plugin.php';
}
else
{
require_once $cfg['modules_dir'] . '/' . $env['ext'] . '/' . $env['ext'] . '.php';
}
?>