Passed
Push — master ( b9fe7d...96ae3b )
by Elia
01:25
created
calorie/delete/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
         returnError($e);
37 37
     }
38 38
 
39
-} catch(Exception $e) {
39
+} catch (Exception $e) {
40 40
     returnForbidden($e);
41 41
 }
42 42
 
Please login to merge, or discard this patch.
calorie/read/byDay/index.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
     $stmt = $calorie->readByDay();
33 33
     $num = $stmt->rowCount();
34 34
 
35
-    if($num>0){
35
+    if ($num>0) {
36 36
 
37
-        $calories_arr=array();
38
-        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
37
+        $calories_arr = array();
38
+        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
39 39
 
40 40
             extract($row);
41 41
             $calorie_item = array(
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         returnNoData();
54 54
     }
55 55
 
56
-} catch(Exception $e) {
56
+} catch (Exception $e) {
57 57
     returnForbidden($e);
58 58
 }
59 59
 
Please login to merge, or discard this patch.
calorie/read/days/index.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
     $stmt = $calorie->readDays();
32 32
     $num = $stmt->rowCount();
33 33
 
34
-    if($num>0){
34
+    if ($num>0) {
35 35
 
36 36
         $i = 1;
37
-        $val_arr=array();
37
+        $val_arr = array();
38 38
 
39
-        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
39
+        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
40 40
             extract($row);
41 41
             $val_item = array(
42 42
                 "date" => $date,
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         returnNoData();
52 52
     }
53 53
 
54
-} catch(Exception $e) {
54
+} catch (Exception $e) {
55 55
     returnForbidden($e);
56 56
 }
57 57
 
Please login to merge, or discard this patch.
_config/headers.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
 header("Access-Control-Max-Age: 3600");
7 7
 header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
8 8
 
9
-if($_SERVER['REQUEST_METHOD'] === "OPTIONS"){
9
+if ($_SERVER['REQUEST_METHOD'] === "OPTIONS") {
10 10
     die();
11 11
 }
12 12
 
Please login to merge, or discard this patch.
_config/core.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     "expireAt" => time() + (604800),
15 15
 );
16 16
 
17
-function authenticate(){
17
+function authenticate() {
18 18
     if (isset(getallheaders()['Authorization'])) {
19 19
         list($type, $data) = explode(" ", getallheaders()['Authorization'], 2);
20 20
         if (strcasecmp($type, "Bearer") == 0) {
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
     }
28 28
 }
29 29
 
30
-function returnSuccess($data = false){
30
+function returnSuccess($data = false) {
31 31
     http_response_code(200);
32
-    if($data){
32
+    if ($data) {
33 33
         echo json_encode(array(
34 34
             "status" => "success",
35 35
             "message" => "Request successfully handled",
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     die();
45 45
 }
46 46
 
47
-function returnNoData(){
47
+function returnNoData() {
48 48
     http_response_code(204);
49 49
     echo json_encode(array(
50 50
     "status" => "success",
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
     die();
54 54
 }
55 55
 
56
-function returnForbidden($reason = false){
56
+function returnForbidden($reason = false) {
57 57
     http_response_code(403);
58
-    if($reason){
58
+    if ($reason) {
59 59
         echo json_encode(array(
60 60
         "status" => "unauthorized",
61 61
         "message" => "User is not authorized to perform this action",
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
     die();
71 71
 }
72 72
 
73
-function returnBadRequest($reason = false){
73
+function returnBadRequest($reason = false) {
74 74
     http_response_code(400);
75
-    if($reason){
75
+    if ($reason) {
76 76
         echo json_encode(array(
77 77
         "status" => "failed",
78 78
         "message" => "Bad Request: Values are wrong or missing.",
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
     die();
88 88
 }
89 89
 
90
-function returnError($reason = false){
90
+function returnError($reason = false) {
91 91
     http_response_code(500);
92
-    if($reason){
92
+    if ($reason) {
93 93
         echo json_encode(array(
94 94
         "status" => "error",
95 95
         "message" => "An internal error occured",
Please login to merge, or discard this patch.
_config/database.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
         private $password = "";
10 10
 
11 11
         public $conn;
12
-        public function connect(){
12
+        public function connect() {
13 13
 
14 14
             $this->conn = null;
15 15
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
                 $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
19 19
 
20
-            } catch(PDOException $exception) {
20
+            } catch (PDOException $exception) {
21 21
 
22 22
                 echo "Connection error: " . $exception->getMessage();
23 23
 
Please login to merge, or discard this patch.
template/create/upload/index.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 
28 28
     $decoded = JWT::decode($token, $token_conf['secret'], $token_conf['algorithm']);
29 29
 
30
-    if($_FILES['img']['type'] == 'image/png'){
30
+    if ($_FILES['img']['type'] == 'image/png') {
31 31
         $source = imagecreatefrompng($_FILES['img']['tmp_name']);
32
-    } else if($_FILES['img']['type'] == 'image/jpeg') {
32
+    } else if ($_FILES['img']['type'] == 'image/jpeg') {
33 33
         $source = imagecreatefromjpeg($_FILES['img']['tmp_name']);
34
-    } else if($_FILES['img']['type'] == 'image/gif') {
34
+    } else if ($_FILES['img']['type'] == 'image/gif') {
35 35
         $source = imagecreatefromgif($_FILES['img']['tmp_name']);
36 36
     } else {
37 37
         returnBadRequest();
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     }
40 40
 
41 41
     list($width, $height) = getimagesize($_FILES['img']['tmp_name']);
42
-    $imageName = "minska-U".$decoded->data->id."U-T".time()."T-R".rand(100,999)."R.jpg";
42
+    $imageName = "minska-U" . $decoded->data->id . "U-T" . time() . "T-R" . rand(100, 999) . "R.jpg";
43 43
     $imageWidth = 300;
44 44
     $imageHeight = $height*($imageWidth/$width);
45 45
     $imageQuality = 80;
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
     $rendered = imagecreatetruecolor($imageWidth, $imageHeight);
49 49
     imagecopyresampled($rendered, $source, 0, 0, 0, 0, $imageWidth, $imageHeight, $width, $height);
50
-    imagejpeg($rendered, $uploaddir ."/".$imageName, $imageQuality);
50
+    imagejpeg($rendered, $uploaddir . "/" . $imageName, $imageQuality);
51 51
 
52 52
     returnSuccess($imageName);
53 53
 
Please login to merge, or discard this patch.
template/read/index.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
     $stmt = $template->read();
32 32
     $num = $stmt->rowCount();
33 33
 
34
-    if($num>0){
34
+    if ($num>0) {
35 35
 
36
-        $templates_arr=array();
36
+        $templates_arr = array();
37 37
 
38
-        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
38
+        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
39 39
             extract($row);
40 40
             $template_item = array(
41 41
                 "id" => $id,
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         returnNoData();
54 54
     }
55 55
 
56
-} catch(Exception $e){
56
+} catch (Exception $e) {
57 57
     returnForbidden($e);
58 58
 }
59 59
 
Please login to merge, or discard this patch.
weight/read/index.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
     $stmt = $weight->read();
32 32
     $num = $stmt->rowCount();
33 33
 
34
-    if($num>0){
34
+    if ($num>0) {
35 35
 
36
-        $weights_arr=array();
36
+        $weights_arr = array();
37 37
 
38
-        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
38
+        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
39 39
             extract($row);
40 40
             $weight_item = array(
41 41
                 "id" => $id,
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         returnNoData();
52 52
     }
53 53
 
54
-} catch(Exception $e){
54
+} catch (Exception $e) {
55 55
     returnForbidden($e);
56 56
 }
57 57
 
Please login to merge, or discard this patch.