/
modes.php
286 lines (276 loc) · 9.54 KB
/
modes.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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<?php
/*
****************************************************************
#mode.php File
#Version 1.4
****************************************************************
#Copy Righted 2006-2007(http://nevuxbulletin.com)
#Created By NevuxAB Developement Team
****************************************************************
*/
//Runs to moderating mods for posts and topics
function moderator()
{
//global vars
global $logged,$permissions;
//set up permissions id's and type id's
$id = intval( htmlspecialchars( trim( strip_tags( $_GET['id'] ) ) ) );
$type = htmlspecialchars( trim( strip_tags( $_GET['type'] ) ) );
$tid = intval( htmlspecialchars( $_GET['tid'] ) );
$posts = htmlspecialchars( $_GET['post'] );
//check what type and modes where in
switch($type)
{
case "edit":
switch($posts)
{
case "topic":
echo "TOPIC";
//gets topic data from database
$tdata_ = mysql_query("SELECT * FROM `topics` WHERE `id` = '" . $id . "' ");
$tdata = mysql_fetch_array($tdata_);
//if they don't have permission
if( ($permissions['e_topic'] != 't' AND $logged['username'] != $tdata['username']) || $permissions['admin'] != 't' )
{
logs("Invalid User","1");
pageerror("Topic Error","There was an error editing topic.","You don't have permissions to edit this topic!");
}
if( !isset( $_POST['newtopic'] ) )
{
$Temp = new Template;
$Temp->dir = $logged['dskin'];
$Temp->file = "newtopic.tpl";
$Temp->tp();
$Temp->tr(array(
'TOPIC_NAME' => 'Edit Topic',
'TITLE' => $tdata['title'],
'DESC' => $tdata['description'],
'POST' => '',
'<<HIDE>>' => '<!--',
'<<HIDE_2>>' => '-->'
));
echo $Temp->html;
}
else
{
if( empty($_POST['title']) )
{
pageerror("Topic Error","There was an error editing topic","Please check your post because you left the topic post or topic title blank!");
}
else
{
$ttitle = htmlspecialchars($_POST['title']);
$description = htmlspecialchars($_POST['tdesc']);
$ndata = @mysql_query("UPDATE `topics` SET `description` = '".$description."', `title` = '".$ttitle."' WHERE `id` = '".$id."' ");
if( !$ndata )
{
pageerror("Topic Error","There was an error editing topic","There was an error updating sql: " . mysql_error());
}
finished("Topic Updated!","Current Topic was Updated!","Thank you now your topic was sucessfully updated.","index.php?act=topicshow&id=".$id);
}
}
break;
case "reply":
//Selects reply data from db
$pdata_ = mysql_query("SELECT * FROM `replies` WHERE `id` = '".$id."' ");
$pdata = mysql_fetch_array($pdata_);
if( ($permissions['e_post'] != 't' AND $logged['username'] != $pdata['username']) or ($permissions['admin'] != 't') )
{
logs("Invalid User","1");
pageerror("Reply Error","There was an error editing reply.","You don't have permissions to edit this post!");
}
if( !isset( $_POST['newreply'] ) )
{
$Temp = new Template;
$Temp->dir = $logged['dskin'];
$Temp->file = "newreply.tpl";
$Temp->tp();
$Temp->tr(array(
'POST' => $pdata['post'],
'NAME' => "Edit Reply"
));
echo $Temp->html;
}
else
{
$rpost = htmlspecialchars( $_POST['post'] );
if( empty( $_POST['post'] ) )
{
pageerror("Reply Error","There was an error editing reply.","You left the post field blank please go back and check again!");
}
else
{
$pdata = @mysql_query("UPDATE `replies` SET `post` = '".$rpost."' WHERE `id` = '".$id."' ");
if( !$pdata )
{
pageerror("Reply Error","There was an error editing reply.","There was an sql error: " . mysql_error());
}
finished("Reply Updated!","Current Post was Updated!","Thank you now your reply was sucessfully updated.","index.php?act=topicshow&id=".$tid);
}
}
break;
}
break;
case "delete":
//Checks if user has permissiosn
if( $permissions['d_post'] != 't' )
{
logs("Invalid User","1");
pageerror("Topic Error","There was an error opening topic.","You don't have permissions to open this topic!");
}
switch( $posts )
{
case "reply":
if( !isset( $_POST['submit'] ) )
{
$Temp = new Template;
$Temp->dir = $logged['dskin'];
$Temp->file = "mode_delete.tpl";
$Temp->tp();
echo $Temp->html;
}
else
{
if( isset( $_POST['del'] ) )
{
if( mysql_query("DELETE FROM `replies` WHERE `id` = '" . $id . "'") )
{
finished("Post deleted Successfully","","Your post was deleted successfully, please wait while your being redirected.","index.php?act=topicshow&id=".$tid);
}
else
{
pageerror("Deletion Error","","There was a problem deleting post, please contact the NevuxAB Support Tech.");
}
}
else
{
finished("Post Message","","No action was taken, please wait while your being redirected.","index.php?act=topicshow&id=".$tid);
}
}
break;
}
break;
case "opentopic":
if( $permissions['o_topic'] != 't' )
{
logs("Invalid User","1");
pageerror("Topic Error","There was an error opening topic.","You don't have permissions to open this topic!");
}
$otopic = mysql_query("SELECT `closed` FROM `topics` WHERE `id` = '" . $tid . "' ");
$otopic = mysql_fetch_array($otopic);
if( $otopic['closed'] == 1 )
{
pageerror("Topic Error","","Topic is already Opened!");
}
else
{
$topic_update = mysql_query("UPDATE `topics` SET `closed` = '1' WHERE `id` = '" . $tid . "' ");
if( !$topic_update )
{
pageerror("Topic Error","","There was an error updating topic: " . mysql_error());
}
finished("Topic Updated!","Current Topic was Pinned!","Thank you now your topic was sucessfully opened.","index.php?act=topicshow&id=".$tid);
}
break;
case "closetopic":
if( $permissions['c_topic'] != 't' )
{
logs("Invalid User","1");
pageerror("Topic Error","There was an error closing topic.","You don't have permissions to close this topic!");
}
$ctopic = mysql_query("SELECT `closed` FROM `topics` WHERE `id` = '" . $tid . "' ");
$ctopic = mysql_fetch_array($ctopic);
if( $ctopic['closed'] == 0 )
{
pageerror("Topic Error","","Topic is already closed!");
}
else
{
$topic_update = mysql_query("UPDATE `topics` SET `closed` = '0' WHERE `id` = '" . $tid . "' ");
if( !$topic_update )
{
pageerror("Topic Error","","There was an error updating topic: " . mysql_error());
}
finished("Topic Updated!","Current Topic was Closed!","Thank you now your topic was sucessfully Closed.","index.php?act=topicshow&id=".$tid);
}
break;
case "sticktopic":
if($permissions['topic_pin'] != 't')
{
logs("Invalid User","1");
pageerror("Topic Error","There was an error Pinning topic.","You don't have permissions to Pin this topic!");
}
$stopic = mysql_query("SELECT `sticky` FROM `topics` WHERE `id` = '".$tid."' ");
$stopic = mysql_fetch_array($stopic);
if( $stopic['sticky'] == 0 )
{
pageerror("Topic Error","","Topic is already Pinned!");
}
else
{
$topic_update = mysql_query("UPDATE `topics` SET `sticky` = '0' WHERE `id` = '" . $tid . "' ");
if( !$topic_update )
{
pageerror("Topic Error","","There was an error updating topic: " . mysql_error());
}
finished("Topic Updated!","Current Topic was Pinned!","Thank you now your topic was sucessfully Pinned.","index.php?act=topicshow&id=".$tid);
}
break;
case "unsticktopic":
if( $permissions['topic_pin'] != 't' )
{
logs("Invalid User","1");
pageerror("Topic Error","There was an error Un-Pinning topic.","You don't have permissions to Un-Pin this topic!");
}
$ustopic = mysql_query("SELECT `sticky` FROM `topics` WHERE `id` = '".$tid."' ");
$ustopic = mysql_fetch_array($ustopic);
if($ustopic['sticky'] == 1)
{
pageerror("Topic Error","","Topic is already Un-Pinned!");
}
else
{
$topic_update = mysql_query("UPDATE topics SET sticky = '1' WHERE `id` = '".$tid."' ");
if( !$topic_update )
{
pageerror("Topic Error","","There was an error updating topic: " . mysql_error());
}
finished("Topic Updated!","Current Topic was Un-Pinned!","Thank you now your topic was sucessfully Un-Pinned.","index.php?act=topicshow&id=$tid");
}
break;
case "move":
if( $permissions['m_topic'] != 't' )
{
logs("Invalid User","1");
pageerror("Topic Error","There was an error moving topic.","You don't have permissions to move this topic!");
}
$nparent = htmlspecialchars($_POST['to']);
if( isset( $_POST['update'] ) )
{
$topic_update = mysql_query("UPDATE `topics` SET `fid` = '" . $nparent . "' WHERE `id` = '" . $id . "'");
if( !$topic_update )
{
pageerror("Topic Error","","There was an error updating topic: " . mysql_error());
}
finished("Topic Updated!","Current Topic was Pinned!","Thank you now your topic was moved sucessfully.","index.php?act=topicshow&id=".$id);
}
else
{
$gettopics = mysql_query("SELECT * FROM `forums` ORDER BY `id` ASC");
$values = "";
while ( $showtopics = MySQL_Fetch_Array($gettopics) )
{
$values .= "<option value='" . $showtopics['id'] . "'>" . $showtopics['title'] . "</option>";
}
$Temp = new Template;
$Temp->dir = $logged['dskin'];
$Temp->file = "mode_move.tpl";
$Temp->tp();
$Temp->tr(array(
'OPTIONS' => $values
));
echo $Temp->html;
}
break;
}
}