Everythink :/
parent
c5b703308f
commit
5e124aa2b4
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
// Initialize the session
|
||||
session_start();
|
||||
|
||||
|
||||
|
||||
// Check if the user is already logged in, if yes then redirect him to welcome page
|
||||
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
|
||||
header("location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Include config file
|
||||
require_once "model/db.php";
|
||||
|
||||
// Define variables and initialize with empty values
|
||||
$username = $password = "";
|
||||
$username_err = $password_err = $login_err = "";
|
||||
|
||||
|
||||
// Processing form data when form is submitted
|
||||
if($_SERVER["REQUEST_METHOD"] == "POST"){
|
||||
|
||||
// Check if username is empty
|
||||
if(empty(trim($_POST["username"]))){
|
||||
$username_err = "Please enter username.";
|
||||
} else{
|
||||
$username = trim($_POST["username"]);
|
||||
}
|
||||
|
||||
// Check if password is empty
|
||||
if(empty(trim($_POST["password"]))){
|
||||
$password_err = "Please enter your password.";
|
||||
} else{
|
||||
$password = trim($_POST["password"]);
|
||||
}
|
||||
|
||||
// Validate credentials
|
||||
if(empty($username_err) && empty($password_err)){
|
||||
if($username == "pseudoRoot"){
|
||||
if($password == "nemamheslo"){
|
||||
|
||||
session_start();
|
||||
$_SESSION["loggedinAdmin"] = true;
|
||||
$_SESSION["username"] = "admin";
|
||||
header("location: controller/insertWhat.php");
|
||||
} else $login_err = "Wrong Password";
|
||||
} else $login_err = "Wrong Username";
|
||||
}else $login_err = "You didnt Enter either username of Password";
|
||||
|
||||
unset($pdo);
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Admin Login</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||
<style>
|
||||
body{ font: 14px sans-serif; }
|
||||
.wrapper{ width: 360px; padding: 20px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<h2>SECRET ADMIN LOGIN???</h2>
|
||||
<?php
|
||||
if(!empty($login_err)){
|
||||
echo '<div class="alert alert-danger">' . $login_err . '</div>';
|
||||
}
|
||||
?>
|
||||
|
||||
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
|
||||
<div class="form-group">
|
||||
<label>ADMIN name</label>
|
||||
<input type="text" name="username" class="form-control <?php echo (!empty($username_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $username; ?>">
|
||||
<span class="invalid-feedback"><?php echo $username_err; ?></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Password</label>
|
||||
<input type="password" name="password" class="form-control <?php echo (!empty($password_err)) ? 'is-invalid' : ''; ?>">
|
||||
<span class="invalid-feedback"><?php echo $password_err; ?></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" class="btn btn-primary" value="Login">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// Initialize the session
|
||||
session_start();
|
||||
|
||||
// Check if the user is already logged in, if yes then redirect him to welcome page
|
||||
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] == false){
|
||||
header("location: ../index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Include config file
|
||||
require_once("../model/db.php");
|
||||
|
||||
$what = key($_POST);
|
||||
$item = $_POST[$what];
|
||||
$id = $_SESSION["id"];
|
||||
|
||||
if ($what == "beer"){
|
||||
$from_id = "beer_id";
|
||||
$from="list";
|
||||
} else {
|
||||
$from_id = "brewery_id";
|
||||
$from="follow";
|
||||
}
|
||||
|
||||
$conn = $pdo;
|
||||
try {
|
||||
$sql = "INSERT INTO $from ( user_id, $from_id) values ( $id, $item );";
|
||||
echo $sql;
|
||||
$conn->exec($sql);
|
||||
} catch (PDOException $e) {
|
||||
echo "Error in $from: Not Found";
|
||||
}
|
||||
header("location: ../$what.php?id=$item");
|
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
// Initialize the session
|
||||
session_start();
|
||||
|
||||
// Check if the user is already logged in, if yes then redirect him to welcome page
|
||||
if(isset($_SESSION["loggedinAdmin"]) && $_SESSION["loggedinAdmin"] === true){
|
||||
echo "";
|
||||
}else header("location: ../index.php");
|
||||
|
||||
// Include config file
|
||||
require_once("../model/db.php");
|
||||
|
||||
$title = $_POST["title"];
|
||||
$body = $_POST["body"];
|
||||
|
||||
if(!is_null($title)){
|
||||
$conn = $pdo;
|
||||
try {
|
||||
$sql = "INSERT INTO article ( title, body ) values ( '$title', '$body' );";
|
||||
echo $sql;
|
||||
$conn->exec($sql);
|
||||
} catch (PDOException $e) {
|
||||
echo "Error in $from: Not Found";
|
||||
}
|
||||
}
|
||||
//header("location: ../insertWhat.php");
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Insert Article</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||
<style>
|
||||
body{ font: 14px sans-serif; }
|
||||
.wrapper{ width: 360px; padding: 20px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<h2>Insert Article</h2>
|
||||
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
|
||||
<div class="form-group">
|
||||
<label>Title</label>
|
||||
<input type="text" name="title" class="form-control">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Body</label>
|
||||
<textarea rows="4" cols="50" name="body" class="form-control"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" class="btn btn-primary" value="Submit">
|
||||
<a class="btn btn-link ml-2" href="insertWhat.php">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
// Initialize the session
|
||||
session_start();
|
||||
|
||||
// Check if the user is already logged in, if yes then redirect him to welcome page
|
||||
if(isset($_SESSION["loggedinAdmin"]) && $_SESSION["loggedinAdmin"] === true){
|
||||
echo "";
|
||||
}else header("location: ../index.php");
|
||||
|
||||
// Include config file
|
||||
require_once("../model/db.php");
|
||||
require_once("listLatest.php");
|
||||
|
||||
$name = $_POST["name"];
|
||||
$alc = $_POST["alc"];
|
||||
$ibu = $_POST["ibu"];
|
||||
$description = $_POST["description"];
|
||||
$brewery_id = $_POST["brewery_id"];
|
||||
$degree = $_POST["degree"];
|
||||
|
||||
$arrayOfBreweries = listBeersByBreweryNAN( $pdo );
|
||||
|
||||
if(!is_null($name)){
|
||||
$conn = $pdo;
|
||||
try {
|
||||
$sql = "INSERT INTO beer ( name, alc, ibu, description, brewery_id, degree ) values ( '$name', $alc, '$ibu', '$description', '$brewery_id', '$degree' );";
|
||||
echo $sql;
|
||||
$conn->exec($sql);
|
||||
} catch (PDOException $e) {
|
||||
echo "Error in $from: Not Found";
|
||||
}
|
||||
}
|
||||
// header("location: ../insertWhat.php");
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Reset Password</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||
<style>
|
||||
body{ font: 14px sans-serif; }
|
||||
.wrapper{ width: 360px; padding: 20px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<h2>Insert Beer</h2>
|
||||
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
|
||||
<div class="form-group">
|
||||
<label>Beer Name</label>
|
||||
<input type="text" name="name" class="form-control">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Alc (float for example: 4.2)</label>
|
||||
<input type="text" name="alc" class="form-control">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>IBU</label>
|
||||
<input type="text" name="ibu" class="form-control">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Description</label>
|
||||
<textarea rows="4" cols="50" name="decsription" class="form-control"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Parent Brewery</label>
|
||||
<select name="brewery_id" class="form-control">
|
||||
<?php foreach($arrayOfBreweries as $row) : ?>
|
||||
<option value="<?= $row['id'] ?>"><?= $row['name'] ?></option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Degree</label>
|
||||
<input type="text" name="degree" class="form-control">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" class="btn btn-primary" value="Submit">
|
||||
<a class="btn btn-link ml-2" href="insertWhat.php">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
// Initialize the session
|
||||
session_start();
|
||||
|
||||
// Check if the user is already logged in, if yes then redirect him to welcome page
|
||||
if(isset($_SESSION["loggedinAdmin"]) && $_SESSION["loggedinAdmin"] === true){
|
||||
echo "";
|
||||
}else header("location: ../index.php");
|
||||
|
||||
// Include config file
|
||||
require_once("../model/db.php");
|
||||
|
||||
$name = $_POST["name"];
|
||||
$region = $_POST["region"];
|
||||
$description = $_POST["description"];
|
||||
|
||||
if(!is_null($name)){
|
||||
$conn = $pdo;
|
||||
try {
|
||||
$sql = "INSERT INTO article ( name, region, description ) values ( '$name', '$region', '$description' );";
|
||||
$conn->exec($sql);
|
||||
} catch (PDOException $e) {
|
||||
echo "Error in $from: Not Found";
|
||||
}
|
||||
}
|
||||
// header("location: ../insertWhat.php");
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Reset Password</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||
<style>
|
||||
body{ font: 14px sans-serif; }
|
||||
.wrapper{ width: 360px; padding: 20px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<h2>Insert Brewery</h2>
|
||||
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
|
||||
<div class="form-group">
|
||||
<label>Name of Brewery</label>
|
||||
<input type="text" name="name" class="form-control">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Region</label>
|
||||
<input type="text" name="region" class="form-control">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Description</label>
|
||||
<textarea rows="4" cols="50" name="decsription" class="form-control"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" class="btn btn-primary" value="Submit">
|
||||
<a class="btn btn-link ml-2" href="insertWhat.php">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// Initialize the session
|
||||
session_start();
|
||||
|
||||
// Check if the user is already logged in, if yes then redirect him to welcome page
|
||||
if(isset($_SESSION["loggedinAdmin"]) && $_SESSION["loggedinAdmin"] === true){
|
||||
echo "";
|
||||
}else header("location: ../index.php");
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Reset Password</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||
<style>
|
||||
body{ font: 14px sans-serif; }
|
||||
.wrapper{ width: 360px; padding: 20px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<select name="forma" onchange="location = this.value;">
|
||||
<option value="">Choose ...</option>
|
||||
<option value="insertBeer.php">Insert Beer</option>
|
||||
<option value="insertBrewery.php">Insert Brewery</option>
|
||||
<option value="insertArticle.php">Insert Article</option>
|
||||
<option value="../logout.php">Logout Admin</option>
|
||||
</select>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// Initialize the session
|
||||
session_start();
|
||||
|
||||
// Check if the user is already logged in, if yes then redirect him to welcome page
|
||||
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] == false){
|
||||
header("location: ../index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Include config file
|
||||
require_once("../model/db.php");
|
||||
$what = key($_POST);
|
||||
|
||||
$item = $_POST[$what];
|
||||
|
||||
$id = $_SESSION["id"];
|
||||
|
||||
|
||||
$conn = $pdo;
|
||||
try {
|
||||
$sql = "UPDATE list SET rating='$item' WHERE user_id = '$id' AND beer_id = '$what'";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
} catch (PDOException $e) {
|
||||
echo "Error in list: Not Found";
|
||||
}
|
||||
header("location: ../beer.php?id=$what");
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// Initialize the session
|
||||
session_start();
|
||||
|
||||
// Check if the user is already logged in, if yes then redirect him to welcome page
|
||||
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] == false){
|
||||
header("location: ../index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Include config file
|
||||
require_once("../model/db.php");
|
||||
|
||||
$what = key($_POST);
|
||||
$item = $_POST[$what];
|
||||
$id = $_SESSION["id"];
|
||||
|
||||
if ($what == "beer"){
|
||||
$from_id = "beer_id";
|
||||
$from="list";
|
||||
} else {
|
||||
$from_id = "brewery_id";
|
||||
$from="follow";
|
||||
}
|
||||
|
||||
$conn = $pdo;
|
||||
try {
|
||||
$sql = "DELETE FROM $from WHERE $from_id = $item AND user_id = $id";
|
||||
echo $sql;
|
||||
$conn->exec($sql);
|
||||
} catch (PDOException $e) {
|
||||
echo "Error in $from: Not Found";
|
||||
}
|
||||
header("location: ../$what.php?id=$item");
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
header("location: index.php");
|
||||
|
||||
print_r($_GET);
|
||||
//header("location: index.php");
|
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
@ -0,0 +1,7 @@
|
||||
<div class="content">
|
||||
<div class="taglist">
|
||||
<?php foreach($array as $row) : ?>
|
||||
<span class="tag"><a href="search.php?type=tag&keyword=<?= $row['tag_title'] ?>">+ <?= $row['tag_title'] ?></a></span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
@ -1,35 +1,42 @@
|
||||
<?php
|
||||
|
||||
function unfollowButton($pdo, $where, $item_id, $user_id){
|
||||
print_r($pdo);
|
||||
$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;
|
||||
function unfollowButton($where, $item_id){
|
||||
echo "<form method=\"POST\">
|
||||
<button type=\"submit\" name=\"";
|
||||
|
||||
if($where == "list"){
|
||||
echo "beer\" value=\"$item_id\" formaction=\"controller/unfollow.php\">Remove from My Beer List";
|
||||
}else echo "brewery\" value=\"$item_id\" formaction=\"controller/unfollow.php\">Unfollow Brewery";
|
||||
|
||||
echo "</button></form></br>";
|
||||
}
|
||||
|
||||
function followButton($pdo, $where, $item_id, $user_id){
|
||||
print_r($pdo);
|
||||
$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";
|
||||
function followButton($where, $item_id){
|
||||
|
||||
echo "<form method=\"POST\">
|
||||
<button type=\"submit\" name=\"";
|
||||
|
||||
|
||||
if($where == "list"){
|
||||
echo "beer\" value=\"$item_id\" formaction=\"controller/follow.php\">Add to My Beer List";
|
||||
}else echo "brewery\" value=\"$item_id\" formaction=\"controller/follow.php\">Follow Brewery";
|
||||
|
||||
echo "</button></form></br>";
|
||||
}
|
||||
|
||||
function showStars($beer_id, $rating){
|
||||
|
||||
for ($i = 1; $i <= $rating; $i++) {
|
||||
echo "<form method=\"POST\" action=\"controller/rate.php\">";
|
||||
echo "<input class=\"login\" type=\"text\" name=\"$beer_id\" value=\"$i\"></input>";
|
||||
echo "<input class=\"Star\" type=\"image\" alt=\"Rate !\" src=\"src/starY.png\" value=\"\">";
|
||||
echo "</form>";
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
function showStars($pdo, $beer_id, $user_id){
|
||||
print_r($pdo);
|
||||
for ($i = ++$rating ; $i <= 10; $i++) {
|
||||
echo "<form method=\"POST\" action=\"controller/rate.php\">";
|
||||
echo "<input class=\"login\" type=\"text\" name=\"$beer_id\" value=\"$i\"></input>";
|
||||
echo "<input class=\"Star\" type=\"image\" alt=\"Rate !\" src=\"src/starN.png\" value=\"\" >";
|
||||
echo "</form>";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue