Return error when called function misses parameters
This commit is contained in:
parent
60d298db6d
commit
bb1699402c
@ -17,112 +17,112 @@ switch ($_POST['function']) {
|
|||||||
echo json_encode($album->getAll(false));
|
echo json_encode($album->getAll(false));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'getAlbum': if (!isset($_POST['albumID'])) exit();
|
case 'getAlbum': Module::dependencies(isset($_POST['albumID']));
|
||||||
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
|
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
|
||||||
echo json_encode($album->get());
|
echo json_encode($album->get());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'addAlbum': if (!isset($_POST['title'])) exit();
|
case 'addAlbum': Module::dependencies(isset($_POST['title']));
|
||||||
$album = new Album($database, $plugins, $settings, null);
|
$album = new Album($database, $plugins, $settings, null);
|
||||||
echo $album->add($_POST['title']);
|
echo $album->add($_POST['title']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'setAlbumTitle': if (!isset($_POST['albumIDs'], $_POST['title'])) exit();
|
case 'setAlbumTitle': Module::dependencies(isset($_POST['albumIDs'], $_POST['title']));
|
||||||
$album = new Album($database, $plugins, $settings, $_POST['albumIDs']);
|
$album = new Album($database, $plugins, $settings, $_POST['albumIDs']);
|
||||||
echo $album->setTitle($_POST['title']);
|
echo $album->setTitle($_POST['title']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'setAlbumDescription': if (!isset($_POST['albumID'], $_POST['description'])) exit();
|
case 'setAlbumDescription': Module::dependencies(isset($_POST['albumID'], $_POST['description']));
|
||||||
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
|
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
|
||||||
echo $album->setDescription($_POST['description']);
|
echo $album->setDescription($_POST['description']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'setAlbumPublic': if (!isset($_POST['albumID'], $_POST['password'])) exit();
|
case 'setAlbumPublic': Module::dependencies(isset($_POST['albumID'], $_POST['password']));
|
||||||
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
|
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
|
||||||
echo $album->setPublic($_POST['password']);
|
echo $album->setPublic($_POST['password']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'setAlbumPassword': if (!isset($_POST['albumID'], $_POST['password'])) exit();
|
case 'setAlbumPassword': Module::dependencies(isset($_POST['albumID'], $_POST['password']));
|
||||||
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
|
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
|
||||||
echo $album->setPassword($_POST['password']);
|
echo $album->setPassword($_POST['password']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'deleteAlbum': if (!isset($_POST['albumIDs'])) exit();
|
case 'deleteAlbum': Module::dependencies(isset($_POST['albumIDs']));
|
||||||
$album = new Album($database, $plugins, $settings, $_POST['albumIDs']);
|
$album = new Album($database, $plugins, $settings, $_POST['albumIDs']);
|
||||||
echo $album->delete($_POST['albumIDs']);
|
echo $album->delete($_POST['albumIDs']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Photo Functions
|
// Photo Functions
|
||||||
|
|
||||||
case 'getPhoto': if (!isset($_POST['photoID'], $_POST['albumID'])) exit();
|
case 'getPhoto': Module::dependencies(isset($_POST['photoID'], $_POST['albumID']));
|
||||||
$photo = new Photo($database, $plugins, null, $_POST['photoID']);
|
$photo = new Photo($database, $plugins, null, $_POST['photoID']);
|
||||||
echo json_encode($photo->get($_POST['albumID']));
|
echo json_encode($photo->get($_POST['albumID']));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'setPhotoTitle': if (!isset($_POST['photoIDs'], $_POST['title'])) exit();
|
case 'setPhotoTitle': Module::dependencies(isset($_POST['photoIDs'], $_POST['title']));
|
||||||
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
|
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
|
||||||
echo $photo->setTitle($_POST['title']);
|
echo $photo->setTitle($_POST['title']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'setPhotoDescription': if (!isset($_POST['photoID'], $_POST['description'])) exit();
|
case 'setPhotoDescription': Module::dependencies(isset($_POST['photoID'], $_POST['description']));
|
||||||
$photo = new Photo($database, $plugins, null, $_POST['photoID']);
|
$photo = new Photo($database, $plugins, null, $_POST['photoID']);
|
||||||
echo $photo->setDescription($_POST['description']);
|
echo $photo->setDescription($_POST['description']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'setPhotoStar': if (!isset($_POST['photoIDs'])) exit();
|
case 'setPhotoStar': Module::dependencies(isset($_POST['photoIDs']));
|
||||||
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
|
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
|
||||||
echo $photo->setStar();
|
echo $photo->setStar();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'setPhotoPublic': if (!isset($_POST['photoID'])) exit();
|
case 'setPhotoPublic': Module::dependencies(isset($_POST['photoID']));
|
||||||
$photo = new Photo($database, $plugins, null, $_POST['photoID']);
|
$photo = new Photo($database, $plugins, null, $_POST['photoID']);
|
||||||
echo $photo->setPublic();
|
echo $photo->setPublic();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'setPhotoAlbum': if (!isset($_POST['photoIDs'], $_POST['albumID'])) exit();
|
case 'setPhotoAlbum': Module::dependencies(isset($_POST['photoIDs'], $_POST['albumID']));
|
||||||
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
|
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
|
||||||
echo $photo->setAlbum($_POST['albumID']);
|
echo $photo->setAlbum($_POST['albumID']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'setPhotoTags': if (!isset($_POST['photoIDs'], $_POST['tags'])) exit();
|
case 'setPhotoTags': Module::dependencies(isset($_POST['photoIDs'], $_POST['tags']));
|
||||||
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
|
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
|
||||||
echo $photo->setTags($_POST['tags']);
|
echo $photo->setTags($_POST['tags']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'deletePhoto': if (!isset($_POST['photoIDs'])) exit();
|
case 'deletePhoto': Module::dependencies(isset($_POST['photoIDs']));
|
||||||
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
|
$photo = new Photo($database, $plugins, null, $_POST['photoIDs']);
|
||||||
echo $photo->delete();
|
echo $photo->delete();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Add Functions
|
// Add Functions
|
||||||
|
|
||||||
case 'upload': if (!isset($_FILES, $_POST['albumID'])) exit();
|
case 'upload': Module::dependencies(isset($_FILES, $_POST['albumID']));
|
||||||
$photo = new Photo($database, $plugins, $settings, null);
|
$photo = new Photo($database, $plugins, $settings, null);
|
||||||
echo $photo->add($_FILES, $_POST['albumID']);
|
echo $photo->add($_FILES, $_POST['albumID']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'importUrl': if (!isset($_POST['url'], $_POST['albumID'])) exit();
|
case 'importUrl': Module::dependencies(isset($_POST['url'], $_POST['albumID']));
|
||||||
echo Import::url($_POST['url'], $_POST['albumID']);
|
echo Import::url($_POST['url'], $_POST['albumID']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'importServer': if (!isset($_POST['albumID'])) exit();
|
case 'importServer': Module::dependencies(isset($_POST['albumID']));
|
||||||
echo Import::server($_POST['albumID'], null);
|
echo Import::server($_POST['albumID'], null);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Search Function
|
// Search Function
|
||||||
|
|
||||||
case 'search': if (!isset($_POST['term'])) exit();
|
case 'search': Module::dependencies(isset($_POST['term']));
|
||||||
echo json_encode(search($database, $settings, $_POST['term']));
|
echo json_encode(search($database, $settings, $_POST['term']));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Session Function
|
// Session Function
|
||||||
|
|
||||||
case 'init': if (!isset($_POST['version'])) exit();
|
case 'init': Module::dependencies(isset($_POST['version']));
|
||||||
$session = new Session($plugins, $settings);
|
$session = new Session($plugins, $settings);
|
||||||
echo json_encode($session->init($database, $dbName, false, $_POST['version']));
|
echo json_encode($session->init($database, $dbName, false, $_POST['version']));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'login': if (!isset($_POST['user'], $_POST['password'])) exit();
|
case 'login': Module::dependencies(isset($_POST['user'], $_POST['password']));
|
||||||
$session = new Session($plugins, $settings);
|
$session = new Session($plugins, $settings);
|
||||||
echo $session->login($_POST['user'], $_POST['password']);
|
echo $session->login($_POST['user'], $_POST['password']);
|
||||||
break;
|
break;
|
||||||
@ -133,18 +133,18 @@ switch ($_POST['function']) {
|
|||||||
|
|
||||||
// Settings Function
|
// Settings Function
|
||||||
|
|
||||||
case 'setLogin': if (!isset($_POST['username'], $_POST['password'])) exit();
|
case 'setLogin': Module::dependencies(isset($_POST['username'], $_POST['password']));
|
||||||
if (!isset($_POST['oldPassword'])) $_POST['oldPassword'] = '';
|
if (!isset($_POST['oldPassword'])) $_POST['oldPassword'] = '';
|
||||||
$settings = new Settings($database);
|
$settings = new Settings($database);
|
||||||
echo $settings->setLogin($_POST['oldPassword'], $_POST['username'], $_POST['password']);
|
echo $settings->setLogin($_POST['oldPassword'], $_POST['username'], $_POST['password']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'setSorting': if (!isset($_POST['type'], $_POST['order'])) exit();
|
case 'setSorting': Module::dependencies(isset($_POST['type'], $_POST['order']));
|
||||||
$settings = new Settings($database);
|
$settings = new Settings($database);
|
||||||
echo $settings->setSorting($_POST['type'], $_POST['order']);
|
echo $settings->setSorting($_POST['type'], $_POST['order']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'setDropboxKey': if (!isset($_POST['key'])) exit();
|
case 'setDropboxKey': Module::dependencies(isset($_POST['key']));
|
||||||
$settings = new Settings($database);
|
$settings = new Settings($database);
|
||||||
echo $settings->setDropboxKey($_POST['key']);
|
echo $settings->setDropboxKey($_POST['key']);
|
||||||
break;
|
break;
|
||||||
@ -153,12 +153,12 @@ switch ($_POST['function']) {
|
|||||||
|
|
||||||
default: switch ($_GET['function']) {
|
default: switch ($_GET['function']) {
|
||||||
|
|
||||||
case 'getAlbumArchive': if (!isset($_GET['albumID'])) exit();
|
case 'getAlbumArchive': Module::dependencies(isset($_GET['albumID']));
|
||||||
$album = new Album($database, $plugins, $settings, $_GET['albumID']);
|
$album = new Album($database, $plugins, $settings, $_GET['albumID']);
|
||||||
$album->getArchive();
|
$album->getArchive();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'getPhotoArchive': if (!isset($_GET['photoID'])) exit();
|
case 'getPhotoArchive': Module::dependencies(isset($_GET['photoID']));
|
||||||
$photo = new Photo($database, $plugins, null, $_GET['photoID']);
|
$photo = new Photo($database, $plugins, null, $_GET['photoID']);
|
||||||
$photo->getArchive();
|
$photo->getArchive();
|
||||||
break;
|
break;
|
||||||
|
@ -17,7 +17,7 @@ switch ($_POST['function']) {
|
|||||||
echo json_encode($album->getAll(true));
|
echo json_encode($album->getAll(true));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'getAlbum': if (!isset($_POST['albumID'], $_POST['password'])) exit();
|
case 'getAlbum': Module::dependencies(isset($_POST['albumID'], $_POST['password']));
|
||||||
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
|
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
|
||||||
if ($album->getPublic()) {
|
if ($album->getPublic()) {
|
||||||
// Album Public
|
// Album Public
|
||||||
@ -29,7 +29,7 @@ switch ($_POST['function']) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'checkAlbumAccess':if (!isset($_POST['albumID'], $_POST['password'])) exit();
|
case 'checkAlbumAccess':Module::dependencies(isset($_POST['albumID'], $_POST['password']));
|
||||||
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
|
$album = new Album($database, $plugins, $settings, $_POST['albumID']);
|
||||||
if ($album->getPublic()) {
|
if ($album->getPublic()) {
|
||||||
// Album Public
|
// Album Public
|
||||||
@ -43,7 +43,7 @@ switch ($_POST['function']) {
|
|||||||
|
|
||||||
// Photo Functions
|
// Photo Functions
|
||||||
|
|
||||||
case 'getPhoto': if (!isset($_POST['photoID'], $_POST['albumID'], $_POST['password'])) exit();
|
case 'getPhoto': Module::dependencies(isset($_POST['photoID'], $_POST['albumID'], $_POST['password']));
|
||||||
$photo = new Photo($database, $plugins, null, $_POST['photoID']);
|
$photo = new Photo($database, $plugins, null, $_POST['photoID']);
|
||||||
if ($photo->getPublic($_POST['password']))
|
if ($photo->getPublic($_POST['password']))
|
||||||
echo json_encode($photo->get($_POST['albumID']));
|
echo json_encode($photo->get($_POST['albumID']));
|
||||||
@ -57,7 +57,7 @@ switch ($_POST['function']) {
|
|||||||
echo json_encode($session->init($database, $dbName, true, $_POST['version']));
|
echo json_encode($session->init($database, $dbName, true, $_POST['version']));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'login': if (!isset($_POST['user'], $_POST['password'])) exit();
|
case 'login': Module::dependencies(isset($_POST['user'], $_POST['password']));
|
||||||
$session = new Session($plugins, $settings);
|
$session = new Session($plugins, $settings);
|
||||||
echo $session->login($_POST['user'], $_POST['password']);
|
echo $session->login($_POST['user'], $_POST['password']);
|
||||||
break;
|
break;
|
||||||
@ -66,7 +66,7 @@ switch ($_POST['function']) {
|
|||||||
|
|
||||||
default: switch ($_GET['function']) {
|
default: switch ($_GET['function']) {
|
||||||
|
|
||||||
case 'getAlbumArchive': if (!isset($_GET['albumID'], $_GET['password'])) exit();
|
case 'getAlbumArchive': Module::dependencies(isset($_GET['albumID'], $_GET['password']));
|
||||||
$album = new Album($database, $plugins, $settings, $_GET['albumID']);
|
$album = new Album($database, $plugins, $settings, $_GET['albumID']);
|
||||||
|
|
||||||
// Album Download
|
// Album Download
|
||||||
@ -81,7 +81,7 @@ switch ($_POST['function']) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'getPhotoArchive': if (!isset($_GET['photoID'], $_GET['password'])) exit();
|
case 'getPhotoArchive': Module::dependencies(isset($_GET['photoID'], $_GET['password']));
|
||||||
$photo = new Photo($database, $plugins, null, $_GET['photoID']);
|
$photo = new Photo($database, $plugins, null, $_GET['photoID']);
|
||||||
|
|
||||||
// Photo Download
|
// Photo Download
|
||||||
|
@ -11,7 +11,7 @@ if (!defined('LYCHEE_ACCESS_INSTALLATION')) exit('Error: You are not allowed to
|
|||||||
|
|
||||||
switch ($_POST['function']) {
|
switch ($_POST['function']) {
|
||||||
|
|
||||||
case 'dbCreateConfig': if (!isset($_POST['dbHost'], $_POST['dbUser'], $_POST['dbPassword'], $_POST['dbName'])) exit();
|
case 'dbCreateConfig': Module::dependencies(isset($_POST['dbHost'], $_POST['dbUser'], $_POST['dbPassword'], $_POST['dbName']));
|
||||||
echo Database::createConfig($_POST['dbHost'], $_POST['dbUser'], $_POST['dbPassword'], $_POST['dbName']);
|
echo Database::createConfig($_POST['dbHost'], $_POST['dbUser'], $_POST['dbPassword'], $_POST['dbName']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ if (!empty($_POST['function'])||!empty($_GET['function'])) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
exit('Error: No permission!');
|
exit('Error: Called function not found!');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ class Module {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function dependencies($available = false) {
|
public function dependencies($available = false) {
|
||||||
|
|
||||||
if ($available===false) exit('Error: Can not execute function. Missing parameters and variables.');
|
if ($available===false) exit('Error: Can not execute function. Missing parameters or variables.');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user