Use AutoLoader to load classes:
[lhc/web/wiklou.git] / includes / AjaxDispatcher.php
1 <?php
2
3 require_once( 'AjaxFunctions.php' );
4
5 if ( ! $wgUseAjax ) {
6 die ( -1 );
7 }
8
9 class AjaxDispatcher {
10 var $mode;
11 var $func_name;
12 var $args;
13
14 function AjaxDispatcher() {
15 global $wgAjaxCachePolicy;
16
17 wfProfileIn( 'AjaxDispatcher::AjaxDispatcher' );
18
19 $wgAjaxCachePolicy = new AjaxCachePolicy();
20
21 $this->mode = "";
22
23 if (! empty($_GET["rs"])) {
24 $this->mode = "get";
25 }
26
27 if (!empty($_POST["rs"])) {
28 $this->mode = "post";
29 }
30
31 if ($this->mode == "get") {
32 $this->func_name = $_GET["rs"];
33 if (! empty($_GET["rsargs"])) {
34 $this->args = $_GET["rsargs"];
35 } else {
36 $this->args = array();
37 }
38 } else {
39 $this->func_name = $_POST["rs"];
40 if (! empty($_POST["rsargs"])) {
41 $this->args = $_POST["rsargs"];
42 } else {
43 $this->args = array();
44 }
45 }
46 wfProfileOut( 'AjaxDispatcher::AjaxDispatcher' );
47 }
48
49 function performAction() {
50 global $wgAjaxCachePolicy, $wgAjaxExportList;
51 if ( empty( $this->mode ) ) {
52 return;
53 }
54 wfProfileIn( 'AjaxDispatcher::performAction' );
55
56 if (! in_array( $this->func_name, $wgAjaxExportList ) ) {
57 echo "-:{$this->func_name} not callable";
58 } else {
59 echo "+:";
60 $result = call_user_func_array($this->func_name, $this->args);
61 header( 'Content-Type: text/html; charset=utf-8', true );
62 $wgAjaxCachePolicy->writeHeader();
63 echo $result;
64 }
65 wfProfileOut( 'AjaxDispatcher::performAction' );
66 exit;
67 }
68 }
69
70 ?>