lychee/php/access/guest.php

106 lines
3.3 KiB
PHP
Raw Normal View History

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
2014-04-02 20:15:59 +00:00
case 'getAlbums': $album = new Album($database, $plugins, $settings, null);
2014-04-02 20:14:20 +00:00
echo json_encode($album->getAll(true));
2014-02-09 18:21:55 +00:00
break;
case 'getAlbum': if (!isset($_POST['albumID'], $_POST['password'])) exit();
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
if ($album->getPublic()) {
// Album Public
if ($album->checkPassword($_POST['password'])) echo json_encode($album->get());
else echo 'Warning: Wrong password!';
} else {
// Album Private
echo 'Warning: Album private!';
2014-02-09 18:21:55 +00:00
}
break;
case 'checkAlbumAccess':if (!isset($_POST['albumID'], $_POST['password'])) exit();
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
if ($album->getPublic()) {
// Album Public
if ($album->checkPassword($_POST['password'])) echo true;
else echo false;
} else {
// Album Private
echo false;
2014-02-09 18:21:55 +00:00
}
break;
// Photo Functions
2014-04-05 14:02:53 +00:00
case 'getPhoto': if (!isset($_POST['photoID'], $_POST['albumID'], $_POST['password'])) exit();
$photo = new Photo($database, $plugins, $_POST['photoID']);
if ($photo->getPublic($_POST['password']))
echo json_encode($photo->get($_POST['albumID']));
else
echo 'Warning: Wrong password!';
2014-02-09 18:21:55 +00:00
break;
// Session Functions
2014-04-04 19:10:32 +00:00
case 'init': $session = new Session($plugins, $settings);
echo json_encode($session->init($database, $dbName, true, $_POST['version']));
2014-02-09 18:21:55 +00:00
break;
2014-04-04 19:10:32 +00:00
case 'login': if (!isset($_POST['user'], $_POST['password'])) exit();
$session = new Session($plugins, $settings);
echo $session->login($_POST['user'], $_POST['password']);
2014-02-09 18:21:55 +00:00
break;
// Miscellaneous
default: switch ($_GET['function']) {
2014-02-17 16:01:46 +00:00
2014-04-04 15:18:59 +00:00
case 'getAlbumArchive': if (!isset($_GET['albumID'], $_GET['password'])) exit();
$album = new Album($database, $plugins, $settings, $_GET['albumID']);
2014-04-04 15:18:59 +00:00
// Album Download
if ($album->getPublic()) {
2014-04-04 15:18:59 +00:00
// Album Public
if ($album->checkPassword($_GET['password'])) $album->getArchive();
else exit('Warning: Wrong password!');
2014-04-04 15:18:59 +00:00
} else {
// Album Private
exit('Warning: Album private or not downloadable!');
2014-02-09 18:21:55 +00:00
}
2014-04-04 15:18:59 +00:00
2014-02-09 18:21:55 +00:00
break;
2014-02-17 16:01:46 +00:00
2014-04-05 14:02:53 +00:00
case 'getPhotoArchive': if (!isset($_GET['photoID'], $_GET['password'])) exit();
$photo = new Photo($database, $plugins, $_GET['photoID']);
2014-02-17 16:01:46 +00:00
2014-04-05 14:02:53 +00:00
// Photo Download
if ($photo->getPublic($_GET['password']))
// Photo Public
$photo->getArchive();
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;
}
?>