Passed
Push — Security_and_bug_fixes ( 6b5782...452225 )
by Stone
02:00
created
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/ImageUpload.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
     private function getFilename(string $folder, string $file): string
45 45
     {
46 46
         //slugify the file name to avoid security errors or bugs with special characters.
47
-        $fileName = pathinfo($file, PATHINFO_FILENAME );
48
-        $fileExtension = pathinfo($file, PATHINFO_EXTENSION );
47
+        $fileName = pathinfo($file, PATHINFO_FILENAME);
48
+        $fileExtension = pathinfo($file, PATHINFO_EXTENSION);
49 49
         $slugify = new Slugify();
50 50
         $fileName = $slugify->slugify($fileName);
51 51
         //if the filename has only special chars, the slugify will be empty, create a unique ID
52
-        if($fileName ==="")
52
+        if ($fileName === "")
53 53
         {
54 54
             $fileName = uniqid();
55 55
         }
56 56
         $file = $fileName.".".$fileExtension;
57
-        $fileUrl = $folder . $file;
57
+        $fileUrl = $folder.$file;
58 58
         $docRoot = $this->request->getDocumentRoot();
59
-        $filePath = $docRoot . "/public/" . $fileUrl;
59
+        $filePath = $docRoot."/public/".$fileUrl;
60 60
         if (file_exists($filePath) !== 1) {
61 61
             $fileNum = 0;
62 62
             while (file_exists($filePath)) {
63
-                $fileUrl = $folder . $fileNum . "_" . $file;
64
-                $filePath = $docRoot . "/public/" . $fileUrl;
63
+                $fileUrl = $folder.$fileNum."_".$file;
64
+                $filePath = $docRoot."/public/".$fileUrl;
65 65
                 $fileNum += 1;
66 66
             }
67 67
         }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
             // Respond to the successful upload with JSON.
87 87
             echo json_encode(array('location' => $filetowrite));
88
-        } else {
88
+        }else {
89 89
             // Notify editor that the upload failed
90 90
             echo json_encode(array('error' => 'Upload failed, file might be too big'));
91 91
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
             // Respond to the successful upload with JSON.
121 121
             echo json_encode(array('location' => $filetowrite));
122
-        } else {
122
+        }else {
123 123
             // Notify editor that the upload failed
124 124
             header("HTTP/1.1 500 Server Error");
125 125
         }
Please login to merge, or discard this patch.
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/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.
Core/Dependency/Cookie.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace Core\Dependency;
4 4
 
5
-class Cookie{
5
+class Cookie {
6 6
 
7 7
     /**
8 8
      * set a cookie
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function deleteCookie(string $name):void
23 23
     {
24
-        setcookie($name, "", time()-3600); //expire the cookie
24
+        setcookie($name, "", time() - 3600); //expire the cookie
25 25
     }
26 26
 
27 27
     /**
Please login to merge, or discard this patch.
App/Models/RoleModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 use Core\Container;
7 7
 use Core\Model;
8 8
 
9
-class RoleModel extends Model{
9
+class RoleModel extends Model {
10 10
 
11 11
     private $roleTbl;
12 12
 
Please login to merge, or discard this patch.
App/Controllers/Admin/Comments.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 use Core\Container;
10 10
 use Core\Traits\StringFunctions;
11 11
 
12
-class Comments extends AdminController{
12
+class Comments extends AdminController {
13 13
 
14 14
     use StringFunctions;
15 15
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         }
115 115
 
116 116
         //update comment
117
-        if($this->commentModel->update($commentId, $comment["commentTextArea"], $comment["commentApproved"]))
117
+        if ($this->commentModel->update($commentId, $comment["commentTextArea"], $comment["commentApproved"]))
118 118
         {
119 119
             $this->alertBox->setAlert("Comment updated");
120 120
         }
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
@@ -24,13 +24,13 @@
 block discarded – undo
24 24
     const LIST_PER_PAGE = 10;
25 25
     const COMMENTS_PER_PAGE = 2;
26 26
 
27
-    const EXCERPT_WORD_COUNT =50;
27
+    const EXCERPT_WORD_COUNT = 50;
28 28
 
29 29
     //login security
30 30
     const NUMBER_OF_BAD_PASSWORD_TRIES = 3;
31 31
     const LOCKOUT_MINUTES = 5;
32 32
 
33
-    const PASSWORD_RESET_DURATION = 240;//number of minutes the reset password link is valid
33
+    const PASSWORD_RESET_DURATION = 240; //number of minutes the reset password link is valid
34 34
 
35 35
     const HASH_KEY = "1337blogOcPass159758348ShaQpiss";
36 36
 }
37 37
\ No newline at end of file
Please login to merge, or discard this patch.
App/Controllers/Password.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -45,27 +45,27 @@  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
         }
52 52
 
53 53
         //grab the token and ID
54 54
         $token = $this->request->getData("token");
55
-        $userId = (int)$this->request->getData("userId");
55
+        $userId = (int) $this->request->getData("userId");
56 56
 
57
-        if($token === null)
57
+        if ($token === null)
58 58
         {
59 59
             throw new \Exception("Null Token");
60 60
         }
61 61
 
62 62
         //verify if token is valid
63
-        if(!$this->isHexa($token)|| !$this->isInt($userId))
63
+        if (!$this->isHexa($token) || !$this->isInt($userId))
64 64
         {
65 65
             $this->alertBox->setAlert('Badly formatted Token', 'error');
66 66
             $this->response->redirect();
67 67
         }
68
-        if(!$this->userModel->getUserDetailsByToken($token, $userId))
68
+        if (!$this->userModel->getUserDetailsByToken($token, $userId))
69 69
         {
70 70
             $this->alertBox->setAlert('Invalid reset token, please request a new password', 'error');
71 71
             $this->response->redirect();
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
         $token = $request["token"];
89 89
         $userId = $request["userId"];
90 90
 
91
-        if(!$this->isHexa($token) || !$this->isInt($userId) )
91
+        if (!$this->isHexa($token) || !$this->isInt($userId))
92 92
         {
93 93
             throw new \Exception("Bad Token or ID request");
94 94
         }
95 95
 
96 96
         $error = false;
97 97
         $registerErrors = new \stdClass();
98
-        if($password !== $confirm)
98
+        if ($password !== $confirm)
99 99
         {
100 100
             $error = true;
101 101
             $registerErrors->forgotPassword = "password and confirmation do not match";
Please login to merge, or discard this patch.