<?php
@session_start();
// Include library code
require_once "./lib/config.php";
require_once "JsHttpRequest/JsHttpRequest.php";
// Init class...
$JsHttpRequest =& new JsHttpRequest('utf-8');
/*
*  prevent DW from packing the content
*/
define('DOKU_DISABLE_GZIP_OUTPUT',1);

/*
*  define constants and load all required libraries
*/
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/');

require_once (DOKU_INC.'inc/init.php');
require_once(DOKU_INC.'inc/html.php');
require_once(DOKU_INC.'inc/auth.php');


if (isset($_REQUEST['callback'])) {
  /*
  *  cleanup possible security hole
  */
  $_REQUEST['callback'] = preg_replace("/\.+/","",$_REQUEST['callback']);
  /*
  *  die, if there's no such a file
  */
  if (!@file_exists(DOKU_PLUGIN.$_REQUEST['callback']."/".$_REQUEST['callback'].".php")) die ('Cannot access callback library');

  require_once DOKU_PLUGIN.$_REQUEST['callback']."/".$_REQUEST['callback'].".php";
  /*
  *  die, if callback function is not exists
  */
  if ((isset($_REQUEST['method']) && !function_exists($callback = $_REQUEST['callback']."_".$_REQUEST['method']))
      ||
      (!isset($_REQUEST['method']) && !function_exists($callback = $_REQUEST['callback']))
     )
    die ('Cannot start callback method');
  /*
  *  return the result
  */
  $_RESULT = call_user_func_array($callback,$_REQUEST['args']);

}
