Compare commits
6 Commits
4c227b8e01
...
90048c7632
Author | SHA1 | Date | |
---|---|---|---|
90048c7632 | |||
4ff4c6eb14 | |||
a4c3d4ce31 | |||
f980c5c9af | |||
ab3a0457e0 | |||
5762e6d5a1 |
11
api.php
11
api.php
@@ -82,6 +82,7 @@
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");
|
||||
}
|
||||
|
||||
if(isset($_GET["cmd"])) {
|
||||
$cmd = $_GET['cmd'];
|
||||
|
||||
switch($cmd) {
|
||||
@@ -106,17 +107,12 @@
|
||||
break;
|
||||
|
||||
case "selectmessage":
|
||||
query("SELECT `id` FROM `for_stallman` WHERE `selected` = true;", function($row) {
|
||||
query("UPDATE `for_stallman` SET `selected` = false WHERE `id` = " . $row["id"] . ";");
|
||||
});
|
||||
|
||||
query("UPDATE `for_stallman` SET `selected` = false");
|
||||
query("UPDATE `for_stallman` SET `selected` = true WHERE `id` = " . file_get_contents("php://input") . ";");
|
||||
break;
|
||||
|
||||
case "unselectmessage":
|
||||
query("SELECT `id` FROM `for_stallman` WHERE `selected` = true;", function($row) {
|
||||
query("UPDATE `for_stallman` SET `selected` = false WHERE `id` = " . $row["id"] . ";");
|
||||
});
|
||||
query("UPDATE `for_stallman` SET `selected` = false");
|
||||
break;
|
||||
|
||||
case "getmodmessages":
|
||||
@@ -158,5 +154,6 @@
|
||||
default:
|
||||
die("Loading React...");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
23
insertion.php
Normal file
23
insertion.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
if(isset($_GET["message"])) {
|
||||
include "api.php";
|
||||
query("INSERT INTO `for_moderation`(`text`) VALUES (\"" . $conn->real_escape_string($_GET["message"]) . "\");");
|
||||
header("Location: /insertion.php");
|
||||
die();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Vkládání otázek</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Vkládání otázek na moderaci pro pana Stallmana</h1>
|
||||
<form action="/insertion.php" method="get">
|
||||
<label for="message">Obsah otázky:</label><br>
|
||||
<textarea id="message" name="message" rows=8 cols=80></textarea><br><br>
|
||||
<input type="submit" value="Odeslat!">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
111
moderation.php
Normal file
111
moderation.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
include "api.php";
|
||||
|
||||
$found = false;
|
||||
|
||||
foreach($_GET as $key => $value) {
|
||||
$found = true;
|
||||
if(gettype($key) != "integer") continue;
|
||||
|
||||
if($value == "del") {
|
||||
query("DELETE FROM `for_moderation` WHERE `id` = " . $key . ";");
|
||||
}
|
||||
|
||||
if($value == "ok" && isset($_GET[(string)$key . "message"])) {
|
||||
$message = $_GET[(string)$key . "message"];
|
||||
query("INSERT INTO `for_stallman`(`text`, `selected`) VALUES (\"" . $conn->real_escape_string($message) . "\", false);");
|
||||
query("DELETE FROM `for_moderation` WHERE `id` = " . $key . ";");
|
||||
}
|
||||
}
|
||||
|
||||
if($found) {
|
||||
header("Location: /moderation.php");
|
||||
die();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Moderace otázek</title>
|
||||
<style>
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
tr {
|
||||
border-bottom: 1px solid black;
|
||||
border-top: 1px solid black;
|
||||
}
|
||||
|
||||
td {
|
||||
width: 1px;
|
||||
white-space: nowrap;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
td:last-child {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
input[type="radio"] {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
label {
|
||||
padding-right: 16px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Moderace otázek pro pana Stallmana</h1>
|
||||
<p>
|
||||
<a href="/moderation.php">Načíst nové otázky</a>
|
||||
</p>
|
||||
<p>- = zatím nechat otázku (beze změn) ve frontě moderátora, ✅ = odeslat otázku panu Stallmanovi (s případnými změnami), ❌ = odstranit otázku</p>
|
||||
<form action="/moderation.php" method="get">
|
||||
<table>
|
||||
<?php
|
||||
$found = false;
|
||||
|
||||
query("SELECT `id`, `text` FROM `for_moderation`;", function($row) {
|
||||
global $found;
|
||||
$found = true;
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
<input type="radio" id="' . $row["id"] . 'nothing" name="' . $row["id"] . '" value="nothing" checked>
|
||||
<label for="' . $row["id"] . 'nothing">-</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="radio" id="' . $row["id"] . 'ok" name="' . $row["id"] . '" value="ok">
|
||||
<label for="' . $row["id"] . 'ok">✅</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="radio" id="' . $row["id"] . 'del" name="' . $row["id"] . '" value="del">
|
||||
<label for="' . $row["id"] . 'del">❌</label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea name="' . $row["id"] . 'message" style="width: 100%">' . htmlspecialchars($row["text"]) . '</textarea>
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
});
|
||||
|
||||
if(!$found) {
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
Žádné otázky nenalezeny.
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
?>
|
||||
</table><br>
|
||||
<input type="submit" value="Odeslat!">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user