3 // vim: expandtab sw=4 ts=4 sts=4:
5 require_once('./libraries/grab_globals.lib.php');
6 require_once('./libraries/common.lib.php');
7 require_once('./libraries/mysql_charsets.lib.php');
9 * Rename database or Copy database
12 ((isset($db_rename) && $db_rename == 'true') ||
13 (isset($db_copy) && $db_copy == 'true'))) {
15 require_once('./libraries/tbl_move_copy.php');
17 $force_queryframe_reload = TRUE;
19 if (isset($db_rename) && $db_rename == 'true') {
25 if (!isset($newname) ||
empty($newname)) {
26 $message = $strDatabaseEmpty;
29 (isset($create_database_before_copying) && $create_database_before_copying)) {
30 $local_query = 'CREATE DATABASE ' . PMA_backquote($newname);
31 if (isset($db_collation)) {
32 $local_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
35 $sql_query = $local_query;
36 PMA_DBI_query($local_query);
39 $tables_full = PMA_DBI_get_tables_full($db);
40 foreach ($tables_full as $table => $tmp) {
44 // value of $what for this table only
47 if (!isset($tables_full[$table]['Engine'])) {
48 $tables_full[$table]['Engine'] = $tables_full[$table]['Type'];
50 // do not copy the data from a Merge table
51 // note: on the calling FORM, 'data' means 'structure and data'
52 if ($tables_full[$table]['Engine'] == 'MRG_MyISAM') {
53 if ($this_what == 'data') {
54 $this_what = 'structure';
56 if ($this_what == 'dataonly') {
57 $this_what = 'nocopy';
61 if ($this_what != 'nocopy') {
62 PMA_table_move_copy($db, $table, $newname, $table, isset($this_what) ?
$this_what : 'data', $move);
65 $sql_query = $back . $sql_query;
69 // Duplicate the bookmarks for this db (done once for each db)
70 if ($db != $newname) {
71 $get_fields = array('user','label','query');
72 $where_fields = array('dbase' => $db);
73 $new_fields = array('dbase' => $newname);
74 PMA_duplicate_table_info('bookmarkwork', 'bookmark', $get_fields, $where_fields, $new_fields);
78 // cleanup pmadb stuff for this db
79 require_once('./libraries/relation_cleanup.lib.php');
80 PMA_relationsCleanupDatabase($db);
82 $local_query = 'DROP DATABASE ' . PMA_backquote($db) . ';';
83 $sql_query .= "\n" . $local_query;
84 PMA_DBI_query($local_query);
85 $message = sprintf($strRenameDatabaseOK, htmlspecialchars($db), htmlspecialchars($newname));
87 $message = sprintf($strCopyDatabaseOK, htmlspecialchars($db), htmlspecialchars($newname));
91 /* Change database to be used */
95 $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
96 if (isset($switch_to_new) && $switch_to_new == 'true') {
97 setcookie('pma_switch_to_new', 'true', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']);
100 setcookie('pma_switch_to_new', '', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']);
106 * Settings for relations stuff
109 require_once('./libraries/relation.lib.php');
110 $cfgRelation = PMA_getRelationsParam();
113 * Check if comments were updated
114 * (must be done before displaying the menu tabs)
116 if ($cfgRelation['commwork'] && isset($db_comment) && $db_comment == 'true') {
117 PMA_SetComment($db, '', '(db_comment)', $comment);
121 * Prepares the tables list if the user where not redirected to this script
122 * because there is no table in the database ($is_info is TRUE)
124 if (empty($is_info)) {
125 require('./db_details_common.php');
126 $url_query .= '&goto=db_operations.php';
128 // Gets the database structure
129 $sub_part = '_structure';
130 require('./db_details_db_info.php');
134 if (PMA_MYSQL_INT_VERSION
>= 40101) {
135 $db_collation = PMA_getDbCollation($db);
137 if (PMA_MYSQL_INT_VERSION
< 50002 ||
(PMA_MYSQL_INT_VERSION
>= 50002 && $db != 'information_schema')) {
138 $is_information_schema = FALSE;
140 $is_information_schema = TRUE;
143 if (!$is_information_schema) {
146 <table border
="0" cellpadding
="2" cellspacing
="0">
147 <!-- Create a
new table
-->
148 <form method
="post" action
="tbl_create.php" onsubmit
="return (emptyFormElements(this, 'table') && checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldCount']); ?>', 1))">
150 <td
class="tblHeaders" colspan
="3" nowrap
="nowrap"><?php
151 echo PMA_generate_common_hidden_inputs($db);
152 if($cfg['PropertiesIconic']){ echo '<img src="' . $pmaThemeImage . 'b_newtbl.png" border="0" width="16" height="16" hspace="2" align="middle" />'; }
153 // if you want navigation:
154 $strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url() . '&db=' . urlencode($GLOBALS['db']) . '">'
155 . htmlspecialchars($GLOBALS['db']) . '</a>';
157 // $strDBLink = htmlspecialchars($db);
158 echo ' ' . sprintf($strCreateNewTable, $strDBLink) . ': ' . "\n";
160 echo ' <tr bgcolor="'.$cfg['BgcolorOne'].'"><td nowrap="nowrap">';
161 echo ' ' . $strName . ': ' . "\n";
163 echo ' <td nowrap="nowrap">';
164 echo ' ' . '<input type="text" name="table" maxlength="64" size="30" class="textfield" />';
165 echo ' </td><td> </td></tr>';
166 echo ' <tr bgcolor="'.$cfg['BgcolorOne'].'"><td nowrap="nowrap">';
167 echo ' ' . $strFields . ': ' . "\n";
169 echo ' <td nowrap="nowrap">';
170 echo ' ' . '<input type="text" name="num_fields" size="2" class="textfield" />' . "\n";
172 echo ' <td align="right">';
173 echo ' ' . ' <input type="submit" value="' . $strGo . '" />' . "\n";
174 echo ' </td> </tr>' . "\n";
175 echo ' </form>' . "\n";
176 echo '</table>' . "\n";
178 echo '<table border="0" cellpadding="2" cellspacing="0">';
179 if ($cfgRelation['commwork']) {
181 <!-- Alter
/Enter db
-comment
-->
182 <tr
><td colspan
="3"><img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width
="1" height
="1" border
="0" alt
="" /></td
></tr
>
185 <td colspan
="3" class="tblHeaders"><?php
186 if ($cfg['PropertiesIconic']) {
187 echo '<img src="' . $pmaThemeImage . 'b_comment.png" border="0" width="16" height="16" hspace="2" align="middle" />';
190 $comment = PMA_getComments($db);
192 <form method
="post" action
="db_operations.php">
193 <tr bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
194 <td colspan
="2" nowrap
="nowrap">
195 <input type
="hidden" name
="db_comment" value
="true" />
196 <?php
echo PMA_generate_common_hidden_inputs($db); ?
>
197 <input type
="text" name
="comment" class="textfield" size
="30" value
="<?php echo (isset($comment) && is_array($comment) ? htmlspecialchars(implode(' ', $comment)) : ''); ?>" /></td
><td align
="right">
198 <input type
="submit" value
="<?php echo $strGo; ?>" />
204 <!-- Rename database
-->
205 <tr
><td colspan
="3"><img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width
="1" height
="1" border
="0" alt
="" /></td
></tr
>
206 <tr
><td colspan
="3" class="tblHeaders"><?php
207 if ($cfg['PropertiesIconic']) {
208 echo '<img src="' . $pmaThemeImage . 'b_edit.png" border="0" width="16" height="16" hspace="2" align="middle" />';
210 echo $strDBRename.': ';
212 <form method
="post" action
="db_operations.php"
213 onsubmit
="return emptyFormElements(this, 'newname')">
214 <tr bgcolor
="<?php echo $cfg['BgcolorOne']; ?>"><td colspan
="2"><?php
215 echo '<input type="hidden" name="what" value="data" />';
216 echo '<input type="hidden" name="db_rename" value="true" />'
217 . PMA_generate_common_hidden_inputs($db);
218 ?
><input type
="text" name
="newname" size
="30" class="textfield" value
="" /></td
>
219 <td align
="right"><input type
="submit" value
="<?php echo $strGo; ?>" /></td
>
222 <!-- Copy database
-->
223 <tr
><td colspan
="3"><img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width
="1" height
="1" border
="0" alt
="" /></td
></tr
>
224 <tr
><td colspan
="3" class="tblHeaders"><?php
225 if ($cfg['PropertiesIconic']) {
226 echo '<img src="' . $pmaThemeImage . 'b_edit.png" border="0" width="16" height="16" hspace="2" align="middle" />';
228 echo $strDBCopy.': ';
230 <form method
="post" action
="db_operations.php"
231 onsubmit
="return emptyFormElements(this, 'newname')">
232 <tr bgcolor
="<?php echo $cfg['BgcolorOne']; ?>"><td colspan
="3">
234 if (isset($db_collation)) {
235 echo '<input type="hidden" name="db_collation" value="' . $db_collation .'" />' . "\n";
237 echo '<input type="hidden" name="db_copy" value="true" />' . "\n"
238 . PMA_generate_common_hidden_inputs($db);
239 ?
><input type
="text" name
="newname" size
="30" class="textfield" value
="" /></td
>
241 <td nowrap
="nowrap" bgcolor
="<?php echo $cfg['BgcolorOne']; ?>" colspan
="2">
242 <input type
="radio" name
="what" value
="structure" id
="radio_copy_structure" style
="vertical-align: middle" /><label
for="radio_copy_structure"><?php
echo $strStrucOnly; ?
></label
> 
; 
;<br
/>
243 <input type
="radio" name
="what" value
="data" id
="radio_copy_data" checked
="checked" style
="vertical-align: middle" /><label
for="radio_copy_data"><?php
echo $strStrucData; ?
></label
> 
; 
;<br
/>
244 <input type
="radio" name
="what" value
="dataonly" id
="radio_copy_dataonly" style
="vertical-align: middle" /><label
for="radio_copy_dataonly"><?php
echo $strDataOnly; ?
></label
> 
; 
;<br
/>
247 <input type
="checkbox" name
="create_database_before_copying" value
="1" id
="checkbox_create_database_before_copying" style
="vertical-align: middle" checked
="checked" /><label
for="checkbox_create_database_before_copying"><?php
echo $strCreateDatabaseBeforeCopying; ?
></label
><br
/>
248 <input type
="checkbox" name
="drop_if_exists" value
="true" id
="checkbox_drop" style
="vertical-align: middle" /><label
for="checkbox_drop"><?php
echo $strStrucDrop; ?
></label
> 
; 
;<br
/>
249 <input type
="checkbox" name
="auto_increment" value
="1" id
="checkbox_auto_increment" style
="vertical-align: middle" /><label
for="checkbox_auto_increment"><?php
echo $strAddAutoIncrement; ?
></label
><br
/>
250 <input type
="checkbox" name
="constraints" value
="1" id
="checkbox_constraints" style
="vertical-align: middle" /><label
for="checkbox_constraints"><?php
echo $strAddConstraints; ?
></label
><br
/>
252 if (isset($_COOKIE) && isset($_COOKIE['pma_switch_to_new']) && $_COOKIE['pma_switch_to_new'] == 'true') {
253 $pma_switch_to_new = 'true';
256 <input type
="checkbox" name
="switch_to_new" value
="true" id
="checkbox_switch"<?php
echo ((isset($pma_switch_to_new) && $pma_switch_to_new == 'true') ?
' checked="checked"' : ''); ?
> style
="vertical-align: middle" /><label
for="checkbox_switch"><?php
echo $strSwitchToDatabase; ?
></label
> 
; 
;
258 <td align
="<?php echo $cell_align_right; ?>" valign
="bottom" bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
259 <input type
="submit" name
="submit_copy" value
="<?php echo $strGo; ?>" />
266 if (PMA_MYSQL_INT_VERSION
>= 40101) {
267 // MySQL supports setting default charsets / collations for databases since
269 echo ' <!-- Change database charset -->' . "\n"
270 . ' <tr><td colspan="3"><img src="' . $GLOBALS['pmaThemeImage'] . 'spacer.png' . '" width="1" height="1" border="0" alt="" /></td></tr>' . "\n"
271 . ' <tr><td colspan="3" class="tblHeaders">';
272 if ($cfg['PropertiesIconic']) {
273 echo '<img src="' . $pmaThemeImage . 's_asci.png" border="0" width="16" height="16" hspace="2" align="middle" />';
275 echo ' <label for="select_db_collation">' . $strCollation . '</label>: ' . "\n"
276 . ' </td></tr>' . "\n"
277 . ' <form method="post" action="./db_operations.php">' . "\n"
278 . ' <tr bgcolor="' . $cfg['BgcolorOne'] . '"><td colspan="2" nowrap="nowrap">'
279 . PMA_generate_common_hidden_inputs($db, $table, 3)
280 . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION
, 'db_collation', 'select_db_collation', $db_collation, FALSE, 3)
281 . ' </td><td align="right">'
282 . ' <input type="submit" name="submitcollation" value="' . $strGo . '" style="vertical-align: middle" />' . "\n"
283 . ' </td></tr>' . "\n"
289 && !$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == FALSE) {
290 echo '<tr><td colspan="3"><img src="' . $GLOBALS['pmaThemeImage'] . 'spacer.png' . '" width="1" height="1" border="0" alt="" /></td></tr>'
291 . '<tr><th colspan="3" class="tblHeadError"><div class="errorhead">' . $strError . '</div></th></tr>'
292 . '<tr><td colspan="3" class="tblError">'
293 . sprintf(wordwrap($strRelationNotWorking,65,'<br />'), '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $url_query . '">', '</a>')
299 } // end if (!$is_information_schema)
300 // not sure about leaving the PDF dialog for information_schema
303 <form method
="post" action
="pdf_schema.php">
306 if ($num_tables > 0) {
307 $takeaway = $url_query . '&table=' . urlencode($table);
310 if (($cfgRelation['pdfwork'] && $num_tables > 0) ||
312 && $cfgRelation['relwork'] && $cfgRelation['commwork']
313 && isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])
315 <hr
/><table border
="0" cellpadding
="2" cellspacing
="0">
319 if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?
>
320 <!-- Work on PDF Pages
-->
322 <td colspan
="3" class="tblHeaders">
324 if ($cfg['PropertiesIconic']) {
325 echo '<img src="' . $pmaThemeImage . 'b_pdfdoc.png" border="0" width="16" height="16" hspace="2" align="middle" />';
329 <tr bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
332 echo '<a href="pdf_pages.php?' . $takeaway . '">';
333 if ($cfg['PropertiesIconic']) {
334 echo '<img src="' . $pmaThemeImage . 'b_edit.png" border="0" width="16" height="16" hspace="2" align="middle" />';
336 echo ''. $strEditPDFPages . '</a>';
343 // We only show this if we find something in the new pdf_pages table
345 $test_query = 'SELECT * FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
346 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
347 $test_rs = PMA_query_as_cu($test_query, NULL, PMA_DBI_QUERY_STORE
);
349 if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) { ?
>
350 <tr bgcolor
="<?php echo $cfg['BgcolorTwo']; ?>">
353 echo PMA_generate_common_hidden_inputs($db);
354 if ($cfg['PropertiesIconic']) {
355 echo '<img src="' . $pmaThemeImage . 'b_view.png" border="0" width="16" height="16" hspace="2" align="middle" />';
357 echo $strDisplayPDF; ?
>: 
;
361 <tr bgcolor
="<?php echo $cfg['BgcolorTwo']; ?>">
362 <td width
="20"> 
;</td
>
364 <label
for="pdf_page_number_opt"><?php
echo $strPageNumber; ?
></label
>
365 <select name
="pdf_page_number" id
="pdf_page_number_opt">
367 while ($pages = @PMA_DBI_fetch_assoc
($test_rs)) {
368 echo ' <option value="' . $pages['page_nr'] . '">' . $pages['page_nr'] . ': ' . $pages['page_descr'] . '</option>' . "\n";
370 PMA_DBI_free_result($test_rs);
375 <input type
="checkbox" name
="show_grid" id
="show_grid_opt" /><label
for="show_grid_opt"><?php
echo $strShowGrid; ?
></label
><br
/>
376 <input type
="checkbox" name
="show_color" id
="show_color_opt" checked
="checked" /><label
for="show_color_opt"><?php
echo $strShowColor; ?
></label
><br
/>
377 <input type
="checkbox" name
="show_table_dimension" id
="show_table_dim_opt" /><label
for="show_table_dim_opt"><?php
echo $strShowTableDimension; ?
></label
><br
/>
378 <input type
="checkbox" name
="all_tab_same_wide" id
="all_tab_same_wide" /><label
for="all_tab_same_wide"><?php
echo $strAllTableSameWidth; ?
></label
><br
/>
379 <input type
="checkbox" name
="with_doc" id
="with_doc" checked
="checked" /><label
for="with_doc"><?php
echo $strDataDict; ?
></label
><br
/>
381 <label
for="orientation_opt"><?php
echo $strShowDatadictAs; ?
></label
>
382 <select name
="orientation" id
="orientation_opt">
383 <option value
="L"><?php
echo $strLandscape;?
></option
>
384 <option value
="P"><?php
echo $strPortrait;?
></option
>
387 <label
for="paper_opt"><?php
echo $strPaperSize; ?
></label
>
388 <select name
="paper" id
="paper_opt">
390 foreach ($cfg['PDFPageSizes'] AS $key => $val) {
391 echo '<option value="' . $val . '"';
392 if ($val == $cfg['PDFDefaultPageSize']) {
393 echo ' selected="selected"';
395 echo ' >' . $val . '</option>' . "\n";
402 <tr bgcolor
="<?php echo $cfg['BgcolorTwo']; ?>">
403 <td width
="20"> 
;</td
>
404 <td colspan
="3" align
="right"> 
; 
;<input type
="submit" value
="<?php echo $strGo; ?>" /></td
>
407 <td colspan
="3"><img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width
="1" height
="1" border
="0" alt
="" /></td
>
414 && $cfgRelation['relwork'] && $cfgRelation['commwork']
415 && isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])
418 <!-- import docSQL files
-->
419 <tr bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
422 echo '<a href="db_details_importdocsql.php?' . $takeaway . '">';
423 if ($cfg['PropertiesIconic']) {
424 echo '<img src="' . $pmaThemeImage . 'b_docsql.png" border="0" width="16" height="16" hspace="2" align="middle" />';
426 echo $strImportDocSQL . '</a>';
433 if (($cfgRelation['pdfwork'] && $num_tables > 0) ||
435 && $cfgRelation['relwork'] && $cfgRelation['commwork']
436 && isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])
444 * Displays the footer
447 require_once('./footer.inc.php');