/* $Id: db_create.php,v 1.14 2001/11/23 01:03:19 loic1 Exp $ */ /** * Gets some core libraries */ require './libraries/grab_globals.lib.php'; $js_to_run = 'functions.js'; require './header.inc.php'; /** * Defines the url to return to in case of error in a sql statement */ $err_url = 'main.php' . '?lang=' . $lang . '&server=' . $server; /** * Ensures the db name is valid */ if (get_magic_quotes_gpc()) { $db = stripslashes($db); } if (PMA_MYSQL_INT_VERSION < 32306) { PMA_checkReservedWords($db, $err_url); } /** * Executes the db creation sql query */ $local_query = 'CREATE DATABASE ' . PMA_backquote($db); $result = mysql_query('CREATE DATABASE ' . PMA_backquote($db)) or PMA_mysqlDie('', $local_query, FALSE, $err_url); /** * Displays the result and moves back to the calling page */ $message = $strDatabase . ' ' . htmlspecialchars($db) . ' ' . $strHasBeenCreated; require './db_details.php';
$sql_query = $query_cpy . ';'; unset($query_cpy); $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenCreated; include './tbl_properties.php'; exit; } else { if (isset($num_fields)) { $num_fields = intval($num_fields); } // No table name if (!isset($table) || trim($table) == '') { PMA_mysqlDie($strTableEmpty, '', '', $err_url); } else { if (empty($num_fields) || !is_int($num_fields)) { PMA_mysqlDie($strFieldsEmpty, '', '', $err_url); } else { // Ensures the table name is valid if (get_magic_quotes_gpc()) { $table = stripslashes($table); } if (PMA_MYSQL_INT_VERSION < 32306) { PMA_checkReservedWords($table, $err_url); } $action = 'tbl_create.php'; include './tbl_properties.inc.php'; // Diplays the footer echo "\n"; include './footer.inc.php'; } } }
$asfile = 1; if (get_magic_quotes_gpc()) { if (!empty($target_db)) { $target_db = stripslashes($target_db); } else { $target_db = stripslashes($db); } $new_name = stripslashes($new_name); } // Ensure the target is valid if (count($dblist) > 0 && (PMA_isInto($db, $dblist) == -1 || PMA_isInto($target_db, $dblist) == -1)) { exit; } if (PMA_MYSQL_INT_VERSION < 32306) { PMA_checkReservedWords($target_db, $err_url); PMA_checkReservedWords($new_name, $err_url); } $source = PMA_backquote($db) . '.' . PMA_backquote($table); $target = PMA_backquote($target_db) . '.' . PMA_backquote($new_name); include './libraries/build_dump.lib.php'; $sql_structure = PMA_getTableDef($db, $table, "\n", $err_url); $sql_structure = eregi_replace('^CREATE TABLE (`?)' . $table . '(`?)', 'CREATE TABLE ' . $target, $sql_structure); $result = @mysql_query($sql_structure); if (mysql_error()) { include './header.inc.php'; PMA_mysqlDie('', $sql_structure, '', $err_url); } else { if (isset($sql_query)) { $sql_query .= "\n" . $sql_structure . ';'; } else { $sql_query = $sql_structure . ';';
$field_index[] = $i; } if (${'field_key_' . $i} == 'unique_' . $i) { $field_unique[] = $i; } } // end if } // end for // Builds the field creation statement and alters the table for ($i = 0; $i < $field_cnt; ++$i) { if (get_magic_quotes_gpc()) { $field_name[$i] = stripslashes($field_name[$i]); } if (PMA_MYSQL_INT_VERSION < 32306) { PMA_checkReservedWords($field_name[$i], $err_url); } $query .= PMA_backquote($field_name[$i]) . ' ' . $field_type[$i]; if ($field_length[$i] != '' && !eregi('^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT)$', $field_type[$i])) { if (get_magic_quotes_gpc()) { $query .= '(' . stripslashes($field_length[$i]) . ')'; } else { $query .= '(' . $field_length[$i] . ')'; } } if ($field_attribute[$i] != '') { $query .= ' ' . $field_attribute[$i]; } if ($field_default[$i] != '') { if (strtoupper($field_default[$i]) == 'NULL') { $query .= ' DEFAULT NULL';