Advertisement
Guest User

Untitled

a guest
Nov 24th, 2018
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.63 KB | None | 0 0
  1. <?php
  2.  
  3. //Version LiteBans WebInterface Fixed By Ilario42
  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 = '88.99.91.195';
  14. $this->port = 3306;
  15.  
  16. $database = 's103_litebans';
  17.  
  18. $username = 'u103_EMuSmAihRh';
  19. $password = '1EhDJ7ViyWlXKfTu';
  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 = 'KarmaPVP';
  29.  
  30. // Clicking on the header name will send you to this address.
  31. $this->name_link = '#';
  32.  
  33. // Show server scope column?
  34. $this->show_server_scope = true;
  35.  
  36. // Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Expired).
  37. $this->show_inactive_bans = true;
  38.  
  39. // Show silent bans?
  40. $this->show_silent_bans = true;
  41.  
  42. // Show pager? This allows users to page through the list of bans.
  43. $this->show_pager = true;
  44.  
  45. // Amount of bans/mutes/warnings to show on each page
  46. $this->limit_per_page = 10;
  47.  
  48. // The server console will be identified by any of these names.
  49. // It will be given a standard name and avatar image.
  50. $this->console_aliases = array(
  51. "CONSOLE", "Console",
  52. );
  53. $this->console_name = "Console";
  54. $this->console_image = "inc/img/console.png";
  55.  
  56. // Avatar images for all players will be fetched from this URL.
  57. // Examples:
  58. // 'https://cravatar.eu/avatar/{uuid}/25'
  59. // 'https://crafatar.com/avatars/{uuid}?size=25'
  60. // 'https://minotar.net/avatar/{uuid}/25'
  61. $this->avatar_source = 'https://crafatar.com/avatars/{uuid}?size=25';
  62.  
  63. // `avatar_source_offline_mode` controls where avatars for offline-mode players are fetched from.
  64. // Offline-mode UUIDs are substituted for player names unless the `avatar_allow_offline_mode_uuids` option is enabled.
  65. // (This is done because avatar sources generally serve the default "Steve" avatar for *all* offline-mode UUIDs, including those of premium players)
  66. // 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)
  67. // Since "skins.minecraft.net" is no longer available, this could pose a problem for other avatar sources as well.
  68. $this->avatar_source_offline_mode = 'https://minotar.net/avatar/{name}/25';
  69.  
  70. // If enabled, names will be shown below avatars instead of being shown next to them.
  71. $this->avatar_names_below = true;
  72.  
  73. // If enabled, offline-mode UUIDs will be requested from avatar_source instead of player names.
  74. $this->avatar_allow_offline_mode_uuids = false;
  75.  
  76. // If enabled, the total amount of bans, mutes, warnings, and kicks will be shown next to the buttons in the header.
  77. $this->header_show_totals = true;
  78.  
  79. // The date format can be changed here.
  80. // https://secure.php.net/manual/en/function.strftime.php
  81. // Example output of default format: July 2, 2015, 09:19; August 4, 2016, 18:37
  82. $this->date_format = '%B %d, %Y, %H:%M';
  83.  
  84. // https://secure.php.net/manual/en/timezones.php
  85. $timezone = "UTC";
  86.  
  87. // Enable PHP error reporting.
  88. $this->error_reporting = true;
  89.  
  90. // Enable error pages.
  91. $this->error_pages = true;
  92.  
  93. $this->date_month_translations = null;
  94.  
  95. // If your system locale doesn't automatically translate month names, you can set them manually here.
  96. // Change "if (false)" to "if (true)" for this to take effect.
  97. // X=>Y, X is replaced with Y. E.g. "January"=>"Januari"
  98. if (false) {
  99. $this->date_month_translations = array(
  100. "January" => "Month 1",
  101. "February" => "Month 2",
  102. "March" => "Month 3",
  103. "April" => "Month 4",
  104. "May" => "Month 5",
  105. "June" => "Month 6",
  106. "July" => "Month 7",
  107. "August" => "Month 8",
  108. "September" => "Month 9",
  109. "October" => "Month 10",
  110. "November" => "Month 11",
  111. "December" => "Month 12",
  112. );
  113. }
  114.  
  115.  
  116. /*** End of configuration ***/
  117.  
  118.  
  119. /** Don't modify anything here unless you know what you're doing **/
  120.  
  121. if ($this->error_reporting) {
  122. error_reporting(E_ALL);
  123. ini_set("display_errors", 1);
  124. }
  125.  
  126. $this->active_query = "";
  127.  
  128. if ($driver === "pgsql") {
  129. Settings::$TRUE = "B'1'";
  130. Settings::$FALSE = "B'0'";
  131. }
  132.  
  133. if (!$this->show_inactive_bans) {
  134. $this->active_query = self::append_query($this->active_query, "active=" . Settings::$TRUE);
  135. }
  136.  
  137. if (!$this->show_silent_bans) {
  138. $this->active_query = self::append_query($this->active_query, "silent=" . Settings::$FALSE);
  139. }
  140.  
  141. $this->test_strftime();
  142.  
  143. date_default_timezone_set($timezone); // set configured timezone
  144.  
  145. $table_prefix = $this->table_prefix;
  146.  
  147. // Internal table names, do not translate.
  148. $this->table = array(
  149. 'bans' => "${table_prefix}bans",
  150. 'mutes' => "${table_prefix}mutes",
  151. 'warnings' => "${table_prefix}warnings",
  152. 'kicks' => "${table_prefix}kicks",
  153. 'history' => "${table_prefix}history",
  154. 'servers' => "${table_prefix}servers",
  155. // 'config' => "${table_prefix}config",
  156. );
  157.  
  158. $this->driver = $driver;
  159. if ($connect) {
  160. if ($username === "" && $password === "") {
  161. $this->redirect("error/unconfigured.php");
  162. }
  163. $host = $this->host;
  164. $port = $this->port;
  165.  
  166. $dsn = "$driver:dbname=$database;host=$host;port=$port";
  167. if ($driver === 'mysql') {
  168. $dsn .= ';charset=utf8';
  169. }
  170.  
  171. $options = array(
  172. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  173. PDO::ATTR_EMULATE_PREPARES => false,
  174. PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
  175. );
  176.  
  177. try {
  178. $this->conn = new PDO($dsn, $username, $password, $options);
  179.  
  180. //$st = $this->conn->query("SELECT * FROM " . $this->table['config'] . " LIMIT 1;");
  181. //$st->fetch();
  182. // $st->closeCursor();
  183. } catch (PDOException $e) {
  184. Settings::handle_error($this, $e);
  185. }
  186. if ($driver === 'pgsql') {
  187. $this->conn->query("SET NAMES 'UTF8';");
  188. }
  189. }
  190. }
  191.  
  192. static function append_query($existing, $new) {
  193. if ($existing !== "") {
  194. return "$existing AND $new";
  195. }
  196. return "WHERE $new";
  197. }
  198.  
  199. /**
  200. * @param $settings Settings
  201. * @param $e Exception
  202. */
  203. static function handle_error($settings, $e) {
  204. $message = $e->getMessage();
  205. if ($settings->error_pages) {
  206. if (strstr($message, "Access denied for user")) {
  207. if ($settings->error_reporting) {
  208. $settings->redirect("error/access-denied.php?error=" . base64_encode($message));
  209. } else {
  210. $settings->redirect("error/access-denied.php");
  211. }
  212. }
  213. if (strstr($message, "Base table or view not found:")) {
  214. $settings->redirect("error/tables-not-found.php");
  215. }
  216. if (strstr($message, "Unknown column")) {
  217. $settings->redirect("error/outdated-plugin.php");
  218. }
  219. }
  220. if ($settings->error_reporting === false) {
  221. die("Database error");
  222. }
  223. die('Database error: ' . $message);
  224. }
  225.  
  226.  
  227. function redirect($url, $showtext = true) {
  228. if ($showtext === true) {
  229. echo "<a href=\"$url\">Redirecting...</a>";
  230. }
  231. echo "<script data-cfasync=\"false\" type=\"text/javascript\">document.location=\"$url\";</script>";
  232. die;
  233. }
  234.  
  235. private function test_strftime() {
  236. // If you modify this function, you may get an "Assertion failed" error.
  237. date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
  238.  
  239. $fail = false;
  240. $test = strftime($this->date_format, 0);
  241. if ($test == false) {
  242. ob_start();
  243. var_dump($test);
  244. $testdump = ob_get_clean();
  245. echo("Error: date_format test failed. strftime(\"" . $this->date_format . "\",0) returned " . $testdump);
  246. $fail = true;
  247. }
  248.  
  249. $test = strftime("%Y-%m-%d %H:%M", 0);
  250. if ($test !== "1970-01-01 00:00") {
  251. ob_start();
  252. var_dump($test);
  253. $testdump = ob_get_clean();
  254. echo("Assertion failed: strftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>");
  255. echo("Actual result: " . $testdump);
  256. $fail = true;
  257. }
  258.  
  259. if ($fail === true) {
  260. die;
  261. }
  262. }
  263. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement