2024-02-09 00:13:23 +03:00
< ? php
// Post creation page
// Includes
require_once ( " api/post/create.php " );
2024-03-07 19:58:39 +03:00
// Markup includes
2024-02-09 00:13:23 +03:00
require_once ( " front/pages/main_nav.php " );
require_once ( " front/notifications.php " );
// Redirecting to main page if not logged in
if ( ! $LOGGED_IN ) {
header ( " Location: . " );
exit ();
}
// Processing POST-request
if ( isset ( $_POST ) && $_POST ) {
if ( isset ( $_POST [ " tags " ]) && $_POST [ " tags " ] && isset ( $_FILES [ " pic " ])) {
if ( isset ( $_POST [ " title " ]) && ! $_POST [ " title " ])
unset ( $_POST [ " title " ]);
$result = Post_Create_Method ( $_POST , $_FILES );
if ( $result -> IsError ()) { // Something happened
NTFY_AddNotice ( " Failed to create post! Reason:<br> " . $result -> GetError ());
} /* else { // All OK
header ( " Location: . " );
exit ();
} TODO : redirect to page with new post */
} else {
NTFY_AddNotice ( " You must supply image and tags for post " );
}
}
NTFY_EchoAllNotices ();
?>
< div class = " visualbox " >
< h1 > New post </ h1 >
< form class = " basicform " action = " ./?do=new_post " accept - charset = " UTF-8 " method = " post " enctype = " multipart/form-data " >
< div >
< label for = " pic " > Select image :</ label >< br >
< input type = " file " name = " pic " id = " pic " >
</ div >
< div >
< label for = " tags " > Comma - separated tags list :</ label >< br >
< textarea placeholder = " tag_1, tag_2, tag_3, ..., tag_N " name = " tags " id = " tags " style = " width: 98%; " rows = " 1 " >< ? php if ( isset ( $_POST [ " tags " ])) { echo $_POST [ " tags " ]; } ?> </textarea>
</ div >
< div >
< label for = " title " > Post title :</ label >< br >
2024-03-07 19:58:39 +03:00
< textarea placeholder = " Lorem ipsum dolor sit amet... " name = " title " id = " title " style = " width: 98%; " rows = " 2 " >< ? php if ( isset ( $_POST [ " title " ]) && $_POST [ " title " ]) { echo $_POST [ " title " ]; } ?> </textarea>
2024-02-09 00:13:23 +03:00
</ div >
< div >
< input type = " submit " value = " Submit " >
</ div >
</ form >
</ div >