-
Notifications
You must be signed in to change notification settings - Fork 6
/
core1.php
134 lines (125 loc) · 4.44 KB
/
core1.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
<?php
require_once("include/lib/ts3admin.class.php");
require_once("include/configs/config.php");
require_once("include/functions/functions.php");
require_once("include/language/".$config['bot']['laguage'].".php");
require_once("include/cache/version.php");
global $serverInfo;
global $online;
global $user;
global $channels;
global $groups;
global $footer;
global $config;
$footer = "\n\n[hr][right][i]".$version."[/i][/right][hr] [right][url=https://xtrust.pl][img]https://xtrust.pl/botbanner.png[/img][/url]";
$instance_number = str_replace("core", "", $_SERVER['SCRIPT_NAME']);
$instance_number = str_replace(".php", "", $instance_number);
$instance_number = (int) $instance_number;
$functions_enable = 0;
if($config[$instance_number]['enable'])
{
$tsAdmin = new ts3admin($config[$instance_number]['server']['ip'], $config[$instance_number]['server']['queryport']);
if($tsAdmin->getElement('success', $tsAdmin->connect()))
{
echo "
\e[1m \e[32m
▀▀█▀▀ █▀▀▄ █▀▀█ ▀▀█▀▀ ▄█░
░░█░░ █▀▀▄ █░░█ ░░█░░ ░█░
░░▀░░ ▀▀▀░ ▀▀▀▀ ░░▀░░ ▄█▄
\e[0m
";
echo "Bot połączony pomyślnie\n\n";
$tsAdmin->login($config[$instance_number]['query']['login'], $config[$instance_number]['query']['password']);
$tsAdmin->selectServer($config[$instance_number]['server']['port']);
$tsAdmin->setName("Tbot ".$config[$instance_number]['bot']['name']);
$whoami = $tsAdmin->getElement('data', $tsAdmin->whoAmI());
if($config[1]['server']['defaultchannel'] != $config[$instance_number]['bot']['channel'])
{
$tsAdmin->clientMove($whoami['client_id'] , $config[$instance_number]['bot']['channel']);
}
$instance = count($config[$instance_number]['functions']);
for($i=0; $i<$instance; $i++)
{
$function_name = $config[$instance_number]['functions'][$i];
if($config['function'][$function_name]['enable']==true)
{
$functions_enable++;
}
}
echo "/\/\ Instancja nr. ".$instance_number."\n";
echo "/\/\ Aktywnych funkcji: ".$functions_enable."\n";
function intervaltosecond($interval)
{
$interval['hours']+= $interval['days']*24;
$interval['minutes']+= $interval['hours']*60;
$interval['seconds']+= $interval['minutes']*60;
return $interval['seconds'];
}
function ready($data1, $data2, $interval)
{
if((strtotime($data1) - strtotime($data2)) >= $interval)
{
$now = true;
}
else
{
$now = false;
}
return $now;
}
echo "\n\nWykorzystanie ramu: \n";
while(true)
{
$loopdate = date('Y-m-d G:i:s');
$serverInfo = $tsAdmin->getElement('data', $tsAdmin->serverInfo());
$online = $serverInfo['virtualserver_clientsonline'] - $serverInfo['virtualserver_queryclientsonline'];
$user = $tsAdmin->clientList("-uid -away -voice -times -groups -info -icon -country -ip -badges");
$channels = $tsAdmin->channelList("-topic -flags -voice -limits -icon -secondsempty");
$groups = $tsAdmin->serverGroupList();
if($config['bot']['loop']['enable']==true)
{
if(ready($loopdate, $config['bot']['loop']['datazero'], intervaltosecond($config['bot']['loop']['interval'])) == true)
{
loop();
$config['bot']['loop']['datazero'] = $loopdate;
$instance_info = "";
$ram = memory_get_usage(false);
$ram = round($ram/1024/1024, 2);
$instance_info = $ram.",".$functions_enable;
$ff = fopen("include/cache/instance_info/core1.txt", "w+");
fputs($ff, $instance_info);
fclose($ff);
echo date('H:i d.m.Y')." - ".$ram." MB\n";
}
}
$instance = count($config[$instance_number]['functions']);
for($i=0; $i<$instance; $i++)
{
$function_name = $config[$instance_number]['functions'][$i];
if($config['function'][$function_name]['enable']==true)
{
if(ready($loopdate, $config['function'][$function_name]['datazero'], intervaltosecond($config['function'][$function_name]['interval'])) == true)
{
$function_name();
$config['function'][$function_name]['datazero'] = $loopdate;
}
}
}
unset($serverInfo);
unset($online);
unset($user);
unset($channels);
unset($groups);
sleep($config[$instance_number]['bot']['speed']);
}
}
else
{
echo "Problem z połączeniem \n";
}
}
else
{
echo "/\/\ Instancja nr. ".$instance_number." wyłączona\n";
}
?>