ajax.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. // Include functions if not already included
  3. require_once('functions.php');
  4. // Upgrade environment
  5. upgradeCheck();
  6. // Lazyload settings
  7. $databaseConfig = configLazy('config/config.php');
  8. // Authorization
  9. # Check if user is currently active and allowed to access resource
  10. //require_once("user.php");
  11. # ^^ I think adding this does that?
  12. // Get Action
  13. if (isset($_POST['submit'])) { $action = $_POST['submit']; }
  14. if (isset($_POST['action'])) { $action = $_POST['action']; }
  15. if (isset($_GET['action'])) { $action = $_GET['action']; }
  16. if (isset($_GET['a'])) { $action = $_GET['a']; }
  17. // No Action
  18. if (!isset($action)) {
  19. debug_out('No Action Specified!',1);
  20. }
  21. // Process Request
  22. switch ($_SERVER['REQUEST_METHOD']) {
  23. case 'GET':
  24. switch ($action) {
  25. case 'emby-image':
  26. getEmbyImage();
  27. break;
  28. case 'plex-image':
  29. getPlexImage();
  30. break;
  31. case 'emby-streams':
  32. echo getEmbyStreams(12);
  33. break;
  34. case 'plex-streams':
  35. echo getPlexStreams(12);
  36. break;
  37. case 'emby-recent':
  38. echo getEmbyRecent($_GET['type'], 12);
  39. break;
  40. case 'plex-recent':
  41. echo getPlexRecent($_GET['type'], 12);
  42. break;
  43. default:
  44. debug_out('Unsupported Action!',1);
  45. }
  46. break;
  47. case 'POST':
  48. switch ($action) {
  49. case 'upload-images':
  50. uploadFiles('images/', array('jpg', 'png', 'svg', 'jpeg', 'bmp'));
  51. break;
  52. case 'remove-images':
  53. removeFiles('images/'.(isset($_POST['file'])?$_POST['file']:''));
  54. break;
  55. case 'editCSS':
  56. write_ini_file($_POST["css-show"], "custom.css");
  57. echo '<script>window.top.location = window.top.location.href.split(\'#\')[0];</script>';
  58. break;
  59. default:
  60. debug_out('Unsupported Action!',1);
  61. }
  62. break;
  63. case 'PUT':
  64. break;
  65. case 'DELETE':
  66. break;
  67. default:
  68. debug_out('Unknown Request Type!',1);
  69. }