EPESI BIM • Business Information Manager • Cloud CRM/ERP http://epe.si/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ajax.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. use Symfony\Component\HttpFoundation\Request;
  3. use Symfony\Component\HttpFoundation\Response;
  4. if (!isset($_GET['key']) || !isset($_GET['cid']) || !is_numeric($_GET['cid']))
  5. die('Error: Invalid request');
  6. define('CID', $_GET['cid']);
  7. define('READ_ONLY_SESSION', true);
  8. require_once('include.php');
  9. ModuleManager::load_modules();
  10. if (!isset($_SESSION['ajax_callbacks'])) {
  11. print('Session expired, please reload the page');
  12. return;
  13. }
  14. if (!isset($_SESSION['ajax_callbacks'][$_GET['key']])) {
  15. die('Invalid callback key');
  16. }
  17. $params = $_SESSION['ajax_callbacks'][$_GET['key']];
  18. $callback = $params['callback'];
  19. $args = $params['args'];
  20. if (!is_callable($callback))
  21. throw new Exception('Callback ' . print_r($callback, true) . ' is not callable');
  22. $request = Request::createFromGlobals();
  23. /** @var Response $response */
  24. $response = call_user_func_array($callback, array($request, $args));
  25. if(!$response instanceof Response)
  26. throw new Exception('Ajax callback must return instance of HttpFoundation\Response');
  27. $response->send();