-
Notifications
You must be signed in to change notification settings - Fork 3
/
pageadd.php
107 lines (102 loc) · 3.36 KB
/
pageadd.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
// Redirect to SSL port if configured
include 'ssl.php';
// Check if user is admin
include 'admincheck.php';
?>
<html>
<head>
<title><?php include 'config.php'; echo TITLE?> | Add Page</title>
<?php
// Inlcude material design CSS
include 'material.php';
?>
<script>
function addA() {
var lnk = prompt("Destination URL:", "");
var title = prompt("Link Text:", "");
if(lnk != "") {
if(title != "") {
document.getElementById("post_content").value += "<a href='" + lnk + "'>" + title + "</a>";
} else {
alert("Title cannot be empty");
}
} else {
alert("Link cannot be empty");
}
}
function bold() {
if(document.getElementById("boldState").innerHTML == "off") {
document.getElementById("post_content").value += "<strong>";
document.getElementById("bold_button").innerHTML = "End Bolded Text";
document.getElementById("boldState").innerHTML = "on";
} else {
document.getElementById("post_content").value += "</strong>";
document.getElementById("bold_button").innerHTML = "<strong>Add bolded text</strong>";
document.getElementById("boldState").innerHTML = "off";
}
}
</script>
</head>
<body>
<?php include "adminmenu.php"; ?>
<h5>
<?php
if(isset($_GET['edit'])) {
echo "Edit ";
} else {
echo "Add ";
}
?>Blog Post</h5>
<hr>
<?php
if(isset($_GET['edit'])) {
require 'db.php';
$conn = new mysqli($host, $user, $pass, $database);
if($conn->connect_error) {
die('<center><h2><strong>Page failed to load</strong></h2><h3><i>Please try again later 😞</i></h3></center></body></html>');
}
}
?>
<form action="createpage.php" method="POST">
<div class"input-field col s6">
<i class="material-icons prefix">info_outline</i>
<input id="post_title" type="text" name="title" class="validate" placeholder="Title" value=
<?php
if(isset($_GET['edit'])) {
$sql = 'SELECT * FROM `openappstorestatic` WHERE `id` = ' . mysqli_real_escape_string($conn, $_GET['edit']) . ' LIMIT 0,2;';
$result = $conn->query($sql);
if($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo '"' . $row['title'] . '"';
$content = $row['content'];
}
} else {
echo '""';
}
} else {
echo '""';
}
?>
>
</div>
<div class"input-field col s6">
<i class="material-icons prefix">description</i>
<textarea name="content" id="post_content" rows="80" cols="50" class="validate" placeholder="Your page content here...."><?php
if(isset($_GET['edit'])) {
echo $content;
}
?>
</textarea>
</div>
<a onclick="addA()">Add Hyperlink</a> | <a onclick="bold()" id="bold_button"><strong>Add bolded text</strong></a>
<br>
<?php
if(isset($_GET['edit'])) {
echo '<input type="hidden" name="edit" value="true">';
echo '<input type="hidden" name="edit_id" value="' . $_GET['edit'] . '">';
}
?>
<input type="submit" value="Submit" class="btn waves">
</form>
<p id="boldState" hidden>off</p>