forked from Adleraci/adlerka.top
Test css
This commit is contained in:
31
lib/meme.php
31
lib/meme.php
@@ -3,16 +3,39 @@
|
||||
function addMeme(string $memeText, int $imageID): bool
|
||||
{
|
||||
global $mysqli;
|
||||
if(fileExists($imageID)){
|
||||
$stmtMemeAdd = $mysqli->prepare('INSERT INTO Memes (AuthorID, TextContent, FileID) VALUES (?, ?, ?)');
|
||||
$stmtMemeAdd->bind_param('isi', $_SESSION['ID'], htmlspecialchars($memeText), $imageID);
|
||||
|
||||
if (isLoggedIn() && fileExists($imageID)) {
|
||||
$stmtMemeAdd = $mysqli->prepare('INSERT INTO Memes (AuthorID, Title, TextContent, FileID) VALUES (?, ?, ?)');
|
||||
$stmtMemeAdd->bind_param('issi', $_SESSION['ID'], htmlspecialchars($memeText), $imageID);
|
||||
$stmtMemeAdd->execute();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function renderMemeGallery() :string
|
||||
function renderMemeGallery(): string
|
||||
{
|
||||
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();
|
||||
return "";
|
||||
}
|
@@ -228,4 +228,17 @@ function addToGroup(int $groupId, int $fileId): bool
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
function getImageURL(int $imageFileID) :string
|
||||
{
|
||||
global $mysqli;
|
||||
$path = "";
|
||||
$stmtget = $mysqli->prepare('SELECT Path FROM Files WHERE ID = ?');
|
||||
$stmtget->bind_param('i', $imageFileID);
|
||||
$stmtget->execute();
|
||||
$stmtget->bind_result($path);
|
||||
$stmtget->fetch();
|
||||
return $path;
|
||||
|
||||
}
|
Reference in New Issue
Block a user