File: /var/www/ilya/data/www/kamforum.ru/sources/tasks/db_optimizer.php
<?php
/*
+--------------------------------------------------------------------------
| Invision Power Board v2.1.x DB Optimizer Task
| =============================================
| by .silent
+---------------------------------------------------------------------------
|
| > TASK SCRIPT: Optimize forum database tables
| > Script written by .silent
| > Date started: 08st March 2006 (09:35)
|
+--------------------------------------------------------------------------
*/
//-----------------------------------------
// THIS TASKS OPERATIONS:
// Optimize database tables
//+----------------------------------------
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class task_item
{
var $class = "";
var $root_path = "";
var $task = "";
/*-------------------------------------------------------------------------*/
// Our 'auto_run' function
// ADD CODE HERE
/*-------------------------------------------------------------------------*/
function run_task()
{
$tableNames = $this->ipsclass->DB->get_table_names();
if ( count( $tableNames ) )
{
$brokenTables = array();
$this->ipsclass->DB->query( "CHECK TABLE ".implode( ",", $tableNames )." EXTENDED" );
while ( $tableStatus = $this->ipsclass->DB->fetch_row() )
if ( ( $tableStatus['Msg_text'] != "OK" ) and ( $tableStatus['Msg_type'] != "status" ) )
if ( !in_array( str_replace( $this->ipsclass->DB->obj['sql_database'].".", "", $tableStatus['Table'] ), $brokenTables ) )
$brokenTables[] = str_replace( $this->ipsclass->DB->obj['sql_database'].".", "", $tableStatus['Table'] );
if ( count( $brokenTables ) )
$this->ipsclass->DB->query( "REPAIR TABLE ".implode( ",", $brokenTables ) );
$this->ipsclass->DB->query( "OPTIMIZE TABLE ".implode( ",", $tableNames ) );
//-----------------------------------------
// Log to log table - modify but dont delete
//-----------------------------------------
$this->class->append_task_log( $this->task, 'Forum database optimization was completed successefully' );
}
//-----------------------------------------
// Unlock Task: DO NOT MODIFY!
//-----------------------------------------
$this->class->unlock_task( $this->task );
}
/*-------------------------------------------------------------------------*/
// register_class
// LEAVE ALONE
/*-------------------------------------------------------------------------*/
function register_class(&$class)
{
$this->class = $class;
$this->ipsclass =& $class->ipsclass;
$this->root_path = $this->class->root_path;
}
/*-------------------------------------------------------------------------*/
// pass_task
// LEAVE ALONE
/*-------------------------------------------------------------------------*/
function pass_task( $this_task )
{
$this->task = $this_task;
}
}
?>