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
|
<?php
$modules = array();
function getModuleList()
{
$mlist = array();
array_push($mlist, "config");
array_push($mlist, "discography");
array_push($mlist, "events");
array_push($mlist, "gallery");
array_push($mlist, "guestbook");
array_push($mlist, "icons");
array_push($mlist, "links");
array_push($mlist, "members");
array_push($mlist, "news");
array_push($mlist, "pages");
array_push($mlist, "downloads");
array_push($mlist, "newsletter");
array_push($mlist, "pressrelease");
array_push($mlist, "user");
array_push($mlist, "users");
return $mlist;
}
function loadModule($modulename)
{
global $MODULES_DIR;
global $modules;
$modulefile = $MODULES_DIR . "/" . $modulename . ".php";
if(!$modules[$modulename]) {
if(file_exists($modulefile)) {
include_once($modulefile);
$module = call_user_func($modulename . "_init");
$modules[$modulename] = $module;
} else {
// Module does not exist.
}
}
}
function loadAllModules()
{
foreach(getModuleList() as $m) {
loadModule($m);
}
}
function getModuleParams($code)
{
$params = array();
$ps = explode(",", $code);
foreach($ps as $p) {
$v = explode("=", $p);
$params[$v[0]] = $v[1];
}
return $params;
}
function runModule($code)
{
global $modules;
$str = "";
$m = explode("?", $code);
$module = $m[0];
$params = getModuleParams($m[1]);
loadModule($module);
if($modules[$module]) {
$str .= $modules[$module]->run($params);
} else {
$str .= "<p><strong>CMS ERROR: Could not find module:";
$str .= " [[" . $modulecode . "]]</strong></p>\n";
}
return $str;
}
?>
|