Passed
Push — Security_and_bug_fixes ( cd248f )
by Stone
04:41 queued 26s
created
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/Controllers/Ajax/postModification.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
     {
27 27
         $this->onlyAdmin();
28 28
         $this->onlyPost();
29
-        $state = (bool)($this->request->getData("state") === 'true');
30
-        $postId = (int)$this->request->getData("postId");
29
+        $state = (bool) ($this->request->getData("state") === 'true');
30
+        $postId = (int) $this->request->getData("postId");
31 31
 
32 32
         $result = array();
33 33
         $result["success"] = $this->postModule->setPublished(!$state, $postId);
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
     {
45 45
         $this->onlyAdmin();
46 46
         $this->onlyPost();
47
-        $state = (bool)($this->request->getData("state") === 'true');
48
-        $postId = (int)$this->request->getData("postId");
47
+        $state = (bool) ($this->request->getData("state") === 'true');
48
+        $postId = (int) $this->request->getData("postId");
49 49
 
50 50
         $result = array();
51 51
         $result["success"] = $this->postModule->setOnFrontPage(!$state, $postId);
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/Modules/SendMail.php 1 patch
Spacing   +5 added lines, -5 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
         ;
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             ->setBody($message, 'text/html')
52 52
         ;
53 53
 
54
-        if($from === null)
54
+        if ($from === null)
55 55
         {
56 56
             //if we haven't set a from, get the config value
57 57
             $from = $this->siteConfig["SMTP_from"];
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         $message = "<h1>Message from <a href='".$this->container->getRequest()->getBaseUrl()."'>".$this->siteConfig["site_name"]."</a></h1>";
78 78
         $message .= "<p>You have asked to reset your password, please click <a href=\"".$url."\">Here</a> to define a new password</p>";
79 79
 
80
-        $this->send($to, "Define New Password", $message );
80
+        $this->send($to, "Define New Password", $message);
81 81
 
82 82
     }
83 83
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         $message .= "<p>You have sucsessfuly created an account, now all you need to do is <a href=\"".$url."\">Create your new password</a></p>";
98 98
         $message .= "<p>Have fun</p>";
99 99
 
100
-        $this->send($to, "Define Password at ".$this->siteConfig["site_name"], $message );
100
+        $this->send($to, "Define Password at ".$this->siteConfig["site_name"], $message);
101 101
 
102 102
     }
103 103
 }
104 104
\ No newline at end of file
Please login to merge, or discard this patch.
App/Models/CommentModel.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use HTMLPurifier;
9 9
 use HTMLPurifier_Config;
10 10
 
11
-class CommentModel extends Model{
11
+class CommentModel extends Model {
12 12
 
13 13
     private $commentTbl;
14 14
     private $userTbl;
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
      * @return int
155 155
      * @throws \Exception
156 156
      */
157
-    public function addComment(int $postId, int $userId, string $comment, bool $admin=false):int
157
+    public function addComment(int $postId, int $userId, string $comment, bool $admin = false):int
158 158
     {
159 159
         $comment = $this->purifyHtml($comment);
160
-        $sql="
160
+        $sql = "
161 161
             INSERT INTO $this->commentTbl (users_idusers, posts_idposts, comment, approved)
162 162
             VALUES (:userId, :postId, :comment, :approved)
163 163
         ";
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         $this->bind(':approved', $admin);
169 169
 
170 170
         $this->execute();
171
-        return (int)$this->dbh->lastInsertId();
171
+        return (int) $this->dbh->lastInsertId();
172 172
     }
173 173
 
174 174
     /**
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
         $comment = $this->purifyHtml($comment);
203 203
 
204
-        $sql="
204
+        $sql = "
205 205
             UPDATE $this->commentTbl 
206 206
             SET
207 207
               comment = :comment,
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/Ajax/PostVerification.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,9 +44,11 @@
 block discarded – undo
44 44
 
45 45
         $data = $postModel->isPostSlugUnique(/** @scrutinizer ignore-type */$postSlug); //we have checked that slug is valid so no type error
46 46
 
47
-        if ($data === false) //slug is not unique, but could be from the same post
47
+        if ($data === false) {
48
+            //slug is not unique, but could be from the same post
48 49
         {
49 50
             $slugOfId = $postModel->getPostSlugFromId($postId);
51
+        }
50 52
             if ($slugOfId === $postSlug) {
51 53
                 //it's the same post, return true
52 54
                 $data = true;
Please login to merge, or discard this 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.