punbb/admin_index.php
changeset 2 a8a21e1c7afa
parent 0 f9ffdbd96607
equal deleted inserted replaced
1:8f6143115bf5 2:a8a21e1c7afa
    24 
    24 
    25 
    25 
    26 // Tell header.php to use the admin template
    26 // Tell header.php to use the admin template
    27 define('PUN_ADMIN_CONSOLE', 1);
    27 define('PUN_ADMIN_CONSOLE', 1);
    28 
    28 
    29 define('PUN_ROOT', './');
    29 //define('PUN_ROOT', './');
    30 require PUN_ROOT.'include/common.php';
    30 //require PUN_ROOT.'include/common.php';
       
    31 
       
    32 global $pun_db, $pun_user, $pun_config, $lang_common;
       
    33 
    31 require PUN_ROOT.'include/common_admin.php';
    34 require PUN_ROOT.'include/common_admin.php';
    32 
    35 
    33 
    36 
    34 if ($pun_user['g_id'] > PUN_MOD)
    37 if ($pun_user['g_id'] < PUN_MOD)
    35 	message($lang_common['No permission']);
    38 	message($lang_common['No permission']);
    36 
    39 
    37 
    40 
    38 $action = isset($_GET['action']) ? $_GET['action'] : null;
    41 $action = isset($_GET['action']) ? $_GET['action'] : null;
    39 
    42 
    91 else
    94 else
    92 	$server_load = 'Not available';
    95 	$server_load = 'Not available';
    93 
    96 
    94 
    97 
    95 // Get number of current visitors
    98 // Get number of current visitors
    96 $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());
    99 $result = $pun_db->query('SELECT COUNT(user_id) FROM '.$pun_db->prefix.'online WHERE idle=0') or error('Unable to fetch online count', __FILE__, __LINE__, $pun_db->error());
    97 $num_online = $db->result($result);
   100 $num_online = $pun_db->result($result);
    98 
   101 
    99 
   102 
   100 // Get the database system version
   103 // Get the database system version
   101 switch ($db_type)
   104 switch ($db_type)
   102 {
   105 {
   103 	case 'sqlite':
   106 	case 'sqlite':
   104 		$db_version = 'SQLite '.sqlite_libversion();
   107 		$db_version = 'SQLite '.sqlite_libversion();
   105 		break;
   108 		break;
   106 
   109 
   107 	default:
   110 	default:
   108 		$result = $db->query('SELECT VERSION()') or error('Unable to fetch version info', __FILE__, __LINE__, $db->error());
   111 		$result = $pun_db->query('SELECT VERSION()') or error('Unable to fetch version info', __FILE__, __LINE__, $pun_db->error());
   109 		$db_version = $db->result($result);
   112 		$db_version = $pun_db->result($result);
   110 		break;
   113 		break;
   111 }
   114 }
   112 
   115 
   113 
   116 
   114 // Collect some additional info about MySQL
   117 // Collect some additional info about MySQL
   115 if ($db_type == 'mysql' || $db_type == 'mysqli')
   118 if ($db_type == 'mysql' || $db_type == 'mysqli')
   116 {
   119 {
   117 	$db_version = 'MySQL '.$db_version;
   120 	$db_version = 'MySQL '.$db_version;
   118 
   121 
   119 	// Calculate total db size/row count
   122 	// Calculate total db size/row count
   120 	$result = $db->query('SHOW TABLE STATUS FROM `'.$db_name.'`') or error('Unable to fetch table status', __FILE__, __LINE__, $db->error());
   123 	$result = $pun_db->query('SHOW TABLE STATUS FROM `'.$db_name.'`') or error('Unable to fetch table status', __FILE__, __LINE__, $pun_db->error());
   121 
   124 
   122 	$total_records = $total_size = 0;
   125 	$total_records = $total_size = 0;
   123 	while ($status = $db->fetch_assoc($result))
   126 	while ($status = $pun_db->fetch_assoc($result))
   124 	{
   127 	{
   125 		$total_records += $status['Rows'];
   128 		$total_records += $status['Rows'];
   126 		$total_size += $status['Data_length'] + $status['Index_length'];
   129 		$total_size += $status['Data_length'] + $status['Index_length'];
   127 	}
   130 	}
   128 
   131