2023-11-19 19:28:43 +01:00
|
|
|
<?php
|
|
|
|
$pdo;
|
|
|
|
try {
|
|
|
|
$pdo = new PDO($dsn, $user, $passwd);
|
|
|
|
// if ($pdo) echo "Connected to the $dbname database successfully!";
|
|
|
|
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
echo $e->getMessage();
|
|
|
|
}
|
|
|
|
|
2024-11-16 22:00:15 +01:00
|
|
|
function get_images($pdo, $search='%', $sort='img_date', $sdir='DESC') {
|
2024-11-18 23:18:36 +01:00
|
|
|
if ($sort != 'img_date' && $sdir != 'ASC') {
|
|
|
|
if ($sort != 'img_title' && $sdir != 'DESC') {
|
|
|
|
echo('Ey boss, database request is kinda f*cked up. Maybe you want to try that again, hey...<br>'.$sort.' '.$sdir);
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$params = array('search' => $search);
|
|
|
|
$stmt = $pdo->prepare("SELECT * FROM images WHERE img_title LIKE CONCAT('%', :search ,'%') ORDER BY $sort $sdir;");
|
2024-11-16 22:00:15 +01:00
|
|
|
$stmt->execute($params);
|
2024-11-18 23:18:36 +01:00
|
|
|
// $stmt->debugDumpParams();
|
2023-11-19 19:28:43 +01:00
|
|
|
$data = $stmt->fetchAll();
|
|
|
|
|
|
|
|
$img_list = '<ul class="img_list">';
|
|
|
|
foreach ($data as $block) {
|
|
|
|
$img_list .= '<li>';
|
|
|
|
$img_list .= '<img src=\''.$block['img_path'].'\'><br>';
|
|
|
|
$img_list .= '<h4>'.$block['img_title']."<br></h4>";
|
2024-11-22 22:08:27 +01:00
|
|
|
$img_list .= '<p class="list_text">'.$block['img_desc']."</p>";
|
2023-11-19 19:28:43 +01:00
|
|
|
$img_list .= '</li>';
|
|
|
|
}
|
|
|
|
$img_list .= '</ul>';
|
|
|
|
echo $img_list;
|
|
|
|
}
|
2024-11-22 22:08:27 +01:00
|
|
|
|
|
|
|
function get_audio($pdo, $search='%', $sort='aud_date', $sdir='DESC') {
|
|
|
|
if ($sort != 'aud_date' && $sdir != 'ASC') {
|
|
|
|
if ($sort != 'aud_title' && $sdir != 'DESC') {
|
|
|
|
echo('Ey boss, database request is kinda f*cked up. Maybe you want to try that again, hey...<br>'.$sort.' '.$sdir);
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$params = array('search' => $search);
|
|
|
|
$stmt = $pdo->prepare("SELECT * FROM audio WHERE aud_title LIKE CONCAT('%', :search ,'%') ORDER BY $sort $sdir;");
|
|
|
|
$stmt->execute($params);
|
|
|
|
// $stmt->debugDumpParams();
|
|
|
|
$data = $stmt->fetchAll();
|
|
|
|
|
|
|
|
$aud_list = '<ul class="aud_list">';
|
|
|
|
foreach ($data as $block) {
|
|
|
|
$aud_list .= '<li>';
|
|
|
|
$aud_list .= '<audio controls>';
|
|
|
|
$aud_list .= '<source src=\''.$block['aud_path'].'\' type="audio/mpeg">';
|
|
|
|
$aud_list .= 'There would be an awesome music player here if you weren\'t such a weirdo...';
|
|
|
|
$aud_list .= '</audio>';
|
|
|
|
$aud_list .= '<h4>'.$block['aud_title']."<br></h4>";
|
|
|
|
$aud_list .= '<p class="list_text">'.$block['aud_desc']."</p>";
|
|
|
|
$aud_list .= '</li>';
|
|
|
|
}
|
|
|
|
$aud_list .= '</ul>';
|
|
|
|
echo $aud_list;
|
|
|
|
}
|