2014-01-22 10:12:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2014-02-17 16:01:46 +00:00
|
|
|
* @name API
|
|
|
|
* @author Tobias Reich
|
|
|
|
* @copyright 2014 by Tobias Reich
|
2014-01-22 10:12:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
@ini_set('max_execution_time', '200');
|
|
|
|
@ini_set('post_max_size', '200M');
|
|
|
|
@ini_set('upload_max_size', '200M');
|
|
|
|
@ini_set('upload_max_filesize', '20M');
|
|
|
|
@ini_set('max_file_uploads', '100');
|
|
|
|
|
|
|
|
if (!empty($_POST['function'])||!empty($_GET['function'])) {
|
|
|
|
|
|
|
|
session_start();
|
|
|
|
define('LYCHEE', true);
|
2014-02-09 18:21:55 +00:00
|
|
|
date_default_timezone_set('UTC');
|
2014-01-22 10:12:51 +00:00
|
|
|
|
2014-04-02 17:30:58 +00:00
|
|
|
// Load autoload
|
|
|
|
require('autoload.php');
|
|
|
|
|
2014-02-09 18:21:55 +00:00
|
|
|
// Load modules
|
|
|
|
require('modules/misc.php');
|
2014-01-22 10:12:51 +00:00
|
|
|
require('modules/upload.php');
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2014-02-07 23:08:18 +00:00
|
|
|
if (file_exists('../data/config.php')) require('../data/config.php');
|
2014-01-22 10:12:51 +00:00
|
|
|
else {
|
|
|
|
|
|
|
|
/**
|
2014-02-09 18:21:55 +00:00
|
|
|
* Installation Access
|
2014-01-22 10:12:51 +00:00
|
|
|
* Limited access to configure Lychee. Only available when the config.php file is missing.
|
|
|
|
*/
|
|
|
|
|
2014-02-09 18:21:55 +00:00
|
|
|
define('LYCHEE_ACCESS_INSTALLATION', true);
|
|
|
|
require('access/installation.php');
|
2014-01-22 10:12:51 +00:00
|
|
|
exit();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-04-04 21:17:54 +00:00
|
|
|
// Connect to database
|
2014-04-04 19:59:39 +00:00
|
|
|
$database = Database::connect($dbHost, $dbUser, $dbPassword, $dbName);
|
2014-04-04 21:17:54 +00:00
|
|
|
|
|
|
|
// Load settings
|
|
|
|
$settings = new Settings($database);
|
|
|
|
$settings = $settings->get();
|
2014-02-07 23:08:18 +00:00
|
|
|
|
2014-04-02 17:30:58 +00:00
|
|
|
// Init plugins
|
|
|
|
$plugins = explode(';', $settings['plugins']);
|
2014-04-02 20:14:20 +00:00
|
|
|
$plugins = new Plugins($plugins, $database);
|
2014-04-02 17:30:58 +00:00
|
|
|
|
2014-01-31 21:29:45 +00:00
|
|
|
// Escape
|
2014-02-09 18:21:55 +00:00
|
|
|
foreach(array_keys($_POST) as $key) $_POST[$key] = mysqli_real_escape_string($database, urldecode($_POST[$key]));
|
|
|
|
foreach(array_keys($_GET) as $key) $_GET[$key] = mysqli_real_escape_string($database, urldecode($_GET[$key]));
|
2014-01-22 10:12:51 +00:00
|
|
|
|
2014-01-31 21:29:45 +00:00
|
|
|
// Validate parameters
|
2014-02-09 18:21:55 +00:00
|
|
|
if (isset($_POST['albumIDs'])&&preg_match('/^[0-9\,]{1,}$/', $_POST['albumIDs'])!==1) exit('Error: Wrong parameter type for albumIDs!');
|
|
|
|
if (isset($_POST['photoIDs'])&&preg_match('/^[0-9\,]{1,}$/', $_POST['photoIDs'])!==1) exit('Error: Wrong parameter type for photoIDs!');
|
|
|
|
if (isset($_POST['albumID'])&&preg_match('/^[0-9sf]{1,}$/', $_POST['albumID'])!==1) exit('Error: Wrong parameter type for albumID!');
|
|
|
|
if (isset($_POST['photoID'])&&preg_match('/^[0-9]{14}$/', $_POST['photoID'])!==1) exit('Error: Wrong parameter type for photoID!');
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2014-02-09 18:21:55 +00:00
|
|
|
// Fallback for switch statement
|
|
|
|
if (!isset($_POST['function'])) $_POST['function'] = '';
|
|
|
|
if (!isset($_GET['function'])) $_GET['function'] = '';
|
2014-02-23 21:42:15 +00:00
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
if (isset($_SESSION['login'])&&$_SESSION['login']==true) {
|
|
|
|
|
|
|
|
/**
|
2014-02-09 18:21:55 +00:00
|
|
|
* Admin Access
|
2014-01-22 10:12:51 +00:00
|
|
|
* Full access to Lychee. Only with correct password/session.
|
|
|
|
*/
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2014-02-09 18:21:55 +00:00
|
|
|
define('LYCHEE_ACCESS_ADMIN', true);
|
|
|
|
require('access/admin.php');
|
2014-01-22 10:12:51 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/**
|
2014-02-09 18:21:55 +00:00
|
|
|
* Guest Access
|
2014-01-22 10:12:51 +00:00
|
|
|
* Access to view all public folders and photos in Lychee.
|
|
|
|
*/
|
|
|
|
|
2014-02-09 18:21:55 +00:00
|
|
|
define('LYCHEE_ACCESS_GUEST', true);
|
|
|
|
require('access/guest.php');
|
2014-01-22 10:12:51 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
exit('Error: No permission!');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-10-02 15:48:08 +00:00
|
|
|
?>
|