@@ -56,7 +56,7 @@ |
||
| 56 | 56 | "submit" => [ |
| 57 | 57 | "type" => "submit", |
| 58 | 58 | "value" => "Skicka", |
| 59 | - "callback" => [$this, "callbackSubmit"] |
|
| 59 | + "callback" => [ $this, "callbackSubmit" ] |
|
| 60 | 60 | ], |
| 61 | 61 | ] |
| 62 | 62 | ); |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | "submit" => [ |
| 57 | 57 | "type" => "submit", |
| 58 | 58 | "value" => "Skicka", |
| 59 | - "callback" => [$this, "callbackSubmit"] |
|
| 59 | + "callback" => [ $this, "callbackSubmit" ] |
|
| 60 | 60 | ], |
| 61 | 61 | ] |
| 62 | 62 | ); |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | "submit" => [ |
| 54 | 54 | "type" => "submit", |
| 55 | 55 | "value" => "Create user", |
| 56 | - "callback" => [$this, "callbackSubmit"] |
|
| 56 | + "callback" => [ $this, "callbackSubmit" ] |
|
| 57 | 57 | ], |
| 58 | 58 | ] |
| 59 | 59 | ); |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | "submit" => [ |
| 55 | 55 | "type" => "submit", |
| 56 | 56 | "value" => "Ställ fråga", |
| 57 | - "callback" => [$this, "callbackSubmit"] |
|
| 57 | + "callback" => [ $this, "callbackSubmit" ] |
|
| 58 | 58 | ], |
| 59 | 59 | ] |
| 60 | 60 | ); |
@@ -82,18 +82,18 @@ |
||
| 82 | 82 | $db = $this->di->get("dbqb"); |
| 83 | 83 | $db->connect(); |
| 84 | 84 | $user = $db->select("password") |
| 85 | - ->from("User") |
|
| 86 | - ->where("acronym = ?") |
|
| 87 | - ->execute([$acronym]) |
|
| 88 | - ->fetch(); |
|
| 85 | + ->from("User") |
|
| 86 | + ->where("acronym = ?") |
|
| 87 | + ->execute([$acronym]) |
|
| 88 | + ->fetch(); |
|
| 89 | 89 | |
| 90 | 90 | // $user is null if user is not found |
| 91 | 91 | if (!$user || !password_verify($password, $user->password)) { |
| 92 | 92 | var_dump($acronym); |
| 93 | 93 | var_dump($password); |
| 94 | - $this->form->rememberValues(); |
|
| 95 | - $this->form->addOutput("User $acronym or password $password did not match."); |
|
| 96 | - return false; |
|
| 94 | + $this->form->rememberValues(); |
|
| 95 | + $this->form->addOutput("User $acronym or password $password did not match."); |
|
| 96 | + return false; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // $_SESSION["status"] = "Logga ut"; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | "submit" => [ |
| 43 | 43 | "type" => "submit", |
| 44 | 44 | "value" => "Login", |
| 45 | - "callback" => [$this, "callbackSubmit"] |
|
| 45 | + "callback" => [ $this, "callbackSubmit" ] |
|
| 46 | 46 | ], |
| 47 | 47 | ] |
| 48 | 48 | ); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $user = $db->select("password") |
| 85 | 85 | ->from("User") |
| 86 | 86 | ->where("acronym = ?") |
| 87 | - ->execute([$acronym]) |
|
| 87 | + ->execute([ $acronym ]) |
|
| 88 | 88 | ->fetch(); |
| 89 | 89 | |
| 90 | 90 | // $user is null if user is not found |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | // $_SESSION["status"] = "Logga ut"; |
| 100 | 100 | // $_SESSION["status_url"] = "user/logout"; |
| 101 | - $_SESSION["status"] = [ |
|
| 101 | + $_SESSION[ "status" ] = [ |
|
| 102 | 102 | "text" => "Profil", |
| 103 | 103 | "url" => "user/profile", |
| 104 | 104 | "title" => "Profil", |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | ], |
| 113 | 113 | ], |
| 114 | 114 | ]; |
| 115 | - $_SESSION["acronym"] = $acronym; |
|
| 115 | + $_SESSION[ "acronym" ] = $acronym; |
|
| 116 | 116 | // $this->form->addOutput("User logged in."); |
| 117 | 117 | return true; |
| 118 | 118 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | // "description" => "Here you can place a description.", |
| 31 | 31 | "placeholder" => "Sök", |
| 32 | 32 | "label" => "Sök", |
| 33 | - "callback" => [$this, "callbackSubmit"], |
|
| 33 | + "callback" => [ $this, "callbackSubmit" ], |
|
| 34 | 34 | ] |
| 35 | 35 | ] |
| 36 | 36 | ); |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | ], |
| 33 | 33 | "submit" => [ |
| 34 | 34 | "type" => "submit", |
| 35 | - "callback" => [$this, "callbackSubmit"], |
|
| 35 | + "callback" => [ $this, "callbackSubmit" ], |
|
| 36 | 36 | ], |
| 37 | 37 | ] |
| 38 | 38 | ); |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | // $user = $db->select("id, question, tags")
|
| 25 | 25 | // ->from("Question")
|
| 26 | 26 | $user = $db->select($rows) |
| 27 | - ->from($table) |
|
| 28 | - ->where("acronym = ?")
|
|
| 29 | - ->execute([$acronym]) |
|
| 30 | - ->fetchAll(); |
|
| 27 | + ->from($table) |
|
| 28 | + ->where("acronym = ?")
|
|
| 29 | + ->execute([$acronym]) |
|
| 30 | + ->fetchAll(); |
|
| 31 | 31 | |
| 32 | 32 | // var_dump($user); |
| 33 | 33 | return $user; |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | $db = $di->get("dbqb");
|
| 50 | 50 | $db->connect(); |
| 51 | 51 | $post = $db->select($rows) |
| 52 | - ->from($table) |
|
| 53 | - ->where("id = ?")
|
|
| 54 | - ->execute([$id]) |
|
| 55 | - ->fetchAll(); |
|
| 52 | + ->from($table) |
|
| 53 | + ->where("id = ?")
|
|
| 54 | + ->execute([$id]) |
|
| 55 | + ->fetchAll(); |
|
| 56 | 56 | |
| 57 | 57 | // var_dump($post); |
| 58 | 58 | return $post; |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | $db = $di->get("dbqb");
|
| 115 | 115 | $db->connect(); |
| 116 | 116 | $users = $db->select("acronym")
|
| 117 | - ->from("User")
|
|
| 118 | - ->execute() |
|
| 119 | - ->fetchAll(); |
|
| 117 | + ->from("User")
|
|
| 118 | + ->execute() |
|
| 119 | + ->fetchAll(); |
|
| 120 | 120 | |
| 121 | 121 | return $users; |
| 122 | 122 | } |
@@ -315,10 +315,10 @@ discard block |
||
| 315 | 315 | $db = $di->get("dbqb");
|
| 316 | 316 | $db->connect(); |
| 317 | 317 | $questions = $db->select("id, acronym, question, tags")
|
| 318 | - ->from("Question")
|
|
| 319 | - ->where("tags LIKE ?")
|
|
| 320 | - ->execute(["%$res%"]) |
|
| 321 | - ->fetchAll(); |
|
| 318 | + ->from("Question")
|
|
| 319 | + ->where("tags LIKE ?")
|
|
| 320 | + ->execute(["%$res%"]) |
|
| 321 | + ->fetchAll(); |
|
| 322 | 322 | |
| 323 | 323 | // var_dump($questions); |
| 324 | 324 | return $questions; |
@@ -337,10 +337,10 @@ discard block |
||
| 337 | 337 | $db = $di->get("dbqb");
|
| 338 | 338 | $db->connect(); |
| 339 | 339 | $questions = $db->select("*")
|
| 340 | - ->from("Question")
|
|
| 341 | - ->where("id = ?")
|
|
| 342 | - ->execute([$res]) |
|
| 343 | - ->fetchAll(); |
|
| 340 | + ->from("Question")
|
|
| 341 | + ->where("id = ?")
|
|
| 342 | + ->execute([$res]) |
|
| 343 | + ->fetchAll(); |
|
| 344 | 344 | |
| 345 | 345 | // var_dump($questions); |
| 346 | 346 | return $questions; |
@@ -360,10 +360,10 @@ discard block |
||
| 360 | 360 | $db = $di->get("dbqb");
|
| 361 | 361 | $db->connect(); |
| 362 | 362 | $res = $db->select("*")
|
| 363 | - ->from("Comments")
|
|
| 364 | - ->where("questionId = ?")
|
|
| 365 | - ->execute([$questionId]) |
|
| 366 | - ->fetchAll(); |
|
| 363 | + ->from("Comments")
|
|
| 364 | + ->where("questionId = ?")
|
|
| 365 | + ->execute([$questionId]) |
|
| 366 | + ->fetchAll(); |
|
| 367 | 367 | |
| 368 | 368 | // var_dump($res); |
| 369 | 369 | return $res; |
@@ -383,10 +383,10 @@ discard block |
||
| 383 | 383 | $db = $di->get("dbqb");
|
| 384 | 384 | $db->connect(); |
| 385 | 385 | $res = $db->select("*")
|
| 386 | - ->from("Comments")
|
|
| 387 | - ->where("id = ?")
|
|
| 388 | - ->execute([$id]) |
|
| 389 | - ->fetchAll(); |
|
| 386 | + ->from("Comments")
|
|
| 387 | + ->where("id = ?")
|
|
| 388 | + ->execute([$id]) |
|
| 389 | + ->fetchAll(); |
|
| 390 | 390 | |
| 391 | 391 | return $res; |
| 392 | 392 | } |
@@ -405,10 +405,10 @@ discard block |
||
| 405 | 405 | $db = $di->get("dbqb");
|
| 406 | 406 | $db->connect(); |
| 407 | 407 | $res = $db->select("*")
|
| 408 | - ->from("AnswerComments")
|
|
| 409 | - ->where("answerId = ?")
|
|
| 410 | - ->execute([$answerId]) |
|
| 411 | - ->fetchAll(); |
|
| 408 | + ->from("AnswerComments")
|
|
| 409 | + ->where("answerId = ?")
|
|
| 410 | + ->execute([$answerId]) |
|
| 411 | + ->fetchAll(); |
|
| 412 | 412 | |
| 413 | 413 | // var_dump($res); |
| 414 | 414 | return $res; |
@@ -448,10 +448,10 @@ discard block |
||
| 448 | 448 | $db = $di->get("dbqb");
|
| 449 | 449 | $db->connect(); |
| 450 | 450 | $res = $db->select("answer")
|
| 451 | - ->from("Answers")
|
|
| 452 | - ->where("questionId = ?")
|
|
| 453 | - ->execute([$questionId]) |
|
| 454 | - ->fetch(); |
|
| 451 | + ->from("Answers")
|
|
| 452 | + ->where("questionId = ?")
|
|
| 453 | + ->execute([$questionId]) |
|
| 454 | + ->fetch(); |
|
| 455 | 455 | |
| 456 | 456 | $answered = "Nej"; |
| 457 | 457 | if ($res ?? null) {
|
@@ -474,10 +474,10 @@ discard block |
||
| 474 | 474 | $db = $di->get("dbqb");
|
| 475 | 475 | $db->connect(); |
| 476 | 476 | $res = $db->select("*")
|
| 477 | - ->from("Answers")
|
|
| 478 | - ->where("questionId = ?")
|
|
| 479 | - ->execute([$questionId]) |
|
| 480 | - ->fetchAll(); |
|
| 477 | + ->from("Answers")
|
|
| 478 | + ->where("questionId = ?")
|
|
| 479 | + ->execute([$questionId]) |
|
| 480 | + ->fetchAll(); |
|
| 481 | 481 | |
| 482 | 482 | // var_dump($res); |
| 483 | 483 | return $res; |
@@ -514,10 +514,10 @@ discard block |
||
| 514 | 514 | $db = $di->get("dbqb");
|
| 515 | 515 | $db->connect(); |
| 516 | 516 | $res = $db->select("points")
|
| 517 | - ->from($table) |
|
| 518 | - ->where("id = ?")
|
|
| 519 | - ->execute([$id]) |
|
| 520 | - ->fetch(); |
|
| 517 | + ->from($table) |
|
| 518 | + ->where("id = ?")
|
|
| 519 | + ->execute([$id]) |
|
| 520 | + ->fetch(); |
|
| 521 | 521 | |
| 522 | 522 | return $res; |
| 523 | 523 | } |
@@ -624,10 +624,10 @@ discard block |
||
| 624 | 624 | $db = $di->get("dbqb");
|
| 625 | 625 | $db->connect(); |
| 626 | 626 | $res = $db->select("name")
|
| 627 | - ->from("Pictures")
|
|
| 628 | - ->where("acronym = ? OR acronym = ?")
|
|
| 629 | - ->execute(["default", $acronym]) |
|
| 630 | - ->fetchAll(); |
|
| 627 | + ->from("Pictures")
|
|
| 628 | + ->where("acronym = ? OR acronym = ?")
|
|
| 629 | + ->execute(["default", $acronym]) |
|
| 630 | + ->fetchAll(); |
|
| 631 | 631 | |
| 632 | 632 | return $res; |
| 633 | 633 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $user = $db->select($rows) |
| 27 | 27 | ->from($table) |
| 28 | 28 | ->where("acronym = ?")
|
| 29 | - ->execute([$acronym]) |
|
| 29 | + ->execute([ $acronym ]) |
|
| 30 | 30 | ->fetchAll(); |
| 31 | 31 | |
| 32 | 32 | // var_dump($user); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $post = $db->select($rows) |
| 52 | 52 | ->from($table) |
| 53 | 53 | ->where("id = ?")
|
| 54 | - ->execute([$id]) |
|
| 54 | + ->execute([ $id ]) |
|
| 55 | 55 | ->fetchAll(); |
| 56 | 56 | |
| 57 | 57 | // var_dump($post); |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | {
|
| 75 | 75 | $db = $di->get("dbqb");
|
| 76 | 76 | $db->connect() |
| 77 | - ->update($table, [$rows]) |
|
| 77 | + ->update($table, [ $rows ]) |
|
| 78 | 78 | ->where("id = ?")
|
| 79 | - ->execute([$res, $id]); |
|
| 79 | + ->execute([ $res, $id ]); |
|
| 80 | 80 | |
| 81 | 81 | return "Saved"; |
| 82 | 82 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $db = $di->get("dbqb");
|
| 97 | 97 | $db->connect(); |
| 98 | 98 | $sql = "DELETE FROM $table WHERE id = ?;"; |
| 99 | - $db->execute($sql, [$id]); |
|
| 99 | + $db->execute($sql, [ $id ]); |
|
| 100 | 100 | return "Deleted"; |
| 101 | 101 | } |
| 102 | 102 | |
@@ -134,14 +134,14 @@ discard block |
||
| 134 | 134 | public function getUserStatus($di, $users) |
| 135 | 135 | {
|
| 136 | 136 | // get all answers made by $acronym |
| 137 | - $answers = []; |
|
| 137 | + $answers = [ ]; |
|
| 138 | 138 | foreach ($users as $acronym) {
|
| 139 | 139 | $db = $di->get("dbqb");
|
| 140 | 140 | $db->connect(); |
| 141 | 141 | $answers = $db->select("answer")
|
| 142 | 142 | ->from("Answers")
|
| 143 | 143 | ->where("acronym = ?")
|
| 144 | - ->execute([$acronym]) |
|
| 144 | + ->execute([ $acronym ]) |
|
| 145 | 145 | ->fetchAll(); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $questions = $db->select("*")
|
| 186 | 186 | ->from("Question")
|
| 187 | 187 | ->where("tags LIKE ?")
|
| 188 | - ->execute(["%$tag%"]) |
|
| 188 | + ->execute([ "%$tag%" ]) |
|
| 189 | 189 | ->fetchAll(); |
| 190 | 190 | |
| 191 | 191 | return $questions; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | public function getTagsOnce($tagsArray) |
| 247 | 247 | {
|
| 248 | - $tags = []; |
|
| 248 | + $tags = [ ]; |
|
| 249 | 249 | foreach ($tagsArray as $val) {
|
| 250 | 250 | if (!in_array($val, $tags)) {
|
| 251 | 251 | array_push($tags, $val); |
@@ -266,12 +266,12 @@ discard block |
||
| 266 | 266 | public function countTagsFrequency($tagsArray) |
| 267 | 267 | {
|
| 268 | 268 | // var_dump($tagsArray); |
| 269 | - $tags = []; |
|
| 269 | + $tags = [ ]; |
|
| 270 | 270 | foreach ($tagsArray as $val) {
|
| 271 | 271 | if (!array_key_exists($val, $tags)) {
|
| 272 | - $tags[$val] = 0; |
|
| 272 | + $tags[ $val ] = 0; |
|
| 273 | 273 | } |
| 274 | - $tags[$val] += 1; |
|
| 274 | + $tags[ $val ] += 1; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | return $tags; |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | $questions = $db->select("id, acronym, question, tags")
|
| 318 | 318 | ->from("Question")
|
| 319 | 319 | ->where("tags LIKE ?")
|
| 320 | - ->execute(["%$res%"]) |
|
| 320 | + ->execute([ "%$res%" ]) |
|
| 321 | 321 | ->fetchAll(); |
| 322 | 322 | |
| 323 | 323 | // var_dump($questions); |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | $questions = $db->select("*")
|
| 340 | 340 | ->from("Question")
|
| 341 | 341 | ->where("id = ?")
|
| 342 | - ->execute([$res]) |
|
| 342 | + ->execute([ $res ]) |
|
| 343 | 343 | ->fetchAll(); |
| 344 | 344 | |
| 345 | 345 | // var_dump($questions); |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | $res = $db->select("*")
|
| 363 | 363 | ->from("Comments")
|
| 364 | 364 | ->where("questionId = ?")
|
| 365 | - ->execute([$questionId]) |
|
| 365 | + ->execute([ $questionId ]) |
|
| 366 | 366 | ->fetchAll(); |
| 367 | 367 | |
| 368 | 368 | // var_dump($res); |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | $res = $db->select("*")
|
| 386 | 386 | ->from("Comments")
|
| 387 | 387 | ->where("id = ?")
|
| 388 | - ->execute([$id]) |
|
| 388 | + ->execute([ $id ]) |
|
| 389 | 389 | ->fetchAll(); |
| 390 | 390 | |
| 391 | 391 | return $res; |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | $res = $db->select("*")
|
| 408 | 408 | ->from("AnswerComments")
|
| 409 | 409 | ->where("answerId = ?")
|
| 410 | - ->execute([$answerId]) |
|
| 410 | + ->execute([ $answerId ]) |
|
| 411 | 411 | ->fetchAll(); |
| 412 | 412 | |
| 413 | 413 | // var_dump($res); |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | $db = $di->get("dbqb");
|
| 430 | 430 | $db->connect(); |
| 431 | 431 | $sql = "SELECT * FROM Answers WHERE questionId = ? ORDER BY $column;"; |
| 432 | - $res = $db->executeFetchAll($sql, [$questionId]); |
|
| 432 | + $res = $db->executeFetchAll($sql, [ $questionId ]); |
|
| 433 | 433 | |
| 434 | 434 | return $res; |
| 435 | 435 | } |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | $res = $db->select("answer")
|
| 451 | 451 | ->from("Answers")
|
| 452 | 452 | ->where("questionId = ?")
|
| 453 | - ->execute([$questionId]) |
|
| 453 | + ->execute([ $questionId ]) |
|
| 454 | 454 | ->fetch(); |
| 455 | 455 | |
| 456 | 456 | $answered = "Nej"; |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | $res = $db->select("*")
|
| 477 | 477 | ->from("Answers")
|
| 478 | 478 | ->where("questionId = ?")
|
| 479 | - ->execute([$questionId]) |
|
| 479 | + ->execute([ $questionId ]) |
|
| 480 | 480 | ->fetchAll(); |
| 481 | 481 | |
| 482 | 482 | // var_dump($res); |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | */ |
| 494 | 494 | public function userCheck($acronym) |
| 495 | 495 | {
|
| 496 | - $user = $_SESSION["acronym"]; |
|
| 496 | + $user = $_SESSION[ "acronym" ]; |
|
| 497 | 497 | if ($user == $acronym) {
|
| 498 | 498 | return true; |
| 499 | 499 | } |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | $res = $db->select("points")
|
| 517 | 517 | ->from($table) |
| 518 | 518 | ->where("id = ?")
|
| 519 | - ->execute([$id]) |
|
| 519 | + ->execute([ $id ]) |
|
| 520 | 520 | ->fetch(); |
| 521 | 521 | |
| 522 | 522 | return $res; |
@@ -538,9 +538,9 @@ discard block |
||
| 538 | 538 | // var_dump($points); |
| 539 | 539 | $db = $di->get("dbqb");
|
| 540 | 540 | $db->connect() |
| 541 | - ->update($table, ["points"]) |
|
| 541 | + ->update($table, [ "points" ]) |
|
| 542 | 542 | ->where("id = ?")
|
| 543 | - ->execute([$points, $id]); |
|
| 543 | + ->execute([ $points, $id ]); |
|
| 544 | 544 | |
| 545 | 545 | return "Saved"; |
| 546 | 546 | } |
@@ -560,9 +560,9 @@ discard block |
||
| 560 | 560 | // var_dump($points); |
| 561 | 561 | $db = $di->get("dbqb");
|
| 562 | 562 | $db->connect() |
| 563 | - ->update("User", ["picture"])
|
|
| 563 | + ->update("User", [ "picture" ])
|
|
| 564 | 564 | ->where("acronym = ?")
|
| 565 | - ->execute([$picture, $acronym]); |
|
| 565 | + ->execute([ $picture, $acronym ]); |
|
| 566 | 566 | |
| 567 | 567 | return "Saved"; |
| 568 | 568 | } |
@@ -581,9 +581,9 @@ discard block |
||
| 581 | 581 | {
|
| 582 | 582 | $db = $di->get("dbqb");
|
| 583 | 583 | $db->connect() |
| 584 | - ->update("User", ["info"])
|
|
| 584 | + ->update("User", [ "info" ])
|
|
| 585 | 585 | ->where("acronym = ?")
|
| 586 | - ->execute([$info, $acronym]); |
|
| 586 | + ->execute([ $info, $acronym ]); |
|
| 587 | 587 | |
| 588 | 588 | return "Saved"; |
| 589 | 589 | } |
@@ -603,8 +603,8 @@ discard block |
||
| 603 | 603 | // var_dump($points); |
| 604 | 604 | $db = $di->get("dbqb");
|
| 605 | 605 | $db->connect() |
| 606 | - ->insert("Pictures", ["acronym", "name"])
|
|
| 607 | - ->execute([$acronym, $name]); |
|
| 606 | + ->insert("Pictures", [ "acronym", "name" ])
|
|
| 607 | + ->execute([ $acronym, $name ]); |
|
| 608 | 608 | |
| 609 | 609 | return "Saved"; |
| 610 | 610 | } |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | $res = $db->select("name")
|
| 627 | 627 | ->from("Pictures")
|
| 628 | 628 | ->where("acronym = ? OR acronym = ?")
|
| 629 | - ->execute(["default", $acronym]) |
|
| 629 | + ->execute([ "default", $acronym ]) |
|
| 630 | 630 | ->fetchAll(); |
| 631 | 631 | |
| 632 | 632 | return $res; |
@@ -649,8 +649,8 @@ discard block |
||
| 649 | 649 | |
| 650 | 650 | $db = $di->get("dbqb");
|
| 651 | 651 | $db->connect() |
| 652 | - ->insert("Answers", ["questionId", "acronym", "answer", "points", "created"])
|
|
| 653 | - ->execute([$questionId, $acronym, $answer, $points, $created]); |
|
| 652 | + ->insert("Answers", [ "questionId", "acronym", "answer", "points", "created" ])
|
|
| 653 | + ->execute([ $questionId, $acronym, $answer, $points, $created ]); |
|
| 654 | 654 | |
| 655 | 655 | return "Saved"; |
| 656 | 656 | } |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | $db = $di->get("dbqb");
|
| 670 | 670 | $db->connect(); |
| 671 | 671 | $sql = "DELETE FROM Comments WHERE id = ?;"; |
| 672 | - $db->execute($sql, [$id]); |
|
| 672 | + $db->execute($sql, [ $id ]); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | |
@@ -681,9 +681,9 @@ discard block |
||
| 681 | 681 | */ |
| 682 | 682 | function sessionDestroy() |
| 683 | 683 | {
|
| 684 | - $style = $_SESSION['AnaxStyleChooser'] ?? "css/mine.css"; |
|
| 684 | + $style = $_SESSION[ 'AnaxStyleChooser' ] ?? "css/mine.css"; |
|
| 685 | 685 | // Unset all of the session variables. |
| 686 | - $_SESSION = []; |
|
| 686 | + $_SESSION = [ ]; |
|
| 687 | 687 | |
| 688 | 688 | // If it's desired to kill the session, also delete the session cookie. |
| 689 | 689 | // Note: This will destroy the session, and not just the session data! |
@@ -693,17 +693,17 @@ discard block |
||
| 693 | 693 | session_name(), |
| 694 | 694 | '', |
| 695 | 695 | time() - 42000, |
| 696 | - $params["path"], |
|
| 697 | - $params["domain"], |
|
| 698 | - $params["secure"], |
|
| 699 | - $params["httponly"] |
|
| 696 | + $params[ "path" ], |
|
| 697 | + $params[ "domain" ], |
|
| 698 | + $params[ "secure" ], |
|
| 699 | + $params[ "httponly" ] |
|
| 700 | 700 | ); |
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | // Finally, destroy the session. |
| 704 | 704 | session_destroy(); |
| 705 | 705 | |
| 706 | - $_SESSION['AnaxStyleChooser'] = $style; |
|
| 706 | + $_SESSION[ 'AnaxStyleChooser' ] = $style; |
|
| 707 | 707 | |
| 708 | 708 | // $_SESSION["status"] = null; |
| 709 | 709 | // $_SESSION["acronym"] = null; |
@@ -301,46 +301,46 @@ |
||
| 301 | 301 | // Check if image file is a actual image or fake image |
| 302 | 302 | if(isset($_POST["submit"])) { |
| 303 | 303 | var_dump("smask"); |
| 304 | - $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); |
|
| 305 | - if($check !== false) { |
|
| 304 | + $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); |
|
| 305 | + if($check !== false) { |
|
| 306 | 306 | echo "File is an image - " . $check["mime"] . "."; |
| 307 | 307 | $uploadOk = 1; |
| 308 | - } else { |
|
| 308 | + } else { |
|
| 309 | 309 | echo "File is not an image."; |
| 310 | 310 | $uploadOk = 0; |
| 311 | - } |
|
| 311 | + } |
|
| 312 | 312 | } |
| 313 | 313 | // Check if file already exists |
| 314 | 314 | if (file_exists($target_file)) { |
| 315 | - echo "Sorry, file already exists."; |
|
| 316 | - $uploadOk = 0; |
|
| 315 | + echo "Sorry, file already exists."; |
|
| 316 | + $uploadOk = 0; |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | // Check file size |
| 320 | 320 | if ($_FILES["fileToUpload"]["size"] > 500000) { |
| 321 | - echo "Sorry, your file is too large."; |
|
| 322 | - $uploadOk = 0; |
|
| 321 | + echo "Sorry, your file is too large."; |
|
| 322 | + $uploadOk = 0; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | // Allow certain file formats |
| 326 | 326 | if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" |
| 327 | 327 | && $imageFileType != "gif" ) { |
| 328 | - echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; |
|
| 329 | - $uploadOk = 0; |
|
| 328 | + echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; |
|
| 329 | + $uploadOk = 0; |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | // Check if $uploadOk is set to 0 by an error |
| 333 | 333 | if ($uploadOk == 0) { |
| 334 | - echo "Sorry, your file was not uploaded."; |
|
| 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)) { |
|
| 337 | + if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { |
|
| 338 | 338 | echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded."; |
| 339 | 339 | $res->setProfilePicture($this->di, $acronym, $_FILES["fileToUpload"]); |
| 340 | 340 | $res->addProfilePicture($this->di, $acronym, $_FILES["fileToUpload"]); |
| 341 | - } else { |
|
| 341 | + } else { |
|
| 342 | 342 | echo "Sorry, there was an error uploading your file."; |
| 343 | - } |
|
| 343 | + } |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | |
@@ -50,7 +50,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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); |
@@ -630,9 +630,9 @@ discard block |
||
| 630 | 630 | $res = new Functions(); |
| 631 | 631 | $comment = $res->getOneQuestionComment($this->di, $commentId); |
| 632 | 632 | |
| 633 | - $acronym = $comment[0]->acronym; |
|
| 634 | - $answer = $comment[0]->comment; |
|
| 635 | - $created = $comment[0]->created; |
|
| 633 | + $acronym = $comment[ 0 ]->acronym; |
|
| 634 | + $answer = $comment[ 0 ]->comment; |
|
| 635 | + $created = $comment[ 0 ]->created; |
|
| 636 | 636 | |
| 637 | 637 | // Save as answer. |
| 638 | 638 | $res->saveAnswer($this->di, $questionId, $acronym, $answer, $created); |
@@ -640,7 +640,7 @@ discard block |
||
| 640 | 640 | // Delete comment. |
| 641 | 641 | $res->deleteComment($this->di, $commentId); |
| 642 | 642 | |
| 643 | - var_dump($comment[0]->comment); |
|
| 643 | + var_dump($comment[ 0 ]->comment); |
|
| 644 | 644 | |
| 645 | 645 | // $page->add("anax/v2/article/default", [ |
| 646 | 646 | // "content" => "Hello", |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | // get profile picture of the user who made a question |
| 692 | 692 | $picture = $res->getProfileInfo($acronym, $this->di, "User", "picture"); |
| 693 | 693 | |
| 694 | - $question->picture = "<img src='{$baseURL}/image/profile/{$picture[0]->picture}{$size}'></img>"; |
|
| 694 | + $question->picture = "<img src='{$baseURL}/image/profile/{$picture[ 0 ]->picture}{$size}'></img>"; |
|
| 695 | 695 | // get all answers |
| 696 | 696 | $question->answers = $res->getQuestionAnswers($this->di, $questionId); |
| 697 | 697 | } |
@@ -704,9 +704,9 @@ discard block |
||
| 704 | 704 | |
| 705 | 705 | // get variables from posted checkbox form |
| 706 | 706 | $items = $request->getPost(); |
| 707 | - if ($items["items"] ?? null) { |
|
| 707 | + if ($items[ "items" ] ?? null) { |
|
| 708 | 708 | // visa endast info gällande de ikryssade taggarna |
| 709 | - foreach ($items["items"] as $val) { |
|
| 709 | + foreach ($items[ "items" ] as $val) { |
|
| 710 | 710 | // var_dump($val); |
| 711 | 711 | $questions = $res->getSomeQuestionsTags($this->di, $val); |
| 712 | 712 | // var_dump($questions); |
@@ -777,9 +777,9 @@ discard block |
||
| 777 | 777 | // var_dump($answers); |
| 778 | 778 | |
| 779 | 779 | // var_dump($comments); |
| 780 | - $qId = $question[0]->id; |
|
| 780 | + $qId = $question[ 0 ]->id; |
|
| 781 | 781 | // var_dump($qId); |
| 782 | - $acronym = $_SESSION["acronym"]; |
|
| 782 | + $acronym = $_SESSION[ "acronym" ]; |
|
| 783 | 783 | // var_dump($acronym); |
| 784 | 784 | |
| 785 | 785 | $form = new CreateCommentsForm($this->di, $acronym, $qId); |
@@ -794,7 +794,7 @@ discard block |
||
| 794 | 794 | $up = "<img src='../../../htdocs/image/up.png' width='30px'></img>"; |
| 795 | 795 | $down = "<img src='../../../htdocs/image/down.png' width='30px'></img>"; |
| 796 | 796 | |
| 797 | - $user = $_SESSION["acronym"]; |
|
| 797 | + $user = $_SESSION[ "acronym" ]; |
|
| 798 | 798 | |
| 799 | 799 | $page->add("view-question", [ |
| 800 | 800 | "res" => $question, |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | "qId" => $id, |
| 812 | 812 | ]); |
| 813 | 813 | |
| 814 | - $tags = $question[0]->tags ?? "Grönsaker, Plantor"; |
|
| 814 | + $tags = $question[ 0 ]->tags ?? "Grönsaker, Plantor"; |
|
| 815 | 815 | $tagsArray = explode("; ", $tags); |
| 816 | 816 | |
| 817 | 817 | $page->add("show-tags", [ |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | "content" => $content, |
| 831 | 831 | ], "sidebar-right"); |
| 832 | 832 | |
| 833 | - $page->add("ask-tip", [], "sidebar-right"); |
|
| 833 | + $page->add("ask-tip", [ ], "sidebar-right"); |
|
| 834 | 834 | |
| 835 | 835 | return $page->render([ |
| 836 | 836 | "title" => "View question", |
@@ -929,14 +929,14 @@ discard block |
||
| 929 | 929 | // get profile picture of the user who made a question |
| 930 | 930 | $picture = $res->getProfileInfo($acronym, $this->di, "User", "picture"); |
| 931 | 931 | |
| 932 | - $question->picture = "<img src='{$baseURL}/image/profile/{$picture[0]->picture}{$size}'></img>"; |
|
| 932 | + $question->picture = "<img src='{$baseURL}/image/profile/{$picture[ 0 ]->picture}{$size}'></img>"; |
|
| 933 | 933 | // get all answers |
| 934 | 934 | $question->answers = $res->getQuestionAnswers($this->di, $questionId); |
| 935 | 935 | } |
| 936 | 936 | |
| 937 | 937 | $filter = new \Anax\TextFilter\TextFilter(); |
| 938 | 938 | |
| 939 | - $user = $_SESSION["acronym"]; |
|
| 939 | + $user = $_SESSION[ "acronym" ]; |
|
| 940 | 940 | |
| 941 | 941 | $page->add("view-tag-questions", [ |
| 942 | 942 | "questions" => $questions, |