Example #1
0
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
global $Plugins, $template_action, $admin_url;
$block_item_Widget = new Widget('block_item');
if (!empty($template_action)) {
    // Execute action inside template to display a process in real rime
    $block_item_Widget->title = T_('Log');
    $block_item_Widget->disp_template_replaced('block_start');
    // Turn off the output buffering to do the correct work of the function flush()
    @ini_set('output_buffering', 'off');
    evo_flush();
    switch ($template_action) {
        case 'optimize_tables':
            // Optimize MyISAM & InnoDB tables
            dbm_optimize_tables();
            break;
        case 'check_tables':
            // Check ALL database tables
            dbm_check_tables();
            break;
        case 'analyze_tables':
            // Analize ALL database tables
            dbm_analyze_tables();
            break;
        case 'delete_orphan_files':
            // delete orphan File objects with no matching file on disk
            dbm_delete_orphan_files();
            break;
        case 'delete_orphan_file_roots':
            // delete orphan file roots with no matching Blog or User entry in the database
 *
 * @version $Id: _heavy_db_maintenance.job.php 9 2011-10-24 22:32:00Z fplanque $
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
global $dbm_tables_count;
load_funcs('tools/model/_dbmaintenance.funcs.php');
$simple_keys = array(0, 1, 2, 3);
$failed_results = array();
// Execute query to get results of CHECK command
$results = dbm_check_tables(false, false);
foreach ($results as $result) {
    if ($result->Msg_type != 'status') {
        // Add different result types then 'status' to the failed resulsts array, so they can be display on the cron task view
        // Convert keys to simple integer values to decrease a size of the data
        $failed_results[] = array_combine($simple_keys, (array) $result);
    }
}
// Optimize MyISAM & InnoDB tables
$results = dbm_optimize_tables(false, false);
foreach ($results as $result) {
    if ($result->Msg_text != 'OK' && !($result->Msg_type == 'note' && $result->Msg_text == 'Table does not support optimize, doing recreate + analyze instead')) {
        // Save only results which are not OK and they are different notes then 'Table does not support optimize ...' because that is normal for innoDb tables
        // Convert keys to simple integer values to decrease a size of the data
        $failed_results[] = array_combine($simple_keys, (array) $result);
    }
}
$result_message = array('message' => sprintf(T_('The commands CHECK & OPTIMIZE have been executed for all %d tables.'), $dbm_tables_count), 'table_cols' => array(T_('Table'), T_('Operation'), T_('Result'), T_('Message ')), 'table_data' => $failed_results);
return 1;
/* ok */