m3
This commit is contained in:
parent
059d9d5e20
commit
4b69e73f65
1
www/hit.dat
Normal file
1
www/hit.dat
Normal file
@ -0,0 +1 @@
|
||||
0
|
@ -7,7 +7,7 @@
|
||||
<body>
|
||||
<?php
|
||||
|
||||
$file = "../../../user.dat";
|
||||
$file = "../../../userM2.dat";
|
||||
|
||||
function addUser($newUser, $file) {
|
||||
|
||||
|
@ -1,25 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php
|
||||
function cleanData($data) {
|
||||
mb_internal_encoding("UTF-8");
|
||||
function cleanData($data)
|
||||
{
|
||||
mb_internal_encoding("UTF-8");
|
||||
|
||||
if(!mb_check_encoding($data)){
|
||||
header('Location: start.php');
|
||||
}
|
||||
|
||||
$data = strip_tags($data);
|
||||
$data = htmlspecialchars($data);
|
||||
$data = trim($data);
|
||||
$data = stripslashes($data);
|
||||
return $data;
|
||||
if (!mb_check_encoding($data)) {
|
||||
header('Location: start.php');
|
||||
}
|
||||
|
||||
$data = strip_tags($data);
|
||||
$data = htmlspecialchars($data);
|
||||
$data = trim($data);
|
||||
$data = stripslashes($data);
|
||||
return $data;
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
BIN
www/public/Moment-3/bilder/bgImg.png
Executable file
BIN
www/public/Moment-3/bilder/bgImg.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
137
www/public/Moment-3/css/styleSheet.css
Executable file
137
www/public/Moment-3/css/styleSheet.css
Executable file
@ -0,0 +1,137 @@
|
||||
@CHARSET "UTF-8";
|
||||
* {
|
||||
margin:0;
|
||||
padding:0;
|
||||
font-family:Verdana, Geneva, sans-serif;
|
||||
}
|
||||
body{
|
||||
font-size: 100%;
|
||||
}
|
||||
p {
|
||||
font-size: 0.8em;
|
||||
margin-bottom: 10px;
|
||||
margin-top: 5px;
|
||||
margin-right: 10px;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
/* Wrapper */
|
||||
#wrapper {
|
||||
width: 800px;
|
||||
margin-left: auto;
|
||||
margin-right:auto;
|
||||
margin-top:10px;
|
||||
border: 2px solid rgba(0,0,0,0.8);
|
||||
}
|
||||
/* End wrapper */
|
||||
|
||||
/* Header */
|
||||
header {
|
||||
text-align:center;
|
||||
height: 60px;
|
||||
background-image: url("../bilder/bgImg.png");
|
||||
|
||||
color: white;
|
||||
}
|
||||
header h1{
|
||||
font-family: Arial;
|
||||
font-size: 1.9em;
|
||||
padding-top: 0.25em;
|
||||
}
|
||||
|
||||
header time{
|
||||
float: right;
|
||||
margin-right: 2em;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
/* End header */
|
||||
|
||||
nav{
|
||||
border-radius: 5px; /* CSS3 */
|
||||
border: 1px solid #999;
|
||||
padding: 4px;
|
||||
margin-bottom:5px;
|
||||
}
|
||||
nav ul {
|
||||
list-style:none;
|
||||
}
|
||||
nav li{
|
||||
margin-top: 5px;
|
||||
border: 1px solid #000;
|
||||
}
|
||||
nav li a{
|
||||
display:block;
|
||||
font-size: 0.8em;
|
||||
text-decoration: none;
|
||||
color: #aa0000;
|
||||
padding-left: 15px;
|
||||
background-color:#FFC;
|
||||
}
|
||||
nav li a:hover, #leftColumn li a:active, #leftColumn li a:focus{
|
||||
background-color: gray;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
aside {
|
||||
-moz-border-radius: 5px; /* Ger rundade hörn i Firefox */
|
||||
border-radius: 5px; /* CSS3 */
|
||||
border: 1px solid #999;
|
||||
padding: 4px;
|
||||
margin-bottom:5px;
|
||||
}
|
||||
|
||||
aside p {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
/* leftColumn */
|
||||
#leftColumn {
|
||||
float: left;
|
||||
width: 180px;
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
#leftColumn h1 {
|
||||
font-family:Arial, Helvetica, sans-serif;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
/* End leftColumn */
|
||||
/* Main */
|
||||
main {
|
||||
margin-top: 8px;
|
||||
margin-left:200px;
|
||||
}
|
||||
main h1{
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 1.4em;
|
||||
}
|
||||
main h2{
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
main section{
|
||||
float:right;
|
||||
width: 99%;
|
||||
}
|
||||
|
||||
form label,a{
|
||||
font-size: 0.8em;
|
||||
}
|
||||
/* End content */
|
||||
/* Footer */
|
||||
footer {
|
||||
height: 30px;
|
||||
background-image: url("../bilder/bgImg.png");
|
||||
color: white;
|
||||
font-size: 0.75em;
|
||||
clear:both;
|
||||
}
|
||||
footer #footerRight{
|
||||
float:right;
|
||||
padding: 5px;
|
||||
}
|
||||
footer #footerLeft{
|
||||
float:left;
|
||||
padding: 5px;
|
||||
}
|
||||
/* End footer */
|
41
www/public/Moment-3/dataBas/addUser.php
Normal file
41
www/public/Moment-3/dataBas/addUser.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
$file = "../../../userM3.dat";
|
||||
|
||||
function addUser($newUser, $file) {
|
||||
|
||||
if(file_exists($file)){
|
||||
$users = unserialize(file_get_contents($file));
|
||||
}else{
|
||||
echo "Filen finns inte!!!";
|
||||
exit;
|
||||
}
|
||||
if (!is_array($users)) {
|
||||
$users = [];
|
||||
} else {
|
||||
// If file does not exist, initialize as an empty array
|
||||
$users = [];
|
||||
}
|
||||
$users[] = $newUser;
|
||||
file_put_contents($file, serialize($users));
|
||||
}
|
||||
|
||||
function readUser($file, $användarnamn, $lösenord) {
|
||||
if(file_exists($file)){
|
||||
$users = unserialize(file_get_contents($file));
|
||||
}else{
|
||||
// Filen finns ej!! Kör om programmet “personWrite.php”
|
||||
}
|
||||
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
|
||||
foreach($users as $user) {
|
||||
if ($user->getAnvändarnamn() == $användarnamn && $user->getLösenord() == $lösenord) {
|
||||
echo('Välkommen ' . $user->getFörnamn() . " " . $user->getEfternamn());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
11
www/public/Moment-3/dataBas/besökRäknare.php
Normal file
11
www/public/Moment-3/dataBas/besökRäknare.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$hit = 0;
|
||||
|
||||
if(file_exists("../../../hit.dat")){
|
||||
$hit = file_get_contents("../../../hit.dat");
|
||||
}
|
||||
|
||||
$hit++;
|
||||
file_put_contents("../../../hit.dat",$hit);
|
||||
echo "Antal användare: " . $hit;
|
||||
?>
|
17
www/public/Moment-3/dataBas/cleanData.php
Normal file
17
www/public/Moment-3/dataBas/cleanData.php
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
<?php
|
||||
function cleanData($data)
|
||||
{
|
||||
mb_internal_encoding("UTF-8");
|
||||
|
||||
if (!mb_check_encoding($data)) {
|
||||
header('Location: start.php');
|
||||
}
|
||||
|
||||
$data = strip_tags($data);
|
||||
$data = htmlspecialchars($data);
|
||||
$data = trim($data);
|
||||
$data = stripslashes($data);
|
||||
return $data;
|
||||
}
|
||||
?>
|
63
www/public/Moment-3/dataBas/inLoggning.php
Normal file
63
www/public/Moment-3/dataBas/inLoggning.php
Normal file
@ -0,0 +1,63 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>FeetBook</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>FeetBook</h1>
|
||||
<form action="" method="post">
|
||||
<fieldset>
|
||||
<legend>Sign up</legend>
|
||||
<input type="hidden" name="form_id" value="sign_up">
|
||||
<label>Skriv förnamn</label>
|
||||
<input type="text" name="förnamn">
|
||||
<label>Skriv efternamn</label>
|
||||
<input type="text" name="efternamn">
|
||||
<label>Skriv användarnamn</label>
|
||||
<input type="text" name="användarnamn">
|
||||
<label>Skriv lösenord</label>
|
||||
<input type="text" name="lösenord">
|
||||
<input type="submit" value="Sign Up">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<form action="" method="post">
|
||||
<fieldset>
|
||||
<legend>Sign in</legend>
|
||||
<input type="hidden" name="form_id" value="sign_in">
|
||||
<label>Skriv användarnamn</label>
|
||||
<input type="text" name="användarnamn">
|
||||
<label>Skriv lösenord</label>
|
||||
<input type="text" name="lösenord">
|
||||
<input type="submit" value="Sign in">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
include('cleanData.php');
|
||||
include('user.php');
|
||||
include('addUser.php');
|
||||
if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
if ($_POST['form_id'] === 'sign_up') {
|
||||
$förnamn = cleandata($_POST['förnamn']);
|
||||
$användarnamn = cleandata($_POST['användarnamn']);
|
||||
$lösenord = cleandata($_POST['lösenord']);
|
||||
$efternamn = cleandata($_POST['efternamn']);
|
||||
|
||||
$newUser = new user($förnamn, $efternamn, $användarnamn, $lösenord);
|
||||
addUser($newUser, $file);
|
||||
}
|
||||
if ($_POST['form_id'] === 'sign_in') {
|
||||
$användarnamn = cleandata($_POST['användarnamn']);
|
||||
$lösenord = cleandata($_POST['lösenord']);
|
||||
readUser($file, $användarnamn, $lösenord);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
include("../../footer.html");
|
||||
?>
|
||||
</body>
|
||||
</html>
|
32
www/public/Moment-3/dataBas/logIn.php
Normal file
32
www/public/Moment-3/dataBas/logIn.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if(isset($_POST['password'],$_POST['username'])){
|
||||
|
||||
if($_POST['password'] == '12345' && $_POST['username']=='admin'){
|
||||
$_SESSION['inloggad'] = true; // Användaren har anget rätt uppgifter.
|
||||
$_SESSION['user'] = $_POST['username'];
|
||||
}
|
||||
}
|
||||
|
||||
// Om lyckad inloggning gå till index.php. Annars gå vidare och visa formuläret.
|
||||
if(isset($_SESSION['inloggad'])){
|
||||
header("Location: ../index.php");
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="sv">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" >
|
||||
<title>Sessioner</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form method="post" >
|
||||
Username: <input type="text" name="username" size="20" /><br />
|
||||
Password: <input type="password" name="password" size="20" /><br />
|
||||
<input type="submit" value="Logga in" name="login"/>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
8
www/public/Moment-3/dataBas/loggOut.php
Normal file
8
www/public/Moment-3/dataBas/loggOut.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
$_SESSION = array(); // Tömmer sessionsarrayen
|
||||
session_destroy();
|
||||
|
||||
header("Location: index.php");
|
||||
?>
|
36
www/public/Moment-3/dataBas/user.php
Normal file
36
www/public/Moment-3/dataBas/user.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
class user {
|
||||
|
||||
private $förnamn;
|
||||
private $efternamn;
|
||||
private $användarnamn;
|
||||
private $lösenord;
|
||||
|
||||
public function __construct($förnamn, $efternamn, $användarnamn, $lösenord) {
|
||||
$this->förnamn = $förnamn;
|
||||
$this->efternamn = $efternamn;
|
||||
$this->användarnamn = $användarnamn;
|
||||
$this->lösenord = $lösenord;
|
||||
}
|
||||
|
||||
public function getFörnamn() {
|
||||
return $this->förnamn;
|
||||
}
|
||||
|
||||
public function getEfternamn() {
|
||||
return $this->efternamn;
|
||||
}
|
||||
|
||||
public function getAnvändarnamn() {
|
||||
return $this->användarnamn;
|
||||
}
|
||||
|
||||
public function getLösenord() {
|
||||
return $this->lösenord;
|
||||
}
|
||||
|
||||
public function setLösenord($lösenord) {
|
||||
$this->lösenord = $lösenord;
|
||||
}
|
||||
}
|
||||
?>
|
8
www/public/Moment-3/inc/aside.php
Normal file
8
www/public/Moment-3/inc/aside.php
Normal file
@ -0,0 +1,8 @@
|
||||
<aside>
|
||||
<h1>Namn</h1>
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
Nulla tristique elementum nisl, et vehicula neque laoreet ut.
|
||||
Praesent sed ultrices purus.
|
||||
</p>
|
||||
</aside>
|
4
www/public/Moment-3/inc/footer.php
Normal file
4
www/public/Moment-3/inc/footer.php
Normal file
@ -0,0 +1,4 @@
|
||||
<footer>
|
||||
<span id="footerLeft">© Sidlayoutarna</span>
|
||||
<span id="footerRight"><a href="mailto:xxx@doman">xxx@doman</a></span>
|
||||
</footer>
|
3
www/public/Moment-3/inc/header.php
Normal file
3
www/public/Moment-3/inc/header.php
Normal file
@ -0,0 +1,3 @@
|
||||
<header>
|
||||
<h1>Webbserverprogrammering 1 med Bygren</h1>
|
||||
</header>
|
9
www/public/Moment-3/inc/meny.php
Normal file
9
www/public/Moment-3/inc/meny.php
Normal file
@ -0,0 +1,9 @@
|
||||
<nav>
|
||||
<h1>Innehåll</h1>
|
||||
<ul>
|
||||
<li><a href="index.php">Hem</a></li>
|
||||
<li><a href="index.php?page=blogg">Blogg</a></li>
|
||||
<li><a href="index.php?page=bilder">Bilder</a></li>
|
||||
<li><a href="index.php?page=kontakt">Kontakt</a></li>
|
||||
</ul>
|
||||
</nav>
|
53
www/public/Moment-3/index.php
Normal file
53
www/public/Moment-3/index.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
session_start();
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="sv">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Länka in sidor med PHP</title>
|
||||
<link href="css/styleSheet.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<?php
|
||||
include("inc/header.php");
|
||||
?>
|
||||
|
||||
<section id="leftColumn">
|
||||
<?php
|
||||
include("inc/meny.php");
|
||||
include("inc/aside.php");
|
||||
?>
|
||||
</section>
|
||||
<!-- End leftColumn -->
|
||||
<?php
|
||||
|
||||
$page = "start";
|
||||
if (isset($_GET['page']))
|
||||
$page = $_GET['page'];
|
||||
|
||||
switch ($page) {
|
||||
case 'blogg':
|
||||
include('pages/blogg.php');
|
||||
break;
|
||||
case 'bilder':
|
||||
include('pages/bilder.php');
|
||||
break;
|
||||
case 'kontakt':
|
||||
include('pages/kontakt.php');
|
||||
break;
|
||||
|
||||
default:
|
||||
include('pages/start.php');
|
||||
}
|
||||
include("inc/footer.php");
|
||||
include("dataBas/besökRäknare.php");
|
||||
?>
|
||||
</div>
|
||||
<!-- End wrapper -->
|
||||
</body>
|
||||
|
||||
</html>
|
2
www/public/Moment-3/pages/bilder.php
Normal file
2
www/public/Moment-3/pages/bilder.php
Normal file
@ -0,0 +1,2 @@
|
||||
<p>Bild 1</p>
|
||||
<p>Bild 2</p>
|
13
www/public/Moment-3/pages/blogg.php
Normal file
13
www/public/Moment-3/pages/blogg.php
Normal file
@ -0,0 +1,13 @@
|
||||
<main role="main">
|
||||
<section>
|
||||
<hgroup>
|
||||
<h1>Min blogg Nu</h1>
|
||||
<h2>I dag gör vi mallar</h2>
|
||||
</hgroup>
|
||||
<p>Lorem ipsum id duo autem qualisque, cu laoreet eleifend cum. Eu sea
|
||||
vidit altera civibus, harum deserunt argumentum ne vim. Eu paulo
|
||||
corpora appareat pro, brute everti iuvaret ne vis. Diam incorrupte
|
||||
voluptatibus cu vel, nam congue soluta praesent at.
|
||||
</p>
|
||||
</section>
|
||||
</main>
|
2
www/public/Moment-3/pages/kontakt.php
Normal file
2
www/public/Moment-3/pages/kontakt.php
Normal file
@ -0,0 +1,2 @@
|
||||
<p>TelefonNummber: 112</p>
|
||||
<p>Get help today call your mother</p>
|
3
www/public/Moment-3/pages/start.php
Normal file
3
www/public/Moment-3/pages/start.php
Normal file
@ -0,0 +1,3 @@
|
||||
<h1>Välkommen till Webbserverprogrammering 1</h1>
|
||||
<h2>Moment 2</h2>
|
||||
<p>Vi kommer använda include() för att länka in sidor i vår mall.</p>
|
@ -9,5 +9,6 @@
|
||||
<a href="Moment-0/index.php">Moment-0</a>
|
||||
<a href="Moment-1/index.php">Moment-1</a>
|
||||
<a href="Moment-2/index.php">Moment-2</a>
|
||||
<a href="Moment-3/index.php">Moment-3</a>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user