Compare commits

..

No commits in common. "af1865776cdfb272eace4061cf4b9cb81579b94e" and "b703505447c3f4dc2e2f5380439904ab7c6a3814" have entirely different histories.

116 changed files with 12 additions and 3216 deletions

View File

@ -1,12 +1,7 @@
<!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>
<!doctype html>
<html>
<head lang="sv"></head>
<body>
<h1>Matematik-test</h1>
<form action="evaluate.php" method="post">
<fieldset>

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>M0 | 03</title>
<title>Responsiv webbdesign</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 | 01</title>
<title>M1-test</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 | 02</title>
<title>M1-test</title>
</head>
<body>
<form action="./handle.php" method="post">

View File

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

View File

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

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

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

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

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

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

View File

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

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

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

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

View File

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

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

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

View File

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

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

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

View File

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

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

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

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

View File

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

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

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

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

View File

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

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

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

View File

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

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

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

View File

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

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

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

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

View File

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

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

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

View File

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

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

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

View File

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

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

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

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

View File

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

View File

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

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

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

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

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

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

View File

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

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

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

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

View File

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

View File

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

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

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

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

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

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

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

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

View File

@ -1,28 +0,0 @@
<?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;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

View File

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

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

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

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

View File

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

View File

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

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

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

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

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

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

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

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

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

View File

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

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

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

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

View File

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

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

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

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

View File

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

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

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