select id
This commit is contained in:
parent
ba5ad5ff06
commit
f06bd74ca1
|
@ -67,11 +67,12 @@ if (isset($_POST['words'])) {
|
||||||
$words = array();
|
$words = array();
|
||||||
|
|
||||||
if ($recent_public) {
|
if ($recent_public) {
|
||||||
$sql_str = "SELECT `word1`, `word2`, `word3`, `author`, `new` FROM `words` ORDER BY `id` DESC LIMIT " . $recent_count . ";";
|
$sql_str = "SELECT `id`, `word1`, `word2`, `word3`, `author`, `new` FROM `words` ORDER BY `id` DESC LIMIT " . $recent_count . ";";
|
||||||
$res = $sql->query($sql_str);
|
$res = $sql->query($sql_str);
|
||||||
|
|
||||||
while ($r = $res->fetch_assoc()) {
|
while ($r = $res->fetch_assoc()) {
|
||||||
array_push($words, array(
|
array_push($words, array(
|
||||||
|
"id" => $r['id'],
|
||||||
"word1" => $r['word1'],
|
"word1" => $r['word1'],
|
||||||
"word2" => $r['word2'],
|
"word2" => $r['word2'],
|
||||||
"word3" => $r['word3'],
|
"word3" => $r['word3'],
|
||||||
|
|
34
ucp.php
34
ucp.php
|
@ -20,15 +20,40 @@
|
||||||
|
|
||||||
include_once 'config.php';
|
include_once 'config.php';
|
||||||
|
|
||||||
function check_privileges() {
|
function check_privileges($ajax = false) {
|
||||||
if (!$_SESSION['logged_in']) {
|
if (!$_SESSION['logged_in']) {
|
||||||
$_SESSION['flash'] = "Log in to continue.";
|
if ($ajax) {
|
||||||
header('Location: ucp.php?page=login');
|
header('Content-Type: application/javascript');
|
||||||
|
echo json_encode(array("success" => false));
|
||||||
|
} else {
|
||||||
|
$_SESSION['flash'] = "Log in to continue.";
|
||||||
|
header('Location: ucp.php?page=login');
|
||||||
|
}
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($_GET['page']) {
|
switch ($_GET['page']) {
|
||||||
|
case "ajax": {
|
||||||
|
check_privileges(true);
|
||||||
|
header('Content-Type: application/javascript');
|
||||||
|
$response = array("success" => false);
|
||||||
|
switch ($_GET['action']) {
|
||||||
|
case "delete-word": {
|
||||||
|
if (isset($_GET['id'])) {
|
||||||
|
if (is_numeric($_GET['id'])) {
|
||||||
|
$id = (int) $_GET['id'];
|
||||||
|
if ($sql->query("DELETE FROM `words` WHERE `id`=" . $id . ";")) {
|
||||||
|
$response["success"] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo json_encode($response);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "login": {
|
case "login": {
|
||||||
if ($_SESSION['logged_in']) {
|
if ($_SESSION['logged_in']) {
|
||||||
$_SESSION['flash'] = "You're already logged in.";
|
$_SESSION['flash'] = "You're already logged in.";
|
||||||
|
@ -121,13 +146,14 @@ switch ($_GET['page']) {
|
||||||
default: {
|
default: {
|
||||||
check_privileges();
|
check_privileges();
|
||||||
|
|
||||||
$sql_str = "SELECT `word1`, `word2`, `word3`, `author`, `new` FROM `words`;";
|
$sql_str = "SELECT `id`, `word1`, `word2`, `word3`, `author`, `new` FROM `words`;";
|
||||||
$res = $sql->query($sql_str);
|
$res = $sql->query($sql_str);
|
||||||
|
|
||||||
$words = array();
|
$words = array();
|
||||||
|
|
||||||
while ($r = $res->fetch_assoc()) {
|
while ($r = $res->fetch_assoc()) {
|
||||||
array_push($words, array(
|
array_push($words, array(
|
||||||
|
"id" => $r['id'],
|
||||||
"word1" => $r['word1'],
|
"word1" => $r['word1'],
|
||||||
"word2" => $r['word2'],
|
"word2" => $r['word2'],
|
||||||
"word3" => $r['word3'],
|
"word3" => $r['word3'],
|
||||||
|
|
Loading…
Reference in New Issue