lychee/php/access/admin.php

157 lines
4.5 KiB
PHP
Raw Normal View History

2014-02-09 18:21:55 +00:00
<?php
/**
2014-02-17 16:01:46 +00:00
* @name Admin Access
* @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_ADMIN')) exit('Error: You are not allowed to access this area!');
switch ($_POST['function']) {
// Album Functions
case 'getAlbums': echo json_encode(getAlbums(false));
break;
case 'getAlbum': if (isset($_POST['albumID']))
echo json_encode(getAlbum($_POST['albumID']));
break;
case 'addAlbum': if (isset($_POST['title']))
echo addAlbum($_POST['title']);
break;
2014-03-18 21:46:52 +00:00
case 'setAlbumTitle': if (isset($_POST['albumIDs'], $_POST['title']))
2014-02-09 18:21:55 +00:00
echo setAlbumTitle($_POST['albumIDs'], $_POST['title']);
break;
2014-03-18 21:46:52 +00:00
case 'setAlbumDescription': if (isset($_POST['albumID'], $_POST['description']))
2014-02-09 18:21:55 +00:00
echo setAlbumDescription($_POST['albumID'], $_POST['description']);
break;
case 'setAlbumPublic': if (isset($_POST['albumID']))
if (!isset($_POST['password'])) $_POST['password'] = '';
echo setAlbumPublic($_POST['albumID'], $_POST['password']);
break;
2014-03-18 21:46:52 +00:00
case 'setAlbumPassword': if (isset($_POST['albumID'], $_POST['password']))
2014-02-09 18:21:55 +00:00
echo setAlbumPassword($_POST['albumID'], $_POST['password']);
break;
case 'deleteAlbum': if (isset($_POST['albumIDs']))
echo deleteAlbum($_POST['albumIDs']);
break;
// Photo Functions
2014-03-18 21:46:52 +00:00
case 'getPhoto': if (isset($_POST['photoID'], $_POST['albumID']))
2014-02-09 18:21:55 +00:00
echo json_encode(getPhoto($_POST['photoID'], $_POST['albumID']));
break;
case 'deletePhoto': if (isset($_POST['photoIDs']))
echo deletePhoto($_POST['photoIDs']);
break;
2014-03-18 21:46:52 +00:00
case 'setPhotoAlbum': if (isset($_POST['photoIDs'], $_POST['albumID']))
2014-02-09 18:21:55 +00:00
echo setPhotoAlbum($_POST['photoIDs'], $_POST['albumID']);
break;
2014-03-18 21:46:52 +00:00
case 'setPhotoTitle': if (isset($_POST['photoIDs'], $_POST['title']))
2014-02-09 18:21:55 +00:00
echo setPhotoTitle($_POST['photoIDs'], $_POST['title']);
break;
case 'setPhotoStar': if (isset($_POST['photoIDs']))
echo setPhotoStar($_POST['photoIDs']);
break;
2014-03-18 21:46:52 +00:00
case 'setPhotoPublic': if (isset($_POST['photoID'], $_POST['url']))
2014-02-09 18:21:55 +00:00
echo setPhotoPublic($_POST['photoID'], $_POST['url']);
break;
2014-03-18 21:46:52 +00:00
case 'setPhotoDescription': if (isset($_POST['photoID'], $_POST['description']))
2014-02-09 18:21:55 +00:00
echo setPhotoDescription($_POST['photoID'], $_POST['description']);
break;
2014-02-17 16:01:46 +00:00
2014-03-18 21:46:52 +00:00
case 'setPhotoTags': if (isset($_POST['photoIDs'], $_POST['tags']))
2014-02-09 18:21:55 +00:00
echo setPhotoTags($_POST['photoIDs'], $_POST['tags']);
break;
// Add Functions
2014-03-18 21:46:52 +00:00
case 'upload': if (isset($_FILES, $_POST['albumID']))
2014-02-09 18:21:55 +00:00
echo upload($_FILES, $_POST['albumID']);
break;
2014-03-18 21:46:52 +00:00
case 'importUrl': if (isset($_POST['url'], $_POST['albumID']))
2014-02-09 18:21:55 +00:00
echo importUrl($_POST['url'], $_POST['albumID']);
break;
case 'importServer': if (isset($_POST['albumID']))
echo importServer($_POST['albumID']);
break;
// Search Function
case 'search': if (isset($_POST['term']))
echo json_encode(search($_POST['term']));
break;
// Session Function
2014-02-23 18:41:12 +00:00
case 'init': echo json_encode(init('admin', $_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;
case 'logout': logout();
break;
// Settings
2014-03-18 21:46:52 +00:00
case 'setLogin': if (isset($_POST['username'], $_POST['password']))
2014-02-09 18:21:55 +00:00
if (!isset($_POST['oldPassword'])) $_POST['oldPassword'] = '';
echo setLogin($_POST['oldPassword'], $_POST['username'], $_POST['password']);
break;
2014-03-18 21:46:52 +00:00
case 'setSorting': if (isset($_POST['type'], $_POST['order']))
2014-02-09 18:21:55 +00:00
echo setSorting($_POST['type'], $_POST['order']);
break;
2014-02-23 21:42:15 +00:00
case 'setDropboxKey': if (isset($_POST['key']))
echo setDropboxKey($_POST['key']);
break;
2014-02-09 18:21:55 +00:00
// Miscellaneous
default: switch ($_GET['function']) {
2014-02-17 16:01:46 +00:00
2014-02-09 18:21:55 +00:00
case 'getFeed': if (isset($_GET['albumID']))
echo getFeed($_GET['albumID']);
break;
2014-02-17 16:01:46 +00:00
2014-02-09 18:21:55 +00:00
case 'getAlbumArchive': if (isset($_GET['albumID']))
getAlbumArchive($_GET['albumID']);
break;
2014-02-17 16:01:46 +00:00
2014-02-09 18:21:55 +00:00
case 'getPhotoArchive': if (isset($_GET['photoID']))
getPhotoArchive($_GET['photoID']);
break;
2014-02-17 16:01:46 +00:00
2014-02-09 18:21:55 +00:00
case 'update': echo update();
break;
2014-02-17 16:01:46 +00:00
2014-02-09 18:21:55 +00:00
default: exit('Error: Function not found! Please check the spelling of the called function.');
break;
2014-02-17 16:01:46 +00:00
2014-02-09 18:21:55 +00:00
}
break;
}
?>