Passed
Branch master (af5a34)
by Elia
01:48
created
Category
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/create/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
         returnError($e);
40 40
     }
41 41
 
42
-} catch(Exception $e) {
42
+} catch (Exception $e) {
43 43
     returnForbidden($e);
44 44
 }
45 45
 
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/objects/template.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,19 +12,19 @@  discard block
 block discarded – undo
12 12
     public $amount;
13 13
     public $image;
14 14
 
15
-    public function __construct($db){
15
+    public function __construct($db) {
16 16
         $this->conn = $db;
17 17
     }
18 18
 
19
-    function read($amount = false, $order = 'DESC'){
19
+    function read($amount = false, $order = 'DESC') {
20 20
 
21 21
         $query = "
22 22
         SELECT ID as id, Title as title, DefaultAmout as amount, Calories as calories, Image as image
23 23
         FROM ". $this->db_table . "
24 24
         WHERE UserID = :userid";
25 25
 
26
-        if($amount){
27
-            $query .= " LIMIT ". $amount;
26
+        if ($amount) {
27
+            $query .= " LIMIT " . $amount;
28 28
         }
29 29
 
30 30
         $stmt = $this->conn->prepare($query);
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
     }
37 37
 
38
-    function create(){
38
+    function create() {
39 39
 
40 40
         $query = "
41 41
             INSERT INTO " . $this->db_table . " SET
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
             Image = :image
47 47
         ";
48 48
 
49
-        $this->userid=htmlspecialchars(strip_tags($this->userid));
50
-        $this->title=htmlspecialchars(strip_tags($this->title));
51
-        $this->calories=htmlspecialchars(strip_tags($this->calories));
52
-        $this->amount=htmlspecialchars(strip_tags($this->amount));
53
-        $this->image=htmlspecialchars(strip_tags($this->image));
49
+        $this->userid = htmlspecialchars(strip_tags($this->userid));
50
+        $this->title = htmlspecialchars(strip_tags($this->title));
51
+        $this->calories = htmlspecialchars(strip_tags($this->calories));
52
+        $this->amount = htmlspecialchars(strip_tags($this->amount));
53
+        $this->image = htmlspecialchars(strip_tags($this->image));
54 54
 
55 55
         $stmt = $this->conn->prepare($query);
56 56
         $stmt->bindParam(":userid", $this->userid);
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         $stmt->bindParam(":calories", $this->calories);
60 60
         $stmt->bindParam(":image", $this->image);
61 61
 
62
-        if($stmt->execute()){
62
+        if ($stmt->execute()) {
63 63
             $this->id = $this->conn->lastInsertId();
64 64
             return true;
65 65
         }
@@ -68,21 +68,21 @@  discard block
 block discarded – undo
68 68
 
69 69
     }
70 70
 
71
-    function delete(){
71
+    function delete() {
72 72
 
73 73
         $query = "
74 74
         DELETE FROM " . $this->db_table . "
75 75
         WHERE ID = :id AND UserID = :userid
76 76
         ";
77 77
 
78
-        $this->id=htmlspecialchars(strip_tags($this->id));
79
-        $this->userid=htmlspecialchars(strip_tags($this->userid));
78
+        $this->id = htmlspecialchars(strip_tags($this->id));
79
+        $this->userid = htmlspecialchars(strip_tags($this->userid));
80 80
 
81 81
         $stmt = $this->conn->prepare($query);
82 82
         $stmt->bindParam(":id", $this->id);
83 83
         $stmt->bindParam(":userid", $this->userid);
84 84
 
85
-        if($stmt->execute()){
85
+        if ($stmt->execute()) {
86 86
 
87 87
             return true;
88 88
 
Please login to merge, or discard this patch.
_config/objects/weight.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
     public $weight;
11 11
     public $measuredate;
12 12
 
13
-    public function __construct($db){
13
+    public function __construct($db) {
14 14
         $this->conn = $db;
15 15
     }
16 16
 
17
-    function read($amount = false, $order = 'DESC'){
17
+    function read($amount = false, $order = 'DESC') {
18 18
 
19 19
         $query = "
20 20
         SELECT ID as id, Weight as weight, MeasureDate as measuredate, CreationDate as creationdate
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
         WHERE UserID = :userid
23 23
         ORDER BY CreationDate ". $order;
24 24
 
25
-        if($amount){
26
-            $query .= " LIMIT ". $amount;
25
+        if ($amount) {
26
+            $query .= " LIMIT " . $amount;
27 27
         }
28 28
 
29 29
         $stmt = $this->conn->prepare($query);
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
     }
36 36
 
37
-    function create(){
37
+    function create() {
38 38
 
39 39
         $query = "
40 40
             INSERT INTO " . $this->db_table . " SET
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
             MeasureDate = :measuredate
44 44
         ";
45 45
 
46
-        $this->userid=htmlspecialchars(strip_tags($this->userid));
47
-        $this->weight=htmlspecialchars(strip_tags($this->weight));
48
-        $this->measuredate=htmlspecialchars(strip_tags($this->measuredate));
46
+        $this->userid = htmlspecialchars(strip_tags($this->userid));
47
+        $this->weight = htmlspecialchars(strip_tags($this->weight));
48
+        $this->measuredate = htmlspecialchars(strip_tags($this->measuredate));
49 49
 
50 50
         $stmt = $this->conn->prepare($query);
51 51
         $stmt->bindParam(":userid", $this->userid);
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         $stmt->bindParam(":measuredate", $this->measuredate);
54 54
 
55 55
 
56
-        if($stmt->execute()){
56
+        if ($stmt->execute()) {
57 57
             $this->id = $this->conn->lastInsertId();
58 58
             return true;
59 59
         }
@@ -62,22 +62,22 @@  discard block
 block discarded – undo
62 62
 
63 63
     }
64 64
 
65
-    function delete(){
65
+    function delete() {
66 66
 
67 67
         $query = "
68 68
         DELETE FROM " . $this->db_table . "
69 69
         WHERE ID = :id AND UserID = :userid
70 70
         ";
71 71
 
72
-        $this->id=htmlspecialchars(strip_tags($this->id));
73
-        $this->userid=htmlspecialchars(strip_tags($this->userid));
72
+        $this->id = htmlspecialchars(strip_tags($this->id));
73
+        $this->userid = htmlspecialchars(strip_tags($this->userid));
74 74
 
75 75
         $stmt = $this->conn->prepare($query);
76 76
         $stmt->bindParam(":id", $this->id);
77 77
         $stmt->bindParam(":userid", $this->userid);
78 78
 
79 79
 
80
-        if($stmt->execute()){
80
+        if ($stmt->execute()) {
81 81
 
82 82
             return true;
83 83
 
Please login to merge, or discard this patch.
_config/objects/user.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
     public $birthdate;
18 18
     public $aims;
19 19
 
20
-    public function __construct($db){
20
+    public function __construct($db) {
21 21
         $this->conn = $db;
22 22
     }
23 23
 
24
-    function create(){
24
+    function create() {
25 25
 
26 26
         $query = "
27 27
         INSERT INTO " . $this->db_table . " SET
@@ -32,27 +32,27 @@  discard block
 block discarded – undo
32 32
 
33 33
         $stmt = $this->conn->prepare($query);
34 34
 
35
-        if(strlen($this->firstname) > 0 && strlen($this->lastname) > 0){
36
-            $this->firstname=htmlspecialchars(strip_tags($this->firstname));
37
-            $this->lastname=htmlspecialchars(strip_tags($this->lastname));
35
+        if (strlen($this->firstname)>0 && strlen($this->lastname)>0) {
36
+            $this->firstname = htmlspecialchars(strip_tags($this->firstname));
37
+            $this->lastname = htmlspecialchars(strip_tags($this->lastname));
38 38
         } else {
39 39
             throw new InvalidArgumentException('Invalid Firstname or Lastname');
40 40
         }
41 41
 
42
-        if($this->emailExists()){
42
+        if ($this->emailExists()) {
43 43
             throw new InvalidArgumentException('E-Mail already in use');
44 44
         }
45 45
 
46
-        if(filter_var($this->email, FILTER_VALIDATE_EMAIL)){
47
-            $this->email=htmlspecialchars(strip_tags($this->email));
46
+        if (filter_var($this->email, FILTER_VALIDATE_EMAIL)) {
47
+            $this->email = htmlspecialchars(strip_tags($this->email));
48 48
         } else {
49 49
             throw new InvalidArgumentException('Invalid E-Mail Adress');
50 50
         }
51 51
 
52
-        if (strlen($this->password) < 8 && !preg_match("#[0-9]+#", $this->password) && !preg_match("#[a-zA-Z]+#", $this->password)) {
52
+        if (strlen($this->password)<8 && !preg_match("#[0-9]+#", $this->password) && !preg_match("#[a-zA-Z]+#", $this->password)) {
53 53
             throw new InvalidArgumentException('Invalid Password');
54 54
         } else {
55
-            $this->password=htmlspecialchars(strip_tags($this->password));
55
+            $this->password = htmlspecialchars(strip_tags($this->password));
56 56
         }
57 57
 
58 58
         $stmt->bindParam(':firstname', $this->firstname);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         $password_hash = password_hash($this->password, PASSWORD_BCRYPT);
63 63
         $stmt->bindParam(':password', $password_hash);
64 64
 
65
-        if($stmt->execute()){
65
+        if ($stmt->execute()) {
66 66
             return true;
67 67
         }
68 68
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     }
72 72
 
73
-    function emailExists(){
73
+    function emailExists() {
74 74
 
75 75
         $query = "
76 76
         SELECT ID, Firstname, Lastname, Email, Password, Language, IsFemale, Birthdate, Height, Aim_Weight, Aim_Date
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
         LIMIT 0,1
80 80
         ";
81 81
 
82
-        $this->email=htmlspecialchars(strip_tags($this->email));
82
+        $this->email = htmlspecialchars(strip_tags($this->email));
83 83
 
84 84
         $stmt = $this->conn->prepare($query);
85 85
         $stmt->bindParam(1, $this->email);
86 86
         $stmt->execute();
87
-        if($stmt->rowCount()>0){
87
+        if ($stmt->rowCount()>0) {
88 88
 
89 89
             $row = $stmt->fetch(PDO::FETCH_ASSOC);
90 90
             $this->id = $row['ID'];
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
     }
109 109
 
110
-    public function update(){
110
+    public function update() {
111 111
 
112 112
         $query = "
113 113
         UPDATE " . $this->db_table . " SET
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
         ";
124 124
 
125 125
         $stmt = $this->conn->prepare($query);
126
-        $this->firstname=htmlspecialchars(strip_tags($this->firstname));
127
-        $this->lastname=htmlspecialchars(strip_tags($this->lastname));
128
-        $this->language=htmlspecialchars(strip_tags($this->language));
129
-        $this->isFemale=htmlspecialchars(strip_tags($this->isFemale));
130
-        $this->birthdate=htmlspecialchars(strip_tags($this->birthdate));
131
-        $this->height=htmlspecialchars(strip_tags($this->height));
132
-        $this->aims->weight=htmlspecialchars(strip_tags($this->aims->weight));
133
-        $this->aims->date=htmlspecialchars(strip_tags($this->aims->date));
126
+        $this->firstname = htmlspecialchars(strip_tags($this->firstname));
127
+        $this->lastname = htmlspecialchars(strip_tags($this->lastname));
128
+        $this->language = htmlspecialchars(strip_tags($this->language));
129
+        $this->isFemale = htmlspecialchars(strip_tags($this->isFemale));
130
+        $this->birthdate = htmlspecialchars(strip_tags($this->birthdate));
131
+        $this->height = htmlspecialchars(strip_tags($this->height));
132
+        $this->aims->weight = htmlspecialchars(strip_tags($this->aims->weight));
133
+        $this->aims->date = htmlspecialchars(strip_tags($this->aims->date));
134 134
 
135 135
         $stmt->bindParam(':firstname', $this->firstname);
136 136
         $stmt->bindParam(':lastname', $this->lastname);
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         $stmt->bindParam(':aim_date', $this->aims->date);
143 143
         $stmt->bindParam(':id', $this->id);
144 144
 
145
-        if($stmt->execute()){
145
+        if ($stmt->execute()) {
146 146
             return true;
147 147
         }
148 148
 
Please login to merge, or discard this patch.
_config/objects/calorie.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
     public $amount;
13 13
     public $date;
14 14
 
15
-    public function __construct($db){
15
+    public function __construct($db) {
16 16
         $this->conn = $db;
17 17
     }
18 18
 
19
-    function readByDay($amount = false, $order = 'DESC'){
19
+    function readByDay($amount = false, $order = 'DESC') {
20 20
 
21 21
         $query = "
22 22
         SELECT ID as id, Title as title, Calories as calories, Amount as amount
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
     }
36 36
 
37
-    function readDays($order = 'DESC'){
37
+    function readDays($order = 'DESC') {
38 38
 
39 39
         $query = "
40 40
         SELECT Date as date FROM ". $this->db_table . "
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     }
52 52
 
53
-    function create(){
53
+    function create() {
54 54
 
55 55
         $query = "
56 56
         INSERT INTO " . $this->db_table . " SET
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
         Date = :date
62 62
         ";
63 63
 
64
-        $this->userid=htmlspecialchars(strip_tags($this->userid));
65
-        $this->title=htmlspecialchars(strip_tags($this->title));
66
-        $this->calories=htmlspecialchars(strip_tags($this->calories));
67
-        $this->amount=htmlspecialchars(strip_tags($this->amount));
68
-        $this->date=htmlspecialchars(strip_tags($this->date));
64
+        $this->userid = htmlspecialchars(strip_tags($this->userid));
65
+        $this->title = htmlspecialchars(strip_tags($this->title));
66
+        $this->calories = htmlspecialchars(strip_tags($this->calories));
67
+        $this->amount = htmlspecialchars(strip_tags($this->amount));
68
+        $this->date = htmlspecialchars(strip_tags($this->date));
69 69
 
70 70
         $stmt = $this->conn->prepare($query);
71 71
         $stmt->bindParam(":userid", $this->userid);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         $stmt->bindParam(":amount", $this->amount);
75 75
         $stmt->bindParam(":date", $this->date);
76 76
 
77
-        if($stmt->execute()){
77
+        if ($stmt->execute()) {
78 78
             $this->id = $this->conn->lastInsertId();
79 79
             return true;
80 80
         }
@@ -83,21 +83,21 @@  discard block
 block discarded – undo
83 83
 
84 84
     }
85 85
 
86
-    function delete(){
86
+    function delete() {
87 87
 
88 88
         $query = "
89 89
         DELETE FROM " . $this->db_table . "
90 90
         WHERE ID = :id AND UserID = :userid
91 91
         ";
92 92
 
93
-        $this->id=htmlspecialchars(strip_tags($this->id));
94
-        $this->userid=htmlspecialchars(strip_tags($this->userid));
93
+        $this->id = htmlspecialchars(strip_tags($this->id));
94
+        $this->userid = htmlspecialchars(strip_tags($this->userid));
95 95
 
96 96
         $stmt = $this->conn->prepare($query);
97 97
         $stmt->bindParam(":id", $this->id);
98 98
         $stmt->bindParam(":userid", $this->userid);
99 99
 
100
-        if($stmt->execute()){
100
+        if ($stmt->execute()) {
101 101
 
102 102
             return true;
103 103
 
Please login to merge, or discard this patch.