index.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * @author Tobias Reich
  4. * @copyright 2016 by Tobias Reich
  5. */
  6. namespace Lychee;
  7. use Lychee\Modules\Config;
  8. use Lychee\Modules\Response;
  9. use Lychee\Modules\Settings;
  10. use Lychee\Modules\Validator;
  11. use Lychee\Access\Installation;
  12. use Lychee\Access\Admin;
  13. use Lychee\Access\Guest;
  14. require(__DIR__ . '/define.php');
  15. require(__DIR__ . '/autoload.php');
  16. require(__DIR__ . '/helpers/fastImageCopyResampled.php');
  17. require(__DIR__ . '/helpers/generateID.php');
  18. require(__DIR__ . '/helpers/getExtension.php');
  19. require(__DIR__ . '/helpers/getGPSCoordinate.php');
  20. require(__DIR__ . '/helpers/getGraphHeader.php');
  21. require(__DIR__ . '/helpers/getHashedString.php');
  22. require(__DIR__ . '/helpers/hasPermissions.php');
  23. require(__DIR__ . '/helpers/search.php');
  24. // Define the called function
  25. if (isset($_POST['function'])) $fn = $_POST['function'];
  26. else if (isset($_GET['function'])) $fn = $_GET['function'];
  27. else $fn = null;
  28. // Check if a function has been specified
  29. if (!empty($fn)) {
  30. // Start the session and set the default timezone
  31. session_start();
  32. date_default_timezone_set('UTC');
  33. // Validate parameters
  34. if (isset($_POST['albumIDs'])&&Validator::isAlbumIDs($_POST['albumIDs'])===false) Response::error('Wrong parameter type for albumIDs!');
  35. if (isset($_POST['photoIDs'])&&Validator::isPhotoIDs($_POST['photoIDs'])===false) Response::error('Wrong parameter type for photoIDs!');
  36. if (isset($_POST['albumID'])&&Validator::isAlbumID($_POST['albumID'])==false) Response::error('Wrong parameter type for albumID!');
  37. if (isset($_POST['photoID'])&&Validator::isPhotoID($_POST['photoID'])==false) Response::error('Wrong parameter type for photoID!');
  38. // Check if a configuration exists
  39. if (Config::exists()===false) {
  40. /**
  41. * Installation Access
  42. * Limited access to configure Lychee. Only available when the config.php file is missing.
  43. */
  44. Installation::init($fn);
  45. exit();
  46. }
  47. // Check if user is logged
  48. if ((isset($_SESSION['login'])&&$_SESSION['login']===true)&&
  49. (isset($_SESSION['identifier'])&&$_SESSION['identifier']===Settings::get()['identifier'])) {
  50. /**
  51. * Admin Access
  52. * Full access to Lychee. Only with correct password/session.
  53. */
  54. Admin::init($fn);
  55. exit();
  56. } else {
  57. /**
  58. * Guest Access
  59. * Access to view all public folders and photos in Lychee.
  60. */
  61. Guest::init($fn);
  62. exit();
  63. }
  64. } else {
  65. Response::error('No API function specified!');
  66. }
  67. ?>