-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathajax.php
More file actions
69 lines (51 loc) · 1.33 KB
/
ajax.php
File metadata and controls
69 lines (51 loc) · 1.33 KB
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
<?php
include '_include.php';
// initialize CMS
TznCms::init(0, false); //public page, do not autoload modules
//include CMS_CLASS_PATH.'pkg_content.php';
if (!$_REQUEST['module']) {
header('Status: 404 Not Found');
exit;
}
if (!preg_match('/^[a-z0-9_\-]*$/i', $_REQUEST['module'])) {
header('Status: 500 Server Error');
echo 'Oops, '.$_REQUEST['module'].' is a bogus module name';
exit;
}
if (!$_REQUEST['action']) {
header('Status: 404 Not Found');
exit;
}
$method = $_REQUEST['action'];
if (!preg_match('/^[a-z0-9_\-]*$/i', $method)) {
header('Status: 500 Server Error');
echo 'Oops, '.$method.' is a bogus method name';
exit;
}
$method = 'ajax'.ucFirst($method);
// Mootools bug: sends in UTF-8
if (CMS_CHARSET != 'UTF-8') {
foreach($_POST as $key => $value) {
$_POST[$key] = utf8_decode($value);
}
}
if ($_REQUEST['module'] == 'comment') {
CmsComment::$method();
} else {
$objModuleAjax = $GLOBALS['objCms']->getModuleObject($_REQUEST['module']);
if (is_object($objModuleAjax)) {
$objModuleAjax->$method(); // -TODO- add args
$objModuleAjax->ajaxView();
} else {
/*
if (is_object($objModuleAjax)) {
echo 'object class : '.get_class($objModuleAjax);
} else {
var_dump($objModuleAjax);
}
*/
header('Status: 500 Server Error');
echo 'Oops, can not initialize object '.$_REQUEST['module'];
exit;
}
}