-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
182 lines (148 loc) · 4.43 KB
/
index.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
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
<?php
require 'core.inc.php';
require 'connect.inc.php';
$message = $name = $text = "";
if(loggedin()){
$message = '<a href="logout.php">Log Out</a>';
$name = getuserfield('firstname')." ".getuserfield('surname');
$username = getuserfield('username');
if(isset($_POST['text'])){
$text = $_POST['text'];
if(!empty($text)){
$query = "INSERT INTO `$username` VALUES ('','".mysql_real_escape_string($text)."','')";
$query_run = mysql_query($query);
}
}
function delete_note($del, $name){
$delete = "DELETE FROM `$name` where `id` = '".$del."' ";
$delete_run = mysql_query($delete);
}
?>
<html>
<head>
<title>Quick Notes</title>
<meta charset="utf-8">
<link rel="stylesheet" href="project5.css">
<link rel="icon" href="favicon.png" type="image">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
var name = "<?php echo $username; ?>";
$(document).ready(function(){
$(".del_note").click(function(){
var id = $(this).attr('id') ;
$.ajax({
url: 'test.php',
type: "POST",
data: "id=" + id + "&name=" + name,
success: function(data) {
console.log(data);
$("#"+id).hide(1000);
}
});
});
});
$(document).ready(function(){
$('#chat_box').fadeIn(500);
$('.submit').click(function(){
var sender = name;
var message = $('#message').val();
if(message != '' && receiver != ''){
$.ajax({
url: 'chat.php',
type: "POST",
data: "sender=" + sender + "&message=" + message + "&receiver=" + receiver,
success: function(data) {
$('#chat_box').fadeIn(500);
$('#chat_box').html(data);
$('#chat_box').scrollTop($('#chat_box').prop('scrollHeight'));
$('#name').val("");
$('#message').val("");
}
});
}
});
});
function executeQuery() {
$.ajax({
url: 'update.php',
type: "POST",
data: "sender=" + name + "&receiver=" + receiver,
success: function(data) {
$('#chat_box').html(data);
}
});
setTimeout(executeQuery, 10000);
}
var receiver='';
$(document).ready(function() {
$('.chatters').click(function(){
$('.active').removeClass('active');
$(this).addClass('active');
receiver = $(this).text();
$('#chat_box').scrollTop($('#chat_box').prop('scrollHeight'));
executeQuery();
});
});
/*function chatlistupdate() {
$.ajax({
url: 'chatlist.php',
success: function(data) {
$('#chat_list').html(data);
}
});
setTimeout(chatlistupdate, 2000);
}*/
$(document).ready(function() {
//setTimeout(chatlistupdate, 2000);
//default chat which comes on page loading
$('#10').addClass('active');
receiver = $('#10').html();
executeQuery();
setTimeout(executeQuery, 10000);
});
</script>
</head>
<body>
<div id="container">
<div id="header_bar">
QUICK NOTES
<div id="logout"><?php echo $message; ?></div>
</div>
<div id="hello"><?php echo "Hello ".$name; ?></div>
<div id="content">
<div id="chat_space">
<div id="chat_list">
<?php
$chatters = "SELECT * FROM `users`";
$chatters_run = mysql_query($chatters);
while($chatters_row = mysql_fetch_array($chatters_run)){
echo "<div class='chatters' id='".$chatters_row['id']."'>".$chatters_row['username']."</div>";
}
?>
</div>
<div id="ct">
<div id="chat_box">
</div>
<div id="textsend">
<textarea name="enter message" id="message" maxlength="200" placeholder="Enter Message(Max length 200)"></textarea>
<button class="submit" type="submit" name="submit">click me</button>
</div>
</div>
</div>
</div>
<div id="copyright">
Made with <i class="material-icons" style="color: red;">favorite</i> and <i class="fa fa-code" aria-hidden="true"></i>
by Neelanjan Akuli © 2017
</div>
</div>
</body>
</html>
<?php
}
else{
include 'login.inc.php';
}
?>