-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.php
130 lines (114 loc) · 4.22 KB
/
post.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
session_start();
if (isset($_SESSION['userkey'])) {
$userkey = $_SESSION['userkey'];
}
include 'scripts/dbconnect.php';
$domain = $_SERVER['SERVER_NAME'];
$domport = $_SERVER['SERVER_PORT'];
if(!isset($_GET["topickey"])) {
if(empty($domport)) {header("Location: http://" . $domain . "/list.php");} else {header("Location: http://" . $domain . ":" . $domport . "/list.php");}
return;
}
$tkey = mysqli_real_escape_string($con, $_GET["topickey"]);
$result = mysqli_query($con,"SELECT * FROM topic WHERE topicKey=$tkey");
$row = mysqli_fetch_array($result);
if (isset($userkey)) {
$userresult = mysqli_query($con,"SELECT * FROM user t1 WHERE userKey=$userkey");
$userrow = mysqli_fetch_array($userresult);
}
$taggs = array(">", "<", "!", "@", "$", "%", "^", "*", "(", ")", "{", "}", "-", "+", "=");
$staggs = array(">", "<", "!", "@", "$", "%", "^", "*", "(", ")", "{", "}", "-", "+", "=");
$featt = array("\n", "[B]", "[/b]", "[i]", "[/i]", "[ul]", "[/ul]", "[li]", "[/li]");
$sfeatt = array("<br>", "<b>", "</b>", "<i>", "</i>", "<ul>", "</ul>", "<li>", "</li>");
$end = ".jpg";
//echo "POST: " . print_r($row, true) . "<br>";
?>
<html>
<head>
<title>
<?php
echo $row['title'];
?>
</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<br><br><br>
<div id ="navigation">
<?php include('button.php'); ?>
</div>
<br><br>
<div id="content">
<?php
echo"<table>"; //Open Table
echo "<tr>";
if (isset($userkey)) {
echo "<th id='Table-short'></th>";
}
echo "<th id='Table-long'>" . $row['title'] . "</th>";
echo "<th id='Table-short'></th>";
if (isset($userkey)) {
echo "<th id='Table-short'></th>";
}
echo "</tr>";
$tableresult = mysqli_query($con,"SELECT * FROM comment t1, user t2 WHERE tKey=$tkey AND t1.userKey=t2.userKey");
while($trow = mysqli_fetch_array($tableresult)) {
echo "<tr>";
if (isset($userkey)) {
if ($trow['userKey']===$userkey || $userkey == 1) {
echo "<td id=Table-short><input type='checkbox' id=" . $trow['userKey'] . " disabled> </td>";
} else {
echo "<td id=Table-short></td>";
}
}
if (file_exists('images/users/' . $trow['userKey'] . '.png')) {
$image = $trow['userKey'] . ".png";
} elseif (file_exists('images/users/' . $trow['userKey'] . '.jpg')) {
$image = $trow['userKey'] . ".jpg";
} elseif (file_exists('images/users/' . $trow['userKey'] . '.gif')) {
$image = $trow['userKey'] . ".gif";
} else {
$image = "nouser.jpg";
}
echo "<td id=Table2-long>" . str_ireplace($featt,$sfeatt, str_ireplace($taggs, $staggs, $trow['text'])) . "</td>";
echo "<td id=Table-short> <img src='images/users/" . $image . "' border='1px' width='125px'><br><br>" . $trow['userName'] . "<br><br><b>Posted At:</b><br>" . $trow['tombstone'] . "</td>";
// echo "<td id=Table-short>" . $trow['tombstone'] . "</td>";
if (isset($userkey)) {
if ($trow['userKey']===$userkey || $userkey == 1) {
if ($row['cancom'] === "Y" || $userkey == 1) {
echo "<td id=Table-short> <a id='tabletext' href='editpost.php?comkey=" . $trow['comkey'] . "&tkey=" . $trow['tKey'] . "'>[ Edit ]</a>";
echo "<br>";
echo "<a id='tabletext' href=''>[ Delete ]</a></td>";
} else {
echo "<td id=Table-short></td>";
}
} else {
echo "<td id=Table-short></td>";
}
}
echo "</tr>";
}
echo"</table> <br> <br>";
if (isset($userkey)) {
if ($row['cancom']==="Y" and $userrow['active']==="Y") {
echo "<center><form name='newComment' action='scripts/newcomment.php' method='POST'>";
echo "<textarea name='body' rows='10' cols='90' placeholder='Respond to this post here.. Remember, Be Nice!' required></textarea><br>";
echo "<input name='tkey' value='$tkey' readonly required hidden>";
echo "<input type='submit' value='Submit Comment'>";
echo "</form></center>";
} else {
if ($row['cancom']==="N") {
echo "<center><button id='button' disabled>Commenting Disabled</button></center>";
} else {
echo "<center><button id='button' disabled>This Post Could<br>Not Be Found</button></center>";
}
}
} else {
echo "<center><a href='login.php'><button id='button'>Login to Comment</button></a></center>";
}
?>
<br><br><br>
</div> <br>
</body>
</html>