lychee/php/access/admin.php

172 lines
5.6 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
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(false));
2014-02-09 18:21:55 +00:00
break;
case 'getAlbum': if (!isset($_POST['albumID'])) exit();
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
echo json_encode($album->get());
2014-02-09 18:21:55 +00:00
break;
case 'addAlbum': if (!isset($_POST['title'])) exit();
$album = new Album($database, $plugins, $settings, null);
2014-04-02 20:14:20 +00:00
echo $album->add($_POST['title']);
2014-02-09 18:21:55 +00:00
break;
case 'setAlbumTitle': if (!isset($_POST['albumIDs'], $_POST['title'])) exit();
2014-04-03 16:38:58 +00:00
$album = new Album($database, $plugins, $settings, $_POST['albumIDs']);
echo $album->setTitle($_POST['title']);
2014-02-09 18:21:55 +00:00
break;
case 'setAlbumDescription': if (!isset($_POST['albumID'], $_POST['description'])) exit();
2014-04-03 16:38:58 +00:00
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
echo $album->setDescription($_POST['description']);
2014-02-09 18:21:55 +00:00
break;
case 'setAlbumPublic': if (!isset($_POST['albumID'], $_POST['password'])) exit();
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
echo $album->setPublic($_POST['password']);
2014-02-09 18:21:55 +00:00
break;
case 'setAlbumPassword': if (!isset($_POST['albumID'], $_POST['password'])) exit();
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
echo $album->setPassword($_POST['password']);
2014-02-09 18:21:55 +00:00
break;
2014-04-03 16:38:58 +00:00
case 'deleteAlbum': if (!isset($_POST['albumIDs'])) exit();
$album = new Album($database, $plugins, $settings, $_POST['albumIDs']);
echo $album->delete($_POST['albumIDs']);
2014-02-09 18:21:55 +00:00
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-04-04 19:10:32 +00:00
case 'init': if (!isset($_POST['version'])) exit();
$session = new Session($plugins, $settings);
echo json_encode($session->init(false, $_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;
2014-04-04 19:10:32 +00:00
case 'logout': $session = new Session($plugins, $settings);
echo $session->logout();
2014-02-09 18:21:55 +00:00
break;
2014-04-04 19:10:32 +00:00
// Settings Function
2014-02-09 18:21:55 +00:00
2014-04-04 21:17:54 +00:00
case 'setLogin': if (!isset($_POST['username'], $_POST['password'])) exit();
if (!isset($_POST['oldPassword'])) $_POST['oldPassword'] = '';
$settings = new Settings($database);
echo $settings->setLogin($_POST['oldPassword'], $_POST['username'], $_POST['password']);
2014-02-09 18:21:55 +00:00
break;
2014-04-04 21:17:54 +00:00
case 'setSorting': if (!isset($_POST['type'], $_POST['order'])) exit();
$settings = new Settings($database);
echo $settings->setSorting($_POST['type'], $_POST['order']);
2014-02-09 18:21:55 +00:00
break;
2014-04-04 21:17:54 +00:00
case 'setDropboxKey': if (!isset($_POST['key'])) exit();
$settings = new Settings($database);
echo $settings->setDropboxKey($_POST['key']);
2014-02-23 21:42:15 +00:00
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-04-04 15:18:59 +00:00
case 'getAlbumArchive': if (!isset($_GET['albumID'])) exit();
$album = new Album($database, $plugins, $settings, $_GET['albumID']);
$album->getArchive();
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
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;
}
?>