Admin "welcome" screen functions
| > Module written by Matt Mecham
| > Date started: 1st march 2002
|
| > Module Version Number: 1.0.0
| > DBA Checked: Tue 25th May 2004
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_ACP' ) )
{
print "
Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
class ad_index {
var $mysql_version = "";
function auto_run()
{
global $DB, $std, $ibforums;
//-----------------------------------------
// Kill globals - globals bad, Homer good.
//-----------------------------------------
$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
foreach ( $tmp_in as $k => $v )
{
unset($$k);
}
//-----------------------------------------
$ibforums->admin->page_title = "Welcome to the Invision Power Board Administration CP";
$ibforums->admin->page_detail = "Clicking on one of the links in the left menu pane will show you the relevant options for that administration category. Each option will contain further information on configuration, etc.";
//-----------------------------------------
// Get MySQL & PHP Version
//-----------------------------------------
$DB->sql_get_version();
$phpv = phpversion();
$phpmethod = @php_sapi_name();
//-----------------------------------------
// Upgrade history?
//-----------------------------------------
$upgrade_history = array();
$latest_version = array();
$DB->simple_construct( array( 'select' => '*', 'from' => 'upgrade_history', 'order' => 'upgrade_version_id DESC' ) );
$DB->simple_exec();
while( $r = $DB->fetch_row() )
{
if ( $r['upgrade_version_id'] > $latest_version['upgrade_version_id'] )
{
$latest_version = $r;
}
$upgrade_history[] = $r;
}
//-----------------------------------------
// Got reg code?
//-----------------------------------------
$reg_html = "";
$reg_end = "";
//-----------------------------------------
// Got real version number?
//-----------------------------------------
if ( $ibforums->version == 'v2.0.0 ' )
{
$ibforums->version = 'v'.$latest_version['upgrade_version_human'];
}
if ( $ibforums->acpversion == '20010' )
{
$ibforums->acpversion = $latest_version['upgrade_version_id'];
}
$version_info = "
PHP VERSION: $phpv ($phpmethod), SQL: (".strtoupper(SQL_DRIVER).") ".$DB->true_version."
IPB Version {$ibforums->version} (ID: {$ibforums->acpversion})";
if ( $ibforums->vars['ipb_reg_number'] )
{
list( $a, $b, $c, $d, $e ) = explode( '-', $ibforums->vars['ipb_reg_number'] );
if ( strlen($e) > 9 )
{
$reg_end = "Registered until: ". $ibforums->admin->get_date( $e, 'SHORT' )." ";
}
else
{
$reg_end = "Registered for life";
}
$reg_html = "
Registered Invision Power Board
Thank you for registering your Invision Power Board!
Please visit your
client area for news, updates and support.
$reg_end
";
}
else
{
$reg_html = "
Unregistered Invision Power Board
This copy of Invision Power Board is unregistered.
Why register?
click here to find out!
Go on,
register today! you know it makes sense!
";
}
//-----------------------------------------
// Notepad
//-----------------------------------------
if ( $ibforums->input['save'] == 1 )
{
$DB->do_update( 'cache_store', array( 'cs_value' => $std->txt_stripslashes($_POST['notes']) ), "cs_key='adminnotes'" );
}
$text = "You can use this section to keep notes for yourself and other admins, etc.";
$DB->simple_construct( array( 'select' => '*', 'from' => 'cache_store', 'where' => "cs_key='adminnotes'" ) );
$DB->simple_exec();
if ( ! $notes = $DB->fetch_row() )
{
$DB->do_insert( 'cache_store', array( 'cs_key' => 'adminnotes', 'cs_value' => $text ) );
$notes = array( 'cs_key' => 'adminnotes', 'cs_value' => $text );
}
$ad_notes = "";
//-----------------------------------------
// Printy-poos
//-----------------------------------------
$ibforums->html .= "
{$ad_notes}
{$version_info} {$reg_html}
\n";
//-----------------------------------------
// Make sure the uploads path is correct
//-----------------------------------------
$uploads_size = 0;
if ($dh = opendir( $ibforums->vars['upload_dir'] ))
{
while ( $file = readdir( $dh ) )
{
if ( !preg_match( "/^..?$|^index/i", $file ) )
{
$uploads_size += @filesize( $ibforums->vars['upload_dir'] . "/" . $file );
}
}
closedir( $dh );
}
// This piece of code from Jesse's (jesse@jess.on.ca) contribution
// to the PHP manual @ php.net
if ($uploads_size >= 1048576)
{
$uploads_size = round($uploads_size / 1048576 * 100 ) / 100 . " mb";
}
else if ($uploads_size >= 1024)
{
$uploads_size = round($uploads_size / 1024 * 100 ) / 100 . " k";
}
else
{
$uploads_size = $uploads_size . " bytes";
}
//-----------------------------------------
// Trashed skin?
//-----------------------------------------
$skinmsg = $DB->simple_exec_query( array( "select" => '*', 'from' => "cache_store", "where" => "cs_key='skinpanic'" ) );
if ( $skinmsg['cs_value'] == 'rebuildemergency' )
{
$ibforums->html .= "
Warning: A Skin error occured
Either you or one of your members encountered a skin error. The following took place
automatically:
They were asked to clear their skin settings
They were asked to click a link to attempt access in the ACP
The ACP picked up the skin error and rebuilt the skin ID cache, the default skin and it may have turned on safe mode skins
What to do now
Firstly, if you don't wish to use safe mode skins, check the CHMOD value of the 'skin_cache' directory to make sure IPB can write into that directory
If the permissions are correct, check your 'System Settings -> General Configuration' settings to check the value of 'Safe Mode Skins' - disable if not required
As a precaution, rebuild all your skins by following the link below
>> REBUILD ALL SKIN CACHES & REMOVE THIS WARNING <<
";
}
if ( $skinmsg['cs_value'] == 'rebuildupgrade' )
{
$ibforums->html .= " ";
}
//-----------------------------------------
// INSTALLER PRESENT?
//-----------------------------------------
$sm_install = 0;
$lock_file = 0;
if ( @file_exists( ROOT_PATH . 'sm_install.php' ) )
{
$sm_install = 1;
}
if ( @file_exists( ROOT_PATH . 'install.lock' ) )
{
$lock_file = 1;
}
if ( $sm_install == 1 )
{
if ( $lock_file != 1 )
{
$ibforums->html .= "
Warning: Unlocked Installer Still Present
Remove sm_install.php from your server at once!
Leaving it on your server WILL compromise the security of your system.
";
}
else
{
$ibforums->html .= "
Warning: Installer Still Present
Although the installer appears to be locked, we recommend you remove it
from your server for security.
Simply remove sm_install.php from your installation to remove this message.
";
}
}
//-----------------------------------------
// BOARD OFFLINE?
//-----------------------------------------
if ($ibforums->vars['board_offline'])
{
$ibforums->adskin->td_header[] = array( " ", "100%" );
$ibforums->html .= $ibforums->adskin->start_table( "Offline Notice" );
$ibforums->html .= $ibforums->adskin->add_td_row( array( "Your board is currently offline » Turn Board Online "
) );
$ibforums->html .= $ibforums->adskin->end_table();
$ibforums->html .= $ibforums->adskin->add_td_spacer();
}
//-----------------------------------------
// Quick clicks + Upgrade History
//-----------------------------------------
$ibforums->html .= "
";
$ibforums->html .= $ibforums->adskin->start_form();
$ibforums->adskin->td_header[] = array( "{none}" , "30%" );
$ibforums->adskin->td_header[] = array( "{none}" , "40%" );
$ibforums->adskin->td_header[] = array( "{none}" , "30%" );
$ibforums->html .= $ibforums->adskin->start_table( "Quick Clicks" );
$ibforums->html .= "
";
$ibforums->html .= $ibforums->adskin->add_td_row( array( "Edit Member:",
" ",
" "
) );
$ibforums->html .= $ibforums->adskin->add_td_row( array( "Add New Forum:",
" ",
" "
) );
$ibforums->html .= $ibforums->adskin->add_td_row( array( "PHP Function:",
" ",
" "
) );
$ibforums->html .= " ";
$ibforums->html .= $ibforums->adskin->end_table();
$ibforums->html .= "
";
$ibforums->adskin->td_header[] = array( "{none}" , "40%" );
$ibforums->adskin->td_header[] = array( "{none}" , "60%" );
$ibforums->html .= $ibforums->adskin->start_table( "Upgrade History" );
foreach( $upgrade_history as $r )
{
$ibforums->html .= $ibforums->adskin->add_td_row( array( $r['upgrade_version_human'] .' ('.$r['upgrade_version_id'].')',
$std->get_date( $r['upgrade_date'], 'SHORT' )
) );
}
$ibforums->html .= $ibforums->adskin->end_table();
$ibforums->html .= "
";
//-----------------------------------------
// ADMINS USING CP
//-----------------------------------------
$ibforums->adskin->td_header[] = array( "Name" , "20%" );
$ibforums->adskin->td_header[] = array( "IP Address" , "20%" );
$ibforums->adskin->td_header[] = array( "Log In" , "20%" );
$ibforums->adskin->td_header[] = array( "Last Click" , "20%" );
$ibforums->adskin->td_header[] = array( "Location" , "20%" );
$ibforums->html .= $ibforums->adskin->start_table( "Administrators using the CP" );
$t_time = time() - 60*10;
$DB->simple_construct( array( 'select' => 'session_member_name, session_location, session_log_in_time, session_running_time, session_ip_address',
'from' => 'admin_sessions',
'where' => "session_running_time > $t_time" ) );
$DB->simple_exec();
$time_now = time();
$seen_name = array();
while ( $r = $DB->fetch_row() )
{
if ( $seen_name[ $r['session_member_name'] ] == 1 )
{
continue;
}
else
{
$seen_name[ $r['session_member_name'] ] = 1;
}
$log_in = $time_now - $r['session_log_in_time'];
$click = $time_now - $r['session_running_time'];
if ( ($log_in / 60) < 1 )
{
$log_in = sprintf("%0d", $log_in) . " seconds ago";
}
else
{
$log_in = sprintf("%0d", ($log_in / 60) ) . " minutes ago";
}
if ( ($click / 60) < 1 )
{
$click = sprintf("%0d", $click) . " seconds ago";
}
else
{
$click = sprintf("%0d", ($click / 60) ) . " minutes ago";
}
$ibforums->html .= $ibforums->adskin->add_td_row( array (
$r['session_member_name'],
"".$r['session_ip_address']." ",
"".$log_in." ",
"".$click." ",
"".$r['session_location']." ",
) );
}
$ibforums->html .= $ibforums->adskin->end_table();
//-----------------------------------------
$ibforums->html .= $ibforums->adskin->add_td_spacer();
//-----------------------------------------
if ($ibforums->member['mgroup'] == $ibforums->vars['admin_group'])
{
//-----------------------------------------
// LAST 5 Admin Actions
//-----------------------------------------
$ibforums->adskin->td_header[] = array( "Member Name" , "20%" );
$ibforums->adskin->td_header[] = array( "Action Performed" , "40%" );
$ibforums->adskin->td_header[] = array( "Time of action" , "20%" );
$ibforums->adskin->td_header[] = array( "IP address" , "20%" );
$ibforums->html .= $ibforums->adskin->start_table( "Last 5 Admin Actions" );
$DB->cache_add_query( 'index_admin_logs', array() );
$DB->cache_exec_query();
if ( $DB->get_num_rows() )
{
while ( $rowb = $DB->fetch_row() )
{
$rowb['ctime'] = $ibforums->admin->get_date( $rowb['ctime'] );
$ibforums->html .= $ibforums->adskin->add_td_row( array( "{$rowb['name']} ",
"{$rowb['note']}",
"{$rowb['ctime']}",
"{$rowb['ip_address']}",
) );
}
}
else
{
$ibforums->html .= $ibforums->adskin->add_td_basic("No results ");
}
$ibforums->html .= $ibforums->adskin->end_table();
//-----------------------------------------
$ibforums->html .= $ibforums->adskin->add_td_spacer();
}
//-----------------------------------------
// Bots stuff
//-----------------------------------------
if ( $ibforums->vars['spider_sense'] )
{
//-----------------------------------------
// Get bot names
//-----------------------------------------
foreach( explode( "\n", $ibforums->vars['search_engine_bots'] ) as $bot )
{
list($ua, $n) = explode( "=", $bot );
$this->bot_map[ strtolower($ua) ] = $n;
}
$ibforums->adskin->td_header[] = array( "Search Bot" , "20%" );
$ibforums->adskin->td_header[] = array( "Date" , "25%" );
$ibforums->adskin->td_header[] = array( "Query" , "20%" );
$ibforums->adskin->td_header[] = array( "Query" , "35%" );
$ibforums->html .= $ibforums->adskin->start_table( "Last 10 Search Engine Spiders Hits" );
$DB->simple_construct( array( 'select' => '*', 'from' => 'spider_logs', 'order' => 'entry_date DESC', 'limit' => array( 0,10) ) );
$DB->simple_exec();
while ( $r = $DB->fetch_row() )
{
$ibforums->html .= $ibforums->adskin->add_td_row( array( "".$this->bot_map[ strtolower($r['bot']) ]." ",
$ibforums->admin->get_date( $r['entry_date'], 'SHORT' ),
$r['ip_address'].' ',
$r['query_string'].' '
) );
}
$ibforums->html .= $ibforums->adskin->end_table();
$ibforums->html .= $ibforums->adskin->add_td_spacer();
}
//-----------------------------------------
// Stats
//-----------------------------------------
$reg = $DB->simple_exec_query( array( 'select' => 'COUNT(*) as reg', 'from' => 'validating', 'where' => 'lost_pass <> 1' ) );
$reg['reg'] = intval( $reg['reg'] );
$coppa = $DB->simple_exec_query( array( 'select' => 'COUNT(*) as coppa', 'from' => 'validating', 'where' => 'coppa_user=1' ) );
$coppa['coppa'] = intval( $coppa['coppa'] );
$ibforums->adskin->td_header[] = array( "Definition", "25%" );
$ibforums->adskin->td_header[] = array( "Value" , "25%" );
$ibforums->adskin->td_header[] = array( "Definition", "25%" );
$ibforums->adskin->td_header[] = array( "Value" , "25%" );
$ibforums->html .= $ibforums->adskin->start_table( "System Overview" );
$ibforums->html .= $ibforums->adskin->add_td_row( array( "Total Unique Topics" , intval($ibforums->cache['stats']['total_topics']),
"Total Replies to topics", intval($ibforums->cache['stats']['total_replies']),
) );
$ibforums->html .= $ibforums->adskin->add_td_row( array( "Total Members", intval($ibforums->cache['stats']['mem_count']), "Public Upload Folder Size", $uploads_size ) );
$ibforums->html .= $ibforums->adskin->add_td_row( array( "Users awaiting validation " , $reg['reg'],
"COPPA Requests from 'Users awaiting validation' total", $coppa['coppa'],
) );
$ibforums->html .= $ibforums->adskin->end_table();
$ibforums->admin->output();
}
}
?>