-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlines.php
executable file
·82 lines (62 loc) · 1.82 KB
/
lines.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
<?php
require "core.php";
$response = array();
if (isset($_GET['timestamp'])) {
$timestamp = $mysql->real_escape_string($_GET['timestamp']);
$username = "";
$webchat_lines = $mysql->prepare("SELECT `timestamp`, `username`, `text` FROM `webchat_lines` WHERE `timestamp` > ? ORDER BY `timestamp` DESC LIMIT 10");
$webchat_powers = $mysql->prepare("SELECT `power`, `data` FROM `webchat_powers` WHERE `username` = ? AND `actived` = 1");
if ($webchat_lines) {
$webchat_lines->bind_param("s", $timestamp);
if ($webchat_powers) {
$webchat_powers->bind_param("s", $username);
}
session_write_close();
do {
if ($webchat_lines->execute()) {
$webchat_lines->store_result();
if ($webchat_lines->num_rows > 0) {
$webchat_lines->bind_result($timestamp, $username, $text);
while ($webchat_lines->fetch()) {
$powers = array();
if ($webchat_powers) {
if ($webchat_powers->execute()) {
$webchat_powers->store_result();
if ($webchat_powers->num_rows > 0) {
$webchat_powers->bind_result($power, $data);
while ($webchat_powers->fetch()) {
array_push($powers, array(
"power" => $power,
"data" => $data
));
}
}
$webchat_powers->free_result();
}
}
array_unshift($response, array(
"timestamp" => $timestamp,
"username" => $username,
"powers" => $powers,
"text" => $text
));
}
break;
}
$webchat_lines->free_result();
} else {
break;
}
usleep(10000);
clearstatcache();
} while (true);
if ($webchat_powers) {
$webchat_powers->close();
}
$webchat_lines->close();
} else {
$response['error'] = $mysql->error;
}
}
echo json_encode($response);
?>