Newer
Older
Graham Cole
committed
<?php
/***********************************************************************
Graham Cole
committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
This file is part of PunBB.
PunBB is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PunBB is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA
************************************************************************/
// Tell header.php to use the admin template
define('PUN_ADMIN_CONSOLE', 1);
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
require PUN_ROOT.'include/common_admin.php';
if ($pun_user['g_id'] > PUN_MOD)
message($lang_common['No permission']);
$action = isset($_GET['action']) ? $_GET['action'] : null;
// Check for upgrade
if ($action == 'check_upgrade')
{
if (!ini_get('allow_url_fopen'))
message('Unable to check for upgrade since \'allow_url_fopen\' is disabled on this system.');
$fp = @fopen('http://punbb.informer.com/latest_version', 'r');
Graham Cole
committed
$latest_version = trim(@fread($fp, 16));
@fclose($fp);
if ($latest_version == '')
message('Check for upgrade failed for unknown reasons.');
$latest_version = preg_replace('/(\.0)+(?!\.)|(\.0+$)/', '$2', $latest_version);
$cur_version = preg_replace('/(\.0)+(?!\.)|(\.0+$)/', '$2', $cur_version);
Graham Cole
committed
if (version_compare($cur_version, $latest_version, '>='))
Graham Cole
committed
message('You are running the latest version of PunBB.');
else
message('A new version of PunBB has been released. You can download the latest version at <a href="http://punbb.informer.com/">PunBB.Informer.Com</a>.');
Graham Cole
committed
}
// Show phpinfo() output
else if ($action == 'phpinfo' && $pun_user['g_id'] == PUN_ADMIN)
{
// Is phpinfo() a disabled function?
if (strpos(strtolower((string)@ini_get('disable_functions')), 'phpinfo') !== false)
message('The PHP function phpinfo() has been disabled on this server.');
phpinfo();
Graham Cole
committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
}
// Get the server load averages (if possible)
if (@file_exists('/proc/loadavg') && is_readable('/proc/loadavg'))
{
// We use @ just in case
$fh = @fopen('/proc/loadavg', 'r');
$load_averages = @fread($fh, 64);
@fclose($fh);
$load_averages = @explode(' ', $load_averages);
$server_load = isset($load_averages[2]) ? $load_averages[0].' '.$load_averages[1].' '.$load_averages[2] : 'Not available';
}
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))
$server_load = $load_averages[1].' '.$load_averages[2].' '.$load_averages[3];
else
$server_load = 'Not available';
// Get number of current visitors
$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());
$num_online = $db->result($result);
// Get the database system version
switch ($db_type)
{
case 'sqlite':
$db_version = 'SQLite '.sqlite_libversion();
break;
default:
$result = $db->query('SELECT VERSION()') or error('Unable to fetch version info', __FILE__, __LINE__, $db->error());
$db_version = $db->result($result);
break;
}
// Collect some additional info about MySQL
if ($db_type == 'mysql' || $db_type == 'mysqli')
{
$db_version = 'MySQL '.$db_version;
// Calculate total db size/row count
$result = $db->query('SHOW TABLE STATUS FROM `'.$db_name.'`') or error('Unable to fetch table status', __FILE__, __LINE__, $db->error());
$total_records = $total_size = 0;
while ($status = $db->fetch_assoc($result))
{
$total_records += $status['Rows'];
$total_size += $status['Data_length'] + $status['Index_length'];
}
$total_size = $total_size / 1024;
if ($total_size > 1024)
$total_size = round($total_size / 1024, 2).' MB';
else
$total_size = round($total_size, 2).' KB';
}
// See if MMCache or PHPA is loaded
if (function_exists('mmcache'))
$php_accelerator = '<a href="http://turck-mmcache.sourceforge.net/">Turck MMCache</a>';
else if (isset($_PHPA))
$php_accelerator = '<a href="http://www.php-accelerator.co.uk/">ionCube PHP Accelerator</a>';
else
$php_accelerator = 'N/A';
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin';
require PUN_ROOT.'header.php';
generate_admin_menu('index');
?>
<div class="block">
<h2>Forum administration</h2>
<div id="adintro" class="box">
<div class="inbox">
<p>
Welcome to the PunBB administration control panel. From here you can control vital aspects of the forum. Depending on whether you are an administrator or a moderator you can<br /><br />
- organize categories and forums.<br />
- set forum-wide options and preferences.<br />
- control permissions for users and guests.<br />
- view IP statistics for users.<br />
- ban users.<br />
- censor words.<br />
- set up user ranks.<br />
- prune old posts.<br />
- handle post reports.
</p>
</div>
</div>
<h2 class="block2"><span>Statistics</span></h2>
<div id="adstats" class="box">
<div class="inbox">
<dl>
<dt>PunBB version</dt>
<dd>
PunBB <?php echo $pun_config['o_cur_version'] ?> - <a href="admin_index.php?action=check_upgrade">Check for upgrade</a><br />
Graham Cole
committed
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
</dd>
<dt>Server load</dt>
<dd>
<?php echo $server_load ?> (<?php echo $num_online ?> users online)
</dd>
<?php if ($pun_user['g_id'] == PUN_ADMIN): ?> <dt>Environment</dt>
<dd>
Operating system: <?php echo PHP_OS ?><br />
PHP: <?php echo phpversion() ?> - <a href="admin_index.php?action=phpinfo">Show info</a><br />
Accelerator: <?php echo $php_accelerator."\n" ?>
</dd>
<dt>Database</dt>
<dd>
<?php echo $db_version."\n" ?>
<?php if (isset($total_records) && isset($total_size)): ?> <br />Rows: <?php echo $total_records."\n" ?>
<br />Size: <?php echo $total_size."\n" ?>
<?php endif; endif; ?> </dd>
</dl>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<?php
require PUN_ROOT.'footer.php';