lychee/php/access/admin.php

175 lines
6.1 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-04-05 14:02:53 +00:00
case 'getPhoto': if (!isset($_POST['photoID'], $_POST['albumID'])) exit();
2014-04-11 22:30:26 +00:00
$photo = new Photo($database, $plugins, null, $_POST['photoID']);
2014-04-05 14:02:53 +00:00
echo json_encode($photo->get($_POST['albumID']));
2014-02-09 18:21:55 +00:00
break;
2014-04-05 14:02:53 +00:00
case 'setPhotoTitle': if (!isset($_POST['photoIDs'], $_POST['title'])) exit();
2014-04-11 22:30:26 +00:00
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
2014-04-05 14:02:53 +00:00
echo $photo->setTitle($_POST['title']);
2014-02-09 18:21:55 +00:00
break;
2014-04-05 14:02:53 +00:00
case 'setPhotoDescription': if (!isset($_POST['photoID'], $_POST['description'])) exit();
2014-04-11 22:30:26 +00:00
$photo = new Photo($database, $plugins, null, $_POST['photoID']);
2014-04-05 14:02:53 +00:00
echo $photo->setDescription($_POST['description']);
2014-02-09 18:21:55 +00:00
break;
2014-04-05 14:02:53 +00:00
case 'setPhotoStar': if (!isset($_POST['photoIDs'])) exit();
2014-04-11 22:30:26 +00:00
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
2014-04-05 14:02:53 +00:00
echo $photo->setStar();
2014-02-09 18:21:55 +00:00
break;
2014-04-05 14:02:53 +00:00
case 'setPhotoPublic': if (!isset($_POST['photoID'])) exit();
2014-04-11 22:30:26 +00:00
$photo = new Photo($database, $plugins, null, $_POST['photoID']);
2014-04-05 14:02:53 +00:00
echo $photo->setPublic();
2014-02-09 18:21:55 +00:00
break;
2014-04-05 14:02:53 +00:00
case 'setPhotoAlbum': if (!isset($_POST['photoIDs'], $_POST['albumID'])) exit();
2014-04-11 22:30:26 +00:00
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
2014-04-05 14:02:53 +00:00
echo $photo->setAlbum($_POST['albumID']);
2014-02-09 18:21:55 +00:00
break;
2014-04-05 14:02:53 +00:00
case 'setPhotoTags': if (!isset($_POST['photoIDs'], $_POST['tags'])) exit();
2014-04-11 22:30:26 +00:00
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
2014-04-05 14:02:53 +00:00
echo $photo->setTags($_POST['tags']);
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 'deletePhoto': if (!isset($_POST['photoIDs'])) exit();
2014-04-11 22:30:26 +00:00
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
2014-04-05 14:02:53 +00:00
echo $photo->delete();
2014-02-09 18:21:55 +00:00
break;
// Add Functions
2014-04-11 22:30:26 +00:00
case 'upload': if (!isset($_FILES, $_POST['albumID'])) exit();
$photo = new Photo($database, $plugins, $settings, null);
echo $photo->add($_FILES, $_POST['albumID']);
2014-02-09 18:21:55 +00:00
break;
case 'importUrl': if (!isset($_POST['url'], $_POST['albumID'])) exit();
echo Import::url($_POST['url'], $_POST['albumID']);
2014-02-09 18:21:55 +00:00
break;
case 'importServer': if (!isset($_POST['albumID'])) exit();
echo Import::server($_POST['albumID'], null);
2014-02-09 18:21:55 +00:00
break;
// Search Function
2014-04-19 18:27:53 +00:00
case 'search': if (!isset($_POST['term'])) exit();
echo json_encode(search($database, $settings, $_POST['term']));
2014-02-09 18:21:55 +00:00
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($database, $dbName, 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-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-04-05 14:02:53 +00:00
case 'getPhotoArchive': if (!isset($_GET['photoID'])) exit();
2014-04-11 22:30:26 +00:00
$photo = new Photo($database, $plugins, null, $_GET['photoID']);
2014-04-05 14:02:53 +00:00
$photo->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
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;
}
?>