@@ -18,11 +18,11 @@ discard block |
||
| 18 | 18 | public $birthdate; |
| 19 | 19 | public $aims; |
| 20 | 20 | |
| 21 | - public function __construct($db){ |
|
| 21 | + public function __construct($db) { |
|
| 22 | 22 | $this->conn = $db; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function create(){ |
|
| 25 | + public function create() { |
|
| 26 | 26 | |
| 27 | 27 | $query = " |
| 28 | 28 | INSERT INTO " . $this->db_table . " SET |
@@ -33,23 +33,23 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | $stmt = $this->conn->prepare($query); |
| 35 | 35 | |
| 36 | - if(strlen($this->firstname) > 0 && strlen($this->lastname) > 0){ |
|
| 37 | - $this->firstname=htmlspecialchars(strip_tags($this->firstname)); |
|
| 38 | - $this->lastname=htmlspecialchars(strip_tags($this->lastname)); |
|
| 36 | + if (strlen($this->firstname)>0 && strlen($this->lastname)>0) { |
|
| 37 | + $this->firstname = htmlspecialchars(strip_tags($this->firstname)); |
|
| 38 | + $this->lastname = htmlspecialchars(strip_tags($this->lastname)); |
|
| 39 | 39 | } else { |
| 40 | 40 | throw new InvalidArgumentException('Invalid Firstname or Lastname'); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if($this->emailExists() || !filter_var($this->email, FILTER_VALIDATE_EMAIL)){ |
|
| 43 | + if ($this->emailExists() || !filter_var($this->email, FILTER_VALIDATE_EMAIL)) { |
|
| 44 | 44 | throw new InvalidArgumentException('E-Mail problematic'); |
| 45 | 45 | } else { |
| 46 | - $this->email=htmlspecialchars(strip_tags($this->email)); |
|
| 46 | + $this->email = htmlspecialchars(strip_tags($this->email)); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if (strlen($this->password) < 8 && !preg_match("#[0-9]+#", $this->password) && !preg_match("#[a-zA-Z]+#", $this->password)) { |
|
| 49 | + if (strlen($this->password)<8 && !preg_match("#[0-9]+#", $this->password) && !preg_match("#[a-zA-Z]+#", $this->password)) { |
|
| 50 | 50 | throw new InvalidArgumentException('Invalid Password'); |
| 51 | 51 | } else { |
| 52 | - $this->password=htmlspecialchars(strip_tags($this->password)); |
|
| 52 | + $this->password = htmlspecialchars(strip_tags($this->password)); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | $stmt->bindParam(':firstname', $this->firstname); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $password_hash = password_hash($this->password, PASSWORD_BCRYPT); |
| 60 | 60 | $stmt->bindParam(':password', $password_hash); |
| 61 | 61 | |
| 62 | - if($stmt->execute()){ |
|
| 62 | + if ($stmt->execute()) { |
|
| 63 | 63 | return true; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function emailExists(){ |
|
| 70 | + public function emailExists() { |
|
| 71 | 71 | |
| 72 | 72 | $query = " |
| 73 | 73 | SELECT ID, Firstname, Lastname, Email, Password, Language, IsFemale, Birthdate, Height, Aim_Weight, Aim_Date |
@@ -76,12 +76,12 @@ discard block |
||
| 76 | 76 | LIMIT 0,1 |
| 77 | 77 | "; |
| 78 | 78 | |
| 79 | - $this->email=htmlspecialchars(strip_tags($this->email)); |
|
| 79 | + $this->email = htmlspecialchars(strip_tags($this->email)); |
|
| 80 | 80 | |
| 81 | 81 | $stmt = $this->conn->prepare($query); |
| 82 | 82 | $stmt->bindParam(1, $this->email); |
| 83 | 83 | $stmt->execute(); |
| 84 | - if($stmt->rowCount()>0){ |
|
| 84 | + if ($stmt->rowCount()>0) { |
|
| 85 | 85 | |
| 86 | 86 | $row = $stmt->fetch(PDO::FETCH_ASSOC); |
| 87 | 87 | $this->id = $row['ID']; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - public function update(){ |
|
| 107 | + public function update() { |
|
| 108 | 108 | |
| 109 | 109 | $query = " |
| 110 | 110 | UPDATE " . $this->db_table . " SET |
@@ -120,14 +120,14 @@ discard block |
||
| 120 | 120 | "; |
| 121 | 121 | |
| 122 | 122 | $stmt = $this->conn->prepare($query); |
| 123 | - $this->firstname=htmlspecialchars(strip_tags($this->firstname)); |
|
| 124 | - $this->lastname=htmlspecialchars(strip_tags($this->lastname)); |
|
| 125 | - $this->language=htmlspecialchars(strip_tags($this->language)); |
|
| 126 | - $this->isFemale=htmlspecialchars(strip_tags($this->isFemale)); |
|
| 127 | - $this->birthdate=htmlspecialchars(strip_tags($this->birthdate)); |
|
| 128 | - $this->height=htmlspecialchars(strip_tags($this->height)); |
|
| 129 | - $this->aims->weight=htmlspecialchars(strip_tags($this->aims->weight)); |
|
| 130 | - $this->aims->date=htmlspecialchars(strip_tags($this->aims->date)); |
|
| 123 | + $this->firstname = htmlspecialchars(strip_tags($this->firstname)); |
|
| 124 | + $this->lastname = htmlspecialchars(strip_tags($this->lastname)); |
|
| 125 | + $this->language = htmlspecialchars(strip_tags($this->language)); |
|
| 126 | + $this->isFemale = htmlspecialchars(strip_tags($this->isFemale)); |
|
| 127 | + $this->birthdate = htmlspecialchars(strip_tags($this->birthdate)); |
|
| 128 | + $this->height = htmlspecialchars(strip_tags($this->height)); |
|
| 129 | + $this->aims->weight = htmlspecialchars(strip_tags($this->aims->weight)); |
|
| 130 | + $this->aims->date = htmlspecialchars(strip_tags($this->aims->date)); |
|
| 131 | 131 | |
| 132 | 132 | $stmt->bindParam(':firstname', $this->firstname); |
| 133 | 133 | $stmt->bindParam(':lastname', $this->lastname); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $stmt->bindParam(':aim_date', $this->aims->date); |
| 140 | 140 | $stmt->bindParam(':id', $this->id); |
| 141 | 141 | |
| 142 | - if($stmt->execute()){ |
|
| 142 | + if ($stmt->execute()) { |
|
| 143 | 143 | return true; |
| 144 | 144 | } |
| 145 | 145 | |