Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions Version_16_AdminLoginUndMemberboard/Swiss_JDM_Blog/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Password for Admin:



Password for the registred User Svendolin
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
// HTML output of the header without a dynamic navigation state
?>

<!DOCTYPE html>
<html lang="en">
<head> <!-- close here to clean the code visually -->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-------------------------------------- BASIC HTML5 TAG FOR RESPONSIVENESS -------------------------------------->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-------------------------------------- META TAG -------------------------------------->
<meta name="keywords" content="JDM Blog Website using PHP and MySQL">
<meta name="description" content="This SAE Modul Project needs to be build up with PHP and MySQL so here we go :D">
<meta name="author" content="Svendolin">
<title>Admin Area - Swiss JDM Blog</title>
<!-------------------------------------- CDN FONTAWESOME ICONS (Keep me updated) -------------------------------------->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta2/css/all.min.css" integrity="sha512-YWzhKL2whUzgiheMoBFwW8CKV4qpHQAEuvilg9FAn5VJUDwKZZxkJNuGM4XkWuk94WCrrwslk8yWNGmY1EduTA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-------------------------------------- GOOGLE FONTS LINK -------------------------------------->
<link href="https://fonts.googleapis.com/css2?family=Abel&family=Lexend:wght@200;300;400;500;700&family=Nunito:wght@300;400;600;700;800&family=Permanent+Marker&display=swap" rel="stylesheet">
<!-------------------------------------- OWL-CAROUSEL -------------------------------------->
<link rel="stylesheet" type="text/css" media="screen" href="../theme/css/owl.carousel.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="../theme/css/owl.theme.default.min.css">
<!-------------------------------------- AOS Library CSS ---------------------------------->
<!-- (Animate on scroll) https://michalsnik.github.io/aos/ > download > dist > copy aos.js and aos.css -->
<link rel="stylesheet" href="../theme/css/aos.css">
<!-------------------------------------- CSS LINKS -------------------------------------->
<link rel="stylesheet" type="text/css" media="screen" href="../theme/css/variables.css">
<link rel="stylesheet" type="text/css" media="screen" href="../theme/css/style.css">

<!-------------------------------------- CSS LINK TO SEPERATE MEDIA QUERY PAGE -------------------------------------->
<link rel="stylesheet" type="text/css" media="screen" href="../theme/css/mediaqueries.css">
<!-------------------------------------- Favicon -------------------------------------->
<link rel="apple-touch-icon" sizes="57x57" href="../favicon/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="../favicon/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="../favicon/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="../favicon/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="../favicon/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="../favicon/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="../favicon/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="../favicon/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="../favicon/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="../favicon/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="../favicon/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="../favicon/favicon-16x16.png">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<!-------------------------------------- JQUERY / JAVASCRIPT CONNECTION -------------------------------------->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer" defer></script>
<!-------------------------------------- OWL-CAROUSEL JQUERY -------------------------------------->
<script src="../theme/javascript/owl.carousel.min.js" defer></script>
<!-------------------------------------- AOS Library JS -------------------------------------->
<script src="../theme/javascript/aos.js" defer></script>
<!-------------------------------------- JS CONNECTION -------------------------------------->
<script src="../theme/javascript/main.js" defer></script>
</head>
<body>
<!--------- NAVIGATION ------------------------------------------------------------------------------------------>

<nav class="nav">
<div class="nav-menu flex-row">
<div class="nav-brand">
<a href="../index.php">Swiss JDM Blog</a> <!-- text or image -->
</div>
<!-- toggle burger -->
<!-- <div class="toggle-collapse">
<div class="toggle-icons">
<i class="menu-toggle-btn fas fa-bars"></i>
</div>
</div> -->
<!-- <div>
<ul class="nav-items">
<li class="nav-link">
<a href="../index.php" class="home">Return to main page</a>
</li>
<li class="nav-link">
<a href="blogposts.php">Blogposts</a>
</li>
<li class="nav-link">
<a href="../memberboard.php" class="member">Memberboard</a>
</li>
</ul>
</div> -->

<div class="login text-gray">
<a href="../admin/logout.php">Logout</a>
</div>
</div>
</nav>

<!---x---- NAVIGATION ----x-------------------------------------------------------------------------------------->
69 changes: 69 additions & 0 deletions Version_16_AdminLoginUndMemberboard/Swiss_JDM_Blog/admin/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
require_once('../includes/config.php'); // Serverconfiguration that apply to the whole project
require_once('../includes/mysql-connect.php'); // Initializing the mysql database connection
require_once('../includes/functions.inc.php'); // functions which refers to session_init() and session_check()

// ----- Users are allowed to see this content when they're logged in ONLY ----- //
session_init();
// $usertype = $_POST["admin_usertype"];
$isLoggedIn = sessioncheck();
if($isLoggedIn == false){
// if($usertype !== 1)
// schüztt dieses Script vor Zurgriff ohne Login
header("location: ../admin/login.php");
exit;
}
// --x-- Users are allowed to see this content when they're logged in ONLY --x-- //


?>

<!---------- Header + Navigation -------------------------------------------------------------------------------------------->
<?php include('html/start-logout.php'); // Use of the html admin folder ?>
<!-----x---- Header + Navigation ----x--------------------------------------------------------------------------------------->


<section id="admin-control">

<div class="controlbox text-gray">
<h1>Blog management</h1>
<i class="fas fa-book"></i>
<h2>Edit and delete posts created by users</h2>
<a href="../index.php" name="" class="btn-edit">Go for it!</a>
</div>
<div class="controlbox text-gray">
<h1>Profile management</h1>
<i class="fas fa-user"></i>
<h2>Edit and delete user profiles</h2>
<a href="../index.php" name="" class="btn-edit">Go for it!</a>
</div>
<div class="controlbox text-gray">
<h1>Profile management</h1>
<i class="fas fa-user"></i>
<h2>Edit and delete user profiles</h2>
<a href="../index.php" name="" class="btn-edit">Go for it!</a>
</div>


</section>
















<!-- TODO: You should see me if the login system has worked well -->

<!------------ footer ----------------------------------------------------------------------------------------------------->
<?php include('html/end-clean-end.php'); // Use of the html admin folder ?>
<!-----x---- footer ----x-------------------------------------------------------------------------------------------------->
120 changes: 120 additions & 0 deletions Version_16_AdminLoginUndMemberboard/Swiss_JDM_Blog/admin/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?php
require_once('../includes/config.php'); // Serverconfiguration that apply to the whole project
require_once('../includes/mysql-connect.php'); // Initializing the mysql database connection
require_once('../includes/functions.inc.php'); // for session_init() / session_check() and adminIdExists()

// ----- Users are allowed to see this content when logged in AND logged out: ----- //
session_start();
// --x-- Users are allowed to see this content when logged in AND logged out. --x-- //

// -- Check if sign-in input is set... -- //
if (isset($_POST["admin-submit-sign-in"])) {

// First we get the form data from the URL
$adminname = $_POST["admin_name"];
$adminemail = $_POST["admin_email"];
$adminpwd = $_POST["admin_password"];

if (emptyInputAdminLogin($adminname, $adminpwd) === true) {
header("location: ../admin/login.php?error=emptyinputlogin");
exit();
}
// Now we insert the user into the database
loginAdmin($conn, $adminname, $adminpwd);
}

// -- Function 1: Check for empty input sign-in -- //
function emptyInputAdminLogin($adminname, $adminpwd) {
$result;
if (empty($adminname) || empty($adminpwd)) {
$result = true;
}
else {
$result = false;
}
return $result;
}

// -- Function 2: Check for empty input sign-in -- //
function loginAdmin($conn, $adminname, $adminpwd) {
$adminIdExists = adminIdExists($conn, $adminname, $adminname); // Check if email OR username already exist in the database. Doubled means: we can handle that as true or false

// Error handler. Check if the user does exist, $uidExists connects the $conn, username and email check (as shown above):
if ($adminIdExists === false) {
header("location: ../admin/login.php?error=wronglogin");
exit();
}
// echo '<pre>';
// print_r($adminIdExists);
// echo '<pre>';

$pwdHashed = $adminIdExists["admin_password"]; // usersPwd is the passwort field inside of our users table of our database
$checkPwd = password_verify($adminpwd, $pwdHashed); // If it matches = true, if not = false, logically

// echo '<pre>';
// print_r($_checkPwd);
// echo '<pre>';

// Check if the entered password of the user does not match (is false) to its password in the database:
if ($checkPwd === false) {
header("location: ../admin/login.php?error=wronglogin");
exit();
}

//...if it matches, the login can start with a SESSION START:
else if ($checkPwd === true) {
session_start();
$_SESSION["adminid"] = $adminIdExists["IDadmin"];
$_SESSION["adminuid"] = $adminIdExists["admin_name"];
$_SESSION['loginstatus'] = true; // logintsatus speichern
$_SESSION['lastactivity'] = time(); // timestamp in session
$_SESSION['login_useragent'] = $_SERVER['HTTP_USER_AGENT'];

header("location: ../admin/index.php"); // THAT's the possitive target! ✅
// exit();
}
}

// echo password_hash("adminPW1234!!", PASSWORD_DEFAULT);
// IMPORTANT: to enter into your admin login, use: Sven Kamm OR sven0815@gmx.ch AND adminPW1234!!



?>

<!---------- Header + Navigation -------------------------------------------------------------------------------------------->
<?php include('html/start.php'); // Use of the html admin folder ?>
<!-----x---- Header + Navigation ----x--------------------------------------------------------------------------------------->


<section id="admin-login">

<div class="center">
<h1>Login</h1>

<form method="post">
<div class="txt_field">
<input type="text" name="admin_name" id="fld_username" value="" required>
<span></span>
<label>*Username</label>
</div>
<div class="txt_field">
<input type="password" name="admin_password" id="fld_pw" value="" required>
<span></span>
<label>*Password</label>
</div>
<div class="emptyspace"></div>
<div class="buttonarea">
<input type="submit" name="admin-submit-sign-in" value="Sign In" class="btn-special-sign-in"></input> <!-- For an input: "value" gives the text -->
<a href="../index.php" name="admin-return" class="btn-special-return">Return</a>
</div>
</div>
</form>
</div>
</section>



<!------------ footer ----------------------------------------------------------------------------------------------------->
<?php include('html/end.php'); // Use of the html admin folder ?>
<!-----x---- footer ----x-------------------------------------------------------------------------------------------------->
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
// --- config.php = SQL Serverconfiguration to PHPMyAdmin (dbh - Databasehandler) --- //


// SQL define() configurations
define( 'DBSERVER', 'localhost' );
define( 'DBUSER', 'root' );
define( 'DBPASSWORT', '' ); // ('root' for MAMP)
define( 'DBNAME', 'swiss_jdm_blog' ); // Adjusted data (Name of database must be equal in PHPMyAdmin)

define( 'SQLDEBUG', true );

define( 'SESSION_EXPIRY', 15 ); // 15*60 seconds (in functions.inc.php)
// define( 'CUSTOM_SESSIONNAME', 'jdmsessioncookie' ); // Not needed


// Defined main-path to the blog
define('INCLUDE_FOLDER', 'includes/html'); // Folder of the HTML includes
define( 'LIVE_SITE', 'Swiss_JDM_Blog' ); // IMPORTANT: SPECIFY ORDERNAME (PATH) EXACTLY from htdocs (without htdocs as first instance) otherwhise the file_sites wont work!

// FIXME: Not proven! (Take care)
define( 'IMAGEFOLDER', 'user-images' );
define( 'IMAGEFOLDERPATH', $_SERVER['DOCUMENT_ROOT'].'/'.LIVE_SITE.'/'.IMAGEFOLDER ); // diesen Ordner musst du anpassen {GEHT NICHT}

define( 'HTMLFOLDER', $_SERVER['DOCUMENT_ROOT'].'/'.LIVE_SITE.'/includes/html' ); // diesen Ordner musst du anpassen {GEHT NICHT}


?>
Loading