-
Notifications
You must be signed in to change notification settings - Fork 2
/
viewPosts.php
192 lines (173 loc) · 6.53 KB
/
viewPosts.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
include("common.php");
include_once("class.Poll.php");
$topic = new Topic(file_get_contents("db/Topics/".$_GET['topicId']."/topic.dat"));
outHtml1($topic->getTopicName());
?>
<!-- TinyMCE -->
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="tiny_mce_init.js"></script>
<script type="text/javascript">
function addQuote(row)
{
var str = document.getElementById("tbl").rows[row].cells[2].innerHTML;
if (str.lastIndexOf("<div class=") == -1)
{
str = str.substring(str.indexOf("Quote</a")+9);
}
else
{
str = str.substring(str.indexOf("Quote</a")+9,str.lastIndexOf("<div class="));
}
return "<blockquote class='quote'><span style='font-size: 12px; font-weight: bold;'>Quote: "+ document.getElementById("tbl").rows[row].cells[0].firstChild.innerHTML +"</span><hr />"+ str +"</blockquote>";
}
</script>
<?php
outHtml2($_SESSION['forum']->getForumName(),"viewTopics.php?forumId=".$_SESSION['forum']->getForumId());
if ($_SESSION['loggedIn'] == true)
{
if ($_SESSION['user']->getLevel() > 1)
{
echo "<div id='adminControls'>Moderator Controls: ";
if ($topic->isLocked() == "false")
{
echo "<a href='lockExecute.php?mode=lock&topicId=".htmlentities($_GET["topicId"])."'>Lock</a> ";
}
else
{
echo "<a href='lockExecute.php?mode=unlock&topicId=".htmlentities($_GET["topicId"])."'>Unlock</a> ";
}
if ($topic->isSticky() == "false")
{
echo "<a href='stickyExecute.php?mode=sticky&forumId=".$_SESSION['forum']->getForumId()."&topicId=".htmlentities($_GET["topicId"])."'>Sticky</a> ";
}
else
{
echo "<a href='stickyExecute.php?mode=unsticky&forumId=".$_SESSION['forum']->getForumId()."&topicId=".htmlentities($_GET["topicId"])."'>Unsticky</a> ";
}
echo "</div>";
}
}
?>
<table class='list' style="margin-top: 10px; margin-bottom: 10px; font-family: Trebuchet MS;">
<tr>
<td class='listuser' style="background: url(images/bar.png) repeat-x; color: white;"><u>User</u></td>
<td class='listdate' style='font-size: 12px; padding: 10px 0px 10px 0px; background: url(images/bar.png) repeat-x; color: white;'><u>Date</u></td>
<td class='listmessage' style="background: url(images/bar.png) repeat-x; color: white;"><u>Post</u></td>
</tr>
</table>
<?php
$tpId = $_GET["topicId"];
$postArr = array();
$fileC = file("db/Topics/".$tpId."/posts.dat");
foreach ($fileC as $line)
{
array_push($postArr, new Post($line));
}
if (file_exists("db/Topics/".$tpId."/poll.dat"))
{
$poll = new Poll(file_get_contents("db/Topics/".$tpId."/poll.dat"));
echo "<div id='pollDiv'>";
$sum = 0;
$str = "";
$optionArr = $poll->getOptions();
foreach ($optionArr as $option)
{
$sum += $option[1];
$str .= $option[1].",";
}
$str = substr($str,0,strlen($str)-1);
if ($sum == 0)
{
echo "No votes yet.<br /><br />";
}
else
{
echo "<img src='createImage.php?values=".$str."' /><br /><br />";
$color[0] = "red";
$color[1] = "green";
$color[2] = "blue";
$color[3] = "#AABBCC";
$color[4] = "black";
$color[5] = "#2affed";
$color[6] = "#ffd8bc";
$color[7] = "#daffbc";
$color[8] = "#ff12a9";
$color[9] = "#762e2e";
for ($i = 0; $i < sizeOf($optionArr); $i++)
{
echo "<span style='color: ".$color[$i]."'>".$optionArr[$i][0].": ".$optionArr[$i][1]."</span><br />";
}
}
if ($_SESSION['loggedIn'] && (time() < strtotime($poll->getEndDate()) || $poll->getEndDate() == "") && $topic->isLocked() == 'false')
{
if (!in_array($_SESSION['user']->getUserId(),$poll->getUsers()))
{
echo "<br /><div id='options'><form name='poll' action='voteExecute.php?topicId=".$tpId."' method='post'>";
for ($i = 0; $i < sizeOf($optionArr); $i++)
{
echo "<input type='radio' name='option' value='$i' />".$optionArr[$i][0]."<br />";
}
echo "<input type='submit' value='Vote' />";
echo "</form></div>";
}
}
echo "</div>";
}
echo "<table id='tbl' class='list'>";
$count = 0;
foreach ($postArr as $key => $item)
{
$count++;
$sig = "";
if (trim($item->getUser()->getSig()) != "")
{
$sig = "<div class='sig'>".trim($item->getUser()->getSig())."</div>";
}
$avatarStr = "";
if ($item->getUser()->getAvatar() != "")
{
$avatarStr = "<img style='padding-top: 5px;' src='".$item->getUser()->getAvatar()."' />";
}
$deleteStr = "";
if ($_SESSION['loggedIn'] == true && $_SESSION['user']->getLevel() > 1 && sizeOf($postArr) > 1)
{
$deleteStr = "<a class='delete' href='moderate.php?flag=post&postId=".$item->getPostId()."&topicId=".htmlentities($_GET['topicId'])."'>delete</a><br />";
}
if ($_SESSION['loggedIn'] == true && $_SESSION['user']->getLevel() > 1)
{
$deleteStr .= "<a class='delete' href='editPost.php?postId=".$key."&topicId=".htmlentities($_GET['topicId'])."'>edit</a><br />";
}
if ($_SESSION['loggedIn'] == true)
{
$deleteStr .= '<a class="delete" href="javascript:;" onClick="tinyMCE.execCommand(\'mceInsertContent\',false,addQuote('.$key.'));">Quote</a>';
}
echo "<tr><td class='listuser'><a href='viewUser.php?userId=".$item->getUser()->getUserId()."'>".$item->getUser()->getUserId()."</a><br />".$avatarStr."</td>
<td class='listdate'>".$item->getDateTime()."</td>
<td class='listmessage'>".$deleteStr.$item->getMessage().$sig."</td></tr>";
$count = $item->getPostId()+1;
}
echo "</table>";
?>
<?php
if ($_SESSION['loggedIn'] == true && $topic->isLocked() == "false")
{
?>
<form action="postExecute.php?topicId=<?php echo htmlentities($_GET['topicId'])."&postId=".$count; ?>" method="post" onsubmit="return verify(this);">
<div id='replyId'>
Post Reply:<br />
<div id="imageInfo">Images may be no bigger than 600 x 600 and 200kB.</div>
<textarea id="reply" name="reply" style="width: 100%; height: 350px;"></textarea>
<?php
if ($_GET['error'] == 1)
{
echo "<div class='error'>Please enter a post!</div>";
}
?>
<input type='submit' value='Reply' id="submitId" />
</div>
</form>
<?php
}
outHtml3();
?>