Passed
Push — main ( cc0c0c...66d0e3 )
by A
02:46
created
src/User/UserController.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         // var_dump($page);
51 51
         $route = $request->getRoute();
52 52
         // var_dump($route);
53
-        $acronym = $_SESSION["acronym"] ?? null;
53
+        $acronym = $_SESSION[ "acronym" ] ?? null;
54 54
         // var_dump($_SESSION);
55 55
 
56 56
         if ($route == "user/login" || $route == "user/create") {
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
         // var_dump($_SESSION);
138 138
 
139
-        if ($_SESSION["acronym"] ?? null) {
139
+        if ($_SESSION[ "acronym" ] ?? null) {
140 140
             $response = $this->di->get("response");
141 141
             return $response->redirect("user/questions");
142 142
         }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             "content" => "<img src='../../htdocs/image/garden2.jpg' width='1000px'></img>",
154 154
         ];
155 155
 
156
-        $page->add("login-side", [], "sidebar-right");
156
+        $page->add("login-side", [ ], "sidebar-right");
157 157
         $page->add("anax/v2/article/default", $pic, "flash");
158 158
 
159 159
         return $page->render([
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         $request = $this->di->get("request");
178 178
 
179 179
         $res = new Functions();
180
-        $acronym = $_SESSION["acronym"];
180
+        $acronym = $_SESSION[ "acronym" ];
181 181
         $rows = "id, question, tags";
182 182
         $questions = $res->getProfileInfo($acronym, $this->di, "Question", $rows);
183 183
         $rows2 = "id, questionId, answer";
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         $user = $res->getProfileInfo($acronym, $this->di, "User", $rows4);
189 189
         // var_dump($comments);
190 190
 
191
-        $form = new FormElementFile("img", ["image/*"]);
191
+        $form = new FormElementFile("img", [ "image/*" ]);
192 192
         $baseURL = $request->getBaseUrl();
193 193
         // var_dump($baseURL);
194 194
 
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
         $user = $res->getProfileInfo($acronym, $this->di, "User", $rows);
239 239
         $pictures = $res->getAllProfilePictures($this->di, $acronym);
240 240
 
241
-        $info = $_POST["info"] ?? null;
242
-        $picture = $_POST["picture"] ?? null;
241
+        $info = $_POST[ "info" ] ?? null;
242
+        $picture = $_POST[ "picture" ] ?? null;
243 243
         if ($info) {
244 244
             var_dump($info);
245 245
             $res->setProfileInfo($this->di, $acronym, $info);
@@ -295,15 +295,15 @@  discard block
 block discarded – undo
295 295
         if ($post) {
296 296
             // $res->setProfilePicture($this->di, $acronym, $post);
297 297
             $target_dir = "C:/cygwin64/home/Lichn/dbwebb-kurser/ramverk1/me/kmom10/module/htdocs/img/profile/";
298
-            $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
298
+            $target_file = $target_dir . basename($_FILES[ "fileToUpload" ][ "name" ]);
299 299
             $uploadOk = 1;
300
-            $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
300
+            $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
301 301
             // Check if image file is a actual image or fake image
302
-            if(isset($_POST["submit"])) {
302
+            if (isset($_POST[ "submit" ])) {
303 303
                 var_dump("smask");
304
-             $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
305
-              if($check !== false) {
306
-                echo "File is an image - " . $check["mime"] . ".";
304
+             $check = getimagesize($_FILES[ "fileToUpload" ][ "tmp_name" ]);
305
+              if ($check !== false) {
306
+                echo "File is an image - " . $check[ "mime" ] . ".";
307 307
                 $uploadOk = 1;
308 308
               } else {
309 309
                 echo "File is not an image.";
@@ -317,14 +317,14 @@  discard block
 block discarded – undo
317 317
             }
318 318
 
319 319
             // Check file size
320
-            if ($_FILES["fileToUpload"]["size"] > 500000) {
320
+            if ($_FILES[ "fileToUpload" ][ "size" ] > 500000) {
321 321
               echo "Sorry, your file is too large.";
322 322
               $uploadOk = 0;
323 323
             }
324 324
 
325 325
             // Allow certain file formats
326
-            if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
327
-            && $imageFileType != "gif" ) {
326
+            if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
327
+            && $imageFileType != "gif") {
328 328
               echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
329 329
               $uploadOk = 0;
330 330
             }
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
               echo "Sorry, your file was not uploaded.";
335 335
             // if everything is ok, try to upload file
336 336
             } else {
337
-              if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
338
-                echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded.";
339
-                $res->setProfilePicture($this->di, $acronym, $_FILES["fileToUpload"]);
340
-                $res->addProfilePicture($this->di, $acronym, $_FILES["fileToUpload"]);
337
+              if (move_uploaded_file($_FILES[ "fileToUpload" ][ "tmp_name" ], $target_file)) {
338
+                echo "The file " . htmlspecialchars(basename($_FILES[ "fileToUpload" ][ "name" ])) . " has been uploaded.";
339
+                $res->setProfilePicture($this->di, $acronym, $_FILES[ "fileToUpload" ]);
340
+                $res->addProfilePicture($this->di, $acronym, $_FILES[ "fileToUpload" ]);
341 341
               } else {
342 342
                 echo "Sorry, there was an error uploading your file.";
343 343
               }
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
     {
418 418
         $page = $this->di->get("page");
419 419
         // $acronym = $_SESSION["acronym"];
420
-        $acronym = $_SESSION["acronym"];
420
+        $acronym = $_SESSION[ "acronym" ];
421 421
         // var_dump($_SESSION);
422 422
         $form = new CreateQuestionForm($this->di, $acronym);
423 423
         $form->check();
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
         //     "content" => "<img src='../../htdocs/image/car.png' width='1000px'></img>",
435 435
         // ];
436 436
 
437
-        $page->add("ask-tip", [], "sidebar-right");
438
-        $page->add("ask-tag", [], "sidebar-right");
437
+        $page->add("ask-tip", [ ], "sidebar-right");
438
+        $page->add("ask-tag", [ ], "sidebar-right");
439 439
         // $page->add("anax/v2/article/default", $pic, "flash");
440 440
 
441 441
         return $page->render([
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 
519 519
         // Get list of all users.
520 520
         $users = $res->getAllUsers($this->di);
521
-        $sums = [];
521
+        $sums = [ ];
522 522
         foreach ($users as $user) {
523 523
             $acronym = $user->acronym;
524 524
             // get all questions made by user
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
             // get all answers made by user
529 529
             $ans = $res->getProfileInfo($acronym, $this->di, "Answers", "answer");
530 530
             // sum up everything
531
-            $sums[$acronym] = sizeof($quests) + sizeof($com) + sizeof($ans);
531
+            $sums[ $acronym ] = sizeof($quests) + sizeof($com) + sizeof($ans);
532 532
         }
533 533
 
534 534
         arsort($sums);
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
         $comment = $res->getOneQuestionComment($this->di, $commentId);
632 632
         var_dump($comment);
633 633
 
634
-        $acronym = $comment[0]->acronym;
635
-        $answer = $comment[0]->comment;
636
-        $created = $comment[0]->created;
634
+        $acronym = $comment[ 0 ]->acronym;
635
+        $answer = $comment[ 0 ]->comment;
636
+        $created = $comment[ 0 ]->created;
637 637
 
638 638
         // Save as answer.
639 639
         $res->saveAnswer($this->di, $questionId, $acronym, $answer, $created);
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
         // Delete comment.
642 642
         $res->deleteComment($this->di, $commentId);
643 643
 
644
-        var_dump($comment[0]->comment);
644
+        var_dump($comment[ 0 ]->comment);
645 645
 
646 646
         // $page->add("anax/v2/article/default", [
647 647
         //     "content" => "Hello",
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
             // get profile picture of the user who made a question
693 693
             $picture = $res->getProfileInfo($acronym, $this->di, "User", "picture");
694 694
 
695
-            $question->picture = "<img src='{$baseURL}/image/profile/{$picture[0]->picture}{$size}'></img>";
695
+            $question->picture = "<img src='{$baseURL}/image/profile/{$picture[ 0 ]->picture}{$size}'></img>";
696 696
             // get all answers
697 697
             $question->answers = $res->getQuestionAnswers($this->di, $questionId);
698 698
         }
@@ -705,9 +705,9 @@  discard block
 block discarded – undo
705 705
 
706 706
         // get variables from posted checkbox form
707 707
         $items = $request->getPost();
708
-        if ($items["items"] ?? null) {
708
+        if ($items[ "items" ] ?? null) {
709 709
             // visa endast info gällande de ikryssade taggarna
710
-            foreach ($items["items"] as $val) {
710
+            foreach ($items[ "items" ] as $val) {
711 711
                 // var_dump($val);
712 712
                 $questions = $res->getSomeQuestionsTags($this->di, $val);
713 713
                 // var_dump($questions);
@@ -778,14 +778,14 @@  discard block
 block discarded – undo
778 778
         // var_dump($answers);
779 779
 
780 780
         // var_dump($comments);
781
-        $qId = $question[0]->id;
781
+        $qId = $question[ 0 ]->id;
782 782
 
783
-        $user = $_SESSION["acronym"];
783
+        $user = $_SESSION[ "acronym" ];
784 784
 
785 785
         $form = new CreateCommentsForm($this->di, $user, $qId);
786 786
         $form->check();
787 787
 
788
-        $acronym = $res->changeCharacter($question[0]->acronym);
788
+        $acronym = $res->changeCharacter($question[ 0 ]->acronym);
789 789
         // $aForm = new CreateAnswerCommentsForm($this->di, $acronym, $aId ?? 1);
790 790
         // $aForm->check();
791 791
 
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
             "qId" => $id,
813 813
         ]);
814 814
 
815
-        $tags = $question[0]->tags ?? "Grönsaker, Plantor";
815
+        $tags = $question[ 0 ]->tags ?? "Grönsaker, Plantor";
816 816
         $tagsArray = explode("; ", $tags);
817 817
 
818 818
         $page->add("show-tags", [
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
             "content" => $content,
832 832
         ], "sidebar-right");
833 833
 
834
-        $page->add("ask-tip", [], "sidebar-right");
834
+        $page->add("ask-tip", [ ], "sidebar-right");
835 835
 
836 836
         return $page->render([
837 837
             "title" => "View question",
@@ -951,14 +951,14 @@  discard block
 block discarded – undo
951 951
             // get profile picture of the user who made a question
952 952
             $picture = $res->getProfileInfo($acronym, $this->di, "User", "picture");
953 953
 
954
-            $question->picture = "<img src='{$baseURL}/image/profile/{$picture[0]->picture}{$size}'></img>";
954
+            $question->picture = "<img src='{$baseURL}/image/profile/{$picture[ 0 ]->picture}{$size}'></img>";
955 955
             // get all answers
956 956
             $question->answers = $res->getQuestionAnswers($this->di, $questionId);
957 957
         }
958 958
 
959 959
         $filter = new \Anax\TextFilter\TextFilter();
960 960
 
961
-        $user = $_SESSION["acronym"];
961
+        $user = $_SESSION[ "acronym" ];
962 962
 
963 963
         $page->add("view-tag-questions", [
964 964
             "questions" => $questions,
Please login to merge, or discard this patch.