API_Controller.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * v1 API Controller file.
  4. *
  5. * Provides a class to handle all posible API requests.
  6. *
  7. * @category Constroller
  8. */
  9. /**
  10. * v1 API controller.
  11. *
  12. * Handles every API request.
  13. *
  14. * @category Controller
  15. */
  16. class API_Controller {
  17. /**
  18. * Constructor.
  19. *
  20. * Handles every request, creating the required models and selecting the
  21. * view.
  22. *
  23. * @param mixed[] $params GET parameters of the request.
  24. */
  25. public function __construct($params){
  26. // API call: Use API controller
  27. if (count($params) == 0){
  28. require_once(__DIR__ . "main.php");
  29. }
  30. else{
  31. $command = strtoupper($params[1]);
  32. switch ($command){
  33. case "log-profile":
  34. require_once(__DIR__ . "log-profile/index.php");
  35. break;
  36. case "log-run":
  37. require_once(__DIR__ . "log-run/index.php");
  38. break;
  39. default:
  40. header("HTTP/1.1 404");
  41. }
  42. }
  43. }
  44. }
  45. ?>