@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $user->birthdate = $data->birthdate; |
| 37 | 37 | $user->aims = $data->aims; |
| 38 | 38 | |
| 39 | - if($user->update()){ |
|
| 39 | + if ($user->update()) { |
|
| 40 | 40 | |
| 41 | 41 | $token = array( |
| 42 | 42 | "iss" => $token_conf['issuer'], |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | returnError(); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - } catch (Exception $e){ |
|
| 66 | + } catch (Exception $e) { |
|
| 67 | 67 | returnForbidden($e); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | $user->email = $data->email; |
| 23 | 23 | $email_exists = $user->emailExists(); |
| 24 | 24 | |
| 25 | -if($email_exists && password_verify($data->password, $user->password)){ |
|
| 25 | +if ($email_exists && password_verify($data->password, $user->password)) { |
|
| 26 | 26 | |
| 27 | 27 | $token = array( |
| 28 | 28 | "iss" => $token_conf['issuer'], |
@@ -12,11 +12,11 @@ discard block |
||
| 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 | - public function readByDay($amount = false, $order = 'DESC'){ |
|
| 19 | + public 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 |
||
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function readDays($order = 'DESC'){ |
|
| 37 | + public 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 |
||
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function create(){ |
|
| 53 | + public function create() { |
|
| 54 | 54 | |
| 55 | 55 | $query = " |
| 56 | 56 | INSERT INTO " . $this->db_table . " SET |
@@ -61,11 +61,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function delete(){ |
|
| 86 | + public 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 | |
@@ -17,11 +17,11 @@ discard block |
||
| 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 | - public function create(){ |
|
| 24 | + public function create() { |
|
| 25 | 25 | |
| 26 | 26 | $query = " |
| 27 | 27 | INSERT INTO " . $this->db_table . " SET |
@@ -32,27 +32,27 @@ discard block |
||
| 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 |
||
| 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 |
||
| 70 | 70 | |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function emailExists(){ |
|
| 73 | + public 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -12,19 +12,19 @@ discard block |
||
| 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 | - public function read($amount = false, $order = 'DESC'){ |
|
| 19 | + public 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 |
||
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function create(){ |
|
| 38 | + public function create() { |
|
| 39 | 39 | |
| 40 | 40 | $query = " |
| 41 | 41 | INSERT INTO " . $this->db_table . " SET |
@@ -46,11 +46,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - public function delete(){ |
|
| 71 | + public 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 | |
@@ -10,11 +10,11 @@ discard block |
||
| 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 | - public function read($amount = false, $order = 'DESC'){ |
|
| 17 | + public 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 |
||
| 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 |
||
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function create(){ |
|
| 37 | + public function create() { |
|
| 38 | 38 | |
| 39 | 39 | $query = " |
| 40 | 40 | INSERT INTO " . $this->db_table . " SET |
@@ -43,9 +43,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public function delete(){ |
|
| 65 | + public 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 | |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | returnError($e); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -} catch(Exception $e) { |
|
| 39 | +} catch (Exception $e) { |
|
| 40 | 40 | returnForbidden($e); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | returnError($e); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -} catch(Exception $e) { |
|
| 39 | +} catch (Exception $e) { |
|
| 40 | 40 | returnForbidden($e); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | returnError($e); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -} catch(Exception $e) { |
|
| 39 | +} catch (Exception $e) { |
|
| 40 | 40 | returnForbidden($e); |
| 41 | 41 | } |
| 42 | 42 | |