-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
80 lines (75 loc) · 1.85 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
ob_start();
if (!isset($_SESSION)) {
session_start();
}
include 'config/setup.php';
include_once "config/pdo.php";
include_once 'includes/like_functions.php';
include_once 'includes/comment_functions.php';
include_once 'includes/time_elapsed_string.php';
if (isset($_GET['logout'])) {
unset($_SESSION["user_id"]);
unset($_SESSION["user_uid"]);
header("Location: login");
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<?php include_once 'frontend/head.php'; ?>
<title>Camagru</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/gallery.css">
<script src='js/comment.js'></script>
<script src='js/image.js'></script>
<script src='js/does_it_match.js'></script>
</head>
<body>
<?php include "frontend/header.php"; ?>
<main>
<div id="overlay_box">
<div id='overlay_bar'>
<h1 id='overlay_header'></h1> <i id='cross' class="fa-solid fa-xmark"></i>
</div>
<div id='overlay_content'></div>
</div>
<div id='dim-background'></div>
<?php
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}
if ($page < 1) {
header("Location: ?page=1");
exit();
}
$per_page = 5;
$image_count = image_count($pdo);
if ($image_count > 0) {
$page_count = ceil($image_count / $per_page);
if ($page > $page_count) {
header("Location: ?page=$page_count");
exit();
}
$data = fetch_page($pdo, $page, $per_page);
foreach ($data as $image) {
require('frontend/image_div.php');
}
require('frontend/pagination.php');
} else { ?>
<div class='no_images'>
<h3>No images to display 😢</h3>
<p><a href='camera'>Click here</a> to upload your first picture</p>
</div>
<?php } ?>
</main>
<script src='js/like.js'></script>
<script src='js/comment.js'></script>
<?php
include 'frontend/footer.html';
?>
</body>
</html>