exit; } //- Import a file into an existing database if (isset($_POST['import'])) { $db = new Database($_SESSION[COOKIENAME . 'currentDB']); $db->registerUserFunction($custom_functions); if ($_POST['import_type'] == "sql") { $data = file_get_contents($_FILES["file"]["tmp_name"]); $importSuccess = $db->import_sql($data); } else { $field_terminate = $_POST['import_csv_fieldsterminated']; $field_enclosed = $_POST['import_csv_fieldsenclosed']; $field_escaped = $_POST['import_csv_fieldsescaped']; $null = $_POST['import_csv_replacenull']; $fields_in_first_row = isset($_POST['import_csv_fieldnames']); $importSuccess = $db->import_csv($_FILES["file"]["tmp_name"], $_POST['single_table'], $field_terminate, $field_enclosed, $field_escaped, $null, $fields_in_first_row); } } //- Download (backup) a database file (as SQLite file, not as dump) if (isset($_GET['download']) && isManagedDB($_GET['download']) !== false) { header("Content-type: application/octet-stream"); header('Content-Disposition: attachment; filename="' . basename($_GET['download']) . '";'); header("Pragma: no-cache"); header("Expires: 0"); readfile($_GET['download']); exit; } } //- HTML: output starts here header('Content-Type: text/html; charset=utf-8'); ?>
$crlf = isset($_POST['export_csv_crlf']); $fields_in_first_row = isset($_POST['export_csv_fieldnames']); $db = new Database($databases[$_SESSION[COOKIENAME . 'currentDB']]); echo $db->export_csv($tables, $field_terminate, $field_enclosed, $field_escaped, $line_terminated, $null, $crlf, $fields_in_first_row); } } exit; } //user is importing a file if (isset($_POST['import'])) { $db = new Database($databases[$_SESSION[COOKIENAME . 'currentDB']]); if ($_POST['import_type'] == "sql") { $data = file_get_contents($_FILES["file"]["tmp_name"]); $importSuccess = $db->import_sql($data); } else { $importSuccess = $db->import_csv($_FILES["file"]["tmp_name"], $_POST['import_csv_separator'], $_POST['single_table']); } } // here begins the HTML. ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <!-- Copyright 2011 phpLiteAdmin (http://phpliteadmin.googlecode.com) --> <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /> <title><?php echo PROJECT; ?> </title> <?php