adlerka.space/lib/meme.php

41 lines
1.2 KiB
PHP
Raw Normal View History

2024-04-11 10:36:40 +02:00
<?php
function addMeme(string $memeText, int $imageID): bool
{
global $mysqli;
2024-04-25 09:04:10 +02:00
if (isLoggedIn() && fileExists($imageID)) {
$stmtMemeAdd = $mysqli->prepare('INSERT INTO Memes (AuthorID, Title, TextContent, FileID) VALUES (?, ?, ?)');
$stmtMemeAdd->bind_param('issi', $_SESSION['ID'], htmlspecialchars($memeText), $imageID);
2024-04-11 10:36:40 +02:00
$stmtMemeAdd->execute();
return true;
}
return false;
}
2024-04-25 09:04:10 +02:00
function renderMemeGallery(): string
2024-04-11 10:36:40 +02:00
{
2024-04-25 09:04:10 +02:00
global $mysqli;
$stmtlist = $mysqli->prepare('SELECT Memes.ID, Memes.Title Memes.TextContent, Memes.CreatedAt, Files.Path, Files.Type, Users.Nickname FROM Memes INNER JOIN Users ON Memes.AuthorID = Users.ID INNER JOIN Files ON Memes.FileID = Files.ID');
// Execute the prepared statement
$stmtlist->execute();
$memeID = 0;
$title = "";
$textContent = "";
$filePath = "";
$fileType = "";
$userNickname = "";
$createdAt = "";
// Bind the result variables
$stmtlist->bind_result($memeID, $title, $textContent, $createdAt, $filePath, $fileType, $userNickname);
// Fetch the results
while ($stmtlist->fetch()) {
}
// Close the statement
$stmtlist->close();
2024-04-11 10:36:40 +02:00
return "";
}