}
 }
 //
 // If has been clicked the button configure
 //
 if (isset($HTTP_POST_VARS['configure']) || isset($HTTP_POST_VARS['show_begin_for'])) {
     if (isset($HTTP_POST_VARS['show_begin_for'])) {
         if ($sql = set_config('show_begin_for', $HTTP_POST_VARS['show_begin_for'])) {
             message_die(GENERAL_ERROR, 'Could not configure show begin for', '', __LINE__, __FILE__, $sql);
         }
     }
     if (isset($HTTP_POST_VARS['configure'])) {
         //
         // Update optimize database cronfiguration
         //
         if ($sql = set_config_arr(array('cron_enable', 'cron_every', 'cron_next', 'show_begin_for', 'show_not_optimized'), array($HTTP_POST_VARS['enable_optimize_cron'], $HTTP_POST_VARS['cron_every'], $current_time + $HTTP_POST_VARS['cron_every'], $HTTP_POST_VARS['show_begin_for'], $HTTP_POST_VARS['show_not_optimized']), array(0, 0, 1, 0, 0))) {
             message_die(GENERAL_ERROR, 'Could not set optimize database configuration', '', __LINE__, __FILE__, $sql);
         }
     }
 }
 //
 // If has been clicked the button optimize
 //
 if (!isset($HTTP_POST_VARS['optimize'])) {
     $sql = 'SHOW TABLE STATUS LIKE \'' . $board_config['show_begin_for'] . '%\' ';
     if (!($result = $db->sql_query($sql))) {
         message_die(GENERAL_ERROR, 'Couldn\'t obtain databases list', '', __LINE__, __FILE__, $sql);
     }
     $i = 0;
     while ($opt = $db->sql_fetchrow($result)) {
         if ($opt['Data_free'] != 0 || !$board_config['show_not_optimized']) {
if (!($result = $db->sql_query($sql))) {
    message_die(GENERAL_ERROR, 'Couldn\'t obtain list of tables', '', __LINE__, __FILE__, $sql);
}
//
// Optimize tables
//
$tables = array();
while ($table = $db->sql_fetchrow($result)) {
    if (intval($table['Data_free']) > 0) {
        $tables[] = $table['Name'];
    }
}
$db->sql_freeresult($result);
if (count($tables) > 0) {
    $sql = implode(', ', $tables);
    $sql = "OPTIMIZE TABLE {$sql}";
    if (!$db->sql_query($sql)) {
        message_die(GENERAL_ERROR, 'Couldn\'t optimize database', '', __LINE__, __FILE__, $sql);
    }
}
unset($tables);
if ($sql = set_config_arr(array('cron_next', 'cron_count'), array($current_time + $board_config['cron_every'], $board_config['cron_count'] + 1), array(1, 1))) {
    message_die(GENERAL_ERROR, 'Could not update optimize config', '', __LINE__, __FILE__, $sql);
}
ignore_user_abort($before_ignore);
//
// Unlock cron for contemporary accesses
//
if ($sql = set_config('cron_lock', 0, 1)) {
    message_die(GENERAL_ERROR, 'Could not unlock optimize database cron', '', __LINE__, __FILE__, $sql);
}