Guest User

Untitled

a guest
Nov 9th, 2018
1,412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 134.66 KB | None | 0 0
  1. Settings.php
  2. =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  3. <?php
  4.  
  5. final class Settings {
  6. public static $TRUE = "1", $FALSE = "0";
  7.  
  8. public function __construct($connect = true) {
  9. // Web interface language. Languages are stored in the "lang/" directory.
  10. $this->lang = 'en_US.utf8';
  11.  
  12. // Database information
  13. $this->host = 'sql9.freemysqlhosting.net';
  14. $this->port = 3306;
  15.  
  16. $database = 'sql9264839';
  17.  
  18. $username = 'sql9264839';
  19. $password = 'WCT1If52yi';
  20.  
  21. // If you set a table prefix in config.yml, set it here as well
  22. $this->table_prefix = "litebans_";
  23.  
  24. // Supported drivers: mysql, pgsql
  25. $driver = 'mysql';
  26.  
  27. // Server name, shown on the main page and on the header
  28. $this->name = 'LiteBans';
  29.  
  30. // Clicking on the header name will send you to this address.
  31. // $this->name_link = 'https://example.com';
  32. $this->name_link = 'index.php';
  33.  
  34. // Here you can customize colors for the Bootstrap 4 theme that you are using.
  35. // Bootstrap 4 themes have four sets of colors: primary, secondary, light and dark.
  36. // Navbar classes: navbar-light, navbar-dark, bg-primary, bg-secondary, bg-light, bg-dark
  37. // Badge (label) classes: badge, badge-pill, badge-primary, badge-secondary, badge-light, badge-dark
  38. $this->navbar_classes = 'navbar-dark bg-primary';
  39. $this->badge_classes = 'badge-pill badge-secondary';
  40. $this->info_badge_classes = 'badge';
  41.  
  42. // Show server scope column?
  43. $this->show_server_scope = true;
  44.  
  45. // Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Expired).
  46. $this->show_inactive_bans = true;
  47.  
  48. // Show silent bans?
  49. $this->show_silent_bans = true;
  50.  
  51. // Show pager? This allows users to page through the list of bans.
  52. $this->show_pager = true;
  53.  
  54. // Amount of bans/mutes/warnings to show on each page
  55. $this->limit_per_page = 10;
  56.  
  57. // The server console will be identified by any of these names.
  58. // It will be given a standard name and avatar image.
  59. $this->console_aliases = array(
  60. "CONSOLE", "Console",
  61. );
  62. $this->console_name = "Console";
  63. $this->console_image = "inc/img/console.png";
  64.  
  65. // Avatar images for all players will be fetched from this URL.
  66. // Examples:
  67. // 'https://cravatar.eu/avatar/{uuid}/25'
  68. // 'https://crafatar.com/avatars/{uuid}?size=25'
  69. // 'https://minotar.net/avatar/{uuid}/25'
  70. $this->avatar_source = 'https://crafatar.com/avatars/{uuid}?size=25';
  71.  
  72. // `avatar_source_offline_mode` controls where avatars for offline-mode players are fetched from.
  73. // Offline-mode UUIDs are substituted for player names unless the `avatar_allow_offline_mode_uuids` option is enabled.
  74. // (This is done because avatar sources generally serve the default "Steve" avatar for *all* offline-mode UUIDs, including those of premium players)
  75. // Crafatar no longer supports names, so it cannot be used as an offline-mode player-name avatar source as of 2018-02-16 (https://crafatar.com/#meta-usernames)
  76. // Since "skins.minecraft.net" is no longer available, this could pose a problem for other avatar sources as well.
  77. $this->avatar_source_offline_mode = 'https://minotar.net/avatar/{name}/25';
  78.  
  79. // If enabled, names will be shown below avatars instead of being shown next to them.
  80. $this->avatar_names_below = true;
  81.  
  82. // If enabled, offline-mode UUIDs will be requested from avatar_source instead of player names.
  83. $this->avatar_allow_offline_mode_uuids = false;
  84.  
  85. // If enabled, the total amount of bans, mutes, warnings, and kicks will be shown next to the buttons in the header.
  86. $this->header_show_totals = true;
  87.  
  88. // The date format can be changed here.
  89. // https://secure.php.net/manual/en/function.strftime.php
  90. // Example output of default format: July 2, 2015, 09:19; August 4, 2016, 18:37
  91. $this->date_format = '%B %d, %Y, %H:%M';
  92.  
  93. // https://secure.php.net/manual/en/timezones.php
  94. $timezone = "UTC";
  95.  
  96. // Enable PHP error reporting.
  97. $this->error_reporting = true;
  98.  
  99. // Enable error pages.
  100. $this->error_pages = true;
  101.  
  102. $this->date_month_translations = null;
  103.  
  104. // If your system locale doesn't automatically translate month names, you can set them manually here.
  105. // Change "if (false)" to "if (true)" for this to take effect.
  106. // X=>Y, X is replaced with Y. E.g. "January"=>"Januari"
  107. if (false) {
  108. $this->date_month_translations = array(
  109. "January" => "Month 1",
  110. "February" => "Month 2",
  111. "March" => "Month 3",
  112. "April" => "Month 4",
  113. "May" => "Month 5",
  114. "June" => "Month 6",
  115. "July" => "Month 7",
  116. "August" => "Month 8",
  117. "September" => "Month 9",
  118. "October" => "Month 10",
  119. "November" => "Month 11",
  120. "December" => "Month 12",
  121. );
  122. }
  123.  
  124.  
  125. /*** End of configuration ***/
  126.  
  127.  
  128. /** Don't modify anything here unless you know what you're doing **/
  129.  
  130. if ($this->error_reporting) {
  131. error_reporting(E_ALL);
  132. ini_set("display_errors", 1);
  133. }
  134.  
  135. $this->active_query = "";
  136.  
  137. if ($driver === "pgsql") {
  138. Settings::$TRUE = "B'1'";
  139. Settings::$FALSE = "B'0'";
  140. }
  141.  
  142. if (!$this->show_inactive_bans) {
  143. $this->active_query = self::append_query($this->active_query, "active=" . Settings::$TRUE);
  144. }
  145.  
  146. if (!$this->show_silent_bans) {
  147. $this->active_query = self::append_query($this->active_query, "silent=" . Settings::$FALSE);
  148. }
  149.  
  150. $this->test_strftime();
  151.  
  152. date_default_timezone_set($timezone); // set configured timezone
  153.  
  154. $table_prefix = $this->table_prefix;
  155.  
  156. // Internal table names, do not translate.
  157. $this->table = array(
  158. 'bans' => "${table_prefix}bans",
  159. 'mutes' => "${table_prefix}mutes",
  160. 'warnings' => "${table_prefix}warnings",
  161. 'kicks' => "${table_prefix}kicks",
  162. 'history' => "${table_prefix}history",
  163. 'servers' => "${table_prefix}servers",
  164. 'config' => "${table_prefix}config",
  165. );
  166.  
  167. $this->driver = $driver;
  168. if ($connect) {
  169. if ($username === "" && $password === "") {
  170. redirect("error/unconfigured.php");
  171. }
  172. $host = $this->host;
  173. $port = $this->port;
  174.  
  175. $dsn = "$driver:dbname=$database;host=$host;port=$port";
  176. if ($driver === 'mysql') {
  177. $dsn .= ';charset=utf8';
  178. }
  179.  
  180. $options = array(
  181. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  182. PDO::ATTR_EMULATE_PREPARES => false,
  183. PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
  184. );
  185.  
  186. try {
  187. $this->conn = new PDO($dsn, $username, $password, $options);
  188.  
  189. $st = $this->conn->query("SELECT * FROM " . $this->table['config'] . " LIMIT 1;");
  190. $st->fetch();
  191. $st->closeCursor();
  192. } catch (PDOException $e) {
  193. Settings::handle_error($this, $e);
  194. }
  195. if ($driver === 'pgsql') {
  196. $this->conn->query("SET NAMES 'UTF8';");
  197. }
  198. }
  199. }
  200.  
  201. static function append_query($existing, $new) {
  202. if ($existing !== "") {
  203. return "$existing AND $new";
  204. }
  205. return "WHERE $new";
  206. }
  207.  
  208. /**
  209. * @param $settings Settings
  210. * @param $e Exception
  211. */
  212. static function handle_error($settings, $e) {
  213. $message = $e->getMessage();
  214. if ($settings->error_pages) {
  215. if (strstr($message, "Access denied for user")) {
  216. if ($settings->error_reporting) {
  217. redirect("error/access-denied.php?error=" . base64_encode($message));
  218. } else {
  219. redirect("error/access-denied.php");
  220. }
  221. }
  222. if (strstr($message, "Base table or view not found:")) {
  223. try {
  224. $st = $settings->conn->query("SELECT * FROM " . $settings->table['bans'] . " LIMIT 1;");
  225. $st->fetch();
  226. $st->closeCursor();
  227. } catch (PDOException $e) {
  228. redirect("error/tables-not-found.php");
  229. }
  230. redirect("error/outdated-plugin.php");
  231. }
  232. if (strstr($message, "Unknown column")) {
  233. redirect("error/outdated-plugin.php");
  234. }
  235. }
  236. if ($settings->error_reporting === false) {
  237. die("Database error");
  238. }
  239. die("Database error: $message");
  240. }
  241.  
  242.  
  243.  
  244. private function test_strftime() {
  245. // If you modify this function, you may get an "Assertion failed" error.
  246. date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
  247.  
  248. $fail = false;
  249. $test = gmstrftime($this->date_format, 0);
  250. if ($test == false) {
  251. ob_start();
  252. var_dump($test);
  253. $testdump = ob_get_clean();
  254. echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
  255. $fail = true;
  256. }
  257.  
  258. $test = gmstrftime("%Y-%m-%d %H:%M", 0);
  259. if ($test !== "1970-01-01 00:00") {
  260. ob_start();
  261. var_dump($test);
  262. $testdump = ob_get_clean();
  263. echo("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>");
  264. echo("Actual result: $testdump");
  265. $fail = true;
  266. }
  267.  
  268. if ($fail === true) {
  269. die;
  270. }
  271. }
  272. }
  273.  
  274. <?php
  275.  
  276. final class Settings {
  277. public static $TRUE = "1", $FALSE = "0";
  278.  
  279. public function __construct($connect = true) {
  280. // Web interface language. Languages are stored in the "lang/" directory.
  281. $this->lang = 'en_US.utf8';
  282.  
  283. // Database information
  284. $this->host = 'sql9.freemysqlhosting.net';
  285. $this->port = 3306;
  286.  
  287. $database = 'sql9264839';
  288.  
  289. $username = 'sql9264839';
  290. $password = 'WCT1If52yi';
  291.  
  292. // If you set a table prefix in config.yml, set it here as well
  293. $this->table_prefix = "litebans_";
  294.  
  295. // Supported drivers: mysql, pgsql
  296. $driver = 'mysql';
  297.  
  298. // Server name, shown on the main page and on the header
  299. $this->name = 'LiteBans';
  300.  
  301. // Clicking on the header name will send you to this address.
  302. // $this->name_link = 'https://example.com';
  303. $this->name_link = 'index.php';
  304.  
  305. // Here you can customize colors for the Bootstrap 4 theme that you are using.
  306. // Bootstrap 4 themes have four sets of colors: primary, secondary, light and dark.
  307. // Navbar classes: navbar-light, navbar-dark, bg-primary, bg-secondary, bg-light, bg-dark
  308. // Badge (label) classes: badge, badge-pill, badge-primary, badge-secondary, badge-light, badge-dark
  309. $this->navbar_classes = 'navbar-dark bg-primary';
  310. $this->badge_classes = 'badge-pill badge-secondary';
  311. $this->info_badge_classes = 'badge';
  312.  
  313. // Show server scope column?
  314. $this->show_server_scope = true;
  315.  
  316. // Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Expired).
  317. $this->show_inactive_bans = true;
  318.  
  319. // Show silent bans?
  320. $this->show_silent_bans = true;
  321.  
  322. // Show pager? This allows users to page through the list of bans.
  323. $this->show_pager = true;
  324.  
  325. // Amount of bans/mutes/warnings to show on each page
  326. $this->limit_per_page = 10;
  327.  
  328. // The server console will be identified by any of these names.
  329. // It will be given a standard name and avatar image.
  330. $this->console_aliases = array(
  331. "CONSOLE", "Console",
  332. );
  333. $this->console_name = "Console";
  334. $this->console_image = "inc/img/console.png";
  335.  
  336. // Avatar images for all players will be fetched from this URL.
  337. // Examples:
  338. // 'https://cravatar.eu/avatar/{uuid}/25'
  339. // 'https://crafatar.com/avatars/{uuid}?size=25'
  340. // 'https://minotar.net/avatar/{uuid}/25'
  341. $this->avatar_source = 'https://crafatar.com/avatars/{uuid}?size=25';
  342.  
  343. // `avatar_source_offline_mode` controls where avatars for offline-mode players are fetched from.
  344. // Offline-mode UUIDs are substituted for player names unless the `avatar_allow_offline_mode_uuids` option is enabled.
  345. // (This is done because avatar sources generally serve the default "Steve" avatar for *all* offline-mode UUIDs, including those of premium players)
  346. // Crafatar no longer supports names, so it cannot be used as an offline-mode player-name avatar source as of 2018-02-16 (https://crafatar.com/#meta-usernames)
  347. // Since "skins.minecraft.net" is no longer available, this could pose a problem for other avatar sources as well.
  348. $this->avatar_source_offline_mode = 'https://minotar.net/avatar/{name}/25';
  349.  
  350. // If enabled, names will be shown below avatars instead of being shown next to them.
  351. $this->avatar_names_below = true;
  352.  
  353. // If enabled, offline-mode UUIDs will be requested from avatar_source instead of player names.
  354. $this->avatar_allow_offline_mode_uuids = false;
  355.  
  356. // If enabled, the total amount of bans, mutes, warnings, and kicks will be shown next to the buttons in the header.
  357. $this->header_show_totals = true;
  358.  
  359. // The date format can be changed here.
  360. // https://secure.php.net/manual/en/function.strftime.php
  361. // Example output of default format: July 2, 2015, 09:19; August 4, 2016, 18:37
  362. $this->date_format = '%B %d, %Y, %H:%M';
  363.  
  364. // https://secure.php.net/manual/en/timezones.php
  365. $timezone = "UTC";
  366.  
  367. // Enable PHP error reporting.
  368. $this->error_reporting = true;
  369.  
  370. // Enable error pages.
  371. $this->error_pages = true;
  372.  
  373. $this->date_month_translations = null;
  374.  
  375. // If your system locale doesn't automatically translate month names, you can set them manually here.
  376. // Change "if (false)" to "if (true)" for this to take effect.
  377. // X=>Y, X is replaced with Y. E.g. "January"=>"Januari"
  378. if (false) {
  379. $this->date_month_translations = array(
  380. "January" => "Month 1",
  381. "February" => "Month 2",
  382. "March" => "Month 3",
  383. "April" => "Month 4",
  384. "May" => "Month 5",
  385. "June" => "Month 6",
  386. "July" => "Month 7",
  387. "August" => "Month 8",
  388. "September" => "Month 9",
  389. "October" => "Month 10",
  390. "November" => "Month 11",
  391. "December" => "Month 12",
  392. );
  393. }
  394.  
  395.  
  396. /*** End of configuration ***/
  397.  
  398.  
  399. /** Don't modify anything here unless you know what you're doing **/
  400.  
  401. if ($this->error_reporting) {
  402. error_reporting(E_ALL);
  403. ini_set("display_errors", 1);
  404. }
  405.  
  406. $this->active_query = "";
  407.  
  408. if ($driver === "pgsql") {
  409. Settings::$TRUE = "B'1'";
  410. Settings::$FALSE = "B'0'";
  411. }
  412.  
  413. if (!$this->show_inactive_bans) {
  414. $this->active_query = self::append_query($this->active_query, "active=" . Settings::$TRUE);
  415. }
  416.  
  417. if (!$this->show_silent_bans) {
  418. $this->active_query = self::append_query($this->active_query, "silent=" . Settings::$FALSE);
  419. }
  420.  
  421. $this->test_strftime();
  422.  
  423. date_default_timezone_set($timezone); // set configured timezone
  424.  
  425. $table_prefix = $this->table_prefix;
  426.  
  427. // Internal table names, do not translate.
  428. $this->table = array(
  429. 'bans' => "${table_prefix}bans",
  430. 'mutes' => "${table_prefix}mutes",
  431. 'warnings' => "${table_prefix}warnings",
  432. 'kicks' => "${table_prefix}kicks",
  433. 'history' => "${table_prefix}history",
  434. 'servers' => "${table_prefix}servers",
  435. 'config' => "${table_prefix}config",
  436. );
  437.  
  438. $this->driver = $driver;
  439. if ($connect) {
  440. if ($username === "" && $password === "") {
  441. redirect("error/unconfigured.php");
  442. }
  443. $host = $this->host;
  444. $port = $this->port;
  445.  
  446. $dsn = "$driver:dbname=$database;host=$host;port=$port";
  447. if ($driver === 'mysql') {
  448. $dsn .= ';charset=utf8';
  449. }
  450.  
  451. $options = array(
  452. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  453. PDO::ATTR_EMULATE_PREPARES => false,
  454. PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
  455. );
  456.  
  457. try {
  458. $this->conn = new PDO($dsn, $username, $password, $options);
  459.  
  460. $st = $this->conn->query("SELECT * FROM " . $this->table['config'] . " LIMIT 1;");
  461. $st->fetch();
  462. $st->closeCursor();
  463. } catch (PDOException $e) {
  464. Settings::handle_error($this, $e);
  465. }
  466. if ($driver === 'pgsql') {
  467. $this->conn->query("SET NAMES 'UTF8';");
  468. }
  469. }
  470. }
  471.  
  472. static function append_query($existing, $new) {
  473. if ($existing !== "") {
  474. return "$existing AND $new";
  475. }
  476. return "WHERE $new";
  477. }
  478.  
  479. /**
  480. * @param $settings Settings
  481. * @param $e Exception
  482. */
  483. static function handle_error($settings, $e) {
  484. $message = $e->getMessage();
  485. if ($settings->error_pages) {
  486. if (strstr($message, "Access denied for user")) {
  487. if ($settings->error_reporting) {
  488. redirect("error/access-denied.php?error=" . base64_encode($message));
  489. } else {
  490. redirect("error/access-denied.php");
  491. }
  492. }
  493. if (strstr($message, "Base table or view not found:")) {
  494. try {
  495. $st = $settings->conn->query("SELECT * FROM " . $settings->table['bans'] . " LIMIT 1;");
  496. $st->fetch();
  497. $st->closeCursor();
  498. } catch (PDOException $e) {
  499. redirect("error/tables-not-found.php");
  500. }
  501. redirect("error/outdated-plugin.php");
  502. }
  503. if (strstr($message, "Unknown column")) {
  504. redirect("error/outdated-plugin.php");
  505. }
  506. }
  507. if ($settings->error_reporting === false) {
  508. die("Database error");
  509. }
  510. die("Database error: $message");
  511. }
  512.  
  513.  
  514.  
  515. private function test_strftime() {
  516. // If you modify this function, you may get an "Assertion failed" error.
  517. date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
  518.  
  519. $fail = false;
  520. $test = gmstrftime($this->date_format, 0);
  521. if ($test == false) {
  522. ob_start();
  523. var_dump($test);
  524. $testdump = ob_get_clean();
  525. echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
  526. $fail = true;
  527. }
  528.  
  529. $test = gmstrftime("%Y-%m-%d %H:%M", 0);
  530. if ($test !== "1970-01-01 00:00") {
  531. ob_start();
  532. var_dump($test);
  533. $testdump = ob_get_clean();
  534. echo("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>");
  535. echo("Actual result: $testdump");
  536. $fail = true;
  537. }
  538.  
  539. if ($fail === true) {
  540. die;
  541. }
  542. }
  543. }
  544. <?php
  545.  
  546. final class Settings {
  547. public static $TRUE = "1", $FALSE = "0";
  548.  
  549. public function __construct($connect = true) {
  550. // Web interface language. Languages are stored in the "lang/" directory.
  551. $this->lang = 'en_US.utf8';
  552.  
  553. // Database information
  554. $this->host = 'sql9.freemysqlhosting.net';
  555. $this->port = 3306;
  556.  
  557. $database = 'sql9264839';
  558.  
  559. $username = 'sql9264839';
  560. $password = 'WCT1If52yi';
  561.  
  562. // If you set a table prefix in config.yml, set it here as well
  563. $this->table_prefix = "litebans_";
  564.  
  565. // Supported drivers: mysql, pgsql
  566. $driver = 'mysql';
  567.  
  568. // Server name, shown on the main page and on the header
  569. $this->name = 'LiteBans';
  570.  
  571. // Clicking on the header name will send you to this address.
  572. // $this->name_link = 'https://example.com';
  573. $this->name_link = 'index.php';
  574.  
  575. // Here you can customize colors for the Bootstrap 4 theme that you are using.
  576. // Bootstrap 4 themes have four sets of colors: primary, secondary, light and dark.
  577. // Navbar classes: navbar-light, navbar-dark, bg-primary, bg-secondary, bg-light, bg-dark
  578. // Badge (label) classes: badge, badge-pill, badge-primary, badge-secondary, badge-light, badge-dark
  579. $this->navbar_classes = 'navbar-dark bg-primary';
  580. $this->badge_classes = 'badge-pill badge-secondary';
  581. $this->info_badge_classes = 'badge';
  582.  
  583. // Show server scope column?
  584. $this->show_server_scope = true;
  585.  
  586. // Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Expired).
  587. $this->show_inactive_bans = true;
  588.  
  589. // Show silent bans?
  590. $this->show_silent_bans = true;
  591.  
  592. // Show pager? This allows users to page through the list of bans.
  593. $this->show_pager = true;
  594.  
  595. // Amount of bans/mutes/warnings to show on each page
  596. $this->limit_per_page = 10;
  597.  
  598. // The server console will be identified by any of these names.
  599. // It will be given a standard name and avatar image.
  600. $this->console_aliases = array(
  601. "CONSOLE", "Console",
  602. );
  603. $this->console_name = "Console";
  604. $this->console_image = "inc/img/console.png";
  605.  
  606. // Avatar images for all players will be fetched from this URL.
  607. // Examples:
  608. // 'https://cravatar.eu/avatar/{uuid}/25'
  609. // 'https://crafatar.com/avatars/{uuid}?size=25'
  610. // 'https://minotar.net/avatar/{uuid}/25'
  611. $this->avatar_source = 'https://crafatar.com/avatars/{uuid}?size=25';
  612.  
  613. // `avatar_source_offline_mode` controls where avatars for offline-mode players are fetched from.
  614. // Offline-mode UUIDs are substituted for player names unless the `avatar_allow_offline_mode_uuids` option is enabled.
  615. // (This is done because avatar sources generally serve the default "Steve" avatar for *all* offline-mode UUIDs, including those of premium players)
  616. // Crafatar no longer supports names, so it cannot be used as an offline-mode player-name avatar source as of 2018-02-16 (https://crafatar.com/#meta-usernames)
  617. // Since "skins.minecraft.net" is no longer available, this could pose a problem for other avatar sources as well.
  618. $this->avatar_source_offline_mode = 'https://minotar.net/avatar/{name}/25';
  619.  
  620. // If enabled, names will be shown below avatars instead of being shown next to them.
  621. $this->avatar_names_below = true;
  622.  
  623. // If enabled, offline-mode UUIDs will be requested from avatar_source instead of player names.
  624. $this->avatar_allow_offline_mode_uuids = false;
  625.  
  626. // If enabled, the total amount of bans, mutes, warnings, and kicks will be shown next to the buttons in the header.
  627. $this->header_show_totals = true;
  628.  
  629. // The date format can be changed here.
  630. // https://secure.php.net/manual/en/function.strftime.php
  631. // Example output of default format: July 2, 2015, 09:19; August 4, 2016, 18:37
  632. $this->date_format = '%B %d, %Y, %H:%M';
  633.  
  634. // https://secure.php.net/manual/en/timezones.php
  635. $timezone = "UTC";
  636.  
  637. // Enable PHP error reporting.
  638. $this->error_reporting = true;
  639.  
  640. // Enable error pages.
  641. $this->error_pages = true;
  642.  
  643. $this->date_month_translations = null;
  644.  
  645. // If your system locale doesn't automatically translate month names, you can set them manually here.
  646. // Change "if (false)" to "if (true)" for this to take effect.
  647. // X=>Y, X is replaced with Y. E.g. "January"=>"Januari"
  648. if (false) {
  649. $this->date_month_translations = array(
  650. "January" => "Month 1",
  651. "February" => "Month 2",
  652. "March" => "Month 3",
  653. "April" => "Month 4",
  654. "May" => "Month 5",
  655. "June" => "Month 6",
  656. "July" => "Month 7",
  657. "August" => "Month 8",
  658. "September" => "Month 9",
  659. "October" => "Month 10",
  660. "November" => "Month 11",
  661. "December" => "Month 12",
  662. );
  663. }
  664.  
  665.  
  666. /*** End of configuration ***/
  667.  
  668.  
  669. /** Don't modify anything here unless you know what you're doing **/
  670.  
  671. if ($this->error_reporting) {
  672. error_reporting(E_ALL);
  673. ini_set("display_errors", 1);
  674. }
  675.  
  676. $this->active_query = "";
  677.  
  678. if ($driver === "pgsql") {
  679. Settings::$TRUE = "B'1'";
  680. Settings::$FALSE = "B'0'";
  681. }
  682.  
  683. if (!$this->show_inactive_bans) {
  684. $this->active_query = self::append_query($this->active_query, "active=" . Settings::$TRUE);
  685. }
  686.  
  687. if (!$this->show_silent_bans) {
  688. $this->active_query = self::append_query($this->active_query, "silent=" . Settings::$FALSE);
  689. }
  690.  
  691. $this->test_strftime();
  692.  
  693. date_default_timezone_set($timezone); // set configured timezone
  694.  
  695. $table_prefix = $this->table_prefix;
  696.  
  697. // Internal table names, do not translate.
  698. $this->table = array(
  699. 'bans' => "${table_prefix}bans",
  700. 'mutes' => "${table_prefix}mutes",
  701. 'warnings' => "${table_prefix}warnings",
  702. 'kicks' => "${table_prefix}kicks",
  703. 'history' => "${table_prefix}history",
  704. 'servers' => "${table_prefix}servers",
  705. 'config' => "${table_prefix}config",
  706. );
  707.  
  708. $this->driver = $driver;
  709. if ($connect) {
  710. if ($username === "" && $password === "") {
  711. redirect("error/unconfigured.php");
  712. }
  713. $host = $this->host;
  714. $port = $this->port;
  715.  
  716. $dsn = "$driver:dbname=$database;host=$host;port=$port";
  717. if ($driver === 'mysql') {
  718. $dsn .= ';charset=utf8';
  719. }
  720.  
  721. $options = array(
  722. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  723. PDO::ATTR_EMULATE_PREPARES => false,
  724. PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
  725. );
  726.  
  727. try {
  728. $this->conn = new PDO($dsn, $username, $password, $options);
  729.  
  730. $st = $this->conn->query("SELECT * FROM " . $this->table['config'] . " LIMIT 1;");
  731. $st->fetch();
  732. $st->closeCursor();
  733. } catch (PDOException $e) {
  734. Settings::handle_error($this, $e);
  735. }
  736. if ($driver === 'pgsql') {
  737. $this->conn->query("SET NAMES 'UTF8';");
  738. }
  739. }
  740. }
  741.  
  742. static function append_query($existing, $new) {
  743. if ($existing !== "") {
  744. return "$existing AND $new";
  745. }
  746. return "WHERE $new";
  747. }
  748.  
  749. /**
  750. * @param $settings Settings
  751. * @param $e Exception
  752. */
  753. static function handle_error($settings, $e) {
  754. $message = $e->getMessage();
  755. if ($settings->error_pages) {
  756. if (strstr($message, "Access denied for user")) {
  757. if ($settings->error_reporting) {
  758. redirect("error/access-denied.php?error=" . base64_encode($message));
  759. } else {
  760. redirect("error/access-denied.php");
  761. }
  762. }
  763. if (strstr($message, "Base table or view not found:")) {
  764. try {
  765. $st = $settings->conn->query("SELECT * FROM " . $settings->table['bans'] . " LIMIT 1;");
  766. $st->fetch();
  767. $st->closeCursor();
  768. } catch (PDOException $e) {
  769. redirect("error/tables-not-found.php");
  770. }
  771. redirect("error/outdated-plugin.php");
  772. }
  773. if (strstr($message, "Unknown column")) {
  774. redirect("error/outdated-plugin.php");
  775. }
  776. }
  777. if ($settings->error_reporting === false) {
  778. die("Database error");
  779. }
  780. die("Database error: $message");
  781. }
  782.  
  783.  
  784.  
  785. private function test_strftime() {
  786. // If you modify this function, you may get an "Assertion failed" error.
  787. date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
  788.  
  789. $fail = false;
  790. $test = gmstrftime($this->date_format, 0);
  791. if ($test == false) {
  792. ob_start();
  793. var_dump($test);
  794. $testdump = ob_get_clean();
  795. echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
  796. $fail = true;
  797. }
  798.  
  799. $test = gmstrftime("%Y-%m-%d %H:%M", 0);
  800. if ($test !== "1970-01-01 00:00") {
  801. ob_start();
  802. var_dump($test);
  803. $testdump = ob_get_clean();
  804. echo("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>");
  805. echo("Actual result: $testdump");
  806. $fail = true;
  807. }
  808.  
  809. if ($fail === true) {
  810. die;
  811. }
  812. }
  813. }
  814. <?php
  815.  
  816. final class Settings {
  817. public static $TRUE = "1", $FALSE = "0";
  818.  
  819. public function __construct($connect = true) {
  820. // Web interface language. Languages are stored in the "lang/" directory.
  821. $this->lang = 'en_US.utf8';
  822.  
  823. // Database information
  824. $this->host = 'sql9.freemysqlhosting.net';
  825. $this->port = 3306;
  826.  
  827. $database = 'sql9264839';
  828.  
  829. $username = 'sql9264839';
  830. $password = 'WCT1If52yi';
  831.  
  832. // If you set a table prefix in config.yml, set it here as well
  833. $this->table_prefix = "litebans_";
  834.  
  835. // Supported drivers: mysql, pgsql
  836. $driver = 'mysql';
  837.  
  838. // Server name, shown on the main page and on the header
  839. $this->name = 'LiteBans';
  840.  
  841. // Clicking on the header name will send you to this address.
  842. // $this->name_link = 'https://example.com';
  843. $this->name_link = 'index.php';
  844.  
  845. // Here you can customize colors for the Bootstrap 4 theme that you are using.
  846. // Bootstrap 4 themes have four sets of colors: primary, secondary, light and dark.
  847. // Navbar classes: navbar-light, navbar-dark, bg-primary, bg-secondary, bg-light, bg-dark
  848. // Badge (label) classes: badge, badge-pill, badge-primary, badge-secondary, badge-light, badge-dark
  849. $this->navbar_classes = 'navbar-dark bg-primary';
  850. $this->badge_classes = 'badge-pill badge-secondary';
  851. $this->info_badge_classes = 'badge';
  852.  
  853. // Show server scope column?
  854. $this->show_server_scope = true;
  855.  
  856. // Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Expired).
  857. $this->show_inactive_bans = true;
  858.  
  859. // Show silent bans?
  860. $this->show_silent_bans = true;
  861.  
  862. // Show pager? This allows users to page through the list of bans.
  863. $this->show_pager = true;
  864.  
  865. // Amount of bans/mutes/warnings to show on each page
  866. $this->limit_per_page = 10;
  867.  
  868. // The server console will be identified by any of these names.
  869. // It will be given a standard name and avatar image.
  870. $this->console_aliases = array(
  871. "CONSOLE", "Console",
  872. );
  873. $this->console_name = "Console";
  874. $this->console_image = "inc/img/console.png";
  875.  
  876. // Avatar images for all players will be fetched from this URL.
  877. // Examples:
  878. // 'https://cravatar.eu/avatar/{uuid}/25'
  879. // 'https://crafatar.com/avatars/{uuid}?size=25'
  880. // 'https://minotar.net/avatar/{uuid}/25'
  881. $this->avatar_source = 'https://crafatar.com/avatars/{uuid}?size=25';
  882.  
  883. // `avatar_source_offline_mode` controls where avatars for offline-mode players are fetched from.
  884. // Offline-mode UUIDs are substituted for player names unless the `avatar_allow_offline_mode_uuids` option is enabled.
  885. // (This is done because avatar sources generally serve the default "Steve" avatar for *all* offline-mode UUIDs, including those of premium players)
  886. // Crafatar no longer supports names, so it cannot be used as an offline-mode player-name avatar source as of 2018-02-16 (https://crafatar.com/#meta-usernames)
  887. // Since "skins.minecraft.net" is no longer available, this could pose a problem for other avatar sources as well.
  888. $this->avatar_source_offline_mode = 'https://minotar.net/avatar/{name}/25';
  889.  
  890. // If enabled, names will be shown below avatars instead of being shown next to them.
  891. $this->avatar_names_below = true;
  892.  
  893. // If enabled, offline-mode UUIDs will be requested from avatar_source instead of player names.
  894. $this->avatar_allow_offline_mode_uuids = false;
  895.  
  896. // If enabled, the total amount of bans, mutes, warnings, and kicks will be shown next to the buttons in the header.
  897. $this->header_show_totals = true;
  898.  
  899. // The date format can be changed here.
  900. // https://secure.php.net/manual/en/function.strftime.php
  901. // Example output of default format: July 2, 2015, 09:19; August 4, 2016, 18:37
  902. $this->date_format = '%B %d, %Y, %H:%M';
  903.  
  904. // https://secure.php.net/manual/en/timezones.php
  905. $timezone = "UTC";
  906.  
  907. // Enable PHP error reporting.
  908. $this->error_reporting = true;
  909.  
  910. // Enable error pages.
  911. $this->error_pages = true;
  912.  
  913. $this->date_month_translations = null;
  914.  
  915. // If your system locale doesn't automatically translate month names, you can set them manually here.
  916. // Change "if (false)" to "if (true)" for this to take effect.
  917. // X=>Y, X is replaced with Y. E.g. "January"=>"Januari"
  918. if (false) {
  919. $this->date_month_translations = array(
  920. "January" => "Month 1",
  921. "February" => "Month 2",
  922. "March" => "Month 3",
  923. "April" => "Month 4",
  924. "May" => "Month 5",
  925. "June" => "Month 6",
  926. "July" => "Month 7",
  927. "August" => "Month 8",
  928. "September" => "Month 9",
  929. "October" => "Month 10",
  930. "November" => "Month 11",
  931. "December" => "Month 12",
  932. );
  933. }
  934.  
  935.  
  936. /*** End of configuration ***/
  937.  
  938.  
  939. /** Don't modify anything here unless you know what you're doing **/
  940.  
  941. if ($this->error_reporting) {
  942. error_reporting(E_ALL);
  943. ini_set("display_errors", 1);
  944. }
  945.  
  946. $this->active_query = "";
  947.  
  948. if ($driver === "pgsql") {
  949. Settings::$TRUE = "B'1'";
  950. Settings::$FALSE = "B'0'";
  951. }
  952.  
  953. if (!$this->show_inactive_bans) {
  954. $this->active_query = self::append_query($this->active_query, "active=" . Settings::$TRUE);
  955. }
  956.  
  957. if (!$this->show_silent_bans) {
  958. $this->active_query = self::append_query($this->active_query, "silent=" . Settings::$FALSE);
  959. }
  960.  
  961. $this->test_strftime();
  962.  
  963. date_default_timezone_set($timezone); // set configured timezone
  964.  
  965. $table_prefix = $this->table_prefix;
  966.  
  967. // Internal table names, do not translate.
  968. $this->table = array(
  969. 'bans' => "${table_prefix}bans",
  970. 'mutes' => "${table_prefix}mutes",
  971. 'warnings' => "${table_prefix}warnings",
  972. 'kicks' => "${table_prefix}kicks",
  973. 'history' => "${table_prefix}history",
  974. 'servers' => "${table_prefix}servers",
  975. 'config' => "${table_prefix}config",
  976. );
  977.  
  978. $this->driver = $driver;
  979. if ($connect) {
  980. if ($username === "" && $password === "") {
  981. redirect("error/unconfigured.php");
  982. }
  983. $host = $this->host;
  984. $port = $this->port;
  985.  
  986. $dsn = "$driver:dbname=$database;host=$host;port=$port";
  987. if ($driver === 'mysql') {
  988. $dsn .= ';charset=utf8';
  989. }
  990.  
  991. $options = array(
  992. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  993. PDO::ATTR_EMULATE_PREPARES => false,
  994. PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
  995. );
  996.  
  997. try {
  998. $this->conn = new PDO($dsn, $username, $password, $options);
  999.  
  1000. $st = $this->conn->query("SELECT * FROM " . $this->table['config'] . " LIMIT 1;");
  1001. $st->fetch();
  1002. $st->closeCursor();
  1003. } catch (PDOException $e) {
  1004. Settings::handle_error($this, $e);
  1005. }
  1006. if ($driver === 'pgsql') {
  1007. $this->conn->query("SET NAMES 'UTF8';");
  1008. }
  1009. }
  1010. }
  1011.  
  1012. static function append_query($existing, $new) {
  1013. if ($existing !== "") {
  1014. return "$existing AND $new";
  1015. }
  1016. return "WHERE $new";
  1017. }
  1018.  
  1019. /**
  1020. * @param $settings Settings
  1021. * @param $e Exception
  1022. */
  1023. static function handle_error($settings, $e) {
  1024. $message = $e->getMessage();
  1025. if ($settings->error_pages) {
  1026. if (strstr($message, "Access denied for user")) {
  1027. if ($settings->error_reporting) {
  1028. redirect("error/access-denied.php?error=" . base64_encode($message));
  1029. } else {
  1030. redirect("error/access-denied.php");
  1031. }
  1032. }
  1033. if (strstr($message, "Base table or view not found:")) {
  1034. try {
  1035. $st = $settings->conn->query("SELECT * FROM " . $settings->table['bans'] . " LIMIT 1;");
  1036. $st->fetch();
  1037. $st->closeCursor();
  1038. } catch (PDOException $e) {
  1039. redirect("error/tables-not-found.php");
  1040. }
  1041. redirect("error/outdated-plugin.php");
  1042. }
  1043. if (strstr($message, "Unknown column")) {
  1044. redirect("error/outdated-plugin.php");
  1045. }
  1046. }
  1047. if ($settings->error_reporting === false) {
  1048. die("Database error");
  1049. }
  1050. die("Database error: $message");
  1051. }
  1052.  
  1053.  
  1054.  
  1055. private function test_strftime() {
  1056. // If you modify this function, you may get an "Assertion failed" error.
  1057. date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
  1058.  
  1059. $fail = false;
  1060. $test = gmstrftime($this->date_format, 0);
  1061. if ($test == false) {
  1062. ob_start();
  1063. var_dump($test);
  1064. $testdump = ob_get_clean();
  1065. echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
  1066. $fail = true;
  1067. }
  1068.  
  1069. $test = gmstrftime("%Y-%m-%d %H:%M", 0);
  1070. if ($test !== "1970-01-01 00:00") {
  1071. ob_start();
  1072. var_dump($test);
  1073. $testdump = ob_get_clean();
  1074. echo("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>");
  1075. echo("Actual result: $testdump");
  1076. $fail = true;
  1077. }
  1078.  
  1079. if ($fail === true) {
  1080. die;
  1081. }
  1082. }
  1083. }
  1084. <?php
  1085.  
  1086. final class Settings {
  1087. public static $TRUE = "1", $FALSE = "0";
  1088.  
  1089. public function __construct($connect = true) {
  1090. // Web interface language. Languages are stored in the "lang/" directory.
  1091. $this->lang = 'en_US.utf8';
  1092.  
  1093. // Database information
  1094. $this->host = 'sql9.freemysqlhosting.net';
  1095. $this->port = 3306;
  1096.  
  1097. $database = 'sql9264839';
  1098.  
  1099. $username = 'sql9264839';
  1100. $password = 'WCT1If52yi';
  1101.  
  1102. // If you set a table prefix in config.yml, set it here as well
  1103. $this->table_prefix = "litebans_";
  1104.  
  1105. // Supported drivers: mysql, pgsql
  1106. $driver = 'mysql';
  1107.  
  1108. // Server name, shown on the main page and on the header
  1109. $this->name = 'LiteBans';
  1110.  
  1111. // Clicking on the header name will send you to this address.
  1112. // $this->name_link = 'https://example.com';
  1113. $this->name_link = 'index.php';
  1114.  
  1115. // Here you can customize colors for the Bootstrap 4 theme that you are using.
  1116. // Bootstrap 4 themes have four sets of colors: primary, secondary, light and dark.
  1117. // Navbar classes: navbar-light, navbar-dark, bg-primary, bg-secondary, bg-light, bg-dark
  1118. // Badge (label) classes: badge, badge-pill, badge-primary, badge-secondary, badge-light, badge-dark
  1119. $this->navbar_classes = 'navbar-dark bg-primary';
  1120. $this->badge_classes = 'badge-pill badge-secondary';
  1121. $this->info_badge_classes = 'badge';
  1122.  
  1123. // Show server scope column?
  1124. $this->show_server_scope = true;
  1125.  
  1126. // Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Expired).
  1127. $this->show_inactive_bans = true;
  1128.  
  1129. // Show silent bans?
  1130. $this->show_silent_bans = true;
  1131.  
  1132. // Show pager? This allows users to page through the list of bans.
  1133. $this->show_pager = true;
  1134.  
  1135. // Amount of bans/mutes/warnings to show on each page
  1136. $this->limit_per_page = 10;
  1137.  
  1138. // The server console will be identified by any of these names.
  1139. // It will be given a standard name and avatar image.
  1140. $this->console_aliases = array(
  1141. "CONSOLE", "Console",
  1142. );
  1143. $this->console_name = "Console";
  1144. $this->console_image = "inc/img/console.png";
  1145.  
  1146. // Avatar images for all players will be fetched from this URL.
  1147. // Examples:
  1148. // 'https://cravatar.eu/avatar/{uuid}/25'
  1149. // 'https://crafatar.com/avatars/{uuid}?size=25'
  1150. // 'https://minotar.net/avatar/{uuid}/25'
  1151. $this->avatar_source = 'https://crafatar.com/avatars/{uuid}?size=25';
  1152.  
  1153. // `avatar_source_offline_mode` controls where avatars for offline-mode players are fetched from.
  1154. // Offline-mode UUIDs are substituted for player names unless the `avatar_allow_offline_mode_uuids` option is enabled.
  1155. // (This is done because avatar sources generally serve the default "Steve" avatar for *all* offline-mode UUIDs, including those of premium players)
  1156. // Crafatar no longer supports names, so it cannot be used as an offline-mode player-name avatar source as of 2018-02-16 (https://crafatar.com/#meta-usernames)
  1157. // Since "skins.minecraft.net" is no longer available, this could pose a problem for other avatar sources as well.
  1158. $this->avatar_source_offline_mode = 'https://minotar.net/avatar/{name}/25';
  1159.  
  1160. // If enabled, names will be shown below avatars instead of being shown next to them.
  1161. $this->avatar_names_below = true;
  1162.  
  1163. // If enabled, offline-mode UUIDs will be requested from avatar_source instead of player names.
  1164. $this->avatar_allow_offline_mode_uuids = false;
  1165.  
  1166. // If enabled, the total amount of bans, mutes, warnings, and kicks will be shown next to the buttons in the header.
  1167. $this->header_show_totals = true;
  1168.  
  1169. // The date format can be changed here.
  1170. // https://secure.php.net/manual/en/function.strftime.php
  1171. // Example output of default format: July 2, 2015, 09:19; August 4, 2016, 18:37
  1172. $this->date_format = '%B %d, %Y, %H:%M';
  1173.  
  1174. // https://secure.php.net/manual/en/timezones.php
  1175. $timezone = "UTC";
  1176.  
  1177. // Enable PHP error reporting.
  1178. $this->error_reporting = true;
  1179.  
  1180. // Enable error pages.
  1181. $this->error_pages = true;
  1182.  
  1183. $this->date_month_translations = null;
  1184.  
  1185. // If your system locale doesn't automatically translate month names, you can set them manually here.
  1186. // Change "if (false)" to "if (true)" for this to take effect.
  1187. // X=>Y, X is replaced with Y. E.g. "January"=>"Januari"
  1188. if (false) {
  1189. $this->date_month_translations = array(
  1190. "January" => "Month 1",
  1191. "February" => "Month 2",
  1192. "March" => "Month 3",
  1193. "April" => "Month 4",
  1194. "May" => "Month 5",
  1195. "June" => "Month 6",
  1196. "July" => "Month 7",
  1197. "August" => "Month 8",
  1198. "September" => "Month 9",
  1199. "October" => "Month 10",
  1200. "November" => "Month 11",
  1201. "December" => "Month 12",
  1202. );
  1203. }
  1204.  
  1205.  
  1206. /*** End of configuration ***/
  1207.  
  1208.  
  1209. /** Don't modify anything here unless you know what you're doing **/
  1210.  
  1211. if ($this->error_reporting) {
  1212. error_reporting(E_ALL);
  1213. ini_set("display_errors", 1);
  1214. }
  1215.  
  1216. $this->active_query = "";
  1217.  
  1218. if ($driver === "pgsql") {
  1219. Settings::$TRUE = "B'1'";
  1220. Settings::$FALSE = "B'0'";
  1221. }
  1222.  
  1223. if (!$this->show_inactive_bans) {
  1224. $this->active_query = self::append_query($this->active_query, "active=" . Settings::$TRUE);
  1225. }
  1226.  
  1227. if (!$this->show_silent_bans) {
  1228. $this->active_query = self::append_query($this->active_query, "silent=" . Settings::$FALSE);
  1229. }
  1230.  
  1231. $this->test_strftime();
  1232.  
  1233. date_default_timezone_set($timezone); // set configured timezone
  1234.  
  1235. $table_prefix = $this->table_prefix;
  1236.  
  1237. // Internal table names, do not translate.
  1238. $this->table = array(
  1239. 'bans' => "${table_prefix}bans",
  1240. 'mutes' => "${table_prefix}mutes",
  1241. 'warnings' => "${table_prefix}warnings",
  1242. 'kicks' => "${table_prefix}kicks",
  1243. 'history' => "${table_prefix}history",
  1244. 'servers' => "${table_prefix}servers",
  1245. 'config' => "${table_prefix}config",
  1246. );
  1247.  
  1248. $this->driver = $driver;
  1249. if ($connect) {
  1250. if ($username === "" && $password === "") {
  1251. redirect("error/unconfigured.php");
  1252. }
  1253. $host = $this->host;
  1254. $port = $this->port;
  1255.  
  1256. $dsn = "$driver:dbname=$database;host=$host;port=$port";
  1257. if ($driver === 'mysql') {
  1258. $dsn .= ';charset=utf8';
  1259. }
  1260.  
  1261. $options = array(
  1262. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  1263. PDO::ATTR_EMULATE_PREPARES => false,
  1264. PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
  1265. );
  1266.  
  1267. try {
  1268. $this->conn = new PDO($dsn, $username, $password, $options);
  1269.  
  1270. $st = $this->conn->query("SELECT * FROM " . $this->table['config'] . " LIMIT 1;");
  1271. $st->fetch();
  1272. $st->closeCursor();
  1273. } catch (PDOException $e) {
  1274. Settings::handle_error($this, $e);
  1275. }
  1276. if ($driver === 'pgsql') {
  1277. $this->conn->query("SET NAMES 'UTF8';");
  1278. }
  1279. }
  1280. }
  1281.  
  1282. static function append_query($existing, $new) {
  1283. if ($existing !== "") {
  1284. return "$existing AND $new";
  1285. }
  1286. return "WHERE $new";
  1287. }
  1288.  
  1289. /**
  1290. * @param $settings Settings
  1291. * @param $e Exception
  1292. */
  1293. static function handle_error($settings, $e) {
  1294. $message = $e->getMessage();
  1295. if ($settings->error_pages) {
  1296. if (strstr($message, "Access denied for user")) {
  1297. if ($settings->error_reporting) {
  1298. redirect("error/access-denied.php?error=" . base64_encode($message));
  1299. } else {
  1300. redirect("error/access-denied.php");
  1301. }
  1302. }
  1303. if (strstr($message, "Base table or view not found:")) {
  1304. try {
  1305. $st = $settings->conn->query("SELECT * FROM " . $settings->table['bans'] . " LIMIT 1;");
  1306. $st->fetch();
  1307. $st->closeCursor();
  1308. } catch (PDOException $e) {
  1309. redirect("error/tables-not-found.php");
  1310. }
  1311. redirect("error/outdated-plugin.php");
  1312. }
  1313. if (strstr($message, "Unknown column")) {
  1314. redirect("error/outdated-plugin.php");
  1315. }
  1316. }
  1317. if ($settings->error_reporting === false) {
  1318. die("Database error");
  1319. }
  1320. die("Database error: $message");
  1321. }
  1322.  
  1323.  
  1324.  
  1325. private function test_strftime() {
  1326. // If you modify this function, you may get an "Assertion failed" error.
  1327. date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
  1328.  
  1329. $fail = false;
  1330. $test = gmstrftime($this->date_format, 0);
  1331. if ($test == false) {
  1332. ob_start();
  1333. var_dump($test);
  1334. $testdump = ob_get_clean();
  1335. echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
  1336. $fail = true;
  1337. }
  1338.  
  1339. $test = gmstrftime("%Y-%m-%d %H:%M", 0);
  1340. if ($test !== "1970-01-01 00:00") {
  1341. ob_start();
  1342. var_dump($test);
  1343. $testdump = ob_get_clean();
  1344. echo("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>");
  1345. echo("Actual result: $testdump");
  1346. $fail = true;
  1347. }
  1348.  
  1349. if ($fail === true) {
  1350. die;
  1351. }
  1352. }
  1353. }
  1354. <?php
  1355.  
  1356. final class Settings {
  1357. public static $TRUE = "1", $FALSE = "0";
  1358.  
  1359. public function __construct($connect = true) {
  1360. // Web interface language. Languages are stored in the "lang/" directory.
  1361. $this->lang = 'en_US.utf8';
  1362.  
  1363. // Database information
  1364. $this->host = 'sql9.freemysqlhosting.net';
  1365. $this->port = 3306;
  1366.  
  1367. $database = 'sql9264839';
  1368.  
  1369. $username = 'sql9264839';
  1370. $password = 'WCT1If52yi';
  1371.  
  1372. // If you set a table prefix in config.yml, set it here as well
  1373. $this->table_prefix = "litebans_";
  1374.  
  1375. // Supported drivers: mysql, pgsql
  1376. $driver = 'mysql';
  1377.  
  1378. // Server name, shown on the main page and on the header
  1379. $this->name = 'LiteBans';
  1380.  
  1381. // Clicking on the header name will send you to this address.
  1382. // $this->name_link = 'https://example.com';
  1383. $this->name_link = 'index.php';
  1384.  
  1385. // Here you can customize colors for the Bootstrap 4 theme that you are using.
  1386. // Bootstrap 4 themes have four sets of colors: primary, secondary, light and dark.
  1387. // Navbar classes: navbar-light, navbar-dark, bg-primary, bg-secondary, bg-light, bg-dark
  1388. // Badge (label) classes: badge, badge-pill, badge-primary, badge-secondary, badge-light, badge-dark
  1389. $this->navbar_classes = 'navbar-dark bg-primary';
  1390. $this->badge_classes = 'badge-pill badge-secondary';
  1391. $this->info_badge_classes = 'badge';
  1392.  
  1393. // Show server scope column?
  1394. $this->show_server_scope = true;
  1395.  
  1396. // Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Expired).
  1397. $this->show_inactive_bans = true;
  1398.  
  1399. // Show silent bans?
  1400. $this->show_silent_bans = true;
  1401.  
  1402. // Show pager? This allows users to page through the list of bans.
  1403. $this->show_pager = true;
  1404.  
  1405. // Amount of bans/mutes/warnings to show on each page
  1406. $this->limit_per_page = 10;
  1407.  
  1408. // The server console will be identified by any of these names.
  1409. // It will be given a standard name and avatar image.
  1410. $this->console_aliases = array(
  1411. "CONSOLE", "Console",
  1412. );
  1413. $this->console_name = "Console";
  1414. $this->console_image = "inc/img/console.png";
  1415.  
  1416. // Avatar images for all players will be fetched from this URL.
  1417. // Examples:
  1418. // 'https://cravatar.eu/avatar/{uuid}/25'
  1419. // 'https://crafatar.com/avatars/{uuid}?size=25'
  1420. // 'https://minotar.net/avatar/{uuid}/25'
  1421. $this->avatar_source = 'https://crafatar.com/avatars/{uuid}?size=25';
  1422.  
  1423. // `avatar_source_offline_mode` controls where avatars for offline-mode players are fetched from.
  1424. // Offline-mode UUIDs are substituted for player names unless the `avatar_allow_offline_mode_uuids` option is enabled.
  1425. // (This is done because avatar sources generally serve the default "Steve" avatar for *all* offline-mode UUIDs, including those of premium players)
  1426. // Crafatar no longer supports names, so it cannot be used as an offline-mode player-name avatar source as of 2018-02-16 (https://crafatar.com/#meta-usernames)
  1427. // Since "skins.minecraft.net" is no longer available, this could pose a problem for other avatar sources as well.
  1428. $this->avatar_source_offline_mode = 'https://minotar.net/avatar/{name}/25';
  1429.  
  1430. // If enabled, names will be shown below avatars instead of being shown next to them.
  1431. $this->avatar_names_below = true;
  1432.  
  1433. // If enabled, offline-mode UUIDs will be requested from avatar_source instead of player names.
  1434. $this->avatar_allow_offline_mode_uuids = false;
  1435.  
  1436. // If enabled, the total amount of bans, mutes, warnings, and kicks will be shown next to the buttons in the header.
  1437. $this->header_show_totals = true;
  1438.  
  1439. // The date format can be changed here.
  1440. // https://secure.php.net/manual/en/function.strftime.php
  1441. // Example output of default format: July 2, 2015, 09:19; August 4, 2016, 18:37
  1442. $this->date_format = '%B %d, %Y, %H:%M';
  1443.  
  1444. // https://secure.php.net/manual/en/timezones.php
  1445. $timezone = "UTC";
  1446.  
  1447. // Enable PHP error reporting.
  1448. $this->error_reporting = true;
  1449.  
  1450. // Enable error pages.
  1451. $this->error_pages = true;
  1452.  
  1453. $this->date_month_translations = null;
  1454.  
  1455. // If your system locale doesn't automatically translate month names, you can set them manually here.
  1456. // Change "if (false)" to "if (true)" for this to take effect.
  1457. // X=>Y, X is replaced with Y. E.g. "January"=>"Januari"
  1458. if (false) {
  1459. $this->date_month_translations = array(
  1460. "January" => "Month 1",
  1461. "February" => "Month 2",
  1462. "March" => "Month 3",
  1463. "April" => "Month 4",
  1464. "May" => "Month 5",
  1465. "June" => "Month 6",
  1466. "July" => "Month 7",
  1467. "August" => "Month 8",
  1468. "September" => "Month 9",
  1469. "October" => "Month 10",
  1470. "November" => "Month 11",
  1471. "December" => "Month 12",
  1472. );
  1473. }
  1474.  
  1475.  
  1476. /*** End of configuration ***/
  1477.  
  1478.  
  1479. /** Don't modify anything here unless you know what you're doing **/
  1480.  
  1481. if ($this->error_reporting) {
  1482. error_reporting(E_ALL);
  1483. ini_set("display_errors", 1);
  1484. }
  1485.  
  1486. $this->active_query = "";
  1487.  
  1488. if ($driver === "pgsql") {
  1489. Settings::$TRUE = "B'1'";
  1490. Settings::$FALSE = "B'0'";
  1491. }
  1492.  
  1493. if (!$this->show_inactive_bans) {
  1494. $this->active_query = self::append_query($this->active_query, "active=" . Settings::$TRUE);
  1495. }
  1496.  
  1497. if (!$this->show_silent_bans) {
  1498. $this->active_query = self::append_query($this->active_query, "silent=" . Settings::$FALSE);
  1499. }
  1500.  
  1501. $this->test_strftime();
  1502.  
  1503. date_default_timezone_set($timezone); // set configured timezone
  1504.  
  1505. $table_prefix = $this->table_prefix;
  1506.  
  1507. // Internal table names, do not translate.
  1508. $this->table = array(
  1509. 'bans' => "${table_prefix}bans",
  1510. 'mutes' => "${table_prefix}mutes",
  1511. 'warnings' => "${table_prefix}warnings",
  1512. 'kicks' => "${table_prefix}kicks",
  1513. 'history' => "${table_prefix}history",
  1514. 'servers' => "${table_prefix}servers",
  1515. 'config' => "${table_prefix}config",
  1516. );
  1517.  
  1518. $this->driver = $driver;
  1519. if ($connect) {
  1520. if ($username === "" && $password === "") {
  1521. redirect("error/unconfigured.php");
  1522. }
  1523. $host = $this->host;
  1524. $port = $this->port;
  1525.  
  1526. $dsn = "$driver:dbname=$database;host=$host;port=$port";
  1527. if ($driver === 'mysql') {
  1528. $dsn .= ';charset=utf8';
  1529. }
  1530.  
  1531. $options = array(
  1532. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  1533. PDO::ATTR_EMULATE_PREPARES => false,
  1534. PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
  1535. );
  1536.  
  1537. try {
  1538. $this->conn = new PDO($dsn, $username, $password, $options);
  1539.  
  1540. $st = $this->conn->query("SELECT * FROM " . $this->table['config'] . " LIMIT 1;");
  1541. $st->fetch();
  1542. $st->closeCursor();
  1543. } catch (PDOException $e) {
  1544. Settings::handle_error($this, $e);
  1545. }
  1546. if ($driver === 'pgsql') {
  1547. $this->conn->query("SET NAMES 'UTF8';");
  1548. }
  1549. }
  1550. }
  1551.  
  1552. static function append_query($existing, $new) {
  1553. if ($existing !== "") {
  1554. return "$existing AND $new";
  1555. }
  1556. return "WHERE $new";
  1557. }
  1558.  
  1559. /**
  1560. * @param $settings Settings
  1561. * @param $e Exception
  1562. */
  1563. static function handle_error($settings, $e) {
  1564. $message = $e->getMessage();
  1565. if ($settings->error_pages) {
  1566. if (strstr($message, "Access denied for user")) {
  1567. if ($settings->error_reporting) {
  1568. redirect("error/access-denied.php?error=" . base64_encode($message));
  1569. } else {
  1570. redirect("error/access-denied.php");
  1571. }
  1572. }
  1573. if (strstr($message, "Base table or view not found:")) {
  1574. try {
  1575. $st = $settings->conn->query("SELECT * FROM " . $settings->table['bans'] . " LIMIT 1;");
  1576. $st->fetch();
  1577. $st->closeCursor();
  1578. } catch (PDOException $e) {
  1579. redirect("error/tables-not-found.php");
  1580. }
  1581. redirect("error/outdated-plugin.php");
  1582. }
  1583. if (strstr($message, "Unknown column")) {
  1584. redirect("error/outdated-plugin.php");
  1585. }
  1586. }
  1587. if ($settings->error_reporting === false) {
  1588. die("Database error");
  1589. }
  1590. die("Database error: $message");
  1591. }
  1592.  
  1593.  
  1594.  
  1595. private function test_strftime() {
  1596. // If you modify this function, you may get an "Assertion failed" error.
  1597. date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
  1598.  
  1599. $fail = false;
  1600. $test = gmstrftime($this->date_format, 0);
  1601. if ($test == false) {
  1602. ob_start();
  1603. var_dump($test);
  1604. $testdump = ob_get_clean();
  1605. echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
  1606. $fail = true;
  1607. }
  1608.  
  1609. $test = gmstrftime("%Y-%m-%d %H:%M", 0);
  1610. if ($test !== "1970-01-01 00:00") {
  1611. ob_start();
  1612. var_dump($test);
  1613. $testdump = ob_get_clean();
  1614. echo("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>");
  1615. echo("Actual result: $testdump");
  1616. $fail = true;
  1617. }
  1618.  
  1619. if ($fail === true) {
  1620. die;
  1621. }
  1622. }
  1623. }
  1624. <?php
  1625.  
  1626. final class Settings {
  1627. public static $TRUE = "1", $FALSE = "0";
  1628.  
  1629. public function __construct($connect = true) {
  1630. // Web interface language. Languages are stored in the "lang/" directory.
  1631. $this->lang = 'en_US.utf8';
  1632.  
  1633. // Database information
  1634. $this->host = 'sql9.freemysqlhosting.net';
  1635. $this->port = 3306;
  1636.  
  1637. $database = 'sql9264839';
  1638.  
  1639. $username = 'sql9264839';
  1640. $password = 'WCT1If52yi';
  1641.  
  1642. // If you set a table prefix in config.yml, set it here as well
  1643. $this->table_prefix = "litebans_";
  1644.  
  1645. // Supported drivers: mysql, pgsql
  1646. $driver = 'mysql';
  1647.  
  1648. // Server name, shown on the main page and on the header
  1649. $this->name = 'LiteBans';
  1650.  
  1651. // Clicking on the header name will send you to this address.
  1652. // $this->name_link = 'https://example.com';
  1653. $this->name_link = 'index.php';
  1654.  
  1655. // Here you can customize colors for the Bootstrap 4 theme that you are using.
  1656. // Bootstrap 4 themes have four sets of colors: primary, secondary, light and dark.
  1657. // Navbar classes: navbar-light, navbar-dark, bg-primary, bg-secondary, bg-light, bg-dark
  1658. // Badge (label) classes: badge, badge-pill, badge-primary, badge-secondary, badge-light, badge-dark
  1659. $this->navbar_classes = 'navbar-dark bg-primary';
  1660. $this->badge_classes = 'badge-pill badge-secondary';
  1661. $this->info_badge_classes = 'badge';
  1662.  
  1663. // Show server scope column?
  1664. $this->show_server_scope = true;
  1665.  
  1666. // Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Expired).
  1667. $this->show_inactive_bans = true;
  1668.  
  1669. // Show silent bans?
  1670. $this->show_silent_bans = true;
  1671.  
  1672. // Show pager? This allows users to page through the list of bans.
  1673. $this->show_pager = true;
  1674.  
  1675. // Amount of bans/mutes/warnings to show on each page
  1676. $this->limit_per_page = 10;
  1677.  
  1678. // The server console will be identified by any of these names.
  1679. // It will be given a standard name and avatar image.
  1680. $this->console_aliases = array(
  1681. "CONSOLE", "Console",
  1682. );
  1683. $this->console_name = "Console";
  1684. $this->console_image = "inc/img/console.png";
  1685.  
  1686. // Avatar images for all players will be fetched from this URL.
  1687. // Examples:
  1688. // 'https://cravatar.eu/avatar/{uuid}/25'
  1689. // 'https://crafatar.com/avatars/{uuid}?size=25'
  1690. // 'https://minotar.net/avatar/{uuid}/25'
  1691. $this->avatar_source = 'https://crafatar.com/avatars/{uuid}?size=25';
  1692.  
  1693. // `avatar_source_offline_mode` controls where avatars for offline-mode players are fetched from.
  1694. // Offline-mode UUIDs are substituted for player names unless the `avatar_allow_offline_mode_uuids` option is enabled.
  1695. // (This is done because avatar sources generally serve the default "Steve" avatar for *all* offline-mode UUIDs, including those of premium players)
  1696. // Crafatar no longer supports names, so it cannot be used as an offline-mode player-name avatar source as of 2018-02-16 (https://crafatar.com/#meta-usernames)
  1697. // Since "skins.minecraft.net" is no longer available, this could pose a problem for other avatar sources as well.
  1698. $this->avatar_source_offline_mode = 'https://minotar.net/avatar/{name}/25';
  1699.  
  1700. // If enabled, names will be shown below avatars instead of being shown next to them.
  1701. $this->avatar_names_below = true;
  1702.  
  1703. // If enabled, offline-mode UUIDs will be requested from avatar_source instead of player names.
  1704. $this->avatar_allow_offline_mode_uuids = false;
  1705.  
  1706. // If enabled, the total amount of bans, mutes, warnings, and kicks will be shown next to the buttons in the header.
  1707. $this->header_show_totals = true;
  1708.  
  1709. // The date format can be changed here.
  1710. // https://secure.php.net/manual/en/function.strftime.php
  1711. // Example output of default format: July 2, 2015, 09:19; August 4, 2016, 18:37
  1712. $this->date_format = '%B %d, %Y, %H:%M';
  1713.  
  1714. // https://secure.php.net/manual/en/timezones.php
  1715. $timezone = "UTC";
  1716.  
  1717. // Enable PHP error reporting.
  1718. $this->error_reporting = true;
  1719.  
  1720. // Enable error pages.
  1721. $this->error_pages = true;
  1722.  
  1723. $this->date_month_translations = null;
  1724.  
  1725. // If your system locale doesn't automatically translate month names, you can set them manually here.
  1726. // Change "if (false)" to "if (true)" for this to take effect.
  1727. // X=>Y, X is replaced with Y. E.g. "January"=>"Januari"
  1728. if (false) {
  1729. $this->date_month_translations = array(
  1730. "January" => "Month 1",
  1731. "February" => "Month 2",
  1732. "March" => "Month 3",
  1733. "April" => "Month 4",
  1734. "May" => "Month 5",
  1735. "June" => "Month 6",
  1736. "July" => "Month 7",
  1737. "August" => "Month 8",
  1738. "September" => "Month 9",
  1739. "October" => "Month 10",
  1740. "November" => "Month 11",
  1741. "December" => "Month 12",
  1742. );
  1743. }
  1744.  
  1745.  
  1746. /*** End of configuration ***/
  1747.  
  1748.  
  1749. /** Don't modify anything here unless you know what you're doing **/
  1750.  
  1751. if ($this->error_reporting) {
  1752. error_reporting(E_ALL);
  1753. ini_set("display_errors", 1);
  1754. }
  1755.  
  1756. $this->active_query = "";
  1757.  
  1758. if ($driver === "pgsql") {
  1759. Settings::$TRUE = "B'1'";
  1760. Settings::$FALSE = "B'0'";
  1761. }
  1762.  
  1763. if (!$this->show_inactive_bans) {
  1764. $this->active_query = self::append_query($this->active_query, "active=" . Settings::$TRUE);
  1765. }
  1766.  
  1767. if (!$this->show_silent_bans) {
  1768. $this->active_query = self::append_query($this->active_query, "silent=" . Settings::$FALSE);
  1769. }
  1770.  
  1771. $this->test_strftime();
  1772.  
  1773. date_default_timezone_set($timezone); // set configured timezone
  1774.  
  1775. $table_prefix = $this->table_prefix;
  1776.  
  1777. // Internal table names, do not translate.
  1778. $this->table = array(
  1779. 'bans' => "${table_prefix}bans",
  1780. 'mutes' => "${table_prefix}mutes",
  1781. 'warnings' => "${table_prefix}warnings",
  1782. 'kicks' => "${table_prefix}kicks",
  1783. 'history' => "${table_prefix}history",
  1784. 'servers' => "${table_prefix}servers",
  1785. 'config' => "${table_prefix}config",
  1786. );
  1787.  
  1788. $this->driver = $driver;
  1789. if ($connect) {
  1790. if ($username === "" && $password === "") {
  1791. redirect("error/unconfigured.php");
  1792. }
  1793. $host = $this->host;
  1794. $port = $this->port;
  1795.  
  1796. $dsn = "$driver:dbname=$database;host=$host;port=$port";
  1797. if ($driver === 'mysql') {
  1798. $dsn .= ';charset=utf8';
  1799. }
  1800.  
  1801. $options = array(
  1802. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  1803. PDO::ATTR_EMULATE_PREPARES => false,
  1804. PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
  1805. );
  1806.  
  1807. try {
  1808. $this->conn = new PDO($dsn, $username, $password, $options);
  1809.  
  1810. $st = $this->conn->query("SELECT * FROM " . $this->table['config'] . " LIMIT 1;");
  1811. $st->fetch();
  1812. $st->closeCursor();
  1813. } catch (PDOException $e) {
  1814. Settings::handle_error($this, $e);
  1815. }
  1816. if ($driver === 'pgsql') {
  1817. $this->conn->query("SET NAMES 'UTF8';");
  1818. }
  1819. }
  1820. }
  1821.  
  1822. static function append_query($existing, $new) {
  1823. if ($existing !== "") {
  1824. return "$existing AND $new";
  1825. }
  1826. return "WHERE $new";
  1827. }
  1828.  
  1829. /**
  1830. * @param $settings Settings
  1831. * @param $e Exception
  1832. */
  1833. static function handle_error($settings, $e) {
  1834. $message = $e->getMessage();
  1835. if ($settings->error_pages) {
  1836. if (strstr($message, "Access denied for user")) {
  1837. if ($settings->error_reporting) {
  1838. redirect("error/access-denied.php?error=" . base64_encode($message));
  1839. } else {
  1840. redirect("error/access-denied.php");
  1841. }
  1842. }
  1843. if (strstr($message, "Base table or view not found:")) {
  1844. try {
  1845. $st = $settings->conn->query("SELECT * FROM " . $settings->table['bans'] . " LIMIT 1;");
  1846. $st->fetch();
  1847. $st->closeCursor();
  1848. } catch (PDOException $e) {
  1849. redirect("error/tables-not-found.php");
  1850. }
  1851. redirect("error/outdated-plugin.php");
  1852. }
  1853. if (strstr($message, "Unknown column")) {
  1854. redirect("error/outdated-plugin.php");
  1855. }
  1856. }
  1857. if ($settings->error_reporting === false) {
  1858. die("Database error");
  1859. }
  1860. die("Database error: $message");
  1861. }
  1862.  
  1863.  
  1864.  
  1865. private function test_strftime() {
  1866. // If you modify this function, you may get an "Assertion failed" error.
  1867. date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
  1868.  
  1869. $fail = false;
  1870. $test = gmstrftime($this->date_format, 0);
  1871. if ($test == false) {
  1872. ob_start();
  1873. var_dump($test);
  1874. $testdump = ob_get_clean();
  1875. echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
  1876. $fail = true;
  1877. }
  1878.  
  1879. $test = gmstrftime("%Y-%m-%d %H:%M", 0);
  1880. if ($test !== "1970-01-01 00:00") {
  1881. ob_start();
  1882. var_dump($test);
  1883. $testdump = ob_get_clean();
  1884. echo("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>");
  1885. echo("Actual result: $testdump");
  1886. $fail = true;
  1887. }
  1888.  
  1889. if ($fail === true) {
  1890. die;
  1891. }
  1892. }
  1893. }
  1894. <?php
  1895.  
  1896. final class Settings {
  1897. public static $TRUE = "1", $FALSE = "0";
  1898.  
  1899. public function __construct($connect = true) {
  1900. // Web interface language. Languages are stored in the "lang/" directory.
  1901. $this->lang = 'en_US.utf8';
  1902.  
  1903. // Database information
  1904. $this->host = 'sql9.freemysqlhosting.net';
  1905. $this->port = 3306;
  1906.  
  1907. $database = 'sql9264839';
  1908.  
  1909. $username = 'sql9264839';
  1910. $password = 'WCT1If52yi';
  1911.  
  1912. // If you set a table prefix in config.yml, set it here as well
  1913. $this->table_prefix = "litebans_";
  1914.  
  1915. // Supported drivers: mysql, pgsql
  1916. $driver = 'mysql';
  1917.  
  1918. // Server name, shown on the main page and on the header
  1919. $this->name = 'LiteBans';
  1920.  
  1921. // Clicking on the header name will send you to this address.
  1922. // $this->name_link = 'https://example.com';
  1923. $this->name_link = 'index.php';
  1924.  
  1925. // Here you can customize colors for the Bootstrap 4 theme that you are using.
  1926. // Bootstrap 4 themes have four sets of colors: primary, secondary, light and dark.
  1927. // Navbar classes: navbar-light, navbar-dark, bg-primary, bg-secondary, bg-light, bg-dark
  1928. // Badge (label) classes: badge, badge-pill, badge-primary, badge-secondary, badge-light, badge-dark
  1929. $this->navbar_classes = 'navbar-dark bg-primary';
  1930. $this->badge_classes = 'badge-pill badge-secondary';
  1931. $this->info_badge_classes = 'badge';
  1932.  
  1933. // Show server scope column?
  1934. $this->show_server_scope = true;
  1935.  
  1936. // Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Expired).
  1937. $this->show_inactive_bans = true;
  1938.  
  1939. // Show silent bans?
  1940. $this->show_silent_bans = true;
  1941.  
  1942. // Show pager? This allows users to page through the list of bans.
  1943. $this->show_pager = true;
  1944.  
  1945. // Amount of bans/mutes/warnings to show on each page
  1946. $this->limit_per_page = 10;
  1947.  
  1948. // The server console will be identified by any of these names.
  1949. // It will be given a standard name and avatar image.
  1950. $this->console_aliases = array(
  1951. "CONSOLE", "Console",
  1952. );
  1953. $this->console_name = "Console";
  1954. $this->console_image = "inc/img/console.png";
  1955.  
  1956. // Avatar images for all players will be fetched from this URL.
  1957. // Examples:
  1958. // 'https://cravatar.eu/avatar/{uuid}/25'
  1959. // 'https://crafatar.com/avatars/{uuid}?size=25'
  1960. // 'https://minotar.net/avatar/{uuid}/25'
  1961. $this->avatar_source = 'https://crafatar.com/avatars/{uuid}?size=25';
  1962.  
  1963. // `avatar_source_offline_mode` controls where avatars for offline-mode players are fetched from.
  1964. // Offline-mode UUIDs are substituted for player names unless the `avatar_allow_offline_mode_uuids` option is enabled.
  1965. // (This is done because avatar sources generally serve the default "Steve" avatar for *all* offline-mode UUIDs, including those of premium players)
  1966. // Crafatar no longer supports names, so it cannot be used as an offline-mode player-name avatar source as of 2018-02-16 (https://crafatar.com/#meta-usernames)
  1967. // Since "skins.minecraft.net" is no longer available, this could pose a problem for other avatar sources as well.
  1968. $this->avatar_source_offline_mode = 'https://minotar.net/avatar/{name}/25';
  1969.  
  1970. // If enabled, names will be shown below avatars instead of being shown next to them.
  1971. $this->avatar_names_below = true;
  1972.  
  1973. // If enabled, offline-mode UUIDs will be requested from avatar_source instead of player names.
  1974. $this->avatar_allow_offline_mode_uuids = false;
  1975.  
  1976. // If enabled, the total amount of bans, mutes, warnings, and kicks will be shown next to the buttons in the header.
  1977. $this->header_show_totals = true;
  1978.  
  1979. // The date format can be changed here.
  1980. // https://secure.php.net/manual/en/function.strftime.php
  1981. // Example output of default format: July 2, 2015, 09:19; August 4, 2016, 18:37
  1982. $this->date_format = '%B %d, %Y, %H:%M';
  1983.  
  1984. // https://secure.php.net/manual/en/timezones.php
  1985. $timezone = "UTC";
  1986.  
  1987. // Enable PHP error reporting.
  1988. $this->error_reporting = true;
  1989.  
  1990. // Enable error pages.
  1991. $this->error_pages = true;
  1992.  
  1993. $this->date_month_translations = null;
  1994.  
  1995. // If your system locale doesn't automatically translate month names, you can set them manually here.
  1996. // Change "if (false)" to "if (true)" for this to take effect.
  1997. // X=>Y, X is replaced with Y. E.g. "January"=>"Januari"
  1998. if (false) {
  1999. $this->date_month_translations = array(
  2000. "January" => "Month 1",
  2001. "February" => "Month 2",
  2002. "March" => "Month 3",
  2003. "April" => "Month 4",
  2004. "May" => "Month 5",
  2005. "June" => "Month 6",
  2006. "July" => "Month 7",
  2007. "August" => "Month 8",
  2008. "September" => "Month 9",
  2009. "October" => "Month 10",
  2010. "November" => "Month 11",
  2011. "December" => "Month 12",
  2012. );
  2013. }
  2014.  
  2015.  
  2016. /*** End of configuration ***/
  2017.  
  2018.  
  2019. /** Don't modify anything here unless you know what you're doing **/
  2020.  
  2021. if ($this->error_reporting) {
  2022. error_reporting(E_ALL);
  2023. ini_set("display_errors", 1);
  2024. }
  2025.  
  2026. $this->active_query = "";
  2027.  
  2028. if ($driver === "pgsql") {
  2029. Settings::$TRUE = "B'1'";
  2030. Settings::$FALSE = "B'0'";
  2031. }
  2032.  
  2033. if (!$this->show_inactive_bans) {
  2034. $this->active_query = self::append_query($this->active_query, "active=" . Settings::$TRUE);
  2035. }
  2036.  
  2037. if (!$this->show_silent_bans) {
  2038. $this->active_query = self::append_query($this->active_query, "silent=" . Settings::$FALSE);
  2039. }
  2040.  
  2041. $this->test_strftime();
  2042.  
  2043. date_default_timezone_set($timezone); // set configured timezone
  2044.  
  2045. $table_prefix = $this->table_prefix;
  2046.  
  2047. // Internal table names, do not translate.
  2048. $this->table = array(
  2049. 'bans' => "${table_prefix}bans",
  2050. 'mutes' => "${table_prefix}mutes",
  2051. 'warnings' => "${table_prefix}warnings",
  2052. 'kicks' => "${table_prefix}kicks",
  2053. 'history' => "${table_prefix}history",
  2054. 'servers' => "${table_prefix}servers",
  2055. 'config' => "${table_prefix}config",
  2056. );
  2057.  
  2058. $this->driver = $driver;
  2059. if ($connect) {
  2060. if ($username === "" && $password === "") {
  2061. redirect("error/unconfigured.php");
  2062. }
  2063. $host = $this->host;
  2064. $port = $this->port;
  2065.  
  2066. $dsn = "$driver:dbname=$database;host=$host;port=$port";
  2067. if ($driver === 'mysql') {
  2068. $dsn .= ';charset=utf8';
  2069. }
  2070.  
  2071. $options = array(
  2072. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  2073. PDO::ATTR_EMULATE_PREPARES => false,
  2074. PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
  2075. );
  2076.  
  2077. try {
  2078. $this->conn = new PDO($dsn, $username, $password, $options);
  2079.  
  2080. $st = $this->conn->query("SELECT * FROM " . $this->table['config'] . " LIMIT 1;");
  2081. $st->fetch();
  2082. $st->closeCursor();
  2083. } catch (PDOException $e) {
  2084. Settings::handle_error($this, $e);
  2085. }
  2086. if ($driver === 'pgsql') {
  2087. $this->conn->query("SET NAMES 'UTF8';");
  2088. }
  2089. }
  2090. }
  2091.  
  2092. static function append_query($existing, $new) {
  2093. if ($existing !== "") {
  2094. return "$existing AND $new";
  2095. }
  2096. return "WHERE $new";
  2097. }
  2098.  
  2099. /**
  2100. * @param $settings Settings
  2101. * @param $e Exception
  2102. */
  2103. static function handle_error($settings, $e) {
  2104. $message = $e->getMessage();
  2105. if ($settings->error_pages) {
  2106. if (strstr($message, "Access denied for user")) {
  2107. if ($settings->error_reporting) {
  2108. redirect("error/access-denied.php?error=" . base64_encode($message));
  2109. } else {
  2110. redirect("error/access-denied.php");
  2111. }
  2112. }
  2113. if (strstr($message, "Base table or view not found:")) {
  2114. try {
  2115. $st = $settings->conn->query("SELECT * FROM " . $settings->table['bans'] . " LIMIT 1;");
  2116. $st->fetch();
  2117. $st->closeCursor();
  2118. } catch (PDOException $e) {
  2119. redirect("error/tables-not-found.php");
  2120. }
  2121. redirect("error/outdated-plugin.php");
  2122. }
  2123. if (strstr($message, "Unknown column")) {
  2124. redirect("error/outdated-plugin.php");
  2125. }
  2126. }
  2127. if ($settings->error_reporting === false) {
  2128. die("Database error");
  2129. }
  2130. die("Database error: $message");
  2131. }
  2132.  
  2133.  
  2134.  
  2135. private function test_strftime() {
  2136. // If you modify this function, you may get an "Assertion failed" error.
  2137. date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
  2138.  
  2139. $fail = false;
  2140. $test = gmstrftime($this->date_format, 0);
  2141. if ($test == false) {
  2142. ob_start();
  2143. var_dump($test);
  2144. $testdump = ob_get_clean();
  2145. echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
  2146. $fail = true;
  2147. }
  2148.  
  2149. $test = gmstrftime("%Y-%m-%d %H:%M", 0);
  2150. if ($test !== "1970-01-01 00:00") {
  2151. ob_start();
  2152. var_dump($test);
  2153. $testdump = ob_get_clean();
  2154. echo("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>");
  2155. echo("Actual result: $testdump");
  2156. $fail = true;
  2157. }
  2158.  
  2159. if ($fail === true) {
  2160. die;
  2161. }
  2162. }
  2163. }
  2164. <?php
  2165.  
  2166. final class Settings {
  2167. public static $TRUE = "1", $FALSE = "0";
  2168.  
  2169. public function __construct($connect = true) {
  2170. // Web interface language. Languages are stored in the "lang/" directory.
  2171. $this->lang = 'en_US.utf8';
  2172.  
  2173. // Database information
  2174. $this->host = 'sql9.freemysqlhosting.net';
  2175. $this->port = 3306;
  2176.  
  2177. $database = 'sql9264839';
  2178.  
  2179. $username = 'sql9264839';
  2180. $password = 'WCT1If52yi';
  2181.  
  2182. // If you set a table prefix in config.yml, set it here as well
  2183. $this->table_prefix = "litebans_";
  2184.  
  2185. // Supported drivers: mysql, pgsql
  2186. $driver = 'mysql';
  2187.  
  2188. // Server name, shown on the main page and on the header
  2189. $this->name = 'LiteBans';
  2190.  
  2191. // Clicking on the header name will send you to this address.
  2192. // $this->name_link = 'https://example.com';
  2193. $this->name_link = 'index.php';
  2194.  
  2195. // Here you can customize colors for the Bootstrap 4 theme that you are using.
  2196. // Bootstrap 4 themes have four sets of colors: primary, secondary, light and dark.
  2197. // Navbar classes: navbar-light, navbar-dark, bg-primary, bg-secondary, bg-light, bg-dark
  2198. // Badge (label) classes: badge, badge-pill, badge-primary, badge-secondary, badge-light, badge-dark
  2199. $this->navbar_classes = 'navbar-dark bg-primary';
  2200. $this->badge_classes = 'badge-pill badge-secondary';
  2201. $this->info_badge_classes = 'badge';
  2202.  
  2203. // Show server scope column?
  2204. $this->show_server_scope = true;
  2205.  
  2206. // Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Expired).
  2207. $this->show_inactive_bans = true;
  2208.  
  2209. // Show silent bans?
  2210. $this->show_silent_bans = true;
  2211.  
  2212. // Show pager? This allows users to page through the list of bans.
  2213. $this->show_pager = true;
  2214.  
  2215. // Amount of bans/mutes/warnings to show on each page
  2216. $this->limit_per_page = 10;
  2217.  
  2218. // The server console will be identified by any of these names.
  2219. // It will be given a standard name and avatar image.
  2220. $this->console_aliases = array(
  2221. "CONSOLE", "Console",
  2222. );
  2223. $this->console_name = "Console";
  2224. $this->console_image = "inc/img/console.png";
  2225.  
  2226. // Avatar images for all players will be fetched from this URL.
  2227. // Examples:
  2228. // 'https://cravatar.eu/avatar/{uuid}/25'
  2229. // 'https://crafatar.com/avatars/{uuid}?size=25'
  2230. // 'https://minotar.net/avatar/{uuid}/25'
  2231. $this->avatar_source = 'https://crafatar.com/avatars/{uuid}?size=25';
  2232.  
  2233. // `avatar_source_offline_mode` controls where avatars for offline-mode players are fetched from.
  2234. // Offline-mode UUIDs are substituted for player names unless the `avatar_allow_offline_mode_uuids` option is enabled.
  2235. // (This is done because avatar sources generally serve the default "Steve" avatar for *all* offline-mode UUIDs, including those of premium players)
  2236. // Crafatar no longer supports names, so it cannot be used as an offline-mode player-name avatar source as of 2018-02-16 (https://crafatar.com/#meta-usernames)
  2237. // Since "skins.minecraft.net" is no longer available, this could pose a problem for other avatar sources as well.
  2238. $this->avatar_source_offline_mode = 'https://minotar.net/avatar/{name}/25';
  2239.  
  2240. // If enabled, names will be shown below avatars instead of being shown next to them.
  2241. $this->avatar_names_below = true;
  2242.  
  2243. // If enabled, offline-mode UUIDs will be requested from avatar_source instead of player names.
  2244. $this->avatar_allow_offline_mode_uuids = false;
  2245.  
  2246. // If enabled, the total amount of bans, mutes, warnings, and kicks will be shown next to the buttons in the header.
  2247. $this->header_show_totals = true;
  2248.  
  2249. // The date format can be changed here.
  2250. // https://secure.php.net/manual/en/function.strftime.php
  2251. // Example output of default format: July 2, 2015, 09:19; August 4, 2016, 18:37
  2252. $this->date_format = '%B %d, %Y, %H:%M';
  2253.  
  2254. // https://secure.php.net/manual/en/timezones.php
  2255. $timezone = "UTC";
  2256.  
  2257. // Enable PHP error reporting.
  2258. $this->error_reporting = true;
  2259.  
  2260. // Enable error pages.
  2261. $this->error_pages = true;
  2262.  
  2263. $this->date_month_translations = null;
  2264.  
  2265. // If your system locale doesn't automatically translate month names, you can set them manually here.
  2266. // Change "if (false)" to "if (true)" for this to take effect.
  2267. // X=>Y, X is replaced with Y. E.g. "January"=>"Januari"
  2268. if (false) {
  2269. $this->date_month_translations = array(
  2270. "January" => "Month 1",
  2271. "February" => "Month 2",
  2272. "March" => "Month 3",
  2273. "April" => "Month 4",
  2274. "May" => "Month 5",
  2275. "June" => "Month 6",
  2276. "July" => "Month 7",
  2277. "August" => "Month 8",
  2278. "September" => "Month 9",
  2279. "October" => "Month 10",
  2280. "November" => "Month 11",
  2281. "December" => "Month 12",
  2282. );
  2283. }
  2284.  
  2285.  
  2286. /*** End of configuration ***/
  2287.  
  2288.  
  2289. /** Don't modify anything here unless you know what you're doing **/
  2290.  
  2291. if ($this->error_reporting) {
  2292. error_reporting(E_ALL);
  2293. ini_set("display_errors", 1);
  2294. }
  2295.  
  2296. $this->active_query = "";
  2297.  
  2298. if ($driver === "pgsql") {
  2299. Settings::$TRUE = "B'1'";
  2300. Settings::$FALSE = "B'0'";
  2301. }
  2302.  
  2303. if (!$this->show_inactive_bans) {
  2304. $this->active_query = self::append_query($this->active_query, "active=" . Settings::$TRUE);
  2305. }
  2306.  
  2307. if (!$this->show_silent_bans) {
  2308. $this->active_query = self::append_query($this->active_query, "silent=" . Settings::$FALSE);
  2309. }
  2310.  
  2311. $this->test_strftime();
  2312.  
  2313. date_default_timezone_set($timezone); // set configured timezone
  2314.  
  2315. $table_prefix = $this->table_prefix;
  2316.  
  2317. // Internal table names, do not translate.
  2318. $this->table = array(
  2319. 'bans' => "${table_prefix}bans",
  2320. 'mutes' => "${table_prefix}mutes",
  2321. 'warnings' => "${table_prefix}warnings",
  2322. 'kicks' => "${table_prefix}kicks",
  2323. 'history' => "${table_prefix}history",
  2324. 'servers' => "${table_prefix}servers",
  2325. 'config' => "${table_prefix}config",
  2326. );
  2327.  
  2328. $this->driver = $driver;
  2329. if ($connect) {
  2330. if ($username === "" && $password === "") {
  2331. redirect("error/unconfigured.php");
  2332. }
  2333. $host = $this->host;
  2334. $port = $this->port;
  2335.  
  2336. $dsn = "$driver:dbname=$database;host=$host;port=$port";
  2337. if ($driver === 'mysql') {
  2338. $dsn .= ';charset=utf8';
  2339. }
  2340.  
  2341. $options = array(
  2342. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  2343. PDO::ATTR_EMULATE_PREPARES => false,
  2344. PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
  2345. );
  2346.  
  2347. try {
  2348. $this->conn = new PDO($dsn, $username, $password, $options);
  2349.  
  2350. $st = $this->conn->query("SELECT * FROM " . $this->table['config'] . " LIMIT 1;");
  2351. $st->fetch();
  2352. $st->closeCursor();
  2353. } catch (PDOException $e) {
  2354. Settings::handle_error($this, $e);
  2355. }
  2356. if ($driver === 'pgsql') {
  2357. $this->conn->query("SET NAMES 'UTF8';");
  2358. }
  2359. }
  2360. }
  2361.  
  2362. static function append_query($existing, $new) {
  2363. if ($existing !== "") {
  2364. return "$existing AND $new";
  2365. }
  2366. return "WHERE $new";
  2367. }
  2368.  
  2369. /**
  2370. * @param $settings Settings
  2371. * @param $e Exception
  2372. */
  2373. static function handle_error($settings, $e) {
  2374. $message = $e->getMessage();
  2375. if ($settings->error_pages) {
  2376. if (strstr($message, "Access denied for user")) {
  2377. if ($settings->error_reporting) {
  2378. redirect("error/access-denied.php?error=" . base64_encode($message));
  2379. } else {
  2380. redirect("error/access-denied.php");
  2381. }
  2382. }
  2383. if (strstr($message, "Base table or view not found:")) {
  2384. try {
  2385. $st = $settings->conn->query("SELECT * FROM " . $settings->table['bans'] . " LIMIT 1;");
  2386. $st->fetch();
  2387. $st->closeCursor();
  2388. } catch (PDOException $e) {
  2389. redirect("error/tables-not-found.php");
  2390. }
  2391. redirect("error/outdated-plugin.php");
  2392. }
  2393. if (strstr($message, "Unknown column")) {
  2394. redirect("error/outdated-plugin.php");
  2395. }
  2396. }
  2397. if ($settings->error_reporting === false) {
  2398. die("Database error");
  2399. }
  2400. die("Database error: $message");
  2401. }
  2402.  
  2403.  
  2404.  
  2405. private function test_strftime() {
  2406. // If you modify this function, you may get an "Assertion failed" error.
  2407. date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
  2408.  
  2409. $fail = false;
  2410. $test = gmstrftime($this->date_format, 0);
  2411. if ($test == false) {
  2412. ob_start();
  2413. var_dump($test);
  2414. $testdump = ob_get_clean();
  2415. echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
  2416. $fail = true;
  2417. }
  2418.  
  2419. $test = gmstrftime("%Y-%m-%d %H:%M", 0);
  2420. if ($test !== "1970-01-01 00:00") {
  2421. ob_start();
  2422. var_dump($test);
  2423. $testdump = ob_get_clean();
  2424. echo("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>");
  2425. echo("Actual result: $testdump");
  2426. $fail = true;
  2427. }
  2428.  
  2429. if ($fail === true) {
  2430. die;
  2431. }
  2432. }
  2433. }
  2434. <?php
  2435.  
  2436. final class Settings {
  2437. public static $TRUE = "1", $FALSE = "0";
  2438.  
  2439. public function __construct($connect = true) {
  2440. // Web interface language. Languages are stored in the "lang/" directory.
  2441. $this->lang = 'en_US.utf8';
  2442.  
  2443. // Database information
  2444. $this->host = 'sql9.freemysqlhosting.net';
  2445. $this->port = 3306;
  2446.  
  2447. $database = 'sql9264839';
  2448.  
  2449. $username = 'sql9264839';
  2450. $password = 'WCT1If52yi';
  2451.  
  2452. // If you set a table prefix in config.yml, set it here as well
  2453. $this->table_prefix = "litebans_";
  2454.  
  2455. // Supported drivers: mysql, pgsql
  2456. $driver = 'mysql';
  2457.  
  2458. // Server name, shown on the main page and on the header
  2459. $this->name = 'LiteBans';
  2460.  
  2461. // Clicking on the header name will send you to this address.
  2462. // $this->name_link = 'https://example.com';
  2463. $this->name_link = 'index.php';
  2464.  
  2465. // Here you can customize colors for the Bootstrap 4 theme that you are using.
  2466. // Bootstrap 4 themes have four sets of colors: primary, secondary, light and dark.
  2467. // Navbar classes: navbar-light, navbar-dark, bg-primary, bg-secondary, bg-light, bg-dark
  2468. // Badge (label) classes: badge, badge-pill, badge-primary, badge-secondary, badge-light, badge-dark
  2469. $this->navbar_classes = 'navbar-dark bg-primary';
  2470. $this->badge_classes = 'badge-pill badge-secondary';
  2471. $this->info_badge_classes = 'badge';
  2472.  
  2473. // Show server scope column?
  2474. $this->show_server_scope = true;
  2475.  
  2476. // Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Expired).
  2477. $this->show_inactive_bans = true;
  2478.  
  2479. // Show silent bans?
  2480. $this->show_silent_bans = true;
  2481.  
  2482. // Show pager? This allows users to page through the list of bans.
  2483. $this->show_pager = true;
  2484.  
  2485. // Amount of bans/mutes/warnings to show on each page
  2486. $this->limit_per_page = 10;
  2487.  
  2488. // The server console will be identified by any of these names.
  2489. // It will be given a standard name and avatar image.
  2490. $this->console_aliases = array(
  2491. "CONSOLE", "Console",
  2492. );
  2493. $this->console_name = "Console";
  2494. $this->console_image = "inc/img/console.png";
  2495.  
  2496. // Avatar images for all players will be fetched from this URL.
  2497. // Examples:
  2498. // 'https://cravatar.eu/avatar/{uuid}/25'
  2499. // 'https://crafatar.com/avatars/{uuid}?size=25'
  2500. // 'https://minotar.net/avatar/{uuid}/25'
  2501. $this->avatar_source = 'https://crafatar.com/avatars/{uuid}?size=25';
  2502.  
  2503. // `avatar_source_offline_mode` controls where avatars for offline-mode players are fetched from.
  2504. // Offline-mode UUIDs are substituted for player names unless the `avatar_allow_offline_mode_uuids` option is enabled.
  2505. // (This is done because avatar sources generally serve the default "Steve" avatar for *all* offline-mode UUIDs, including those of premium players)
  2506. // Crafatar no longer supports names, so it cannot be used as an offline-mode player-name avatar source as of 2018-02-16 (https://crafatar.com/#meta-usernames)
  2507. // Since "skins.minecraft.net" is no longer available, this could pose a problem for other avatar sources as well.
  2508. $this->avatar_source_offline_mode = 'https://minotar.net/avatar/{name}/25';
  2509.  
  2510. // If enabled, names will be shown below avatars instead of being shown next to them.
  2511. $this->avatar_names_below = true;
  2512.  
  2513. // If enabled, offline-mode UUIDs will be requested from avatar_source instead of player names.
  2514. $this->avatar_allow_offline_mode_uuids = false;
  2515.  
  2516. // If enabled, the total amount of bans, mutes, warnings, and kicks will be shown next to the buttons in the header.
  2517. $this->header_show_totals = true;
  2518.  
  2519. // The date format can be changed here.
  2520. // https://secure.php.net/manual/en/function.strftime.php
  2521. // Example output of default format: July 2, 2015, 09:19; August 4, 2016, 18:37
  2522. $this->date_format = '%B %d, %Y, %H:%M';
  2523.  
  2524. // https://secure.php.net/manual/en/timezones.php
  2525. $timezone = "UTC";
  2526.  
  2527. // Enable PHP error reporting.
  2528. $this->error_reporting = true;
  2529.  
  2530. // Enable error pages.
  2531. $this->error_pages = true;
  2532.  
  2533. $this->date_month_translations = null;
  2534.  
  2535. // If your system locale doesn't automatically translate month names, you can set them manually here.
  2536. // Change "if (false)" to "if (true)" for this to take effect.
  2537. // X=>Y, X is replaced with Y. E.g. "January"=>"Januari"
  2538. if (false) {
  2539. $this->date_month_translations = array(
  2540. "January" => "Month 1",
  2541. "February" => "Month 2",
  2542. "March" => "Month 3",
  2543. "April" => "Month 4",
  2544. "May" => "Month 5",
  2545. "June" => "Month 6",
  2546. "July" => "Month 7",
  2547. "August" => "Month 8",
  2548. "September" => "Month 9",
  2549. "October" => "Month 10",
  2550. "November" => "Month 11",
  2551. "December" => "Month 12",
  2552. );
  2553. }
  2554.  
  2555.  
  2556. /*** End of configuration ***/
  2557.  
  2558.  
  2559. /** Don't modify anything here unless you know what you're doing **/
  2560.  
  2561. if ($this->error_reporting) {
  2562. error_reporting(E_ALL);
  2563. ini_set("display_errors", 1);
  2564. }
  2565.  
  2566. $this->active_query = "";
  2567.  
  2568. if ($driver === "pgsql") {
  2569. Settings::$TRUE = "B'1'";
  2570. Settings::$FALSE = "B'0'";
  2571. }
  2572.  
  2573. if (!$this->show_inactive_bans) {
  2574. $this->active_query = self::append_query($this->active_query, "active=" . Settings::$TRUE);
  2575. }
  2576.  
  2577. if (!$this->show_silent_bans) {
  2578. $this->active_query = self::append_query($this->active_query, "silent=" . Settings::$FALSE);
  2579. }
  2580.  
  2581. $this->test_strftime();
  2582.  
  2583. date_default_timezone_set($timezone); // set configured timezone
  2584.  
  2585. $table_prefix = $this->table_prefix;
  2586.  
  2587. // Internal table names, do not translate.
  2588. $this->table = array(
  2589. 'bans' => "${table_prefix}bans",
  2590. 'mutes' => "${table_prefix}mutes",
  2591. 'warnings' => "${table_prefix}warnings",
  2592. 'kicks' => "${table_prefix}kicks",
  2593. 'history' => "${table_prefix}history",
  2594. 'servers' => "${table_prefix}servers",
  2595. 'config' => "${table_prefix}config",
  2596. );
  2597.  
  2598. $this->driver = $driver;
  2599. if ($connect) {
  2600. if ($username === "" && $password === "") {
  2601. redirect("error/unconfigured.php");
  2602. }
  2603. $host = $this->host;
  2604. $port = $this->port;
  2605.  
  2606. $dsn = "$driver:dbname=$database;host=$host;port=$port";
  2607. if ($driver === 'mysql') {
  2608. $dsn .= ';charset=utf8';
  2609. }
  2610.  
  2611. $options = array(
  2612. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  2613. PDO::ATTR_EMULATE_PREPARES => false,
  2614. PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
  2615. );
  2616.  
  2617. try {
  2618. $this->conn = new PDO($dsn, $username, $password, $options);
  2619.  
  2620. $st = $this->conn->query("SELECT * FROM " . $this->table['config'] . " LIMIT 1;");
  2621. $st->fetch();
  2622. $st->closeCursor();
  2623. } catch (PDOException $e) {
  2624. Settings::handle_error($this, $e);
  2625. }
  2626. if ($driver === 'pgsql') {
  2627. $this->conn->query("SET NAMES 'UTF8';");
  2628. }
  2629. }
  2630. }
  2631.  
  2632. static function append_query($existing, $new) {
  2633. if ($existing !== "") {
  2634. return "$existing AND $new";
  2635. }
  2636. return "WHERE $new";
  2637. }
  2638.  
  2639. /**
  2640. * @param $settings Settings
  2641. * @param $e Exception
  2642. */
  2643. static function handle_error($settings, $e) {
  2644. $message = $e->getMessage();
  2645. if ($settings->error_pages) {
  2646. if (strstr($message, "Access denied for user")) {
  2647. if ($settings->error_reporting) {
  2648. redirect("error/access-denied.php?error=" . base64_encode($message));
  2649. } else {
  2650. redirect("error/access-denied.php");
  2651. }
  2652. }
  2653. if (strstr($message, "Base table or view not found:")) {
  2654. try {
  2655. $st = $settings->conn->query("SELECT * FROM " . $settings->table['bans'] . " LIMIT 1;");
  2656. $st->fetch();
  2657. $st->closeCursor();
  2658. } catch (PDOException $e) {
  2659. redirect("error/tables-not-found.php");
  2660. }
  2661. redirect("error/outdated-plugin.php");
  2662. }
  2663. if (strstr($message, "Unknown column")) {
  2664. redirect("error/outdated-plugin.php");
  2665. }
  2666. }
  2667. if ($settings->error_reporting === false) {
  2668. die("Database error");
  2669. }
  2670. die("Database error: $message");
  2671. }
  2672.  
  2673.  
  2674.  
  2675. private function test_strftime() {
  2676. // If you modify this function, you may get an "Assertion failed" error.
  2677. date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
  2678.  
  2679. $fail = false;
  2680. $test = gmstrftime($this->date_format, 0);
  2681. if ($test == false) {
  2682. ob_start();
  2683. var_dump($test);
  2684. $testdump = ob_get_clean();
  2685. echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
  2686. $fail = true;
  2687. }
  2688.  
  2689. $test = gmstrftime("%Y-%m-%d %H:%M", 0);
  2690. if ($test !== "1970-01-01 00:00") {
  2691. ob_start();
  2692. var_dump($test);
  2693. $testdump = ob_get_clean();
  2694. echo("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>");
  2695. echo("Actual result: $testdump");
  2696. $fail = true;
  2697. }
  2698.  
  2699. if ($fail === true) {
  2700. die;
  2701. }
  2702. }
  2703. }
  2704. <?php
  2705.  
  2706. final class Settings {
  2707. public static $TRUE = "1", $FALSE = "0";
  2708.  
  2709. public function __construct($connect = true) {
  2710. // Web interface language. Languages are stored in the "lang/" directory.
  2711. $this->lang = 'en_US.utf8';
  2712.  
  2713. // Database information
  2714. $this->host = 'sql9.freemysqlhosting.net';
  2715. $this->port = 3306;
  2716.  
  2717. $database = 'sql9264839';
  2718.  
  2719. $username = 'sql9264839';
  2720. $password = 'WCT1If52yi';
  2721.  
  2722. // If you set a table prefix in config.yml, set it here as well
  2723. $this->table_prefix = "litebans_";
  2724.  
  2725. // Supported drivers: mysql, pgsql
  2726. $driver = 'mysql';
  2727.  
  2728. // Server name, shown on the main page and on the header
  2729. $this->name = 'LiteBans';
  2730.  
  2731. // Clicking on the header name will send you to this address.
  2732. // $this->name_link = 'https://example.com';
  2733. $this->name_link = 'index.php';
  2734.  
  2735. // Here you can customize colors for the Bootstrap 4 theme that you are using.
  2736. // Bootstrap 4 themes have four sets of colors: primary, secondary, light and dark.
  2737. // Navbar classes: navbar-light, navbar-dark, bg-primary, bg-secondary, bg-light, bg-dark
  2738. // Badge (label) classes: badge, badge-pill, badge-primary, badge-secondary, badge-light, badge-dark
  2739. $this->navbar_classes = 'navbar-dark bg-primary';
  2740. $this->badge_classes = 'badge-pill badge-secondary';
  2741. $this->info_badge_classes = 'badge';
  2742.  
  2743. // Show server scope column?
  2744. $this->show_server_scope = true;
  2745.  
  2746. // Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Expired).
  2747. $this->show_inactive_bans = true;
  2748.  
  2749. // Show silent bans?
  2750. $this->show_silent_bans = true;
  2751.  
  2752. // Show pager? This allows users to page through the list of bans.
  2753. $this->show_pager = true;
  2754.  
  2755. // Amount of bans/mutes/warnings to show on each page
  2756. $this->limit_per_page = 10;
  2757.  
  2758. // The server console will be identified by any of these names.
  2759. // It will be given a standard name and avatar image.
  2760. $this->console_aliases = array(
  2761. "CONSOLE", "Console",
  2762. );
  2763. $this->console_name = "Console";
  2764. $this->console_image = "inc/img/console.png";
  2765.  
  2766. // Avatar images for all players will be fetched from this URL.
  2767. // Examples:
  2768. // 'https://cravatar.eu/avatar/{uuid}/25'
  2769. // 'https://crafatar.com/avatars/{uuid}?size=25'
  2770. // 'https://minotar.net/avatar/{uuid}/25'
  2771. $this->avatar_source = 'https://crafatar.com/avatars/{uuid}?size=25';
  2772.  
  2773. // `avatar_source_offline_mode` controls where avatars for offline-mode players are fetched from.
  2774. // Offline-mode UUIDs are substituted for player names unless the `avatar_allow_offline_mode_uuids` option is enabled.
  2775. // (This is done because avatar sources generally serve the default "Steve" avatar for *all* offline-mode UUIDs, including those of premium players)
  2776. // Crafatar no longer supports names, so it cannot be used as an offline-mode player-name avatar source as of 2018-02-16 (https://crafatar.com/#meta-usernames)
  2777. // Since "skins.minecraft.net" is no longer available, this could pose a problem for other avatar sources as well.
  2778. $this->avatar_source_offline_mode = 'https://minotar.net/avatar/{name}/25';
  2779.  
  2780. // If enabled, names will be shown below avatars instead of being shown next to them.
  2781. $this->avatar_names_below = true;
  2782.  
  2783. // If enabled, offline-mode UUIDs will be requested from avatar_source instead of player names.
  2784. $this->avatar_allow_offline_mode_uuids = false;
  2785.  
  2786. // If enabled, the total amount of bans, mutes, warnings, and kicks will be shown next to the buttons in the header.
  2787. $this->header_show_totals = true;
  2788.  
  2789. // The date format can be changed here.
  2790. // https://secure.php.net/manual/en/function.strftime.php
  2791. // Example output of default format: July 2, 2015, 09:19; August 4, 2016, 18:37
  2792. $this->date_format = '%B %d, %Y, %H:%M';
  2793.  
  2794. // https://secure.php.net/manual/en/timezones.php
  2795. $timezone = "UTC";
  2796.  
  2797. // Enable PHP error reporting.
  2798. $this->error_reporting = true;
  2799.  
  2800. // Enable error pages.
  2801. $this->error_pages = true;
  2802.  
  2803. $this->date_month_translations = null;
  2804.  
  2805. // If your system locale doesn't automatically translate month names, you can set them manually here.
  2806. // Change "if (false)" to "if (true)" for this to take effect.
  2807. // X=>Y, X is replaced with Y. E.g. "January"=>"Januari"
  2808. if (false) {
  2809. $this->date_month_translations = array(
  2810. "January" => "Month 1",
  2811. "February" => "Month 2",
  2812. "March" => "Month 3",
  2813. "April" => "Month 4",
  2814. "May" => "Month 5",
  2815. "June" => "Month 6",
  2816. "July" => "Month 7",
  2817. "August" => "Month 8",
  2818. "September" => "Month 9",
  2819. "October" => "Month 10",
  2820. "November" => "Month 11",
  2821. "December" => "Month 12",
  2822. );
  2823. }
  2824.  
  2825.  
  2826. /*** End of configuration ***/
  2827.  
  2828.  
  2829. /** Don't modify anything here unless you know what you're doing **/
  2830.  
  2831. if ($this->error_reporting) {
  2832. error_reporting(E_ALL);
  2833. ini_set("display_errors", 1);
  2834. }
  2835.  
  2836. $this->active_query = "";
  2837.  
  2838. if ($driver === "pgsql") {
  2839. Settings::$TRUE = "B'1'";
  2840. Settings::$FALSE = "B'0'";
  2841. }
  2842.  
  2843. if (!$this->show_inactive_bans) {
  2844. $this->active_query = self::append_query($this->active_query, "active=" . Settings::$TRUE);
  2845. }
  2846.  
  2847. if (!$this->show_silent_bans) {
  2848. $this->active_query = self::append_query($this->active_query, "silent=" . Settings::$FALSE);
  2849. }
  2850.  
  2851. $this->test_strftime();
  2852.  
  2853. date_default_timezone_set($timezone); // set configured timezone
  2854.  
  2855. $table_prefix = $this->table_prefix;
  2856.  
  2857. // Internal table names, do not translate.
  2858. $this->table = array(
  2859. 'bans' => "${table_prefix}bans",
  2860. 'mutes' => "${table_prefix}mutes",
  2861. 'warnings' => "${table_prefix}warnings",
  2862. 'kicks' => "${table_prefix}kicks",
  2863. 'history' => "${table_prefix}history",
  2864. 'servers' => "${table_prefix}servers",
  2865. 'config' => "${table_prefix}config",
  2866. );
  2867.  
  2868. $this->driver = $driver;
  2869. if ($connect) {
  2870. if ($username === "" && $password === "") {
  2871. redirect("error/unconfigured.php");
  2872. }
  2873. $host = $this->host;
  2874. $port = $this->port;
  2875.  
  2876. $dsn = "$driver:dbname=$database;host=$host;port=$port";
  2877. if ($driver === 'mysql') {
  2878. $dsn .= ';charset=utf8';
  2879. }
  2880.  
  2881. $options = array(
  2882. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  2883. PDO::ATTR_EMULATE_PREPARES => false,
  2884. PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
  2885. );
  2886.  
  2887. try {
  2888. $this->conn = new PDO($dsn, $username, $password, $options);
  2889.  
  2890. $st = $this->conn->query("SELECT * FROM " . $this->table['config'] . " LIMIT 1;");
  2891. $st->fetch();
  2892. $st->closeCursor();
  2893. } catch (PDOException $e) {
  2894. Settings::handle_error($this, $e);
  2895. }
  2896. if ($driver === 'pgsql') {
  2897. $this->conn->query("SET NAMES 'UTF8';");
  2898. }
  2899. }
  2900. }
  2901.  
  2902. static function append_query($existing, $new) {
  2903. if ($existing !== "") {
  2904. return "$existing AND $new";
  2905. }
  2906. return "WHERE $new";
  2907. }
  2908.  
  2909. /**
  2910. * @param $settings Settings
  2911. * @param $e Exception
  2912. */
  2913. static function handle_error($settings, $e) {
  2914. $message = $e->getMessage();
  2915. if ($settings->error_pages) {
  2916. if (strstr($message, "Access denied for user")) {
  2917. if ($settings->error_reporting) {
  2918. redirect("error/access-denied.php?error=" . base64_encode($message));
  2919. } else {
  2920. redirect("error/access-denied.php");
  2921. }
  2922. }
  2923. if (strstr($message, "Base table or view not found:")) {
  2924. try {
  2925. $st = $settings->conn->query("SELECT * FROM " . $settings->table['bans'] . " LIMIT 1;");
  2926. $st->fetch();
  2927. $st->closeCursor();
  2928. } catch (PDOException $e) {
  2929. redirect("error/tables-not-found.php");
  2930. }
  2931. redirect("error/outdated-plugin.php");
  2932. }
  2933. if (strstr($message, "Unknown column")) {
  2934. redirect("error/outdated-plugin.php");
  2935. }
  2936. }
  2937. if ($settings->error_reporting === false) {
  2938. die("Database error");
  2939. }
  2940. die("Database error: $message");
  2941. }
  2942.  
  2943.  
  2944.  
  2945. private function test_strftime() {
  2946. // If you modify this function, you may get an "Assertion failed" error.
  2947. date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
  2948.  
  2949. $fail = false;
  2950. $test = gmstrftime($this->date_format, 0);
  2951. if ($test == false) {
  2952. ob_start();
  2953. var_dump($test);
  2954. $testdump = ob_get_clean();
  2955. echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
  2956. $fail = true;
  2957. }
  2958.  
  2959. $test = gmstrftime("%Y-%m-%d %H:%M", 0);
  2960. if ($test !== "1970-01-01 00:00") {
  2961. ob_start();
  2962. var_dump($test);
  2963. $testdump = ob_get_clean();
  2964. echo("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>");
  2965. echo("Actual result: $testdump");
  2966. $fail = true;
  2967. }
  2968.  
  2969. if ($fail === true) {
  2970. die;
  2971. }
  2972. }
  2973. }
  2974. <?php
  2975.  
  2976. final class Settings {
  2977. public static $TRUE = "1", $FALSE = "0";
  2978.  
  2979. public function __construct($connect = true) {
  2980. // Web interface language. Languages are stored in the "lang/" directory.
  2981. $this->lang = 'en_US.utf8';
  2982.  
  2983. // Database information
  2984. $this->host = 'sql9.freemysqlhosting.net';
  2985. $this->port = 3306;
  2986.  
  2987. $database = 'sql9264839';
  2988.  
  2989. $username = 'sql9264839';
  2990. $password = 'WCT1If52yi';
  2991.  
  2992. // If you set a table prefix in config.yml, set it here as well
  2993. $this->table_prefix = "litebans_";
  2994.  
  2995. // Supported drivers: mysql, pgsql
  2996. $driver = 'mysql';
  2997.  
  2998. // Server name, shown on the main page and on the header
  2999. $this->name = 'LiteBans';
  3000.  
  3001. // Clicking on the header name will send you to this address.
  3002. // $this->name_link = 'https://example.com';
  3003. $this->name_link = 'index.php';
  3004.  
  3005. // Here you can customize colors for the Bootstrap 4 theme that you are using.
  3006. // Bootstrap 4 themes have four sets of colors: primary, secondary, light and dark.
  3007. // Navbar classes: navbar-light, navbar-dark, bg-primary, bg-secondary, bg-light, bg-dark
  3008. // Badge (label) classes: badge, badge-pill, badge-primary, badge-secondary, badge-light, badge-dark
  3009. $this->navbar_classes = 'navbar-dark bg-primary';
  3010. $this->badge_classes = 'badge-pill badge-secondary';
  3011. $this->info_badge_classes = 'badge';
  3012.  
  3013. // Show server scope column?
  3014. $this->show_server_scope = true;
  3015.  
  3016. // Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Expired).
  3017. $this->show_inactive_bans = true;
  3018.  
  3019. // Show silent bans?
  3020. $this->show_silent_bans = true;
  3021.  
  3022. // Show pager? This allows users to page through the list of bans.
  3023. $this->show_pager = true;
  3024.  
  3025. // Amount of bans/mutes/warnings to show on each page
  3026. $this->limit_per_page = 10;
  3027.  
  3028. // The server console will be identified by any of these names.
  3029. // It will be given a standard name and avatar image.
  3030. $this->console_aliases = array(
  3031. "CONSOLE", "Console",
  3032. );
  3033. $this->console_name = "Console";
  3034. $this->console_image = "inc/img/console.png";
  3035.  
  3036. // Avatar images for all players will be fetched from this URL.
  3037. // Examples:
  3038. // 'https://cravatar.eu/avatar/{uuid}/25'
  3039. // 'https://crafatar.com/avatars/{uuid}?size=25'
  3040. // 'https://minotar.net/avatar/{uuid}/25'
  3041. $this->avatar_source = 'https://crafatar.com/avatars/{uuid}?size=25';
  3042.  
  3043. // `avatar_source_offline_mode` controls where avatars for offline-mode players are fetched from.
  3044. // Offline-mode UUIDs are substituted for player names unless the `avatar_allow_offline_mode_uuids` option is enabled.
  3045. // (This is done because avatar sources generally serve the default "Steve" avatar for *all* offline-mode UUIDs, including those of premium players)
  3046. // Crafatar no longer supports names, so it cannot be used as an offline-mode player-name avatar source as of 2018-02-16 (https://crafatar.com/#meta-usernames)
  3047. // Since "skins.minecraft.net" is no longer available, this could pose a problem for other avatar sources as well.
  3048. $this->avatar_source_offline_mode = 'https://minotar.net/avatar/{name}/25';
  3049.  
  3050. // If enabled, names will be shown below avatars instead of being shown next to them.
  3051. $this->avatar_names_below = true;
  3052.  
  3053. // If enabled, offline-mode UUIDs will be requested from avatar_source instead of player names.
  3054. $this->avatar_allow_offline_mode_uuids = false;
  3055.  
  3056. // If enabled, the total amount of bans, mutes, warnings, and kicks will be shown next to the buttons in the header.
  3057. $this->header_show_totals = true;
  3058.  
  3059. // The date format can be changed here.
  3060. // https://secure.php.net/manual/en/function.strftime.php
  3061. // Example output of default format: July 2, 2015, 09:19; August 4, 2016, 18:37
  3062. $this->date_format = '%B %d, %Y, %H:%M';
  3063.  
  3064. // https://secure.php.net/manual/en/timezones.php
  3065. $timezone = "UTC";
  3066.  
  3067. // Enable PHP error reporting.
  3068. $this->error_reporting = true;
  3069.  
  3070. // Enable error pages.
  3071. $this->error_pages = true;
  3072.  
  3073. $this->date_month_translations = null;
  3074.  
  3075. // If your system locale doesn't automatically translate month names, you can set them manually here.
  3076. // Change "if (false)" to "if (true)" for this to take effect.
  3077. // X=>Y, X is replaced with Y. E.g. "January"=>"Januari"
  3078. if (false) {
  3079. $this->date_month_translations = array(
  3080. "January" => "Month 1",
  3081. "February" => "Month 2",
  3082. "March" => "Month 3",
  3083. "April" => "Month 4",
  3084. "May" => "Month 5",
  3085. "June" => "Month 6",
  3086. "July" => "Month 7",
  3087. "August" => "Month 8",
  3088. "September" => "Month 9",
  3089. "October" => "Month 10",
  3090. "November" => "Month 11",
  3091. "December" => "Month 12",
  3092. );
  3093. }
  3094.  
  3095.  
  3096. /*** End of configuration ***/
  3097.  
  3098.  
  3099. /** Don't modify anything here unless you know what you're doing **/
  3100.  
  3101. if ($this->error_reporting) {
  3102. error_reporting(E_ALL);
  3103. ini_set("display_errors", 1);
  3104. }
  3105.  
  3106. $this->active_query = "";
  3107.  
  3108. if ($driver === "pgsql") {
  3109. Settings::$TRUE = "B'1'";
  3110. Settings::$FALSE = "B'0'";
  3111. }
  3112.  
  3113. if (!$this->show_inactive_bans) {
  3114. $this->active_query = self::append_query($this->active_query, "active=" . Settings::$TRUE);
  3115. }
  3116.  
  3117. if (!$this->show_silent_bans) {
  3118. $this->active_query = self::append_query($this->active_query, "silent=" . Settings::$FALSE);
  3119. }
  3120.  
  3121. $this->test_strftime();
  3122.  
  3123. date_default_timezone_set($timezone); // set configured timezone
  3124.  
  3125. $table_prefix = $this->table_prefix;
  3126.  
  3127. // Internal table names, do not translate.
  3128. $this->table = array(
  3129. 'bans' => "${table_prefix}bans",
  3130. 'mutes' => "${table_prefix}mutes",
  3131. 'warnings' => "${table_prefix}warnings",
  3132. 'kicks' => "${table_prefix}kicks",
  3133. 'history' => "${table_prefix}history",
  3134. 'servers' => "${table_prefix}servers",
  3135. 'config' => "${table_prefix}config",
  3136. );
  3137.  
  3138. $this->driver = $driver;
  3139. if ($connect) {
  3140. if ($username === "" && $password === "") {
  3141. redirect("error/unconfigured.php");
  3142. }
  3143. $host = $this->host;
  3144. $port = $this->port;
  3145.  
  3146. $dsn = "$driver:dbname=$database;host=$host;port=$port";
  3147. if ($driver === 'mysql') {
  3148. $dsn .= ';charset=utf8';
  3149. }
  3150.  
  3151. $options = array(
  3152. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  3153. PDO::ATTR_EMULATE_PREPARES => false,
  3154. PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
  3155. );
  3156.  
  3157. try {
  3158. $this->conn = new PDO($dsn, $username, $password, $options);
  3159.  
  3160. $st = $this->conn->query("SELECT * FROM " . $this->table['config'] . " LIMIT 1;");
  3161. $st->fetch();
  3162. $st->closeCursor();
  3163. } catch (PDOException $e) {
  3164. Settings::handle_error($this, $e);
  3165. }
  3166. if ($driver === 'pgsql') {
  3167. $this->conn->query("SET NAMES 'UTF8';");
  3168. }
  3169. }
  3170. }
  3171.  
  3172. static function append_query($existing, $new) {
  3173. if ($existing !== "") {
  3174. return "$existing AND $new";
  3175. }
  3176. return "WHERE $new";
  3177. }
  3178.  
  3179. /**
  3180. * @param $settings Settings
  3181. * @param $e Exception
  3182. */
  3183. static function handle_error($settings, $e) {
  3184. $message = $e->getMessage();
  3185. if ($settings->error_pages) {
  3186. if (strstr($message, "Access denied for user")) {
  3187. if ($settings->error_reporting) {
  3188. redirect("error/access-denied.php?error=" . base64_encode($message));
  3189. } else {
  3190. redirect("error/access-denied.php");
  3191. }
  3192. }
  3193. if (strstr($message, "Base table or view not found:")) {
  3194. try {
  3195. $st = $settings->conn->query("SELECT * FROM " . $settings->table['bans'] . " LIMIT 1;");
  3196. $st->fetch();
  3197. $st->closeCursor();
  3198. } catch (PDOException $e) {
  3199. redirect("error/tables-not-found.php");
  3200. }
  3201. redirect("error/outdated-plugin.php");
  3202. }
  3203. if (strstr($message, "Unknown column")) {
  3204. redirect("error/outdated-plugin.php");
  3205. }
  3206. }
  3207. if ($settings->error_reporting === false) {
  3208. die("Database error");
  3209. }
  3210. die("Database error: $message");
  3211. }
  3212.  
  3213.  
  3214.  
  3215. private function test_strftime() {
  3216. // If you modify this function, you may get an "Assertion failed" error.
  3217. date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
  3218.  
  3219. $fail = false;
  3220. $test = gmstrftime($this->date_format, 0);
  3221. if ($test == false) {
  3222. ob_start();
  3223. var_dump($test);
  3224. $testdump = ob_get_clean();
  3225. echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
  3226. $fail = true;
  3227. }
  3228.  
  3229. $test = gmstrftime("%Y-%m-%d %H:%M", 0);
  3230. if ($test !== "1970-01-01 00:00") {
  3231. ob_start();
  3232. var_dump($test);
  3233. $testdump = ob_get_clean();
  3234. echo("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>");
  3235. echo("Actual result: $testdump");
  3236. $fail = true;
  3237. }
  3238.  
  3239. if ($fail === true) {
  3240. die;
  3241. }
  3242. }
  3243. }
  3244.  
  3245. =x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=
  3246. config.yml
  3247. =x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=x=
  3248. # LiteBans config.yml generated by version 2.2.5
  3249.  
  3250. # If bungeecord is set to true, banned players will be kicked from BungeeCord itself.
  3251. # (Players will not be kicked to the lobby when they are banned.)
  3252. # This option has no effect if the plugin is running directly under BungeeCord.
  3253. bungeecord: false
  3254.  
  3255. # If this option is enabled and the server is connected to a remote database (e.g. MySQL),
  3256. # LiteBans will synchronize across all servers connected to that database with sync enabled.
  3257. sync: true
  3258.  
  3259. # If enabled, broadcasts will be synchronized.
  3260. sync_broadcasts: true
  3261.  
  3262. # If enabled, notifications will be synchronized.
  3263. sync_notifications: true
  3264.  
  3265. # If enabled, dupeip notifications will be synchronized.
  3266. # This will appear multiple times if a player joins multiple servers, so you might want to leave this disabled.
  3267. sync_dupeip_notifications: false
  3268.  
  3269. # The server name is an identifier used in cross-server synchronization.
  3270. # It represents a single plugin instance (or group of instances) and can be updated at any time.
  3271. # If you need per-server bans, you have to change server_name on all instances
  3272. # The "$serverScope" and "$serverOrigin" variables can be used in messages.
  3273. # Maximum length is 32 characters.
  3274. server_name: 'litebans'
  3275.  
  3276. # This option decides which server(s) will be affected in commands by default.
  3277. default_server_scope: '*'
  3278.  
  3279. sql:
  3280. # H2, MySQL, MariaDB, and PostgreSQL are supported database drivers.
  3281. driver: H2
  3282.  
  3283. ## MySQL/PostgreSQL settings ##
  3284. # If using H2, the database will be stored in the LiteBans plugin folder,
  3285. # and most of these settings won't apply.
  3286.  
  3287. # Database server address.
  3288. address: 'sql9.freemysqlhosting.net'
  3289.  
  3290. # Database name, username and password.
  3291. database: 'sql9264839'
  3292. username: 'sql9264839'
  3293. password: 'WCT1If52yi'
  3294.  
  3295. table_prefix: 'litebans_'
  3296.  
  3297. # LiteBans utilizes connection pooling for extra performance and reliability.
  3298. # min_connections: Minimum amount of pooled connections.
  3299. # max_connections: Maximum amount of pooled connections. See: https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing
  3300. # timeout: Connection timeout.
  3301. # idle_timeout: Maximum amount of time a pooled connection can remain idle before it is closed for inactivity.
  3302. pool:
  3303. min_connections: 1
  3304. max_connections: 10
  3305. timeout: 30 seconds
  3306. idle_timeout: 1 minute
  3307.  
  3308. # Database engine. Only applies to MySQL.
  3309. engine: InnoDB
  3310.  
  3311. options: 'useSSL=false'
  3312.  
  3313. # Format: <name>:<class>[:URL:version]
  3314. # SQLite is only included here for backwards compatibility, it is no longer supported (use H2 instead).
  3315. drivers:
  3316. - version:1
  3317.  
  3318. - 'h2:org.h2.Driver:https://repo1.maven.org/maven2/com/h2database/h2/{}/h2-{}.jar:1.4.196'
  3319.  
  3320. durations:
  3321. # Can be bypassed with the permission "litebans.unlimited.ban"
  3322. tempban_max: 14 days
  3323. # Can be bypassed with the permission "litebans.unlimited.mute"
  3324. mute_max: 14 day
  3325. # If true, players will not get an error when using a duration higher than the configured limit.
  3326. # The duration will be rounded down to the maximum duration instead.
  3327. round_down: true
  3328.  
  3329. mutes:
  3330. enabled: true
  3331.  
  3332. # All of these commands can not be used while muted.
  3333. command_blacklist:
  3334. - /me
  3335. - /say
  3336. - /tell
  3337. - /whisper
  3338. - /reply
  3339. - /pm
  3340. - /message
  3341. - /msg
  3342. - /emsg
  3343. - /epm
  3344. - /etell
  3345. - /ewhisper
  3346. - /w
  3347. - /m
  3348. - /t
  3349. - /r
  3350. mutechat_command_blacklist:
  3351. - /me
  3352. - /say
  3353. # If enabled, muted players cannot use commands containing ":", for example: "/minecraft:me".
  3354. prevent_bypass: true
  3355.  
  3356. # If set, a ban or mute reason must be provided, otherwise players will get an error.
  3357. # When set to false, "default_ban_reason" and "default_mute_reason" in messages.yml are used as reasons when no reason is provided.
  3358. require_ban_mute_reason: false
  3359.  
  3360. warnings:
  3361. # Warnings will expire after this duration has passed.
  3362. expire_after: 7 days
  3363.  
  3364. # Warning actions.
  3365. # Format: <amount>[+]:<action>
  3366. # If '+' is provided after the amount, the action will execute if the player has that amount of warnings or more.
  3367. actions:
  3368. - '3:/kick -s:$silent $player Final warning: $reason'
  3369. - '4:/tempban -s:$silent $player 1 day Reached 4 warnings: $list'
  3370.  
  3371. # If enabled, the console will execute warning actions.
  3372. # Otherwise, the player who executes the last warning also executes the warning action.
  3373. actions_execute_as_console: false
  3374.  
  3375. # If enabled, all active warnings will be deactivated after a warning action is executed.
  3376. delete_warnings_after_action: false
  3377.  
  3378. notify:
  3379. # If enabled, players with the permission 'litebans.notify' or 'litebans.notify.banned_join' will be notified when a banned player tries to join.
  3380. banned_player_join: true
  3381.  
  3382. # If enabled, /dupeip output will be shown on join if the player meets certain conditions.
  3383. dupeip_on_join: true
  3384.  
  3385. # Notify if the player has a banned account on the same IP.
  3386. dupeip_on_banned_account: true
  3387.  
  3388. # If enabled, muted accounts will be detected with /dupeip.
  3389. # This is disabled by default since it can add quite a lot of query overhead on larger servers especially if dupeip_on_join is enabled.
  3390. dupeip_show_muted_accounts: false
  3391.  
  3392. # If you set this to a lower value, players with X accounts will send dupeip notifications.
  3393. dupeip_on_join_threshold: 9999999
  3394.  
  3395. # Log all notifications to the console?
  3396. notify_console: true
  3397.  
  3398. exempt:
  3399. enable: true
  3400. # By default, the first loaded world is used for permission checks.
  3401. permission_world: default
  3402.  
  3403. # Permission groups that are exempt from bans, mutes, warnings, and kicks.
  3404. exempt_groups: []
  3405.  
  3406. # Players who are exempt from bans, mutes, warnings, and kicks.
  3407. # Format: <name/UUID>[:type]
  3408. # Type can be ban, mute, warning, or kick.
  3409. # Example:
  3410. # exempt_players: ['Player', 'Player:kick', 'Player2']
  3411. exempt_players: []
  3412.  
  3413. geoip:
  3414. enable: false
  3415. # Anyone from these locations will not be able to join.
  3416. # A full list of countries that can be blacklisted:
  3417. # https://dev.maxmind.com/geoip/legacy/codes/iso3166/
  3418. # Example:
  3419. # blacklist: ['Australia', 'Brazil', 'Canada', 'Denmark']
  3420. blacklist: []
  3421.  
  3422. # If the whitelist is not empty, all countries which are not found in the list will be blocked.
  3423. whitelist: []
  3424. download:
  3425. # Download links for the API and database. They are downloaded to the 'plugins/LiteBans/geoip' folder.
  3426. # You shouldn't need to change these, but if it isn't working, you can search for these files.
  3427. api:
  3428. - https://repo1.maven.org/maven2/com/maxmind/geoip2/geoip2/2.1.0/geoip2-2.1.0.jar
  3429. - https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.4.3/jackson-databind-2.4.3.jar
  3430. - https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.4.3/jackson-core-2.4.3.jar
  3431. - https://repo1.maven.org/maven2/com/maxmind/db/maxmind-db/1.0.0/maxmind-db-1.0.0.jar
  3432. - https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.4.3/jackson-annotations-2.4.3.jar
  3433. # Will be extracted and saved as 'GeoLite2-Country.mmdb'.
  3434. db: https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz
  3435.  
  3436. # After configuring import options, run "/litebans import start" to begin the import.
  3437. # The import process occurs while the server is running, no downtime is required.
  3438. import:
  3439. # You can import from: MaxBans, Ultrabans, BanHammer, BanManagerv4, BanManagerv5, BungeeAdminTools, LiteBans, Vanilla.
  3440. # Vanilla means importing from banned-players.json, which is also used by Essentials.
  3441. from: maxbans
  3442.  
  3443. # If enabled, importing will be done from a SQLite database instead of a MySQL database.
  3444. # You can ignore this if importing from banned-players.json.
  3445. # If importing from LiteBans, H2 will be used instead of SQLite.
  3446. sqlite: true
  3447.  
  3448. # SQLite file locations:
  3449. # MaxBans: plugins/MaxBans/bans.db
  3450. # Ultrabans: plugins/Ultrabans/banlist.db
  3451. # BanHammer: plugins/BanHammer/BanHammer.db
  3452. # LiteBans: plugins/LiteBans/litebans.sqlite (legacy)
  3453. sqlite_file: plugins/MaxBans/bans.db
  3454.  
  3455. import_ipbans: true
  3456. ## MySQL import settings ##
  3457. import_mysql_address: localhost:3306
  3458. import_mysql_database: maxbans
  3459. import_mysql_username: ''
  3460. import_mysql_password: ''
  3461.  
  3462. # Use display names?
  3463. # This means that when moderators and punished players change their name using /nick,
  3464. # this name will be used in broadcasts and other messages instead of their regular name.
  3465. # The BungeeCord version of the plugin cannot detect Spigot-side display names.
  3466. use_display_names: false
  3467.  
  3468. # Instead of "CONSOLE", this name will be used to represent the console.
  3469. console_sender_name: Console
  3470.  
  3471. # Players in this list will not be shown in /dupeip or /alts output.
  3472. # Names, UUIDs and IP addresses can be specified.
  3473. hidden_dupeip_players: []
  3474.  
  3475. # A player cannot be warned again while they are on cooldown.
  3476. # This prevents two moderators from warning the same player for the same reason.
  3477. warning_cooldown: 30
  3478.  
  3479. # If enabled, online player names will be auto-completed.
  3480. # Example: /ban Pl -> /ban Player
  3481. autocomplete_online_player_names: false
  3482.  
  3483. # This allows /dupeip and /ipreport to scan every single IP address that a player has ever joined with.
  3484. # If set to false, it will only scan the last IP address.
  3485. dupeip_scan_all_ips: false
  3486.  
  3487. # /ipreport will not show accounts that have no other players attached by default.
  3488. ipreport_minimum_accounts: 1
  3489.  
  3490. # If disabled, all previous IP addresses will be recorded, allowing /iphistory to work.
  3491. delete_previous_history: true
  3492.  
  3493. # If enabled, all previous login history will be unbanned when unbanning a player.
  3494. unban_all_history: false
  3495.  
  3496. # This is the amount of bans shown on each page for /banlist.
  3497. # Note that ban entries can span 2-3 lines.
  3498. banlist_bans_per_page: 5
  3499.  
  3500. # Only show active bans for /banlist?
  3501. banlist_show_active_only: false
  3502.  
  3503. # If enabled, AuthMe will be detected and IP history will only be added after a player has successfully logged in.
  3504. # This option will only work under Spigot, since AuthMe is a Spigot plugin.
  3505. support_authme: true
  3506.  
  3507. lockdown:
  3508. # If enabled, /lockdown will continue after restarts.
  3509. persist_enabled: true
  3510.  
  3511. debug_level: 0
  3512.  
  3513. # If enabled, this performs an additional two database queries on each join
  3514. # in order to provide case-insensitive name bans.
  3515. ban_names: false
  3516.  
  3517. # If a kick message contains any of these, it will not be added to the database.
  3518. # You can set this list to [''] if you don't want any kicks to be added to the database.
  3519. ignored_kick_messages: ['restarting']
  3520.  
  3521. # This option controls how often notifications are sent from a single player.
  3522. # When a player tries to join when banned or talk while muted,
  3523. # you won't see any more messages from them for a short while.
  3524. notification_throttle_ticks: 12000
  3525.  
  3526. # If enabled, LiteBans will use the database server's time rather than the local system time.
  3527. use_database_time: false
  3528.  
  3529. # If enabled, the plugin will notify you when an update is available.
  3530. update_check: true
  3531.  
  3532. # If enabled, players will be checked for bans after they have joined. (Spigot only)
  3533. check_after_join: false
  3534.  
  3535. # If enabled, ProtocolLib will be detected and chat events will be cancelled before they can be processed by any other plugins.
  3536. # This can help prevent plugin conflicts which allow muted players to chat.
  3537. # This option will only work under Spigot, since ProtocolLib is a Spigot plugin.
  3538. use_protocollib: true
  3539.  
  3540. # This option controls the behaviour of the "-N" flag. This flag prevents active bans/mutes from being overridden.
  3541. # If enabled, the "-N" flag will only prevent bans from being overridden if the active ban has a lower duration.
  3542. override_lower_duration: true
  3543.  
  3544. # This option allows you to disable recording IP history on specific servers under BungeeCord.
  3545. # Example: ignored_history_servers: ['Lobby']
  3546. ignored_history_servers: []
  3547.  
  3548. # If enabled, the local system timezone will be used.
  3549. # UTC time will be stored in the database, but dates will be formatted using the timezone offset.
  3550. use_timezone: true
  3551.  
  3552. # This option controls how often the database is polled for sync data (cross-server punishments, kicks, notifications).
  3553. sync_poll_ticks: 20
  3554.  
  3555. # If this is set above 0, the plugin will skip polling up to N times while no players are online.
  3556. sync_poll_skip: 5
Add Comment
Please, Sign In to add comment