ajax.php 1.8 KB

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