kind of everything, lets be real

master
flejk 2 years ago
parent 4150b74666
commit 147a41aa0c

@ -1 +0,0 @@
<?php include("view/footer.php"); ?>

@ -1 +0,0 @@
<?php include("view/footer.php"); ?>

@ -1 +0,0 @@
<?php include("view/footer.php"); ?>

@ -1 +0,0 @@
<?php include("view/footer.php"); ?>

@ -4,6 +4,15 @@
## TO DO:
*Make searchbar work*
*Add editors and extend the database*
*Implement articles*
*Implement listing and following*
### Tasks
*search.php*
*insert beer/brewery/article form - /admin.php*
*add beer to list/ add brewery to follow*
*article/brewery/beer/list .php*

@ -0,0 +1,18 @@
<?php
session_start();
require_once("model/db.php");
require_once("controller/getRecord.php");
require("view/header.php");
$record = getRecord($pdo, "article", $_GET["id"] );
$title = $record["title"];
$description = $record["body"];
$date = $record["time"];
require("view/mainContent/mainContent.php");
require("view/sidebar.php");
include("view/footer.php");

@ -0,0 +1,21 @@
<?php
session_start();
require_once("model/db.php");
require_once("controller/getRecord.php");
require("view/header.php");
$record = getRecord($pdo, "beer", $_GET["id"] );
$title = $record["name"];
$alc = $record["alc"];
$ibu = $record["ibu"];
$description = $record["description"];
$brewery_id = $record["brewery_id"];
$date = $record["time"];
require("view/mainContent/mainContent.php");
require("view/sidebar.php");
include("view/footer.php");

@ -0,0 +1,20 @@
<?php
session_start();
require_once("model/db.php");
require_once("controller/getRecord.php");
require("view/header.php");
$record = getRecord($pdo, "brewery", $_GET["id"] );
$title = $record["name"];
$description = $record["description"];
$date = $record["time"];
$region = $record["region"];
require("view/mainContent/mainContent.php");
require("view/sidebar.php");
include("view/footer.php");

@ -0,0 +1,15 @@
<?php
function getRecord($pdo, $from, $where ){
$conn = $pdo;
try {
$sql = "SELECT * FROM $from WHERE id = $where";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$record = $stmt->fetch();
} catch (PDOException $e) {
echo "Error in $from: Not Found";
}
return $record;
}

@ -0,0 +1,58 @@
<?php
function listLatestBeers($pdo, $where){
$conn = $pdo;
try {
$sql = "SELECT * FROM beer ORDER BY time DESC LIMIT $where";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$arrayOfBeers = $stmt->fetchAll();
} catch (PDOException $e) {
echo "Error in Beers: " . $e->getMessage();
}
return $arrayOfBeers;
}
function listLatestBreweries($pdo, $where){
$conn = $pdo;
try {
$sql = "SELECT * FROM brewery ORDER BY time DESC LIMIT $where";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$arrayOfBreweries = $stmt->fetchAll();
} catch (PDOException $e) {
echo "Error in Breweries: " . $e->getMessage();
}
return $arrayOfBreweries;
}
function listLatestUsers($pdo, $where){
$conn = $pdo;
try {
$stmt = $conn->prepare("SELECT * FROM user ORDER BY time DESC LIMIT $where");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$arrayOfBreweries = $stmt->fetchAll();
} catch (PDOException $e) {
echo "Error in Beers: " . $e->getMessage();
}
return $arrayOfUsers;
}
function listLatestArticle($pdo, $where){
$conn = $pdo;
try {
$stmt = $conn->prepare("SELECT * FROM article ORDER BY time DESC LIMIT $where");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$arrayOfArticles = $stmt->fetchAll();
} catch (PDOException $e) {
echo "Error in Beers: " . $e->getMessage();
}
return $arrayOfArticles;
}

@ -1,5 +1,5 @@
-- MySQL Script generated by MySQL Workbench
-- Tue 08 Feb 2022 03:13:53 AM CET
-- Wed 09 Feb 2022 11:18:41 PM CET
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
@ -27,6 +27,7 @@ CREATE TABLE IF NOT EXISTS `vujovicig`.`user` (
`nick` VARCHAR(25) NOT NULL,
`mail` VARCHAR(255) NOT NULL,
`password` VARCHAR(255) NOT NULL,
`time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE INDEX `nick_UNIQUE` (`nick` ASC))
ENGINE = InnoDB;
@ -42,6 +43,7 @@ CREATE TABLE IF NOT EXISTS `vujovicig`.`brewery` (
`name` VARCHAR(45) NULL,
`region` VARCHAR(45) NULL,
`description` MEDIUMTEXT NULL,
`time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
@ -58,6 +60,8 @@ CREATE TABLE IF NOT EXISTS `vujovicig`.`beer` (
`ibu` INT NULL,
`description` MEDIUMTEXT NULL,
`brewery_id` INT NOT NULL,
`time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`degree` INT NULL,
PRIMARY KEY (`id`, `brewery_id`),
INDEX `fk_beer_brewery1_idx` (`brewery_id` ASC),
CONSTRAINT `fk_beer_brewery1`
@ -154,6 +158,20 @@ CREATE TABLE IF NOT EXISTS `vujovicig`.`beer_has_tag` (
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `vujovicig`.`article`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `vujovicig`.`article` ;
CREATE TABLE IF NOT EXISTS `vujovicig`.`article` (
`id` INT NOT NULL AUTO_INCREMENT,
`title` VARCHAR(45) NULL,
`body` MEDIUMTEXT NULL,
`time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

@ -17,15 +17,15 @@ insert into brewery (name, region, description) values ( 'Matuska', 'Broumy', 'R
insert into brewery (name, region, description) values ( 'Cestmir', 'Stara Boleslav', 'Remeslny pivovar');
insert into brewery (name, region, description) values ( 'Prazdroj', 'Plzen', 'Pilsner Urquell');
insert into beer ( name, alc, ibu, description, brewery_id) values ( 'Robin', 5.1, '40', '12', '1' );
insert into beer ( name, alc, ibu, description, brewery_id) values ( 'Krahulik', 5.0, '32', '12', '1' );
insert into beer ( name, alc, ibu, description, brewery_id) values ( 'Pilsner Urquell', 4.4, '38', '12', '5' );
insert into beer ( name, alc, ibu, description, brewery_id) values ( 'Zlata Raketa', 7.0, '60', '17', '3' );
insert into beer ( name, alc, ibu, description, brewery_id) values ( 'Yummy Blackcurrant Raspberry & Lingonberry', 5.1, '40', '12', '2' );
insert into beer ( name, alc, ibu, description, brewery_id, degree) values ( 'Robin', 5.1, '40', 'Quality APA, good as a starting beer', '1','12' );
insert into beer ( name, alc, ibu, description, brewery_id, degree) values ( 'Krahulik', 5.0, '32', 'Classic Lagger from Zichovec, comes in handy','1', '12' );
insert into beer ( name, alc, ibu, description, brewery_id, degree) values ( 'Pilsner Urquell', 4.4, '38', 'Oh yes, the PILSNER!','5', '12' );
insert into beer ( name, alc, ibu, description, brewery_id, degree) values ( 'Zlata Raketa', 7.0, '60', 'Signature beer from Matuska Brewery','3', '17' );
insert into beer ( name, alc, ibu, description, brewery_id, degree) values ( 'Yummy Blackcurrant Raspberry & Lingonberry', 5.1, '40', 'Simply delicious Beer from Siberia with full taste','2', '12' );
insert into tag ( tag_title ) values ( 'IPA' );
insert into tag ( tag_title ) values ( 'APA' );
insert into tag ( tag_title ) values ( 'LEZAK' );
insert into tag ( tag_title ) values ( 'LAGER' );
insert into tag ( tag_title ) values ( 'PASTRY SOUR' );
insert into tag ( tag_title ) values ( 'SOUR' );
insert into tag ( tag_title ) values ( 'NEIPA' );
@ -56,4 +56,10 @@ insert into list ( user_id, beer_id, rating ) values ( '2', '3', '5' );
insert into list ( user_id, beer_id ) values ( '2', '4');
insert into list ( user_id, beer_id ) values ( '2', '1' );
insert into list ( user_id, beer_id, rating ) values ( '3', '4', '5' );
insert into list ( user_id, beer_id, rating ) values ( '3', '5', '5');
insert into list ( user_id, beer_id, rating ) values ( '3', '5', '5');
insert into article ( title, body ) values ( 'I have no Clue 2', 'I Have still no Idea.');
insert into article ( title, body ) values ( 'I have no Clue 1', 'I should know What Im doing by know, but I am not smart enough to do so.');
insert into article ( title, body ) values ( 'Where does it come from?', 'Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.');
insert into article ( title, body ) values ( 'Why do we use it?', 'It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using "Content here, content here", making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for "lorem ipsum" will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).');
insert into article ( title, body ) values ( 'News - Lorem Ipsum!', 'This is a placeholder for news');

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -3,7 +3,7 @@ session_start();
require("view/header.php");
require("view/mainContent.php");
require("view/mainPage.php");
require("view/sidebar.php");

@ -0,0 +1,14 @@
<?php
session_start();
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
require("view/header.php");
require("view/sidebar.php");
include("view/footer.php");
} else {
header("location: index.php");
}

@ -0,0 +1,4 @@
<?php
session_start();
header("location: index.php");

@ -45,6 +45,10 @@ h3 {
/* --- HEAD --- */
a:link {
color: red;
text-decoration: none;
}
header {
@ -67,7 +71,6 @@ nav {
nav > div.profile {
padding: 0.5em;
color: #fff;
display: flex;
justify-content: space-between;
}
@ -165,6 +168,13 @@ button:hover {
}
/* --- FOOTER --- */
#topSearchValue {
height: 52px;
margin: 10px;
font-size: 1em;
}
footer {
clear: both;
width: 100%;

@ -67,7 +67,6 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
header("location: index.php");
} else{
// Password is not valid, display a generic error message
$login_err = "Invalid username or password.";
session_start();
$_SESSION["wrongCr"] = true;
header("location: index.php");
@ -75,7 +74,6 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
}
} else{
// Username doesn't exist, display a generic error message
$login_err = "Invalid username or password.";
session_start();
$_SESSION["wrongCr"] = true;
header("location: index.php");

@ -1,5 +1,12 @@
<div class="scrolltainer">
<form id="searchBar" method="get" class="searchBar" action="search.php">
<select name="type" id="topSearchValue" class="inputtext">
<option value="all">All</option>
<option value="beer">Beers</option>
<option value="brewery">Breweries</option>
<option value="tag">Tags</option>
<option value="article">Articles</option>
</select>
<input id="SearchText" type="text" name="keyword" placeholder="Beers, Breweries and more..." size="22" autocomplete="off">
<input id="SearchButton" type="image" alt="Search !" src="src/search-ico.png">
</form>

@ -16,43 +16,15 @@ session_start();
<header>
<h1>Welcome to<br/>Beer List of Mine</h1>
</header>
</a>
</a>
<!-- menu-->
<nav>
<div
<?php
<?php
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
echo 'class="profile">
<div class="slice">
<ul>
<li>Yo, <b>'; echo htmlspecialchars($_SESSION["username"]); echo '</b>! Another one on the tab?</li>
</ul>
</div>
<div class="slice">
<ul>
<li><a href="passChange.php" >Reset Your Password</a></li>
<li><a href="logout.php" >Log out.</a></li>
</ul>
</div>
';
} else echo '>
<form id="nigol" method="post" action="verify.php" class="menu">
<input id="prihlasovaciJmeno" name="prihlasovaciJmeno" type="text" placeholder="Nickname" size="22" >
<input id="prihlasovaciHeslo" name="prihlasovaciHeslo" type="password" placeholder="Passphrase" size="22" >
<input id="SearchButton" type="image" alt="Enter !" src="src/key-ico.png">
</form>
</div>
<div class="login"> //Honeypot
<form id="login" method="post" action="verify.php" class="login">
<input name="user" type="text" placeholder="Username" size="22" >
<input name="password" type="password" placeholder="Password" size="22" >
<input id="SearchButton" type="image" alt="Enter !" src="src/key-ico.png">
</form>';?> </div>
</nav>
<?php if(isset($_SESSION["wrongCr"]) && $_SESSION["wrongCr"] === true){
echo '<script>alert("Wrong Credentials")</script>';
$_SESSION["wrongCr"] = false;
}
require("view/navbar/userbar.php");
} else {
require("view/navbar/loginbar.php");
}
?>

@ -1,22 +0,0 @@
<div class="content">
<div class="box">
<article>
<h2>News - Lorem Ipsum!</h2> <time pubdate="pubdate"> 07-02-2022 </time>
<p><em> This is a placeholder for news </em></p>
</article>
</div>
<div class="box">
<article>
<h2>Why do we use it?</h2> <time pubdate="pubdate"> 07-02-2022 </time>
<p><em>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</em></p>
</article>
</div>
<div class="box">
<article>
<h2>Where does it come from?</h2> <time pubdate="pubdate"> 07-02-2022 </time>
<p><em>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</em></p>
</article>
</div>
</div>

@ -0,0 +1,9 @@
<div class="content">
<div class="box">
<article>
<h2><?= $title ?></h2>
<em>In our database from:</em><time pubdate="pubdate"> <?= $date ?> </time>
<p><?= $description ?></p>
</article>
</div>
</div>

@ -0,0 +1,22 @@
<?php
require_once("model/db.php");
require_once("controller/listLatest.php");
?>
<div class="content">
<?php
$where = "5";
$what = "article";
$array = listLatestArticle($pdo, $where);
?>
<h2>NEWS:</h2>
<?php foreach($array as $row) : ?>
<div class="box">
<article>
<a href="<?= $what ?>.php?id=<?= $row['id'] ?>" ><h2><?= $row['title'] ?></h2></a> Published on:<time pubdate="pubdate"> <?= $row['time'] ?> </time>
<p><em> <?= substr($row['body'],0 ,120) ?>...</em></p>
</article>
</div>
<?php endforeach; ?>
</div>

@ -0,0 +1,22 @@
<nav>
<div>
<form id="nigol" method="post" action="verify.php" class="menu">
<input id="prihlasovaciJmeno" name="prihlasovaciJmeno" type="text" placeholder="Nickname" size="22" >
<input id="prihlasovaciHeslo" name="prihlasovaciHeslo" type="password" placeholder="Passphrase" size="22" >
<input id="SearchButton" type="image" alt="Enter !" src="src/key-ico.png">
</form>
</div>
<div class="login"> //Honeypot
<form id="login" method="post" action="verify.php" class="login">
<input name="user" type="text" placeholder="Username" size="22" >
<input name="password" type="password" placeholder="Password" size="22" >
<input id="loginButton" type="image" alt="Enter !" src="src/key-ico.png">
</form>
</div>
</nav>
<?php
if(isset($_SESSION["wrongCr"]) && $_SESSION["wrongCr"] === true){
echo '<script>alert("Wrong Credentials")</script>';
$_SESSION["wrongCr"] = false;
}
?>

@ -0,0 +1,18 @@
<?php
session_start();
?>
<nav>
<div class="profile">
<div class="slice">
<ul>
<li>Yo, <b><?php echo htmlspecialchars($_SESSION["username"]); ?></b>! Another one on the tab?</li>
</ul>
</div>
<div class="slice">
<ul>
<li><a href="myList.php" >Beer List of Mine</a></li>
<li><a href="passChange.php" >Reset Your Password</a></li>
<li><a href="logout.php" >Log out.</a></li>
</ul>
</div>
</nav>

@ -1,26 +1,31 @@
<?php
require_once("model/db.php");
require_once("controller/listLatest.php");
?>
<aside>
<?php
$title = "LATEST Beers";
$where = "5";
$what = "beer";
$array = listLatestBeers($pdo, $where);
require("sidebar/sidebarLister.php")
?>
<?php
<div>
<h3>New Beers</h3>
<ul>
<li><a href="BLM/article.php">Zichovec</a></li>
<li>Matuska</li>
<li>Siberia</li>
<li>Cestmir</li>
<li>Pilsner</li>
</ul>
</div>
<div>
<h3>New Breweries</h3>
<ul>
<li>Zichovec</li>
<li>Matuska</li>
<li>Siberia</li>
<li>Cestmir</li>
<li>Pilsner</li>
</ul>
</div>
$title = "LATEST Breweries";
$where = "5";
$what = "brewery";
$array = listLatestBreweries($pdo, $where);
require("sidebar/sidebarLister.php");
?>
</aside>

@ -0,0 +1,10 @@
<div>
<h3><?= $title ?></h3>
<ul>
<?php foreach($array as $row) : ?>
<li><a href="<?= $what ?>.php?id=<?= $row['id'] ?>">--> <?= $row['name'] ?></a></li>
<?php endforeach; ?>
</ul>
</div>
Loading…
Cancel
Save