admin.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. /**
  3. * @name Admin Access
  4. * @author Tobias Reich
  5. * @copyright 2014 by Tobias Reich
  6. */
  7. if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
  8. if (!defined('LYCHEE_ACCESS_ADMIN')) exit('Error: You are not allowed to access this area!');
  9. switch ($_POST['function']) {
  10. // Album Functions
  11. case 'getAlbums': echo json_encode(getAlbums(false));
  12. break;
  13. case 'getAlbum': if (isset($_POST['albumID']))
  14. echo json_encode(getAlbum($_POST['albumID']));
  15. break;
  16. case 'addAlbum': if (isset($_POST['title']))
  17. echo addAlbum($_POST['title']);
  18. break;
  19. case 'setAlbumTitle': if (isset($_POST['albumIDs'])&&isset($_POST['title']))
  20. echo setAlbumTitle($_POST['albumIDs'], $_POST['title']);
  21. break;
  22. case 'setAlbumDescription': if (isset($_POST['albumID'])&&isset($_POST['description']))
  23. echo setAlbumDescription($_POST['albumID'], $_POST['description']);
  24. break;
  25. case 'setAlbumPublic': if (isset($_POST['albumID']))
  26. if (!isset($_POST['password'])) $_POST['password'] = '';
  27. echo setAlbumPublic($_POST['albumID'], $_POST['password']);
  28. break;
  29. case 'setAlbumPassword': if (isset($_POST['albumID'])&&isset($_POST['password']))
  30. echo setAlbumPassword($_POST['albumID'], $_POST['password']);
  31. break;
  32. case 'deleteAlbum': if (isset($_POST['albumIDs']))
  33. echo deleteAlbum($_POST['albumIDs']);
  34. break;
  35. // Photo Functions
  36. case 'getPhoto': if (isset($_POST['photoID'])&&isset($_POST['albumID']))
  37. echo json_encode(getPhoto($_POST['photoID'], $_POST['albumID']));
  38. break;
  39. case 'deletePhoto': if (isset($_POST['photoIDs']))
  40. echo deletePhoto($_POST['photoIDs']);
  41. break;
  42. case 'setPhotoAlbum': if (isset($_POST['photoIDs'])&&isset($_POST['albumID']))
  43. echo setPhotoAlbum($_POST['photoIDs'], $_POST['albumID']);
  44. break;
  45. case 'setPhotoTitle': if (isset($_POST['photoIDs'])&&isset($_POST['title']))
  46. echo setPhotoTitle($_POST['photoIDs'], $_POST['title']);
  47. break;
  48. case 'setPhotoStar': if (isset($_POST['photoIDs']))
  49. echo setPhotoStar($_POST['photoIDs']);
  50. break;
  51. case 'setPhotoPublic': if (isset($_POST['photoID'])&&isset($_POST['url']))
  52. echo setPhotoPublic($_POST['photoID'], $_POST['url']);
  53. break;
  54. case 'setPhotoDescription': if (isset($_POST['photoID'])&&isset($_POST['description']))
  55. echo setPhotoDescription($_POST['photoID'], $_POST['description']);
  56. break;
  57. case 'setPhotoTags': if (isset($_POST['photoIDs'])&&isset($_POST['tags']))
  58. echo setPhotoTags($_POST['photoIDs'], $_POST['tags']);
  59. break;
  60. // Add Functions
  61. case 'upload': if (isset($_FILES)&&isset($_POST['albumID']))
  62. echo upload($_FILES, $_POST['albumID']);
  63. break;
  64. case 'importUrl': if (isset($_POST['url'])&&isset($_POST['albumID']))
  65. echo importUrl($_POST['url'], $_POST['albumID']);
  66. break;
  67. case 'importServer': if (isset($_POST['albumID']))
  68. echo importServer($_POST['albumID']);
  69. break;
  70. // Search Function
  71. case 'search': if (isset($_POST['term']))
  72. echo json_encode(search($_POST['term']));
  73. break;
  74. // Session Function
  75. case 'init': echo json_encode(init('admin'));
  76. break;
  77. case 'login': if (isset($_POST['user'])&&isset($_POST['password']))
  78. echo login($_POST['user'], $_POST['password']);
  79. break;
  80. case 'logout': logout();
  81. break;
  82. // Settings
  83. case 'setLogin': if (isset($_POST['username'])&&isset($_POST['password']))
  84. if (!isset($_POST['oldPassword'])) $_POST['oldPassword'] = '';
  85. echo setLogin($_POST['oldPassword'], $_POST['username'], $_POST['password']);
  86. break;
  87. case 'setSorting': if (isset($_POST['type'])&&isset($_POST['order']))
  88. echo setSorting($_POST['type'], $_POST['order']);
  89. break;
  90. // Miscellaneous
  91. case 'update': echo update();
  92. default: switch ($_GET['function']) {
  93. case 'getFeed': if (isset($_GET['albumID']))
  94. echo getFeed($_GET['albumID']);
  95. break;
  96. case 'getAlbumArchive': if (isset($_GET['albumID']))
  97. getAlbumArchive($_GET['albumID']);
  98. break;
  99. case 'getPhotoArchive': if (isset($_GET['photoID']))
  100. getPhotoArchive($_GET['photoID']);
  101. break;
  102. case 'update': echo update();
  103. break;
  104. default: exit('Error: Function not found! Please check the spelling of the called function.');
  105. break;
  106. }
  107. break;
  108. }
  109. ?>