index.php 2.3 KB

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