-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
39 lines (32 loc) · 1.07 KB
/
admin.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
<?php
require_once("libs/common.php");
if (Account::getLoggedInAccount()->getAdmin()) {
if(isset($_GET['id'])) {
switch($_GET['action']) {
case 'toggle':
$stmt = getDB()->prepare("UPDATE people SET published = NOT published WHERE userid = ?");
$stmt->execute(array($_GET['id']));
case 'removeq':
$stmt = getDB()->prepare("DELETE FROM questions WHERE qid = ?");
$stmt->execute(array($_GET['id']));
}
header("Location: admin.php");
}
if(isset($_POST['kysymys'])) {
$q = getDB()->prepare("INSERT INTO questions (question) VALUES (?)");
$q->execute(array(strip_tags(trim($_POST['kysymys']))));
echo "!!!";
}
$users = getDB()->prepare("SELECT * FROM people ORDER BY userid");
$users->execute();
$questions = getDB()->prepare("SELECT * FROM questions");
$questions->execute();
showView("base", array(
'innerContent' => "page/admin",
'users' => $users->fetchAll(PDO::FETCH_CLASS),
'questions' => $questions->fetchAll(PDO::FETCH_CLASS)
));
} else {
error("Et ole kirjautuneena ylläpitäjän tunnuksella!");
header("Location: index.php");
}