active_object_ping_linker.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Sloodle active object ping.
  4. * Allows active objects to notify the Sloodle installation that they are still 'alive'.
  5. *
  6. * @package sloodleclassroom
  7. * @copyright Copyright (c) 2008 Sloodle (various contributors)
  8. * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  9. *
  10. * @contributor Peter R. Bloomfield
  11. *
  12. */
  13. // The following parameters are required:
  14. //
  15. // sloodlecontrollerid = the ID of the controller through which the current object may access Sloodle
  16. // sloodlepwd = the prim password or object-specific session key to authenticate access
  17. // sloodleobjuuid = the UUID of the object which is active
  18. //
  19. //
  20. // If the check is successful, the status code will be 1.
  21. // If the object was not found, status code -103 is returned.
  22. //
  23. // NOTE: using the "sloodleobjuuid" parameter allows an object to ping on behalf of another.
  24. // However, the object must be authorised on the controller identified by "sloodlecontrollerid".
  25. //
  26. /** Lets Sloodle know we are in a linker script. */
  27. define('SLOODLE_LINKER_SCRIPT', true);
  28. /** Grab the Sloodle/Moodle configuration. */
  29. require_once('../init.php');
  30. /** Include the Sloodle PHP API. */
  31. require_once(SLOODLE_LIBROOT.'/sloodle_session.php');
  32. // Authenticate the request
  33. $sloodle = new SloodleSession();
  34. // The access record happens when we authenticate.
  35. // If it fails, it should error out and exit.
  36. $sloodle->authenticate_request();
  37. $sloodle->response->set_status_code(1);
  38. $sloodle->response->set_status_descriptor('OK');
  39. $sloodle->response->set_refresh_seconds(SLOODLE_PING_INTERVAL);
  40. // Output the response
  41. $sloodle->response->render_to_output();
  42. ?>