PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/web/hlstats.php

https://bitbucket.org/JabLuszko/hlstatsxce
PHP | 233 lines | 158 code | 27 blank | 48 comment | 19 complexity | 1c52f581cf35e124bd8321e37168ef3f 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. define('IN_HLSTATS', true);
  32. require('config.php');
  33. $historical_cache=0;
  34. if(defined('HISTORICAL_CACHE'))
  35. {
  36. $historical_cache=constant('HISTORICAL_CACHE');
  37. }
  38. if($historical_cache==1)
  39. {
  40. $rawmd5=md5(http_build_query($_REQUEST));
  41. $dir1=substr($rawmd5,0,1);
  42. $dir2=substr($rawmd5,1,1);
  43. $cachetarget=sprintf("cache/%s/%s/%s", $dir1, $dir2, $rawmd5);
  44. @mkdir("cache/$dir1");
  45. @mkdir("cache/$dir1/$dir2");
  46. if(file_exists($cachetarget))
  47. {
  48. file_put_contents("cache/cachehit",$cachetarget . "\n", FILE_APPEND);
  49. echo file_get_contents($cachetarget);
  50. die;
  51. }
  52. }
  53. session_start();
  54. if((!empty($_GET['logout'])) && $_GET['logout'] == '1') {
  55. unset($_SESSION['loggedin']);
  56. header("Location: http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']);
  57. die;
  58. }
  59. // Several stuff added by Malte Bayer
  60. global $scripttime, $siteurlneo;
  61. $scripttime = microtime(true);
  62. $siteurlneo='http://'.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],strrchr($_SERVER['PHP_SELF'],'/'))+1);
  63. $siteurlneo=str_replace('\\','/',$siteurlneo);
  64. // Several Stuff end
  65. foreach ($_SERVER as $key => $entry) {
  66. if ($key !== 'HTTP_COOKIE') {
  67. $search_pattern = array('/<script>/', '/<\/script>/', '/[^A-Za-z0-9.\-\/=:;_?#&~]/');
  68. $replace_pattern = array('', '', '');
  69. $entry = preg_replace($search_pattern, $replace_pattern, $entry);
  70. if ($key == "PHP_SELF") {
  71. if ((strrchr($entry, '/') !== '/hlstats.php') &&
  72. (strrchr($entry, '/') !== '/ingame.php') &&
  73. (strrchr($entry, '/') !== '/show_graph.php') &&
  74. (strrchr($entry, '/') !== '/sig.php') &&
  75. (strrchr($entry, '/') !== '/sig2.php') &&
  76. (strrchr($entry, '/') !== '/index.php') &&
  77. (strrchr($entry, '/') !== '/status.php') &&
  78. (strrchr($entry, '/') !== '/top10.php') &&
  79. (strrchr($entry, '/') !== '/config.php') &&
  80. (strrchr($entry, '/') !== '/') &&
  81. ($entry !== '')) {
  82. header("Location: http://$siteurlneo/hlstats.php");
  83. exit;
  84. }
  85. }
  86. $_SERVER[$key] = $entry;
  87. }
  88. }
  89. @header('Content-Type: text/html; charset=utf-8');
  90. // do not report NOTICE warnings
  91. @error_reporting(E_ALL ^ E_NOTICE);
  92. ////
  93. //// Initialisation
  94. ////
  95. define('PAGE', 'HLSTATS');
  96. ///
  97. /// Classes
  98. ///
  99. // Load required files
  100. require(INCLUDE_PATH . '/class_db.php');
  101. require(INCLUDE_PATH . '/class_table.php');
  102. require(INCLUDE_PATH . '/functions.php');
  103. $db_classname = 'DB_' . DB_TYPE;
  104. if ( class_exists($db_classname) )
  105. {
  106. $db = new $db_classname(DB_ADDR, DB_USER, DB_PASS, DB_NAME, DB_PCONNECT);
  107. }
  108. else
  109. {
  110. error('Database class does not exist. Please check your config.php file for DB_TYPE');
  111. }
  112. $g_options = getOptions();
  113. if (!isset($g_options['scripturl'])) {
  114. $g_options['scripturl'] = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
  115. }
  116. ////
  117. //// Main
  118. ////
  119. $game = valid_request(isset($_GET['game'])?$_GET['game']:'', 0);
  120. if (!$game)
  121. {
  122. $game = isset($_SESSION['game'])?$_SESSION['game']:'';
  123. }
  124. else
  125. {
  126. $_SESSION['game'] = $game;
  127. }
  128. if (!$realgame && $game)
  129. {
  130. $realgame = getRealGame($game);
  131. $_SESSION['realgame'] = $realgame;
  132. }
  133. $mode = isset($_GET['mode'])?$_GET['mode']:'';
  134. $valid_modes = array(
  135. 'players',
  136. 'clans',
  137. 'weapons',
  138. 'roles',
  139. 'rolesinfo',
  140. 'maps',
  141. 'actions',
  142. 'claninfo',
  143. 'playerinfo',
  144. 'weaponinfo',
  145. 'mapinfo',
  146. 'actioninfo',
  147. 'playerhistory',
  148. 'playersessions',
  149. 'playerawards',
  150. 'search',
  151. 'admin',
  152. 'help',
  153. 'bans',
  154. 'servers',
  155. 'chathistory',
  156. 'ranks',
  157. 'rankinfo',
  158. 'ribbons',
  159. 'ribboninfo',
  160. 'chat',
  161. 'globalawards',
  162. 'awards',
  163. 'dailyawardinfo',
  164. 'countryclans',
  165. 'countryclansinfo',
  166. 'teamspeak',
  167. 'ventrilo',
  168. 'updater',
  169. 'profile'
  170. );
  171. if (file_exists('./updater') && $mode != 'updater')
  172. {
  173. pageHeader(array('Update Notice'), array('Update Notice' => ''));
  174. echo "<div class=\"warning\">\n" .
  175. "<span class=\"warning-heading\"><img src=\"".IMAGE_PATH."/warning.gif\" alt=\"Warning\"> Warning:</span><br />\n" .
  176. "<span class=\"warning-text\">The updater folder was detected in your web directory.<br />
  177. To perform a Database Update, please go to <strong><a href=\"{$g_options['scripturl']}?mode=updater\">HLX:CE Database Updater</a></strong> to perform the database update.<br /><br />
  178. <strong>If you have already performed the database update, <strong>you must delete the \"updater\" folder from your web folder.</span>\n</div>";
  179. pageFooter();
  180. die();
  181. }
  182. if ( !in_array($mode, $valid_modes) )
  183. {
  184. $mode = 'contents';
  185. }
  186. if ( file_exists(PAGE_PATH . "/$mode.php") )
  187. {
  188. @include(PAGE_PATH . "/$mode.php");
  189. pageFooter();
  190. }
  191. else
  192. {
  193. header('HTTP/1.1 404 File Not Found', false, 404);
  194. error('Unable to find ' . PAGE_PATH . "/$mode.php");
  195. pageFooter();
  196. }
  197. ?>