Use Response in Access

This commit is contained in:
Tobias Reich 2016-02-07 14:32:46 +01:00
parent f4e909895f
commit e9accae2a7
4 changed files with 23 additions and 18 deletions

View File

@ -2,11 +2,13 @@
namespace Lychee\Access;
use Lychee\Modules\Response;
abstract class Access {
final protected static function fnNotFound() {
exit('Error: Function not found! Please check the spelling of the called function.');
Response::error('Function not found! Please check the spelling of the called function.');
}

View File

@ -5,6 +5,7 @@ namespace Lychee\Access;
use Lychee\Modules\Album;
use Lychee\Modules\Import;
use Lychee\Modules\Photo;
use Lychee\Modules\Response;
use Lychee\Modules\Session;
use Lychee\Modules\Settings;
use Lychee\Modules\Validator;
@ -72,7 +73,7 @@ final class Admin extends Access {
private static function getAlbumsAction() {
$album = new Album(null);
echo json_encode($album->getAll(false));
Response::json($album->getAll(false));
}
@ -81,7 +82,7 @@ final class Admin extends Access {
Validator::required(isset($_POST['albumID']), __METHOD__);
$album = new Album($_POST['albumID']);
echo json_encode($album->get());
Response::json($album->get());
}
@ -145,7 +146,7 @@ final class Admin extends Access {
Validator::required(isset($_POST['photoID'], $_POST['albumID']), __METHOD__);
$photo = new Photo($_POST['photoID']);
echo json_encode($photo->get($_POST['albumID']));
Response::json($photo->get($_POST['albumID']));
}
@ -256,7 +257,7 @@ final class Admin extends Access {
Validator::required(isset($_POST['term']), __METHOD__);
echo json_encode(search($_POST['term']));
Response::json(search($_POST['term']));
}
@ -265,7 +266,7 @@ final class Admin extends Access {
private static function initAction() {
$session = new Session();
echo json_encode($session->init(false));
Response::json($session->init(false));
}

View File

@ -4,6 +4,7 @@ namespace Lychee\Access;
use Lychee\Modules\Album;
use Lychee\Modules\Photo;
use Lychee\Modules\Response;
use Lychee\Modules\Session;
use Lychee\Modules\Validator;
@ -44,7 +45,7 @@ final class Guest extends Access {
private static function getAlbumsAction() {
$album = new Album(null);
echo json_encode($album->getAll(true));
Response::json($album->getAll(true));
}
@ -57,13 +58,13 @@ final class Guest extends Access {
if ($album->getPublic()) {
// Album public
if ($album->checkPassword($_POST['password'])) echo json_encode($album->get());
else echo 'Warning: Wrong password!';
if ($album->checkPassword($_POST['password'])) Response::json($album->get());
else Response::warning('Wrong password!');
} else {
// Album private
echo 'Warning: Album private!';
Response::warning('Album private!');
}
@ -100,9 +101,9 @@ final class Guest extends Access {
$pgP = $photo->getPublic($_POST['password']);
if ($pgP===2) echo json_encode($photo->get($_POST['albumID']));
else if ($pgP===1) echo 'Warning: Wrong password!';
else if ($pgP===0) echo 'Warning: Photo private!';
if ($pgP===2) Response::json($photo->get($_POST['albumID']));
else if ($pgP===1) Response::warning('Wrong password!');
else if ($pgP===0) Response::warning('Photo private!');
}
@ -111,7 +112,7 @@ final class Guest extends Access {
private static function initAction() {
$session = new Session();
echo json_encode($session->init(true));
Response::json($session->init(true));
}
@ -143,12 +144,12 @@ final class Guest extends Access {
// Album Public
if ($album->checkPassword($_GET['password'])) $album->getArchive();
else exit('Warning: Wrong password!');
else Response::warning('Wrong password!');
} else {
// Album Private
exit('Warning: Album private or not downloadable!');
Response::warning('Album private or not downloadable!');
}
@ -171,7 +172,7 @@ final class Guest extends Access {
} else {
// Photo Private
exit('Warning: Photo private or password incorrect!');
Response::warning('Photo private or password incorrect!');
}

View File

@ -3,6 +3,7 @@
namespace Lychee\Access;
use Lychee\Modules\Config;
use Lychee\Modules\Response;
use Lychee\Modules\Validator;
final class Installation extends Access {
@ -36,7 +37,7 @@ final class Installation extends Access {
'status' => LYCHEE_STATUS_NOCONFIG
);
echo json_encode($return);
Response::json($return);
}