-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathview.php
executable file
·98 lines (85 loc) · 3.07 KB
/
view.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
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>View</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<link href="css/navbar.css" rel="stylesheet" />
<style>
table {
margin-left:auto;
margin-right:auto;
width:500px;
}
</style>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
<?php
include "./script/dbconnect.php";
include "./script/navbar.php";
session_start();
$idx = $_GET['Idx'];
$query = "SELECT * FROM memo WHERE Idx='$idx'";
$result = $db->query($query)->fetchArray();
if ($idx) {
$query = "SELECT * FROM memo WHERE Idx='$idx'";
$result = $db->query($query)->fetchArray();
$isSecret = $result['IsSecret'];
if ($isSecret) {
if ($_SESSION['isAdmin'] == 1) {
goto a;
}
else if ($_SESSION['isLoginId'] != $result['Id']) {
echo "<script>
alert('This is secret memo');
history.back();
</script>";
exit;
}
}
}
?>
<? a: ?>
<form action="writePost.php" method="POST">
<table border="1" class="table w-auto">
<tr>
<th style="width:200px;"> ID </th>
<td style="width:600px;"> <?=$result['Id']?> </td>
</tr>
<tr>
<th> Title </th>
<td> <?=$result['Title']?> </td>
</tr>
<tr>
<th style="height:200px;"> Memo </th>
<td>
<?=nl2br($result['Memo'])?>
</td>
</tr>
<tr>
<td colspan="2">
<?php
if ($_SESSION['isAdmin'] == 1) goto b;
if ($result['Id']==$_SESSION['isLoginId']) {
b:
echo "
<div style='float:right;'>
<a href='write.php?Idx=$idx' class='btn btn-warning'> Edit </a>
<a href='confirmDel.php?Idx=$idx' class='btn btn-warning'> Delete </a>
</div>
";
}
?>
<a href="list.php" class="btn btn-warning"> List </a>
</td>
</tr>
</table>
</form>
</body>
</html>
<?php
$db->close();
?>