2024-05-24 18:52:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include("../../global.php");
|
|
|
|
session_start();
|
|
|
|
|
|
|
|
if (!isset($_SESSION["username"])) goto fail;
|
|
|
|
|
|
|
|
$out = $database -> query("SELECT username FROM user WHERE BINARY username=\"" . $_SESSION["username"] . "\"");
|
|
|
|
|
|
|
|
if ($out -> num_rows != 1)
|
|
|
|
{
|
|
|
|
fail:
|
|
|
|
echo "nope";
|
|
|
|
header("Location: ../../../index.php");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-05-25 16:06:15 +02:00
|
|
|
$out = $database -> query("SELECT title, description, photo_id, author FROM post WHERE archived=0 ORDER BY id DESC");
|
2024-05-24 18:52:27 +02:00
|
|
|
|
|
|
|
$output = array();
|
|
|
|
|
|
|
|
while (($res = $out -> fetch_assoc()))
|
|
|
|
{
|
|
|
|
$buffer_array = array();
|
|
|
|
|
|
|
|
foreach ($res as $key => $value)
|
|
|
|
{
|
|
|
|
$buffer_array[$key] = $value;
|
|
|
|
}
|
|
|
|
|
2024-05-24 19:52:19 +02:00
|
|
|
$author_buffer = $database -> query("SELECT username FROM user WHERE id=" . $value);
|
|
|
|
if ($author_buffer -> num_rows == 1)
|
|
|
|
{
|
|
|
|
$buffer_array["username"] = ($author_buffer -> fetch_assoc())["username"];
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
$buffer_array["username"] = "[odstraněn]";
|
|
|
|
}
|
|
|
|
|
2024-05-24 18:52:27 +02:00
|
|
|
array_push($output, $buffer_array);
|
|
|
|
}
|
|
|
|
|
|
|
|
header('Content-type: application/json');
|
|
|
|
echo json_encode($output);
|