2014-02-09 18:21:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2014-02-17 16:01:46 +00:00
|
|
|
* @name Guest Access (Public Mode)
|
|
|
|
* @author Tobias Reich
|
|
|
|
* @copyright 2014 by Tobias Reich
|
2014-02-09 18:21:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
|
|
|
if (!defined('LYCHEE_ACCESS_GUEST')) exit('Error: You are not allowed to access this area!');
|
|
|
|
|
|
|
|
switch ($_POST['function']) {
|
|
|
|
|
|
|
|
// Album Functions
|
|
|
|
|
|
|
|
case 'getAlbums': echo json_encode(getAlbums(true));
|
|
|
|
break;
|
|
|
|
|
2014-03-18 21:46:52 +00:00
|
|
|
case 'getAlbum': if (isset($_POST['albumID'], $_POST['password'])) {
|
2014-02-09 18:21:55 +00:00
|
|
|
if (isAlbumPublic($_POST['albumID'])) {
|
|
|
|
// Album Public
|
|
|
|
if (checkAlbumPassword($_POST['albumID'], $_POST['password']))
|
|
|
|
echo json_encode(getAlbum($_POST['albumID']));
|
|
|
|
else
|
|
|
|
echo 'Warning: Wrong password!';
|
|
|
|
} else {
|
|
|
|
// Album Private
|
|
|
|
echo 'Warning: Album private!';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-03-18 21:46:52 +00:00
|
|
|
case 'checkAlbumAccess':if (isset($_POST['albumID'], $_POST['password'])) {
|
2014-02-09 18:21:55 +00:00
|
|
|
if (isAlbumPublic($_POST['albumID'])) {
|
|
|
|
// Album Public
|
|
|
|
if (checkAlbumPassword($_POST['albumID'], $_POST['password']))
|
|
|
|
echo true;
|
|
|
|
else
|
|
|
|
echo false;
|
|
|
|
} else {
|
|
|
|
// Album Private
|
|
|
|
echo false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Photo Functions
|
|
|
|
|
2014-03-18 21:46:52 +00:00
|
|
|
case 'getPhoto': if (isset($_POST['photoID'], $_POST['albumID'], $_POST['password'])) {
|
2014-02-09 18:21:55 +00:00
|
|
|
if (isPhotoPublic($_POST['photoID'], $_POST['password']))
|
|
|
|
echo json_encode(getPhoto($_POST['photoID'], $_POST['albumID']));
|
|
|
|
else
|
|
|
|
echo 'Warning: Wrong password!';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Session Functions
|
|
|
|
|
2014-02-23 18:41:12 +00:00
|
|
|
case 'init': echo json_encode(init('public', $_POST['version']));
|
2014-02-09 18:21:55 +00:00
|
|
|
break;
|
|
|
|
|
2014-03-18 21:46:52 +00:00
|
|
|
case 'login': if (isset($_POST['user'], $_POST['password']))
|
2014-02-09 18:21:55 +00:00
|
|
|
echo login($_POST['user'], $_POST['password']);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Miscellaneous
|
|
|
|
|
|
|
|
default: switch ($_GET['function']) {
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2014-03-18 21:46:52 +00:00
|
|
|
case 'getFeed': if (isset($_GET['albumID'], $_GET['password'])) {
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2014-02-09 18:21:55 +00:00
|
|
|
// Album Feed
|
|
|
|
if (isAlbumPublic($_GET['albumID'])) {
|
|
|
|
// Album Public
|
|
|
|
if (checkAlbumPassword($_GET['albumID'], $_GET['password']))
|
|
|
|
echo getFeed($_GET['albumID']);
|
|
|
|
else
|
|
|
|
exit('Warning: Wrong password!');
|
|
|
|
} else {
|
|
|
|
// Album Private
|
|
|
|
exit('Warning: Album private!');
|
|
|
|
}
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2014-02-09 18:21:55 +00:00
|
|
|
}
|
|
|
|
break;
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2014-03-18 21:46:52 +00:00
|
|
|
case 'getAlbumArchive': if (isset($_GET['albumID'], $_GET['password'])) {
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2014-02-09 18:21:55 +00:00
|
|
|
// Album Download
|
|
|
|
if (isAlbumPublic($_GET['albumID'])) {
|
|
|
|
// Album Public
|
|
|
|
if (checkAlbumPassword($_GET['albumID'], $_GET['password']))
|
|
|
|
getAlbumArchive($_GET['albumID']);
|
|
|
|
else
|
|
|
|
exit('Warning: Wrong password!');
|
|
|
|
} else {
|
|
|
|
// Album Private
|
|
|
|
exit('Warning: Album private or not downloadable!');
|
|
|
|
}
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2014-02-09 18:21:55 +00:00
|
|
|
}
|
|
|
|
break;
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2014-03-18 21:46:52 +00:00
|
|
|
case 'getPhotoArchive': if (isset($_GET['photoID'], $_GET['password'])) {
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2014-02-09 18:21:55 +00:00
|
|
|
// Photo Download
|
|
|
|
if (isPhotoPublic($_GET['photoID'], $_GET['password']))
|
|
|
|
// Photo Public
|
|
|
|
getPhotoArchive($_GET['photoID']);
|
|
|
|
else
|
|
|
|
// Photo Private
|
|
|
|
exit('Warning: Photo private or not downloadable!');
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2014-02-09 18:21:55 +00:00
|
|
|
}
|
|
|
|
break;
|
2014-02-17 16:01:46 +00:00
|
|
|
|
|
|
|
default: exit('Error: Function not found! Please check the spelling of the called function.');
|
2014-02-09 18:21:55 +00:00
|
|
|
break;
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2014-02-09 18:21:55 +00:00
|
|
|
}
|
2014-02-17 16:01:46 +00:00
|
|
|
|
2014-02-09 18:21:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|