-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsg.php
More file actions
139 lines (87 loc) · 2.58 KB
/
Copy pathmsg.php
File metadata and controls
139 lines (87 loc) · 2.58 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
<?php
include('conexao_bd.php');
include('verifica_login.php');
$usu = $_SESSION['usu'];
$sql = "select id,usuario, mensagem,horario,entrar from chat";
$result = $con->query($sql);
@$entrar = $_POST['entrar'];
if($entrar == 1){
date_default_timezone_set("America/Sao_Paulo");
$date = date('H:i:s');
$sql = "insert into chat (usuario,mensagem,horario,entrar) values ('$usu','$usu pegou o bonde andando!','$date','1');";
$result = $con->query($sql);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Siscon</title>
<meta charset="UTF-8">
<!--<META HTTP-EQUIV="REFRESH" CONTENT="5; URL=msg.php">-->
<link rel="stylesheet" type="text/css" href="style2.css">
<script type="text/javascript">
function Ajax(){
var xmlHttp;
try{
xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
}
catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!?");
return false;
}
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
document.getElementById('chat').innerHTML=xmlHttp.responseText;
setTimeout('Ajax()',990);
setTimeout('window.scrollTo(0,document.body.scrollHeight)',0);
}
}
xmlHttp.open("GET","msg.php",true);
xmlHttp.send(null);
}
window.onload=function(){
setTimeout('Ajax()',990);
setTimeout('window.scrollTo(0,document.body.scrollHeight)',990);
}
</script>
<script language="Javascript">
</script>
<script src="js/jquery-2.2.3.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
window.scrollTo(0,document.body.scrollHeight);
});
</script>
</head>
<body>
<div id='chat'>
<?php
$x = 0;
$date = date('g:i:s');
while($row = $result->fetch_assoc()){
$entrou = $row['entrar'];
if($entrou == 1){
echo "<div class='entrar' style='border: 1px solid'><p id=".$row['id']." class='Usu' ></p><span id=".$row['id']."x>".$row['mensagem']."</span></div><br>";
}else{
echo "<div class='msg' style='border: 1px solid'><p id=".$row['id']." class='Usu' > ".$row['usuario']." </p><span id=".$row['id']."x>".$row['mensagem']."</span>|| ".$row['horario']."</div><br>";
}
}
?>
</div>
<div id="login">
<center>
</center>
</div>
</div>
</body>
</html>