Passed
Push — Auth ( 5fd30d...9fba6d )
by Stone
02:24
created
App/Models/Remembered_loginModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
     {
28 28
         if ($token_value) {
29 29
             $this->token = $token_value;
30
-        } else {
30
+        }else {
31 31
             $this->token = $this->generateToken();
32 32
         }
33 33
     }
Please login to merge, or discard this patch.
Core/Constant.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@
 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;
30 30
     const LOCKOUT_MINUTES = 5;
31 31
 
32
-    const PASSWORD_RESET_DURATION = 240;//number of minutes the reset password link is valid
32
+    const PASSWORD_RESET_DURATION = 240; //number of minutes the reset password link is valid
33 33
 
34 34
     const HASH_KEY = "1337blogOcPass159758348ShaQpiss";
35 35
 }
36 36
\ No newline at end of file
Please login to merge, or discard this patch.
Core/Controller.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -109,12 +109,12 @@  discard block
 block discarded – undo
109 109
         $loadModuleObj = $this->getModuleNamespace($loadModule);
110 110
         //Modules must be children of the Module template
111 111
         if (!is_subclass_of($loadModuleObj, 'Core\Modules\Module')) {
112
-            throw new \ErrorException('Module ' . $loadModuleName . ' must be a sub class of module');
112
+            throw new \ErrorException('Module '.$loadModuleName.' must be a sub class of module');
113 113
         }
114 114
         $loadedModule = new $loadModuleObj($this->container);
115 115
         //we are not allowed to create public modules, they must be a placeholder ready
116 116
         if (!property_exists($this, $loadModuleName)) {
117
-            throw new \ErrorException('the protected or private variable of ' . $loadModuleName . ' is not present');
117
+            throw new \ErrorException('the protected or private variable of '.$loadModuleName.' is not present');
118 118
         }
119 119
         $this->$loadModuleName = $loadedModule;
120 120
     }
@@ -131,23 +131,23 @@  discard block
 block discarded – undo
131 131
         $childClass = new \ReflectionClass(get_class($this));
132 132
         $childClassNamespace = $childClass->getNamespaceName();
133 133
         //check in classNameSpace
134
-        if (class_exists($childClassNamespace . '\\Modules\\' . $loadModule)) {
135
-            $this->addToDevHelper('module ' . $loadModule . ' loaded', $childClassNamespace . '\\' . $loadModule);
136
-            return $childClassNamespace . '\\' . $loadModule;
134
+        if (class_exists($childClassNamespace.'\\Modules\\'.$loadModule)) {
135
+            $this->addToDevHelper('module '.$loadModule.' loaded', $childClassNamespace.'\\'.$loadModule);
136
+            return $childClassNamespace.'\\'.$loadModule;
137 137
         }
138 138
         //check in app
139
-        if (class_exists('App\\Modules\\' . $loadModule)) {
140
-            $this->addToDevHelper('module ' . $loadModule . ' loaded', 'App\\Modules\\' . $loadModule);
141
-            return 'App\\Modules\\' . $loadModule;
139
+        if (class_exists('App\\Modules\\'.$loadModule)) {
140
+            $this->addToDevHelper('module '.$loadModule.' loaded', 'App\\Modules\\'.$loadModule);
141
+            return 'App\\Modules\\'.$loadModule;
142 142
         }
143 143
         //check in core, send error popup if overcharged
144
-        if (class_exists('Core\\Modules\\' . $loadModule)) {
145
-            $this->addToDevHelper('module ' . $loadModule . ' loaded', 'Core\\Modules\\' . $loadModule);
146
-            return 'Core\\Modules\\' . $loadModule;
144
+        if (class_exists('Core\\Modules\\'.$loadModule)) {
145
+            $this->addToDevHelper('module '.$loadModule.' loaded', 'Core\\Modules\\'.$loadModule);
146
+            return 'Core\\Modules\\'.$loadModule;
147 147
         }
148 148
 
149 149
         //if we are here then no module found
150
-        throw new \ErrorException('module ' . $loadModule . ' does not exist or not loaded');
150
+        throw new \ErrorException('module '.$loadModule.' does not exist or not loaded');
151 151
 
152 152
     }
153 153
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     public function getView($template)
173 173
     {
174 174
         $twig = $this->container->getTemplate();
175
-        return $twig->render($template . '.twig', $this->data);
175
+        return $twig->render($template.'.twig', $this->data);
176 176
     }
177 177
 
178 178
     /**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         }
199 199
 
200 200
         $twig = $this->container->getTemplate();
201
-        $twig->display($template . '.twig', $this->data);
201
+        $twig->display($template.'.twig', $this->data);
202 202
     }
203 203
 
204 204
     /**
Please login to merge, or discard this patch.
App/Modules/SendMail.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use Swift_Message;
9 9
 use Swift_SmtpTransport;
10 10
 
11
-class SendMail extends Module{
11
+class SendMail extends Module {
12 12
 
13 13
     private $siteConfig;
14 14
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
         // Create the Transport for mail sending
26 26
         //$config = $this->siteConfig->getSiteConfig();
27
-        $this->transport = (new Swift_SmtpTransport($this->siteConfig["SMTP_server"], (int)$this->siteConfig["SMTP_port"]))
27
+        $this->transport = (new Swift_SmtpTransport($this->siteConfig["SMTP_server"], (int) $this->siteConfig["SMTP_port"]))
28 28
             ->setUsername($this->siteConfig["SMTP_user"])
29 29
             ->setPassword($this->siteConfig["SMTP_pass"])
30 30
         ;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
         $message = "<a href=\"".$url."\">Define new password</a>";
68 68
 
69
-        $this->send($to, "Define Password", $message );
69
+        $this->send($to, "Define Password", $message);
70 70
 
71 71
     }
72 72
 }
73 73
\ No newline at end of file
Please login to merge, or discard this patch.
App/Controllers/Password.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     public function reset($get)
46 46
     {
47 47
         //only get messages here
48
-        if(!$this->startsWith(strtolower($get),"get"))
48
+        if (!$this->startsWith(strtolower($get), "get"))
49 49
         {
50 50
             throw new \Exception("invalid call");
51 51
         }
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
         $userId = $this->request->getData("userId");
56 56
 
57 57
         //verify if token is valid
58
-        if(!$this->isHexa($token)|| !$this->isInt($userId))
58
+        if (!$this->isHexa($token) || !$this->isInt($userId))
59 59
         {
60 60
             $this->alertBox->setAlert('Badly formatted Token', 'error');
61 61
             $this->response->redirect();
62 62
         }
63
-        if(!$this->userModel->getUserDetailsByToken($token, $userId))
63
+        if (!$this->userModel->getUserDetailsByToken($token, $userId))
64 64
         {
65 65
             $this->alertBox->setAlert('Invalid reset token, please request a new password', 'error');
66 66
             $this->response->redirect();
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
         $token = $request["token"];
84 84
         $userId = $request["userId"];
85 85
 
86
-        if(!$this->isHexa($token) || !$this->isInt($userId) )
86
+        if (!$this->isHexa($token) || !$this->isInt($userId))
87 87
         {
88 88
             throw new \Exception("Bad Token or ID request");
89 89
         }
90 90
 
91 91
         $error = false;
92 92
         $registerErrors = new \stdClass();
93
-        if($password !== $confirm)
93
+        if ($password !== $confirm)
94 94
         {
95 95
             $error = true;
96 96
             $registerErrors->forgotPassword = "password and confirmation do not match";
Please login to merge, or discard this patch.
App/Controllers/Login.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     private function populateUserFromId(int $userId)
77 77
     {
78 78
         $result = $this->userModel->getUserDetailsById($userId);
79
-        $this->populateUser((array)$result);
79
+        $this->populateUser((array) $result);
80 80
     }
81 81
 
82 82
     /**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function index()
99 99
     {
100
-        if($this->session->isParamSet("user"))
100
+        if ($this->session->isParamSet("user"))
101 101
         {
102 102
             //we are already connected, redirect
103 103
             $this->response->redirect();
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function register()
128 128
     {
129
-        if($this->session->isParamSet("user"))
129
+        if ($this->session->isParamSet("user"))
130 130
         {
131 131
             //we are already connected, redirect
132 132
             $this->response->redirect();
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             }
184 184
 
185 185
             $authUser = $this->userModel->authenticateUser($email, $password);
186
-            if(!$authUser->success)
186
+            if (!$authUser->success)
187 187
             {
188 188
                 $error = true;
189 189
                 $loginErrors->global = $authUser->message;
@@ -202,14 +202,14 @@  discard block
 block discarded – undo
202 202
         //we are authenticated here
203 203
 
204 204
         //populate the user object with returned data
205
-        $this->populateUser((array)$authUser->user);
205
+        $this->populateUser((array) $authUser->user);
206 206
 
207 207
         //if the user wanted to be remembered
208
-        if($rememberMe)
208
+        if ($rememberMe)
209 209
         {
210 210
             $this->rememberedLoginModel->setToken(); //generate a new token
211 211
             $rememberMeToken = $this->rememberedLoginModel->rememberMe($this->user->idusers);
212
-            if($rememberMeToken->success)
212
+            if ($rememberMeToken->success)
213 213
             {
214 214
                 //set cookie
215 215
                 $this->cookie->setCookie("rememberMe", $rememberMeToken->token, $rememberMeToken->expiry_timestamp);
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
         $baseUrl = $this->request->getBaseUrl();
293 293
         $redirectUrl = $this->removeFromBeginning($refererUrl, $baseUrl);
294 294
 
295
-        if($redirectUrl === "login/register")
295
+        if ($redirectUrl === "login/register")
296 296
         {
297 297
             //if we were already on the register page, go to home page
298
-            $redirectUrl="";
298
+            $redirectUrl = "";
299 299
         }
300 300
 
301 301
         $this->alertBox->setAlert('Account created, please check your mailbox to activate account');
Please login to merge, or discard this patch.
App/Modules/SiteConfig.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         $categories = $categoryModel->getCategories();
51 51
         foreach ($categories as $category) {
52 52
             $data += [
53
-                $category->category_name => '/category/posts/' . $category->categories_slug
53
+                $category->category_name => '/category/posts/'.$category->categories_slug
54 54
             ];
55 55
         }
56 56
         return $data;
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
         $session = $this->container->getSession();
69 69
 
70 70
         $userToken = $cookie->getCookie("rememberMe");
71
-        if($userToken && $this->isHexa($userToken))
71
+        if ($userToken && $this->isHexa($userToken))
72 72
         {
73 73
             //we have a rememberMe Hash, login
74 74
             $rememberedLogin = $rememberedLoginModel->findByToken($userToken);
75
-            if($rememberedLogin){
75
+            if ($rememberedLogin) {
76 76
                 //we have a hash, login
77 77
                 $user = $userModel->getUserDetailsById($rememberedLogin->users_idusers);
78 78
                 $session->regenerateSessionId(); //regenerate the ID to avoid session ghosting
Please login to merge, or discard this patch.
App/Controllers/Ajax/Category.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             $send[$item->name] = $item->value;
41 41
         }
42 42
 
43
-        if(!$this->slug->isSlugValid($send["categories_slug"]))
43
+        if (!$this->slug->isSlugValid($send["categories_slug"]))
44 44
         {
45 45
             $result["success"] = false;
46 46
             $result["errorMessage"] = "Invalid Slug";
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         foreach ($categoryUpdate as $item) {
74 74
             $send[$item->name] = $item->value;
75 75
         }
76
-        if(!$this->slug->isSlugValid($send["categories_slug"]))
76
+        if (!$this->slug->isSlugValid($send["categories_slug"]))
77 77
         {
78 78
             $result["success"] = false;
79 79
             $result["errorMessage"] = "Invalid Slug";
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             die();
82 82
         }
83 83
 
84
-        if(!$this->isInt($send["idcategories"])){
84
+        if (!$this->isInt($send["idcategories"])) {
85 85
             $result["success"] = false;
86 86
             $result["errorMessage"] = "Invalid ID";
87 87
             echo json_encode($result);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             $send[$item->name] = $item->value;
118 118
         }
119 119
 
120
-        if(!$this->isInt($send["idcategories"])){
120
+        if (!$this->isInt($send["idcategories"])) {
121 121
             $result["success"] = false;
122 122
             $result["errorMessage"] = "Invalid ID";
123 123
             echo json_encode($result);
Please login to merge, or discard this patch.
App/Modules/Slug.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@
 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();
12 12
         $validSlug = $slugify->slugify($slug);
13
-        if($slug !== $validSlug)
13
+        if ($slug !== $validSlug)
14 14
         {
15 15
             return false;
16 16
         }
Please login to merge, or discard this patch.