forked from rishirdua/smart-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logout.php
32 lines (30 loc) · 804 Bytes
/
logout.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!--
Smart Chat
Authors:
Rishi Dua <https://github.com/rishirdua>
Harvineet Singh <https://github.com/harvineet>
File description: Removes user from list of logged in users
This projected is licensed under the terms of the MIT license. See LICENCE.txt for details
-->
<?php
include "config.php";
if (empty($_GET)) {
echo "You have been logged out";
}
else {
$userid = $_SERVER['QUERY_STRING'] ;
$file = file_get_contents($users_file);
$lines = explode("\n",$file);
$num = count($lines);
echo $num;
file_put_contents($users_file, "");
for ($i = 0; $i < $num; $i++) {
$data = explode(",",$lines[$i]);
$uid = $data[0];
if( $userid != $uid) {
file_put_contents($users_file, $lines[$i]."\n", FILE_APPEND);
}
}
header("location: index.php?alert=5");
}
?>