admin.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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': $album = new Albums($database, $plugins, $settings, null);
  12. echo json_encode($album->getAll(false));
  13. break;
  14. case 'getAlbum': if (isset($_POST['albumID']))
  15. echo json_encode(getAlbum($_POST['albumID']));
  16. break;
  17. case 'addAlbum': $album = new Albums($database, $plugins, $settings, null);
  18. echo $album->add($_POST['title']);
  19. break;
  20. case 'setAlbumTitle': if (isset($_POST['albumIDs'], $_POST['title']))
  21. echo setAlbumTitle($_POST['albumIDs'], $_POST['title']);
  22. break;
  23. case 'setAlbumDescription': if (isset($_POST['albumID'], $_POST['description']))
  24. echo setAlbumDescription($_POST['albumID'], $_POST['description']);
  25. break;
  26. case 'setAlbumPublic': if (isset($_POST['albumID']))
  27. if (!isset($_POST['password'])) $_POST['password'] = '';
  28. echo setAlbumPublic($_POST['albumID'], $_POST['password']);
  29. break;
  30. case 'setAlbumPassword': if (isset($_POST['albumID'], $_POST['password']))
  31. echo setAlbumPassword($_POST['albumID'], $_POST['password']);
  32. break;
  33. case 'deleteAlbum': if (isset($_POST['albumIDs']))
  34. echo deleteAlbum($_POST['albumIDs']);
  35. break;
  36. // Photo Functions
  37. case 'getPhoto': if (isset($_POST['photoID'], $_POST['albumID']))
  38. echo json_encode(getPhoto($_POST['photoID'], $_POST['albumID']));
  39. break;
  40. case 'deletePhoto': if (isset($_POST['photoIDs']))
  41. echo deletePhoto($_POST['photoIDs']);
  42. break;
  43. case 'setPhotoAlbum': if (isset($_POST['photoIDs'], $_POST['albumID']))
  44. echo setPhotoAlbum($_POST['photoIDs'], $_POST['albumID']);
  45. break;
  46. case 'setPhotoTitle': if (isset($_POST['photoIDs'], $_POST['title']))
  47. echo setPhotoTitle($_POST['photoIDs'], $_POST['title']);
  48. break;
  49. case 'setPhotoStar': if (isset($_POST['photoIDs']))
  50. echo setPhotoStar($_POST['photoIDs']);
  51. break;
  52. case 'setPhotoPublic': if (isset($_POST['photoID'], $_POST['url']))
  53. echo setPhotoPublic($_POST['photoID'], $_POST['url']);
  54. break;
  55. case 'setPhotoDescription': if (isset($_POST['photoID'], $_POST['description']))
  56. echo setPhotoDescription($_POST['photoID'], $_POST['description']);
  57. break;
  58. case 'setPhotoTags': if (isset($_POST['photoIDs'], $_POST['tags']))
  59. echo setPhotoTags($_POST['photoIDs'], $_POST['tags']);
  60. break;
  61. // Add Functions
  62. case 'upload': if (isset($_FILES, $_POST['albumID']))
  63. echo upload($_FILES, $_POST['albumID']);
  64. break;
  65. case 'importUrl': if (isset($_POST['url'], $_POST['albumID']))
  66. echo importUrl($_POST['url'], $_POST['albumID']);
  67. break;
  68. case 'importServer': if (isset($_POST['albumID']))
  69. echo importServer($_POST['albumID']);
  70. break;
  71. // Search Function
  72. case 'search': if (isset($_POST['term']))
  73. echo json_encode(search($_POST['term']));
  74. break;
  75. // Session Function
  76. case 'init': echo json_encode(init('admin', $_POST['version']));
  77. break;
  78. case 'login': if (isset($_POST['user'], $_POST['password']))
  79. echo login($_POST['user'], $_POST['password']);
  80. break;
  81. case 'logout': logout();
  82. break;
  83. // Settings
  84. case 'setLogin': if (isset($_POST['username'], $_POST['password']))
  85. if (!isset($_POST['oldPassword'])) $_POST['oldPassword'] = '';
  86. echo setLogin($_POST['oldPassword'], $_POST['username'], $_POST['password']);
  87. break;
  88. case 'setSorting': if (isset($_POST['type'], $_POST['order']))
  89. echo setSorting($_POST['type'], $_POST['order']);
  90. break;
  91. case 'setDropboxKey': if (isset($_POST['key']))
  92. echo setDropboxKey($_POST['key']);
  93. break;
  94. // Miscellaneous
  95. default: switch ($_GET['function']) {
  96. case 'getFeed': if (isset($_GET['albumID']))
  97. echo getFeed($_GET['albumID']);
  98. break;
  99. case 'getAlbumArchive': if (isset($_GET['albumID']))
  100. getAlbumArchive($_GET['albumID']);
  101. break;
  102. case 'getPhotoArchive': if (isset($_GET['photoID']))
  103. getPhotoArchive($_GET['photoID']);
  104. break;
  105. case 'update': echo update();
  106. break;
  107. default: exit('Error: Function not found! Please check the spelling of the called function.');
  108. break;
  109. }
  110. break;
  111. }
  112. ?>