From 651399fba8df16a71e698a8174d51e4fc2274829 Mon Sep 17 00:00:00 2001 From: NichtJens Date: Fri, 25 Mar 2016 22:09:26 -0700 Subject: [PATCH 1/5] translated the interface to English --- User.php | 2 +- UserManager.php | 4 ++-- templates/403.phtml | 10 +++++----- templates/user/edit.phtml | 14 +++++++------- templates/user/index.phtml | 10 +++++----- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/User.php b/User.php index 7128493..6fa8559 100644 --- a/User.php +++ b/User.php @@ -50,7 +50,7 @@ public function getPassword() { */ public function setPassword($password) { if (empty($password)) - throw new Exception("Ein leeres Passwort ist nicht erlaubt."); + throw new Exception("No password supplied."); $this->_password = crypt($password, base64_encode($password)); } diff --git a/UserManager.php b/UserManager.php index ce3b55f..b41abe2 100644 --- a/UserManager.php +++ b/UserManager.php @@ -98,7 +98,7 @@ public function deleteUser(User $user) { */ public function addUser(User $user) { if ($this->userExists($user->getUsername())) - throw new Exception("Der Benutzer existiert bereits."); + throw new Exception("User exists already."); $this->users[$user->getUsername()] = $user; $this->changed = true; @@ -110,7 +110,7 @@ public function addUser(User $user) { */ public function updateUser(User $user) { if (!$this->userExists($user->getUsername())) - throw new Exception("Der Benutzer existiert nicht."); + throw new Exception("User does not exist."); $this->users[$user->getUsername()] = $user; $this->changed = true; diff --git a/templates/403.phtml b/templates/403.phtml index acf639f..95f04d4 100644 --- a/templates/403.phtml +++ b/templates/403.phtml @@ -9,9 +9,9 @@
@@ -21,7 +21,7 @@
-
Passwort wurde erfolgreich geändert.
+
Password changed successfully.
@@ -30,7 +30,7 @@

403

-

Zugriff verweigert

+

Access denied

- \ No newline at end of file + diff --git a/templates/user/edit.phtml b/templates/user/edit.phtml index 243ef4d..6b47356 100644 --- a/templates/user/edit.phtml +++ b/templates/user/edit.phtml @@ -9,19 +9,19 @@ -

Passwort ändern

+

Change your password

-
Passwort wurde erfolgreich geändert.
+
Password changed successfully.
@@ -31,12 +31,12 @@
?action=updatePassword" method="post">
- +
- +
- \ No newline at end of file + diff --git a/templates/user/index.phtml b/templates/user/index.phtml index 9ef884e..420f196 100644 --- a/templates/user/index.phtml +++ b/templates/user/index.phtml @@ -9,19 +9,19 @@ -

Benutzerübersicht

+

List of known users

-
Passwort wurde erfolgreich geändert.
+
Password changed successfully.
@@ -41,4 +41,4 @@
- \ No newline at end of file + From 36bd29ed47d72864b3f18839cec3c9ff3c818713 Mon Sep 17 00:00:00 2001 From: NichtJens Date: Fri, 25 Mar 2016 22:15:53 -0700 Subject: [PATCH 2/5] made /templates folder easily changeable, could be improved by adding it to config.php --- UserController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/UserController.php b/UserController.php index 7ec2083..da31e68 100644 --- a/UserController.php +++ b/UserController.php @@ -2,20 +2,22 @@ class UserController { + private $templates = "/templates"; + public function index() { global $userManager, $firewall; if ($firewall->hasUserAccess()) - include_once __DIR__ . "/templates/user/index.phtml"; + include_once __DIR__ . $this->templates . "/user/index.phtml"; else { header("HTTP/1.1 403 Forbidden"); - include_once __DIR__ . "/templates/403.phtml"; + include_once __DIR__ . $this->templates . "/403.phtml"; } } public function editPassword() { global $userManager, $firewall; - include_once __DIR__."/templates/user/edit.phtml"; + include_once __DIR__.$this->templates . "/user/edit.phtml"; } public function updatePassword() { @@ -37,7 +39,7 @@ public function updatePassword() { header("Location: {$_SERVER["SCRIPT_NAME"]}?action=changePassword&success=".(int)$success."&message=".urlencode($message)); } else { header("HTTP/1.1 403 Forbidden"); - include_once __DIR__ . "/templates/403.phtml"; + include_once __DIR__ . $this->templates . "/403.phtml"; } } } From cd1479dcdeedd912b16a75b413d43201e733c05e Mon Sep 17 00:00:00 2001 From: NichtJens Date: Sat, 26 Mar 2016 09:31:12 -0700 Subject: [PATCH 3/5] moved English version into /templatesEN --- UserController.php | 2 +- {templates => templatesEN}/403.phtml | 0 {templates => templatesEN}/user/edit.phtml | 0 {templates => templatesEN}/user/index.phtml | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename {templates => templatesEN}/403.phtml (100%) rename {templates => templatesEN}/user/edit.phtml (100%) rename {templates => templatesEN}/user/index.phtml (100%) diff --git a/UserController.php b/UserController.php index da31e68..503da18 100644 --- a/UserController.php +++ b/UserController.php @@ -2,7 +2,7 @@ class UserController { - private $templates = "/templates"; + private $templates = "/templatesEN"; public function index() { global $userManager, $firewall; diff --git a/templates/403.phtml b/templatesEN/403.phtml similarity index 100% rename from templates/403.phtml rename to templatesEN/403.phtml diff --git a/templates/user/edit.phtml b/templatesEN/user/edit.phtml similarity index 100% rename from templates/user/edit.phtml rename to templatesEN/user/edit.phtml diff --git a/templates/user/index.phtml b/templatesEN/user/index.phtml similarity index 100% rename from templates/user/index.phtml rename to templatesEN/user/index.phtml From c4d8bed6cc06b079ed3437866c8f3452cf14964f Mon Sep 17 00:00:00 2001 From: NichtJens Date: Sat, 26 Mar 2016 09:31:45 -0700 Subject: [PATCH 4/5] added back German version in /templatesDE --- templatesDE/403.phtml | 36 +++++++++++++++++++++++++++++ templatesDE/user/edit.phtml | 42 ++++++++++++++++++++++++++++++++++ templatesDE/user/index.phtml | 44 ++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 templatesDE/403.phtml create mode 100644 templatesDE/user/edit.phtml create mode 100644 templatesDE/user/index.phtml diff --git a/templatesDE/403.phtml b/templatesDE/403.phtml new file mode 100644 index 0000000..acf639f --- /dev/null +++ b/templatesDE/403.phtml @@ -0,0 +1,36 @@ + + + + + Administration + + + + + + +

Error 403

+ + +
+ +
Passwort wurde erfolgreich geändert.
+ +
+ +
+ + +
+

403

+

Zugriff verweigert

+
+ + \ No newline at end of file diff --git a/templatesDE/user/edit.phtml b/templatesDE/user/edit.phtml new file mode 100644 index 0000000..243ef4d --- /dev/null +++ b/templatesDE/user/edit.phtml @@ -0,0 +1,42 @@ + + + + + Administration + + + + + + +

Passwort ändern

+ + +
+ +
Passwort wurde erfolgreich geändert.
+ +
+ +
+ + +
+
?action=updatePassword" method="post"> +
+ + +
+ + +
+
+ + \ No newline at end of file diff --git a/templatesDE/user/index.phtml b/templatesDE/user/index.phtml new file mode 100644 index 0000000..9ef884e --- /dev/null +++ b/templatesDE/user/index.phtml @@ -0,0 +1,44 @@ + + + + + Administration + + + + + + +

Benutzerübersicht

+ + +
+ +
Passwort wurde erfolgreich geändert.
+ +
+ +
+ + +
+ + + + + getUsers() as $user) : ?> + + + + +
Username
getUsername() ?>
+
+ + \ No newline at end of file From 52950165f7e3007c23757e7925be1762c39dbf81 Mon Sep 17 00:00:00 2001 From: NichtJens Date: Mon, 28 Mar 2016 20:36:38 -0700 Subject: [PATCH 5/5] added password retype field to avoid typos becoming actual passwords --- UserController.php | 17 +++++++++++------ templatesDE/user/edit.phtml | 5 +++++ templatesEN/user/edit.phtml | 7 ++++++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/UserController.php b/UserController.php index 503da18..70b5670 100644 --- a/UserController.php +++ b/UserController.php @@ -27,12 +27,17 @@ public function updatePassword() { $message = ''; $success = false; - try { - $user = $userManager->getCurrentUser(); - $user->setPassword($_POST['password']); - $success = $userManager->updateUser($user); - } catch(Exception $e) { - $message = $e->getMessage(); + + if ($_POST['password'] !== $_POST['pwretype']) { + $message = 'Sorry, passwords do not match.'; + } else { + try { + $user = $userManager->getCurrentUser(); + $user->setPassword($_POST['password']); + $success = $userManager->updateUser($user); + } catch(Exception $e) { + $message = $e->getMessage(); + } } header("HTTP/1.1 303 See Other"); diff --git a/templatesDE/user/edit.phtml b/templatesDE/user/edit.phtml index 243ef4d..0d137f2 100644 --- a/templatesDE/user/edit.phtml +++ b/templatesDE/user/edit.phtml @@ -32,7 +32,12 @@
?action=updatePassword" method="post">
+
+
+ +
+
diff --git a/templatesEN/user/edit.phtml b/templatesEN/user/edit.phtml index 6b47356..38287bb 100644 --- a/templatesEN/user/edit.phtml +++ b/templatesEN/user/edit.phtml @@ -32,11 +32,16 @@ ?action=updatePassword" method="post">
+
+
+ +
+
- + \ No newline at end of file