diff --git a/www/M3-02-hit.dat b/www/M3-02-hit.dat index 8fdd954..31ff414 100644 --- a/www/M3-02-hit.dat +++ b/www/M3-02-hit.dat @@ -1 +1 @@ -22 \ No newline at end of file +48 \ No newline at end of file diff --git a/www/M3-03-hit.dat b/www/M3-03-hit.dat index 56a6051..bf0d87a 100644 --- a/www/M3-03-hit.dat +++ b/www/M3-03-hit.dat @@ -1 +1 @@ -1 \ No newline at end of file +4 \ No newline at end of file diff --git a/www/M3-04-hit.dat b/www/M3-04-hit.dat index bf0d87a..62f9457 100644 --- a/www/M3-04-hit.dat +++ b/www/M3-04-hit.dat @@ -1 +1 @@ -4 \ No newline at end of file +6 \ No newline at end of file diff --git a/www/M3-04-messages.dat b/www/M3-04-messages.dat index 8be9d17..bece204 100644 --- a/www/M3-04-messages.dat +++ b/www/M3-04-messages.dat @@ -1 +1,2 @@ -

Från: wreqtrthsr

reywtyret


Från: eargnkdsl

earsthy


Från: aeawwtsrthd

agdhsf


Från: argsdn

hsdtrj


Från: ewttr

rerew


Från: nklhio

hiohiohio


Från: jo

jijpnin


Från:

j


Från: joqoapre

dvbilgfb

\ No newline at end of file +

Från: wreqtrthsr

reywtyret


Från: eargnkdsl

earsthy


Från: aeawwtsrthd

agdhsf


Från: argsdn

hsdtrj


Från: ewttr

rerew


Från: nklhio

hiohiohio


Från: jo

jijpnin


Från:

j


Från: joqoapre

dvbilgfb


Från: 1234

testtest +


Från:
Vadym

dfsgdhsg

\ No newline at end of file diff --git a/www/M3-06-hit.dat b/www/M3-06-hit.dat index bf0d87a..301160a 100644 --- a/www/M3-06-hit.dat +++ b/www/M3-06-hit.dat @@ -1 +1 @@ -4 \ No newline at end of file +8 \ No newline at end of file diff --git a/www/M3-06-messages.dat b/www/M3-06-messages.dat new file mode 100644 index 0000000..5e6a3fd --- /dev/null +++ b/www/M3-06-messages.dat @@ -0,0 +1 @@ +

Från: 555

afsdgfh

\ No newline at end of file diff --git a/www/M3-06-users.dat b/www/M3-06-users.dat index e81d6ca..20dc8ca 100644 Binary files a/www/M3-06-users.dat and b/www/M3-06-users.dat differ diff --git a/www/M4-01-users.dat b/www/M4-01-users.dat new file mode 100644 index 0000000..b0f1c20 Binary files /dev/null and b/www/M4-01-users.dat differ diff --git a/www/public/M3/02/index.php b/www/public/M3/02/index.php index af38e30..8a2ede0 100644 --- a/www/public/M3/02/index.php +++ b/www/public/M3/02/index.php @@ -2,18 +2,14 @@ if (session_status() == PHP_SESSION_NONE) { session_start(); } - else { - $_SESSION = array(); // Tömmer sessionsarrayen - session_destroy(); - } - $hit = 0; - if(file_exists("../../../M3-02-hit.dat")) { - $hit = file_get_contents("../../../M3-02-hit.dat"); - } - $hit++; // Ökar antalet besökare med 1 - - file_put_contents("../../../M3-02-hit.dat", $hit); - echo $hit; + $hit = 0; + if(file_exists("../../../M3-02-hit.dat")) { + $hit = file_get_contents("../../../M3-02-hit.dat"); + } + $hit++; // Ökar antalet besökare med 1 + + file_put_contents("../../../M3-02-hit.dat", $hit); + echo $hit; ?> diff --git a/www/public/M3/06/handle.php b/www/public/M3/06/handle.php deleted file mode 100644 index b13fb48..0000000 --- a/www/public/M3/06/handle.php +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - M3 06 - - - - getUsername(); - echo "
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; - } - ?> - - - \ No newline at end of file diff --git a/www/public/M3/06/index.php b/www/public/M3/06/index.php index b5210a4..ec359ed 100644 --- a/www/public/M3/06/index.php +++ b/www/public/M3/06/index.php @@ -27,7 +27,12 @@ function login() 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"]; @@ -40,11 +45,14 @@ function signup() { 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() diff --git a/www/public/M3/06/pages/klotter.php b/www/public/M3/06/pages/klotter.php index 40affd2..2d6f3ce 100644 --- a/www/public/M3/06/pages/klotter.php +++ b/www/public/M3/06/pages/klotter.php @@ -1,16 +1,11 @@ -No login "; -} -else { -?>

Klotterplanket

-
-
- + Namn
'; + echo '
'; + ?>
-
+
@@ -18,5 +13,4 @@ else { if(file_exists("../../../M3-06-messages.dat")) { echo file_get_contents("../../../M3-06-messages.dat"); } -} - ?> \ No newline at end of file +?> \ No newline at end of file diff --git a/www/public/M3/06/saveMsg.php b/www/public/M3/06/saveMsg.php index eae70fc..f14b29b 100644 --- a/www/public/M3/06/saveMsg.php +++ b/www/public/M3/06/saveMsg.php @@ -1,8 +1,19 @@ -

Från: " . $_POST['name'] . "

"; - $msg = "

" . $_POST['message'] . "

"; - - file_put_contents("../../../M3-06-messages.dat",$name.$msg,FILE_APPEND); - - header("location: index.php?page=klotter"); //Omdirigerar till klotterplanket -?> \ No newline at end of file +

Från: " . $_SESSION['username'] . "

"; + $msg = "

" . cleanData($_POST['message']) . "

"; + + file_put_contents("../../../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; +} diff --git a/www/public/M4/01/User.php b/www/public/M4/01/User.php new file mode 100644 index 0000000..afa0130 --- /dev/null +++ b/www/public/M4/01/User.php @@ -0,0 +1,28 @@ +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; + } +} diff --git a/www/public/M4/01/index.php b/www/public/M4/01/index.php new file mode 100644 index 0000000..ad26309 --- /dev/null +++ b/www/public/M4/01/index.php @@ -0,0 +1,94 @@ + + + + + + + M4 | 01 + + + + +
+ Logged in!"; + } + else { + echo "

Not logged in!

"; + } + ?> + Login +
+ + + \ No newline at end of file diff --git a/www/public/M4/01/login.php b/www/public/M4/01/login.php new file mode 100644 index 0000000..c367978 --- /dev/null +++ b/www/public/M4/01/login.php @@ -0,0 +1,44 @@ + + + + + + Login + + +
+
+ Login + + +

+ +

+ +
+
+ +
+
+ Signup + + +

+ +

+ +
+
+ +
+
+ +
+
+ Logout + + +
+
+ + \ No newline at end of file diff --git a/www/public/M4/01/userManipulation.php b/www/public/M4/01/userManipulation.php new file mode 100644 index 0000000..7dacf2d --- /dev/null +++ b/www/public/M4/01/userManipulation.php @@ -0,0 +1,47 @@ + + + + + + Person write + + + + + getUsername() == $user->getUsername() && password_verify($userToFind->getPassword(), $user->getPassword())) return true; + } + return false; + } + ?> + + + \ No newline at end of file diff --git a/www/public/M4/02/User.php b/www/public/M4/02/User.php new file mode 100644 index 0000000..afa0130 --- /dev/null +++ b/www/public/M4/02/User.php @@ -0,0 +1,28 @@ +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; + } +} diff --git a/www/public/M4/02/index.php b/www/public/M4/02/index.php new file mode 100644 index 0000000..ad26309 --- /dev/null +++ b/www/public/M4/02/index.php @@ -0,0 +1,94 @@ + + + + + + + M4 | 01 + + + + +
+ Logged in!"; + } + else { + echo "

Not logged in!

"; + } + ?> + Login +
+ + + \ No newline at end of file diff --git a/www/public/M4/02/login.php b/www/public/M4/02/login.php new file mode 100644 index 0000000..c367978 --- /dev/null +++ b/www/public/M4/02/login.php @@ -0,0 +1,44 @@ + + + + + + Login + + +
+
+ Login + + +

+ +

+ +
+
+ +
+
+ Signup + + +

+ +

+ +
+
+ +
+
+ +
+
+ Logout + + +
+
+ + \ No newline at end of file diff --git a/www/public/M4/02/userManipulation.php b/www/public/M4/02/userManipulation.php new file mode 100644 index 0000000..f83d150 --- /dev/null +++ b/www/public/M4/02/userManipulation.php @@ -0,0 +1,47 @@ + + + + + + Person write + + + + + getUsername() == $user->getUsername() && password_verify($userToFind->getPassword(), $user->getPassword())) return true; + } + return false; + } + ?> + + + \ No newline at end of file