diff --git a/App/Controllers/Home.php b/App/Controllers/Home.php
index 5217f5c..9440b77 100644
--- a/App/Controllers/Home.php
+++ b/App/Controllers/Home.php
@@ -69,7 +69,7 @@ class Home
foreach ($args as $value) {
if ($value == '') {
Session::flash('info', 'Semua data harus diisi.');
- Redirect::to('/');
+ Redirect::to('./register');
die();
}
}
@@ -88,7 +88,12 @@ class Home
$data = $this->model->showAll();
foreach ($data as $users) {
- if ($args['username'] == $users['username']) {
+ if (is_array($users)) {
+ $known_uname = $users['username'];
+ } else {
+ $known_uname = $data['username'];
+ }
+ if ($args['username'] == $known_uname) {
Session::flash('info', 'Username telah digunakan. Silahkan gunakan username lain.');
Redirect::to('./register');
die();
@@ -96,7 +101,7 @@ class Home
}
$this->model->entry($args);
-
+ Session::flash('info', 'Registrasi berhasil');
Redirect::to('/');
die();
}
@@ -109,7 +114,7 @@ class Home
$user = $this->model->showAll([
['username', '=', $username]
]);
-
+
if ($user == false) {
$info = "Username/password salah.";
} else {
@@ -142,6 +147,9 @@ class Home
public function delete()
{
+ if (Session::exists('userid') == false) {
+ throw new \Exception("Bad request but thrown as 404", 404);
+ }
$userid = Session::get('userid');
$user = $this->model->showAll([
diff --git a/App/Controllers/Posts.php b/App/Controllers/Posts.php
index a53f373..44fe10e 100644
--- a/App/Controllers/Posts.php
+++ b/App/Controllers/Posts.php
@@ -94,6 +94,11 @@ class Posts
$posts[] = $post;
}
+ // Replace \n or \r with
+ for ($i=0; $i < count($posts); $i++) {
+ $posts[$i]['content'] = preg_replace('/\r\n/', '
', $posts[$i]['content']);
+ }
+
View::render($url, [
'posts' => $posts,
'status' => $status
@@ -138,6 +143,8 @@ class Posts
$creator = $post['creator'];
$editor = $post['editor'];
+ $post['content'] = htmlspecialchars_decode($post['content']);
+
$table = 'users';
$creator = $this->model->showAll([
@@ -204,6 +211,8 @@ class Posts
}
}
+ $args['content'] = htmlspecialchars($args['content']);
+
if (isset($table)) {
if ($this->model->entry($args, $table)) {
Session::flash('info', 'Data berhasil diunggah.');
diff --git a/App/Views/Data/pengumuman.html b/App/Views/Data/pengumuman.html
index 4b05bb2..7bfa62e 100644
--- a/App/Views/Data/pengumuman.html
+++ b/App/Views/Data/pengumuman.html
@@ -22,7 +22,7 @@
(Nonaktif)
{% endif %}
{% endif %}
-
{{ post.content|raw }}
+{{ post.content | raw }}
{% endif %} {% endfor %}