forked from Atheos/Atheos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.php
46 lines (38 loc) · 1.53 KB
/
controller.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
<?php
//////////////////////////////////////////////////////////////////////////////80
// Atheos Controller
//////////////////////////////////////////////////////////////////////////////80
// Copyright (c) Atheos & Liam Siira (Atheos.io), distributed as-is and without
// warranty under the MIT License. See [root]/docs/LICENSE.md for more.
// This information must remain intact.
//////////////////////////////////////////////////////////////////////////////80
// Authors: Atheos Team, @hlsiira
//////////////////////////////////////////////////////////////////////////////80
set_error_handler(function($severity, $message, $file, $line) {
if (error_reporting() & $severity) {
throw new ErrorException($message, 0, $severity, $file, $line);
}
});
require_once('common.php');
$action = POST("action");
$target = POST("target");
//////////////////////////////////////////////////////////////////////////////80
// Verify Session or Key
//////////////////////////////////////////////////////////////////////////////80
if ($action !== 'authenticate') {
Common::checkSession();
}
if (!$action || !$target) {
Common::send("error", "Missing target or action.");
}
if ($target === "i18n" && $action === "init") {
$cache = array("cache" => $i18n->getCache());
Common::send("success", $cache);
}
if (file_exists("components/$target/controller.php")) {
require("components/$target/controller.php");
} elseif (file_exists("plugins/$target/controller.php")) {
require("plugins/$target/controller.php");
} else {
Common::send("error", "Bad target destination");
}