make readable address mandatory
This commit is contained in:
parent
2b69f73dbe
commit
8dd55ce016
2 changed files with 34 additions and 24 deletions
|
@ -3,9 +3,9 @@
|
|||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: localhost
|
||||
-- Generation Time: Jul 20, 2024 at 02:33 PM
|
||||
-- Generation Time: Aug 21, 2024 at 11:22 PM
|
||||
-- Server version: 11.4.2-MariaDB
|
||||
-- PHP Version: 8.3.9
|
||||
-- PHP Version: 8.3.10
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
|
@ -29,7 +29,7 @@ SET time_zone = "+00:00";
|
|||
|
||||
CREATE TABLE IF NOT EXISTS `blogposts` (
|
||||
`blogpost_id` uuid NOT NULL DEFAULT uuid() COMMENT 'uuid of the blogpost',
|
||||
`readable_address` varchar(64) DEFAULT NULL COMMENT 'Human-readable addressing alternative for an article. For example, blogpost with readable_address = "example" can be accessed by article.php?address=example.',
|
||||
`readable_address` varchar(64) NOT NULL COMMENT 'Human-readable addressing alternative for an article. For example, blogpost with readable_address = "example" can be accessed by blog/article/example.',
|
||||
`title` varchar(64) DEFAULT NULL COMMENT 'title of the blogpost',
|
||||
`abstract` varchar(512) DEFAULT NULL COMMENT 'short version of the blogpost to be displayed as preview, usually the first paragraph of the real article.',
|
||||
`content` text DEFAULT NULL COMMENT 'html for the article',
|
||||
|
|
|
@ -255,13 +255,22 @@ if(isset($_POST["submit"])) {
|
|||
$abstract = $_POST["article_abstract"];
|
||||
$content = $_POST["article_content"];
|
||||
|
||||
// If adress is empty, set it to null
|
||||
// If adress is empty, repopulate the prefills and show error
|
||||
if(strcmp($address, "") == 0) {
|
||||
$address = null;
|
||||
// Set prefill values for the form
|
||||
$blogId_prefill = isset($_POST["blogpost_id"]) ?
|
||||
sanitize_input($_POST["blogpost_id"]) : "";
|
||||
$title_prefill = $title;
|
||||
$address_prefill = $address;
|
||||
$abstract_prefill = $abstract;
|
||||
$content_prefill = $content;
|
||||
$tagStr_prefill = $tagsStr;
|
||||
$addrErr = "Cannot be empty!";
|
||||
}
|
||||
|
||||
// Otherwise update/create the blogpost
|
||||
else {
|
||||
if($_POST["blogpost_id"]) {
|
||||
$blogpostId = $_POST["blogpost_id"];
|
||||
$blogpostId = sanitize_input($_POST["blogpost_id"]);
|
||||
update_blogpost($conn, $blogpostId, $address, $title, $tagsStr,
|
||||
$abstract, $content);
|
||||
}
|
||||
|
@ -287,8 +296,9 @@ if(isset($_POST["submit"])) {
|
|||
include_once($COMMONS."/footer.php");
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_GET["guid"])) {
|
||||
else if(isset($_GET["guid"])) {
|
||||
$blogId = sanitize_input($_GET["guid"]);
|
||||
|
||||
// select article title, abstract and content from the database
|
||||
|
@ -340,7 +350,7 @@ printf("
|
|||
</td><td style=\"padding: 0px 4px;\">
|
||||
<input type=\"text\" name=\"blogpost_address\" value=\"%s\">
|
||||
</td><td style=\"padding: 0px 4px;\">
|
||||
Leave empty to use GUID addressing
|
||||
%s
|
||||
</td></tr>
|
||||
<tr><td style=\"padding: 0px 4px;\">
|
||||
<label for=\"blogpost_tags\">Post tags:</label>
|
||||
|
@ -364,7 +374,7 @@ printf("
|
|||
<input name=\"submit\" type=\"submit\" value=\"Send File\">
|
||||
</form>
|
||||
</article>
|
||||
", $blogId_prefill, $title_prefill, $address_prefill, $tagStr_prefill,
|
||||
$abstract_prefill, $content_prefill);
|
||||
", $blogId_prefill, $title_prefill, $address_prefill, $addrErr,
|
||||
$tagStr_prefill, $abstract_prefill, $content_prefill);
|
||||
include_once($COMMONS."/footer.php");
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue