-
-
Notifications
You must be signed in to change notification settings - Fork 137
Expand file tree
/
Copy pathConfig.php
More file actions
367 lines (287 loc) · 10.7 KB
/
Config.php
File metadata and controls
367 lines (287 loc) · 10.7 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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<?php
/**
* eBot - A bot for match management for CS:GO
* @license http://creativecommons.org/licenses/by/3.0/ Creative Commons 3.0
* @author Julien Pardons <julien.pardons@esport-tools.net>
* @version 3.0
* @date 21/10/2012
*/
namespace eBot\Config;
use \eTools\Utils\Singleton;
use \eTools\Utils\Logger;
/**
* @method Config getInstance() Description
*/
class Config extends Singleton {
private $mysql_ip;
private $mysql_port;
private $mysql_user;
private $mysql_pass;
private $mysql_base;
private $bot_ip;
private $external_ip;
private $url_root;
private $bot_port;
private $messages = array();
private $record_name = "ebot";
private $delay_busy_server = 90;
private $nb_max_matchs = 0;
private $advertising = array();
private $maps;
private $workshop;
private $lo3_method;
private $ko3_method;
private $demo_download;
private $pause_method;
private $config_stop_disabled = false;
private $config_knife_method = false;
private $delay_ready = false;
private $damage_report = true;
private $remember_recordmsg = false;
public function __construct() {
Logger::debug("Loading " . APP_ROOT . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "config.ini");
if (file_exists(APP_ROOT . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "config.ini")) {
$config = parse_ini_file(APP_ROOT . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "config.ini");
$this->mysql_ip = $config["MYSQL_IP"];
$this->mysql_port = $config["MYSQL_PORT"];
$this->mysql_user = $config["MYSQL_USER"];
$this->mysql_pass = $config["MYSQL_PASS"];
$this->mysql_base = $config["MYSQL_BASE"];
$this->bot_ip = $config["BOT_IP"];
$this->external_ip = $config["EXTERNAL_IP"];
if($this->external_ip == ""){
$this->external_ip = $this->bot_ip;
}
$this->url_root = $config["URL_ROOT"];
$this->bot_port = $config["BOT_PORT"];
if($this->url_root == ""){
$this->url_root = 'http://'.$this->bot_ip.':'.$this->bot_port;
}
$this->delay_busy_server = $config["DELAY_BUSY_SERVER"];
$this->maps = $config["MAP"];
$this->workshop = $config["WORKSHOP"];
$this->lo3_method = $config["LO3_METHOD"];
$this->ko3_method = $config["KO3_METHOD"];
$this->demo_download = (bool) $config["DEMO_DOWNLOAD"];
$this->pause_method = $config["PAUSE_METHOD"];
$this->config_stop_disabled = (bool) $config['COMMAND_STOP_DISABLED'];
$this->config_knife_method = ($config['RECORD_METHOD'] == "knifestart") ? "knifestart" : "matchstart";
$this->delay_ready = (bool)$config['DELAY_READY'];
if ( isset($config['DAMAGE_REPORT']) && is_bool((bool)$config['DAMAGE_REPORT']) )
$this->damage_report = (bool) $config['DAMAGE_REPORT'];
if ( isset($config['REMIND_RECORD']) && is_bool((bool)$config['REMIND_RECORD']) )
$this->remember_recordmsg = (bool) $config['REMIND_RECORD'];
Logger::debug("Configuration loaded");
}
}
public function scanAdvertising() {
unset($this->advertising);
$q = \mysql_query("SELECT a.`season_id`, a.`message`, s.`name` FROM `advertising` a LEFT JOIN `seasons` s ON a.`season_id` = s.`id` WHERE a.`active` = 1");
while ($row = mysql_fetch_array($q, MYSQL_ASSOC)) {
$this->advertising['message'][] = $row['message'];
if ($row['season_id'] == null) {
$row['season_id'] = 0;
$row['name'] = "General";
}
$this->advertising['season_id'][] = intval($row['season_id']);
$this->advertising['season_name'][] = $row['name'];
}
array_multisort($this->advertising['season_id'], SORT_ASC, $this->advertising['season_name'], $this->advertising['message']);
}
public function printConfig() {
Logger::log("MySQL: " . $this->mysql_ip . ":" . $this->mysql_port . " " . $this->mysql_user . ":" . \str_repeat("*", \strlen($this->mysql_pass)) . "@" . $this->mysql_base);
Logger::log("Socket: " . $this->bot_ip . ":" . $this->bot_port);
Logger::log("Advertising by Season:");
for ($i=0; $i<count($this->advertising['message']); $i++) {
Logger::log("-> ".$this->advertising['season_name'][$i].": ".$this->advertising['message'][$i]);
}
Logger::log("Maps:");
foreach ($this->maps as $map) {
Logger::log("-> ".$map);
}
}
public function getRememberRecordmsgConfig() {
return $this->remember_recordmsg;
}
public function setRememberRecordmsgConfig($remember_recordmsg) {
$this->remember_recordmsg = $remember_recordmsg;
}
public function getDamageReportConfig() {
return $this->damage_report;
}
public function setDamageReportConfig($damage_report) {
$this->damage_report = $damage_report;
}
public function getMysql_ip() {
return $this->mysql_ip;
}
public function setMysql_ip($mysql_ip) {
$this->mysql_ip = $mysql_ip;
}
public function getMysql_port() {
return $this->mysql_port;
}
public function setMysql_port($mysql_port) {
$this->mysql_port = $mysql_port;
}
public function getMysql_user() {
return $this->mysql_user;
}
public function setMysql_user($mysql_user) {
$this->mysql_user = $mysql_user;
}
public function getMysql_pass() {
return $this->mysql_pass;
}
public function setMysql_pass($mysql_pass) {
$this->mysql_pass = $mysql_pass;
}
public function getMysql_base() {
return $this->mysql_base;
}
public function setMysql_base($mysql_base) {
$this->mysql_base = $mysql_base;
}
public function getBot_ip() {
return $this->bot_ip;
}
public function setBot_ip($bot_ip) {
$this->bot_ip = $bot_ip;
}
public function getExternal_ip() {
return $this->external_ip;
}
public function setExternal_ip($external_ip) {
$this->external_ip = $external_ip;
}
public function getUrl_root() {
return $this->url_root;
}
public function setUrl_root($url_root) {
$this->url_root = $url_root;
}
public function getBot_port() {
return $this->bot_port;
}
public function setBot_port($bot_port) {
$this->bot_port = $bot_port;
}
public function getMessages() {
return $this->messages;
}
public function setMessages($messages) {
$this->messages = $messages;
}
public function getRecord_name() {
return $this->record_name;
}
public function setRecord_name($record_name) {
$this->record_name = $record_name;
}
public function getDelay_busy_server() {
return $this->delay_busy_server;
}
public function setDelay_busy_server($delay_busy_server) {
$this->delay_busy_server = $delay_busy_server;
}
public function getNb_max_matchs() {
return $this->nb_max_matchs;
}
public function setNb_max_matchs($nb_max_matchs) {
$this->nb_max_matchs = $nb_max_matchs;
}
public function getNbRoundOvertime() {
return $this->ot_rounds;
}
public function setNbRoundOvertime($ot_rounds) {
$this->ot_rounds = $ot_rounds;
}
public function getPerf_link() {
return $this->perf_link;
}
public function setPerf_link($perf_link) {
$this->perf_link = $perf_link;
}
public function getPerf_link_on_update() {
return $this->perf_link_on_update;
}
public function setPerf_link_on_update($perf_link_on_update) {
$this->perf_link_on_update = $perf_link_on_update;
}
public function getAdvertising($seasonID) {
for ($i=0;$i<count($this->advertising['season_id']);$i++) {
if (($this->advertising['season_id'][$i] == $seasonID) || ($this->advertising['season_id'][$i] == 0)) {
$output['season_id'][] = $this->advertising['season_id'][$i];
$output['season_name'][] = $this->advertising['season_name'][$i];
$output['message'][] = $this->advertising['message'][$i];
}
}
return $output;
}
public function setAdvertising($pubs) {
$this->advertising = $pubs;
}
public function getMaps() {
return $this->maps;
}
public function setMaps($maps) {
$this->maps = $maps;
}
public function getWorkshop() {
return $this->workshop;
}
public function getWorkshopByMap($mapname) {
if (!empty($this->workshop[$mapname]))
return $this->workshop[$mapname];
else return false;
}
public function setWorkshop($workshop) {
$this->workshop = $workshop;
}
public function getLo3Method() {
return $this->lo3_method;
}
public function setLo3Method($lo3_method) {
$this->lo3_method = $lo3_method;
}
public function getPauseMethod() {
return $this->pause_method;
}
public function setPauseMethod($pause_method) {
$this->pause_method = $pause_method;
}
public function getKo3Method() {
return $this->ko3_method;
}
public function setKo3Method($ko3_method) {
$this->ko3_method = $ko3_method;
}
public function getDemoDownload() {
return $this->demo_download;
}
public function setDemoDownload($demo_download) {
$this->demo_download = $demo_download;
}
public function getCryptKey() {
return $this->crypt_key;
}
public function getConfigStopDisabled() {
return $this->config_stop_disabled;
}
public function setConfigStopDisabled($config_stop_disabled) {
$this->config_stop_disabled = $config_stop_disabled;
}
public function getConfigKnifeMethod() {
return $this->config_knife_method;
}
public function setConfigKnifeMethod($config_knife_method) {
$this->config_knife_method = $config_knife_method;
}
public function getDelayReady() {
return $this->delay_ready;
}
public function setDelayReady($delay_ready) {
$this->delay_ready = $delay_ready;
}
}
?>