Compare commits

..

5 Commits

Author SHA1 Message Date
af1865776c add m4 2/2 2024-09-13 14:56:16 +02:00
866c6b3731 add m4 part 1 2024-09-09 14:19:57 +02:00
d442c2facc add m3 2024-09-06 15:22:36 +02:00
1a34e3e93b add M2 2024-08-30 15:43:26 +02:00
546c1a36a8 add m2 1/2 2024-08-26 14:17:08 +02:00
116 changed files with 3216 additions and 12 deletions

View File

@ -1,6 +1,11 @@
<!doctype html>
<!DOCTYPE html>
<head>
<html>
<head lang="sv"></head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M0 | 01</title>
</html>
<body>
<h1>Matematik-test</h1>
<form action="evaluate.php" method="post">

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<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/gridCSS.css">
</head>

View File

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

View File

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

View File

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

View File

@ -28,7 +28,9 @@
else if($points >= 3) $result = "Godkänd";
else $result = "Läs på mer och försök igen";
//test
#test
/*test */
echo "<p>$result, poäng - $points</p>"
?>
</body>

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Result</title>
</head>
<body>
<?php
$name = strip_tags($_GET['name'], "<br>");
$age = strip_tags($_GET['age'], "<br>");
echo "<p>Name - $name; Age - $age</p>"
?>
</body>
</html>

View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 | 01</title>
</head>
<body>
<h1>Send data via url</h1>
<form action="handle.php" method="get">
<fieldset>
<legend>Person</legend>
<label>Name</label>
<input type="text" name="name">
<label>Age</label>
<input type="number" name="age">
<br>
<input type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 | 02</title>
</head>
<body>
<?php
for($i = 1; $i <= 5.0; $i += 0.1) {
echo " $i, ";
}
$i = 1;
echo "<br>";
while($i <= 5.0) {
echo " $i, ";
$i += 0.1;
}
?>
</body>
</html>

View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 | 03</title>
</head>
<body>
<?php
$page["head"] = "<h1>Välkommen</h1>";
$page["main"] = "<p>Detta är innehållet på min sida</p>";
$page["footer"] = "<hr><p>Min sidfoot</p>";
foreach($page as $value) {
echo $value;
}
?>
</body>
</html>

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 | 04</title>
</head>
<body>
<?php
include("math.php");
$num1 = 6;
$num2 = 3;
echo "Number 1 = $num1; Number 2 = $num2 <br>";
echo "Sum: " . sum($num1, $num2) . ". Difference: " .substract($num1, $num2) . ". Product: " . multiply($num1, $num2) . ". Division: " . divide($num1, $num2);
?>
</body>
</html>

18
www/public/M2/04/math.php Normal file
View File

@ -0,0 +1,18 @@
<?php
function sum($num1, $num2) {
return $num1 + $num2;
}
function substract($num1, $num2) {
return $num1 - $num2;
}
function multiply($num1, $num2) {
return $num1 * $num2;
}
function divide($num1, $num2) {
return $num1 / $num2;
}
?>

View File

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 05</title>
</head>
<body>
<?php
if(isset($_POST["name"])) $name = $_POST["name"];
if(isset($_POST["surname"])) $surname = $_POST["surname"];
if(isset($_POST["username"])) $username = $_POST["username"];
if(isset($_POST["password"])) $password = $_POST["password"];
$name = strip_tags($name);
$name = htmlspecialchars($name);
$name = trim($name);
$name = stripslashes($name);
$surname = strip_tags($surname);
$surname = htmlspecialchars($surname);
$surname = trim($surname);
$surname = stripslashes($surname);
$username = strip_tags($username);
$username = htmlspecialchars($username);
$username = trim($username);
$username = stripslashes($username);
$password = strip_tags($password);
$password = htmlspecialchars($password);
$password = trim($password);
$password = stripslashes($password);
echo "Name: " . $name . "<br>";
echo "Surname: " . $surname . "<br>";
echo "Username: " . $username . "<br>";
echo "Password: " . $password . "<br>";
?>
</body>
</html>

View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 | 05</title>
</head>
<body>
<form action="handle.php" method="post">
<fieldset >
<legend>Login</legend>
<label>Your name: </label>
<input type="text" name="name">
<label>Your surname: </label>
<input type="text" name="surname"> <br> <br>
<label>Your username: </label>
<input type="text" name="username">
<label>Your password: </label>
<input type="text" name="password">
<input type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>

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

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 05</title>
</head>
<body>
<?php
include("cleanData.php");
if(isset($_POST["name"])) $name = $_POST["name"];
if(isset($_POST["surname"])) $surname = $_POST["surname"];
if(isset($_POST["username"])) $username = $_POST["username"];
if(isset($_POST["password"])) $password = $_POST["password"];
$name = cleanData($name);
$surname = cleanData($surname);
$username = cleanData($username);
$password = cleanData($password);
echo "Name: " . $name . "<br>";
echo "Surname: " . $surname . "<br>";
echo "Username: " . $username . "<br>";
echo "Password: " . $password . "<br>";
?>
</body>
</html>

View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 | 06</title>
</head>
<body>
<form action="handle.php" method="post">
<fieldset >
<legend>Login</legend>
<label>Your name: </label>
<input type="text" name="name">
<label>Your surname: </label>
<input type="text" name="surname"> <br> <br>
<label>Your username: </label>
<input type="text" name="username">
<label>Your password: </label>
<input type="text" name="password">
<input type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>

View File

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 | 07</title>
</head>
<body>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
if(isset($_POST["name"])) $name = $_POST["name"];
if(isset($_POST["surname"])) $surname = $_POST["surname"];
if(isset($_POST["username"])) $username = $_POST["username"];
if(isset($_POST["password"])) $password = $_POST["password"];
$name = cleanData($name);
$surname = cleanData($surname);
$username = cleanData($username);
$password = cleanData($password);
echo "Name: " . $name . "<br>";
echo "Surname: " . $surname . "<br>";
echo "Username: " . $username . "<br>";
echo "Password: " . $password . "<br>";
}
function cleanData($data) {
$data = strip_tags($data);
$data = htmlspecialchars($data);
$data = trim($data);
$data = stripslashes($data);
return $data;
}
?>
<form action="" method="post">
<fieldset >
<legend>Login</legend>
<label>Your name: </label>
<input type="text" name="name">
<label>Your surname: </label>
<input type="text" name="surname"> <br> <br>
<label>Your username: </label>
<input type="text" name="username">
<label>Your password: </label>
<input type="text" name="password">
<input type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>

28
www/public/M2/08/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;
}
}

View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 08</title>
</head>
<body>
<?php
include("User.php");
if(isset($_POST["username"])) $username = $_POST["username"];
if(isset($_POST["password"])) $password = $_POST["password"];
$username = cleanData($username);
$newUser = new User($username, $password);
echo "Hello: " . $newUser->getUsername();
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,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 | 08</title>
</head>
<body>
<form action="handle.php" method="post">
<fieldset >
<legend>Login</legend>
<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>
</body>
</html>

28
www/public/M2/09/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;
}
}

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>M2 08</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,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 | 09</title>
</head>
<body>
<form action="handle.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>
<br>
<br>
<br>
<form action="handle.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>
</body>
</html>

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 = "../../../userData/M2-09-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 = "../../../userData/M2-09-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>

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,70 @@
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$hit = 0;
if(file_exists("../../../userCount/M3-02-hit.dat")) {
$hit = file_get_contents("../../../userCount/M3-02-hit.dat");
}
$hit++; // Ökar antalet besökare med 1
file_put_contents("../../../userCount/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("../../../userCount/M3-03-hit.dat")) {
$hit = file_get_contents("../../../userCount/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("../../../userCount/M3-03-hit.dat")) {
$hit = file_get_contents("../../../userCount/M3-03-hit.dat");
}
$hit++; // Ökar antalet besökare med 1
file_put_contents("../../../userCount/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("../../../userCount/M3-04-hit.dat")) {
$hit = file_get_contents("../../../userCount/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("../../../userCount/M3-04-hit.dat")) {
$hit = file_get_contents("../../../userCount/M3-04-hit.dat");
}
$hit++; // Ökar antalet besökare med 1
file_put_contents("../../../userCount/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("../../../userData/M3-04-messages.dat")) {
echo file_get_contents("../../../userData/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("../../../userData/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,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>

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

@ -0,0 +1,161 @@
<?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("../../../userCount/M3-06-hit.dat")) {
$hit = file_get_contents("../../../userCount/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();
}
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$_SESSION['logged_in'] = true;
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
}
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;
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
}
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("../../../userCount/M3-06-hit.dat")) {
$hit = file_get_contents("../../../userCount/M3-06-hit.dat");
}
$hit++; // Ökar antalet besökare med 1
file_put_contents("../../../userCount/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,16 @@
<h1>Klotterplanket</h1>
<form action="saveMsg.php" method="post">
<?php
echo '<label>Namn</label><br>';
echo '<input type="text" value="' . $_SESSION['username'] .'" disabled 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("../../../userData/M3-06-messages.dat")) {
echo file_get_contents("../../../userData/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,19 @@
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$name = "<hr><p>Från: " . $_SESSION['username'] . "</p>";
$msg = "<p>" . cleanData($_POST['message']) . "</p>";
file_put_contents("../../../userData/M3-06-messages.dat", $name . $msg, FILE_APPEND);
header("location: index.php?page=klotter"); //Omdirigerar till klotterplanket
function cleanData($data)
{
$data = strip_tags($data);
$data = htmlspecialchars($data);
$data = trim($data);
$data = stripslashes($data);
return $data;
}

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 = "../../../userData/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 = "../../../userData/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>

28
www/public/M4/01/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;
}
}

View File

@ -0,0 +1,94 @@
<?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");
}
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();
}
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$_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);
$password = password_hash($password, PASSWORD_DEFAULT);
$user = new User($username, $password);
addUser($user);
$_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 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>M4 | 01</title>
<link href="css/styleSheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<main>
<?php
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true) {
echo "<h1>Logged in!</h1>";
}
else {
echo "<h1>Not logged in!</h1>";
}
?>
<a href="login.php">Login</a>
</main>
</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,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 = "../../../userData/M4-01-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 = "../../../userData/M4-01-users.dat";
if (file_exists($file)) {
$userArray = unserialize(file_get_contents($file));
}
else return false;
foreach($userArray as $user) {
if($userToFind->getUsername() == $user->getUsername() && password_verify($userToFind->getPassword(), $user->getPassword())) return true;
}
return false;
}
?>
</body>
</html>

28
www/public/M4/02/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;
}
}

107
www/public/M4/02/index.php Normal file
View File

@ -0,0 +1,107 @@
<?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();
}
}
function login()
{
if (isset($_POST["username"])) $username = $_POST["username"];
if (isset($_POST["password"])) $password = $_POST["password"];
$username = filter_input(INPUT_POST, $username, FILTER_SANITIZE_SPECIAL_CHARS | FILTER_SANITIZE_STRIPPED);
$user = new User($username, $password);
if (!isPresent($user)) {
header("Location: login.php");
exit();
}
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
session_regenerate_id(true);
$_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 = filter_input(INPUT_POST, $username, FILTER_SANITIZE_SPECIAL_CHARS | FILTER_SANITIZE_STRIPPED);
$password = password_hash($password, PASSWORD_DEFAULT);
$user = new User($username, $password);
addUser($user);
$_SESSION['logged_in'] = true;
}
function logout()
{
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$_POST = array();
$_SESSION = array(); // Tömmer sessionsarrayen
session_regenerate_id(true);
}
?>
<!doctype html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<title>M4 | 02</title>
<link href="css/styleSheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<main>
<form action="" method="post">
<fieldset>
<legend>Form</legend>
<input type="hidden" name="message">
<label>Your name: </label>
<input type="text" name="name"> <br> <br>
<label>Your message: </label>
<input type="text" name="text"> <br> <br>
<input type="submit" value="Submit">
</fieldset>
</form>
<?php
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true) {
echo "<h1>Logged in!</h1>";
}
else {
echo "<h1>Not logged in!</h1>";
}
if(isset($_POST['message'])) {
$safeName = filter_input(INPUT_POST, 'name',FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$safeMassage = filter_input(INPUT_POST, 'text',FILTER_SANITIZE_FULL_SPECIAL_CHARS);
echo "<h3>Name - " . $safeName . "</h3>";
echo "<p>Massage - " . $safeMassage . "</p>";
}
else {
echo "<h3>No message!</h3>";
}
?>
<a href="login.php">Login</a>
</main>
</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,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 = "../../../userData/M4-02-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 = "../../../userData/M4-02-users.dat";
if (file_exists($file)) {
$userArray = unserialize(file_get_contents($file));
}
else return false;
foreach($userArray as $user) {
if($userToFind->getUsername() == $user->getUsername() && password_verify($userToFind->getPassword(), $user->getPassword())) return true;
}
return false;
}
?>
</body>
</html>

28
www/public/M4/03/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;
}
}

131
www/public/M4/03/index.php Normal file
View File

@ -0,0 +1,131 @@
<?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();
}
}
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();
}
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
session_regenerate_id(true);
$_SESSION['logged_in'] = true;
$_SESSION['CSRFToken'] = bin2hex(random_bytes(32));
}
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);
$password = password_hash($password, PASSWORD_DEFAULT);
$user = new User($username, $password);
addUser($user);
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
session_regenerate_id();
$_SESSION['logged_in'] = true;
$_SESSION['CSRFToken'] = bin2hex(random_bytes(32));
}
function logout()
{
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$_POST = array();
$_SESSION = array(); // Tömmer sessionsarrayen
session_regenerate_id(true);
$_SESSION['CSRFToken'] = bin2hex(random_bytes(32));
}
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>M4 | 03</title>
<link href="css/styleSheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<main>
<form action="" method="post">
<fieldset>
<legend>Form</legend>
<input type="hidden" name="message">
<input type = "hidden" name = "CSRFToken" value = <?php echo $_SESSION['CSRFToken']; ?>>
<label>Your name: </label>
<input type="text" name="name"> <br> <br>
<label>Your message: </label>
<input type="text" name="text"> <br> <br>
<input type="submit" value="Submit">
</fieldset>
</form>
<?php
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true) {
echo "<h1>Logged in!</h1>";
}
else {
echo "<h1>Not logged in!</h1>";
}
if(isset($_POST['message'])) {
if($_SESSION['CSRFToken'] === $_POST['CSRFToken']){
echo "ok csrft";
}else{
echo "Inte ok csrft";
}
$safeName = filter_input(INPUT_POST, 'name',FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$safeMassage = filter_input(INPUT_POST, 'text',FILTER_SANITIZE_FULL_SPECIAL_CHARS);
echo "<h3>Name - " . $safeName . "</h3>";
echo "<p>Massage - " . $safeMassage . "</p>";
}
else {
echo "<h3>No message!</h3>";
}
?>
<a href="login.php">Login</a>
</main>
</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>

Some files were not shown because too many files have changed in this diff Show More