-
Notifications
You must be signed in to change notification settings - Fork 4
/
nyheter.php
executable file
·76 lines (73 loc) · 1.96 KB
/
nyheter.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
<?php
include("core.php");
startpage("Nyheter");
?>
<h1>Nyheter</h1>
<?php
if (r1() || r2()) {
echo '<p class="button2"><a href="publiser.php">Skriv en ny nyhet!</a></p><p class="button2"><a href="nyhetspanel.php">Behandle nyheter!</a></p>';
}
$np = $db->prepare(
"SELECT COUNT(*) as `numrows` FROM `news` WHERE `showing` = '1' AND `userlevel` >= ? ORDER BY `id` DESC LIMIT 0,10"
);
$np->execute([$obj->status]);
$count = $np->fetchColumn();
if ($count == 0) {
echo info('Ingen nyheter er publisert!');
} else {
echo <<<HTML
<div class="nyheter">
<table class="ny1">
<tr>
<td>
HTML;
$news = $db->prepare(
"SELECT * FROM `news` WHERE `showing` = '1' AND `userlevel` >= ? ORDER BY `id` DESC LIMIT 0,10"
);
$news->execute([$obj->status]);
while ($r = $news->fetchObject()) {
$statuss = null;
print '
<table class="';
if ($r->id % 2) {
print 'news1">';
} else {
print 'news2">';
}
if ($r->userlevel == 1) {
$statuss = 'news_admin';
} elseif ($r->userlevel == 2) {
$statuss = 'news_mod';
}
$bbc = new BBcodes($r->text);
$newres = $bbc->applyAllBBcodes();
/*$q = $db->query("SELECT * FROM `users` WHERE `user` = '$r->author'");
$f = $db->fetch_object($q);*/
print '
<tr>
<td class="linkstyle ' . $statuss . '"><b>' . htmlentities(
$r->title,
ENT_NOQUOTES | ENT_HTML401,
'UTF-8'
)
. '</b> skrevet av ' . status($r->author) . ' <div class="innlegsdato">' . date(
"H:i:s | d.m.Y",
$r->timestamp
) . '</div></td>
</tr>
<tr>
<td colspan="2">
' . $newres . '
</td>
</tr>
</table>
';
}
echo <<<HTML
</td>
</tr>
</table>
</div>
HTML;
}
endpage();