mirror of
https://github.com/standardebooks/web.git
synced 2025-07-08 15:50:29 -04:00
35 lines
787 B
PHP
35 lines
787 B
PHP
<?
|
|
|
|
$ebook = null;
|
|
|
|
try{
|
|
if(Session::$User === null){
|
|
throw new Exceptions\LoginRequiredException();
|
|
}
|
|
|
|
if(!Session::$User->Benefits->CanEditEbookPlaceholders){
|
|
throw new Exceptions\InvalidPermissionsException();
|
|
}
|
|
|
|
$identifier = EBOOKS_IDENTIFIER_PREFIX . trim(str_replace('.', '', HttpInput::Str(GET, 'url-path') ?? ''), '/');
|
|
|
|
$ebook = Ebook::GetByIdentifier($identifier);
|
|
|
|
if($ebook->IsPlaceholder()){
|
|
require('/standardebooks.org/web/www/ebook-placeholders/edit.php');
|
|
exit();
|
|
}
|
|
|
|
// Editing published `Ebooks` is not supported.
|
|
Template::Emit404();
|
|
}
|
|
catch(Exceptions\EbookNotFoundException){
|
|
Template::Emit404();
|
|
}
|
|
catch(Exceptions\LoginRequiredException){
|
|
Template::RedirectToLogin();
|
|
}
|
|
catch(Exceptions\InvalidPermissionsException){
|
|
Template::Emit403();
|
|
}
|
|
|