Website/ajax/gallerie.php
2020-11-25 16:59:57 +01:00

54 lines
1.6 KiB
PHP

<?php #ajax/gallerie.php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once "../conf.php";
$article = $_POST["article"] ?? "Empty";
$galleries = array();
if ($stmt = $mysqli->prepare("select name,previewheight,previewpic from galleries g where article = ? order by ord asc")) {
$stmt->bind_param("s", $article);
$stmt->execute();
$res = $stmt->get_result();
while ($row = $res->fetch_assoc()) {
$galleries[] = $row;
}
$stmt->close();
}
$name = isset($_POST["section"]) && $_POST["section"]!="" ? $_POST["section"] : ($galleries[0]["name"] ?? "Empty");
$description = "";
$htmlcache = "";
if ($stmt = $mysqli->prepare("select description,htmlcache from galleries g where name = ? and article = ?")) {
$stmt->bind_param("ss", $name, $article);
$stmt->execute();
$stmt->bind_result($description, $htmlcache);
$stmt->fetch();
}
$id = preg_replace('/\s+/', '', $article."_".$name);
?>
<footer>
<h1><?=$article;?></h1>
<?php if (count($galleries)>1) { ?>
<ul>
<?php foreach ($galleries as $gal) { ?>
<a href='javascript:loadArticle("<?=basename(__FILE__);?>", "<?=$article;?>", "<?=$gal["name"];?>")'<?=($gal["name"]==$name ? " class='current'" : "");?>><li>
<?php if ($gal["previewheight"]>0 && $gal["previewpic"]!="") { ?>
<img src="/images/gallerien/<?=$gal["previewpic"];?>" title="<?=$gal["name"];?>" /><div><?=$gal["name"];?></div>
<?php } else { ?>
<?=$gal["name"];?>
<?php } ?>
</li></a>
<?php } ?>
</ul>
<?php } ?>
</footer>
<section id='<?=$id;?>'><?=$description.$htmlcache;?></section>