git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@258 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293
This commit is contained in:
GTDarkNightmare@gmail.com 2011-08-27 17:25:55 +00:00
commit c40eb58b6a

View file

@ -1,363 +1,366 @@
<?php <?php
require('./pagestart.php'); require('./pagestart.php');
// //
// Generate relevant output // Generate relevant output
// //
if( isset($_GET['pane']) && $_GET['pane'] == 'left' ) if( isset($_GET['pane']) && $_GET['pane'] == 'left' )
{ {
$dir = @opendir("."); $dir = @opendir(".");
$setmodules = 1; $setmodules = 1;
while( $file = @readdir($dir) ) while( $file = @readdir($dir) )
{ {
if( preg_match("/^admin_.*?\.php$/", $file) ) if( preg_match("/^admin_.*?\.php$/", $file) )
{ {
include('./' . $file); include('./' . $file);
} }
} }
@closedir($dir); @closedir($dir);
unset($setmodules); unset($setmodules);
$template->assign_vars(array( $template->assign_vars(array(
'TPL_ADMIN_NAVIGATE' => true, 'TPL_ADMIN_NAVIGATE' => true,
"U_FORUM_INDEX" => append_sid("../index.php"), "U_FORUM_INDEX" => append_sid("../index.php"),
"U_ADMIN_INDEX" => append_sid("index.php?pane=right")) "U_ADMIN_INDEX" => append_sid("index.php?pane=right"))
); );
ksort($module); ksort($module);
while( list($cat, $action_array) = each($module) ) while( list($cat, $action_array) = each($module) )
{ {
$cat = ( !empty($lang[strtoupper($cat)]) ) ? $lang[strtoupper($cat)] : preg_replace("/_/", " ", $cat); $cat = ( !empty($lang[strtoupper($cat)]) ) ? $lang[strtoupper($cat)] : preg_replace("/_/", " ", $cat);
$template->assign_block_vars("catrow", array( $template->assign_block_vars("catrow", array(
"ADMIN_CATEGORY" => $cat) "ADMIN_CATEGORY" => $cat)
); );
ksort($action_array); ksort($action_array);
$row_count = 0; $row_count = 0;
while( list($action, $file) = each($action_array) ) while( list($action, $file) = each($action_array) )
{ {
$row_class = !($row_count % 2) ? 'row1' : 'row2'; $row_class = !($row_count % 2) ? 'row1' : 'row2';
$action = ( !empty($lang[strtoupper($action)]) ) ? $lang[strtoupper($action)] : preg_replace("/_/", " ", $action); $action = ( !empty($lang[strtoupper($action)]) ) ? $lang[strtoupper($action)] : preg_replace("/_/", " ", $action);
$template->assign_block_vars("catrow.modulerow", array( $template->assign_block_vars("catrow.modulerow", array(
"ROW_CLASS" => $row_class, "ROW_CLASS" => $row_class,
"ADMIN_MODULE" => $action, "ADMIN_MODULE" => $action,
"U_ADMIN_MODULE" => append_sid($file)) "U_ADMIN_MODULE" => append_sid($file))
); );
$row_count++; $row_count++;
} }
} }
} }
else if( isset($_GET['pane']) && $_GET['pane'] == 'right' ) else if( isset($_GET['pane']) && $_GET['pane'] == 'right' )
{ {
$template->assign_vars(array( $template->assign_vars(array(
'TPL_ADMIN_MAIN' => true, 'TPL_ADMIN_MAIN' => true,
)); ));
// //
// Get forum statistics // Get forum statistics
// //
$total_posts = get_db_stat('postcount'); $total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount'); $total_users = get_db_stat('usercount');
$total_topics = get_db_stat('topiccount'); $total_topics = get_db_stat('topiccount');
$start_date = bb_date($bb_cfg['board_startdate']); $start_date = bb_date($bb_cfg['board_startdate']);
$boarddays = ( TIMENOW - $bb_cfg['board_startdate'] ) / 86400; $boarddays = ( TIMENOW - $bb_cfg['board_startdate'] ) / 86400;
$posts_per_day = sprintf("%.2f", $total_posts / $boarddays); $posts_per_day = sprintf("%.2f", $total_posts / $boarddays);
$topics_per_day = sprintf("%.2f", $total_topics / $boarddays); $topics_per_day = sprintf("%.2f", $total_topics / $boarddays);
$users_per_day = sprintf("%.2f", $total_users / $boarddays); $users_per_day = sprintf("%.2f", $total_users / $boarddays);
$avatar_dir_size = 0; $avatar_dir_size = 0;
if ($avatar_dir = @opendir(BB_ROOT . $bb_cfg['avatar_path'])) if ($avatar_dir = @opendir(BB_ROOT . $bb_cfg['avatar_path']))
{ {
while( $file = @readdir($avatar_dir) ) while( $file = @readdir($avatar_dir) )
{ {
if( $file != "." && $file != ".." ) if( $file != "." && $file != ".." )
{ {
$avatar_dir_size += @filesize(BB_ROOT . $bb_cfg['avatar_path'] . "/" . $file); $avatar_dir_size += @filesize(BB_ROOT . $bb_cfg['avatar_path'] . "/" . $file);
} }
} }
@closedir($avatar_dir); @closedir($avatar_dir);
if($avatar_dir_size >= 1048576) if($avatar_dir_size >= 1048576)
{ {
$avatar_dir_size = round($avatar_dir_size / 1048576 * 100) / 100 . " MB"; $avatar_dir_size = round($avatar_dir_size / 1048576 * 100) / 100 . " MB";
} }
else if($avatar_dir_size >= 1024) else if($avatar_dir_size >= 1024)
{ {
$avatar_dir_size = round($avatar_dir_size / 1024 * 100) / 100 . " KB"; $avatar_dir_size = round($avatar_dir_size / 1024 * 100) / 100 . " KB";
} }
else else
{ {
$avatar_dir_size = $avatar_dir_size . " Bytes"; $avatar_dir_size = $avatar_dir_size . " Bytes";
} }
} }
else else
{ {
// Couldn't open Avatar dir. // Couldn't open Avatar dir.
$avatar_dir_size = $lang['NOT_AVAILABLE']; $avatar_dir_size = $lang['NOT_AVAILABLE'];
} }
if(intval($posts_per_day) > $total_posts) if(intval($posts_per_day) > $total_posts)
{ {
$posts_per_day = $total_posts; $posts_per_day = $total_posts;
} }
if(intval($topics_per_day) > $total_topics) if(intval($topics_per_day) > $total_topics)
{ {
$topics_per_day = $total_topics; $topics_per_day = $total_topics;
} }
if($users_per_day > $total_users) if($users_per_day > $total_users)
{ {
$users_per_day = $total_users; $users_per_day = $total_users;
} }
// //
// DB size ... MySQL only // DB size ... MySQL only
// //
// This code is heavily influenced by a similar routine // This code is heavily influenced by a similar routine
// in phpMyAdmin 2.2.0 // in phpMyAdmin 2.2.0
// //
$sql = "SELECT VERSION() AS mysql_version"; $sql = "SELECT VERSION() AS mysql_version";
if($result = DB()->sql_query($sql)) if($result = DB()->sql_query($sql))
{ {
$row = DB()->sql_fetchrow($result); $row = DB()->sql_fetchrow($result);
$version = $row['mysql_version']; $version = $row['mysql_version'];
if( preg_match("/^(3\.23|4\.|5\.)/", $version) ) if( preg_match("/^(3\.23|4\.|5\.)/", $version) )
{ {
$dblist = array(); $dblist = array();
foreach($bb_cfg['db'] as $name => $row) foreach($bb_cfg['db'] as $name => $row)
{ $sql = "SHOW TABLE STATUS {
FROM {$row[1]}"; $sql = "SHOW TABLE STATUS
if($result = DB()->sql_query($sql)) FROM {$row[1]}";
{ if($result = DB()->sql_query($sql))
$tabledata_ary = DB()->sql_fetchrowset($result); {
$tabledata_ary = DB()->sql_fetchrowset($result);
$dbsize = 0;
for($i = 0; $i < count($tabledata_ary); $i++) $dbsize = 0;
{ for($i = 0; $i < count($tabledata_ary); $i++)
if( @$tabledata_ary[$i]['Type'] != "MRG_MyISAM" ) {
{ if( @$tabledata_ary[$i]['Type'] != "MRG_MyISAM" )
$dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length']; {
} $dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length'];
} }
$dblist[] = '<span title="'. $name .'">'. humn_size($dbsize) .'</span>'; }
} } $dblist[] = '<span title="'. $name .'">'. humn_size($dbsize) .'</span>';
$dbsize = implode('&nbsp;|&nbsp;', $dblist); }
} }
else $dbsize = implode('&nbsp;|&nbsp;', $dblist);
{ }
$dbsize = $lang['Not_available']; else
} {
} $dbsize = $lang['Not_available'];
else }
{ }
$dbsize = $lang['Not_available']; else
} {
$dbsize = $lang['Not_available'];
$template->assign_vars(array( }
"NUMBER_OF_POSTS" => $total_posts,
"NUMBER_OF_TOPICS" => $total_topics, $template->assign_vars(array(
"NUMBER_OF_USERS" => $total_users, "NUMBER_OF_POSTS" => $total_posts,
"START_DATE" => $start_date, "NUMBER_OF_TOPICS" => $total_topics,
"POSTS_PER_DAY" => $posts_per_day, "NUMBER_OF_USERS" => $total_users,
"TOPICS_PER_DAY" => $topics_per_day, "START_DATE" => $start_date,
"USERS_PER_DAY" => $users_per_day, "POSTS_PER_DAY" => $posts_per_day,
"AVATAR_DIR_SIZE" => $avatar_dir_size, "TOPICS_PER_DAY" => $topics_per_day,
"DB_SIZE" => $dbsize, "USERS_PER_DAY" => $users_per_day,
"GZIP_COMPRESSION" => ( $bb_cfg['gzip_compress'] ) ? $lang['ON'] : $lang['OFF']) "AVATAR_DIR_SIZE" => $avatar_dir_size,
); "DB_SIZE" => $dbsize,
// "GZIP_COMPRESSION" => ( $bb_cfg['gzip_compress'] ) ? $lang['ON'] : $lang['OFF'])
// End forum statistics );
// //
if (@$_GET['users_online']) // End forum statistics
{ //
$template->assign_vars(array( if (@$_GET['users_online'])
'SHOW_USERS_ONLINE' => true, {
)); $template->assign_vars(array(
// 'SHOW_USERS_ONLINE' => true,
// Get users online information. ));
// //
$sql = "SELECT u.user_id, u.username, u.user_rank, s.session_time AS user_session_time, u.user_opt, s.session_logged_in, s.session_ip, s.session_start // Get users online information.
FROM " . BB_USERS . " u, " . BB_SESSIONS . " s //
WHERE s.session_logged_in = 1 $sql = "SELECT u.user_id, u.username, u.user_rank, s.session_time AS user_session_time, u.user_opt, s.session_logged_in, s.session_ip, s.session_start
AND u.user_id = s.session_user_id FROM " . BB_USERS . " u, " . BB_SESSIONS . " s
AND u.user_id <> " . ANONYMOUS . " WHERE s.session_logged_in = 1
AND s.session_time >= " . ( TIMENOW - 300 ) . " AND u.user_id = s.session_user_id
ORDER BY s.session_ip ASC, s.session_time DESC"; AND u.user_id <> " . ANONYMOUS . "
if(!$result = DB()->sql_query($sql)) AND s.session_time >= " . ( TIMENOW - 300 ) . "
{ ORDER BY s.session_ip ASC, s.session_time DESC";
message_die(GENERAL_ERROR, "Couldn't obtain regd user/online information.", "", __LINE__, __FILE__, $sql); if(!$result = DB()->sql_query($sql))
} {
$onlinerow_reg = DB()->sql_fetchrowset($result); message_die(GENERAL_ERROR, "Couldn't obtain regd user/online information.", "", __LINE__, __FILE__, $sql);
}
$sql = "SELECT session_logged_in, session_time, session_ip, session_start $onlinerow_reg = DB()->sql_fetchrowset($result);
FROM " . BB_SESSIONS . "
WHERE session_logged_in = 0 $sql = "SELECT session_logged_in, session_time, session_ip, session_start
AND session_time >= " . ( TIMENOW - 300 ) . " FROM " . BB_SESSIONS . "
ORDER BY session_ip ASC, session_time DESC"; WHERE session_logged_in = 0
if(!$result = DB()->sql_query($sql)) AND session_time >= " . ( TIMENOW - 300 ) . "
{ ORDER BY session_ip ASC, session_time DESC";
message_die(GENERAL_ERROR, "Couldn't obtain guest user/online information.", "", __LINE__, __FILE__, $sql); if(!$result = DB()->sql_query($sql))
} {
$onlinerow_guest = DB()->sql_fetchrowset($result); message_die(GENERAL_ERROR, "Couldn't obtain guest user/online information.", "", __LINE__, __FILE__, $sql);
}
$reg_userid_ary = array(); $onlinerow_guest = DB()->sql_fetchrowset($result);
if( count($onlinerow_reg) ) $reg_userid_ary = array();
{
$registered_users = 0; if( count($onlinerow_reg) )
{
for($i=0, $cnt=count($onlinerow_reg); $i < $cnt; $i++) $registered_users = 0;
{
if( !inarray($onlinerow_reg[$i]['user_id'], $reg_userid_ary) ) for($i=0, $cnt=count($onlinerow_reg); $i < $cnt; $i++)
{ {
$reg_userid_ary[] = $onlinerow_reg[$i]['user_id']; if( !inarray($onlinerow_reg[$i]['user_id'], $reg_userid_ary) )
{
$username = $onlinerow_reg[$i]['username']; $reg_userid_ary[] = $onlinerow_reg[$i]['user_id'];
if( !bf($onlinerow_reg[$i]['user_opt'], 'user_opt', 'allow_viewonline')) $username = $onlinerow_reg[$i]['username'];
{
$registered_users++; if( !bf($onlinerow_reg[$i]['user_opt'], 'user_opt', 'allow_viewonline'))
$hidden = FALSE; {
} $registered_users++;
else $hidden = FALSE;
{ }
@$hidden_users++; else
$hidden = TRUE; {
} @$hidden_users++;
$hidden = TRUE;
$row_class = 'row1'; }
$reg_ip = decode_ip($onlinerow_reg[$i]['session_ip']); $row_class = 'row1';
$template->assign_block_vars("reg_user_row", array( $reg_ip = decode_ip($onlinerow_reg[$i]['session_ip']);
"ROW_CLASS" => $row_class,
"USER" => profile_url($onlinerow_reg[$i]), $template->assign_block_vars("reg_user_row", array(
"STARTED" => bb_date($onlinerow_reg[$i]['session_start'], 'H:i', 'false'), "ROW_CLASS" => $row_class,
"LASTUPDATE" => bb_date($onlinerow_reg[$i]['user_session_time'], 'H:i', 'false'), "USER" => profile_url($onlinerow_reg[$i]),
"IP_ADDRESS" => $reg_ip, "STARTED" => bb_date($onlinerow_reg[$i]['session_start'], 'H:i', 'false'),
"LASTUPDATE" => bb_date($onlinerow_reg[$i]['user_session_time'], 'H:i', 'false'),
"U_WHOIS_IP" => "http://ip-whois.net/ip_geo.php?ip=$reg_ip", "IP_ADDRESS" => $reg_ip,
));
} "U_WHOIS_IP" => "http://ip-whois.net/ip_geo.php?ip=$reg_ip",
} ));
}
} }
else
{ }
$template->assign_vars(array( else
"L_NO_REGISTERED_USERS_BROWSING" => $lang['NO_USERS_BROWSING']) {
); $template->assign_vars(array(
} "L_NO_REGISTERED_USERS_BROWSING" => $lang['NO_USERS_BROWSING'])
);
// }
// Guest users
// //
if( count($onlinerow_guest) ) // Guest users
{ //
$guest_users = 0; if( count($onlinerow_guest) )
{
for($i = 0; $i < count($onlinerow_guest); $i++) $guest_users = 0;
{
$guest_userip_ary[] = $onlinerow_guest[$i]['session_ip']; for($i = 0; $i < count($onlinerow_guest); $i++)
$guest_users++; {
$guest_userip_ary[] = $onlinerow_guest[$i]['session_ip'];
$row_class = 'row2'; $guest_users++;
$guest_ip = decode_ip($onlinerow_guest[$i]['session_ip']); $row_class = 'row2';
$template->assign_block_vars("guest_user_row", array( $guest_ip = decode_ip($onlinerow_guest[$i]['session_ip']);
"ROW_CLASS" => $row_class,
"USERNAME" => $lang['GUEST'], $template->assign_block_vars("guest_user_row", array(
"STARTED" => bb_date($onlinerow_guest[$i]['session_start'], 'H:i', 'false'), "ROW_CLASS" => $row_class,
"LASTUPDATE" => bb_date($onlinerow_guest[$i]['session_time'], 'H:i' , 'false'), "USERNAME" => $lang['GUEST'],
"IP_ADDRESS" => $guest_ip, "STARTED" => bb_date($onlinerow_guest[$i]['session_start'], 'H:i', 'false'),
"U_WHOIS_IP" => "http://ip-whois.net/ip_geo.php?ip=$guest_ip", "LASTUPDATE" => bb_date($onlinerow_guest[$i]['session_time'], 'H:i' , 'false'),
)); "IP_ADDRESS" => $guest_ip,
} "U_WHOIS_IP" => "http://ip-whois.net/ip_geo.php?ip=$guest_ip",
} ));
} }
else }
{ }
$template->assign_vars(array( else
'USERS_ONLINE_HREF' => "index.php?pane=right&users_online=1&sid={$userdata['session_id']}", {
)); $template->assign_vars(array(
} 'USERS_ONLINE_HREF' => "index.php?pane=right&users_online=1&sid={$userdata['session_id']}",
'L_SHOW_USERS_ONLINE' => $lang['SHOW_ONLINE_USERLIST'],
$template->assign_vars(array( ));
'U_CLEAR_DATASTORE' => "index.php?clear_datastore=1", }
'U_CLEAR_TPL_CACHE' => "xs_cache.php?clear=",
'U_UPDATE_USER_LEVEL' => "index.php?update_user_level=1", $template->assign_vars(array(
'U_SYNC_TOPICS' => "index.php?sync_topics=1", 'U_CLEAR_DATASTORE' => "index.php?clear_datastore=1",
'U_SYNC_USER_POSTS' => "index.php?sync_user_posts=1", 'U_CLEAR_TPL_CACHE' => "xs_cache.php?clear=",
)); 'U_UPDATE_USER_LEVEL' => "index.php?update_user_level=1",
} 'U_SYNC_TOPICS' => "index.php?sync_topics=1",
else if (isset($_REQUEST['clear_datastore'])) 'U_SYNC_USER_POSTS' => "index.php?sync_user_posts=1",
{ ));
$datastore->clean(); }
bb_die($lang['DATASTORE_CLEARED']); else if (isset($_REQUEST['clear_datastore']))
} {
else if (isset($_REQUEST['update_user_level'])) $datastore->clean();
{ bb_die($lang['DATASTORE_CLEARED']);
require(INC_DIR .'functions_group.php'); }
update_user_level('all'); else if (isset($_REQUEST['update_user_level']))
bb_die($lang['USER_LEVELS_UPDATED']); {
} require(INC_DIR .'functions_group.php');
else if (isset($_REQUEST['sync_topics'])) update_user_level('all');
{ bb_die($lang['USER_LEVELS_UPDATED']);
sync('topic', 'all'); }
sync('forum', 'all'); else if (isset($_REQUEST['sync_topics']))
bb_die($lang['TOPICS_DATA_SYNCHRONIZED']); {
} sync('topic', 'all');
else if (isset($_REQUEST['sync_user_posts'])) sync('forum', 'all');
{ bb_die($lang['TOPICS_DATA_SYNCHRONIZED']);
sync('user_posts', 'all'); }
bb_die($lang['USER POSTS COUNT SYNCHRONIZED']); else if (isset($_REQUEST['sync_user_posts']))
} {
else sync('user_posts', 'all');
{ bb_die($lang['USER POSTS COUNT SYNCHRONIZED']);
// }
// Generate frameset else
// {
$template->assign_vars(array( //
'TPL_ADMIN_FRAMESET' => true, // Generate frameset
'S_FRAME_NAV' => "index.php?pane=left", //
'S_FRAME_MAIN' => "index.php?pane=right", $template->assign_vars(array(
)); 'TPL_ADMIN_FRAMESET' => true,
send_no_cache_headers(); 'S_FRAME_NAV' => "index.php?pane=left",
print_page('index.tpl', 'admin', 'no_header'); 'S_FRAME_MAIN' => "index.php?pane=right",
} ));
send_no_cache_headers();
print_page('index.tpl', 'admin'); print_page('index.tpl', 'admin', 'no_header');
}
//
// Functions print_page('index.tpl', 'admin');
//
function inarray($needle, $haystack) //
{ // Functions
for($i = 0; $i < sizeof($haystack); $i++ ) //
{ function inarray($needle, $haystack)
if( $haystack[$i] == $needle ) {
{ for($i = 0; $i < sizeof($haystack); $i++ )
return true; {
} if( $haystack[$i] == $needle )
} {
return false; return true;
} }
}
return false;
}