2014-01-22 10:12:51 +00:00
|
|
|
<?php
|
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
/**
|
|
|
|
* @author Tobias Reich
|
|
|
|
* @copyright 2016 by Tobias Reich
|
|
|
|
*/
|
2014-01-22 10:12:51 +00:00
|
|
|
|
2016-01-26 14:31:53 +00:00
|
|
|
namespace Lychee;
|
|
|
|
|
|
|
|
use Lychee\Modules\Config;
|
2016-02-06 23:16:48 +00:00
|
|
|
use Lychee\Modules\Response;
|
2016-01-26 14:31:53 +00:00
|
|
|
use Lychee\Modules\Settings;
|
2016-01-30 20:33:31 +00:00
|
|
|
use Lychee\Modules\Validator;
|
2016-01-26 14:31:53 +00:00
|
|
|
|
|
|
|
use Lychee\Access\Installation;
|
|
|
|
use Lychee\Access\Admin;
|
|
|
|
use Lychee\Access\Guest;
|
|
|
|
|
|
|
|
require(__DIR__ . '/define.php');
|
|
|
|
require(__DIR__ . '/autoload.php');
|
|
|
|
|
|
|
|
require(__DIR__ . '/helpers/fastImageCopyResampled.php');
|
|
|
|
require(__DIR__ . '/helpers/getExtension.php');
|
|
|
|
require(__DIR__ . '/helpers/getGraphHeader.php');
|
|
|
|
require(__DIR__ . '/helpers/getHashedString.php');
|
|
|
|
require(__DIR__ . '/helpers/hasPermissions.php');
|
|
|
|
require(__DIR__ . '/helpers/search.php');
|
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
// Define the called function
|
|
|
|
if (isset($_POST['function'])) $fn = $_POST['function'];
|
|
|
|
else if (isset($_GET['function'])) $fn = $_GET['function'];
|
|
|
|
else $fn = null;
|
2014-01-22 10:12:51 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
// Check if a function has been specified
|
2016-01-19 15:09:06 +00:00
|
|
|
if (!empty($fn)) {
|
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
// Start the session and set the default timezone
|
2014-01-22 10:12:51 +00:00
|
|
|
session_start();
|
2014-02-09 18:21:55 +00:00
|
|
|
date_default_timezone_set('UTC');
|
2014-01-22 10:12:51 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
// Validate parameters
|
2016-02-06 23:16:48 +00:00
|
|
|
if (isset($_POST['albumIDs'])&&Validator::isAlbumIDs($_POST['albumIDs'])===false) Response::error('Wrong parameter type for albumIDs!');
|
|
|
|
if (isset($_POST['photoIDs'])&&Validator::isPhotoIDs($_POST['photoIDs'])===false) Response::error('Wrong parameter type for photoIDs!');
|
|
|
|
if (isset($_POST['albumID'])&&Validator::isAlbumID($_POST['albumID'])==false) Response::error('Wrong parameter type for albumID!');
|
|
|
|
if (isset($_POST['photoID'])&&Validator::isPhotoID($_POST['photoID'])==false) Response::error('Wrong parameter type for photoID!');
|
2016-01-19 15:09:06 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
// Check if a configuration exists
|
2016-01-24 21:14:20 +00:00
|
|
|
if (Config::exists()===false) {
|
2014-01-22 10:12:51 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
/**
|
|
|
|
* Installation Access
|
|
|
|
* Limited access to configure Lychee. Only available when the config.php file is missing.
|
|
|
|
*/
|
2014-01-22 10:12:51 +00:00
|
|
|
|
2016-01-30 20:33:31 +00:00
|
|
|
Installation::init($fn);
|
2014-01-22 10:12:51 +00:00
|
|
|
exit();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
// Check if user is logged
|
2015-05-14 19:07:42 +00:00
|
|
|
if ((isset($_SESSION['login'])&&$_SESSION['login']===true)&&
|
2016-01-24 21:14:20 +00:00
|
|
|
(isset($_SESSION['identifier'])&&$_SESSION['identifier']===Settings::get()['identifier'])) {
|
2014-01-22 10:12:51 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
/**
|
|
|
|
* Admin Access
|
|
|
|
* Full access to Lychee. Only with correct password/session.
|
|
|
|
*/
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2016-01-30 20:33:31 +00:00
|
|
|
Admin::init($fn);
|
2016-01-24 21:30:57 +00:00
|
|
|
exit();
|
2014-01-22 10:12:51 +00:00
|
|
|
|
2016-01-30 20:33:31 +00:00
|
|
|
} else {
|
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
/**
|
|
|
|
* Guest Access
|
|
|
|
* Access to view all public folders and photos in Lychee.
|
|
|
|
*/
|
2014-01-22 10:12:51 +00:00
|
|
|
|
2016-01-30 20:33:31 +00:00
|
|
|
Guest::init($fn);
|
|
|
|
exit();
|
2014-01-22 10:12:51 +00:00
|
|
|
|
2016-01-30 20:33:31 +00:00
|
|
|
}
|
2014-01-22 10:12:51 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2016-02-06 23:16:48 +00:00
|
|
|
Response::error('No API function specified!');
|
2014-01-22 10:12:51 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-01-19 15:09:06 +00:00
|
|
|
?>
|