Completed
Push — master ( d60caa...394d07 )
by Ankit
02:48
created
src/Chat.php 2 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -25,6 +25,9 @@  discard block
 block discarded – undo
25 25
         Online::setOnlineStatus($conn->userId);
26 26
     }
27 27
 
28
+    /**
29
+     * @param ConnectionInterface $conn
30
+     */
28 31
     public function setID($conn) {
29 32
         session_id($conn->WebSocket->request->getCookies()['PHPSESSID']);
30 33
         @session_start();
@@ -117,11 +120,19 @@  discard block
 block discarded – undo
117 120
         return $obSidebar->loadSideBar($data);
118 121
     }
119 122
 
123
+    /**
124
+     * @param string $data
125
+     * @param boolean $para
126
+     */
120 127
     public function onConversation($data, $para) {
121 128
         $obConversation = new Conversation();
122 129
         return $obConversation->conversationLoad($data, $para);
123 130
     }
124 131
 
132
+    /**
133
+     * @param string $data
134
+     * @param boolean $para
135
+     */
125 136
     public function onReceiver($data, $para) {
126 137
         $obReceiver = new Receiver();
127 138
         return $obReceiver->receiverLoad($data, $para);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
     }
35 35
 
36 36
     public function onMessage(ConnectionInterface $from, $msg) {
37
-        $msg = (object) json_decode($msg);
37
+        $msg = (object)json_decode($msg);
38 38
         if ($msg->type == 'OpenChat initiated..!') {
39
-            $initial = (object) array();
39
+            $initial = (object)array();
40 40
             $initial->initial = json_decode($this->onSidebar($from->userId));
41 41
 
42 42
             if ($initial->initial != null) {
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
             }
53 53
             $from->send(json_encode($initial));
54 54
         } else if ($msg->type == 'Load Sidebar') {
55
-            $sidebar = (object) array();
55
+            $sidebar = (object)array();
56 56
             $sidebar->sidebar = json_decode($this->onSidebar($from->userId));
57 57
             $from->send(json_encode($sidebar));
58 58
         } else if ($msg->type == 'Initiated') {
59 59
             $msg->userId = $from->userId;
60
-            $result = (object) array();
60
+            $result = (object)array();
61 61
             $result->conversation = json_decode($this->onConversation(json_encode($msg), False));
62 62
             $from->send(json_encode($result));
63 63
         } else if ($msg->type == 'Search') {
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
             $getReturn = $this->onReply($msg);
76 76
             echo $getReturn;
77 77
 
78
-            $receiveResult = (object) array();
79
-            $sentResult = (object) array();
78
+            $receiveResult = (object)array();
79
+            $sentResult = (object)array();
80 80
             foreach ($this->clients as $client)
81 81
             {
82 82
                 if ($client->userId == $msg->name) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                     );
94 94
 
95 95
                     $client->send(json_encode($receiveResult));
96
-                } else if($client == $from) {
96
+                } else if ($client == $from) {
97 97
                     $sentResult->sidebar = json_decode($this->onSidebar($client->userId));
98 98
 
99 99
                     $sentResult->conversation = json_decode(
Please login to merge, or discard this patch.
src/Register.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -94,6 +94,9 @@
 block discarded – undo
94 94
     }
95 95
 
96 96
 
97
+    /**
98
+     * @param string $value
99
+     */
97 100
     public function onError($key, $value)
98 101
     {
99 102
         $this->flag = 1;
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
         $query = "INSERT INTO register VALUES(null, '$email', '$username', '$password')";
65 65
         if (!$this->connect->query($query)) {
66 66
             return json_encode(
67
-            	[
68
-            	"Error" => "You are not registered, ".$this->connect->error
69
-            	]
67
+                [
68
+                "Error" => "You are not registered, ".$this->connect->error
69
+                ]
70 70
             );
71 71
         }
72 72
         $query = "SELECT id FROM register WHERE email = '$email'";
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
 
87 87
             Session::put('start', $userId);
88 88
             return json_encode(
89
-            	[
89
+                [
90 90
                 "location" => getenv('APP_URL')."/views/account.php"
91
-            	]
91
+                ]
92 92
             );
93 93
         }
94 94
     }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,12 +76,12 @@
 block discarded – undo
76 76
             $query = "INSERT INTO login VALUES('$userId', '$name', '$email', '$username', '$mob', 0)";
77 77
 
78 78
             if (!$this->connect->query($query)) {
79
-                return json_encode(["Error" => "You are not registered, ".$this->connect->error ]);
79
+                return json_encode(["Error" => "You are not registered, ".$this->connect->error]);
80 80
             }
81 81
 
82 82
             $query = "INSERT INTO profile VALUES('$userId', 'Joined OpenChat', 'Joined OpenChat', '')";
83 83
             if (!$this->connect->query($query)) {
84
-                return json_encode(["Error" => "You are not registered, ".$this->connect->error ]);
84
+                return json_encode(["Error" => "You are not registered, ".$this->connect->error]);
85 85
             }
86 86
 
87 87
             Session::put('start', $userId);
Please login to merge, or discard this patch.
src/Reply.php 2 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -75,6 +75,11 @@
 block discarded – undo
75 75
         return "Failed";
76 76
     }
77 77
 
78
+    /**
79
+     * @param string $identifier
80
+     * @param string $reply
81
+     * @param string $time
82
+     */
78 83
     public function updateMessages($query, $identifier, $reply, $userId, $time)
79 84
     {
80 85
         if ($result = $this->connect->query($query)) {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
                 // geneate specific unique code to store messages
37 37
                 $user1 = $userId;
38 38
                 $user2 = $receiverID;
39
-                $identifier = $userId . ":" . $receiverID;
39
+                $identifier = $userId.":".$receiverID;
40 40
             } else {
41 41
                 $user1 = $receiverID;
42 42
                 $user2 = $userId;
43
-                $identifier = $receiverID . ":" . $userId;
43
+                $identifier = $receiverID.":".$userId;
44 44
             }
45 45
 
46 46
             $reply = addslashes(trim($msg->reply)); // stores the message sent by the user.
47 47
 
48
-            $time = date("D d M Y H:i:s", time() + 16200);  // current time
48
+            $time = date("D d M Y H:i:s", time() + 16200); // current time
49 49
             $time_id = date("YmdHis", time() + 16200); //to sort the array on the basis of time
50 50
 
51 51
             //the sender id must not be equal to current session id
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
                         return $this->updateMessages($query, $identifier, $reply, $userId, $time);
70 70
                     }
71 71
                 }
72
-                return "Invalid Authentication";  // if he is unauthorized echo message is failed
72
+                return "Invalid Authentication"; // if he is unauthorized echo message is failed
73 73
             }
74 74
         }
75 75
         return "Failed";
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             //insert message in db
82 82
             $query = "INSERT into messages values('$identifier', '$reply', '$userId', '$time', null)";
83 83
             if ($this->connect->query($query)) {
84
-                return "Messages is sent";    // if query is executed return true
84
+                return "Messages is sent"; // if query is executed return true
85 85
             }
86 86
             return "Message is failed";
87 87
         }
Please login to merge, or discard this patch.
views/account.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -65,20 +65,20 @@
 block discarded – undo
65 65
                         <div class="brief">
66 66
                             <h1 id="name">Name: <?php echo $row['name']; ?></h1><br>
67 67
                             <?php foreach ($row as $key => $value) {
68
-                                if ($key =='username' && $value != null) {
69
-                                    echo '<p>Username: '.$row["username"] .'</p><br>';
68
+                                if ($key == 'username' && $value != null) {
69
+                                    echo '<p>Username: '.$row["username"].'</p><br>';
70 70
                                 }
71 71
                                 if ($key == 'email' && $value != null) {
72
-                                    echo '<p>Email Id: '.$row["email"] .'</p><br>';
72
+                                    echo '<p>Email Id: '.$row["email"].'</p><br>';
73 73
                                 }
74 74
                                 if ($key == 'status' && $value != null) {
75
-                                    echo '<p>Status: '.$row["status"] .'</p><br>';
75
+                                    echo '<p>Status: '.$row["status"].'</p><br>';
76 76
                                 }
77 77
                                 if ($key == 'education' && $value != null) {
78
-                                    echo '<p>Education: '.$row["education"] .'</p><br>';
78
+                                    echo '<p>Education: '.$row["education"].'</p><br>';
79 79
                                 }
80 80
                                 if ($key == 'gender' && $value != null) {
81
-                                    echo '<p>Gender:     '.$row["gender"] .'</p><br>';
81
+                                    echo '<p>Gender:     '.$row["gender"].'</p><br>';
82 82
                                 }
83 83
                             }
84 84
                             ?>
Please login to merge, or discard this patch.
src/Conversation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
                     if ($result->num_rows > 0) {
77 77
                         while ($row = $result->fetch_assoc()) {
78 78
                             $row['time'] = $this->obTime->timeConversion($row['time']);
79
-                            $row = array_merge($row,['start' => $userId]);
79
+                            $row = array_merge($row, ['start' => $userId]);
80 80
                             $this->array = array_merge($this->array, [$row]);
81 81
                         }
82 82
 
Please login to merge, or discard this patch.
src/Login.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,12 +58,12 @@
 block discarded – undo
58 58
                         $this->onError("passLogin", " *Invalid password");
59 59
                         return json_encode($this->error);
60 60
                     }
61
-                    return json_encode(["Error" => "You are not registered, ".$this->connect->error ]);
61
+                    return json_encode(["Error" => "You are not registered, ".$this->connect->error]);
62 62
                 }
63 63
                 $this->onError("login", " *Invalid username or email");
64 64
                 return json_encode($this->error);
65 65
             }
66
-            return json_encode(["Error" => "You are not registered, ".$this->connect->error ]);
66
+            return json_encode(["Error" => "You are not registered, ".$this->connect->error]);
67 67
         } else {
68 68
             return json_encode($this->error);
69 69
         }
Please login to merge, or discard this patch.
src/Receiver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
         $msg = json_encode($msg);
37 37
         $this->messages = json_decode($this->conversation->conversationLoad($msg, $para));
38 38
         // $id1 = json_decode($msg)->details;
39
-        for ($i=1 ; $i < count($this->messages); $i++) {
39
+        for ($i = 1; $i < count($this->messages); $i++) {
40 40
             $this->messages[$i]->start = $id1;
41 41
         }
42 42
         $id2 = bin2hex(convert_uuencode($id2));
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
     public 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
 
29 29
         return $time;
Please login to merge, or discard this patch.
cmd.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@
 block discarded – undo
9 9
 
10 10
 $server = IoServer::factory(
11 11
     new HttpServer(
12
-		new WsServer(
13
-			new Chat()
14
-			)
15
-		)
16
-	,
17
-	8080
18
-	);
12
+        new WsServer(
13
+            new Chat()
14
+            )
15
+        )
16
+    ,
17
+    8080
18
+    );
19 19
 $server->run();
Please login to merge, or discard this patch.