PageRenderTime 44ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/web/ingame.php

https://bitbucket.org/psychonic/hlstatsxce
PHP | 153 lines | 97 code | 11 blank | 45 comment | 6 complexity | 1b952160dfeeaef3dc48c2ed4cf14c4e MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /*
  3. HLstatsX Community Edition - Real-time player and clan rankings and statistics
  4. Copyleft (L) 2008-20XX Nicholas Hastings (nshastings@gmail.com)
  5. http://www.hlxcommunity.com
  6. HLstatsX Community Edition is a continuation of
  7. ELstatsNEO - Real-time player and clan rankings and statistics
  8. Copyleft (L) 2008-20XX Malte Bayer (steam@neo-soft.org)
  9. http://ovrsized.neo-soft.org/
  10. ELstatsNEO is an very improved & enhanced - so called Ultra-Humongus Edition of HLstatsX
  11. HLstatsX - Real-time player and clan rankings and statistics for Half-Life 2
  12. http://www.hlstatsx.com/
  13. Copyright (C) 2005-2007 Tobias Oetzel (Tobi@hlstatsx.com)
  14. HLstatsX is an enhanced version of HLstats made by Simon Garner
  15. HLstats - Real-time player and clan rankings and statistics for Half-Life
  16. http://sourceforge.net/projects/hlstats/
  17. Copyright (C) 2001 Simon Garner
  18. This program is free software; you can redistribute it and/or
  19. modify it under the terms of the GNU General Public License
  20. as published by the Free Software Foundation; either version 2
  21. of the License, or (at your option) any later version.
  22. This program is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. GNU General Public License for more details.
  26. You should have received a copy of the GNU General Public License
  27. along with this program; if not, write to the Free Software
  28. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  29. For support and installation notes visit http://www.hlxcommunity.com
  30. */
  31. foreach ($_SERVER as $key => $entry) {
  32. if ($key !== "HTTP_COOKIE") {
  33. $search_pattern = array("/<script>/", "/<\/script>/", "/[^A-Za-z0-9.\-\/=:;_?#&~]/");
  34. $replace_pattern = array("", "", "");
  35. $entry = preg_replace($search_pattern, $replace_pattern, $entry);
  36. if ($key == "PHP_SELF") {
  37. if ((strrchr($entry, "/") !== "/hlstats.php") &&
  38. (strrchr($entry, "/") !== "/ingame.php") &&
  39. (strrchr($entry, "/") !== "/show_graph.php") &&
  40. (strrchr($entry, "/") !== "/sig.php") &&
  41. (strrchr($entry, "/") !== "/sig2.php") &&
  42. (strrchr($entry, "/") !== "/index.php") &&
  43. (strrchr($entry, "/") !== "/status.php") &&
  44. (strrchr($entry, "/") !== "/top10.php") &&
  45. (strrchr($entry, "/") !== "/config.php") &&
  46. (strrchr($entry, "/") !== "/") &&
  47. ($entry !== "")) {
  48. header("Location: http://".$_SERVER['HTTP_HOST']."/hlstats.php");
  49. exit;
  50. }
  51. }
  52. $_SERVER[$key] = $entry;
  53. }
  54. }
  55. // Several Stuff end
  56. @header("Content-Type: text/html; charset=utf-8");
  57. // do not report NOTICE warnings
  58. @error_reporting(E_ALL ^ E_NOTICE);
  59. ////
  60. //// Initialisation
  61. ////
  62. define('IN_HLSTATS', true);
  63. define('PAGE', 'INGAME');
  64. ///
  65. /// Classes
  66. ///
  67. // Load required files
  68. require("config.php");
  69. require(INCLUDE_PATH . "/class_db.php");
  70. require(INCLUDE_PATH . "/class_table.php");
  71. require(INCLUDE_PATH . "/functions.php");
  72. $db_classname = "DB_" . DB_TYPE;
  73. if ( class_exists($db_classname) )
  74. {
  75. $db = new $db_classname(DB_ADDR, DB_USER, DB_PASS, DB_NAME, DB_PCONNECT);
  76. }
  77. else
  78. {
  79. error('Database class does not exist. Please check your config.php file for DB_TYPE');
  80. }
  81. $g_options = getOptions();
  82. if (!isset($g_options['scripturl']))
  83. $g_options['scripturl'] = str_replace('\\','/',$_SERVER['PHP_SELF']);
  84. ////
  85. //// Main
  86. ////
  87. if ( isset($_GET["game"]) )
  88. {
  89. $game = valid_request($_GET["game"], 0);
  90. }
  91. $mode = isset($_GET["mode"])?$_GET["mode"]:"";
  92. $valid_modes = array(
  93. "pro",
  94. "motd",
  95. "status",
  96. "load",
  97. "help",
  98. "players",
  99. "clans",
  100. "statsme",
  101. "kills",
  102. "targets",
  103. "accuracy",
  104. "actions",
  105. "weapons",
  106. "maps",
  107. "servers",
  108. "bans",
  109. "claninfo",
  110. "weaponinfo",
  111. "mapinfo",
  112. "actioninfo"
  113. );
  114. if (!in_array($mode, $valid_modes))
  115. {
  116. $mode = "status";
  117. }
  118. pageHeader();
  119. if ( file_exists(PAGE_PATH . "/ingame/$mode.php") )
  120. @include(PAGE_PATH . "/ingame/$mode.php");
  121. else
  122. error('Unable to find ' . PAGE_PATH . "/ingame/$mode.php");
  123. pageFooter();
  124. ?>