aboutsummaryrefslogtreecommitdiff
path: root/ratatoeskr/main.php
blob: 09f4d8dbe33b8eb09e8e440b2f102fd3fdd3cc9f (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
<?php
/*
 * File: ratatoeskr/main.php
 * Initialize and launch Ratatöskr
 * 
 * License:
 * This file is part of Ratatöskr.
 * Ratatöskr is licensed unter the MIT / X11 License.
 * See "ratatoeskr/licenses/ratatoeskr" for more information.
 */

require_once(dirname(__FILE__) . "/sys/db.php");
require_once(dirname(__FILE__) . "/sys/plugin_api.php");
require_once(dirname(__FILE__) . "/sys/models.php");
require_once(dirname(__FILE__) . "/sys/init_ste.php");
require_once(dirname(__FILE__) . "/sys/translation.php");
require_once(dirname(__FILE__) . "/sys/urlprocess.php");
#require_once(dirname(__FILE__) . "/frontend.php");
require_once(dirname(__FILE__) . "/backend/main.php");

function ratatoeskr()
{
	global $backend_subactions, $ste, $url_handlers;
	session_start();
	if(!CONFIG_FILLED_OUT)
		return setup();
	
	db_connect();
	
	$activeplugins = array_filter(PluginDB::all(), function($plugin) { return $plugin->active; });
	$plugin_objs = array();
	foreach($activeplugins as $plugin)
	{
		eval($plugin->phpcode);
		$plugin_obj = new $plugin->class;
		$plugin_obj->init();
		$plugin_objs[] = $plugin_obj;
	}
	
	/* Register URL handlers */
	#register_url_handler("_default", "frontend_url_handler");
	register_url_handler("backend", $backend_subactions);
	#register_url_handler("_notfound", "e404handler");
	
	$urlpath = explode("/", $_GET["action"]);
	$rel_path_to_root = implode("/", array_merge(array("."), array_repeat("..", count($urlpath) - 1)));
	$data = array("rel_path_to_root" => $rel_path_to_root);
	$ste->vars["rel_path_to_root"] = $rel_path_to_root;
	
	url_process($urlpath, $url_handlers, $data);
}

?>