@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace ChatApp; |
| 4 | -require_once (dirname(__DIR__) . '/config/database.php'); |
|
| 4 | +require_once (dirname(__DIR__).'/config/database.php'); |
|
| 5 | 5 | use ChatApp\Time; |
| 6 | 6 | use ChatApp\User; |
| 7 | 7 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | |
| 32 | 32 | $flag = 1; |
| 33 | - if(isset($_SESSION['start']) && isset($msg)) |
|
| 33 | + if (isset($_SESSION['start']) && isset($msg)) |
|
| 34 | 34 | { |
| 35 | 35 | $add_load = 0; |
| 36 | 36 | $id = $_SESSION['start']; |
@@ -40,25 +40,25 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $fetch = $this->obUser->UserDetails($username, $para); |
| 42 | 42 | |
| 43 | - if($fetch != NULL) |
|
| 43 | + if ($fetch != NULL) |
|
| 44 | 44 | { |
| 45 | 45 | $login_id = (int)$fetch['login_id']; |
| 46 | 46 | |
| 47 | 47 | // Unique Identifier |
| 48 | - if($login_id > $id) |
|
| 48 | + if ($login_id > $id) |
|
| 49 | 49 | $identifier = $id.':'.$login_id; |
| 50 | 50 | else |
| 51 | 51 | $identifier = $login_id.':'.$id; |
| 52 | 52 | |
| 53 | 53 | $query = "SELECT total_messages from total_message where identifier = '$identifier'"; |
| 54 | - if($result = $this->connect->query($query)) |
|
| 54 | + if ($result = $this->connect->query($query)) |
|
| 55 | 55 | { |
| 56 | - if($result->num_rows > 0) |
|
| 56 | + if ($result->num_rows > 0) |
|
| 57 | 57 | { |
| 58 | 58 | $total = $result->fetch_assoc(); |
| 59 | 59 | $total = $total['total_messages']; |
| 60 | - if($total - $load > 0) |
|
| 61 | - if($total - $load > 10) |
|
| 60 | + if ($total - $load > 0) |
|
| 61 | + if ($total - $load > 10) |
|
| 62 | 62 | $add_load = $load + 10; |
| 63 | 63 | else |
| 64 | 64 | $add_load = $total; |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $query = "SELECT message, time, sent_by FROM messages WHERE identifier_message_number = '$identifier' ORDER BY id DESC limit ".$load; |
| 69 | - if($result = $this->connect->query($query)) |
|
| 69 | + if ($result = $this->connect->query($query)) |
|
| 70 | 70 | { |
| 71 | - if($result->num_rows > 0) |
|
| 71 | + if ($result->num_rows > 0) |
|
| 72 | 72 | { |
| 73 | - while($row = $result->fetch_assoc()) |
|
| 73 | + while ($row = $result->fetch_assoc()) |
|
| 74 | 74 | { |
| 75 | 75 | $row['time'] = $this->obTime->TimeConversion($row['time']); |
| 76 | - $row = array_merge($row,['start' => $id]); |
|
| 76 | + $row = array_merge($row, ['start' => $id]); |
|
| 77 | 77 | $this->array = array_merge($this->array, [$row]); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace ChatApp; |
| 3 | -require_once (dirname(__DIR__) . '/config/database.php'); |
|
| 3 | +require_once (dirname(__DIR__).'/config/database.php'); |
|
| 4 | 4 | |
| 5 | 5 | class Validate |
| 6 | 6 | { |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace ChatApp; |
| 4 | -require_once (dirname(__DIR__) . '/config/database.php'); |
|
| 4 | +require_once (dirname(__DIR__).'/config/database.php'); |
|
| 5 | 5 | use ChatApp\Time; |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -23,26 +23,26 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | public function LoadSideBar($userId) |
| 25 | 25 | { |
| 26 | - if(isset($userId)) |
|
| 26 | + if (isset($userId)) |
|
| 27 | 27 | { |
| 28 | 28 | $query = "SELECT * FROM total_message WHERE user1='$userId' or user2='$userId' ORDER BY id DESC"; |
| 29 | - if($result = $this->connect->query($query)) |
|
| 29 | + if ($result = $this->connect->query($query)) |
|
| 30 | 30 | { |
| 31 | 31 | if ($result->num_rows > 0) |
| 32 | 32 | { |
| 33 | 33 | $length = strlen($userId); |
| 34 | - while($row = $result->fetch_assoc()) |
|
| 34 | + while ($row = $result->fetch_assoc()) |
|
| 35 | 35 | { |
| 36 | 36 | $identifier = $row['identifier']; |
| 37 | 37 | $substring = substr($identifier, 0, $length); |
| 38 | - if($substring != $userId) |
|
| 38 | + if ($substring != $userId) |
|
| 39 | 39 | { |
| 40 | 40 | $this->Data($substring, $row); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | else |
| 44 | 44 | { |
| 45 | - $substring = substr($identifier, $length+1); |
|
| 45 | + $substring = substr($identifier, $length + 1); |
|
| 46 | 46 | $this->Data($substring, $row); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | public function Data($id, $row) |
| 69 | 69 | { |
| 70 | 70 | $query = "SELECT username,name,login_status,login_id from login where login_id = '$id'"; |
| 71 | - if($result = $this->connect->query($query)) |
|
| 71 | + if ($result = $this->connect->query($query)) |
|
| 72 | 72 | { |
| 73 | - if($result->num_rows > 0) |
|
| 73 | + if ($result->num_rows > 0) |
|
| 74 | 74 | { |
| 75 | 75 | $fetch = $result->fetch_assoc(); |
| 76 | 76 | $row['time'] = $this->obTime->TimeConversion($row['time']); |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace ChatApp; |
| 4 | -require_once (dirname(__DIR__) . '/config/database.php'); |
|
| 4 | +require_once (dirname(__DIR__).'/config/database.php'); |
|
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * For checking online status |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | { |
| 14 | 14 | $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
| 15 | 15 | $query = "Update login set login_status = 1 where login_id = '$userId'"; |
| 16 | - if(!$connect->query($query)); |
|
| 16 | + if (!$connect->query($query)); |
|
| 17 | 17 | echo $connect->error; |
| 18 | 18 | $connect->close(); |
| 19 | 19 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
| 24 | 24 | $query = "Update login set login_status = 0 where login_id = '$userId'"; |
| 25 | - if(!$connect->query($query)); |
|
| 25 | + if (!$connect->query($query)); |
|
| 26 | 26 | echo $connect->error; |
| 27 | 27 | $connect->close(); |
| 28 | 28 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace ChatApp; |
| 4 | -require_once (dirname(__DIR__) . '/config/database.php'); |
|
| 4 | +require_once (dirname(__DIR__).'/config/database.php'); |
|
| 5 | 5 | use ChatApp\User; |
| 6 | 6 | use ChatApp\Time; |
| 7 | 7 | use ChatApp\Conversation; |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $name = $this->messages['name']; |
| 32 | 32 | $this->messages = json_decode($this->conversation->ConversationLoad($msg, True)); |
| 33 | 33 | $id = json_decode($msg)->username; |
| 34 | - for ($i=1 ; $i < count($this->messages); $i++) { |
|
| 34 | + for ($i = 1; $i < count($this->messages); $i++) { |
|
| 35 | 35 | $this->messages[$i]->start = $id; |
| 36 | 36 | } |
| 37 | 37 | $this->messages[0]->username = $username; |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace ChatApp; |
| 4 | -require_once (dirname(__DIR__) . '/config/database.php'); |
|
| 4 | +require_once (dirname(__DIR__).'/config/database.php'); |
|
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * |
@@ -23,18 +23,18 @@ discard block |
||
| 23 | 23 | public function SelectUser($msg) |
| 24 | 24 | { |
| 25 | 25 | $msg = $msg->value; |
| 26 | - if(isset($_SESSION['start']) && isset($msg)) |
|
| 26 | + if (isset($_SESSION['start']) && isset($msg)) |
|
| 27 | 27 | { |
| 28 | 28 | $id = $_SESSION['start']; |
| 29 | 29 | $suggestion = trim($msg); |
| 30 | - if($suggestion != "" ) |
|
| 30 | + if ($suggestion != "") |
|
| 31 | 31 | { |
| 32 | 32 | $query = "SELECT * FROM login where login_id != '$id' and name like '$suggestion%' ORDER BY name DESC"; |
| 33 | - if($result = $this->connect->query($query)) |
|
| 33 | + if ($result = $this->connect->query($query)) |
|
| 34 | 34 | { |
| 35 | - if($result->num_rows > 0) |
|
| 35 | + if ($result->num_rows > 0) |
|
| 36 | 36 | { |
| 37 | - while($row = $result->fetch_assoc()) |
|
| 37 | + while ($row = $result->fetch_assoc()) |
|
| 38 | 38 | { |
| 39 | 39 | $this->array = array_merge($this->array, [$row]); |
| 40 | 40 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace ChatApp; |
| 4 | -require_once (dirname(__DIR__) . '/config/database.php'); |
|
| 4 | +require_once (dirname(__DIR__).'/config/database.php'); |
|
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * For retreiving User Profile |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
| 15 | 15 | $query = "SELECT * from profile where login_id = '$userId'"; |
| 16 | 16 | $result = $connect->query($query); |
| 17 | - if($result->num_rows > 0) // if true |
|
| 17 | + if ($result->num_rows > 0) // if true |
|
| 18 | 18 | { |
| 19 | 19 | $details = $result->fetch_assoc(); |
| 20 | 20 | return $details; |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | namespace ChatApp; |
| 5 | -require_once (dirname(__DIR__) . '/config/database.php'); |
|
| 5 | +require_once (dirname(__DIR__).'/config/database.php'); |
|
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * For retreiving User Information |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public function UserDetails($id, $para) |
| 23 | 23 | { |
| 24 | - if($para == True) |
|
| 24 | + if ($para == True) |
|
| 25 | 25 | $this->query = "SELECT * from login where login_id = '$id'"; |
| 26 | 26 | else |
| 27 | 27 | $this->query = "SELECT * from login where username = '$id'"; |
| 28 | 28 | $this->result = $this->connect->query($this->query); |
| 29 | - if($this->result->num_rows > 0) // if true |
|
| 29 | + if ($this->result->num_rows > 0) // if true |
|
| 30 | 30 | { |
| 31 | 31 | $this->details = $this->result->fetch_assoc(); |
| 32 | 32 | return $this->details; |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require (__DIR__ . '/vendor/autoload.php'); |
|
| 3 | +require (__DIR__.'/vendor/autoload.php'); |
|
| 4 | 4 | use ChatApp\Session; |
| 5 | 5 | |
| 6 | -if(Session::get('start') != null) |
|
| 6 | +if (Session::get('start') != null) |
|
| 7 | 7 | { |
| 8 | 8 | Session::forget('start'); |
| 9 | 9 | header('Location: index.php'); |