@@ -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 | |
@@ -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 | * |
@@ -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 | |
@@ -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 | ?> |
@@ -3,17 +3,17 @@ |
||
| 3 | 3 | require_once '../source/class.register.php'; |
| 4 | 4 | if(isset($_POST['q'])) |
| 5 | 5 | { |
| 6 | - $register_field=json_decode($_POST['q']); |
|
| 7 | - $name=$register_field->name; |
|
| 8 | - $email=$register_field->email; |
|
| 9 | - $username=$register_field->username; |
|
| 10 | - $mob=$register_field->mob; |
|
| 11 | - $password=$register_field->password; |
|
| 12 | - $ob = new register(); |
|
| 13 | - $result=$ob->_register($name,$email,$username,$password,$mob); |
|
| 14 | - if(isset($result)) |
|
| 15 | - echo $result; |
|
| 16 | - else |
|
| 17 | - echo json_encode([]); |
|
| 6 | + $register_field=json_decode($_POST['q']); |
|
| 7 | + $name=$register_field->name; |
|
| 8 | + $email=$register_field->email; |
|
| 9 | + $username=$register_field->username; |
|
| 10 | + $mob=$register_field->mob; |
|
| 11 | + $password=$register_field->password; |
|
| 12 | + $ob = new register(); |
|
| 13 | + $result=$ob->_register($name,$email,$username,$password,$mob); |
|
| 14 | + if(isset($result)) |
|
| 15 | + echo $result; |
|
| 16 | + else |
|
| 17 | + echo json_encode([]); |
|
| 18 | 18 | } |
| 19 | 19 | ?> |
| 20 | 20 | \ No newline at end of file |
@@ -3,14 +3,14 @@ |
||
| 3 | 3 | require_once '../source/class.login.php'; |
| 4 | 4 | if(isset($_POST['q'])) |
| 5 | 5 | { |
| 6 | - $login_field=json_decode($_POST['q']); |
|
| 7 | - $login=$login_field->login; |
|
| 8 | - $password=$login_field->password; |
|
| 9 | - $ob = new login(); |
|
| 10 | - $result=$ob->_login($login,$password); |
|
| 11 | - if(isset($result)) |
|
| 12 | - echo $result; |
|
| 13 | - else |
|
| 14 | - echo json_encode([]); |
|
| 6 | + $login_field=json_decode($_POST['q']); |
|
| 7 | + $login=$login_field->login; |
|
| 8 | + $password=$login_field->password; |
|
| 9 | + $ob = new login(); |
|
| 10 | + $result=$ob->_login($login,$password); |
|
| 11 | + if(isset($result)) |
|
| 12 | + echo $result; |
|
| 13 | + else |
|
| 14 | + echo json_encode([]); |
|
| 15 | 15 | } |
| 16 | 16 | ?> |
| 17 | 17 | \ No newline at end of file |
@@ -5,36 +5,36 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | class register |
| 7 | 7 | { |
| 8 | - private $array_error; |
|
| 9 | - private $name; |
|
| 10 | - private $email; |
|
| 11 | - private $username; |
|
| 12 | - private $password; |
|
| 13 | - private $mob; |
|
| 14 | - private $key; |
|
| 15 | - private $ob; |
|
| 16 | - private $connect; |
|
| 17 | - |
|
| 18 | - function __construct() |
|
| 19 | - { |
|
| 20 | - $this->array_error=array(); |
|
| 21 | - $this->key=0; |
|
| 22 | - $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
|
| 23 | - $this->ob=new validate(); |
|
| 24 | - |
|
| 25 | - |
|
| 26 | - $query="CREATE TABLE IF NOT EXISTS register ( |
|
| 8 | + private $array_error; |
|
| 9 | + private $name; |
|
| 10 | + private $email; |
|
| 11 | + private $username; |
|
| 12 | + private $password; |
|
| 13 | + private $mob; |
|
| 14 | + private $key; |
|
| 15 | + private $ob; |
|
| 16 | + private $connect; |
|
| 17 | + |
|
| 18 | + function __construct() |
|
| 19 | + { |
|
| 20 | + $this->array_error=array(); |
|
| 21 | + $this->key=0; |
|
| 22 | + $this->connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
|
| 23 | + $this->ob=new validate(); |
|
| 24 | + |
|
| 25 | + |
|
| 26 | + $query="CREATE TABLE IF NOT EXISTS register ( |
|
| 27 | 27 | id int primary key auto_increment unique not null, |
| 28 | 28 | email varchar(255) unique not null, |
| 29 | 29 | username varchar(255) unique not null, |
| 30 | 30 | password varchar(255) not null |
| 31 | 31 | ) ENGINE=INNODB;"; |
| 32 | 32 | |
| 33 | - if (!$this->connect->query($query)) { |
|
| 34 | - echo "Table is not created || Query failed"; |
|
| 35 | - } |
|
| 33 | + if (!$this->connect->query($query)) { |
|
| 34 | + echo "Table is not created || Query failed"; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - $query="CREATE TABLE IF NOT EXISTS login ( |
|
| 37 | + $query="CREATE TABLE IF NOT EXISTS login ( |
|
| 38 | 38 | login_id int primary key not null, |
| 39 | 39 | name varchar(255) not null, |
| 40 | 40 | email varchar(255) unique not null, |
@@ -44,121 +44,121 @@ discard block |
||
| 44 | 44 | FOREIGN KEY (login_id) REFERENCES register(id) |
| 45 | 45 | ) ENGINE=INNODB;"; |
| 46 | 46 | |
| 47 | - if (!$this->connect->query($query)) { |
|
| 48 | - echo "Table is not created || Query failed"; |
|
| 49 | - } |
|
| 47 | + if (!$this->connect->query($query)) { |
|
| 48 | + echo "Table is not created || Query failed"; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - $query="CREATE TABLE IF NOT EXISTS profile ( |
|
| 51 | + $query="CREATE TABLE IF NOT EXISTS profile ( |
|
| 52 | 52 | login_id int primary key not null unique, |
| 53 | 53 | status text, |
| 54 | 54 | education text, |
| 55 | 55 | gender varchar(10) |
| 56 | 56 | ) ENGINE=INNODB;"; |
| 57 | 57 | |
| 58 | - if (!$this->connect->query($query)) { |
|
| 59 | - echo "Table is not created || Query failed"; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - function _register($name,$email,$username,$password,$mob) |
|
| 65 | - { |
|
| 66 | - $this->name=trim($name); |
|
| 67 | - $this->email=trim($email); |
|
| 68 | - $this->username=trim($username); |
|
| 69 | - $this->password=trim($password); |
|
| 70 | - $this->mob=trim($mob); |
|
| 71 | - if (empty($this->name)) { |
|
| 72 | - $this->key=1; |
|
| 73 | - $this->array_error=array_merge($this->array_error,["name"=>"Enter the name"]); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - if(empty($this->email)) { |
|
| 77 | - $this->key=1; |
|
| 78 | - $this->array_error=array_merge($this->array_error,["email"=>"Enter the email address"]); |
|
| 79 | - } |
|
| 80 | - elseif(filter_var($this->email,FILTER_VALIDATE_EMAIL)== false) { |
|
| 81 | - $this->key=1; |
|
| 82 | - $this->array_error=array_merge($this->array_error,["email"=>"Enter correct Email address"]); |
|
| 83 | - } |
|
| 84 | - else |
|
| 85 | - { |
|
| 86 | - if($this->ob->validate_email_in_db($this->email)) |
|
| 87 | - { |
|
| 88 | - $this->key=1; |
|
| 89 | - $this->array_error=array_merge($this->array_error,["email"=>"Email is already registered"]); |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - if(empty($this->username)) { |
|
| 94 | - $this->key=1; |
|
| 95 | - $this->array_error=array_merge($this->array_error,["username"=>"Enter the username"]); |
|
| 96 | - } |
|
| 97 | - else |
|
| 98 | - { |
|
| 99 | - if($this->ob->validate_username_in_db($this->username)) |
|
| 100 | - { |
|
| 101 | - $this->key=1; |
|
| 102 | - $this->array_error=array_merge($this->array_error,["username"=>"Username is already registered"]); |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - if(empty($this->password)) { |
|
| 107 | - $this->key=1; |
|
| 108 | - $this->array_error=array_merge($this->array_error,["password"=>"Enter the password"]); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - if(empty($this->mob)) { |
|
| 112 | - $this->key=1; |
|
| 113 | - $this->array_error=array_merge($this->array_error,["mob"=>"Enter the Mobile Number"]); |
|
| 114 | - } |
|
| 115 | - elseif (!preg_match("/^[0-9]{10}$/",$this->mob)) { |
|
| 116 | - $this->key=1; |
|
| 117 | - $this->array_error=array_merge($this->array_error,["mob"=>"Enter correct Mobile Number"]); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - if($this->key==1) |
|
| 121 | - { |
|
| 122 | - return json_encode($this->array_error); |
|
| 123 | - } |
|
| 124 | - else |
|
| 125 | - { |
|
| 126 | - $this->key=0; |
|
| 127 | - $pass=md5($this->password); |
|
| 128 | - $query="INSERT INTO register VALUES(null,'$this->email','$this->username','$pass')"; |
|
| 129 | - if(!$this->connect->query($query)) { |
|
| 130 | - $this->key=1; |
|
| 131 | - echo "You are not registered || Error in registration2"; |
|
| 132 | - } |
|
| 133 | - else |
|
| 134 | - { |
|
| 135 | - $query="SELECT id FROM register WHERE email='$this->email'"; |
|
| 136 | - if($result=$this->connect->query($query)) { |
|
| 137 | - $row=$result->fetch_assoc(); |
|
| 138 | - $id=$row['id']; |
|
| 139 | - |
|
| 140 | - $query="INSERT INTO login VALUES('$id','$this->name','$this->email','$this->username','$this->mob','1')"; |
|
| 141 | - if(!$this->connect->query($query)) { |
|
| 142 | - $this->key=1; |
|
| 143 | - echo "You are not registered || Error in registration1"; |
|
| 144 | - } |
|
| 145 | - $join="Joined OpenChat"; |
|
| 146 | - $query="INSERT INTO profile VALUES('$id','$join','$join','')"; |
|
| 147 | - if(!$this->connect->query($query)) { |
|
| 148 | - $this->key=1; |
|
| 149 | - echo "You are not updated || Error in profile"; |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - if ($this->key==0) { |
|
| 155 | - $_SESSION['start']=$id; |
|
| 156 | - return json_encode(["location"=>"http://localhost/openchat/account.php"]); |
|
| 157 | - } |
|
| 158 | - else |
|
| 159 | - { |
|
| 160 | - return json_encode($this->array_error); |
|
| 161 | - } |
|
| 162 | - } |
|
| 58 | + if (!$this->connect->query($query)) { |
|
| 59 | + echo "Table is not created || Query failed"; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + function _register($name,$email,$username,$password,$mob) |
|
| 65 | + { |
|
| 66 | + $this->name=trim($name); |
|
| 67 | + $this->email=trim($email); |
|
| 68 | + $this->username=trim($username); |
|
| 69 | + $this->password=trim($password); |
|
| 70 | + $this->mob=trim($mob); |
|
| 71 | + if (empty($this->name)) { |
|
| 72 | + $this->key=1; |
|
| 73 | + $this->array_error=array_merge($this->array_error,["name"=>"Enter the name"]); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + if(empty($this->email)) { |
|
| 77 | + $this->key=1; |
|
| 78 | + $this->array_error=array_merge($this->array_error,["email"=>"Enter the email address"]); |
|
| 79 | + } |
|
| 80 | + elseif(filter_var($this->email,FILTER_VALIDATE_EMAIL)== false) { |
|
| 81 | + $this->key=1; |
|
| 82 | + $this->array_error=array_merge($this->array_error,["email"=>"Enter correct Email address"]); |
|
| 83 | + } |
|
| 84 | + else |
|
| 85 | + { |
|
| 86 | + if($this->ob->validate_email_in_db($this->email)) |
|
| 87 | + { |
|
| 88 | + $this->key=1; |
|
| 89 | + $this->array_error=array_merge($this->array_error,["email"=>"Email is already registered"]); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + if(empty($this->username)) { |
|
| 94 | + $this->key=1; |
|
| 95 | + $this->array_error=array_merge($this->array_error,["username"=>"Enter the username"]); |
|
| 96 | + } |
|
| 97 | + else |
|
| 98 | + { |
|
| 99 | + if($this->ob->validate_username_in_db($this->username)) |
|
| 100 | + { |
|
| 101 | + $this->key=1; |
|
| 102 | + $this->array_error=array_merge($this->array_error,["username"=>"Username is already registered"]); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + if(empty($this->password)) { |
|
| 107 | + $this->key=1; |
|
| 108 | + $this->array_error=array_merge($this->array_error,["password"=>"Enter the password"]); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + if(empty($this->mob)) { |
|
| 112 | + $this->key=1; |
|
| 113 | + $this->array_error=array_merge($this->array_error,["mob"=>"Enter the Mobile Number"]); |
|
| 114 | + } |
|
| 115 | + elseif (!preg_match("/^[0-9]{10}$/",$this->mob)) { |
|
| 116 | + $this->key=1; |
|
| 117 | + $this->array_error=array_merge($this->array_error,["mob"=>"Enter correct Mobile Number"]); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + if($this->key==1) |
|
| 121 | + { |
|
| 122 | + return json_encode($this->array_error); |
|
| 123 | + } |
|
| 124 | + else |
|
| 125 | + { |
|
| 126 | + $this->key=0; |
|
| 127 | + $pass=md5($this->password); |
|
| 128 | + $query="INSERT INTO register VALUES(null,'$this->email','$this->username','$pass')"; |
|
| 129 | + if(!$this->connect->query($query)) { |
|
| 130 | + $this->key=1; |
|
| 131 | + echo "You are not registered || Error in registration2"; |
|
| 132 | + } |
|
| 133 | + else |
|
| 134 | + { |
|
| 135 | + $query="SELECT id FROM register WHERE email='$this->email'"; |
|
| 136 | + if($result=$this->connect->query($query)) { |
|
| 137 | + $row=$result->fetch_assoc(); |
|
| 138 | + $id=$row['id']; |
|
| 139 | + |
|
| 140 | + $query="INSERT INTO login VALUES('$id','$this->name','$this->email','$this->username','$this->mob','1')"; |
|
| 141 | + if(!$this->connect->query($query)) { |
|
| 142 | + $this->key=1; |
|
| 143 | + echo "You are not registered || Error in registration1"; |
|
| 144 | + } |
|
| 145 | + $join="Joined OpenChat"; |
|
| 146 | + $query="INSERT INTO profile VALUES('$id','$join','$join','')"; |
|
| 147 | + if(!$this->connect->query($query)) { |
|
| 148 | + $this->key=1; |
|
| 149 | + echo "You are not updated || Error in profile"; |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + if ($this->key==0) { |
|
| 155 | + $_SESSION['start']=$id; |
|
| 156 | + return json_encode(["location"=>"http://localhost/openchat/account.php"]); |
|
| 157 | + } |
|
| 158 | + else |
|
| 159 | + { |
|
| 160 | + return json_encode($this->array_error); |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | 163 | } |
| 164 | 164 | ?> |
| 165 | 165 | \ No newline at end of file |
@@ -15,6 +15,6 @@ |
||
| 15 | 15 | } |
| 16 | 16 | else |
| 17 | 17 | { |
| 18 | - echo "Please Login"; |
|
| 18 | + echo "Please Login"; |
|
| 19 | 19 | } |
| 20 | 20 | ?> |