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