-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroom.php
More file actions
193 lines (164 loc) · 5.78 KB
/
room.php
File metadata and controls
193 lines (164 loc) · 5.78 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
include 'db_connect.php';
$roomName = $_GET['room_name'];
$username = $_GET['username'];
$query = "SELECT * FROM `claimed_rooms` WHERE room_name = '$roomName'";
$result = mysqli_query($conn, $query);
if($result){
if(mysqli_num_rows($result) == 0){
$msg = "room doesn't exist...first create room";
echo "<script language = 'javascript'>";
echo "alert('$msg');";
echo 'window.location="./home2.php";';
echo "</script>";
}
else{
}
}
else{
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link href="/docs/5.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link href="product.css" rel="stylesheet">
<style>
body {
background: rgb(54, 54, 63);
margin: 0 auto;
max-width: 800px;
padding: 0 20px;
}
.container {
border: 2px solid #dedede;
background-color: #f1f1f1;
border-radius: 5px;
padding: 10px;
margin: 10px 0;
}
.darker {
border-color: #ccc;
background-color: #ddd;
}
.container::after {
content: "";
clear: both;
display: table;
}
.container img {
float: left;
max-width: 60px;
width: 100%;
margin-right: 20px;
border-radius: 50%;
}
.container img.right {
float: right;
margin-left: 20px;
margin-right:0;
}
.time-right {
float: right;
color: #aaa;
}
.time-left {
float: left;
color: #999;
}
.anyClass{
height: 350px;
overflow-y: auto;
scroll-behavior: revert;
}
</style>
</head>
<body>
<div style="background-color: black;">
</div>
<!-- <header class="site-header sticky-top py-1"> -->
<!-- </header> -->
<br>
<h2 style="color: whitesmoke;">Chat Messages - <?php echo $roomName ?></h2>
<h2 style="color: whitesmoke;"><?php echo $_GET['username'] ?></h2>
<form action="login.php" method="get">
<!-- <input type="submit" value="Logout"> -->
<button class="btn btn-outline-secondary" href="#" style="background-color: lightskyblue;">
Logout
</button>
</form><br>
<form action="deletechat.php" method="get">
<input type="hidden" name="name" value="<?php echo $_GET['username'];?>">
<input type="hidden" name="roomname" value="<?php echo $roomName;?>">
<button class="btn btn-outline-secondary" name="clear" id="clear" style="background-color: lightskyblue;">
DeleteChat
</button>
</form><br>
<form action="export.php" method="get">
<input type="hidden" name="name" value="<?php echo $_GET['username'];?>">
<input type="hidden" name="roomname" value="<?php echo $roomName;?>">
<button class="btn btn-outline-secondary" name="export" id="export" style="background-color: lightskyblue;">
Export
</button>
</form>
<!-- <button>
<h6>Logout</h6>
</button> -->
<div class="container">
<div class="anyClass">
<!-- <img src="/w3images/bandmember.jpg" alt="Avatar" style="width:100%;"> -->
<!-- <p>Hello. How are you today?</p> -->
<!-- <span class="time-right">11:00</span> -->
</div>
</div>
<input type="text" class="form-control" name="msg" id="msg" placeholder="Type Message"><br>
<button class="btn btn-outline-secondary" name="submitmsg" id="submitmsg" style="background-color: lightskyblue;">
Send
</button>
<!-- </button> -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script src="/docs/5.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script type="text/javascript">
setInterval(runFunction, 1000);
function runFunction(){
$.post("chats.php", {roombox:'<?php echo $roomName ?>', name:'<?php echo $username?>'},
function(data, status){
document.getElementsByClassName('anyClass')[0].innerHTML = data;
}
)
}
// function PrintChat() {
// $.post("chats.php", {roombox:'<?php echo $roomName ?>', name:'<?php echo $username?>'},
// function(data, status){
// var chatContents = document.getElementById('anyclass')[0].innerHTML;
// var printWindow = window.open('', '', 'height=200,width=400');
// printWindow.document.write('<html><head><title>Chat</title>');
// printWindow.document.write('</head><body >');
// printWindow.document.write(chatContents);
// printWindow.document.write('</body></html>');
// printWindow.document.close();
// printWindow.print();
// }
// }
var input = document.getElementById("msg");
input.addEventListener("keyup", function(event) {
if (event.keyCode === 13) {
event.preventDefault();
document.getElementById("submitmsg").click();
}
});
$("#submitmsg").click(function(){
var c_msg = $("#msg").val();
$.post("msg.php", {msg: c_msg, room: '<?php echo $roomName?>', ip: '<?php echo $_GET['username']?>'},
function(data, status){
document.getElementsByClassName('anyClass')[0].innerHTML = data;});
$("#msg").val("");
return false;
});
</script>
</div>
</body>
</html>