4
0

api.php 930 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. // Include functions
  3. require_once('functions.php');
  4. // Lazyload settings
  5. $databaseConfig = configLazy('config/config.php');
  6. // Get Action
  7. if (isset($_POST['a'])) { $action = $_POST['a']; }
  8. if (isset($_POST['k'])) { $key = $_POST['k']; }
  9. if (isset($_GET['a'])) { $action = $_GET['a']; }
  10. if (isset($_GET['k'])) { $key = $_GET['k']; }
  11. unset($_POST['a']);
  12. unset($_POST['k']);
  13. //Set Default Result
  14. $result = "An error has occurred";
  15. //Check Key
  16. if (!isset($key)) {
  17. exit(json_encode("No API Key set"));
  18. }elseif (strtolower(ORGANIZRAPI) != strtolower($key)) {
  19. exit(json_encode("API Key mismatch"));
  20. }
  21. //Start API Call
  22. if (isset($action)) {
  23. switch ($action) {
  24. case "1":
  25. $result = "test";
  26. break;
  27. case "2":
  28. $result = "other test";
  29. break;
  30. default:
  31. $result = "$action not defined";
  32. }
  33. }
  34. //return JSON array
  35. exit(json_encode($result));
  36. ?>