Compare commits
2 Commits
e4460f0a76
...
a21f3ef6aa
Author | SHA1 | Date | |
---|---|---|---|
a21f3ef6aa | |||
57635df050 |
131
index.php
Normal file
131
index.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
include "api.php";
|
||||
|
||||
$found = false;
|
||||
|
||||
foreach($_GET as $key => $value) {
|
||||
$found = true;
|
||||
|
||||
if($key == "unselectmessage" || $key == "selectmessage") {
|
||||
query("UPDATE `for_stallman` SET `selected` = false");
|
||||
}
|
||||
|
||||
if($key == "selectmessage") {
|
||||
query("UPDATE `for_stallman` SET `selected` = true WHERE `id` = " . $conn->real_escape_string($value) . ";");
|
||||
}
|
||||
|
||||
if($key == "deletemessage") {
|
||||
query("DELETE FROM `for_stallman` WHERE `id` = " . $conn->real_escape_string($value) . ";");
|
||||
}
|
||||
}
|
||||
|
||||
if($found) {
|
||||
header("Location: /index.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:first-child {
|
||||
padding-left: 8px;
|
||||
}
|
||||
|
||||
td {
|
||||
width: 1px;
|
||||
white-space: nowrap;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
td:last-child {
|
||||
width: 100%;
|
||||
padding-right: 8px;
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
label {
|
||||
padding-right: 16px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Audience questions</h1>
|
||||
<p>
|
||||
<a href="/index.php">Load new questions</a>
|
||||
</p>
|
||||
<table>
|
||||
<?php
|
||||
$found = false;
|
||||
|
||||
query("SELECT `id`, `text`, `selected` FROM `for_stallman`;", function($row) {
|
||||
global $found;
|
||||
$found = true;
|
||||
|
||||
if(!$row["selected"]) {
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
<form action="/index.php" method="get">
|
||||
<input type="hidden" name="selectmessage" value="' . $row["id"] . '">
|
||||
<input type="submit" value="Select">
|
||||
</form>
|
||||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
' . htmlspecialchars($row["text"]) . '
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
} else {
|
||||
echo '
|
||||
<tr style="background-color: #EDF;">
|
||||
<td>
|
||||
<form action="/index.php" method="get">
|
||||
<input type="hidden" name="unselectmessage" value="' . $row["id"] . '">
|
||||
<input type="submit" value="Deselect">
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form action="/index.php" method="get">
|
||||
<input type="hidden" name="deletemessage" value="' . $row["id"] . '">
|
||||
<input type="submit" value="Delete" style="color: red;">
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
' . htmlspecialchars($row["text"]) . '
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
});
|
||||
|
||||
if(!$found) {
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
No questions found.
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
?>
|
||||
</table><br>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@@ -44,8 +44,13 @@
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
td:first-child {
|
||||
padding-left: 8px;
|
||||
}
|
||||
|
||||
td:last-child {
|
||||
width: 100%;
|
||||
padding-right: 8px;
|
||||
}
|
||||
|
||||
input[type="radio"] {
|
||||
|
Reference in New Issue
Block a user