-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpmsystem.php
257 lines (252 loc) · 10.4 KB
/
pmsystem.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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<?php
// Private Messaging System
// Add on to Ultimate PHP Board V2.0
// Original PM Version (before _MANUAL_ upgrades): 2.0
// Addon Created by J. Moore aka Rebles
// Using textdb Version: 4.2.3
require_once('./includes/upb.initialize.php');
$where = "<a href='pmsystem.php'>Messenger</a>";
if (isset($_GET["section"]) && $_GET["section"] != "") $where .= " ".$_CONFIG["where_sep"]." ".ucfirst($_GET["section"]);
require_once('./includes/header.php');
if (!isset($_COOKIE["user_env"]) || !isset($_COOKIE["uniquekey_env"]) || !isset($_COOKIE["power_env"]) || !isset($_COOKIE["id_env"])) exitPage("
<div class='alert'><div class='alert_text'>
<strong>Caution!</strong></div><div style='padding:4px;'>You are not logged in.</div></div>");
if (!$tdb->is_logged_in()) exitPage("
<div class='alert'><div class='alert_text'>
<strong>Access Denied!</strong></div><div style='padding:4px;'>Invalid Login!</div></div>");
require_once('./includes/inc/privmsg.inc.php');
$PrivMsg = new functions(DB_DIR."/", "privmsg.tdb");
$PrivMsg->setFp("CuBox", ceil($_COOKIE["id_env"]/120));
if ($_GET["section"] != "outbox") $pmRecs = $PrivMsg->query("CuBox", "box='inbox'&&to='".$_COOKIE["id_env"]."'");
else $pmRecs = $PrivMsg->query("CuBox", "box='outbox'&&from='".$_COOKIE["id_env"]."'");
if (!empty($pmRecs) && $pmRecs[0] != '') $pmRecs = array_reverse($pmRecs);
elseif($_GET['section'] != '') {
//PM Blocking system commented out
echo "
<div id='tabstyle_2'>
<ul>
<li><a href='pmsystem.php?section=inbox'><span>View Inbox</span></a></li>
<li><a href='pmsystem.php?section=outbox'><span>View Outbox</span></a></li>
<li><a href='pmblocklist.php'><span>Manage Blocked Users</span></a></li>
<li><a href='newpm.php'><span>Send a PM</span></a></li>
<!--<li><a href='pmblocklist.php?action=adduser'><span>Block a User</span></a></li>-->
</ul>
</div>
<div style='clear:both;'></div>";
echoTableHeading(str_replace($_CONFIG["where_sep"], $_CONFIG["table_sep"], $where), $_CONFIG);
echo "
<tr>
<th> </th>
</tr>
<tr>
<td class='area_2' style='text-align:center;font-weight:bold;padding:12px;line-height:20px;' colspan='3'>No Messages in your ".$_GET["section"]."</td>
</tr>";
echoTableFooter(SKIN_DIR);
require_once('./includes/footer.php');
exit;
}
if ($pmRecs === false) //if $pmRecs is false, count still evaluates to 1
$count = 0;
else
$count = count($pmRecs);
if ($_GET["section"] == "inbox") {
if ($new_pm != 0) {
$f = fopen(DB_DIR."/new_pm.dat", 'r+');
fseek($f, (((int)$_COOKIE["id_env"] * 2) - 2));
fwrite($f, " 0");
fclose($f);
}
if ($_GET['action'] == "delete") {
$num = 0;
$delete = array();
for($i = 0; $i < $count; $i++) {
if (isset($_POST[$pmRecs[$i]["id"]."_del"])) {
$PrivMsg->delete("CuBox", $pmRecs[$i]["id"], false);
$num++;
$delete[] = $i;
}
}
//$PrivMsg->reBuild("CuBox"); // Not needed with new version of TextDB?
if ($num > 0) {
echo "<p align='center'>Successfully Deleted $num Private Msg(s)</p>";
$count -= $num;
for($i = 0; $i < count($delete); $i++) {
unset($pmRecs[$delete[$i]]);
}
} else {
echo "<p align='center'>No Private Msg(s) Successfully Deleted...</p>";
}
unset($num);
}
$none = TRUE;
$echo = "";
$blockedids = getUsersPMBlockedList($_COOKIE["id_env"]);
foreach($pmRecs as $pmRec) {
if ($pmRec["id"] != "") {
if ($none) $none = FALSE;
if ($pmRec["date"] > $_COOKIE["lastvisit"]) $new = "<img src='".SKIN_DIR."/icons/post_icons/new.gif' alt='' title='' />";
else $new = " ";
$user = $tdb->get("users", $pmRec["from"]);
if ($user[0]["level"] == "1") {
if (TRUE !== (in_array($pmRec["from"], $blockedids))) $ban_text = "<a href='pmblocklist.php?action=add&user_id=".$pmRec["from"]."'>Block</a>";
else $ban_text = "<span style='color:#ff0000'><strong>BLOCKED!</strong></span>";
} else {
$ban_text = "<span style='color:#ff0000'><strong>Admin/Mod</strong></span>";
}
$echo .= "
<tr>
<td class='area_1' style='text-align:center;padding:8px;'>$new</td>
<td class='area_1' style='text-align:center;padding:8px;'><img src='".SKIN_DIR."/icons/post_icons/".$pmRec["icon"]."'></td>
<td class='area_2'><span class='link_1'><a href='viewpm.php?section=".$_GET["section"]."&id=".$pmRec["id"]."'>".$pmRec["subject"]."</a></span></td>
<td class='area_1'><a href='profile.php?action=get&id=".$pmRec["from"]."'>".$user[0]["user_name"]."</a> on ".gmdate("M d, Y g:i:s a", user_date($pmRec["date"]))."</td>
<td class='area_2' style='text-align:center;padding:8px;'>$ban_text</td>
<td class='area_1' style='text-align:center;padding:8px;'><input type='checkbox' name='".$pmRec["id"]."_del' value='CHECKED'></td>
</tr>";
unset($new, $ban_text);
} else {
$none++;
}
}
if ($none) {
$echo = "
<tr>
<td class='area_2' style='text-align:center;font-weight:bold;padding:12px;line-height:20px;' colspan='6'>No Messages in your ".$_GET["section"]."</td>
</tr>";
$disable = "DISABLED";
}
else $disable = "";
echo "
<div id='tabstyle_2'>
<ul>
<li><a href='pmsystem.php?section=inbox'><span>View Inbox</span></a></li>
<li><a href='pmsystem.php?section=outbox'><span>View Outbox</span></a></li>
<li><a href='pmblocklist.php'><span>Manage Blocked Users</span></a></li>
<li><a href='newpm.php'><span>Send a PM</span></a></li>
<!--<li><a href='pmblocklist.php?action=adduser'><span>Block a User</span></a></li>-->
</ul>
</div>
<div style='clear:both;'></div>";
echo "<form name='main' action='pmsystem.php?section=inbox&action=delete' method='post' onSubmit='submitonce(this)' enctype='multipart/form-data'>";
echoTableHeading(str_replace($_CONFIG["where_sep"], $_CONFIG["table_sep"], $where), $_CONFIG);
echo "
<tr>
<th style='width:5%;text-align:center;'> </th>
<th style='width:5%;text-align:center;'> </th>
<th style='width:45%;'>Title</th>
<th style='width:30%;'>From</th>
<th style='width:10%;text-align:center;'>Action</th>
<th style='width:5%;text-align:center;'> </th>
</tr>";
echo $echo;
echo "
<tr>
<td class='footer_3' colspan='6'><img src='./skins/default/images/spacer.gif' alt='' title='' /></td>
</tr>
<tr>
<td class='area_2' style='text-align:center;font-weight:bold;padding:12px;line-height:20px;' colspan='6'>You are not allowed to block Administrators/Moderators</td>
</tr>
<tr>
<td class='footer_3' colspan='6'><img src='./skins/default/images/spacer.gif' alt='' title='' /></td>
</tr>
<tr>
<td class='footer_3a' colspan='6' style='text-align:center;'><input type='submit' name='action' value='Delete Selected PMs' $disable></td>
</tr>
</form>";
echoTableFooter(SKIN_DIR);
} elseif($_GET["section"] == "outbox") {
if ($_GET['action'] == "delete") {
//dump($_POST);
$num = 0;
$delete = array();
for($i = 0; $i < $count; $i++) {
if (isset($_POST[$pmRecs[$i]["id"]."_del"])) {
$PrivMsg->delete("CuBox", $pmRecs[$i]["id"], false);
$num++;
$delete[] = $i;
}
}
//$PrivMsg->reBuild("CuBox"); // Not needed with new version of TextDB?
if ($num > 0) {
echo "<p align='center'>Successfully Deleted $num Private Msg(s)</p>";
$count -= $num;
for($i = 0; $i < count($delete); $i++) {
unset($pmRecs[$delete[$i]]);
}
} else {
echo "<p align='center'>No Private Msg(s) Successfully Deleted...</p>";
}
unset($num);
}
$none = 0;
echo "
<div id='tabstyle_2'>
<ul>
<li><a href='pmsystem.php?section=inbox'><span>View Inbox</span></a></li>
<li><a href='pmsystem.php?section=outbox'><span>View Outbox</span></a></li>
<li><a href='pmblocklist.php'><span>Manage Blocked Users</span></a></li>
<li><a href='newpm.php'><span>Send a PM</span></a></li>
<!--<li><a href='pmblocklist.php?action=adduser'><span>Block a User</span></a></li>-->
</ul>
</div>
<div style='clear:both;'></div>";
echo "<form name='main' action='pmsystem.php?section=outbox&action=delete' method='post' onSubmit='submitonce(this)' enctype='multipart/form-data'>";
echoTableHeading(str_replace($_CONFIG["where_sep"], $_CONFIG["table_sep"], $where), $_CONFIG);
echo "
<tr>
<th style='width:5%;'> </th>
<th style='width:40%;'>Title:</th>
<th style='width:50%;'>By:</th>
<th style='width:5%';>Delete</th>
</tr>";
foreach($pmRecs as $pmRec) {
if ($pmRec["id"] != "") {
$user = $tdb->get("users", $pmRec["to"]);
echo "
<tr>
<td class='area_1' style='text-align:center;padding:8px;'><img src='".SKIN_DIR."/icons/post_icons/".$pmRec["icon"]."' alt='' title='' /></td>
<td class='area_2'> <span class='link_1'><a href='viewpm.php?section=".$_GET["section"]."&id=".$pmRec["id"]."'>".$pmRec["subject"]."</a></span></td>
<td class='area_1'>Sent to <a href='profile.php?action=get&id=".$user[0]['id']."'>".$user[0]["user_name"]."</a> on ".gmdate("M d, Y g:i:s a", user_date($pmRec["date"]))."</td>
<td class='area_1' style='text-align:center;padding:8px;'><input type='checkbox' name='".$pmRec["id"]."_del' value='CHECKED'></td>
</tr>";
unset($pmRec);
} else {
$none++;
}
unset($pmRec);
}
if ($none == $count) {
echo "
<tr>
<td class='area_2' style='text-align:center;font-weight:bold;padding:12px;line-height:20px;' colspan='4'>No Messages in your ".$_GET["section"]."</td>
</tr>";
$disable = "DISABLED";
}
echo "<tr>
<td class='footer_3a' colspan='4' style='text-align:center;'><input type='submit' name='action' value='Delete Selected PMs' $disable></td>
</tr>";
echoTableFooter(SKIN_DIR);
} else {
$old_pm = ($count - $new_pm);
echo "
<div id='tabstyle_2'>
<ul>
<li><a href='pmsystem.php?section=inbox'><span>View Inbox</span></a></li>
<li><a href='pmsystem.php?section=outbox'><span>View Outbox</span></a></li>
<li><a href='pmblocklist.php'><span>Manage Blocked Users</span></a></li>
<li><a href='newpm.php'><span>Send a PM</span></a></li>
<!--<li><a href='pmblocklist.php?action=adduser'><span>Block a User</span></a></li>-->
</ul>
</div>
<div style='clear:both;'></div>";
echoTableHeading(str_replace($_CONFIG["where_sep"], $_CONFIG["table_sep"], $where), $_CONFIG);
echo "
<tr>
<th><strong>Messenger status</strong></th>
</tr>
<tr>
<td class='area_2' style='text-align:center;font-weight:bold;padding:12px;line-height:20px;'>$new_pm New Private Msg(s) and <strong>$old_pm</strong> Old Private Msg(s)</td>
</tr>";
echoTableFooter(SKIN_DIR);
}
require_once("./includes/footer.php");
?>