Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.96 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * eBot - A bot for match management for CS:GO
  5. * @license http://creativecommons.org/licenses/by/3.0/ Creative Commons 3.0
  6. * @author Julien Pardons <julien.pardons@esport-tools.net>
  7. * @version 3.0
  8. * @date 21/10/2012
  9. */
  10.  
  11. namespace eBot\Config;
  12.  
  13. use \eTools\Utils\Singleton;
  14. use \eTools\Utils\Logger;
  15.  
  16. /**
  17. * @method Config getInstance() Description
  18. */
  19. class Config extends Singleton {
  20.  
  21. private $mysql_ip;
  22. private $mysql_port;
  23. private $mysql_user;
  24. private $mysql_pass;
  25. private $mysql_base;
  26. private $bot_ip;
  27. private $bot_port;
  28. private $messages = array();
  29. private $record_name = "ebot";
  30. private $delay_busy_server = 90;
  31. private $nb_max_matchs = 0;
  32. private $advertising = array();
  33. private $maps;
  34. private $workshop;
  35. private $lo3_method;
  36. private $ko3_method;
  37. private $demo_download;
  38. private $pause_method;
  39. private $config_stop_disabled = false;
  40. private $config_knife_method = false;
  41. private $delay_ready = false;
  42. private $damage_report = true;
  43. private $remember_recordmsg = false;
  44.  
  45. public function __construct() {
  46. Logger::debug("Loading " . APP_ROOT . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "config.ini");
  47. if (file_exists(APP_ROOT . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "config.ini")) {
  48. $config = parse_ini_file(APP_ROOT . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "config.ini");
  49.  
  50. $this->mysql_ip = $config["MYSQL_IP"];
  51. $this->mysql_port = $config["MYSQL_PORT"];
  52. $this->mysql_user = $config["MYSQL_USER"];
  53. $this->mysql_pass = $config["MYSQL_PASS"];
  54. $this->mysql_base = $config["MYSQL_BASE"];
  55.  
  56. $this->bot_ip = $config["BOT_IP"];
  57. $this->bot_port = $config["BOT_PORT"];
  58.  
  59. $this->delay_busy_server = $config["DELAY_BUSY_SERVER"];
  60.  
  61. $this->maps = $config["MAP"];
  62. $this->workshop = $config["WORKSHOP"];
  63.  
  64. $this->lo3_method = $config["LO3_METHOD"];
  65. $this->ko3_method = $config["KO3_METHOD"];
  66.  
  67. $this->demo_download = (bool) $config["DEMO_DOWNLOAD"];
  68.  
  69. $this->pause_method = $config["PAUSE_METHOD"];
  70.  
  71. $this->config_stop_disabled = (bool) $config['COMMAND_STOP_DISABLED'];
  72. $this->config_knife_method = ($config['RECORD_METHOD'] == "knifestart") ? "knifestart" : "matchstart";
  73. $this->delay_ready = (bool)$config['DELAY_READY'];
  74.  
  75. if ( isset($config['DAMAGE_REPORT']) && is_bool((bool)$config['DAMAGE_REPORT']) )
  76. $this->damage_report = (bool) $config['DAMAGE_REPORT'];
  77.  
  78. if ( isset($config['REMIND_RECORD']) && is_bool((bool)$config['REMIND_RECORD']) )
  79. $this->remember_recordmsg = (bool) $config['REMIND_RECORD'];
  80.  
  81. Logger::debug("Configuration loaded");
  82. }
  83. }
  84.  
  85. public function scanAdvertising() {
  86. unset($this->advertising);
  87. $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");
  88. while ($row = mysql_fetch_array($q, MYSQL_ASSOC)) {
  89. $this->advertising['message'][] = $row['message'];
  90. if ($row['season_id'] == null) {
  91. $row['season_id'] = 0;
  92. $row['name'] = "General";
  93. }
  94. $this->advertising['season_id'][] = intval($row['season_id']);
  95. $this->advertising['season_name'][] = $row['name'];
  96. }
  97. array_multisort($this->advertising['season_id'], SORT_ASC, $this->advertising['season_name'], $this->advertising['message']);
  98. }
  99.  
  100. public function printConfig() {
  101. Logger::log("MySQL: " . $this->mysql_ip . ":" . $this->mysql_port . " " . $this->mysql_user . ":" . \str_repeat("*", \strlen($this->mysql_pass)) . "@" . $this->mysql_base);
  102. Logger::log("Socket: " . $this->bot_ip . ":" . $this->bot_port);
  103. Logger::log("Advertising by Season:");
  104. for ($i=0; $i<count($this->advertising['message']); $i++) {
  105. Logger::log("-> ".$this->advertising['season_name'][$i].": ".$this->advertising['message'][$i]);
  106. }
  107. Logger::log("Maps:");
  108. foreach ($this->maps as $map) {
  109. Logger::log("-> ".$map);
  110. }
  111. }
  112.  
  113. public function getRememberRecordmsgConfig() {
  114. return $this->remember_recordmsg;
  115. }
  116.  
  117. public function setRememberRecordmsgConfig($remember_recordmsg) {
  118. $this->remember_recordmsg = $remember_recordmsg;
  119. }
  120.  
  121. public function getDamageReportConfig() {
  122. return $this->damage_report;
  123. }
  124.  
  125. public function setDamageReportConfig($damage_report) {
  126. $this->damage_report = $damage_report;
  127. }
  128.  
  129. public function getMysql_ip() {
  130. return $this->mysql_ip;
  131. }
  132.  
  133. public function setMysql_ip($mysql_ip) {
  134. $this->mysql_ip = $mysql_ip;
  135. }
  136.  
  137. public function getMysql_port() {
  138. return $this->mysql_port;
  139. }
  140.  
  141. public function setMysql_port($mysql_port) {
  142. $this->mysql_port = $mysql_port;
  143. }
  144.  
  145. public function getMysql_user() {
  146. return $this->mysql_user;
  147. }
  148.  
  149. public function setMysql_user($mysql_user) {
  150. $this->mysql_user = $mysql_user;
  151. }
  152.  
  153. public function getMysql_pass() {
  154. return $this->mysql_pass;
  155. }
  156.  
  157. public function setMysql_pass($mysql_pass) {
  158. $this->mysql_pass = $mysql_pass;
  159. }
  160.  
  161. public function getMysql_base() {
  162. return $this->mysql_base;
  163. }
  164.  
  165. public function setMysql_base($mysql_base) {
  166. $this->mysql_base = $mysql_base;
  167. }
  168.  
  169. public function getBot_ip() {
  170. return $this->bot_ip;
  171. }
  172.  
  173. public function setBot_ip($bot_ip) {
  174. $this->bot_ip = $bot_ip;
  175. }
  176.  
  177. public function getBot_port() {
  178. return $this->bot_port;
  179. }
  180.  
  181. public function setBot_port($bot_port) {
  182. $this->bot_port = $bot_port;
  183. }
  184.  
  185. public function getMessages() {
  186. return $this->messages;
  187. }
  188.  
  189. public function setMessages($messages) {
  190. $this->messages = $messages;
  191. }
  192.  
  193. public function getRecord_name() {
  194. return $this->record_name;
  195. }
  196.  
  197. public function setRecord_name($record_name) {
  198. $this->record_name = $record_name;
  199. }
  200.  
  201. public function getDelay_busy_server() {
  202. return $this->delay_busy_server;
  203. }
  204.  
  205. public function setDelay_busy_server($delay_busy_server) {
  206. $this->delay_busy_server = $delay_busy_server;
  207. }
  208.  
  209. public function getNb_max_matchs() {
  210. return $this->nb_max_matchs;
  211. }
  212.  
  213. public function setNb_max_matchs($nb_max_matchs) {
  214. $this->nb_max_matchs = $nb_max_matchs;
  215. }
  216.  
  217. public function getNbRoundOvertime() {
  218. return $this->ot_rounds;
  219. }
  220.  
  221. public function setNbRoundOvertime($ot_rounds) {
  222. $this->ot_rounds = $ot_rounds;
  223. }
  224.  
  225. public function getPerf_link() {
  226. return $this->perf_link;
  227. }
  228.  
  229. public function setPerf_link($perf_link) {
  230. $this->perf_link = $perf_link;
  231. }
  232.  
  233. public function getPerf_link_on_update() {
  234. return $this->perf_link_on_update;
  235. }
  236.  
  237. public function setPerf_link_on_update($perf_link_on_update) {
  238. $this->perf_link_on_update = $perf_link_on_update;
  239. }
  240.  
  241. public function getAdvertising($seasonID) {
  242. for ($i=0;$i<count($this->advertising['season_id']);$i++) {
  243. if (($this->advertising['season_id'][$i] == $seasonID) || ($this->advertising['season_id'][$i] == 0)) {
  244. $output['season_id'][] = $this->advertising['season_id'][$i];
  245. $output['season_name'][] = $this->advertising['season_name'][$i];
  246. $output['message'][] = $this->advertising['message'][$i];
  247. }
  248. }
  249. return $output;
  250. }
  251.  
  252. public function setAdvertising($pubs) {
  253. $this->advertising = $pubs;
  254. }
  255.  
  256. public function getMaps() {
  257. return $this->maps;
  258. }
  259.  
  260. public function setMaps($maps) {
  261. $this->maps = $maps;
  262. }
  263.  
  264. public function getWorkshop() {
  265. return $this->workshop;
  266. }
  267.  
  268. public function getWorkshopByMap($mapname) {
  269. if (!empty($this->workshop[$mapname]))
  270. return $this->workshop[$mapname];
  271. else return false;
  272. }
  273.  
  274. public function setWorkshop($workshop) {
  275. $this->workshop = $workshop;
  276. }
  277.  
  278. public function getLo3Method() {
  279. return $this->lo3_method;
  280. }
  281.  
  282. public function setLo3Method($lo3_method) {
  283. $this->lo3_method = $lo3_method;
  284. }
  285.  
  286. public function getPauseMethod() {
  287. return $this->pause_method;
  288. }
  289.  
  290. public function setPauseMethod($pause_method) {
  291. $this->pause_method = $pause_method;
  292. }
  293.  
  294. public function getKo3Method() {
  295. return $this->ko3_method;
  296. }
  297.  
  298. public function setKo3Method($ko3_method) {
  299. $this->ko3_method = $ko3_method;
  300. }
  301.  
  302. public function getDemoDownload() {
  303. return $this->demo_download;
  304. }
  305.  
  306. public function setDemoDownload($demo_download) {
  307. $this->demo_download = $demo_download;
  308. }
  309.  
  310. public function getCryptKey() {
  311. return $this->crypt_key;
  312. }
  313.  
  314. public function getConfigStopDisabled() {
  315. return $this->config_stop_disabled;
  316. }
  317.  
  318. public function setConfigStopDisabled($config_stop_disabled) {
  319. $this->config_stop_disabled = $config_stop_disabled;
  320. }
  321.  
  322. public function getConfigKnifeMethod() {
  323. return $this->config_knife_method;
  324. }
  325.  
  326. public function setConfigKnifeMethod($config_knife_method) {
  327. $this->config_knife_method = $config_knife_method;
  328. }
  329.  
  330. public function getDelayReady() {
  331. return $this->delay_ready;
  332. }
  333.  
  334. public function setDelayReady($delay_ready) {
  335. $this->delay_ready = $delay_ready;
  336. }
  337.  
  338. }
  339.  
  340. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement