Passed
Push — Auth ( 5ea92a...e2a482 )
by Stone
02:11
created
App/Controllers/Ajax/PostVerification.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,9 +36,11 @@
 block discarded – undo
36 36
 
37 37
         $data = $postModel->isPostSlugUnique($postSlug);
38 38
 
39
-        if ($data === false) //slug is not unique, but could be from the same post
39
+        if ($data === false) {
40
+            //slug is not unique, but could be from the same post
40 41
         {
41 42
             $slugOfId = $postModel->getPostSlugFromId($postId);
43
+        }
42 44
             if ($slugOfId === $postSlug) {
43 45
                 //it's the same post, return true
44 46
                 $data = true;
Please login to merge, or discard this patch.
Core/Modules/AlertBox.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
         //make sure we have the right type or throw an error
30 30
 
31 31
         if (!in_array($type, $this->allowedTypes)) {
32
-            throw new \Exception("Invalid toastr alert type " . $type);
32
+            throw new \Exception("Invalid toastr alert type ".$type);
33 33
         }
34 34
 
35 35
         $message = htmlspecialchars($message); //avoid any injection
Please login to merge, or discard this patch.
App/Controllers/Ajax/User.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use Core\JsonException;
9 9
 use Core\Traits\StringFunctions;
10 10
 
11
-class User  extends AjaxController{
11
+class User  extends AjaxController {
12 12
 
13 13
     use StringFunctions;
14 14
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         //the router needs a parameter with get functions else throsw a wobbly
26 26
         //we pass a get variable and call the /controller/function/get?bla
27 27
         //for better use and security, we must pass "get" as the parameter
28
-        if(!$this->startsWith(strtolower($get),"get"))
28
+        if (!$this->startsWith(strtolower($get), "get"))
29 29
         {
30 30
             throw new JsonException("invalid call");
31 31
         }
Please login to merge, or discard this patch.
Core/Controller.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
         $loadModuleObj = $this->getModuleNamespace($loadModule);
107 107
         //Modules must be children of the Module template
108 108
         if (!is_subclass_of($loadModuleObj, 'Core\Modules\Module')) {
109
-            throw new \ErrorException('Module ' . $loadModuleName . ' must be a sub class of module');
109
+            throw new \ErrorException('Module '.$loadModuleName.' must be a sub class of module');
110 110
         }
111 111
         $loadedModule = new $loadModuleObj($this->container);
112 112
         //we are not allowed to create public modules, they must be a placeholder ready
113 113
         if (!property_exists($this, $loadModuleName)) {
114
-            throw new \ErrorException('the protected or private variable of ' . $loadModuleName . ' is not present');
114
+            throw new \ErrorException('the protected or private variable of '.$loadModuleName.' is not present');
115 115
         }
116 116
         $this->$loadModuleName = $loadedModule;
117 117
     }
@@ -128,23 +128,23 @@  discard block
 block discarded – undo
128 128
         $childClass = new \ReflectionClass(get_class($this));
129 129
         $childClassNamespace = $childClass->getNamespaceName();
130 130
         //check in classNameSpace
131
-        if (class_exists($childClassNamespace . '\\Modules\\' . $loadModule)) {
132
-            $this->addToDevHelper('module ' . $loadModule . ' loaded', $childClassNamespace . '\\' . $loadModule);
133
-            return $childClassNamespace . '\\' . $loadModule;
131
+        if (class_exists($childClassNamespace.'\\Modules\\'.$loadModule)) {
132
+            $this->addToDevHelper('module '.$loadModule.' loaded', $childClassNamespace.'\\'.$loadModule);
133
+            return $childClassNamespace.'\\'.$loadModule;
134 134
         }
135 135
         //check in app
136
-        if (class_exists('App\\Modules\\' . $loadModule)) {
137
-            $this->addToDevHelper('module ' . $loadModule . ' loaded', 'App\\Modules\\' . $loadModule);
138
-            return 'App\\Modules\\' . $loadModule;
136
+        if (class_exists('App\\Modules\\'.$loadModule)) {
137
+            $this->addToDevHelper('module '.$loadModule.' loaded', 'App\\Modules\\'.$loadModule);
138
+            return 'App\\Modules\\'.$loadModule;
139 139
         }
140 140
         //check in core, send error popup if overcharged
141
-        if (class_exists('Core\\Modules\\' . $loadModule)) {
142
-            $this->addToDevHelper('module ' . $loadModule . ' loaded', 'Core\\Modules\\' . $loadModule);
143
-            return 'Core\\Modules\\' . $loadModule;
141
+        if (class_exists('Core\\Modules\\'.$loadModule)) {
142
+            $this->addToDevHelper('module '.$loadModule.' loaded', 'Core\\Modules\\'.$loadModule);
143
+            return 'Core\\Modules\\'.$loadModule;
144 144
         }
145 145
 
146 146
         //if we are here then no module found
147
-        throw new \ErrorException('module ' . $loadModule . ' does not exist or not loaded');
147
+        throw new \ErrorException('module '.$loadModule.' does not exist or not loaded');
148 148
 
149 149
     }
150 150
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     public function getView($template)
170 170
     {
171 171
         $twig = $this->container->getTemplate();
172
-        return $twig->render($template . '.twig', $this->data);
172
+        return $twig->render($template.'.twig', $this->data);
173 173
     }
174 174
 
175 175
     /**
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         }
196 196
 
197 197
         $twig = $this->container->getTemplate();
198
-        $twig->display($template . '.twig', $this->data);
198
+        $twig->display($template.'.twig', $this->data);
199 199
     }
200 200
 
201 201
     /**
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
     protected function addToDevHelper($name, $var)
228 228
     {
229 229
         //only populate if in dev environment
230
-        if (Config::DEV_ENVIRONMENT){
230
+        if (Config::DEV_ENVIRONMENT) {
231 231
             $classMethods = [];
232 232
             $classMethods[$name] = $var;
233 233
             if (!isset($this->data['dev_info'])) {
Please login to merge, or discard this patch.
App/Controllers/Ajax/postModification.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
         if (!$this->container->getRequest()->isPost()) {
29 29
             throw new \Core\JsonException('Call is not post');
30 30
         }
31
-        $state = (bool)($this->request->getData("state") === 'true');
32
-        $postId = (int)$this->request->getData("postId");
31
+        $state = (bool) ($this->request->getData("state") === 'true');
32
+        $postId = (int) $this->request->getData("postId");
33 33
 
34 34
         $result = array();
35 35
         $result["success"] = $this->postModule->setPublished(!$state, $postId);
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
         if (!$this->container->getRequest()->isPost()) {
49 49
             throw new \Core\JsonException('Call is not post');
50 50
         }
51
-        $state = (bool)($this->request->getData("state") === 'true'); //TODO test this element
52
-        $postId = (int)$this->request->getData("postId");
51
+        $state = (bool) ($this->request->getData("state") === 'true'); //TODO test this element
52
+        $postId = (int) $this->request->getData("postId");
53 53
 
54 54
         $result = array();
55 55
         $result["success"] = $this->postModule->setOnFrontPage(!$state, $postId);
Please login to merge, or discard this patch.
Core/Dependency/Session.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@
 block discarded – undo
92 92
      * return the entire session superglobal.
93 93
      * @return mixed
94 94
      */
95
-    public function getAllSessionVars(){
95
+    public function getAllSessionVars() {
96 96
         return $_SESSION;
97 97
     }
98 98
 
Please login to merge, or discard this patch.
App/Models/UserModel.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -157,12 +157,12 @@
 block discarded – undo
157 157
         return $this->getUserDetailsByEmail($email) !== false;
158 158
     }
159 159
 
160
-     /**
161
-     * register a new user
162
-     * @param \stdClass $userData
163
-     * @return int
164
-     * @throws \Exception
165
-     */
160
+        /**
161
+         * register a new user
162
+         * @param \stdClass $userData
163
+         * @return int
164
+         * @throws \Exception
165
+         */
166 166
     public function registerUser(\stdClass $userData): int
167 167
     {
168 168
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -200,9 +200,11 @@
 block discarded – undo
200 200
 
201 201
         $user = $this->getUserDetailsByEmail($email);
202 202
 
203
-        if($user === false) //no user exists
203
+        if($user === false) {
204
+            //no user exists
204 205
         {
205 206
             $response->message = "email doesn't exist, register a new account?";
207
+        }
206 208
             return $response;
207 209
         }
208 210
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
      */
56 56
     private function addToBadLoginTries($user):void
57 57
     {
58
-        $badLoginTries = $user->bad_login_tries +1;
59
-        $sql ="
58
+        $badLoginTries = $user->bad_login_tries + 1;
59
+        $sql = "
60 60
             UPDATE $this->userTbl
61 61
             SET
62 62
               bad_login_time = NOW(),
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     private function resetBadLogin($user):void
78 78
     {
79
-        $sql="
79
+        $sql = "
80 80
             UPDATE $this->userTbl
81 81
             SET
82 82
               bad_login_tries = 0
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
 
90 90
     private function isAccountPasswordBlocked($user)
91 91
     {
92
-        if($user->bad_login_tries < Constant::NUMBER_OF_BAD_PASSWORD_TRIES) {
92
+        if ($user->bad_login_tries < Constant::NUMBER_OF_BAD_PASSWORD_TRIES) {
93 93
             //not enough bad tries yet
94 94
             return false;
95 95
         }
96 96
 
97 97
         $blockTime = strtotime($user->bad_login_time);
98 98
         $currentTime = time();
99
-        if($currentTime-$blockTime > Constant::LOCKOUT_MINUTES*60)
99
+        if ($currentTime - $blockTime > Constant::LOCKOUT_MINUTES * 60)
100 100
         {
101 101
             //we have outlived the timeout, connection authorised
102 102
             return false;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         //check if email is valid for sanity
135 135
         if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
136 136
             $email = htmlspecialchars($email);
137
-            throw new BlogocException("invalid email " . $email);
137
+            throw new BlogocException("invalid email ".$email);
138 138
         }
139 139
         $sql = $this->baseSqlSelect();
140 140
         $sql .= "
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         $this->bind(':roles_idroles', 1);
183 183
         $this->execute();
184 184
 
185
-        return (int)$this->dbh->lastInsertId();
185
+        return (int) $this->dbh->lastInsertId();
186 186
     }
187 187
 
188 188
     /**
@@ -200,20 +200,20 @@  discard block
 block discarded – undo
200 200
 
201 201
         $user = $this->getUserDetailsByEmail($email);
202 202
 
203
-        if($user === false) //no user exists
203
+        if ($user === false) //no user exists
204 204
         {
205 205
             $response->message = "email doesn't exist, register a new account?";
206 206
             return $response;
207 207
         }
208 208
 
209 209
         //check if the user has validated his email
210
-        if($user->locked_out)
210
+        if ($user->locked_out)
211 211
         {
212 212
             $response->message = "the email has not been verified, please check your inbox or click on 'reset your password'";
213 213
             return $response;
214 214
         }
215 215
 
216
-        if($this->isAccountPasswordBlocked($user))
216
+        if ($this->isAccountPasswordBlocked($user))
217 217
         {
218 218
             $response->message = "too many bad passwords, account is blocked for ".Constant::LOCKOUT_MINUTES." minutes";
219 219
             return $response;
Please login to merge, or discard this patch.
Core/Constant.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     const POSTS_PER_PAGE = 4;
24 24
     const LIST_PER_PAGE = 10;
25 25
 
26
-    const EXCERPT_WORD_COUNT =50;
26
+    const EXCERPT_WORD_COUNT = 50;
27 27
 
28 28
     //login security
29 29
     const NUMBER_OF_BAD_PASSWORD_TRIES = 3;
Please login to merge, or discard this patch.
App/Controllers/Login.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
         // Create the Transport for mail sending
40 40
         $config = $this->siteConfig->getSiteConfig();
41
-        $this->transport = (new Swift_SmtpTransport($config["SMTP_server"], (int)$config["SMTP_port"]))
41
+        $this->transport = (new Swift_SmtpTransport($config["SMTP_server"], (int) $config["SMTP_port"]))
42 42
             ->setUsername($config["SMTP_user"])
43 43
             ->setPassword($config["SMTP_pass"])
44 44
         ;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     private function populateUserFromId(int $userId)
79 79
     {
80 80
         $result = $this->userModel->getUserDetailsById($userId);
81
-        $this->populateUser((array)$result);
81
+        $this->populateUser((array) $result);
82 82
     }
83 83
 
84 84
     /**
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function index()
101 101
     {
102
-        if($this->session->isParamSet("user"))
102
+        if ($this->session->isParamSet("user"))
103 103
         {
104 104
             //we are already connected, redirect
105 105
             $this->response->redirect();
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      */
129 129
     public function register()
130 130
     {
131
-        if($this->session->isParamSet("user"))
131
+        if ($this->session->isParamSet("user"))
132 132
         {
133 133
             //we are already connected, redirect
134 134
             $this->response->redirect();
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
             }
188 188
 
189 189
             $authUser = $this->userModel->authenticateUser($email, $password);
190
-            if(!$authUser->success)
190
+            if (!$authUser->success)
191 191
             {
192 192
                 $error = true;
193 193
                 $loginErrors->global = $authUser->message;
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         //we are authenticated here
207 207
 
208 208
         //populate the user object with returned data
209
-        $this->populateUser((array)$authUser->user);
209
+        $this->populateUser((array) $authUser->user);
210 210
         $this->setUserSession();
211 211
 
212 212
         //if all is valid, redirect to user admin page
Please login to merge, or discard this patch.