From 1a34e3e93b6076e6a070a70c61f2533f37374818 Mon Sep 17 00:00:00 2001 From: vadym Novoselskyi Date: Fri, 30 Aug 2024 15:43:26 +0200 Subject: [PATCH] add M2 --- www/M2-09-users.dat | Bin 0 -> 354 bytes www/public/M2/05/handle.php | 31 +++++++---- www/public/M2/06/handle.php | 34 ++++++++++++ www/public/M2/06/index.php | 24 ++++++++ www/public/M2/07/index.php | 55 +++++++++++++++++++ www/public/M2/{05/Person.php => 08/User.php} | 25 +++------ www/public/M2/08/handle.php | 27 +++++++++ www/public/M2/08/index.php | 20 +++++++ www/public/M2/09/User.php | 28 ++++++++++ www/public/M2/09/handle.php | 45 +++++++++++++++ www/public/M2/09/index.php | 39 +++++++++++++ www/public/M2/09/userManipulation.php | 47 ++++++++++++++++ 12 files changed, 347 insertions(+), 28 deletions(-) create mode 100644 www/M2-09-users.dat create mode 100644 www/public/M2/06/handle.php create mode 100644 www/public/M2/06/index.php create mode 100644 www/public/M2/07/index.php rename www/public/M2/{05/Person.php => 08/User.php} (53%) create mode 100644 www/public/M2/08/handle.php create mode 100644 www/public/M2/08/index.php create mode 100644 www/public/M2/09/User.php create mode 100644 www/public/M2/09/handle.php create mode 100644 www/public/M2/09/index.php create mode 100644 www/public/M2/09/userManipulation.php diff --git a/www/M2-09-users.dat b/www/M2-09-users.dat new file mode 100644 index 0000000000000000000000000000000000000000..ed6109874e02ac170f3d66637da054204f057577 GIT binary patch literal 354 zcmYeaGO?=8v@)>v2QrjGi&Kk~tc(ZSTm}%Ip%h5uCFZ6oSr=QGLev<7*a#H` ziN(d``9&!pQ41@j064cc)5?%YlVP^wG#IGB(8$zQkjd}xj<7* dO^r>#rWzAzsyQSOEG;c@n`>;P1eUL@1pp8GXy^a{ literal 0 HcmV?d00001 diff --git a/www/public/M2/05/handle.php b/www/public/M2/05/handle.php index 0cffec9..35f0211 100644 --- a/www/public/M2/05/handle.php +++ b/www/public/M2/05/handle.php @@ -12,23 +12,30 @@ 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); + $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 . "
"; echo "Surname: " . $surname . "
"; echo "Username: " . $username . "
"; echo "Password: " . $password . "
"; - - 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/M2/06/handle.php b/www/public/M2/06/handle.php new file mode 100644 index 0000000..0cffec9 --- /dev/null +++ b/www/public/M2/06/handle.php @@ -0,0 +1,34 @@ + + + + + + M2 05 + + + "; + echo "Surname: " . $surname . "
"; + echo "Username: " . $username . "
"; + echo "Password: " . $password . "
"; + + 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/M2/06/index.php b/www/public/M2/06/index.php new file mode 100644 index 0000000..8cf6914 --- /dev/null +++ b/www/public/M2/06/index.php @@ -0,0 +1,24 @@ + + + + + + M2 02 + + +
+
+ Login + + + +

+ + + + + +
+
+ + \ No newline at end of file diff --git a/www/public/M2/07/index.php b/www/public/M2/07/index.php new file mode 100644 index 0000000..67f7ef7 --- /dev/null +++ b/www/public/M2/07/index.php @@ -0,0 +1,55 @@ + + + + + + M2 02 + + +"; + echo "Surname: " . $surname . "
"; + echo "Username: " . $username . "
"; + echo "Password: " . $password . "
"; +} + function cleanData($data) { + $data = strip_tags($data); + $data = htmlspecialchars($data); + $data = trim($data); + $data = stripslashes($data); + return $data; + } + + ?> + + + + + +
+
+ Login + + + +

+ + + + + +
+
+ + \ No newline at end of file diff --git a/www/public/M2/05/Person.php b/www/public/M2/08/User.php similarity index 53% rename from www/public/M2/05/Person.php rename to www/public/M2/08/User.php index 8705b26..e1152c1 100644 --- a/www/public/M2/05/Person.php +++ b/www/public/M2/08/User.php @@ -1,26 +1,15 @@ name = $name; - $this->surname = $surname; + public function __construct($username, $password) + { $this->username = $username; $this->password = $password; } - public function getName() { - return $this->name; - } - - public function getSurname() { - return $this->surname; - } - public function getUsername() { return $this->username; } @@ -29,7 +18,11 @@ class Person { return $this->password; } + public function saetUsername($username) { + $this->username = $username; + } + public function setPassword($password) { $this->password = $password; } -} \ No newline at end of file +} diff --git a/www/public/M2/08/handle.php b/www/public/M2/08/handle.php new file mode 100644 index 0000000..7263a1c --- /dev/null +++ b/www/public/M2/08/handle.php @@ -0,0 +1,27 @@ + + + + + + M2 08 + + + getUsername(); + + 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/M2/08/index.php b/www/public/M2/08/index.php new file mode 100644 index 0000000..ab51959 --- /dev/null +++ b/www/public/M2/08/index.php @@ -0,0 +1,20 @@ + + + + + + M2 08 + + +
+
+ Login + +

+ +

+ +
+
+ + \ No newline at end of file diff --git a/www/public/M2/09/User.php b/www/public/M2/09/User.php new file mode 100644 index 0000000..e1152c1 --- /dev/null +++ b/www/public/M2/09/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 saetUsername($username) { + $this->username = $username; + } + + public function setPassword($password) { + $this->password = $password; + } +} diff --git a/www/public/M2/09/handle.php b/www/public/M2/09/handle.php new file mode 100644 index 0000000..bb4efa3 --- /dev/null +++ b/www/public/M2/09/handle.php @@ -0,0 +1,45 @@ + + + + + + + M2 08 + + + + 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/M2/09/index.php b/www/public/M2/09/index.php new file mode 100644 index 0000000..c8362ee --- /dev/null +++ b/www/public/M2/09/index.php @@ -0,0 +1,39 @@ + + + + + + + M2 08 + + + +
+
+ Login + + +

+ +

+ +
+
+ +
+
+
+ +
+
+ Signup + + +

+ +

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