PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/admin_index.php

https://github.com/Dratone/EveBB
PHP | 173 lines | 127 code | 30 blank | 16 comment | 42 complexity | c24cc576150bf89727643405552aabe3 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * Copyright (C) 2008-2010 FluxBB
  4. * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
  5. * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
  6. */
  7. // Tell header.php to use the admin template
  8. define('PUN_ADMIN_CONSOLE', 1);
  9. define('PUN_ROOT', dirname(__FILE__).'/');
  10. require PUN_ROOT.'include/common.php';
  11. require PUN_ROOT.'include/common_admin.php';
  12. if (!$pun_user['is_admmod'])
  13. message($lang_common['No permission']);
  14. // Load the admin_index.php language file
  15. require PUN_ROOT.'lang/'.$admin_language.'/admin_index.php';
  16. $action = isset($_GET['action']) ? $_GET['action'] : null;
  17. // Check for upgrade
  18. if ($action == 'check_upgrade') {
  19. $latest_version = trim(@file_get_contents('http://www.eve-bb.com/latest_version'));
  20. if (empty($latest_version))
  21. message($lang_admin_index['Upgrade check failed message']);
  22. if (version_compare(EVE_BB_VERSION, $latest_version, '>=')) {
  23. message($lang_admin_index['Running latest version message']);
  24. } else {
  25. message(sprintf($lang_admin_index['New version available message'], '<a href="http://eve-bb.com/">EvE-BB.com</a>'));
  26. } //End if - else.
  27. } //End if.
  28. // Show phpinfo() output
  29. else if ($action == 'phpinfo' && $pun_user['g_id'] == PUN_ADMIN)
  30. {
  31. // Is phpinfo() a disabled function?
  32. if (strpos(strtolower((string) ini_get('disable_functions')), 'phpinfo') !== false)
  33. message($lang_admin_index['PHPinfo disabled message']);
  34. phpinfo();
  35. exit;
  36. }
  37. // Get the server load averages (if possible)
  38. if (@file_exists('/proc/loadavg') && is_readable('/proc/loadavg'))
  39. {
  40. // We use @ just in case
  41. $fh = @fopen('/proc/loadavg', 'r');
  42. $load_averages = @fread($fh, 64);
  43. @fclose($fh);
  44. if (($fh = @fopen('/proc/loadavg', 'r')))
  45. {
  46. $load_averages = fread($fh, 64);
  47. fclose($fh);
  48. }
  49. else
  50. $load_averages = '';
  51. $load_averages = @explode(' ', $load_averages);
  52. $server_load = isset($load_averages[2]) ? $load_averages[0].' '.$load_averages[1].' '.$load_averages[2] : $lang_admin_index['Not available'];
  53. }
  54. else if (!in_array(PHP_OS, array('WINNT', 'WIN32')) && preg_match('/averages?: ([0-9\.]+),?\s+([0-9\.]+),?\s+([0-9\.]+)/i', @exec('uptime'), $load_averages))
  55. $server_load = $load_averages[1].' '.$load_averages[2].' '.$load_averages[3];
  56. else
  57. $server_load = $lang_admin_index['Not available'];
  58. // Get number of current visitors
  59. $result = $db->query('SELECT COUNT(user_id) FROM '.$db->prefix.'online WHERE idle=0') or error('Unable to fetch online count', __FILE__, __LINE__, $db->error());
  60. $num_online = $db->result($result);
  61. // Collect some additional info about MySQL
  62. if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
  63. {
  64. // Calculate total db size/row count
  65. $result = $db->query('SHOW TABLE STATUS LIKE \''.$db->prefix.'%\'') or error('Unable to fetch table status', __FILE__, __LINE__, $db->error());
  66. $total_records = $total_size = 0;
  67. while ($status = $db->fetch_assoc($result))
  68. {
  69. $total_records += $status['rows'];
  70. $total_size += $status['data_length'] + $status['index_length'];
  71. }
  72. $total_size = file_size($total_size);
  73. }
  74. // Check for the existence of various PHP opcode caches/optimizers
  75. if (function_exists('mmcache'))
  76. $php_accelerator = '<a href="http://'.$lang_admin_index['Turck MMCache link'].'">'.$lang_admin_index['Turck MMCache'].'</a>';
  77. else if (isset($_PHPA))
  78. $php_accelerator = '<a href="http://'.$lang_admin_index['ionCube PHP Accelerator link'].'">'.$lang_admin_index['ionCube PHP Accelerator'].'</a>';
  79. else if (ini_get('apc.enabled'))
  80. $php_accelerator ='<a href="http://'.$lang_admin_index['Alternative PHP Cache (APC) link'].'">'.$lang_admin_index['Alternative PHP Cache (APC)'].'</a>';
  81. else if (ini_get('zend_optimizer.optimization_level'))
  82. $php_accelerator = '<a href="http://'.$lang_admin_index['Zend Optimizer link'].'">'.$lang_admin_index['Zend Optimizer'].'</a>';
  83. else if (ini_get('eaccelerator.enable'))
  84. $php_accelerator = '<a href="http://'.$lang_admin_index['eAccelerator link'].'">'.$lang_admin_index['eAccelerator'].'</a>';
  85. else if (ini_get('xcache.cacher'))
  86. $php_accelerator = '<a href="http://'.$lang_admin_index['XCache link'].'">'.$lang_admin_index['XCache'].'</a>';
  87. else
  88. $php_accelerator = $lang_admin_index['NA'];
  89. $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Index']);
  90. define('PUN_ACTIVE_PAGE', 'admin');
  91. require PUN_ROOT.'header.php';
  92. generate_admin_menu('index');
  93. ?>
  94. <div class="block">
  95. <h2><span><?php echo $lang_admin_index['Forum admin head'] ?></span></h2>
  96. <div id="adintro" class="box">
  97. <div class="inbox">
  98. <p><?php echo $lang_admin_index['Welcome to admin'] ?></p>
  99. <ul>
  100. <li><span><?php echo $lang_admin_index['Welcome 1'] ?></span></li>
  101. <li><span><?php echo $lang_admin_index['Welcome 2'] ?></span></li>
  102. <li><span><?php echo $lang_admin_index['Welcome 3'] ?></span></li>
  103. <li><span><?php echo $lang_admin_index['Welcome 4'] ?></span></li>
  104. <li><span><?php echo $lang_admin_index['Welcome 5'] ?></span></li>
  105. <li><span><?php echo $lang_admin_index['Welcome 6'] ?></span></li>
  106. <li><span><?php echo $lang_admin_index['Welcome 7'] ?></span></li>
  107. <li><span><?php echo $lang_admin_index['Welcome 8'] ?></span></li>
  108. <li><span><?php echo $lang_admin_index['Welcome 9'] ?></span></li>
  109. </ul>
  110. </div>
  111. </div>
  112. <h2 class="block2"><span><?php echo $lang_admin_index['Statistics head'] ?></span></h2>
  113. <div id="adstats" class="box">
  114. <div class="inbox">
  115. <dl>
  116. <dt><?php echo $lang_admin_index['FluxBB version label'] ?></dt>
  117. <dd>
  118. <?php printf($lang_admin_index['FluxBB version data'], EVE_BB_VERSION, '<a href="admin_index.php?action=check_upgrade">'.$lang_admin_index['Check for upgrade'].'</a>') ?>
  119. </dd>
  120. <dt><?php echo $lang_admin_index['Server load label'] ?></dt>
  121. <dd>
  122. <?php printf($lang_admin_index['Server load data'], $server_load, $num_online) ?>
  123. </dd>
  124. <?php if ($pun_user['g_id'] == PUN_ADMIN): ?> <dt><?php echo $lang_admin_index['Environment label'] ?></dt>
  125. <dd>
  126. <?php printf($lang_admin_index['Environment data OS'], PHP_OS) ?><br />
  127. <?php printf($lang_admin_index['Environment data version'], phpversion(), '<a href="admin_index.php?action=phpinfo">'.$lang_admin_index['Show info'].'</a>') ?><br />
  128. <?php printf($lang_admin_index['Environment data acc'], $php_accelerator) ?>
  129. </dd>
  130. <dt><?php echo $lang_admin_index['Database label'] ?></dt>
  131. <dd>
  132. <?php echo implode(' ', $db->get_version())."\n" ?>
  133. <?php if (isset($total_records) && isset($total_size)): ?> <br /><?php printf($lang_admin_index['Database data rows'], forum_number_format($total_records)) ?>
  134. <br /><?php printf($lang_admin_index['Database data size'], $total_size) ?>
  135. <?php endif; ?> </dd><?php endif; ?> </dd>
  136. </dl>
  137. </div>
  138. </div>
  139. </div>
  140. <div class="clearer"></div>
  141. </div>
  142. <?php
  143. require PUN_ROOT.'footer.php';