-
Notifications
You must be signed in to change notification settings - Fork 4
/
engine.php
executable file
·110 lines (101 loc) · 3.47 KB
/
engine.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
100
101
102
103
104
105
106
107
108
109
110
<?php
include_once 'lib/adianti/util/TAdiantiLoader.class.php';
spl_autoload_register(array('TAdiantiLoader', 'autoload_web'));
define('APPLICATION_NAME', 'framework');
define('OS', strtoupper(substr(PHP_OS, 0, 3)));
class TApplication
{
static public function run()
{
new TSession;
if (TSession::getValue('started'))
{
date_default_timezone_set(TSession::getValue('timezone'));
$lang = TSession::getValue('language');
}
else
{
$ini = parse_ini_file('application.ini');
$lang = $ini['language'];
date_default_timezone_set($ini['timezone']);
TSession::setValue('timezone', $ini['timezone']);
TSession::setValue('language', $ini['language']);
TSession::setValue('started', TRUE);
}
TAdiantiCoreTranslator::setLanguage($lang);
TApplicationTranslator::setLanguage($lang);
$content = '';
if ($_REQUEST)
{
$class = isset($_REQUEST['class']) ? $_REQUEST['class'] : '';
$static = isset($_REQUEST['static']) ? $_REQUEST['static'] : '';
$method = isset($_REQUEST['method']) ? $_REQUEST['method'] : '';
if (class_exists($class))
{
if ($static)
{
$rf = new ReflectionMethod($class, $method);
if ($rf->isStatic())
{
call_user_func(array($class, $method),$_REQUEST);
}
else
{
call_user_func(array(new $class, $method),$_REQUEST);
}
}
else
{
try
{
$page = new $class($_GET);
ob_start();
$page->show();
$content = ob_get_contents();
ob_end_clean();
}
catch(Exception $e)
{
ob_start();
new TMessage('error', $e->getMessage());
$content = ob_get_contents();
ob_end_clean();
}
}
}
else if (function_exists($method))
{
call_user_func($method, $_REQUEST);
}
else
{
new TMessage('error', "<b>Error</b>: class <b><i><u>{$class}</u></i></b> not found");
}
if (!$static)
{
echo TPage::getLoadedCSS();
}
echo TPage::getLoadedJS();
echo $content;
}
}
/**
* Execute a specific method of a class with parameters
*
* @param $class class name
* @param $method method name
* @param $parameters array of parameters
*/
static public function executeMethod($class, $method = NULL, $parameters = NULL)
{
$url = array();
$url['class'] = $class;
$url['method'] = $method;
unset($parameters['class']);
unset($parameters['method']);
$url = array_merge($url, (array) $parameters);
echo "<script language='JavaScript'> __adianti_goto_page('index.php?".http_build_query($url)."'); </script>";
}
}
TApplication::run();
?>