@@ -72,8 +72,7 @@ |
||
| 72 | 72 | return json_encode($this->error); |
| 73 | 73 | } |
| 74 | 74 | return json_encode(["Error" => "You are not registered, ".$this->connect->error ]); |
| 75 | - } |
|
| 76 | - else |
|
| 75 | + } else |
|
| 77 | 76 | { |
| 78 | 77 | return json_encode($this->error); |
| 79 | 78 | } |
@@ -44,8 +44,7 @@ |
||
| 44 | 44 | if(filter_var($email, FILTER_VALIDATE_EMAIL) == false) |
| 45 | 45 | { |
| 46 | 46 | $this->onError("email", " *Enter correct Email address"); |
| 47 | - } |
|
| 48 | - else if($this->obValidate->validateEmailInDb($email) === 1) |
|
| 47 | + } else if($this->obValidate->validateEmailInDb($email) === 1) |
|
| 49 | 48 | { |
| 50 | 49 | $this->onError("email", " *Email is already registered"); |
| 51 | 50 | } |
@@ -14,8 +14,9 @@ |
||
| 14 | 14 | 'passLogin' => $password |
| 15 | 15 | ); |
| 16 | 16 | $result = $obLogin->authLogin($data); |
| 17 | - if(isset($result)) |
|
| 18 | - echo $result; |
|
| 19 | - else |
|
| 20 | - echo json_encode([]); |
|
| 21 | -} |
|
| 22 | 17 | \ No newline at end of file |
| 18 | + if(isset($result)) { |
|
| 19 | + echo $result; |
|
| 20 | + } else { |
|
| 21 | + echo json_encode([]); |
|
| 22 | + } |
|
| 23 | + } |
|
| 23 | 24 | \ No newline at end of file |
@@ -47,8 +47,7 @@ |
||
| 47 | 47 | if($substring != $userId) |
| 48 | 48 | { |
| 49 | 49 | $this->data($substring, $row); |
| 50 | - } |
|
| 51 | - else |
|
| 50 | + } else |
|
| 52 | 51 | { |
| 53 | 52 | $substring = substr($identifier, $length+1); |
| 54 | 53 | $this->Data($substring, $row); |
@@ -27,16 +27,20 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public function replyTo($msg) |
| 29 | 29 | { |
| 30 | - if(!empty($msg)) //checks for the value send |
|
| 30 | + if(!empty($msg)) { |
|
| 31 | + //checks for the value send |
|
| 31 | 32 | { |
| 32 | 33 | $userId = $msg->userId; |
| 34 | + } |
|
| 33 | 35 | $identifier = $msg->name; |
| 34 | 36 | $receiverID = $identifier; //stores id of the person whom message is to be sent |
| 35 | 37 | |
| 36 | - if($identifier > $userId) // geneate specific unique code to store messages |
|
| 38 | + if($identifier > $userId) { |
|
| 39 | + // geneate specific unique code to store messages |
|
| 37 | 40 | $identifier = $userId . ":" . $identifier; |
| 38 | - else |
|
| 39 | - $identifier = $identifier . ":" . $userId; |
|
| 41 | + } else { |
|
| 42 | + $identifier = $identifier . ":" . $userId; |
|
| 43 | + } |
|
| 40 | 44 | |
| 41 | 45 | $reply = addslashes(trim($msg->reply[0])); // stores the message sent by the user. |
| 42 | 46 | |
@@ -50,27 +54,31 @@ discard block |
||
| 50 | 54 | $query = "SELECT * from login where login_id = '$receiverID'"; |
| 51 | 55 | |
| 52 | 56 | $result = $this->connect->query($query); |
| 53 | - if($result->num_rows > 0) // if true |
|
| 57 | + if($result->num_rows > 0) { |
|
| 58 | + // if true |
|
| 54 | 59 | { |
| 55 | 60 | //check whether he is sending message for thr first time or he has sent messages before |
| 56 | 61 | $query = "SELECT * from total_message where identifier = '$identifier'"; |
| 62 | + } |
|
| 57 | 63 | $result = $this->connect->query($query); |
| 58 | - if($result->num_rows>0) // if he has sent messages before |
|
| 64 | + if($result->num_rows>0) { |
|
| 65 | + // if he has sent messages before |
|
| 59 | 66 | { |
| 60 | 67 | // Update Total_Message Table |
| 61 | 68 | $query = "UPDATE total_message SET total_messages = total_messages+1, time = '$time', unread = 1, id = '$time_id' WHERE identifier = '$identifier'"; |
| 69 | + } |
|
| 62 | 70 | return $this->updateMessages($query, $identifier, $reply, $userId, $time); |
| 63 | 71 | |
| 64 | - } |
|
| 65 | - else // if he sends message for the first time |
|
| 72 | + } else // if he sends message for the first time |
|
| 66 | 73 | { |
| 67 | 74 | $length = strlen($userId); |
| 68 | - if(substr($identifier, 0, $length) == $userId) // generate specific unique code |
|
| 75 | + if(substr($identifier, 0, $length) == $userId) { |
|
| 76 | + // generate specific unique code |
|
| 69 | 77 | { |
| 70 | 78 | $user2 = substr($identifier, $length+1); |
| 71 | - $user1 = $userId; |
|
| 72 | 79 | } |
| 73 | - else |
|
| 80 | + $user1 = $userId; |
|
| 81 | + } else |
|
| 74 | 82 | { |
| 75 | 83 | $user2 = $userId; |
| 76 | 84 | $length = strlen($identifier) - $length-1; |
@@ -50,10 +50,11 @@ discard block |
||
| 50 | 50 | $login_id = (int)$fetch['login_id']; |
| 51 | 51 | |
| 52 | 52 | // Unique Identifier |
| 53 | - if($login_id > $userId) |
|
| 54 | - $identifier = $userId.':'.$login_id; |
|
| 55 | - else |
|
| 56 | - $identifier = $login_id.':'.$userId; |
|
| 53 | + if($login_id > $userId) { |
|
| 54 | + $identifier = $userId.':'.$login_id; |
|
| 55 | + } else { |
|
| 56 | + $identifier = $login_id.':'.$userId; |
|
| 57 | + } |
|
| 57 | 58 | |
| 58 | 59 | $query = "SELECT total_messages from total_message where identifier = '$identifier'"; |
| 59 | 60 | if($result = $this->connect->query($query)) |
@@ -62,11 +63,12 @@ discard block |
||
| 62 | 63 | { |
| 63 | 64 | $total = $result->fetch_assoc(); |
| 64 | 65 | $total = $total['total_messages']; |
| 65 | - if($total - $load > 0) |
|
| 66 | - if($total - $load > 10) |
|
| 66 | + if($total - $load > 0) { |
|
| 67 | + if($total - $load > 10) |
|
| 67 | 68 | $add_load = $load + 10; |
| 68 | - else |
|
| 69 | - $add_load = $total; |
|
| 69 | + } else { |
|
| 70 | + $add_load = $total; |
|
| 71 | + } |
|
| 70 | 72 | } |
| 71 | 73 | } |
| 72 | 74 | |
@@ -84,8 +86,7 @@ discard block |
||
| 84 | 86 | |
| 85 | 87 | $this->array = array_merge([['name' => $fetch['name'], 'username' => $fetch['username'], 'id' => $fetch['login_id'], 'load' => $add_load, 'login_status' => $fetch['login_status'], 'type' => 1]], $this->array); |
| 86 | 88 | return json_encode($this->array); |
| 87 | - } |
|
| 88 | - else |
|
| 89 | + } else |
|
| 89 | 90 | { |
| 90 | 91 | return json_encode([['name' => $fetch['name'], 'username' => $fetch['username'], 'id' => $fetch['login_id'], 'login_status' => $fetch['login_status'], 'type' => 0]]); |
| 91 | 92 | } |