-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.php
More file actions
118 lines (99 loc) · 4.82 KB
/
home.php
File metadata and controls
118 lines (99 loc) · 4.82 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bunny Chat</title>
<link rel="shortcut icon" href="img/favicon.gif" type="image/x-icon" />
<script src="js/jquery-2.1.1.min.js" type="text/javascript"></script>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-theme.min.css" rel="stylesheet">
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-ui.min.js" type="text/javascript"></script>
<link href="css/jquery-ui.min.css" rel="stylesheet">
<link href="css/jquery-ui.structure.min.css" rel="stylesheet">
<link href="css/jquery-ui.theme.min.css" rel="stylesheet">
<link href="css/mystyle.css" rel="stylesheet">
<script src="js/homeActions.js"></script>
<!-- Latest compiled and minified CSS -->
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Optional theme -->
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>-->
</head>
<body>
<?php
include 'ChatDAO.php';
$msg = '';
session_start(); // Starting Session
if (isset($_SESSION['login'])) {
$msg = 'Logged As: ';
} else if (isset($_SESSION['register'])) {
$msg = 'Logged As: ';
} else {
header("Location: index.php");
}
?>
<div id="dummy"></div>
<div id="msg" class="text-center center-block">
<h1>Welcome to BunnyChat</h1>
<h3><?php echo $msg; ?>
<div id="username">
<?php echo $_SESSION['login_user']; ?>
</div>
<br/>
</h3>
<div class="center-block">
<br>
<input class="center-block btn btn-danger btn-block btn-s" name="logout" type="button" value=" Logout " onclick="window.location = 'index.php'" style="width: 150px;">
</div>
<div id="info">
</div>
<br/>
</div>
<div id="tabs" class="center-block">
<ul id="tabsHeader">
<li><a href="#main">Friends List</a></li>
</ul>
<div id="main" class="tab active center-block">
<div class="form-group">
<div class="input-group">
<input class="form-control" type="text" id="friendName" name="friendName" autocomplete="on" placeholder="Write Your friend name here!">
<?php
setcookie("userField", $_SESSION['login_user']);
echo '<div class="btn btn-default btn-s input-group-addon" id="addBtn" onclick="addFriend(\'' . $_SESSION['login_user'] . '\')">Add</div>';
// printf('var userFiled1 = %s;', json_encode($_SESSION['login_user']));
?>
</div>
</div>
<div >
<table class="table table-hover" id="tableList">
<thead class="text-center">
<tr><th>Friend</th><th>Actions</th></tr>
</thead>
<tbody id="friends">
<?php
$dao = new ChatDAO();
$user = $_SESSION['login_user'];
$friends = $dao->getFriends($_SESSION['login_user']);
foreach ($friends as $friend) {
echo '<tr>';
echo "<td>$friend->friendName</td>";
echo "<td class=\"form-group\">"
. "<button class=\"chat\" id=\"chat\" onclick=\"chatFriend('$friend->friendName');\">Chat</button>   "
. "<button class=\"remove\" id=\"remove\" onclick=\"removeFriend('$friend->friendName');\">Remove</button><br />"
. "</td>";
echo '</tr>';
}
?>
</tbody>
</table>
</div>
<div id="result" class="form-group ">
</div>
</div>
</div>
</body>
</html>