Ajax based suggest feature for the search box
[lhc/web/wiklou.git] / ajax.php
1 <?php
2
3 $wgRequestTime = microtime();
4
5 unset( $IP );
6 @ini_set( 'allow_url_fopen', 0 ); # For security...
7
8 # Valid web server entry point, enable includes.
9 # Please don't move this line to includes/Defines.php. This line essentially defines
10 # a valid entry point. If you put it in includes/Defines.php, then any script that includes
11 # it becomes an entry point, thereby defeating its purpose.
12 define( 'MEDIAWIKI', true );
13 require_once( './includes/Defines.php' );
14 require_once( './LocalSettings.php' );
15 require_once( 'includes/Setup.php' );
16 require_once( 'includes/AjaxFunctions.php' );
17
18 if ( ! $wgUseAjax ) {
19 die ( -1 );
20 }
21
22 wfProfileIn( 'main-misc-setup' );
23
24 header( 'Content-Type: text/html; charset=utf-8', true );
25
26 // List of exported PHP functions
27 $sajax_export_list = array( 'wfSajaxSearch' );
28
29 $mode = "";
30
31 $wgAjaxCachePolicy = new AjaxCachePolicy();
32
33 if (! empty($_GET["rs"])) {
34 $mode = "get";
35 }
36
37 if (!empty($_POST["rs"])) {
38 $mode = "post";
39 }
40
41 if (empty($mode)) {
42 return;
43 }
44
45 if ($mode == "get") {
46 $func_name = $_GET["rs"];
47 if (! empty($_GET["rsargs"])) {
48 $args = $_GET["rsargs"];
49 } else {
50 $args = array();
51 }
52 } else {
53 $func_name = $_POST["rs"];
54 if (! empty($_POST["rsargs"])) {
55 $args = $_POST["rsargs"];
56 } else {
57 $args = array();
58 }
59 }
60
61 if (! in_array($func_name, $sajax_export_list)) {
62 echo "-:$func_name not callable";
63 } else {
64 echo "+:";
65 $result = call_user_func_array($func_name, $args);
66 $wgAjaxCachePolicy->writeHeader();
67 echo $result;
68 }
69 exit;
70
71 ?>