guest.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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'])) exit();
  38. $photo = new Photo($database, $plugins, null, $_POST['photoID']);
  39. if ($photo->getPublic($_POST['password']))
  40. echo json_encode($photo->get($_POST['albumID']));
  41. else
  42. echo 'Warning: Wrong password!';
  43. break;
  44. // Session Functions
  45. case 'init': $session = new Session($plugins, $settings);
  46. echo json_encode($session->init($database, $dbName, true, $_POST['version']));
  47. break;
  48. case 'login': if (!isset($_POST['user'], $_POST['password'])) exit();
  49. $session = new Session($plugins, $settings);
  50. echo $session->login($_POST['user'], $_POST['password']);
  51. break;
  52. // Miscellaneous
  53. default: switch ($_GET['function']) {
  54. case 'getAlbumArchive': if (!isset($_GET['albumID'], $_GET['password'])) exit();
  55. $album = new Album($database, $plugins, $settings, $_GET['albumID']);
  56. // Album Download
  57. if ($album->getPublic()) {
  58. // Album Public
  59. if ($album->checkPassword($_GET['password'])) $album->getArchive();
  60. else exit('Warning: Wrong password!');
  61. } else {
  62. // Album Private
  63. exit('Warning: Album private or not downloadable!');
  64. }
  65. break;
  66. case 'getPhotoArchive': if (!isset($_GET['photoID'], $_GET['password'])) exit();
  67. $photo = new Photo($database, $plugins, null, $_GET['photoID']);
  68. // Photo Download
  69. if ($photo->getPublic($_GET['password']))
  70. // Photo Public
  71. $photo->getArchive();
  72. else
  73. // Photo Private
  74. exit('Warning: Photo private or not downloadable!');
  75. break;
  76. default: exit('Error: Function not found! Please check the spelling of the called function.');
  77. break;
  78. }
  79. break;
  80. }
  81. ?>