admin.php 5.6 KB

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