-
Notifications
You must be signed in to change notification settings - Fork 0
/
reactieEdit.php
72 lines (64 loc) · 2.83 KB
/
reactieEdit.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
<?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 mysql maken */
connectDB();
/* Permissies controleren */
if (isset($_GET['id']) && isset($_GET['spelid']) && isset($_GET['topicid'])) {
if (($cUser->checkSession()) || ($cUser->checkCookie())) {
$sQuery = "SELECT b.userid, b.topicid, b.bericht
FROM berichten b
JOIN spellenhulp sh ON b.topicid = sh.topicid
WHERE b.berichtid='" . add($_GET['id']) . "' AND
b.topicid='" . add($_GET['topicid']) . "' AND
sh.spelid='" . add($_GET['spelid']) . "';";
if ($cResult = mysql_query($sQuery)) {
$aData = mysql_fetch_assoc($cResult);
if ($aData !== false && ($cUser->m_iPermis & 2 || $cUser->m_iUserid == $aData['userid'])) {
/* Controleren of het formulier is verzonden */
if (isset($_POST['bericht'])) {
$sQuery = "UPDATE berichten SET bericht='" . add($_POST['bericht']) . "' WHERE berichtid='" . add($_GET['id']) . "';";
if (mysql_query($sQuery)) {
header('Location: gameview.php?id=' . $_GET['spelid'] . '&topicid=' . $aData['topicid']);
} else {
$cTPL->setPlace('TITEL', 'Fout met de database');
$cTPL->setPlace('CONTENT', 'Er is iets fout gegaan met de mysql database');
}
} else {
$cTPL->setPlace('TITEL', 'Bericht bewerken');
$cTPL->setBlock('LOGIN', 'logout');
if ($cUser->m_iPermis & 2) {
$cTPL->parse();
$cTPL->setBlock('ADMIN', 'admin');
}
$cTPL->setFile('CONTENT', 'Templates/reactieEdit.tpl');
$cTPL->parse();
$cTPL->setPlace('BERICHT', $aData['bericht']);
$cTPL->setPlace('SPELID', $_GET['spelid']);
$cTPL->setPlace('TOPICID', $aData['topicid']);
$cTPL->setPlace('ID', $_GET['id']);
$cTPL->show();
}
} else {
header('HTTP/1.0 404');
}
} else {
$cTPL->setPlace('TITEL', 'Fout met de database');
$cTPL->setPlace('CONTENT', 'Er is iets fout gegaan met de mysql database');
$cTPL->show();
}
} else {
header('HTTP/1.0 404');
}
} else {
header('HTTP/1.0 404');
}