-
Notifications
You must be signed in to change notification settings - Fork 0
/
messages.php
113 lines (83 loc) · 2.85 KB
/
messages.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
<?php
/*\
* Scans the subdirectories in a given directory in search of Habbo handlers and responses written in Lingo and inserts them into the database
* Intended for alcosmos.net?tab=habbodev&page=messages
*
* A part of alcosmos.net
\*/
if (true) { // True to NOT execute
echo "Tool disabled";
return;
}
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$route = 'v17/src/'; // 'E:/ALCOSMOSPROJECTS/Cosas Retro/ccts/habbo_src-master/habbo_src-master/v17/src/';
include('../../../config.php');
echo 'Directory scanner and database inserter by Alcosmos<br>';
echo 'Scanning "'.$route.'"...<br>';
$archives = scandir($route);
echo count($archives).' directories found<br>';
foreach($archives as $subRoute) {
if ($subRoute == '.' || $subRoute == '..') {
continue;
}
$files = scandir($route.$subRoute);
echo '<br>'.count($files).' files found in '.$subRoute.'<br>Searching for handlers and responses...<br><br>';
foreach($files as $thisName) {
if ($thisName == '.' || $thisName == '..') {
continue;
}
$responses = file_get_contents($route.$subRoute.'/'.$thisName);
// Handlers
$handlers = $responses;
while (true) {
$pos = strpos($responses, 'tCmds.setaProp("');
if ($pos === false) {
break;
}
$responses = substr($responses, $pos + 16);
$cont = explode(')', $responses, 2)[0];
$parts = explode('"', $cont, 2);
$id = substr($parts[1], 2);
$name = $parts[0];
$query = $pdo -> prepare("INSERT INTO messages_requests (id, base64, name) VALUES (?, '', ?);");
$query -> bindParam(1, $id, PDO::PARAM_INT);
$query -> bindParam(2, $name, PDO::PARAM_STR);
if ($query -> execute()) {
echo 'Inserted "'.$name.'" with ID '.$id.'<br>';
} else {
echo '<b>ERROR</b> inserting '.$name.' with ID '.$id.': ';
print_r($query->errorInfo());
echo '<br>';
}
}
// End of handlers
// Responses
while (true) {
$pos = strpos($handlers, 'tMsgs.setaProp(');
if ($pos === false) {
break;
}
$handlers = substr($handlers, $pos + 15);
$cont = explode(')', $handlers, 2)[0];
$parts = explode(',', $cont, 2);
$id = $parts[0];
$name = substr($parts[1], 2);
$query = $pdo -> prepare("INSERT INTO messages_responses (id, base64, name, file) VALUES (?, '', ?, ?);");
$query -> bindParam(1, $id, PDO::PARAM_INT);
$query -> bindParam(2, $name, PDO::PARAM_STR);
$query -> bindParam(3, $subRoute, PDO::PARAM_STR);
if ($query -> execute()) {
echo 'Inserted "'.$name.'" with ID '.$id.'<br>';
} else {
echo '<b>ERROR</b> inserting '.$name.' with ID '.$id.': ';
print_r($query->errorInfo());
echo '<br>';
}
}
// End of responses
}
}
echo '<br>All done<br>';
?>