This repository has been archived by the owner on Jul 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoteRead.php
74 lines (72 loc) · 2.46 KB
/
noteRead.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
<?php
require_once 'checkLogin.php';
require_once 'connect.php';
require_once 'functions.php';
if (!checkLevel(3)) { echo "You don't have access to this!"; break; }
//Gets info needed to grab the note
$noteid = $_REQUEST['id'];
$user = $_SESSION['username'];
//Tries to grab the note from the DB
try {
$stmt = $conn->prepare('SELECT * FROM notes WHERE _id = ?');
$stmt->execute(array($noteid));
while ($row = $stmt->fetch()) {
//If the username doesn't match the username on the note, errors as they shouldn't be able to read this note.
if ($row['username'] != $user) {
$html .="You don't have access to this note!";
}
else {
$html .= "<div class=\"panel panel-default\"><div class=\"panel-heading\"><h3 class=\"panel-title\">" . $row['name'] . "</h3></div><div class=\"panel-body\">" . nl2br($row['content']) . "</div></div>";
}
}
} catch(PDOException $e) {
echo 'Error: ' . $e->getMessage();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Dectala's DnD GM App">
<meta name="author" content="James McGrew (jemcgrew@gmail.com)">
<title>Dectala's DnDApp</title>
<link href="css/bootstrap.css" rel="stylesheet">
</head>
<body>
<!-- BEGIN NAVIGATION -->
<nav class="navbar navbar-inverse navbar-fluid-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="navbar-brand">Dec's DnDApp</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php">Dec's DnDApp</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<?php
getMenu();
if (checkLevel(3)) {
getAdminMenu();
}
?>
</ul>
</div>
</div>
</nav>
<!-- END NAVIGATION -->
<!-- BEGIN MAIN CONTAINER -->
<?php checkLevel(3); ?>
<div class="container">
<?php echo $html; ?>
</div><!-- /.container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/bootstrap.js"></script>
</body>
</html>