guest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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': $album = new Album($database, $plugins, $settings, null);
  12. echo json_encode($album->getAll(true));
  13. break;
  14. case 'getAlbum': if (!isset($_POST['albumID'], $_POST['password'])) exit();
  15. $album = new Album($database, $plugins, $settings, $_POST['albumID']);
  16. if ($album->getPublic()) {
  17. // Album Public
  18. if ($album->checkPassword($_POST['password'])) echo json_encode($album->get());
  19. else echo 'Warning: Wrong password!';
  20. } else {
  21. // Album Private
  22. echo 'Warning: Album private!';
  23. }
  24. break;
  25. case 'checkAlbumAccess':if (!isset($_POST['albumID'], $_POST['password'])) exit();
  26. $album = new Album($database, $plugins, $settings, $_POST['albumID']);
  27. if ($album->getPublic()) {
  28. // Album Public
  29. if ($album->checkPassword($_POST['password'])) echo true;
  30. else echo false;
  31. } else {
  32. // Album Private
  33. echo false;
  34. }
  35. break;
  36. // Photo Functions
  37. case 'getPhoto': if (isset($_POST['photoID'], $_POST['albumID'], $_POST['password'])) {
  38. if (isPhotoPublic($_POST['photoID'], $_POST['password']))
  39. echo json_encode(getPhoto($_POST['photoID'], $_POST['albumID']));
  40. else
  41. echo 'Warning: Wrong password!';
  42. }
  43. break;
  44. // Session Functions
  45. case 'init': echo json_encode(init('public', $_POST['version']));
  46. break;
  47. case 'login': if (isset($_POST['user'], $_POST['password']))
  48. echo login($_POST['user'], $_POST['password']);
  49. break;
  50. // Miscellaneous
  51. default: switch ($_GET['function']) {
  52. case 'getAlbumArchive': if (!isset($_GET['albumID'], $_GET['password'])) exit();
  53. $album = new Album($database, $plugins, $settings, $_GET['albumID']);
  54. // Album Download
  55. if ($album->getPublic()) {
  56. // Album Public
  57. if ($album->checkPassword($_GET['password'])) $album->getArchive();
  58. else exit('Warning: Wrong password!');
  59. } else {
  60. // Album Private
  61. exit('Warning: Album private or not downloadable!');
  62. }
  63. break;
  64. case 'getPhotoArchive': if (isset($_GET['photoID'], $_GET['password'])) {
  65. // Photo Download
  66. if (isPhotoPublic($_GET['photoID'], $_GET['password']))
  67. // Photo Public
  68. getPhotoArchive($_GET['photoID']);
  69. else
  70. // Photo Private
  71. exit('Warning: Photo private or not downloadable!');
  72. }
  73. break;
  74. default: exit('Error: Function not found! Please check the spelling of the called function.');
  75. break;
  76. }
  77. break;
  78. }
  79. ?>