Passed
Push — main ( 1dcc5d...2357cb )
by Pan
02:14
created
src/Comment/CommentController.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
         // Connect the database
45 45
         $this->db = $this->di->get("db");
46 46
         $this->db->connect();
47
-        if ($this->currentUser !=null) {
47
+        if ($this->currentUser!=null) {
48 48
             $sql = "SELECT id from users where username = ?;";
49
-            $res = $this->db->executeFetchAll($sql, [$this->currentUser]);
50
-            $this->userId = $res[0]->id;
49
+            $res = $this->db->executeFetchAll($sql, [ $this->currentUser ]);
50
+            $this->userId = $res[ 0 ]->id;
51 51
         }
52 52
     }
53 53
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             if ($submit) {
62 62
                 $comment = $request->getPost("comment") ?: null;
63 63
                 $sql = "INSERT INTO comments (comment, post_id, user_id, answer) VALUES (?, ?, ?, ?);";
64
-                $this->db->execute($sql, [$comment, $id, $this->userId, 0]);
64
+                $this->db->execute($sql, [ $comment, $id, $this->userId, 0 ]);
65 65
                 return $response->redirect("post/show/$id");
66 66
             }
67 67
         }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         $page = $this->di->get("page");
75 75
         if ($this->currentUser) {
76 76
             $sql = "INSERT INTO comment_votes (score, comment_id, user_id) VALUES (?, ?, ?);";
77
-            $this->db->execute($sql, [1, $id, $this->userId]);
77
+            $this->db->execute($sql, [ 1, $id, $this->userId ]);
78 78
 
79 79
             $response = $this->di->get("response");
80 80
             return $response->redirect("post/show/$post_id");
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         $page = $this->di->get("page");
89 89
         if ($this->currentUser) {
90 90
             $sql = "INSERT INTO comment_votes (score, comment_id, user_id) VALUES (?, ?, ?);";
91
-            $this->db->execute($sql, [-1, $id, $this->userId]);
91
+            $this->db->execute($sql, [-1, $id, $this->userId ]);
92 92
 
93 93
             $response = $this->di->get("response");
94 94
             return $response->redirect("post/show/$post_id");
@@ -107,16 +107,16 @@  discard block
 block discarded – undo
107 107
         $page = $this->di->get("page");
108 108
         //get the status of this answer
109 109
         $sql = "select accepted from comments where post_id=? and id=?;";
110
-        $res = $this->db->executeFetchAll($sql, [$post_id, $id]);
110
+        $res = $this->db->executeFetchAll($sql, [ $post_id, $id ]);
111 111
 
112
-        if ($res[0]->accepted==0) {
113
-            $accepted =1;
114
-        } elseif ($res[0]->accepted==1) {
115
-            $accepted=0;
112
+        if ($res[ 0 ]->accepted==0) {
113
+            $accepted = 1;
114
+        } elseif ($res[ 0 ]->accepted==1) {
115
+            $accepted = 0;
116 116
         }
117 117
         //change the status of this answer
118 118
         $sql = "update comments set accepted=? where post_id=? and id=?;";
119
-        $this->db->execute($sql, [$accepted, $post_id, $id]);
119
+        $this->db->execute($sql, [ $accepted, $post_id, $id ]);
120 120
         $response = $this->di->get("response");
121 121
         return $response->redirect("post/show/$post_id");
122 122
     }
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
             if ($submit) {
138 138
                 $comment = $request->getPost("comment") ?: null;
139 139
                 $sql = "INSERT INTO comments (comment, comment_reply_id, post_id, user_id, answer) VALUES (?, ?, ?, ?, ?);";
140
-                $this->db->execute($sql, [$comment, $id, $post_id, $this->userId, 0]);
140
+                $this->db->execute($sql, [ $comment, $id, $post_id, $this->userId, 0 ]);
141 141
                 return $response->redirect("post/show/$post_id");
142 142
             }
143 143
         }
Please login to merge, or discard this patch.
src/Tag/TagController1.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,10 +85,10 @@
 block discarded – undo
85 85
     {
86 86
         $page = $this->di->get("page");
87 87
         $sql = "SELECT * from v_all WHERE find_in_set(?, tags);";
88
-        $posts = $this->db->executeFetchAll($sql, [$tagname]);
88
+        $posts = $this->db->executeFetchAll($sql, [ $tagname ]);
89 89
         var_dump($posts);
90 90
         $page->add("tag/show",
91
-            ["tagName" => $tagname,
91
+            [ "tagName" => $tagname,
92 92
             "items"  => $posts,
93 93
             ]);
94 94
 
Please login to merge, or discard this patch.
src/Tag/TagController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,10 +85,10 @@
 block discarded – undo
85 85
     {
86 86
         $page = $this->di->get("page");
87 87
         $sql = "Select * from posts where id IN (SELECT post_id from post2tag WHERE tag_name=?);;";
88
-        $posts = $this->db->executeFetchAll($sql, [$tagname]);
88
+        $posts = $this->db->executeFetchAll($sql, [ $tagname ]);
89 89
 
90 90
         $page->add("tag/show",
91
-            ["tagName" => $tagname,
91
+            [ "tagName" => $tagname,
92 92
             "items"  => $posts,
93 93
             ]);
94 94
 
Please login to merge, or discard this patch.
src/User/UserController.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
         // Connect the database
45 45
         $this->db = $this->di->get("db");
46 46
         $this->db->connect();
47
-        if ($this->currentUser !=null) {
47
+        if ($this->currentUser!=null) {
48 48
             $sql = "SELECT id from users where username = ?;";
49
-            $res = $this->db->executeFetchAll($sql, [$this->currentUser]);
50
-            $this->userId = $res[0]->id;
49
+            $res = $this->db->executeFetchAll($sql, [ $this->currentUser ]);
50
+            $this->userId = $res[ 0 ]->id;
51 51
         }
52 52
     }
53 53
 
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
             //Get Posts
77 77
             $user_id = $res->id;
78 78
             $sql = "SELECT * FROM posts WHERE user_id=?;";
79
-            $posts = $this->db->executeFetchAll($sql, [$user_id]);
79
+            $posts = $this->db->executeFetchAll($sql, [ $user_id ]);
80 80
 
81 81
             // var_dump($posts);
82 82
             //Get the answers for the user
83 83
             $sql = "SELECT * from comments WHERE user_id=? and answer=1;";
84
-            $answers = $this->db->executeFetchAll($sql, [$user_id]);
84
+            $answers = $this->db->executeFetchAll($sql, [ $user_id ]);
85 85
             $bonus = 0;
86 86
             foreach ($answers as $value) {
87 87
                 // var_dump($value->accepted);
@@ -92,19 +92,19 @@  discard block
 block discarded – undo
92 92
 
93 93
             // Get the comments for the user
94 94
             $sql = "SELECT * from comments WHERE user_id=? and answer=0;";
95
-            $comments = $this->db->executeFetchAll($sql, [$user_id]);
95
+            $comments = $this->db->executeFetchAll($sql, [ $user_id ]);
96 96
             // var_dump($comments);
97
-            $reputation = count($posts)*3 + (count($answers)- $bonus)*3 +
97
+            $reputation = count($posts)*3 + (count($answers) - $bonus)*3 +
98 98
             + $bonus*100 + count($comments);
99 99
             $page->add("user/index",
100
-                ["current_user" => $this->currentUser,
100
+                [ "current_user" => $this->currentUser,
101 101
                 "avatar" => $avatar,
102 102
                 "reputation" => $reputation,
103 103
                 "items"  => $posts,
104 104
                 "answers" => $answers,
105 105
                 "comments" => $comments,
106 106
                 ]);
107
-            return $page->render(["title" => $title, ]);
107
+            return $page->render([ "title" => $title, ]);
108 108
         }
109 109
         $response = $this->di->get("response");
110 110
         return $response->redirect("user/login");
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
         //Get Posts
125 125
 
126 126
         $sql = "SELECT * from posts WHERE user_id=?;";
127
-        $posts =  $this->db->executeFetchAll($sql, [$user_id]);
127
+        $posts = $this->db->executeFetchAll($sql, [ $user_id ]);
128 128
         // var_dump($res->email);
129 129
         //Get the answers for the user
130 130
         $sql = "SELECT * from comments WHERE user_id=? and answer=1;";
131
-        $answers = $this->db->executeFetchAll($sql, [$user_id]);
131
+        $answers = $this->db->executeFetchAll($sql, [ $user_id ]);
132 132
         $bonus = 0;
133 133
         foreach ($answers as $value) {
134 134
             if ($value->accepted==1) {
@@ -138,19 +138,19 @@  discard block
 block discarded – undo
138 138
 
139 139
         // Get the comments for the user
140 140
         $sql = "SELECT * from comments WHERE user_id=? and answer=0;";
141
-        $comments = $this->db->executeFetchAll($sql, [$user_id]);
141
+        $comments = $this->db->executeFetchAll($sql, [ $user_id ]);
142 142
         // var_dump($comments);
143
-        $reputation = count($posts)*3 + (count($answers)- $bonus)*3 +
143
+        $reputation = count($posts)*3 + (count($answers) - $bonus)*3 +
144 144
         + $bonus*100 + count($comments);
145 145
         $page->add("user/profile",
146
-            ["user" => $res->username,
146
+            [ "user" => $res->username,
147 147
             "avatar" => $avatar,
148 148
             "reputation" => $reputation,
149 149
             "posts"  => $posts,
150 150
             "answers" => $answers,
151 151
             "comments" => $comments,
152 152
             ]);
153
-        return $page->render(["title" => $title, ]);
153
+        return $page->render([ "title" => $title, ]);
154 154
     }
155 155
 
156 156
     /**
Please login to merge, or discard this patch.
view/user/index.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,20 +18,20 @@  discard block
 block discarded – undo
18 18
 endif;
19 19
 ?>
20 20
 <?php foreach ($items as $item) :
21
-    $db =  $this->di->get("db");
21
+    $db = $this->di->get("db");
22 22
     $sql = "SELECT sum(score) as postscore from post_votes where post_id=?;";
23
-    $score = $db->executeFetchAll($sql, [$item->id]);
23
+    $score = $db->executeFetchAll($sql, [ $item->id ]);
24 24
     $sql = "select * from post2tag where post_id=?;";
25
-    $posttags = $db->executeFetchAll($sql, [$item->id]);
25
+    $posttags = $db->executeFetchAll($sql, [ $item->id ]);
26 26
     $sql = "SELECT sum(answer) as totalanswer from comments where post_id=?;";
27
-    $answer = $db->executeFetchAll($sql, [$item->id]);
27
+    $answer = $db->executeFetchAll($sql, [ $item->id ]);
28 28
     ?>
29 29
 
30 30
     <div class=posts>
31 31
         <div class=leftpost>
32
-            <div class=countvotes><?= $score[0]->postscore?:0?></div>
32
+            <div class=countvotes><?= $score[ 0 ]->postscore ?: 0?></div>
33 33
             <div class=countvotes>votes</div>
34
-            <div class=countanswers><?= $answer[0]->totalanswer?: 0?></div>
34
+            <div class=countanswers><?= $answer[ 0 ]->totalanswer ?: 0?></div>
35 35
             <div class=countvotes>answers</div>
36 36
         </div>
37 37
         <div class=rightpost>
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 <table class=table>
60 60
     <?php foreach ($answers as $answer):
61 61
         if ($answer->accepted==1) {
62
-            $acceptAns ="accepted";
62
+            $acceptAns = "accepted";
63 63
         } else {
64
-            $acceptAns ="NoShowAcceptButton";
64
+            $acceptAns = "NoShowAcceptButton";
65 65
         };
66 66
     ?>
67 67
         <tr>
Please login to merge, or discard this patch.
view/user/profile.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,21 +23,21 @@  discard block
 block discarded – undo
23 23
 endif;
24 24
 ?>
25 25
 <?php foreach ($posts as $item) :
26
-    $db =  $this->di->get("db");
26
+    $db = $this->di->get("db");
27 27
     $sql = "SELECT sum(score) as postscore from post_votes where post_id=?;";
28
-    $score = $db->executeFetchAll($sql, [$item->id]);
28
+    $score = $db->executeFetchAll($sql, [ $item->id ]);
29 29
     $sql = "select * from post2tag where post_id=?;";
30
-    $posttags = $db->executeFetchAll($sql, [$item->id]);
30
+    $posttags = $db->executeFetchAll($sql, [ $item->id ]);
31 31
     $sql = "SELECT sum(answer) as totalanswer from comments where post_id=?;";
32
-    $answer = $db->executeFetchAll($sql, [$item->id]);
32
+    $answer = $db->executeFetchAll($sql, [ $item->id ]);
33 33
 
34
-    $urlToShowPost = url("post/show/$item->id");?>
34
+    $urlToShowPost = url("post/show/$item->id"); ?>
35 35
 
36 36
     <div class=posts>
37 37
         <div class=leftpost>
38
-            <div class=countvotes><?=  $score[0]->postscore?:0?></div>
38
+            <div class=countvotes><?=  $score[ 0 ]->postscore ?: 0?></div>
39 39
             <div class=countvotes>votes</div>
40
-            <div class=countanswers><?= $answer[0]->totalanswer?: 0?></div>
40
+            <div class=countanswers><?= $answer[ 0 ]->totalanswer ?: 0?></div>
41 41
             <div class=countvotes>answers</div>
42 42
         </div>
43 43
         <div class=rightpost>
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
 
64 64
     <?php foreach ($answers as $answer):
65 65
         if ($answer->accepted==1) {
66
-            $acceptAns ="accepted";
66
+            $acceptAns = "accepted";
67 67
         } else {
68
-            $acceptAns ="NoShowAcceptButton";
68
+            $acceptAns = "NoShowAcceptButton";
69 69
         };
70 70
         // var_dump($acceptAns);
71 71
     ?>
72 72
         <div class=profileposts>
73
-                <a href="<?= url("post/show/{$answer->post_id}"); ?>"><?= Markdown::defaultTransform($answer->comment);?></a>
73
+                <a href="<?= url("post/show/{$answer->post_id}"); ?>"><?= Markdown::defaultTransform($answer->comment); ?></a>
74 74
                 <div class=<?=$acceptAns?>><i class="fa-2x fas fa-check"></i></div>
75 75
         </div>
76 76
     <?php endforeach; ?>
Please login to merge, or discard this patch.
view/tag/show.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -33,21 +33,21 @@
 block discarded – undo
33 33
 endif;
34 34
 ?>
35 35
 <?php foreach ($items as $item) :
36
-    $db =  $this->di->get("db");
36
+    $db = $this->di->get("db");
37 37
     $sql = "SELECT sum(score) as postscore from post_votes where post_id=?;";
38
-    $score = $db->executeFetchAll($sql, [$item->id]);
38
+    $score = $db->executeFetchAll($sql, [ $item->id ]);
39 39
     $sql = "select * from post2tag where post_id=?;";
40
-    $posttags = $db->executeFetchAll($sql, [$item->id]);
40
+    $posttags = $db->executeFetchAll($sql, [ $item->id ]);
41 41
     $sql = "SELECT sum(answer) as totalanswer from comments where post_id=?;";
42
-    $answer = $db->executeFetchAll($sql, [$item->id]);
42
+    $answer = $db->executeFetchAll($sql, [ $item->id ]);
43 43
     $urlToShowPost = url("post/show/$item->id");
44 44
     ?>
45 45
 
46 46
     <div class=posts>
47 47
         <div class=leftpost>
48
-            <div class=countvotes><?= $score[0]->postscore?:0?></div>
48
+            <div class=countvotes><?= $score[ 0 ]->postscore ?: 0?></div>
49 49
             <div class=countvotes>votes</div>
50
-            <div class=countanswers><?= $answer[0]->totalanswer?: 0?></div>
50
+            <div class=countanswers><?= $answer[ 0 ]->totalanswer ?: 0?></div>
51 51
             <div class=countvotes>answers</div>
52 52
         </div>
53 53
         <div class=rightpost>
Please login to merge, or discard this patch.
view/home/index.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 endif;
21 21
 ?>
22 22
 <?php foreach ($posts as $item) :
23
-    $db =  $this->di->get("db");
23
+    $db = $this->di->get("db");
24 24
     $sql = "SELECT sum(score) as postscore from post_votes where post_id=?;";
25
-    $score = $db->executeFetchAll($sql, [$item->id]);
25
+    $score = $db->executeFetchAll($sql, [ $item->id ]);
26 26
     $sql = "select * from post2tag where post_id=?;";
27
-    $posttags = $db->executeFetchAll($sql, [$item->id]);
27
+    $posttags = $db->executeFetchAll($sql, [ $item->id ]);
28 28
     $sql = "SELECT sum(answer) as totalanswer from comments where post_id=?;";
29
-    $answer = $db->executeFetchAll($sql, [$item->id]);
29
+    $answer = $db->executeFetchAll($sql, [ $item->id ]);
30 30
     // var_dump($answer);
31 31
     // if (!$score) {
32 32
     //     $score = 0;
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 
37 37
     <div class=posts>
38 38
         <div class=leftpost>
39
-            <div class=countvotes><?= $score[0]->postscore?: 0 ?></div>
39
+            <div class=countvotes><?= $score[ 0 ]->postscore ?: 0 ?></div>
40 40
             <div class=countvotes>votes</div>
41
-            <div class=countanswers><?= $answer[0]->totalanswer?: 0?></div>
41
+            <div class=countanswers><?= $answer[ 0 ]->totalanswer ?: 0?></div>
42 42
             <div class=countvotes>answers</div>
43 43
         </div>
44 44
         <div class=rightpost>
Please login to merge, or discard this patch.
view/home/index1.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,19 +21,19 @@
 block discarded – undo
21 21
 ?>
22 22
 <?php foreach ($posts as $item) :
23 23
     $sql = "select * from v_post_votes where post_id=?;";
24
-    $db =  $this->di->get("db");
25
-    $score = $db->executeFetchAll($sql, [$item->id]);
24
+    $db = $this->di->get("db");
25
+    $score = $db->executeFetchAll($sql, [ $item->id ]);
26 26
     if (!$score) {
27 27
         $score = 0;
28 28
     } else {
29
-        $score = $score[0]-> postscore;
29
+        $score = $score[ 0 ]-> postscore;
30 30
     }?>
31 31
 
32 32
     <div class=posts>
33 33
         <div class=leftpost>
34 34
             <div class=countvotes><?= $score?></div>
35 35
             <div class=countvotes>votes</div>
36
-            <div class=countanswers><?= $item->answer?: 0?></div>
36
+            <div class=countanswers><?= $item->answer ?: 0?></div>
37 37
             <div class=countvotes>answers</div>
38 38
         </div>
39 39
         <div class=rightpost>
Please login to merge, or discard this patch.