HEX
Server: Apache/2.4.59 (Debian)
System: Linux skycube.cz 4.19.0-25-amd64 #1 SMP Debian 4.19.289-2 (2023-08-08) x86_64
User: ilya (534)
PHP: 7.3.31-1~deb10u7
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
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;
	}
	
	
}
?>