guest.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * @name Guest Access (Public Mode)
  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_GUEST')) exit('Error: You are not allowed to access this area!');
  9. switch ($_POST['function']) {
  10. // Album Functions
  11. case 'getAlbums': echo json_encode(getAlbums(true));
  12. break;
  13. case 'getAlbum': if (isset($_POST['albumID'])&&isset($_POST['password'])) {
  14. if (isAlbumPublic($_POST['albumID'])) {
  15. // Album Public
  16. if (checkAlbumPassword($_POST['albumID'], $_POST['password']))
  17. echo json_encode(getAlbum($_POST['albumID']));
  18. else
  19. echo 'Warning: Wrong password!';
  20. } else {
  21. // Album Private
  22. echo 'Warning: Album private!';
  23. }
  24. }
  25. break;
  26. case 'checkAlbumAccess':if (isset($_POST['albumID'])&&isset($_POST['password'])) {
  27. if (isAlbumPublic($_POST['albumID'])) {
  28. // Album Public
  29. if (checkAlbumPassword($_POST['albumID'], $_POST['password']))
  30. echo true;
  31. else
  32. echo false;
  33. } else {
  34. // Album Private
  35. echo false;
  36. }
  37. }
  38. break;
  39. // Photo Functions
  40. case 'getPhoto': if (isset($_POST['photoID'])&&isset($_POST['albumID'])&&isset($_POST['password'])) {
  41. if (isPhotoPublic($_POST['photoID'], $_POST['password']))
  42. echo json_encode(getPhoto($_POST['photoID'], $_POST['albumID']));
  43. else
  44. echo 'Warning: Wrong password!';
  45. }
  46. break;
  47. // Session Functions
  48. case 'init': echo json_encode(init('public', $_POST['version']));
  49. break;
  50. case 'login': if (isset($_POST['user'])&&isset($_POST['password']))
  51. echo login($_POST['user'], $_POST['password']);
  52. break;
  53. // Miscellaneous
  54. default: switch ($_GET['function']) {
  55. case 'getFeed': if (isset($_GET['albumID'])&&isset($_GET['password'])) {
  56. // Album Feed
  57. if (isAlbumPublic($_GET['albumID'])) {
  58. // Album Public
  59. if (checkAlbumPassword($_GET['albumID'], $_GET['password']))
  60. echo getFeed($_GET['albumID']);
  61. else
  62. exit('Warning: Wrong password!');
  63. } else {
  64. // Album Private
  65. exit('Warning: Album private!');
  66. }
  67. }
  68. break;
  69. case 'getAlbumArchive': if (isset($_GET['albumID'])&&isset($_GET['password'])) {
  70. // Album Download
  71. if (isAlbumPublic($_GET['albumID'])) {
  72. // Album Public
  73. if (checkAlbumPassword($_GET['albumID'], $_GET['password']))
  74. getAlbumArchive($_GET['albumID']);
  75. else
  76. exit('Warning: Wrong password!');
  77. } else {
  78. // Album Private
  79. exit('Warning: Album private or not downloadable!');
  80. }
  81. }
  82. break;
  83. case 'getPhotoArchive': if (isset($_GET['photoID'])&&isset($_GET['password'])) {
  84. // Photo Download
  85. if (isPhotoPublic($_GET['photoID'], $_GET['password']))
  86. // Photo Public
  87. getPhotoArchive($_GET['photoID']);
  88. else
  89. // Photo Private
  90. exit('Warning: Photo private or not downloadable!');
  91. }
  92. break;
  93. default: exit('Error: Function not found! Please check the spelling of the called function.');
  94. break;
  95. }
  96. break;
  97. }
  98. ?>