/** * List all backups, i.e. all files ending in .sql * * @return string HTML for the list of files or an error when not writable * */ function listbackups() { global $_CONF, $_TABLES, $_IMAGE_TYPE, $LANG08, $LANG_ADMIN, $LANG_DB_BACKUP, $_DB_dbms; require_once $_CONF['path_system'] . 'lib-admin.php'; $retval = ''; if (is_writable($_CONF['backup_path'])) { $backups = array(); $fd = opendir($_CONF['backup_path']); $index = 0; while (false !== ($file = @readdir($fd))) { if ($file != '.' && $file != '..' && $file != 'CVS' && preg_match('/\\.sql$/i', $file)) { $index++; clearstatcache(); $backups[] = $file; } } // AS, 2004-03-29 - Sort backup files by date, newest first. // Order given by 'readdir' might not be correct. usort($backups, 'compareBackupFiles'); $data_arr = array(); $thisUrl = $_CONF['site_admin_url'] . '/database.php'; $num_backups = count($backups); for ($i = 0; $i < $num_backups; $i++) { $downloadUrl = $thisUrl . '?mode=download&file=' . urlencode($backups[$i]); $downloadLink = COM_createLink($backups[$i], $downloadUrl, array('title' => $LANG_DB_BACKUP['download'])); $backupfile = $_CONF['backup_path'] . $backups[$i]; $backupfilesize = COM_numberFormat(filesizeHelper($backupfile)) . ' <b>' . $LANG_DB_BACKUP['bytes'] . '</b>'; $data_arr[$i] = array('file' => $downloadLink, 'size' => $backupfilesize, 'filename' => $backups[$i]); } $token = SEC_createToken(); $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/database.php?mode=backup&' . CSRF_TOKEN . '=' . $token, 'text' => $LANG_ADMIN['create_new'])); if ($_DB_dbms == 'mysql') { $menu_arr[] = array('url' => $thisUrl . '?mode=optimize', 'text' => $LANG_DB_BACKUP['optimize_menu']); if (innodb_supported()) { $menu_arr[] = array('url' => $thisUrl . '?mode=innodb', 'text' => $LANG_DB_BACKUP['convert_menu']); } } $menu_arr[] = array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']); $retval .= COM_startBlock($LANG_DB_BACKUP['last_ten_backups'], '', COM_getBlockTemplate('_admin_block', 'header')); $retval .= ADMIN_createMenu($menu_arr, "<p>{$LANG_DB_BACKUP['db_explanation']}</p>" . '<p>' . sprintf($LANG_DB_BACKUP['total_number'], $index) . '</p>', $_CONF['layout_url'] . '/images/icons/database.' . $_IMAGE_TYPE); $header_arr = array(array('text' => $LANG_DB_BACKUP['backup_file'], 'field' => 'file'), array('text' => $LANG_DB_BACKUP['size'], 'field' => 'size')); $text_arr = array('form_url' => $thisUrl); $form_arr = array('bottom' => '', 'top' => ''); if ($num_backups > 0) { $form_arr['bottom'] = '<input type="hidden" name="mode" value="delete"' . XHTML . '>' . '<input type="hidden" name="' . CSRF_TOKEN . '" value="' . $token . '"' . XHTML . '>' . LB; } $listoptions = array('chkdelete' => true, 'chkminimum' => 0, 'chkfield' => 'filename'); $retval .= ADMIN_simpleList('', $header_arr, $text_arr, $data_arr, $listoptions, $form_arr); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); } else { $retval .= COM_showMessageText($LANG_DB_BACKUP['no_access'], $LANG08[06]); COM_errorLog($_CONF['backup_path'] . ' is not writable.', 1); } return $retval; }
*/ function innodb_supported() { $result = DB_query("SHOW VARIABLES LIKE 'have_innodb'"); $A = DB_fetchArray($result, true); if (strcasecmp($A[1], 'yes') == 0) { $retval = true; } else { $retval = false; } return $retval; } // MAIN echo COM_siteHeader('menu'); echo COM_startBlock('Changing tables to InnoDB'); if (innodb_supported()) { echo '<p>This may take a while ...</p>' . LB; flush(); $opt_time = new timerobject(); $opt_time->startTimer(); $result = DB_query("SHOW TABLES"); $numTables = DB_numRows($result); for ($i = 0; $i < $numTables; $i++) { $A = DB_fetchArray($result, true); if (in_array($A[0], $_TABLES)) { DB_query("ALTER TABLE {$A['0']} TYPE=InnoDB"); } } $exectime = $opt_time->stopTimer(); echo '<p>Changing ' . sizeof($_TABLES) . ' tables to InnoDB took ' . $exectime . ' seconds.<p>' . LB; } else {