-
Notifications
You must be signed in to change notification settings - Fork 4
/
news.php
407 lines (272 loc) · 10.4 KB
/
news.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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
<?php
include"main.php";
database_con();
/*
if($_GET['id'] == "h") {
die("Æsj, du fant den! Her er koden til modul 2: <b>module.swap(angry)</b>");
}
*/
define("NEWS", "yes");
if($settings['maintenance'] == "yes" && $user['level'] != "4") {
die("<meta http-equiv='refresh' content='0; url=maintenance.php'>"); }
if(isset($_GET['id']) && is_numeric($_GET['id'])) {
$result = mysql_query("SELECT * FROM news WHERE id='".mysql_real_escape_string($_GET['id'])."'");
while($row = mysql_fetch_array($result))
{
$id = $row['id'];
$name = $row['name'];
$content = $row['content'];
$date = $row['date'];
$time = $row['time'];
$composer = $row['composer'];
$category = $row['category'];
$contest_active = $row['contest_active'];
}
if($name != "" && $content !="") {
pagetop("".$settings['site_name']." Nyheter - ".$name."");
include"includes/subheader.php";
pagemid();
echo"<div id='text' align='left'><b><font size='2'>".$name."</font></b><br/><span style=' color: #999999; '>Skrevet: ".$date."</span><br/><b>Kategori:</b> ".$category."<br/><hr width='100%'/><br/>
";
echo strcodes($content);
echo"<br/><br/><hr width='100%'/>Skrevet av: <b><a href='profile?user=".$composer."'>".$composer."</a></b></div><br/>";
define("RENEWS", TRUE);
if($contest_active > 0 && isset($user['name'])) {
$g = mysql_num_rows(mysql_query("SELECT username FROM contests WHERE username='".$user['name']."' AND article_id='".striphtml($_GET['id'])."'"));
if($g < 1) {
pagebreak();
if(!empty($_POST['content'])) {
$message = striphtml($_POST['content']);
$l = mysql_fetch_array(mysql_query("SELECT id FROM contests ORDER BY id DESC LIMIT 1"));
$sql="INSERT INTO contests (id, article_id, type, content, username, date) VALUES
('".($l['id']+1)."','".striphtml($_GET['id'])."','news','".$message."','".$user['name']."','".strftime("%d.%m.%Y - %H:%M")."')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
$x=$user['points'];
$vari = $x+4;
$sql="UPDATE usersystem SET points = '".$vari."'
WHERE username = '".$user['name']."'";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo"Takk for ditt svar!<br/><br/>";
}
echo"
<form action='news?id=".$_GET['id']."' method='post' name='content'>
<b>Send inn svar:</b><br/><textarea style='height: 110px; width: 350px;
font-family: Verdana;
font-size: 11px;
font-weight: normal;
color: #000000;
' name='content' id='textinput'></textarea>
<br/>";
echo"
<br/><br/><input type='submit' id='button' value='Post svar' /></form>";
}
}
pagebreak();
if(isset($user['name'])) {
if($user['chat_ban'] >= 1) {
echo"Du har chatban og kan derfor ikke poste kommentarer.";
} else {
if(isset($_GET['report_comment']) && isset($_GET['comment_id'])) {
mysql_query("UPDATE comments SET status = 'reported' WHERE id='".mysql_real_escape_string($_GET['comment_id'])."'");
mysql_query("UPDATE comments SET reportedby = '".$user['name']."' WHERE id='".mysql_real_escape_string($_GET['comment_id'])."'");
echo"Posten er rapportert!<meta http-equiv='refresh' content='1; url=news.php'><br/><br/>";
}
if (!empty($_POST['message']) && empty($_POST['contest'])) {
$code = $_SESSION['tagwallcode'];
unset($_SESSION['tagwallcode']);
if($code == $_POST['code']) {
if (isset($_POST['type']) && ($_POST['message'])) {
$x5=$settings['latestcommentid'];
$vari5 = $x5+1;
mysql_query("UPDATE latestids SET latestcommentid='".$vari5."'");
$message = striphtml($_POST['message']);
$sql="INSERT INTO comments (id, name, message, page_id, date, ip, type) VALUES
('".$vari5."', '".$user['name']."','".nl2br($message)."','".mysql_real_escape_string($_GET['id'])."','".strftime("%d.%m.%Y - %H:%M")."','".$_SERVER['REMOTE_ADDR']."','news')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
$x=$user['points'];
$vari = $x+0;
$sql="UPDATE usersystem SET points = '".$vari."'
WHERE username = '".$user['name']."'";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo"";
} else {
echo"<br/>Du må skrive noe før du poster det.<br/><br/>";
}
}
}
$mycode = randomtext("aA1", 10);
$_SESSION['tagwallcode'] = $mycode;
echo"
<form action='news.php?id=".$_GET['id']."' method='post' name='comment'>
<input type='hidden' name='name' value='".$user['name']."'>
<input type='hidden' name='type' value='comment'>
<input type='hidden' name='code' value='".$mycode."'>
<textarea style='height: 140px; width: 400px;
font-family: Verdana;
font-size: 11px;
font-weight: normal;
color: #000000;
' name='message' id='textinput'></textarea>
<br/>";
echo showcodes("message", "comment");
echo"
<br/><br/><input type='submit' id='button' value='Post kommentar' /><br/>
";
}
} else {
echo"Du må logge inn for å skrive kommentarer.";
}
pagebreak();
if(!isset($_GET['action']) && $_GET['action'] != "all") {
$result = mysql_query("SELECT * FROM comments WHERE page_id='".mysql_real_escape_string($_GET['id'])."' AND type='news' ORDER BY id DESC LIMIT 10");
} else {
$result = mysql_query("SELECT * FROM comments WHERE page_id='".mysql_real_escape_string($_GET['id'])."' AND type='news' ORDER BY id DESC");
}
while($row = mysql_fetch_array($result))
{
echo"<div id='tagcontainer'>
<div id='tagtop'><div id='text'><br/>";
echo"<b>- <a href='profile.php?user=".$row['name']."'>".$row['name']."</a></b>";
echo"</div></div>
<div id='tagmid'><div id='text'><br/><br/>";
if($row['message'] == "[Kommentar slettet]") {
echo $row['message'];
} else {
echo strcodes($row['message']);
}
echo"<br/><br/>";
echo"Postet: <b>".$row['date']."</b>";
if($user['level'] == "2" || $user['level'] == "3" || $user['level'] == "4") {
echo"<br/><br/><a href='news.php?id=".$_GET['id']."&report_comment=true&comment_id=".$row['id']."' onclick='return confirm(\"Er du sikker?\");'>Rapporter</a>";
}
if($user['level'] > 3 && ($user['rights'] == "admin" || $user['rights'] == "mod" || $user['rights'] == "global")) {
echo" ● <a href='adminpanel.php?action=comments&delete_comment=true&id=".$row['id']."'>Slett</a>";
}
echo"</div></div>
<div id='tagbot'>";
echo"</div></div>
";
}
$result = mysql_query("SELECT * FROM comments WHERE page_id='".mysql_real_escape_string($_GET['id'])."'");
if(mysql_num_rows($result) > 10) {
if(!isset($_GET['action']) && $_GET['action'] != "all") {
echo"<a href='news.php?id=".$_GET['id']."&action=all'>Vis alle kommentarer</a>";
} else {
echo"Alle kommentarer blir vist.";
}
} else {
echo"Alle kommentarer blir vist.";
}
pagebot($settings['footer']);
} else {
echo"<meta http-equiv='refresh' content='0; url=index.php'>";
}
} else {
pagetop("".$settings['site_name']." Nyhetetsarkiv");
include"includes/subheader.php";
pagemidcustom();
/*
echo"<br/><b><a href='?id=h'>Ikke trykk her!</a></b><br/>Skrevet: <span style='color: #999999;'>Mohahahaha *host*</span><br/>";
*/
echo "<b>Kategori:</b><br/><select name=\"category\" id=\"textinput\" onchange=\"window.location.href=this.value\">";
echo"<option"; if($_GET['categoryId'] == 0) { echo" SELECTED"; } echo" value=\"news\">Alle</option>";
$result = mysql_query("SELECT * FROM newscategories ORDER BY id DESC");
while($row = mysql_fetch_array($result))
{
echo"<option"; if($_GET['categoryId'] == $row['id']) { echo" SELECTED"; } echo" value=\"?categoryId=".$row['id']."\">".$row['name']."</option>";
}
echo"</select><br/><br/>";
if(isset($_GET['categoryId']) && is_numeric($_GET['categoryId'])) {
$result = mysql_query("SELECT * FROM newscategories WHERE id = '".mysql_real_escape_string($_GET['categoryId'])."' LIMIT 1");
if(mysql_num_rows($result) > 0) {
$cat = mysql_fetch_array($result);
$t = mysql_query("SELECT * FROM news WHERE category = '".$cat['name']."'");
} else {
$t = mysql_query("SELECT * FROM news");
}
} else {
$t = mysql_query("SELECT * FROM news");
}
$a = mysql_fetch_object($t);
$total_items = mysql_num_rows($t);
$limit = $_GET['limit'];
$type = $_GET['type'];
$page = $_GET['page'];
//set default if: $limit is empty, non numerical, less than 10, greater than 50
if((!$limit) || (is_numeric($limit) == false) || ($limit < 10) || ($limit > 50)) {
$limit = 15; //default
}
//set default if: $page is empty, non numerical, less than zero, greater than total available
if((!$page) || (is_numeric($page) == false) || ($page < 0) || ($page > $total_items)) {
$page = 1; //default
}
//calcuate total pages
$total_pages = ceil($total_items / $limit);
$set_limit = $page * $limit - ($limit);
if(isset($_GET['categoryId']) && is_numeric($_GET['categoryId'])) {
$result = mysql_query("SELECT * FROM newscategories WHERE id = '".mysql_real_escape_string($_GET['categoryId'])."' LIMIT 1");
if(mysql_num_rows($result) > 0) {
$cat = mysql_fetch_array($result);
$result = mysql_query("SELECT * FROM news WHERE category = '".$cat['name']."' ORDER BY id DESC LIMIT $set_limit, $limit");
} else {
$result = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT $set_limit, $limit");
}
} else {
$result = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT $set_limit, $limit");
}
while($row = mysql_fetch_array($result))
{
echo"<b><a href='?id=".$row['id']."'>".$row['name']."</a></b><br/>Skrevet: <span style='color: #999999;'>".$row['date']."</span><br/><br/>";
}
echo"<text style='float:center;'>";
$number1=$page-3;
$number2=$page-2;
$number3=$page-1;
$number4=$page;
$prev_page = $page - 1;
if($prev_page >= 1) {
echo("<b>«</b> <a href='?page=$prev_page'><b>Forrige</b></a> | ");
if($number1 == 1 || $number2 == 1 || $number3 == 1 || $number4 == 1) {
} else { echo"<a href='?page=1'>1</a> ... "; }
}
for($a = 1; $a <= $total_pages; $a++)
{
$number1=$page-1;
$number2=$page-2;
$number3=$page+1;
$number4=$page+2;
$number5=$page-3;
$number6=$page+3;
if($a == $number1 || $a == $number2 || $a == $number3 || $a == $number4 || $a == $page || $a == $number5 || $a == $number6) {
if($a == $page) {
echo("<b>$a</b> "); //no link
} else {
echo("<a href='?page=$a'>$a</a> ");
} }
}
$number1=$page+3;
$number2=$page+2;
$number3=$page+1;
$number4=$page;
$next_page = $page + 1;
if($next_page <= $total_pages) {
if($number1 == $total_pages || $number2 == $total_pages || $number3 == $total_pages || $number4 == $total_pages) {
} else { echo"... <a href='?page=$total_pages'>$total_pages</a>"; }
echo(" | <a href='?page=$next_page'><b>Neste</a> »</b>");
}
echo"</text>";
pagebot($settings['footer']);
}
?>