This commit is contained in:
vadym Novoselskyi 2024-09-06 15:22:36 +02:00
parent 1a34e3e93b
commit d442c2facc
90 changed files with 1856 additions and 24 deletions

1
www/M3-02-hit.dat Normal file
View File

@ -0,0 +1 @@
22

1
www/M3-03-hit.dat Normal file
View File

@ -0,0 +1 @@
1

1
www/M3-04-hit.dat Normal file
View File

@ -0,0 +1 @@
4

1
www/M3-04-messages.dat Normal file
View File

@ -0,0 +1 @@
<hr><p>Från: wreqtrthsr</p><p>reywtyret</p><hr><p>Från: eargnkdsl</p><p>earsthy</p><hr><p>Från: aeawwtsrthd</p><p>agdhsf</p><hr><p>Från: argsdn</p><p>hsdtrj</p><hr><p>Från: ewttr</p><p>rerew</p><hr><p>Från: nklhio</p><p>hiohiohio</p><hr><p>Från: jo</p><p>jijpnin</p><hr><p>Från: </p><p>j</p><hr><p>Från: joqoapre</p><p>dvbilgfb</p>

1
www/M3-06-hit.dat Normal file
View File

@ -0,0 +1 @@
4

BIN
www/M3-06-users.dat Normal file

Binary file not shown.

View File

@ -4,7 +4,7 @@
<head lang="sv"></head> <head lang="sv"></head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title> <title>M0 | 01</title>
</html> </html>
<body> <body>
<h1>Matematik-test</h1> <h1>Matematik-test</h1>

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Responsiv webbdesign</title> <title>M0 | 03</title>
<link rel="stylesheet" href="css/styleSheet.css?v=1.0"> <link rel="stylesheet" href="css/styleSheet.css?v=1.0">
<link rel="stylesheet" href="css/gridCSS.css"> <link rel="stylesheet" href="css/gridCSS.css">
</head> </head>

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M1-test</title> <title>M1 | 01</title>
</head> </head>
<body> <body>
<form action="./handle.php" method="post"> <form action="./handle.php" method="post">

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M1-test</title> <title>M1 | 02</title>
</head> </head>
<body> <body>
<form action="./handle.php" method="post"> <form action="./handle.php" method="post">

View File

@ -2,7 +2,7 @@
<html> <html>
<head lang="sv"></head> <head lang="sv"></head>
<body> <body>
<h1>Matematik-test</h1> <h1>M1 | 03</h1>
<form action="calculate.php" method="post"> <form action="calculate.php" method="post">
<fieldset> <fieldset>

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 01</title> <title>M2 | 01</title>
</head> </head>
<body> <body>
<h1>Send data via url</h1> <h1>Send data via url</h1>

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 02</title> <title>M2 | 02</title>
</head> </head>
<body> <body>
<?php <?php

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 02</title> <title>M2 | 03</title>
</head> </head>
<body> <body>
<?php <?php

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 02</title> <title>M2 | 04</title>
</head> </head>
<body> <body>
<?php <?php

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 02</title> <title>M2 | 05</title>
</head> </head>
<body> <body>
<form action="handle.php" method="post"> <form action="handle.php" method="post">

View File

@ -0,0 +1,8 @@
<?php
function cleanData($data) {
$data = strip_tags($data);
$data = htmlspecialchars($data);
$data = trim($data);
$data = stripslashes($data);
return $data;
}

View File

@ -7,6 +7,7 @@
</head> </head>
<body> <body>
<?php <?php
include("cleanData.php");
if(isset($_POST["name"])) $name = $_POST["name"]; if(isset($_POST["name"])) $name = $_POST["name"];
if(isset($_POST["surname"])) $surname = $_POST["surname"]; if(isset($_POST["surname"])) $surname = $_POST["surname"];
if(isset($_POST["username"])) $username = $_POST["username"]; if(isset($_POST["username"])) $username = $_POST["username"];
@ -21,14 +22,6 @@
echo "Surname: " . $surname . "<br>"; echo "Surname: " . $surname . "<br>";
echo "Username: " . $username . "<br>"; echo "Username: " . $username . "<br>";
echo "Password: " . $password . "<br>"; echo "Password: " . $password . "<br>";
function cleanData($data) {
$data = strip_tags($data);
$data = htmlspecialchars($data);
$data = trim($data);
$data = stripslashes($data);
return $data;
}
?> ?>
</body> </body>
</html> </html>

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 02</title> <title>M2 | 06</title>
</head> </head>
<body> <body>
<form action="handle.php" method="post"> <form action="handle.php" method="post">

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 02</title> <title>M2 | 07</title>
</head> </head>
<body> <body>
<?php <?php

View File

@ -18,7 +18,7 @@ class User
return $this->password; return $this->password;
} }
public function saetUsername($username) { public function setUsername($username) {
$this->username = $username; $this->username = $username;
} }

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 08</title> <title>M2 | 08</title>
</head> </head>
<body> <body>
<form action="handle.php" method="post"> <form action="handle.php" method="post">

View File

@ -18,7 +18,7 @@ class User
return $this->password; return $this->password;
} }
public function saetUsername($username) { public function setUsername($username) {
$this->username = $username; $this->username = $username;
} }

View File

@ -31,6 +31,7 @@
exit(); exit();
} }
function cleanData($data) function cleanData($data)
{ {
$data = strip_tags($data); $data = strip_tags($data);

View File

@ -4,7 +4,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 08</title> <title>M2 | 09</title>
</head> </head>
<body> <body>

BIN
www/public/M3/01/bilder/bgImg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View 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 */

View File

@ -0,0 +1,4 @@
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>

View File

@ -0,0 +1,9 @@
<nav>
<ul style="display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; justify-items: stretch; text-decoration: none; font-size:1rem;">
<li><a href="">nav1</a></li>
<li><a href="">nav2</a></li>
<li><a href="">nav3</a></li>
<li><a href="">nav4</a></li>
</ul>
</nav>

View File

@ -0,0 +1,5 @@
<h1>Webbserverprogrammering 1 med Bygren</h1>
<?php
$date = date("Y-m-d");
echo "<time> $date </time>";
?>

View File

@ -0,0 +1,7 @@
<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>

View File

@ -0,0 +1,56 @@
<!doctype html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<title>Länka in med PHP</title>
<link href="css/styleSheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<header>
<?php include("inc/header.php"); ?>
</header>
<!-- header -->
<section id="leftColumn">
<nav>
<?php include("inc/meny.php"); ?>
</nav>
<aside>
<?php include("inc/aside.php"); ?>
</aside>
</section>
<!-- End leftColumn -->
<main>
<section>
<!-- Lägg in innehållet här -->
<?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');
}
?>
</section>
</main>
<!-- End main -->
<footer>
<?php include('inc/footer.php'); ?>
</footer>
<!-- End footer -->
</div>
<!-- End wrapper -->
</body>
</html>

View File

@ -0,0 +1,5 @@
<h1>My gallery</h1>
<p>*Photo*</p>
<p>*Photo*</p>
<p>*Photo*</p>
<p>*Photo*</p>

View File

@ -0,0 +1,9 @@
<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>

View File

@ -0,0 +1,4 @@
<h1>My contacts</h1>
<p>First contact</p>
<p>2nd contact</p>
<p>3rd contact</p>

View 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>

BIN
www/public/M3/02/bilder/bgImg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View 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 */

View File

@ -0,0 +1,4 @@
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>

View File

@ -0,0 +1,9 @@
<nav>
<ul style="display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; justify-items: stretch; text-decoration: none; font-size:1rem;">
<li><a href="">nav1</a></li>
<li><a href="">nav2</a></li>
<li><a href="">nav3</a></li>
<li><a href="">nav4</a></li>
</ul>
</nav>

View File

@ -0,0 +1,5 @@
<h1>Webbserverprogrammering 1 med Bygren</h1>
<?php
$date = date("Y-m-d");
echo "<time> $date </time>";
?>

View File

@ -0,0 +1,7 @@
<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>

View File

@ -0,0 +1,74 @@
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
else {
$_SESSION = array(); // Tömmer sessionsarrayen
session_destroy();
}
$hit = 0;
if(file_exists("../../../M3-02-hit.dat")) {
$hit = file_get_contents("../../../M3-02-hit.dat");
}
$hit++; // Ökar antalet besökare med 1
file_put_contents("../../../M3-02-hit.dat", $hit);
echo $hit;
?>
<!doctype html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<title>Länka in med PHP</title>
<link href="css/styleSheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<header>
<?php include("inc/header.php"); ?>
</header>
<!-- header -->
<section id="leftColumn">
<nav>
<?php include("inc/meny.php"); ?>
</nav>
<aside>
<?php include("inc/aside.php"); ?>
</aside>
</section>
<!-- End leftColumn -->
<main>
<section>
<!-- Lägg in innehållet här -->
<?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');
}
?>
</section>
</main>
<!-- End main -->
<footer>
<?php include('inc/footer.php'); ?>
</footer>
<!-- End footer -->
</div>
<!-- End wrapper -->
</body>
</html>

View File

@ -0,0 +1,5 @@
<h1>My gallery</h1>
<p>*Photo*</p>
<p>*Photo*</p>
<p>*Photo*</p>
<p>*Photo*</p>

View File

@ -0,0 +1,9 @@
<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>

View File

@ -0,0 +1,4 @@
<h1>My contacts</h1>
<p>First contact</p>
<p>2nd contact</p>
<p>3rd contact</p>

View 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>

BIN
www/public/M3/03/bilder/bgImg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View 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 */

View File

@ -0,0 +1,4 @@
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>

View File

@ -0,0 +1,9 @@
<nav>
<ul style="display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; justify-items: stretch; text-decoration: none; font-size:1rem;">
<li><a href="">nav1</a></li>
<li><a href="">nav2</a></li>
<li><a href="">nav3</a></li>
<li><a href="">nav4</a></li>
</ul>
</nav>

View File

@ -0,0 +1,5 @@
<h1>Webbserverprogrammering 1 med Bygren</h1>
<?php
$date = date("Y-m-d");
echo "<time> $date </time>";
?>

View File

@ -0,0 +1,8 @@
<h1>Innehåll</h1>
<ul>
<li><a href="index.php?page=start">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>
<li><a href="login.php">Account</a></li>
</ul>

106
www/public/M3/03/index.php Normal file
View File

@ -0,0 +1,106 @@
<?php
if (isset($_POST['login'])) login();
else if (isset($_POST['signup'])) login();
else if (isset($_POST['logout'])) logout();
else {
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
}
if (file_exists("../../../M3-03-hit.dat")) {
$hit = file_get_contents("../../../M3-03-hit.dat");
}
echo $hit;
function login()
{
if (session_status() == PHP_SESSION_NONE) {
session_start();
$_SESSION['logged_in'] = true;
$hit = 0;
if (file_exists("../../../M3-03-hit.dat")) {
$hit = file_get_contents("../../../M3-03-hit.dat");
}
$hit++; // Ökar antalet besökare med 1
file_put_contents("../../../M3-03-hit.dat", $hit);
}
}
function logout()
{
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$_POST = array();
$_SESSION = array(); // Tömmer sessionsarrayen
session_destroy();
}
?>
<!doctype html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<title>Länka in med PHP</title>
<link href="css/styleSheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<header>
<?php include("inc/header.php"); ?>
</header>
<!-- header -->
<section id="leftColumn">
<nav>
<?php include("inc/meny.php"); ?>
</nav>
<aside>
<?php include("inc/aside.php"); ?>
</aside>
</section>
<!-- End leftColumn -->
<?php
?>
<main>
<section>
<!-- Lägg in innehållet här -->
<?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');
}
?>
</section>
</main>
<!-- End main -->
<footer>
<?php include('inc/footer.php'); ?>
</footer>
<!-- End footer -->
</div>
<!-- End wrapper -->
</body>
</html>

View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
</head>
<body>
<form action="index.php" method="post">
<fieldset>
<legend>Login</legend>
<input type="hidden" name="login">
<label>Your username: </label>
<input type="text" name="username"> <br> <br>
<label>Your password: </label>
<input type="password" name="password"> <br> <br>
<input type="submit" value="Submit">
</fieldset>
</form>
<form action="index.php" method="post">
<fieldset>
<legend>Signup</legend>
<input type="hidden" name="signup">
<label>Your username: </label>
<input type="text" name="username"> <br> <br>
<label>Your password: </label>
<input type="password" name="password"> <br> <br>
<input type="submit" value="Submit">
</fieldset>
</form>
<br>
<br>
<form action="index.php" method="post">
<fieldset>
<legend>Logout</legend>
<input type="hidden" name="logout">
<input type="submit" value="Logout">
</fieldset>
</form>
</body>
</html>

View File

@ -0,0 +1,12 @@
<?php
if (!isset($_SESSION['logged_in'])) {
echo "<h1>No login </h1>";
}
else {
?>
<h1>My gallery</h1>
<p>*Photo*</p>
<p>*Photo*</p>
<p>*Photo*</p>
<p>*Photo*</p>
<?php } ?>

View File

@ -0,0 +1,16 @@
<?php
if (!isset($_SESSION['logged_in'])) {
echo "<h1>No login </h1>";
}
else {
?>
<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>
<?php } ?>

View File

@ -0,0 +1,11 @@
<?php
if (!isset($_SESSION['logged_in'])) {
echo "<h1>No login </h1>";
}
else {
?>
<h1>My contacts</h1>
<p>First contact</p>
<p>2nd contact</p>
<p>3rd contact</p>
<?php } ?>

View File

@ -0,0 +1,10 @@
<?php
if (!isset($_SESSION['logged_in'])) {
echo "<h1>No login </h1>";
}
else {
?>
<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>
<?php } ?>

BIN
www/public/M3/04/bilder/bgImg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View 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 */

View File

@ -0,0 +1,4 @@
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>

View File

@ -0,0 +1,9 @@
<nav>
<ul style="display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; justify-items: stretch; text-decoration: none; font-size:1rem;">
<li><a href="">nav1</a></li>
<li><a href="">nav2</a></li>
<li><a href="">nav3</a></li>
<li><a href="">nav4</a></li>
</ul>
</nav>

View File

@ -0,0 +1,5 @@
<h1>Webbserverprogrammering 1 med Bygren</h1>
<?php
$date = date("Y-m-d");
echo "<time> $date </time>";
?>

View File

@ -0,0 +1,13 @@
<h1>Innehåll</h1>
<ul>
<li><a href="index.php?page=start">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>
<?php
if (isset($_SESSION['logged_in'])) {
echo '<li><a href="index.php?page=klotter">Klotter</a></li>';
}
?>
<li><a href="login.php">Account</a></li>
</ul>

111
www/public/M3/04/index.php Normal file
View File

@ -0,0 +1,111 @@
<?php
if (isset($_POST['login'])) login();
else if (isset($_POST['signup'])) login();
else if (isset($_POST['logout'])) logout();
else {
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
#header("Location: login.php");
}
if (file_exists("../../../M3-04-hit.dat")) {
$hit = file_get_contents("../../../M3-04-hit.dat");
}
echo $hit;
function login()
{
if (session_status() == PHP_SESSION_NONE) {
session_start();
$_SESSION['logged_in'] = true;
$hit = 0;
if (file_exists("../../../M3-04-hit.dat")) {
$hit = file_get_contents("../../../M3-04-hit.dat");
}
$hit++; // Ökar antalet besökare med 1
file_put_contents("../../../M3-04-hit.dat", $hit);
}
}
function logout()
{
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$_POST = array();
$_SESSION = array(); // Tömmer sessionsarrayen
session_destroy();
#header("Location: login.php");
}
?>
<!doctype html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<title>Länka in med PHP</title>
<link href="css/styleSheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<header>
<?php include("inc/header.php"); ?>
</header>
<!-- header -->
<section id="leftColumn">
<nav>
<?php include("inc/meny.php"); ?>
</nav>
<aside>
<?php include("inc/aside.php"); ?>
</aside>
</section>
<!-- End leftColumn -->
<?php
?>
<main>
<section>
<!-- Lägg in innehållet här -->
<?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;
case 'klotter':
include('pages/klotter.php');
break;
default:
include('pages/start.php');
}
?>
</section>
</main>
<!-- End main -->
<footer>
<?php include('inc/footer.php'); ?>
</footer>
<!-- End footer -->
</div>
<!-- End wrapper -->
</body>
</html>

View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
</head>
<body>
<form action="index.php" method="post">
<fieldset>
<legend>Login</legend>
<input type="hidden" name="login">
<label>Your username: </label>
<input type="text" name="username"> <br> <br>
<label>Your password: </label>
<input type="password" name="password"> <br> <br>
<input type="submit" value="Submit">
</fieldset>
</form>
<form action="index.php" method="post">
<fieldset>
<legend>Signup</legend>
<input type="hidden" name="signup">
<label>Your username: </label>
<input type="text" name="username"> <br> <br>
<label>Your password: </label>
<input type="password" name="password"> <br> <br>
<input type="submit" value="Submit">
</fieldset>
</form>
<br>
<br>
<form action="index.php" method="post">
<fieldset>
<legend>Logout</legend>
<input type="hidden" name="logout">
<input type="submit" value="Logout">
</fieldset>
</form>
</body>
</html>

View File

@ -0,0 +1,12 @@
<?php
if (!isset($_SESSION['logged_in'])) {
echo "<h1>No login </h1>";
}
else {
?>
<h1>My gallery</h1>
<p>*Photo*</p>
<p>*Photo*</p>
<p>*Photo*</p>
<p>*Photo*</p>
<?php } ?>

View File

@ -0,0 +1,16 @@
<?php
if (!isset($_SESSION['logged_in'])) {
echo "<h1>No login </h1>";
}
else {
?>
<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>
<?php } ?>

View File

@ -0,0 +1,22 @@
<?php
if (!isset($_SESSION['logged_in'])) {
echo "<h1>No login </h1>";
}
else {
?>
<h1>Klotterplanket</h1>
<form action="saveMsg.php" method="post">
<label>Namn</label><br>
<input type="text" name="name"><br />
<label>Meddelande</label><br>
<textarea name="message" cols="45" rows="5"></textarea><br />
<input type="submit" value="Skicka">
</form>
<?php
if(file_exists("../../../M3-04-messages.dat")) {
echo file_get_contents("../../../M3-04-messages.dat");
}
}
?>

View File

@ -0,0 +1,11 @@
<?php
if (!isset($_SESSION['logged_in'])) {
echo "<h1>No login </h1>";
}
else {
?>
<h1>My contacts</h1>
<p>First contact</p>
<p>2nd contact</p>
<p>3rd contact</p>
<?php } ?>

View File

@ -0,0 +1,10 @@
<?php
if (!isset($_SESSION['logged_in'])) {
echo "<h1>No login </h1>";
}
else {
?>
<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>
<?php } ?>

View File

@ -0,0 +1,8 @@
<?php
$name = "<hr><p>Från: " . $_POST['name'] . "</p>";
$msg = "<p>" . $_POST['message'] . "</p>";
file_put_contents("../../../M3-04-messages.dat",$name.$msg,FILE_APPEND);
header("location: index.php?page=klotter"); //Omdirigerar till klotterplanket
?>

28
www/public/M3/06/User.php Normal file
View File

@ -0,0 +1,28 @@
<?php
class User
{
private $username;
private $password;
public function __construct($username, $password)
{
$this->username = $username;
$this->password = $password;
}
public function getUsername() {
return $this->username;
}
public function getPassword() {
return $this->password;
}
public function setUsername($username) {
$this->username = $username;
}
public function setPassword($password) {
$this->password = $password;
}
}

BIN
www/public/M3/06/bilder/bgImg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View 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 */

View File

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M3 06</title>
</head>
<body>
<?php
include("userManipulation.php");
if (isset($_POST["username"])) $username = $_POST["username"];
if (isset($_POST["password"])) $password = $_POST["password"];
$username = cleanData($username);
$user = new User($username, $password);
if (isset($_POST["login"])) {
if (isPresent($user)) {
echo "User: " . $user->getUsername();
echo "<br>Pass: " . $user->getPassword();
} else {
header("Location: index.php");
exit();
}
}
else if(isset($_POST["signup"])) {
addUser($user);
header("Location: index.php");
exit();
}
function cleanData($data)
{
$data = strip_tags($data);
$data = htmlspecialchars($data);
$data = trim($data);
$data = stripslashes($data);
return $data;
}
?>
</body>
</html>

View File

@ -0,0 +1,4 @@
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>
<li><a href="">Lorem ipsum dolor sit amet.</a></li>

View File

@ -0,0 +1,9 @@
<nav>
<ul style="display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; justify-items: stretch; text-decoration: none; font-size:1rem;">
<li><a href="">nav1</a></li>
<li><a href="">nav2</a></li>
<li><a href="">nav3</a></li>
<li><a href="">nav4</a></li>
</ul>
</nav>

View File

@ -0,0 +1,5 @@
<h1>Webbserverprogrammering 1 med Bygren</h1>
<?php
$date = date("Y-m-d");
echo "<time> $date </time>";
?>

View File

@ -0,0 +1,13 @@
<h1>Innehåll</h1>
<ul>
<li><a href="index.php?page=start">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>
<?php
if (isset($_SESSION['logged_in'])) {
echo '<li><a href="index.php?page=klotter">Klotter</a></li>';
}
?>
<li><a href="login.php">Account</a></li>
</ul>

153
www/public/M3/06/index.php Normal file
View File

@ -0,0 +1,153 @@
<?php
include("userManipulation.php");
if (isset($_POST['login'])) login();
else if (isset($_POST['signup'])) signup();
else if (isset($_POST['logout'])) logout();
else {
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
#header("Location: login.php");
}
if (file_exists("../../../M3-06-hit.dat")) {
$hit = file_get_contents("../../../M3-06-hit.dat");
echo $hit;
}
function login()
{
if (isset($_POST["username"])) $username = $_POST["username"];
if (isset($_POST["password"])) $password = $_POST["password"];
$username = cleanData($username);
$user = new User($username, $password);
if (!isPresent($user)) {
header("Location: login.php");
exit();
}
$_SESSION['logged_in'] = true;
}
function signup() {
if (isset($_POST["username"]) && $_POST["username"] != "") $username = $_POST["username"];
else {
header("Location: login.php");
exit();
}
if (isset($_POST["password"]) && $_POST["password"] != "") $password = $_POST["password"];
else {
header("Location: login.php");
exit();
}
$username = cleanData($username);
$user = new User($username, $password);
addUser($user);
incUserCount();
$_SESSION['logged_in'] = true;
}
function logout()
{
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$_POST = array();
$_SESSION = array(); // Tömmer sessionsarrayen
session_destroy();
#header("Location: login.php");
}
function incUserCount() {
if (session_status() == PHP_SESSION_NONE) {
session_start();
$hit = 0;
if (file_exists("../../../M3-06-hit.dat")) {
$hit = file_get_contents("../../../M3-06-hit.dat");
}
$hit++; // Ökar antalet besökare med 1
file_put_contents("../../../M3-06-hit.dat", $hit);
}
}
function cleanData($data)
{
$data = strip_tags($data);
$data = htmlspecialchars($data);
$data = trim($data);
$data = stripslashes($data);
return $data;
}
?>
<!doctype html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<title>Länka in med PHP</title>
<link href="css/styleSheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<header>
<?php include("inc/header.php"); ?>
</header>
<!-- header -->
<section id="leftColumn">
<nav>
<?php include("inc/meny.php"); ?>
</nav>
<aside>
<?php include("inc/aside.php"); ?>
</aside>
</section>
<!-- End leftColumn -->
<?php
?>
<main>
<section>
<!-- Lägg in innehållet här -->
<?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;
case 'klotter':
include('pages/klotter.php');
break;
default:
include('pages/start.php');
}
?>
</section>
</main>
<!-- End main -->
<footer>
<?php include('inc/footer.php'); ?>
</footer>
<!-- End footer -->
</div>
<!-- End wrapper -->
</body>
</html>

View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
</head>
<body>
<form action="index.php" method="post">
<fieldset>
<legend>Login</legend>
<input type="hidden" name="login">
<label>Your username: </label>
<input type="text" name="username"> <br> <br>
<label>Your password: </label>
<input type="password" name="password"> <br> <br>
<input type="submit" value="Submit">
</fieldset>
</form>
<form action="index.php" method="post">
<fieldset>
<legend>Signup</legend>
<input type="hidden" name="signup">
<label>Your username: </label>
<input type="text" name="username"> <br> <br>
<label>Your password: </label>
<input type="password" name="password"> <br> <br>
<input type="submit" value="Submit">
</fieldset>
</form>
<br>
<br>
<form action="index.php" method="post">
<fieldset>
<legend>Logout</legend>
<input type="hidden" name="logout">
<input type="submit" value="Logout">
</fieldset>
</form>
</body>
</html>

View File

@ -0,0 +1,12 @@
<?php
if (!isset($_SESSION['logged_in'])) {
echo "<h1>No login </h1>";
}
else {
?>
<h1>My gallery</h1>
<p>*Photo*</p>
<p>*Photo*</p>
<p>*Photo*</p>
<p>*Photo*</p>
<?php } ?>

View File

@ -0,0 +1,16 @@
<?php
if (!isset($_SESSION['logged_in'])) {
echo "<h1>No login </h1>";
}
else {
?>
<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>
<?php } ?>

View File

@ -0,0 +1,22 @@
<?php
if (!isset($_SESSION['logged_in'])) {
echo "<h1>No login </h1>";
}
else {
?>
<h1>Klotterplanket</h1>
<form action="saveMsg.php" method="post">
<label>Namn</label><br>
<input type="text" name="name"><br />
<label>Meddelande</label><br>
<textarea name="message" cols="45" rows="5"></textarea><br />
<input type="submit" value="Skicka">
</form>
<?php
if(file_exists("../../../M3-06-messages.dat")) {
echo file_get_contents("../../../M3-06-messages.dat");
}
}
?>

View File

@ -0,0 +1,11 @@
<?php
if (!isset($_SESSION['logged_in'])) {
echo "<h1>No login </h1>";
}
else {
?>
<h1>My contacts</h1>
<p>First contact</p>
<p>2nd contact</p>
<p>3rd contact</p>
<?php } ?>

View File

@ -0,0 +1,10 @@
<?php
if (!isset($_SESSION['logged_in'])) {
echo "<h1>No login </h1>";
}
else {
?>
<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>
<?php } ?>

View File

@ -0,0 +1,8 @@
<?php
$name = "<hr><p>Från: " . $_POST['name'] . "</p>";
$msg = "<p>" . $_POST['message'] . "</p>";
file_put_contents("../../../M3-06-messages.dat",$name.$msg,FILE_APPEND);
header("location: index.php?page=klotter"); //Omdirigerar till klotterplanket
?>

View File

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="se">
<head>
<meta charset="UTF-8">
<title>Person write</title>
</head>
<body>
<?php
include("User.php");
function addUser($user)
{
$file = "../../../M3-06-users.dat";
if(file_exists($file)) {
$users = unserialize(file_get_contents($file));
$users[] = $user;
file_put_contents($file, serialize($users));
}
else {
$users = array();
$users[] = $user;
file_put_contents($file, serialize($users));
}
}
function isPresent($userToFind)
{
$file = "../../../M3-06-users.dat";
if (file_exists($file)) {
$userArray = unserialize(file_get_contents($file));
}
else return false;
foreach($userArray as $user) {
if($userToFind->getUsername() == $user->getUsername() && $userToFind->getPassword() == $user->getPassword()) return true;
}
return false;
}
?>
</body>
</html>