Test Setup Failed
Push — master ( a87e27...976b69 )
by Ankit
02:24
created
src/Chat.php 2 patches
Doc Comments   +20 added lines patch added patch discarded remove patch
@@ -26,6 +26,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Reply.php 2 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -90,6 +90,11 @@
 block discarded – undo
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))
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
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
 * Store Message in the Database
@@ -21,37 +21,37 @@  discard block
 block discarded – undo
21 21
     public 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
 block discarded – undo
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
 block discarded – undo
92 92
 
93 93
     public 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
             {
Please login to merge, or discard this patch.
login.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Time.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@
 block discarded – undo
16 16
     function TimeConversion($time)
17 17
     {
18 18
 
19
-        if(substr($time,4,11) == date("d M Y", time() + 16200))
20
-            $time = substr($time,16,5);
21
-        else if(substr($time,7,8) == date("M Y", time() + 16200) && substr($time, 4,2) - date("d") < 7)
22
-            $time = substr($time,0,3);
23
-        else if(substr($time,11,4) == date("Y", time() + 16200))
24
-            $time = substr($time,4,6);
19
+        if (substr($time, 4, 11) == date("d M Y", time() + 16200))
20
+            $time = substr($time, 16, 5);
21
+        else if (substr($time, 7, 8) == date("M Y", time() + 16200) && substr($time, 4, 2) - date("d") < 7)
22
+            $time = substr($time, 0, 3);
23
+        else if (substr($time, 11, 4) == date("Y", time() + 16200))
24
+            $time = substr($time, 4, 6);
25 25
         else
26
-            $time = substr($time,4,11);
26
+            $time = substr($time, 4, 11);
27 27
 
28 28
         return $time;
29 29
     }
Please login to merge, or discard this patch.
src/Models/message.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 class Message extends Model
10 10
 {
11
-    protected $table='message';
11
+    protected $table = 'message';
12 12
 
13 13
     protected $fillable = ['identifier_message_number', 'message', 'sent_by', 'time'];
14 14
 }
Please login to merge, or discard this patch.
cmd.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 use Ratchet\WebSocket\WsServer;
8 8
 use ChatApp\Chat;
9 9
 
10
-$server =IoServer::factory(
10
+$server = IoServer::factory(
11 11
 	new HttpServer(
12 12
 		new WsServer(
13 13
 			new Chat()
Please login to merge, or discard this patch.
message.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 session_start();
3
-if(isset($_SESSION['start']) and empty($_GET['user']))
3
+if (isset($_SESSION['start']) and empty($_GET['user']))
4 4
 {
5 5
 ?>
6 6
 <!DOCTYPE html>
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 <?php
132 132
 }
133
-else{
133
+else {
134 134
 	header('Location:http://www.localhost/openchat/login.php');
135 135
 }
136 136
 ?>
Please login to merge, or discard this patch.
profile_generate.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -2,32 +2,32 @@
 block discarded – undo
2 2
 session_start();
3 3
 include 'database.php';
4 4
 $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
5
-$login_id=$_SESSION['start'];
6
-if(isset($_POST['submit']))
5
+$login_id = $_SESSION['start'];
6
+if (isset($_POST['submit']))
7 7
 {
8
-	$query="SELECT * from profile where login_id='$login_id'";
9
-	if($result=$connect->query($query))
8
+	$query = "SELECT * from profile where login_id='$login_id'";
9
+	if ($result = $connect->query($query))
10 10
 	{
11
-		if($result->num_rows>0)
11
+		if ($result->num_rows > 0)
12 12
 		{
13
-			$row=$result->fetch_assoc();
13
+			$row = $result->fetch_assoc();
14 14
 		}
15 15
 	}
16
-	if(trim($_POST['status']))
17
-		$status=$_POST['status'];
16
+	if (trim($_POST['status']))
17
+		$status = $_POST['status'];
18 18
 	else
19
-		$status=$row['status'];
20
-	if(trim($_POST['education']))
21
-		$edu=$_POST['education'];
19
+		$status = $row['status'];
20
+	if (trim($_POST['education']))
21
+		$edu = $_POST['education'];
22 22
 	else
23
-		$edu=$row['education'];
24
-	if(isset($_POST['gender']))
25
-		$gender=$_POST['gender'];
23
+		$edu = $row['education'];
24
+	if (isset($_POST['gender']))
25
+		$gender = $_POST['gender'];
26 26
 	else
27
-		$gender=$row['gender'];
27
+		$gender = $row['gender'];
28 28
 
29
-	$query="UPDATE profile set status='$status', education='$edu', gender='$gender' where login_id='$login_id'";
30
-	if($result=$connect->query($query))
29
+	$query = "UPDATE profile set status='$status', education='$edu', gender='$gender' where login_id='$login_id'";
30
+	if ($result = $connect->query($query))
31 31
 	{
32 32
 		header('Location: account.php');
33 33
 	}
Please login to merge, or discard this patch.
register.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.