You are here

function dba_verify_backup_form_submit in Database Administration 5

File

./dba.module, line 1209
Allows administrators direct access to their Drupal database. Written by Jeremy Andrews <jeremy@kerneltrap.org>, June 2004. PostgreSQL functionality provided by AAM <aam@ugpl.de> Major security audit, porting, and maintenance by Derek…

Code

function dba_verify_backup_form_submit($form_id, $form_values) {
  unset($_SESSION['dba_tables']);
  if (is_array($form_values['tables'])) {
    $tables = $form_values['tables'];
  }
  else {
    $tables = explode(',', $form_values['tables']);
  }
  $file_name = $form_values['file_name'];
  if (user_access('dba administer database')) {
    $database = dba_get_database();
    Header("Content-type: application/octet-stream");
    Header("Content-Disposition: attachment; filename=" . $file_name);
    echo "-- Drupal dba.module database dump\n";
    echo "--\n";
    echo "-- Database: {$database}\n";
    echo "-- Date: " . format_date(time(), 'large') . "\n\n";
    foreach ($tables as $table) {
      dba_backup_table($table, $form_values['add_drop_table']);
    }
    $quantity = count($tables);
    $display = implode(', ', $tables);
    drupal_set_message(t("Saved %tables to %filename.", array(
      '%filename' => $file_name,
      '%tables' => $display,
    )));
    exit(0);
  }
}