2001-02-17 08:37:32 +00:00
|
|
|
<?php
|
|
|
|
/***************************************************************************
|
2001-08-26 14:35:39 +00:00
|
|
|
* (admin) index.php
|
2001-02-17 08:37:32 +00:00
|
|
|
* -------------------
|
|
|
|
* begin : Saturday, Feb 13, 2001
|
|
|
|
* copyright : (C) 2001 The phpBB Group
|
|
|
|
* email : support@phpbb.com
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2001-07-13 17:03:04 +00:00
|
|
|
$phpbb_root_path = "./../";
|
|
|
|
include($phpbb_root_path . 'extension.inc');
|
|
|
|
include($phpbb_root_path . 'common.'.$phpEx);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Start session management
|
|
|
|
//
|
2001-07-13 14:16:11 +00:00
|
|
|
$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
|
|
|
|
init_userprefs($userdata);
|
2001-07-13 17:03:04 +00:00
|
|
|
//
|
2001-07-14 20:00:27 +00:00
|
|
|
// End session management
|
2001-07-13 17:03:04 +00:00
|
|
|
//
|
2001-07-13 14:16:11 +00:00
|
|
|
|
2001-07-14 15:22:55 +00:00
|
|
|
//
|
2001-07-14 20:00:27 +00:00
|
|
|
// Is user logged in? If yes are they an admin?
|
2001-07-14 15:22:55 +00:00
|
|
|
//
|
2001-07-14 20:00:27 +00:00
|
|
|
if( !$userdata['session_logged_in'] )
|
2001-07-14 15:22:55 +00:00
|
|
|
{
|
2001-07-30 15:19:15 +00:00
|
|
|
header("Location: ../login.$phpEx?forward_page=admin/");
|
2001-07-14 15:22:55 +00:00
|
|
|
}
|
2001-07-14 20:00:27 +00:00
|
|
|
else if( $userdata['user_level'] != ADMIN )
|
|
|
|
{
|
2001-07-28 14:54:42 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $lang['Not_admin']);
|
2001-07-14 20:00:27 +00:00
|
|
|
}
|
|
|
|
|
2001-07-14 15:22:55 +00:00
|
|
|
//
|
2001-07-14 20:00:27 +00:00
|
|
|
// Generate relevant output
|
2001-07-14 15:22:55 +00:00
|
|
|
//
|
2001-07-27 23:29:58 +00:00
|
|
|
if( $HTTP_GET_VARS['pane'] == 'left' )
|
2001-07-13 14:16:11 +00:00
|
|
|
{
|
|
|
|
$dir = opendir(".");
|
|
|
|
|
2001-07-13 17:03:04 +00:00
|
|
|
$setmodules = 1;
|
2001-07-13 14:16:11 +00:00
|
|
|
while($file = readdir($dir))
|
|
|
|
{
|
2001-07-13 17:03:04 +00:00
|
|
|
if(preg_match("/^admin_.*/", $file))
|
|
|
|
{
|
|
|
|
include($file);
|
|
|
|
}
|
2001-07-13 14:16:11 +00:00
|
|
|
}
|
|
|
|
|
2001-07-14 21:43:57 +00:00
|
|
|
include('page_header_admin.'.$phpEx);
|
2001-07-14 20:00:27 +00:00
|
|
|
|
2001-07-14 15:22:55 +00:00
|
|
|
$template->set_filenames(array(
|
2001-07-30 15:19:15 +00:00
|
|
|
"body" => "admin/index_navigate.tpl")
|
2001-07-14 15:22:55 +00:00
|
|
|
);
|
2001-07-14 20:00:27 +00:00
|
|
|
|
2001-07-27 23:29:58 +00:00
|
|
|
$template->assign_vars(array(
|
|
|
|
"U_BOARD_INDEX" => append_sid("../index.$phpEx"),
|
|
|
|
"U_ADMIN_INDEX" => append_sid("index.$phpEx?pane=right"),
|
|
|
|
|
|
|
|
"L_BOARD_INDEX" => "Board Index",
|
|
|
|
"L_ADMIN_INDEX" => "Admin Index")
|
|
|
|
);
|
|
|
|
|
2001-07-13 17:03:04 +00:00
|
|
|
while( list($cat, $action_array) = each($module) )
|
2001-07-13 14:16:11 +00:00
|
|
|
{
|
2001-07-14 15:22:55 +00:00
|
|
|
$template->assign_block_vars("catrow", array(
|
|
|
|
"CATNAME" => $cat)
|
|
|
|
);
|
2001-07-27 23:29:58 +00:00
|
|
|
|
|
|
|
$row_count = 0;
|
2001-07-14 20:00:27 +00:00
|
|
|
while( list($action, $file) = each($action_array) )
|
2001-07-13 17:03:04 +00:00
|
|
|
{
|
2001-07-27 23:29:58 +00:00
|
|
|
$row_color = "#" . ( ( !($row_count%2) ) ? $theme['td_color1'] : $theme['td_color2']);
|
|
|
|
$row_class = ( !($row_count%2) ) ? $theme['td_class1'] : $theme['td_class2'];
|
|
|
|
|
2001-07-28 14:54:42 +00:00
|
|
|
$action = preg_replace("'_'", " ", $action);
|
|
|
|
|
2001-07-14 15:22:55 +00:00
|
|
|
$template->assign_block_vars("catrow.actionrow", array(
|
2001-07-27 23:29:58 +00:00
|
|
|
"ROW_COLOR" => $row_color,
|
|
|
|
"ROW_CLASS" => $row_class,
|
2001-07-14 20:00:27 +00:00
|
|
|
"ACTIONNAME" => $action,
|
|
|
|
"FILE" => $file)
|
2001-07-14 15:22:55 +00:00
|
|
|
);
|
2001-07-27 23:29:58 +00:00
|
|
|
$row_count++;
|
2001-07-13 17:03:04 +00:00
|
|
|
}
|
2001-07-13 14:16:11 +00:00
|
|
|
}
|
2001-07-14 20:00:27 +00:00
|
|
|
|
2001-07-14 15:22:55 +00:00
|
|
|
$template->pparse("body");
|
2001-07-13 14:16:11 +00:00
|
|
|
|
2001-07-27 23:29:58 +00:00
|
|
|
unset($setmodules);
|
2001-07-30 15:19:15 +00:00
|
|
|
exit;
|
2001-07-13 14:16:11 +00:00
|
|
|
}
|
2001-07-14 20:00:27 +00:00
|
|
|
elseif( $HTTP_GET_VARS['pane'] == 'right' )
|
2001-07-13 14:16:11 +00:00
|
|
|
{
|
|
|
|
|
2001-07-19 00:25:56 +00:00
|
|
|
include('page_header_admin.'.$phpEx);
|
2001-07-23 18:30:35 +00:00
|
|
|
|
2001-07-27 23:29:58 +00:00
|
|
|
$template->set_filenames(array(
|
2001-07-30 15:19:15 +00:00
|
|
|
"body" => "admin/index_body.tpl")
|
2001-07-27 23:29:58 +00:00
|
|
|
);
|
|
|
|
|
2001-07-28 14:54:42 +00:00
|
|
|
$template->assign_vars(array(
|
|
|
|
"L_WELCOME" => $lang['Welcome_phpBB'],
|
|
|
|
"L_ADMIN_INTRO" => $lang['Admin_intro'],
|
|
|
|
"L_FORUM_STATS" => $lang['Forum_stats'],
|
|
|
|
"L_WHO_IS_ONLINE" => $lang['Who_is_Online'],
|
|
|
|
"L_LOCATION" => $lang['Location'],
|
|
|
|
"L_LAST_UPDATE" => $lang['Last_updated'],
|
|
|
|
"L_IP_ADDRESS" => $lang['IP_Address'],
|
|
|
|
"L_STATISTIC" => $lang['Statistic'],
|
|
|
|
"L_VALUE" => $lang['Value'],
|
|
|
|
"L_NUMBER_POSTS" => $lang['Number_posts'],
|
|
|
|
"L_POSTS_PER_DAY" => $lang['Posts_per_day'],
|
|
|
|
"L_NUMBER_TOPICS" => $lang['Number_topics'],
|
|
|
|
"L_TOPICS_PER_DAY" => $lang['Topics_per_day'],
|
|
|
|
"L_NUMBER_USERS" => $lang['Number_users'],
|
|
|
|
"L_USERS_PER_DAY" => $lang['Users_per_day'],
|
|
|
|
"L_BOARD_STARTED" => $lang['Board_started'],
|
|
|
|
"L_AVATAR_DIR_SIZE" => $lang['Avatar_dir_size'],
|
|
|
|
"L_DB_SIZE" => $lang['Database_size'])
|
|
|
|
);
|
|
|
|
|
2001-07-27 23:29:58 +00:00
|
|
|
//
|
|
|
|
// Get forum statistics
|
|
|
|
//
|
|
|
|
$total_posts = get_db_stat('postcount');
|
|
|
|
$total_users = get_db_stat('usercount');
|
|
|
|
$total_topics = get_db_stat('topiccount');
|
|
|
|
|
2001-07-28 14:54:42 +00:00
|
|
|
$start_date = create_date($board_config['default_dateformat'], $board_config['board_startdate'], $board_config['default_timezone']);
|
|
|
|
|
|
|
|
$boarddays = (time() - $board_config['board_startdate']) / (24*60*60);
|
|
|
|
|
2001-07-28 14:56:33 +00:00
|
|
|
$posts_per_day = sprintf("%.2f", $total_posts / $boarddays);
|
|
|
|
$topics_per_day = sprintf("%.2f", $total_topics / $boarddays);
|
|
|
|
$users_per_day = sprintf("%.2f", $total_users / $boarddays);
|
|
|
|
|
2001-07-27 23:29:58 +00:00
|
|
|
$avatar_dir_size = 0;
|
|
|
|
|
2001-08-02 22:33:20 +00:00
|
|
|
if ($avatar_dir = @opendir($phpbb_root_path . $board_config['avatar_path']))
|
2001-07-27 23:29:58 +00:00
|
|
|
{
|
|
|
|
while($file = readdir($avatar_dir))
|
|
|
|
{
|
|
|
|
if($file != "." && $file != "..")
|
|
|
|
{
|
|
|
|
$avatar_dir_size += filesize($phpbb_root_path . $board_config['avatar_path'] . "/" . $file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir($avatar_dir);
|
|
|
|
}
|
2001-08-02 22:33:20 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Couldn't open Avatar dir.
|
|
|
|
$avatar_dir_size = '?';
|
|
|
|
}
|
2001-07-27 23:29:58 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// This bit of code translates the avatar directory size into human readable format
|
|
|
|
// Borrowed the code from the PHP.net annoted manual, origanally written by:
|
|
|
|
// Jesse (jesse@jess.on.ca)
|
|
|
|
//
|
|
|
|
if($avatar_dir_size >= 1048576)
|
|
|
|
{
|
|
|
|
$avatar_dir_size = round($avatar_dir_size / 1048576 * 100) / 100 . " MB";
|
|
|
|
}
|
|
|
|
else if($avatar_dir_size >= 1024)
|
|
|
|
{
|
|
|
|
$avatar_dir_size = round($avatar_dir_size / 1024 * 100) / 100 . " KB";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$avatar_dir_size = $avatar_dir_size . " Bytes";
|
|
|
|
}
|
|
|
|
|
|
|
|
if($posts_per_day > $total_posts)
|
|
|
|
{
|
|
|
|
$posts_per_day = $total_posts;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($topics_per_day > $total_topics)
|
|
|
|
{
|
|
|
|
$topics_per_day = $total_topics;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($users_per_day > $total_users)
|
|
|
|
{
|
|
|
|
$users_per_day = $total_users;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// DB size ... MySQL only
|
|
|
|
//
|
|
|
|
// This code is heavily influenced by a similar routine
|
|
|
|
// in phpMyAdmin 2.2.0
|
|
|
|
//
|
|
|
|
if(SQL_LAYER == 'mysql')
|
|
|
|
{
|
2001-08-17 16:08:18 +00:00
|
|
|
$sql = "SELECT VERSION() AS mysql_version";
|
|
|
|
if($result = $db->sql_query($sql))
|
2001-07-27 23:29:58 +00:00
|
|
|
{
|
2001-08-17 16:08:18 +00:00
|
|
|
list($version) = $db->sql_fetchrow($result);
|
|
|
|
if( ereg("^3\.23", $version) )
|
2001-07-27 23:29:58 +00:00
|
|
|
{
|
2001-08-17 16:08:18 +00:00
|
|
|
$sql = "SHOW TABLE STATUS FROM " . $dbname;
|
|
|
|
if(!$result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain table information.", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
$tabledata_ary = $db->sql_fetchrowset($result);
|
|
|
|
|
|
|
|
$dbsize = 0;
|
|
|
|
for($i = 0; $i < count($tabledata_ary); $i++)
|
|
|
|
{
|
|
|
|
if($tabledata_ary[$i]['Type'] != "MRG_MyISAM" && strstr($tabledata_ary[$i]['Name'], $table_prefix) )
|
|
|
|
{
|
|
|
|
$dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($dbsize >= 1048576)
|
|
|
|
{
|
|
|
|
$dbsize = sprintf("%.2f MB", ( $dbsize / 1048576 ));
|
|
|
|
}
|
|
|
|
else if($dbsize >= 1024)
|
|
|
|
{
|
|
|
|
$dbsize = sprintf("%.2f KB", ( $dbsize / 1024 ));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$dbsize = sprintf("%.2f Bytes", $dbsize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$dbsize = $lang['Not_available'];
|
2001-07-27 23:29:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-17 16:08:18 +00:00
|
|
|
$dbsize = $lang['Not_available'];
|
2001-07-27 23:29:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-28 14:54:42 +00:00
|
|
|
$dbsize = $lang['Not_available'];
|
2001-07-27 23:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"NUMBER_OF_POSTS" => $total_posts,
|
|
|
|
"NUMBER_OF_TOPICS" => $total_topics,
|
|
|
|
"NUMBER_OF_USERS" => $total_users,
|
|
|
|
"START_DATE" => $start_date,
|
|
|
|
"POSTS_PER_DAY" => $posts_per_day,
|
|
|
|
"TOPICS_PER_DAY" => $topics_per_day,
|
|
|
|
"USERS_PER_DAY" => $users_per_day,
|
|
|
|
"AVATAR_DIR_SIZE" => $avatar_dir_size,
|
|
|
|
"DB_SIZE" => $dbsize)
|
|
|
|
);
|
|
|
|
//
|
|
|
|
// End forum statistics
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get users online information.
|
|
|
|
//
|
|
|
|
$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, s.session_page, s.session_logged_in, s.session_time, s.session_ip
|
|
|
|
FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE . " s
|
|
|
|
WHERE u.user_id = s.session_user_id
|
|
|
|
AND s.session_time >= " . (time()-300) . "
|
|
|
|
ORDER BY s.session_time DESC";
|
|
|
|
if(!$result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain user/online information.", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
$onlinerow = $db->sql_fetchrowset($result);
|
|
|
|
|
|
|
|
$sql = "SELECT forum_name, forum_id
|
|
|
|
FROM " . FORUMS_TABLE;
|
|
|
|
if($forums_result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
while($forumsrow = $db->sql_fetchrow($forums_result))
|
|
|
|
{
|
|
|
|
$forum_data[$forumsrow['forum_id']] = $forumsrow['forum_name'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain user/online forums information.", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
$online_count = $db->sql_numrows($result);
|
|
|
|
if($online_count)
|
|
|
|
{
|
|
|
|
$count = 0;
|
|
|
|
|
|
|
|
for($i = 0; $i < $online_count; $i++)
|
|
|
|
{
|
|
|
|
if($onlinerow[$i]['user_id'] != ANONYMOUS)
|
|
|
|
{
|
|
|
|
if($onlinerow[$i]['session_logged_in'])
|
|
|
|
{
|
|
|
|
$username = $onlinerow[$i]['username'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$username = $onlinerow[$i]['username'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$username = $lang['Anonymous'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if($onlinerow[$i]['session_page'] < 1)
|
|
|
|
{
|
|
|
|
switch($onlinerow[$i]['session_page'])
|
|
|
|
{
|
|
|
|
case PAGE_INDEX:
|
|
|
|
$location = $lang['Forum_index'];
|
|
|
|
$location_url = "index.$phpEx";
|
|
|
|
break;
|
|
|
|
case PAGE_POSTING:
|
|
|
|
$location = $lang['Posting_message'];
|
|
|
|
$location_url = "index.$phpEx";
|
|
|
|
break;
|
|
|
|
case PAGE_LOGIN:
|
|
|
|
$location = $lang['Logging_on'];
|
|
|
|
$location_url = "index.$phpEx";
|
|
|
|
break;
|
|
|
|
case PAGE_SEARCH:
|
|
|
|
$location = $lang['Searching_forums'];
|
|
|
|
$location_url = "search.$phpEx";
|
|
|
|
break;
|
|
|
|
case PAGE_PROFILE:
|
|
|
|
$location = $lang['Viewing_profile'];
|
|
|
|
$location_url = "index.$phpEx";
|
|
|
|
break;
|
|
|
|
case PAGE_VIEWONLINE:
|
|
|
|
$location = $lang['Viewing_online'];
|
|
|
|
$location_url = "viewonline.$phpEx";
|
|
|
|
break;
|
|
|
|
case PAGE_VIEWMEMBERS:
|
|
|
|
$location = $lang['Viewing_member_list'];
|
|
|
|
$location_url = "memberlist.$phpEx";
|
|
|
|
break;
|
|
|
|
case PAGE_PRIVMSGS:
|
|
|
|
$location = $lang['Viewing_priv_msgs'];
|
|
|
|
$location_url = "privmsg.$phpEx";
|
|
|
|
break;
|
|
|
|
case PAGE_FAQ:
|
|
|
|
$location = $lang['Viewing_FAQ'];
|
|
|
|
$location_url = "faq.$phpEx";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$location = $lang['Forum_index'];
|
|
|
|
$location_url = "index.$phpEx";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$location_url = append_sid("admin_forum.$phpEx?" . POST_FORUM_URL . "=" . $onlinerow[$i]['session_page']);
|
|
|
|
$location = $forum_data[$onlinerow[$i]['session_page']];
|
|
|
|
}
|
|
|
|
|
|
|
|
$row_color = "#" . ( ( !($count % 2) ) ? $theme['td_color1'] : $theme['td_color2']);
|
|
|
|
$row_class = ( !($count % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
|
|
|
|
$count++;
|
|
|
|
|
|
|
|
$ip_address = decode_ip($onlinerow[$i]['session_ip']);
|
|
|
|
//
|
|
|
|
// This resolves the users IP to a host name, but it REALLY slows the page down
|
|
|
|
//
|
|
|
|
//$host_name = gethostbyaddr($ip_address);
|
|
|
|
//$ip_address = $ip_address . " ($host_name)";
|
|
|
|
|
|
|
|
if(empty($username))
|
|
|
|
{
|
|
|
|
$username = $lang['Guest'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_block_vars("userrow", array(
|
|
|
|
"ROW_COLOR" => $row_color,
|
|
|
|
"ROW_CLASS" => $row_class,
|
|
|
|
"USERNAME" => $username,
|
|
|
|
"LOGGED_ON" => $logged_on,
|
|
|
|
"LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow[$i]['session_time'], $board_config['default_timezone']),
|
|
|
|
"LOCATION" => $location,
|
2001-07-28 14:54:42 +00:00
|
|
|
"IP_ADDRESS" => $ip_address,
|
2001-07-27 23:29:58 +00:00
|
|
|
"U_USER_PROFILE" => append_sid("admin_user.$phpEx?" . POST_USERS_URL . "=" . $onlinerow[$i]['user_id']),
|
|
|
|
"U_FORUM_LOCATION" => append_sid($location_url))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->pparse("body");
|
|
|
|
|
2001-07-19 00:25:56 +00:00
|
|
|
include('page_footer_admin.'.$phpEx);
|
2001-07-13 14:16:11 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
2001-07-13 17:03:04 +00:00
|
|
|
{
|
2001-07-14 20:00:27 +00:00
|
|
|
//
|
|
|
|
// Generate frameset
|
|
|
|
//
|
|
|
|
$template->set_filenames(array(
|
|
|
|
"body" => "admin/index_frameset.tpl")
|
|
|
|
);
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"S_FRAME_NAV" => "index.$phpEx?pane=left",
|
2001-07-14 20:07:13 +00:00
|
|
|
"S_FRAME_MAIN" => "index.$phpEx?pane=right")
|
2001-07-14 20:00:27 +00:00
|
|
|
);
|
|
|
|
|
2001-07-28 14:54:42 +00:00
|
|
|
header ("Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
|
|
|
|
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
|
|
|
|
2001-07-14 20:00:27 +00:00
|
|
|
$template->pparse("body");
|
2001-07-13 17:03:04 +00:00
|
|
|
|
2001-07-14 20:00:27 +00:00
|
|
|
exit;
|
2001-07-13 14:16:11 +00:00
|
|
|
|
|
|
|
}
|
2001-02-17 08:37:32 +00:00
|
|
|
|
2001-08-26 14:35:39 +00:00
|
|
|
?>
|