@@ -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 |
@@ -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); |
@@ -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)) |
@@ -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 @@ |
||
1 | 1 | <?php |
2 | - // Define database connection constants |
|
3 | - define('DB_HOST', 'localhost'); |
|
4 | - define('DB_USER', 'root'); |
|
5 | - define('DB_PASSWORD',''); |
|
6 | - define('DB_NAME', 'openchat'); |
|
2 | + // Define database connection constants |
|
3 | + define('DB_HOST', 'localhost'); |
|
4 | + define('DB_USER', 'root'); |
|
5 | + define('DB_PASSWORD',''); |
|
6 | + define('DB_NAME', 'openchat'); |
|
7 | 7 | ?> |
@@ -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 |
@@ -10,43 +10,43 @@ discard block |
||
10 | 10 | // var_dump($user); |
11 | 11 | if(isset($_SESSION['start']) and !$user) |
12 | 12 | { |
13 | - $login_id=$_SESSION['start']; |
|
14 | - $query="SELECT username from login where login_id='$login_id'"; |
|
15 | - if($result=$connect->query($query)) |
|
16 | - { |
|
17 | - if($result->num_rows >0) |
|
18 | - { |
|
19 | - $row=$result->fetch_assoc(); |
|
20 | - $location="http://localhost/openchat/account.php/".$row['username']; |
|
21 | - header("Location:".$location); |
|
22 | - } |
|
23 | - } |
|
13 | + $login_id=$_SESSION['start']; |
|
14 | + $query="SELECT username from login where login_id='$login_id'"; |
|
15 | + if($result=$connect->query($query)) |
|
16 | + { |
|
17 | + if($result->num_rows >0) |
|
18 | + { |
|
19 | + $row=$result->fetch_assoc(); |
|
20 | + $location="http://localhost/openchat/account.php/".$row['username']; |
|
21 | + header("Location:".$location); |
|
22 | + } |
|
23 | + } |
|
24 | 24 | |
25 | 25 | } |
26 | 26 | |
27 | 27 | else if($user) |
28 | 28 | { |
29 | - $query="SELECT * from login where username='$user'"; |
|
30 | - if($result=$connect->query($query)) |
|
31 | - { |
|
32 | - if($result->num_rows >0) |
|
33 | - { |
|
34 | - $row=$result->fetch_assoc(); |
|
35 | - $id=$row['login_id']; |
|
36 | - $query="SELECT * from profile where login_id='$id'"; |
|
37 | - if($result=$connect->query($query)) |
|
38 | - { |
|
39 | - if($result->num_rows>0) |
|
40 | - { |
|
41 | - $r=$result->fetch_assoc(); |
|
42 | - $row=array_merge($row,$r); |
|
43 | - // var_dump($row); |
|
44 | - } |
|
45 | - } |
|
46 | - else |
|
47 | - { |
|
48 | - die("error"); |
|
49 | - } |
|
29 | + $query="SELECT * from login where username='$user'"; |
|
30 | + if($result=$connect->query($query)) |
|
31 | + { |
|
32 | + if($result->num_rows >0) |
|
33 | + { |
|
34 | + $row=$result->fetch_assoc(); |
|
35 | + $id=$row['login_id']; |
|
36 | + $query="SELECT * from profile where login_id='$id'"; |
|
37 | + if($result=$connect->query($query)) |
|
38 | + { |
|
39 | + if($result->num_rows>0) |
|
40 | + { |
|
41 | + $r=$result->fetch_assoc(); |
|
42 | + $row=array_merge($row,$r); |
|
43 | + // var_dump($row); |
|
44 | + } |
|
45 | + } |
|
46 | + else |
|
47 | + { |
|
48 | + die("error"); |
|
49 | + } |
|
50 | 50 | ?> |
51 | 51 | <head> |
52 | 52 | <title>OpenChat || Profile</title> |
@@ -62,20 +62,20 @@ discard block |
||
62 | 62 | <ul class="nav-right"> |
63 | 63 | <li><a href="../index.php">About</a></li> |
64 | 64 | <?php if(isset($_SESSION['start'])) |
65 | - { |
|
66 | - ?> |
|
65 | + { |
|
66 | + ?> |
|
67 | 67 | <li><a href="../message.php">Message</a></li> |
68 | 68 | <li><a href="../registration-module/source/class.logout.php">Log out</a></li> |
69 | 69 | <?php |
70 | - } |
|
71 | - else |
|
72 | - { |
|
73 | - ?> |
|
70 | + } |
|
71 | + else |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <li><a href="../login.php">Login</a></li> |
75 | 75 | <li><a href="../register.php">Register</a></li> |
76 | 76 | <?php |
77 | - } |
|
78 | - ?> |
|
77 | + } |
|
78 | + ?> |
|
79 | 79 | </ul> |
80 | 80 | </div> |
81 | 81 | |
@@ -92,32 +92,32 @@ discard block |
||
92 | 92 | <div class="brief"> |
93 | 93 | <h1 id="name">Name: <?php echo $row['name']; ?></h1><br> |
94 | 94 | <?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>'; |
|
105 | - } |
|
106 | - ?> |
|
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>'; |
|
105 | + } |
|
106 | + ?> |
|
107 | 107 | </div> |
108 | 108 | <?php if($_SESSION['start']==$row['login_id']) |
109 | - { |
|
110 | - ?> |
|
109 | + { |
|
110 | + ?> |
|
111 | 111 | <div class="edit"><a href="#">Edit Profile</a></div> |
112 | 112 | <?php |
113 | - } |
|
114 | - ?> |
|
113 | + } |
|
114 | + ?> |
|
115 | 115 | </div> |
116 | 116 | |
117 | 117 | <?php |
118 | - if($_SESSION['start']==$row['login_id']) |
|
119 | - { |
|
120 | - ?> |
|
118 | + if($_SESSION['start']==$row['login_id']) |
|
119 | + { |
|
120 | + ?> |
|
121 | 121 | |
122 | 122 | <div class="boxx" id="profile"> |
123 | 123 | <form method="post" action="../profile_generate.php"> |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | </form> |
133 | 133 | </div> |
134 | 134 | <?php |
135 | - } |
|
136 | - ?> |
|
135 | + } |
|
136 | + ?> |
|
137 | 137 | </div> |
138 | 138 | |
139 | 139 | |
@@ -152,20 +152,20 @@ discard block |
||
152 | 152 | |
153 | 153 | |
154 | 154 | <?php |
155 | - } |
|
156 | - else |
|
157 | - { |
|
158 | - die("Invalid User"); |
|
159 | - } |
|
160 | - } |
|
161 | - else |
|
162 | - { |
|
163 | - die("invalid"); |
|
164 | - } |
|
155 | + } |
|
156 | + else |
|
157 | + { |
|
158 | + die("Invalid User"); |
|
159 | + } |
|
160 | + } |
|
161 | + else |
|
162 | + { |
|
163 | + die("invalid"); |
|
164 | + } |
|
165 | 165 | } |
166 | 166 | else |
167 | 167 | { |
168 | - header("Location:http://localhost/openchat/index.php"); |
|
168 | + header("Location:http://localhost/openchat/index.php"); |
|
169 | 169 | } |
170 | 170 | ?> |
171 | 171 |
@@ -8,16 +8,16 @@ |
||
8 | 8 | use ChatApp\Chat; |
9 | 9 | |
10 | 10 | $server =IoServer::factory( |
11 | - new HttpServer( |
|
12 | - new WsServer( |
|
13 | - new Chat() |
|
14 | - ) |
|
15 | - ) |
|
16 | - , |
|
17 | - 8080 |
|
18 | - ); |
|
11 | + new HttpServer( |
|
12 | + new WsServer( |
|
13 | + new Chat() |
|
14 | + ) |
|
15 | + ) |
|
16 | + , |
|
17 | + 8080 |
|
18 | + ); |
|
19 | 19 | $server->run(); |
20 | 20 | |
21 | 21 | |
22 | 22 | |
23 | - ?> |
|
24 | 23 | \ No newline at end of file |
24 | + ?> |
|
25 | 25 | \ No newline at end of file |
@@ -131,6 +131,6 @@ |
||
131 | 131 | <?php |
132 | 132 | } |
133 | 133 | else{ |
134 | - header('Location:http://www.localhost/openchat/login.php'); |
|
134 | + header('Location:http://www.localhost/openchat/login.php'); |
|
135 | 135 | } |
136 | 136 | ?> |