@@ -33,6 +33,9 @@ discard block |
||
33 | 33 | } |
34 | 34 | } |
35 | 35 | |
36 | + /** |
|
37 | + * @param string $email |
|
38 | + */ |
|
36 | 39 | function validate_email_in_db($email) |
37 | 40 | { |
38 | 41 | $query="SELECT login_id FROM login WHERE email='$email'"; |
@@ -46,6 +49,9 @@ discard block |
||
46 | 49 | } |
47 | 50 | } |
48 | 51 | |
52 | + /** |
|
53 | + * @param string $username |
|
54 | + */ |
|
49 | 55 | function validate_username_in_db($username) |
50 | 56 | { |
51 | 57 | $query="SELECT login_id FROM login WHERE username='$username'"; |
@@ -3,23 +3,23 @@ discard block |
||
3 | 3 | require_once 'database.php'; |
4 | 4 | class validate |
5 | 5 | { |
6 | - private $connect; |
|
7 | - function __construct() |
|
8 | - { |
|
9 | - $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
|
6 | + private $connect; |
|
7 | + function __construct() |
|
8 | + { |
|
9 | + $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
|
10 | 10 | |
11 | - $query="CREATE TABLE IF NOT EXISTS register ( |
|
11 | + $query="CREATE TABLE IF NOT EXISTS register ( |
|
12 | 12 | id int primary key auto_increment unique not null, |
13 | 13 | email varchar(255) unique not null, |
14 | 14 | username varchar(255) unique not null, |
15 | 15 | password varchar(255) not null |
16 | 16 | ) ENGINE=INNODB;"; |
17 | 17 | |
18 | - if (!$this->connect->query($query)) { |
|
19 | - echo "Table is not created || Query failed"; |
|
20 | - } |
|
18 | + if (!$this->connect->query($query)) { |
|
19 | + echo "Table is not created || Query failed"; |
|
20 | + } |
|
21 | 21 | |
22 | - $query="CREATE TABLE IF NOT EXISTS login ( |
|
22 | + $query="CREATE TABLE IF NOT EXISTS login ( |
|
23 | 23 | login_id int primary key not null, |
24 | 24 | name varchar(255) not null, |
25 | 25 | email varchar(255) unique not null, |
@@ -28,34 +28,34 @@ discard block |
||
28 | 28 | FOREIGN KEY (login_id) REFERENCES register(id) |
29 | 29 | ) ENGINE=INNODB;"; |
30 | 30 | |
31 | - if (!$this->connect->query($query)) { |
|
32 | - echo "Table is not created || Query failed"; |
|
33 | - } |
|
34 | - } |
|
31 | + if (!$this->connect->query($query)) { |
|
32 | + echo "Table is not created || Query failed"; |
|
33 | + } |
|
34 | + } |
|
35 | 35 | |
36 | - function validate_email_in_db($email) |
|
37 | - { |
|
38 | - $query="SELECT login_id FROM login WHERE email='$email'"; |
|
39 | - if ($result=$this->connect->query($query)) |
|
40 | - { |
|
41 | - if ($result->num_rows>0) { |
|
42 | - return 1; |
|
43 | - } |
|
44 | - else |
|
45 | - return 0; |
|
46 | - } |
|
47 | - } |
|
36 | + function validate_email_in_db($email) |
|
37 | + { |
|
38 | + $query="SELECT login_id FROM login WHERE email='$email'"; |
|
39 | + if ($result=$this->connect->query($query)) |
|
40 | + { |
|
41 | + if ($result->num_rows>0) { |
|
42 | + return 1; |
|
43 | + } |
|
44 | + else |
|
45 | + return 0; |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | - function validate_username_in_db($username) |
|
50 | - { |
|
51 | - $query="SELECT login_id FROM login WHERE username='$username'"; |
|
52 | - if ($result=$this->connect->query($query)) { |
|
53 | - if ($result->num_rows>0) { |
|
54 | - return 1; |
|
55 | - } |
|
56 | - else |
|
57 | - return 0; |
|
49 | + function validate_username_in_db($username) |
|
50 | + { |
|
51 | + $query="SELECT login_id FROM login WHERE username='$username'"; |
|
52 | + if ($result=$this->connect->query($query)) { |
|
53 | + if ($result->num_rows>0) { |
|
54 | + return 1; |
|
55 | + } |
|
56 | + else |
|
57 | + return 0; |
|
58 | 58 | |
59 | - } |
|
60 | - } |
|
59 | + } |
|
60 | + } |
|
61 | 61 | } |
62 | 62 | \ No newline at end of file |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | { |
9 | 9 | $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
10 | 10 | |
11 | - $query="CREATE TABLE IF NOT EXISTS register ( |
|
11 | + $query = "CREATE TABLE IF NOT EXISTS register ( |
|
12 | 12 | id int primary key auto_increment unique not null, |
13 | 13 | email varchar(255) unique not null, |
14 | 14 | username varchar(255) unique not null, |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | echo "Table is not created || Query failed"; |
20 | 20 | } |
21 | 21 | |
22 | - $query="CREATE TABLE IF NOT EXISTS login ( |
|
22 | + $query = "CREATE TABLE IF NOT EXISTS login ( |
|
23 | 23 | login_id int primary key not null, |
24 | 24 | name varchar(255) not null, |
25 | 25 | email varchar(255) unique not null, |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | |
36 | 36 | function validate_email_in_db($email) |
37 | 37 | { |
38 | - $query="SELECT login_id FROM login WHERE email='$email'"; |
|
39 | - if ($result=$this->connect->query($query)) |
|
38 | + $query = "SELECT login_id FROM login WHERE email='$email'"; |
|
39 | + if ($result = $this->connect->query($query)) |
|
40 | 40 | { |
41 | - if ($result->num_rows>0) { |
|
41 | + if ($result->num_rows > 0) { |
|
42 | 42 | return 1; |
43 | 43 | } |
44 | 44 | else |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | |
49 | 49 | function validate_username_in_db($username) |
50 | 50 | { |
51 | - $query="SELECT login_id FROM login WHERE username='$username'"; |
|
52 | - if ($result=$this->connect->query($query)) { |
|
53 | - if ($result->num_rows>0) { |
|
51 | + $query = "SELECT login_id FROM login WHERE username='$username'"; |
|
52 | + if ($result = $this->connect->query($query)) { |
|
53 | + if ($result->num_rows > 0) { |
|
54 | 54 | return 1; |
55 | 55 | } |
56 | 56 | else |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | { |
41 | 41 | if ($result->num_rows>0) { |
42 | 42 | return 1; |
43 | + } else { |
|
44 | + return 0; |
|
43 | 45 | } |
44 | - else |
|
45 | - return 0; |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | if ($result=$this->connect->query($query)) { |
53 | 53 | if ($result->num_rows>0) { |
54 | 54 | return 1; |
55 | + } else { |
|
56 | + return 0; |
|
55 | 57 | } |
56 | - else |
|
57 | - return 0; |
|
58 | 58 | |
59 | 59 | } |
60 | 60 | } |
@@ -26,6 +26,9 @@ discard block |
||
26 | 26 | echo "New connection! ({$conn->resourceId})\n"; |
27 | 27 | } |
28 | 28 | |
29 | + /** |
|
30 | + * @param ConnectionInterface $conn |
|
31 | + */ |
|
29 | 32 | public function setID($conn) |
30 | 33 | { |
31 | 34 | session_id($conn->WebSocket->request->getCookies()['PHPSESSID']); |
@@ -126,30 +129,47 @@ discard block |
||
126 | 129 | return $obSidebar->LoadSideBar($data); |
127 | 130 | } |
128 | 131 | |
132 | + /** |
|
133 | + * @param string $data |
|
134 | + * @param boolean $para |
|
135 | + */ |
|
129 | 136 | public function onConversation($data, $para, $sessionId) |
130 | 137 | { |
131 | 138 | $obConversation = new Conversation($sessionId); |
132 | 139 | return $obConversation->ConversationLoad($data, $para); |
133 | 140 | } |
134 | 141 | |
142 | + /** |
|
143 | + * @param string $data |
|
144 | + * @param boolean $para |
|
145 | + */ |
|
135 | 146 | public function onReceiver($data, $para, $sessionId) |
136 | 147 | { |
137 | 148 | $obReceiver = new Receiver($sessionId); |
138 | 149 | return $obReceiver->ReceiverLoad($data, True); |
139 | 150 | } |
140 | 151 | |
152 | + /** |
|
153 | + * @param string $data |
|
154 | + */ |
|
141 | 155 | public function onSearch($data, $sessionId) |
142 | 156 | { |
143 | 157 | $obSearch = new Search($sessionId); |
144 | 158 | return $obSearch->SearchItem(json_decode($data)); |
145 | 159 | } |
146 | 160 | |
161 | + /** |
|
162 | + * @param string $data |
|
163 | + */ |
|
147 | 164 | public function onCompose($data, $sessionId) |
148 | 165 | { |
149 | 166 | $obCompose = new Compose($sessionId); |
150 | 167 | return $obCompose->SelectUser(json_decode($data)); |
151 | 168 | } |
152 | 169 | |
170 | + /** |
|
171 | + * @param string $data |
|
172 | + */ |
|
153 | 173 | public function onReply($data, $sessionId) |
154 | 174 | { |
155 | 175 | $obReply = new Reply($sessionId); |
@@ -2,11 +2,9 @@ |
||
2 | 2 | namespace ChatApp; |
3 | 3 | use Ratchet\MessageComponentInterface; |
4 | 4 | use Ratchet\ConnectionInterface; |
5 | -use ChatApp\Models\Message; |
|
6 | 5 | use ChatApp\Reply; |
7 | 6 | use ChatApp\Conversation; |
8 | 7 | use ChatApp\Receiver; |
9 | -use ChatApp\SideBar; |
|
10 | 8 | use ChatApp\Search; |
11 | 9 | use ChatApp\Compose; |
12 | 10 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function onMessage(ConnectionInterface $from, $msg) { |
39 | 39 | $sessionId = $from->WebSocket->request->getCookies()['PHPSESSID']; |
40 | - if($msg == 'OpenChat initiated..!') |
|
40 | + if ($msg == 'OpenChat initiated..!') |
|
41 | 41 | { |
42 | 42 | @$initial->initial = json_decode($this->onSidebar($from->userId)); |
43 | 43 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $client->send(json_encode($result)); |
99 | 99 | $this->online = 1; |
100 | 100 | } |
101 | - elseif($client == $from) |
|
101 | + elseif ($client == $from) |
|
102 | 102 | { |
103 | 103 | @$result->sidebar = json_decode($this->onSidebar($client->userId)); |
104 | 104 |
@@ -52,28 +52,23 @@ discard block |
||
52 | 52 | |
53 | 53 | $initial->conversation[0]->login_status = $this->online; |
54 | 54 | $from->send(json_encode($initial)); |
55 | - } |
|
56 | - elseif ($msg == 'Load Sidebar') |
|
55 | + } elseif ($msg == 'Load Sidebar') |
|
57 | 56 | { |
58 | 57 | @$initial->initial = json_decode($this->onSidebar($from->userId)); |
59 | 58 | $from->send(json_encode($initial)); |
60 | - } |
|
61 | - elseif (@json_decode($msg)->newConversation == 'Initiated') |
|
59 | + } elseif (@json_decode($msg)->newConversation == 'Initiated') |
|
62 | 60 | { |
63 | 61 | @$result->conversation = json_decode($this->onConversation($msg, False, $sessionId)); |
64 | 62 | $from->send(json_encode($result)); |
65 | - } |
|
66 | - elseif (@json_decode($msg)->search == 'search') |
|
63 | + } elseif (@json_decode($msg)->search == 'search') |
|
67 | 64 | { |
68 | 65 | $searchResult = $this->onSearch($msg, $sessionId); |
69 | 66 | $from->send($searchResult); |
70 | - } |
|
71 | - elseif (@json_decode($msg)->Compose == 'Compose') |
|
67 | + } elseif (@json_decode($msg)->Compose == 'Compose') |
|
72 | 68 | { |
73 | 69 | $composeResult = $this->onCompose($msg, $sessionId); |
74 | 70 | $from->send($composeResult); |
75 | - } |
|
76 | - else |
|
71 | + } else |
|
77 | 72 | { |
78 | 73 | $this->onReply($msg, $sessionId); |
79 | 74 | |
@@ -97,8 +92,7 @@ discard block |
||
97 | 92 | |
98 | 93 | $client->send(json_encode($result)); |
99 | 94 | $this->online = 1; |
100 | - } |
|
101 | - elseif($client == $from) |
|
95 | + } elseif($client == $from) |
|
102 | 96 | { |
103 | 97 | @$result->sidebar = json_decode($this->onSidebar($client->userId)); |
104 | 98 |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace ChatApp; |
4 | 4 | require_once (dirname(__DIR__) . '/database.php'); |
5 | 5 | use ChatApp\User; |
6 | -use ChatApp\Time; |
|
7 | 6 | use ChatApp\Conversation; |
8 | 7 | /** |
9 | 8 | * |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | namespace ChatApp; |
4 | -require_once (dirname(__DIR__) . '/database.php'); |
|
4 | +require_once (dirname(__DIR__).'/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; |
@@ -90,6 +90,11 @@ |
||
90 | 90 | $this->connect->close(); |
91 | 91 | } |
92 | 92 | |
93 | + /** |
|
94 | + * @param string $identifier |
|
95 | + * @param string $reply |
|
96 | + * @param string $time |
|
97 | + */ |
|
93 | 98 | function UpdateMessages($query, $identifier, $reply, $id, $time) |
94 | 99 | { |
95 | 100 | if($result = $this->connect->query($query)) |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | namespace ChatApp; |
4 | -require_once (dirname(__DIR__) . '/database.php'); |
|
4 | +require_once (dirname(__DIR__).'/database.php'); |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * Store Message in the Database |
@@ -21,37 +21,37 @@ discard block |
||
21 | 21 | function replyTo($msg) |
22 | 22 | { |
23 | 23 | |
24 | - if(isset($_SESSION['start']) && isset($msg)) //checks for session login and the value send |
|
24 | + if (isset($_SESSION['start']) && isset($msg)) //checks for session login and the value send |
|
25 | 25 | { |
26 | 26 | $id = $_SESSION['start']; |
27 | - $msg = json_decode($msg); //decode json value |
|
27 | + $msg = json_decode($msg); //decode json value |
|
28 | 28 | $identifier = $msg->name; |
29 | 29 | |
30 | - $receiverID = $identifier; //stores id of the person whom message is to be sent |
|
30 | + $receiverID = $identifier; //stores id of the person whom message is to be sent |
|
31 | 31 | |
32 | - if($identifier > $id) // geneate specific unique code to store messages |
|
32 | + if ($identifier > $id) // geneate specific unique code to store messages |
|
33 | 33 | $identifier = $id.":".$identifier; |
34 | 34 | else |
35 | 35 | $identifier = $identifier.":".$id; |
36 | 36 | |
37 | 37 | $reply = addslashes(trim($msg->reply[0])); // stores the message sent by the user. |
38 | 38 | |
39 | - $time = date("D d M Y H:i:s", time() + 16200); // current time |
|
39 | + $time = date("D d M Y H:i:s", time() + 16200); // current time |
|
40 | 40 | $time_id = date("YmdHis", time() + 16200); //to sort the array on the basis of time |
41 | 41 | |
42 | 42 | //the sender id must not be equal to current session id |
43 | - if($reply != "" && $receiverID != $id) |
|
43 | + if ($reply != "" && $receiverID != $id) |
|
44 | 44 | { |
45 | 45 | // check whether the receiver is authorized or registered |
46 | 46 | $query = "SELECT * from login where login_id = '$receiverID'"; |
47 | 47 | |
48 | 48 | $result = $this->connect->query($query); |
49 | - if($result->num_rows > 0) // if true |
|
49 | + if ($result->num_rows > 0) // if true |
|
50 | 50 | { |
51 | 51 | //check whether he is sending message for thr first time or he has sent messages before |
52 | 52 | $query = "SELECT * from total_message where identifier = '$identifier'"; |
53 | 53 | $result = $this->connect->query($query); |
54 | - if($result->num_rows>0) // if he has sent messages before |
|
54 | + if ($result->num_rows > 0) // if he has sent messages before |
|
55 | 55 | { |
56 | 56 | // Update Total_Message Table |
57 | 57 | $query = "UPDATE total_message SET total_messages = total_messages+1, time = '$time', unread = 1, id = '$time_id' WHERE identifier = '$identifier'"; |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | else // if he sends message for the first time |
62 | 62 | { |
63 | 63 | $length = strlen($id); |
64 | - if(substr($identifier, 0, $length) == $id) // generate specific unique code |
|
64 | + if (substr($identifier, 0, $length) == $id) // generate specific unique code |
|
65 | 65 | { |
66 | - $user2 = substr($identifier, $length+1); |
|
66 | + $user2 = substr($identifier, $length + 1); |
|
67 | 67 | $user1 = $id; |
68 | 68 | } |
69 | 69 | else |
70 | 70 | { |
71 | 71 | $user2 = $id; |
72 | - $length = strlen($identifier) - $length-1; |
|
72 | + $length = strlen($identifier) - $length - 1; |
|
73 | 73 | $user1 = substr($identifier, 0, $length); |
74 | 74 | } |
75 | 75 | // insert Details in Total_Message Table |
@@ -92,13 +92,13 @@ discard block |
||
92 | 92 | |
93 | 93 | function UpdateMessages($query, $identifier, $reply, $id, $time) |
94 | 94 | { |
95 | - if($result = $this->connect->query($query)) |
|
95 | + if ($result = $this->connect->query($query)) |
|
96 | 96 | { |
97 | 97 | //insert message in db |
98 | 98 | $query = "INSERT into messages values('$identifier', '$reply', '$id', '$time', null)"; |
99 | - if($result = $this->connect->query($query)) |
|
99 | + if ($result = $this->connect->query($query)) |
|
100 | 100 | { |
101 | - echo "Messages is sent \n"; // if query is executed return true |
|
101 | + echo "Messages is sent \n"; // if query is executed return true |
|
102 | 102 | } |
103 | 103 | else |
104 | 104 | { |
@@ -21,18 +21,22 @@ discard block |
||
21 | 21 | function replyTo($msg) |
22 | 22 | { |
23 | 23 | |
24 | - if(isset($_SESSION['start']) && isset($msg)) //checks for session login and the value send |
|
24 | + if(isset($_SESSION['start']) && isset($msg)) { |
|
25 | + //checks for session login and the value send |
|
25 | 26 | { |
26 | 27 | $id = $_SESSION['start']; |
28 | + } |
|
27 | 29 | $msg = json_decode($msg); //decode json value |
28 | 30 | $identifier = $msg->name; |
29 | 31 | |
30 | 32 | $receiverID = $identifier; //stores id of the person whom message is to be sent |
31 | 33 | |
32 | - if($identifier > $id) // geneate specific unique code to store messages |
|
34 | + if($identifier > $id) { |
|
35 | + // geneate specific unique code to store messages |
|
33 | 36 | $identifier = $id.":".$identifier; |
34 | - else |
|
35 | - $identifier = $identifier.":".$id; |
|
37 | + } else { |
|
38 | + $identifier = $identifier.":".$id; |
|
39 | + } |
|
36 | 40 | |
37 | 41 | $reply = addslashes(trim($msg->reply[0])); // stores the message sent by the user. |
38 | 42 | |
@@ -46,27 +50,31 @@ discard block |
||
46 | 50 | $query = "SELECT * from login where login_id = '$receiverID'"; |
47 | 51 | |
48 | 52 | $result = $this->connect->query($query); |
49 | - if($result->num_rows > 0) // if true |
|
53 | + if($result->num_rows > 0) { |
|
54 | + // if true |
|
50 | 55 | { |
51 | 56 | //check whether he is sending message for thr first time or he has sent messages before |
52 | 57 | $query = "SELECT * from total_message where identifier = '$identifier'"; |
58 | + } |
|
53 | 59 | $result = $this->connect->query($query); |
54 | - if($result->num_rows>0) // if he has sent messages before |
|
60 | + if($result->num_rows>0) { |
|
61 | + // if he has sent messages before |
|
55 | 62 | { |
56 | 63 | // Update Total_Message Table |
57 | 64 | $query = "UPDATE total_message SET total_messages = total_messages+1, time = '$time', unread = 1, id = '$time_id' WHERE identifier = '$identifier'"; |
65 | + } |
|
58 | 66 | $this->UpdateMessages($query, $identifier, $reply, $id, $time); |
59 | 67 | |
60 | - } |
|
61 | - else // if he sends message for the first time |
|
68 | + } else // if he sends message for the first time |
|
62 | 69 | { |
63 | 70 | $length = strlen($id); |
64 | - if(substr($identifier, 0, $length) == $id) // generate specific unique code |
|
71 | + if(substr($identifier, 0, $length) == $id) { |
|
72 | + // generate specific unique code |
|
65 | 73 | { |
66 | 74 | $user2 = substr($identifier, $length+1); |
67 | - $user1 = $id; |
|
68 | 75 | } |
69 | - else |
|
76 | + $user1 = $id; |
|
77 | + } else |
|
70 | 78 | { |
71 | 79 | $user2 = $id; |
72 | 80 | $length = strlen($identifier) - $length-1; |
@@ -76,14 +84,12 @@ discard block |
||
76 | 84 | $query = "INSERT into total_message values('$identifier', 1, '$user1', '$user2', 1, '$time', '$time_id')"; |
77 | 85 | $this->UpdateMessages($query, $identifier, $reply, $id, $time); |
78 | 86 | } |
79 | - } |
|
80 | - else // if he is unauthorized echo message is failed |
|
87 | + } else // if he is unauthorized echo message is failed |
|
81 | 88 | { |
82 | 89 | echo "Message is failed"; |
83 | 90 | } |
84 | 91 | } |
85 | - } |
|
86 | - else |
|
92 | + } else |
|
87 | 93 | { |
88 | 94 | echo "failed"; |
89 | 95 | } |
@@ -99,8 +105,7 @@ discard block |
||
99 | 105 | if($result = $this->connect->query($query)) |
100 | 106 | { |
101 | 107 | echo "Messages is sent \n"; // if query is executed return true |
102 | - } |
|
103 | - else |
|
108 | + } else |
|
104 | 109 | { |
105 | 110 | echo "Message is failed"; |
106 | 111 | } |
@@ -65,6 +65,9 @@ |
||
65 | 65 | $this->connect->close(); |
66 | 66 | } |
67 | 67 | |
68 | + /** |
|
69 | + * @param string $id |
|
70 | + */ |
|
68 | 71 | function Data($id, $row) |
69 | 72 | { |
70 | 73 | $query = "SELECT username,name,login_status,login_id from login where login_id = '$id'"; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | namespace ChatApp; |
4 | -require_once (dirname(__DIR__) . '/database.php'); |
|
4 | +require_once (dirname(__DIR__).'/database.php'); |
|
5 | 5 | use ChatApp\Time; |
6 | 6 | |
7 | 7 | /** |
@@ -23,26 +23,26 @@ discard block |
||
23 | 23 | |
24 | 24 | 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 | 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']); |
@@ -38,27 +38,22 @@ |
||
38 | 38 | if($substring != $userId) |
39 | 39 | { |
40 | 40 | $this->Data($substring, $row); |
41 | - } |
|
42 | - |
|
43 | - else |
|
41 | + } else |
|
44 | 42 | { |
45 | 43 | $substring = substr($identifier, $length+1); |
46 | 44 | $this->Data($substring, $row); |
47 | 45 | } |
48 | 46 | } |
49 | 47 | return json_encode($this->array); |
50 | - } |
|
51 | - else |
|
48 | + } else |
|
52 | 49 | { |
53 | 50 | return json_encode(null); |
54 | 51 | } |
55 | - } |
|
56 | - else |
|
52 | + } else |
|
57 | 53 | { |
58 | 54 | echo "Query Failed"; |
59 | 55 | } |
60 | - } |
|
61 | - else |
|
56 | + } else |
|
62 | 57 | { |
63 | 58 | header('Location:../login.php'); |
64 | 59 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | session_start(); |
3 | -if(isset($_SESSION['start'])) |
|
3 | +if (isset($_SESSION['start'])) |
|
4 | 4 | { |
5 | 5 | header("Location: account.php"); |
6 | 6 | } |
@@ -16,21 +16,21 @@ |
||
16 | 16 | <a id="brand" href="#">OpenChat</a> |
17 | 17 | <ul class="nav-right"> |
18 | 18 | <?php if(isset($_SESSION['start'])) |
19 | - { |
|
20 | - ?> |
|
19 | + { |
|
20 | + ?> |
|
21 | 21 | <li><a href="account.php">Account</a></li> |
22 | 22 | <li><a href="message.php">Message</a></li> |
23 | 23 | <li><a href="registration-module/source/class.logout.php">Log out</a></li> |
24 | 24 | <?php |
25 | - } |
|
26 | - else |
|
27 | - { |
|
28 | - ?> |
|
25 | + } |
|
26 | + else |
|
27 | + { |
|
28 | + ?> |
|
29 | 29 | <li><a href="login.php">Login</a></li> |
30 | 30 | <li><a href="register.php">Register</a></li> |
31 | 31 | <?php |
32 | - } |
|
33 | - ?> |
|
32 | + } |
|
33 | + ?> |
|
34 | 34 | </ul> |
35 | 35 | </div> |
36 | 36 |
@@ -15,7 +15,7 @@ |
||
15 | 15 | <div class="header"> |
16 | 16 | <a id="brand" href="#">OpenChat</a> |
17 | 17 | <ul class="nav-right"> |
18 | - <?php if(isset($_SESSION['start'])) |
|
18 | + <?php if (isset($_SESSION['start'])) |
|
19 | 19 | { |
20 | 20 | ?> |
21 | 21 | <li><a href="account.php">Account</a></li> |
@@ -22,8 +22,7 @@ |
||
22 | 22 | <li><a href="message.php">Message</a></li> |
23 | 23 | <li><a href="registration-module/source/class.logout.php">Log out</a></li> |
24 | 24 | <?php |
25 | - } |
|
26 | - else |
|
25 | + } else |
|
27 | 26 | { |
28 | 27 | ?> |
29 | 28 | <li><a href="login.php">Login</a></li> |
@@ -22,9 +22,7 @@ discard block |
||
22 | 22 | } |
23 | 23 | } |
24 | 24 | |
25 | -} |
|
26 | - |
|
27 | -else if($user) |
|
25 | +} else if($user) |
|
28 | 26 | { |
29 | 27 | $query="SELECT * from login where username='$user'"; |
30 | 28 | if($result=$connect->query($query)) |
@@ -42,8 +40,7 @@ discard block |
||
42 | 40 | $row=array_merge($row,$r); |
43 | 41 | // var_dump($row); |
44 | 42 | } |
45 | - } |
|
46 | - else |
|
43 | + } else |
|
47 | 44 | { |
48 | 45 | die("error"); |
49 | 46 | } |
@@ -67,8 +64,7 @@ discard block |
||
67 | 64 | <li><a href="../message.php">Message</a></li> |
68 | 65 | <li><a href="../registration-module/source/class.logout.php">Log out</a></li> |
69 | 66 | <?php |
70 | - } |
|
71 | - else |
|
67 | + } else |
|
72 | 68 | { |
73 | 69 | ?> |
74 | 70 | <li><a href="../login.php">Login</a></li> |
@@ -92,16 +88,21 @@ discard block |
||
92 | 88 | <div class="brief"> |
93 | 89 | <h1 id="name">Name: <?php echo $row['name']; ?></h1><br> |
94 | 90 | <?php foreach ($row as $key => $value) { |
95 | - if($key=='username' and $value!=null) |
|
96 | - echo '<p>Username: '.$row["username"] .'</p><br>'; |
|
97 | - if($key=='email' and $value!=null) |
|
98 | - echo '<p>Email Id: '.$row["email"] .'</p><br>'; |
|
99 | - if($key=='status' and $value!=null) |
|
100 | - echo '<p>Status: '.$row["status"] .'</p><br>'; |
|
101 | - if($key=='education' and $value!=null) |
|
102 | - echo '<p>Education: '.$row["education"] .'</p><br>'; |
|
103 | - if($key=='gender' and $value!=null) |
|
104 | - echo '<p>Gender: '.$row["gender"] .'</p><br>'; |
|
91 | + if($key=='username' and $value!=null) { |
|
92 | + echo '<p>Username: '.$row["username"] .'</p><br>'; |
|
93 | + } |
|
94 | + if($key=='email' and $value!=null) { |
|
95 | + echo '<p>Email Id: '.$row["email"] .'</p><br>'; |
|
96 | + } |
|
97 | + if($key=='status' and $value!=null) { |
|
98 | + echo '<p>Status: '.$row["status"] .'</p><br>'; |
|
99 | + } |
|
100 | + if($key=='education' and $value!=null) { |
|
101 | + echo '<p>Education: '.$row["education"] .'</p><br>'; |
|
102 | + } |
|
103 | + if($key=='gender' and $value!=null) { |
|
104 | + echo '<p>Gender: '.$row["gender"] .'</p><br>'; |
|
105 | + } |
|
105 | 106 | } |
106 | 107 | ?> |
107 | 108 | </div> |
@@ -152,18 +153,15 @@ discard block |
||
152 | 153 | |
153 | 154 | |
154 | 155 | <?php |
155 | - } |
|
156 | - else |
|
156 | + } else |
|
157 | 157 | { |
158 | 158 | die("Invalid User"); |
159 | 159 | } |
160 | - } |
|
161 | - else |
|
160 | + } else |
|
162 | 161 | { |
163 | 162 | die("invalid"); |
164 | 163 | } |
165 | -} |
|
166 | -else |
|
164 | +} else |
|
167 | 165 | { |
168 | 166 | header("Location:http://localhost/openchat/index.php"); |
169 | 167 | } |
@@ -11,43 +11,43 @@ discard block |
||
11 | 11 | var_dump($user); |
12 | 12 | if(isset($_SESSION['start']) and !$user) |
13 | 13 | { |
14 | - $login_id=$_SESSION['start']; |
|
15 | - $query="SELECT username from login where login_id='$login_id'"; |
|
16 | - if($result=$connect->query($query)) |
|
17 | - { |
|
18 | - if($result->num_rows >0) |
|
19 | - { |
|
20 | - $row=$result->fetch_assoc(); |
|
21 | - $location="http://localhost/openchat/account.php/".$row['username']; |
|
22 | - header("Location:".$location); |
|
23 | - } |
|
24 | - } |
|
14 | + $login_id=$_SESSION['start']; |
|
15 | + $query="SELECT username from login where login_id='$login_id'"; |
|
16 | + if($result=$connect->query($query)) |
|
17 | + { |
|
18 | + if($result->num_rows >0) |
|
19 | + { |
|
20 | + $row=$result->fetch_assoc(); |
|
21 | + $location="http://localhost/openchat/account.php/".$row['username']; |
|
22 | + header("Location:".$location); |
|
23 | + } |
|
24 | + } |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | |
28 | 28 | else if($user) |
29 | 29 | { |
30 | - $query="SELECT * from login where username='$user'"; |
|
31 | - if($result=$connect->query($query)) |
|
32 | - { |
|
33 | - if($result->num_rows >0) |
|
34 | - { |
|
35 | - $row=$result->fetch_assoc(); |
|
36 | - $id=$row['login_id']; |
|
37 | - $query="SELECT * from profile where login_id='$id'"; |
|
38 | - if($result=$connect->query($query)) |
|
39 | - { |
|
40 | - if($result->num_rows>0) |
|
41 | - { |
|
42 | - $r=$result->fetch_assoc(); |
|
43 | - $row=array_merge($row,$r); |
|
44 | - // var_dump($row); |
|
45 | - } |
|
46 | - } |
|
47 | - else |
|
48 | - { |
|
49 | - die("error"); |
|
50 | - } |
|
30 | + $query="SELECT * from login where username='$user'"; |
|
31 | + if($result=$connect->query($query)) |
|
32 | + { |
|
33 | + if($result->num_rows >0) |
|
34 | + { |
|
35 | + $row=$result->fetch_assoc(); |
|
36 | + $id=$row['login_id']; |
|
37 | + $query="SELECT * from profile where login_id='$id'"; |
|
38 | + if($result=$connect->query($query)) |
|
39 | + { |
|
40 | + if($result->num_rows>0) |
|
41 | + { |
|
42 | + $r=$result->fetch_assoc(); |
|
43 | + $row=array_merge($row,$r); |
|
44 | + // var_dump($row); |
|
45 | + } |
|
46 | + } |
|
47 | + else |
|
48 | + { |
|
49 | + die("error"); |
|
50 | + } |
|
51 | 51 | ?> |
52 | 52 | <head> |
53 | 53 | <title>OpenChat || Profile</title> |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | <ul class="nav-right"> |
64 | 64 | <li><a href="../index.php">About</a></li> |
65 | 65 | <?php if(isset($_SESSION['start'])) |
66 | - { |
|
67 | - ?> |
|
66 | + { |
|
67 | + ?> |
|
68 | 68 | <li><a href="../message.php">Message</a></li> |
69 | 69 | <li><a href="../registration-module/source/class.logout.php">Log out</a></li> |
70 | 70 | <?php |
71 | - } |
|
72 | - else |
|
73 | - { |
|
74 | - ?> |
|
71 | + } |
|
72 | + else |
|
73 | + { |
|
74 | + ?> |
|
75 | 75 | <li><a href="../login.php">Login</a></li> |
76 | 76 | <li><a href="../register.php">Register</a></li> |
77 | 77 | <?php |
78 | - } |
|
79 | - ?> |
|
78 | + } |
|
79 | + ?> |
|
80 | 80 | </ul> |
81 | 81 | </div> |
82 | 82 | |
@@ -93,32 +93,32 @@ discard block |
||
93 | 93 | <div class="brief"> |
94 | 94 | <h1 id="name">Name: <?php echo $row['name']; ?></h1><br> |
95 | 95 | <?php foreach ($row as $key => $value) { |
96 | - if($key=='username' and $value!=null) |
|
97 | - echo '<p>Username: '.$row["username"] .'</p><br>'; |
|
98 | - if($key=='email' and $value!=null) |
|
99 | - echo '<p>Email Id: '.$row["email"] .'</p><br>'; |
|
100 | - if($key=='status' and $value!=null) |
|
101 | - echo '<p>Status: '.$row["status"] .'</p><br>'; |
|
102 | - if($key=='education' and $value!=null) |
|
103 | - echo '<p>Education: '.$row["education"] .'</p><br>'; |
|
104 | - if($key=='gender' and $value!=null) |
|
105 | - echo '<p>Gender: '.$row["gender"] .'</p><br>'; |
|
106 | - } |
|
107 | - ?> |
|
96 | + if($key=='username' and $value!=null) |
|
97 | + echo '<p>Username: '.$row["username"] .'</p><br>'; |
|
98 | + if($key=='email' and $value!=null) |
|
99 | + echo '<p>Email Id: '.$row["email"] .'</p><br>'; |
|
100 | + if($key=='status' and $value!=null) |
|
101 | + echo '<p>Status: '.$row["status"] .'</p><br>'; |
|
102 | + if($key=='education' and $value!=null) |
|
103 | + echo '<p>Education: '.$row["education"] .'</p><br>'; |
|
104 | + if($key=='gender' and $value!=null) |
|
105 | + echo '<p>Gender: '.$row["gender"] .'</p><br>'; |
|
106 | + } |
|
107 | + ?> |
|
108 | 108 | </div> |
109 | 109 | <?php if($_SESSION['start']==$row['login_id']) |
110 | - { |
|
111 | - ?> |
|
110 | + { |
|
111 | + ?> |
|
112 | 112 | <div class="edit"><a href="#">Edit Profile</a></div> |
113 | 113 | <?php |
114 | - } |
|
115 | - ?> |
|
114 | + } |
|
115 | + ?> |
|
116 | 116 | </div> |
117 | 117 | |
118 | 118 | <?php |
119 | - if($_SESSION['start']==$row['login_id']) |
|
120 | - { |
|
121 | - ?> |
|
119 | + if($_SESSION['start']==$row['login_id']) |
|
120 | + { |
|
121 | + ?> |
|
122 | 122 | |
123 | 123 | <div class="boxx" id="profile"> |
124 | 124 | <form method="post" action="../profile_generate.php"> |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | </form> |
134 | 134 | </div> |
135 | 135 | <?php |
136 | - } |
|
137 | - ?> |
|
136 | + } |
|
137 | + ?> |
|
138 | 138 | </div> |
139 | 139 | |
140 | 140 | |
@@ -153,20 +153,20 @@ discard block |
||
153 | 153 | |
154 | 154 | |
155 | 155 | <?php |
156 | - } |
|
157 | - else |
|
158 | - { |
|
159 | - die("Invalid User"); |
|
160 | - } |
|
161 | - } |
|
162 | - else |
|
163 | - { |
|
164 | - die("invalid"); |
|
165 | - } |
|
156 | + } |
|
157 | + else |
|
158 | + { |
|
159 | + die("Invalid User"); |
|
160 | + } |
|
161 | + } |
|
162 | + else |
|
163 | + { |
|
164 | + die("invalid"); |
|
165 | + } |
|
166 | 166 | } |
167 | 167 | else |
168 | 168 | { |
169 | - header("Location:http://localhost/openchat/index.php"); |
|
169 | + header("Location:http://localhost/openchat/index.php"); |
|
170 | 170 | } |
171 | 171 | ?> |
172 | 172 |
@@ -6,41 +6,41 @@ discard block |
||
6 | 6 | session_start(); |
7 | 7 | include 'database.php'; |
8 | 8 | $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
9 | -$user=explode("/", $_SERVER['REQUEST_URI']); |
|
10 | -$user = $user[count($user)-1]; |
|
9 | +$user = explode("/", $_SERVER['REQUEST_URI']); |
|
10 | +$user = $user[count($user) - 1]; |
|
11 | 11 | var_dump($user); |
12 | -if(isset($_SESSION['start']) and !$user) |
|
12 | +if (isset($_SESSION['start']) and !$user) |
|
13 | 13 | { |
14 | - $login_id=$_SESSION['start']; |
|
15 | - $query="SELECT username from login where login_id='$login_id'"; |
|
16 | - if($result=$connect->query($query)) |
|
14 | + $login_id = $_SESSION['start']; |
|
15 | + $query = "SELECT username from login where login_id='$login_id'"; |
|
16 | + if ($result = $connect->query($query)) |
|
17 | 17 | { |
18 | - if($result->num_rows >0) |
|
18 | + if ($result->num_rows > 0) |
|
19 | 19 | { |
20 | - $row=$result->fetch_assoc(); |
|
21 | - $location="http://localhost/openchat/account.php/".$row['username']; |
|
20 | + $row = $result->fetch_assoc(); |
|
21 | + $location = "http://localhost/openchat/account.php/".$row['username']; |
|
22 | 22 | header("Location:".$location); |
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | 26 | } |
27 | 27 | |
28 | -else if($user) |
|
28 | +else if ($user) |
|
29 | 29 | { |
30 | - $query="SELECT * from login where username='$user'"; |
|
31 | - if($result=$connect->query($query)) |
|
30 | + $query = "SELECT * from login where username='$user'"; |
|
31 | + if ($result = $connect->query($query)) |
|
32 | 32 | { |
33 | - if($result->num_rows >0) |
|
33 | + if ($result->num_rows > 0) |
|
34 | 34 | { |
35 | - $row=$result->fetch_assoc(); |
|
36 | - $id=$row['login_id']; |
|
37 | - $query="SELECT * from profile where login_id='$id'"; |
|
38 | - if($result=$connect->query($query)) |
|
35 | + $row = $result->fetch_assoc(); |
|
36 | + $id = $row['login_id']; |
|
37 | + $query = "SELECT * from profile where login_id='$id'"; |
|
38 | + if ($result = $connect->query($query)) |
|
39 | 39 | { |
40 | - if($result->num_rows>0) |
|
40 | + if ($result->num_rows > 0) |
|
41 | 41 | { |
42 | - $r=$result->fetch_assoc(); |
|
43 | - $row=array_merge($row,$r); |
|
42 | + $r = $result->fetch_assoc(); |
|
43 | + $row = array_merge($row, $r); |
|
44 | 44 | // var_dump($row); |
45 | 45 | } |
46 | 46 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | <a id="brand" href="">OpenChat</a> |
63 | 63 | <ul class="nav-right"> |
64 | 64 | <li><a href="../index.php">About</a></li> |
65 | - <?php if(isset($_SESSION['start'])) |
|
65 | + <?php if (isset($_SESSION['start'])) |
|
66 | 66 | { |
67 | 67 | ?> |
68 | 68 | <li><a href="../message.php">Message</a></li> |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | <div class="brief"> |
94 | 94 | <h1 id="name">Name: <?php echo $row['name']; ?></h1><br> |
95 | 95 | <?php foreach ($row as $key => $value) { |
96 | - if($key=='username' and $value!=null) |
|
97 | - echo '<p>Username: '.$row["username"] .'</p><br>'; |
|
98 | - if($key=='email' and $value!=null) |
|
99 | - echo '<p>Email Id: '.$row["email"] .'</p><br>'; |
|
100 | - if($key=='status' and $value!=null) |
|
101 | - echo '<p>Status: '.$row["status"] .'</p><br>'; |
|
102 | - if($key=='education' and $value!=null) |
|
103 | - echo '<p>Education: '.$row["education"] .'</p><br>'; |
|
104 | - if($key=='gender' and $value!=null) |
|
105 | - echo '<p>Gender: '.$row["gender"] .'</p><br>'; |
|
96 | + if ($key == 'username' and $value != null) |
|
97 | + echo '<p>Username: '.$row["username"].'</p><br>'; |
|
98 | + if ($key == 'email' and $value != null) |
|
99 | + echo '<p>Email Id: '.$row["email"].'</p><br>'; |
|
100 | + if ($key == 'status' and $value != null) |
|
101 | + echo '<p>Status: '.$row["status"].'</p><br>'; |
|
102 | + if ($key == 'education' and $value != null) |
|
103 | + echo '<p>Education: '.$row["education"].'</p><br>'; |
|
104 | + if ($key == 'gender' and $value != null) |
|
105 | + echo '<p>Gender: '.$row["gender"].'</p><br>'; |
|
106 | 106 | } |
107 | 107 | ?> |
108 | 108 | </div> |
109 | - <?php if($_SESSION['start']==$row['login_id']) |
|
109 | + <?php if ($_SESSION['start'] == $row['login_id']) |
|
110 | 110 | { |
111 | 111 | ?> |
112 | 112 | <div class="edit"><a href="#">Edit Profile</a></div> |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | </div> |
117 | 117 | |
118 | 118 | <?php |
119 | - if($_SESSION['start']==$row['login_id']) |
|
119 | + if ($_SESSION['start'] == $row['login_id']) |
|
120 | 120 | { |
121 | 121 | ?> |
122 | 122 | |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | <label>Education : </label> |
128 | 128 | <input type="text" name="education" id="education" value="<?php echo $row['education']; ?>"></input> |
129 | 129 | <label>Gender : </label><br> |
130 | - <input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender']=='Male')?'checked':'' ?>> Male<br> |
|
131 | - <input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender']=='Female')?'checked':'' ?>> Female<br> |
|
130 | + <input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender'] == 'Male') ? 'checked' : '' ?>> Male<br> |
|
131 | + <input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender'] == 'Female') ? 'checked' : '' ?>> Female<br> |
|
132 | 132 | <input type="submit" name="submit" value="Done" id="submit"> |
133 | 133 | </form> |
134 | 134 | </div> |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | namespace ChatApp; |
4 | -require_once (dirname(__DIR__) . '/database.php'); |
|
4 | +require_once (dirname(__DIR__).'/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 | } |
@@ -40,18 +40,15 @@ |
||
40 | 40 | } |
41 | 41 | $this->array = array_merge([], ["Compose" => $this->array]); |
42 | 42 | return json_encode($this->array); |
43 | - } |
|
44 | - else |
|
43 | + } else |
|
45 | 44 | { |
46 | 45 | return json_encode(["Compose" => "Not Found"]); |
47 | 46 | } |
48 | - } |
|
49 | - else |
|
47 | + } else |
|
50 | 48 | { |
51 | 49 | return json_encode(["Compose" => "Query Failed"]); |
52 | 50 | } |
53 | - } |
|
54 | - else |
|
51 | + } else |
|
55 | 52 | { |
56 | 53 | return json_encode(["Compose" => "Not Found"]); |
57 | 54 | } |