blob: 5a0d62a6de5b0b1abe1b3f13b2ccb433726c9606 (
plain) (
blame)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
<?php
session_start();
require_once "consts.php";
require_once "dbCredentials.php";
checkLoggedIn();
if ($_GET["logout"] === "1") {
header("HTTP/1.0 307 Teapot has no more tea :'(");
header("Location: index.php");
session_unset();
exit();
}
$pdo = new PDO("mysql:dbname=$dbName;host=$dbHost;charset=utf8mb4", $dbUser, $dbPassword);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$stmt = $pdo->prepare("SELECT * FROM `cms_card`");
$stmt->execute();
$cards = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-wEmeIV1mKuiNpC+IOBjI7aAzPcEZeedi5yW5f2yOq55WWLwNGmvvx4Um1vskeMj0" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<style>
.w-45 {
width: 49.5%;
margin-bottom: 5px;
margin-right: 5px;
}
footer {
position: absolute;
bottom: 0;
width: 100%;
height: 3rem;
padding: 12px;
background-color: #202020;
color: white;
text-align: center;
color: #878787;
}
</style>
<title>CMS - Main</title>
</head>
<body class="bg-dark text-white" style="position: relative; min-height: 100vh;">
<div class="container" style="padding-bottom: 3rem;">
<nav class="navbar navbar-expand-lg navbar navbar-dark bg-dark">
<a class="navbar-brand" href="#">
<i class="fas fa-home"></i>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse">
<div class="navbar-nav">
<a class="nav-item nav-link active" href="#">News</a>
<a class="nav-item nav-link" href="#">Articles</a>
<a class="nav-item nav-link" href="#">Pricing</a>
<?php
if ($_SESSION["user_type"] === 1)
echo '<a class="nav-item nav-link" href="users.php">Administration</a>'
?>
</div>
</div>
</nav><br>
<div style='display: flex; flex-wrap: wrap;'>
<?php
$i = 0;
foreach ($cards as $card) {
if (strlen($card["body"]) > 40)
$title = substr($card["title"], 0, 40) . "...";
else
$title = $card["title"];
if (strlen($card["body"]) > 250)
$body = substr($card["body"], 0, 250) . "...";
else
$body = $card["body"];
$i++;
echo "
<div class='card w-45 bg-secondary'>
<h5 class='card-header'>News $i</h5>
<div class='card-body'>
<h5 class='card-title'>$title</h5>
<p class='card-text'>$body</p>
<a href='#' class='btn btn-primary'>Read whole</a>
</div>
</div>
";
} ?>
</div>
<div class="card bg-secondary text-center" style="width: 99.4%">
<h5 class="card-header bg-success">Advertisement</h5>
<div class="card-body">
<h5 class="card-title">By our thing</h5>
<p class="card-text">Out thing is better than those other things</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
<div class="card-footer">
Final countdown
</div>
</div><br>
<?php
if ($_SESSION["user_type"] === 1)
echo '<a class="btn btn-info" href="cardsList.php">Edit cards</a>';
?>
<a class="btn btn-primary" href="main.php?logout=1" style="float: right;">Logout</a>
</div><br>
<footer>
<span>Copyright © 2021, All Right Reserved Maks Jopek</span>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-p34f1UUtsS3wqzfto5wAAmdvj+osOnFyQFpp4Ua3gs/ZVWx6oOypYoCJhGGScy+8" crossorigin="anonymous"></script>
</body>
</html>
|