-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnieuwsDelete.php
78 lines (68 loc) · 2.99 KB
/
nieuwsDelete.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
<?php
error_reporting(E_ALL & ~E_DEPRECATED);
session_start();
/* Classes importeren */
include_once('Classes/User.php');
include_once('Classes/Template.php');
/* Includes importeren */
include_once('Includes/connect.php');
include_once('Includes/slashes.php');
/* Classes initialiseren */
$cUser = new User();
$cTPL = new Template('Templates/main.tpl');
/* Verbinding met database maken */
connectDB();
/* Permissie controleren */
if (($cUser->checkSession() || $cUser->checkCookie()) && isset($_GET['id'])) {
$sQuery = "SELECT userid FROM nieuwsreacties WHERE reactieid='" . add($_GET['id']) . "';";
if ($cResult = mysql_query($sQuery)) {
$aData = mysql_fetch_assoc($cResult);
if($aData) {
if (($cUser->m_iPermis & 2) || ($cUser->m_iUserid == $aData['userid'])) {
/* Controleren of het formulier verzonden is */
if (isset($_POST['delete'])) {
$sQuery = "SELECT nieuwsid FROM nieuwsreacties WHERE reactieid='" . add($_GET['id']) . "';";
if ($cResult = mysql_query($sQuery)) {
$sQuery = "DELETE FROM nieuwsreacties WHERE reactieid='" . add($_GET['id']) . "';";
if (mysql_query($sQuery)) {
$aData = mysql_fetch_assoc($cResult);
header('Location: shownieuws.php?id=' . $aData['nieuwsid']);
} else {
$cTPL->setPlace('TITEL', 'Fout met database');
$cTPL->setPlace('CONTENT', 'Er is iets fout gegaan met de database');
$cTPL->show();
}
} else {
$cTPL->setPlace('TITEL', 'Fout met database');
$cTPL->setPlace('CONTENT', 'Er is iets fout gegaan met de database');
$cTPL->show();
}
} else {
$cTPL->setPlace('TITEL', 'Reactie verwijderen');
$cTPL->setBlock('LOGIN', 'logout');
$cTPL->parse();
if ($cUser->m_iPermis & 2) {
$cTPL->setBlock('ADMIN', 'admin');
}
$cTPL->setFile('CONTENT', 'Templates/nieuwsDelete.tpl');
$cTPL->parse();
$sQuery = "SELECT nieuwsid FROM nieuwsreacties WHERE reactieid='" . add($_GET['id']) . "';";
if ($cResult = mysql_query($sQuery)) {
$aData = mysql_fetch_assoc($cResult);
$cTPL->setPlace('NIEUWSID', $aData['nieuwsid']);
}
$cTPL->setPlace('ID', $_GET['id']);
$cTPL->show();
}
} else {
header('HTTP/1.0 404');
}
} else {
header('hTTP/1.0 404');
}
} else {
print 'Er is iets fout gegaan met de mysql database';
}
} else {
header('HTTP/1.0 404');
}