lychee/php/access/admin.php

175 lines
6.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 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': Module::dependencies(isset($_POST['albumID']));
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
echo json_encode($album->get());
2014-02-09 18:21:55 +00:00
break;
case 'addAlbum': Module::dependencies(isset($_POST['title']));
$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': Module::dependencies(isset($_POST['albumIDs'], $_POST['title']));
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': Module::dependencies(isset($_POST['albumID'], $_POST['description']));
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': Module::dependencies(isset($_POST['albumID'], $_POST['password']));
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
echo $album->setPublic($_POST['password']);
2014-02-09 18:21:55 +00:00
break;
case 'setAlbumPassword': Module::dependencies(isset($_POST['albumID'], $_POST['password']));
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
echo $album->setPassword($_POST['password']);
2014-02-09 18:21:55 +00:00
break;
case 'deleteAlbum': Module::dependencies(isset($_POST['albumIDs']));
2014-04-03 16:38:58 +00:00
$album = new Album($database, $plugins, $settings, $_POST['albumIDs']);
echo $album->delete($_POST['albumIDs']);
2014-02-09 18:21:55 +00:00
break;
// Photo Functions
case 'getPhoto': Module::dependencies(isset($_POST['photoID'], $_POST['albumID']));
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;
case 'setPhotoTitle': Module::dependencies(isset($_POST['photoIDs'], $_POST['title']));
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;
case 'setPhotoDescription': Module::dependencies(isset($_POST['photoID'], $_POST['description']));
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;
case 'setPhotoStar': Module::dependencies(isset($_POST['photoIDs']));
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;
case 'setPhotoPublic': Module::dependencies(isset($_POST['photoID']));
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;
case 'setPhotoAlbum': Module::dependencies(isset($_POST['photoIDs'], $_POST['albumID']));
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;
case 'setPhotoTags': Module::dependencies(isset($_POST['photoIDs'], $_POST['tags']));
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
case 'deletePhoto': Module::dependencies(isset($_POST['photoIDs']));
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
case 'upload': Module::dependencies(isset($_FILES, $_POST['albumID']));
2014-04-11 22:30:26 +00:00
$photo = new Photo($database, $plugins, $settings, null);
echo $photo->add($_FILES, $_POST['albumID']);
2014-02-09 18:21:55 +00:00
break;
case 'importUrl': Module::dependencies(isset($_POST['url'], $_POST['albumID']));
echo Import::url($_POST['url'], $_POST['albumID']);
2014-02-09 18:21:55 +00:00
break;
case 'importServer': Module::dependencies(isset($_POST['albumID']));
echo Import::server($_POST['albumID'], null);
2014-02-09 18:21:55 +00:00
break;
// Search Function
case 'search': Module::dependencies(isset($_POST['term']));
2014-04-19 18:27:53 +00:00
echo json_encode(search($database, $settings, $_POST['term']));
2014-02-09 18:21:55 +00:00
break;
// Session Function
case 'init': Module::dependencies(isset($_POST['version']));
2014-04-04 19:10:32 +00:00
$session = new Session($plugins, $settings);
echo json_encode($session->init($database, $dbName, false, $_POST['version']));
2014-02-09 18:21:55 +00:00
break;
case 'login': Module::dependencies(isset($_POST['user'], $_POST['password']));
2014-04-04 19:10:32 +00:00
$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
case 'setLogin': Module::dependencies(isset($_POST['username'], $_POST['password']));
2014-04-04 21:17:54 +00:00
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;
case 'setSorting': Module::dependencies(isset($_POST['type'], $_POST['order']));
2014-04-04 21:17:54 +00:00
$settings = new Settings($database);
echo $settings->setSorting($_POST['type'], $_POST['order']);
2014-02-09 18:21:55 +00:00
break;
case 'setDropboxKey': Module::dependencies(isset($_POST['key']));
2014-04-04 21:17:54 +00:00
$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
case 'getAlbumArchive': Module::dependencies(isset($_GET['albumID']));
2014-04-04 15:18:59 +00:00
$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
case 'getPhotoArchive': Module::dependencies(isset($_GET['photoID']));
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;
}
?>