Passed
Push — Security_and_bug_fixes ( cd248f )
by Stone
04:41 queued 26s
created
App/Models/UserModel.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
         //check if email is valid for sanity
193 193
         if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
194 194
             $email = htmlspecialchars($email);
195
-            throw new BlogocException("invalid email " . $email);
195
+            throw new BlogocException("invalid email ".$email);
196 196
         }
197 197
         $sql = $this->baseSqlSelect();
198 198
         $sql .= "
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
         $this->bind(':roles_idroles', 1); //we set to one, should probably get from database and config
236 236
         $this->execute();
237 237
 
238
-        return (int)$this->dbh->lastInsertId();
238
+        return (int) $this->dbh->lastInsertId();
239 239
     }
240 240
 
241 241
     /**
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
      */
246 246
     public function updateUser(\stdClass $user):void
247 247
     {
248
-        $sql="
248
+        $sql = "
249 249
             UPDATE $this->userTbl
250 250
             SET
251 251
               name=:name,
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
         }
297 297
 
298 298
         if ($this->isAccountPasswordBlocked($user)) {
299
-            $response->message = "too many bad passwords, account is blocked for " . Constant::LOCKOUT_MINUTES . " minutes";
299
+            $response->message = "too many bad passwords, account is blocked for ".Constant::LOCKOUT_MINUTES." minutes";
300 300
             return $response;
301 301
         }
302 302
 
Please login to merge, or discard this patch.
App/Controllers/Login.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     private function populateUserFromId(int $userId)
75 75
     {
76 76
         $result = $this->userModel->getUserDetailsById($userId);
77
-        $this->populateUser((array)$result);
77
+        $this->populateUser((array) $result);
78 78
     }
79 79
 
80 80
     /**
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
         //we are authenticated here
198 198
 
199 199
         //populate the user object with returned data
200
-        $this->populateUser((array)$authUser->user);
200
+        $this->populateUser((array) $authUser->user);
201 201
 
202 202
         //if the user wanted to be remembered
203 203
         if ($rememberMe) {
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
         $register = $this->request->getDataFull();
227 227
 
228
-        if($register === null)
228
+        if ($register === null)
229 229
         {
230 230
             throw new \Exception("Error no data passed");
231 231
         }
Please login to merge, or discard this patch.
App/Controllers/Ajax/Comment.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
     {
25 25
         $this->onlyAdmin();
26 26
         $this->onlyPost();
27
-        $state = (bool)($this->request->getData("state") === 'true');
28
-        $commentId = (int)$this->request->getData("commentId");
27
+        $state = (bool) ($this->request->getData("state") === 'true');
28
+        $commentId = (int) $this->request->getData("commentId");
29 29
 
30 30
         $result = array();
31 31
         $result["success"] = $this->commentModel->setApproved(!$state, $commentId);
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 
37 37
     public function loadComments()
38 38
     {
39
-        $commentOffset = (int)$this->request->getData("commentOffset");
40
-        $postId = (int)$this->request->getData("postId");
39
+        $commentOffset = (int) $this->request->getData("commentOffset");
40
+        $postId = (int) $this->request->getData("postId");
41 41
 
42 42
         $result = array();
43 43
         $result["success"] = false;
Please login to merge, or discard this patch.
App/Modules/Slug.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 use Cocur\Slugify\Slugify;
6 6
 use Core\Modules\Module;
7 7
 
8
-class Slug extends Module{
8
+class Slug extends Module {
9 9
     public function isSlugValid(string $slug):bool
10 10
     {
11 11
         $slugify = new Slugify();
Please login to merge, or discard this patch.
App/Controllers/Ajax/PostVerification.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
         $this->onlyPost();
33 33
 
34 34
         $postSlug = $this->request->getData("postSlug");
35
-        $postId = (int)$this->request->getData("postId");
35
+        $postId = (int) $this->request->getData("postId");
36 36
 
37 37
         $data = false;
38 38
         if (!$this->slug->isSlugValid($postSlug)) {
Please login to merge, or discard this patch.
App/Controllers/Post.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
     public function viewPost(string $slug, string $page = "page-1", int $linesPerPage = Constant::COMMENTS_PER_PAGE)
43 43
     {
44 44
 
45
-        $postId = (int)$this->postModel->getPostIdFromSlug($slug);
45
+        $postId = (int) $this->postModel->getPostIdFromSlug($slug);
46 46
 
47 47
         $posts = $this->postModel->getSinglePost($postId);
48 48
 
49
-        if($posts === false)
49
+        if ($posts === false)
50 50
         {
51 51
             throw new \Exception("Page no longer exists", "404");
52 52
         }
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
         $this->onlyUser();
90 90
 
91 91
         //get the session userId
92
-        $userId = (int)$this->session->get("userId");
93
-        $comment = (string)$this->request->getData("newComment");
94
-        $postId = (int)$this->request->getData("postId");
92
+        $userId = (int) $this->session->get("userId");
93
+        $comment = (string) $this->request->getData("newComment");
94
+        $postId = (int) $this->request->getData("postId");
95 95
 
96 96
         //check if we are admin, Admins do not need moderation
97 97
         $admin = $this->session->get('user_role_level') >= Constant::ADMIN_LEVEL;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
             $post = $this->postModel->getSinglePost($postId);
104 104
             $baseUrl = $this->request->getBaseUrl();
105 105
 
106
-            $emailMessage = "<h1>New comment on post " . $post->title . "</a></h1>";
107
-            $emailMessage .= "<p>Check it out <a href='" . $baseUrl . "admin/comments/moderate-comment/" . $commentId . "'>here</a> </p>";
106
+            $emailMessage = "<h1>New comment on post ".$post->title."</a></h1>";
107
+            $emailMessage .= "<p>Check it out <a href='".$baseUrl."admin/comments/moderate-comment/".$commentId."'>here</a> </p>";
108 108
 
109 109
             $this->sendMail->send($siteConfig["admin_email_address"], "New comment added", $emailMessage);
110 110
 
@@ -113,6 +113,6 @@  discard block
 block discarded – undo
113 113
 
114 114
         $postSlug = $this->postModel->getPostSlugFromId($postId);
115 115
 
116
-        $this->response->redirect("/post/view-post/" . $postSlug);
116
+        $this->response->redirect("/post/view-post/".$postSlug);
117 117
     }
118 118
 }
119 119
\ No newline at end of file
Please login to merge, or discard this patch.
App/Controllers/Admin/Post.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         $this->onlyPost();
118 118
 
119 119
         $posts = $this->request->getDataFull();
120
-        $userSessionId = (int)$this->session->get("userId");
120
+        $userSessionId = (int) $this->session->get("userId");
121 121
 
122 122
 
123 123
         $title = trim($posts["postTitle"]);
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 
164 164
         //checking result and redirecting
165 165
         if ($postId != null) {
166
-            $this->alertBox->setAlert("Post " . $title . " Created");
167
-            $this->container->getResponse()->redirect("admin/post/modify/" . $postSlug);
166
+            $this->alertBox->setAlert("Post ".$title." Created");
167
+            $this->container->getResponse()->redirect("admin/post/modify/".$postSlug);
168 168
         }
169
-        $this->alertBox->setAlert("Error creating " . $title, "error");
169
+        $this->alertBox->setAlert("Error creating ".$title, "error");
170 170
         $this->container->getResponse()->redirect("admin/post/new");
171 171
 
172 172
     }
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 
232 232
         //checking result and redirecting
233 233
         if ($postUpdate) {
234
-            $this->alertBox->setAlert("Post " . $title . " Updated");
235
-            $this->container->getResponse()->redirect("admin/post/modify/" . $postSlug);
234
+            $this->alertBox->setAlert("Post ".$title." Updated");
235
+            $this->container->getResponse()->redirect("admin/post/modify/".$postSlug);
236 236
         }
237
-        $this->alertBox->setAlert("Error updating " . $title, "error");
238
-        $this->container->getResponse()->redirect("admin/post/modify/" . $originalPostSlug);
237
+        $this->alertBox->setAlert("Error updating ".$title, "error");
238
+        $this->container->getResponse()->redirect("admin/post/modify/".$originalPostSlug);
239 239
     }
240 240
 
241 241
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         $removedPost = $this->postModel->deletePost($postId);
253 253
 
254 254
         if ($removedPost) {
255
-            $this->alertBox->setAlert("Post " . $postTitle . " deleted");
255
+            $this->alertBox->setAlert("Post ".$postTitle." deleted");
256 256
         }
257 257
 
258 258
         $this->response->redirect("admin/post/list/");
Please login to merge, or discard this patch.
App/Controllers/Admin/Home.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         $this->session->remove("registrationErrors");
52 52
 
53 53
         $userId = $this->session->get("userId");
54
-        if($userId === null)
54
+        if ($userId === null)
55 55
         {
56 56
             //this should never happen but scrutinizer thows an alert
57 57
             throw new \Exception("Session error, no ID");
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
         $userDetails = $this->userModel->getUserDetailsById($userId);
61 61
 
62
-        if($userDetails === false)
62
+        if ($userDetails === false)
63 63
         {
64 64
             //the user is still logged in his session but deleted from the DB.
65 65
             $this->cookie->deleteCookie("rememberMe");
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
         $this->onlyUser();
115 115
         $this->onlyPost();
116 116
 
117
-        $user = (object)$this->request->getDataFull();
117
+        $user = (object) $this->request->getDataFull();
118 118
         $redirectUrl = "/admin";
119 119
 
120 120
         if ($user->userId !== $this->session->get("userId") || isset($user->userRoleSelector) || isset($user->locked_out)) {
121 121
             //an admin is trying to update a user or form tampered with
122 122
             $this->onlyAdmin();
123
-            $redirectUrl = "/admin/home/view-user/" . $user->userId;
124
-        } else {
123
+            $redirectUrl = "/admin/home/view-user/".$user->userId;
124
+        }else {
125 125
             //set the role to the original state for update
126 126
             $beforeUser = $this->userModel->getUserDetailsById($user->userId);
127 127
             $user->userRoleSelector = $beforeUser->roles_idroles;
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
         $error = false;
136 136
         $registerErrors = new \stdClass();
137 137
 
138
-        if($userId == 1 && $user->userLockedOut == 1)
138
+        if ($userId == 1 && $user->userLockedOut == 1)
139 139
         {
140 140
             $error = true;
141 141
             $this->alertBox->setAlert("Original admin may not be deactivated", "error");
142 142
         }
143 143
 
144
-        if($userId == 1 && $user->userRoleSelector != 2)
144
+        if ($userId == 1 && $user->userRoleSelector != 2)
145 145
         {
146 146
             $error = true;
147 147
             $this->alertBox->setAlert("Original admin must stay admin", "error");
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
             throw new \Exception("Error in passed ID");
229 229
         }
230 230
 
231
-        if($userId === 1)
231
+        if ($userId === 1)
232 232
         {
233 233
             $this->alertBox->setAlert('Original Admin can not be deleted', "error");
234 234
             $this->response->redirect("/admin/home/list-users");
Please login to merge, or discard this patch.