added ability to read human-readable address
This commit is contained in:
parent
933316458d
commit
83a4d00ca5
1 changed files with 25 additions and 10 deletions
|
@ -408,20 +408,35 @@ if(isset($_POST["submit"])) {
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no ID was entered, display warning and die.
|
// If a human-readable address was provided, extract appropriate id.
|
||||||
if(!isset($_GET["blogpost_id"])) {
|
if(isset($_GET["address"])) {
|
||||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Foud", true, 404);
|
$blogAddr = sanitize_input($_GET["address"]);
|
||||||
include_once($_SERVER["DOCUMENT_ROOT"]."/errors/404.php");
|
|
||||||
include_once($COMMONS."/footer.php");
|
// Prepare and bind statement for gathering blogpost address
|
||||||
die();
|
$stmt = $conn->prepare("SELECT blogpost_id
|
||||||
|
FROM blogposts WHERE readable_address = :readable_address;");
|
||||||
|
$stmt->bindParam(":readable_address", $blogAddr);
|
||||||
|
|
||||||
|
// Execute the statement
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
// Fetch the blogpost
|
||||||
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
// If post with given address was found, set the $blogId var.
|
||||||
|
if($result){
|
||||||
|
$blogId = sanitize_input($result["blogpost_id"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If a blogpost id was provided, get it.
|
||||||
|
else if(isset($_GET["blogpost_id"])) {
|
||||||
|
$blogId = sanitize_input($_GET["blogpost_id"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the blog id.
|
// Attempt to load the blogpost
|
||||||
$blogId = sanitize_input($_GET["blogpost_id"]);
|
|
||||||
|
|
||||||
$blogPost = load_blog($conn, $blogId);
|
$blogPost = load_blog($conn, $blogId);
|
||||||
|
|
||||||
// If no ID was entered, display warning and die.
|
// If blogpost could not be retieved, display warning and die.
|
||||||
if(!$blogPost) {
|
if(!$blogPost) {
|
||||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Foud", true, 404);
|
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Foud", true, 404);
|
||||||
include_once($_SERVER["DOCUMENT_ROOT"]."/errors/404.php");
|
include_once($_SERVER["DOCUMENT_ROOT"]."/errors/404.php");
|
||||||
|
|
Loading…
Reference in a new issue