This repository has been archived by the owner on Mar 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.php
79 lines (57 loc) · 1.79 KB
/
page.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php include_once "server/database.php"; ?>
<?php
// Escape the page name for safe-keeping
$db_pname = mysqli_real_escape_string($db_connection, $_GET["v"]);
// Build query, push to server and get results
$db_query = "SELECT pname, title, header, body FROM blog_posts WHERE pname = \"$db_pname\";";
$db_result = mysqli_query($db_connection, $db_query);
// Make variables so we can close the DB connection ASAP
$page_title;
$page_header;
$page_body;
// If there is a page, pull it
if (mysqli_num_rows($db_result) == 1)
while ($row = mysqli_fetch_assoc($db_result))
{
$page_title = $row["title"];
$page_body = $row["body"];
$page_header = $row["header"];
}
else
{
$page_title = "404 Not Found";
$page_body = "<p>404 Not Found</p>";
$page_header = "";
}
// Extract first paragraph
function extractFirstPara($input) {
// Set the text start and stop positions
$start = strpos($input, "<p>");
$end = strpos($input, "</p>", $start);
// Extract text (using the pointers)
// and return to caller
return substr($input, $start+3, $end-$start-3);
}
$page_description = extractFirstPara($page_body);
// Database kill
mysqli_close($db_connection);
?>
<!DOCTYPE html>
<html>
<head>
<?php include_once 'server/snippets/head.php'; ?>
<title><?php echo $page_title; ?></title>
<?php echo $page_header; ?>
<meta name="description" content="<?php echo $page_description; ?>">
<meta name="keywords" content="Design,Programming,Words,Paper,Photography,Raresh,Nistor">
<meta name="author" content="Raresh Nistor">
</head>
<body>
<?php include_once 'server/snippets/navbar.php'; ?>
<div class="splash-padding"></div>
<div class="container"><div style="padding:10px;" class="card">
<?php echo $page_body; ?>
</div></div>
<?php include_once 'server/snippets/footer.php'; ?>
</body>
</html>