3 // vim: expandtab sw=4 ts=4 sts=4:
5 require_once('./libraries/common.lib.php');
6 require_once('./libraries/mysql_charsets.lib.php');
8 * Rename database or Copy database
11 ((isset($db_rename) && $db_rename == 'true') ||
12 (isset($db_copy) && $db_copy == 'true'))) {
14 require_once('./libraries/tbl_move_copy.php');
16 if (isset($db_rename) && $db_rename == 'true') {
22 if (!isset($newname) ||
empty($newname)) {
23 $message = $strDatabaseEmpty;
26 (isset($create_database_before_copying) && $create_database_before_copying)) {
27 $local_query = 'CREATE DATABASE ' . PMA_backquote($newname);
28 if (isset($db_collation)) {
29 $local_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
32 $sql_query = $local_query;
33 PMA_DBI_query($local_query);
36 $tables_full = PMA_DBI_get_tables_full($db);
37 foreach ($tables_full as $table => $tmp) {
41 // value of $what for this table only
44 if (!isset($tables_full[$table]['Engine'])) {
45 $tables_full[$table]['Engine'] = $tables_full[$table]['Type'];
47 // do not copy the data from a Merge table
48 // note: on the calling FORM, 'data' means 'structure and data'
49 if ($tables_full[$table]['Engine'] == 'MRG_MyISAM') {
50 if ($this_what == 'data') {
51 $this_what = 'structure';
53 if ($this_what == 'dataonly') {
54 $this_what = 'nocopy';
58 if ($this_what != 'nocopy') {
59 PMA_table_move_copy($db, $table, $newname, $table, isset($this_what) ?
$this_what : 'data', $move);
62 $sql_query = $back . $sql_query;
66 // Duplicate the bookmarks for this db (done once for each db)
67 if ($db != $newname) {
68 $get_fields = array('user','label','query');
69 $where_fields = array('dbase' => $db);
70 $new_fields = array('dbase' => $newname);
71 PMA_duplicate_table_info('bookmarkwork', 'bookmark', $get_fields, $where_fields, $new_fields);
75 // cleanup pmadb stuff for this db
76 require_once('./libraries/relation_cleanup.lib.php');
77 PMA_relationsCleanupDatabase($db);
79 $local_query = 'DROP DATABASE ' . PMA_backquote($db) . ';';
80 $sql_query .= "\n" . $local_query;
81 PMA_DBI_query($local_query);
82 $message = sprintf($strRenameDatabaseOK, htmlspecialchars($db), htmlspecialchars($newname));
84 $message = sprintf($strCopyDatabaseOK, htmlspecialchars($db), htmlspecialchars($newname));
88 /* Change database to be used */
92 $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
93 if (isset($switch_to_new) && $switch_to_new == 'true') {
94 setcookie('pma_switch_to_new', 'true', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']);
97 setcookie('pma_switch_to_new', '', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']);
103 * Settings for relations stuff
106 require_once('./libraries/relation.lib.php');
107 $cfgRelation = PMA_getRelationsParam();
110 * Check if comments were updated
111 * (must be done before displaying the menu tabs)
113 if ($cfgRelation['commwork'] && isset($db_comment) && $db_comment == 'true') {
114 PMA_SetComment($db, '', '(db_comment)', $comment);
118 * Prepares the tables list if the user where not redirected to this script
119 * because there is no table in the database ($is_info is TRUE)
121 if (empty($is_info)) {
122 require('./db_details_common.php');
123 $url_query .= '&goto=db_operations.php';
125 // Gets the database structure
126 $sub_part = '_structure';
127 require('./db_details_db_info.php');
131 if (PMA_MYSQL_INT_VERSION
>= 40101) {
132 $db_collation = PMA_getDbCollation($db);
134 if (PMA_MYSQL_INT_VERSION
< 50002 ||
(PMA_MYSQL_INT_VERSION
>= 50002 && $db != 'information_schema')) {
135 $is_information_schema = FALSE;
137 $is_information_schema = TRUE;
140 if (!$is_information_schema) {
142 require('./libraries/display_create_table.lib.php');
144 echo '<table border="0" cellpadding="2" cellspacing="0">';
145 if ($cfgRelation['commwork']) {
147 <!-- Alter
/Enter db
-comment
-->
148 <tr
><td colspan
="3"><img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width
="1" height
="1" border
="0" alt
="" /></td
></tr
>
151 <td colspan
="3" class="tblHeaders"><?php
152 if ($cfg['PropertiesIconic']) {
153 echo '<img src="' . $pmaThemeImage . 'b_comment.png" border="0" width="16" height="16" hspace="2" align="middle" />';
156 $comment = PMA_getComments($db);
158 <form method
="post" action
="db_operations.php">
159 <tr bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
160 <td colspan
="2" nowrap
="nowrap">
161 <input type
="hidden" name
="db_comment" value
="true" />
162 <?php
echo PMA_generate_common_hidden_inputs($db); ?
>
163 <input type
="text" name
="comment" class="textfield" size
="30" value
="<?php echo (isset($comment) && is_array($comment) ? htmlspecialchars(implode(' ', $comment)) : ''); ?>" /></td
><td align
="right">
164 <input type
="submit" value
="<?php echo $strGo; ?>" />
170 <!-- Rename database
-->
171 <tr
><td colspan
="3"><img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width
="1" height
="1" border
="0" alt
="" /></td
></tr
>
172 <tr
><td colspan
="3" class="tblHeaders"><?php
173 if ($cfg['PropertiesIconic']) {
174 echo '<img src="' . $pmaThemeImage . 'b_edit.png" border="0" width="16" height="16" hspace="2" align="middle" />';
176 echo $strDBRename.': ';
178 <form method
="post" action
="db_operations.php"
179 onsubmit
="return emptyFormElements(this, 'newname')">
180 <tr bgcolor
="<?php echo $cfg['BgcolorOne']; ?>"><td colspan
="2"><?php
181 echo '<input type="hidden" name="what" value="data" />';
182 echo '<input type="hidden" name="db_rename" value="true" />'
183 . PMA_generate_common_hidden_inputs($db);
184 ?
><input type
="text" name
="newname" size
="30" class="textfield" value
="" /></td
>
185 <td align
="right"><input type
="submit" value
="<?php echo $strGo; ?>" /></td
>
188 <!-- Copy database
-->
189 <tr
><td colspan
="3"><img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width
="1" height
="1" border
="0" alt
="" /></td
></tr
>
190 <tr
><td colspan
="3" class="tblHeaders"><?php
191 if ($cfg['PropertiesIconic']) {
192 echo '<img src="' . $pmaThemeImage . 'b_edit.png" border="0" width="16" height="16" hspace="2" align="middle" />';
194 echo $strDBCopy.': ';
196 <form method
="post" action
="db_operations.php"
197 onsubmit
="return emptyFormElements(this, 'newname')">
198 <tr bgcolor
="<?php echo $cfg['BgcolorOne']; ?>"><td colspan
="3">
200 if (isset($db_collation)) {
201 echo '<input type="hidden" name="db_collation" value="' . $db_collation .'" />' . "\n";
203 echo '<input type="hidden" name="db_copy" value="true" />' . "\n"
204 . PMA_generate_common_hidden_inputs($db);
205 ?
><input type
="text" name
="newname" size
="30" class="textfield" value
="" /></td
>
207 <td nowrap
="nowrap" bgcolor
="<?php echo $cfg['BgcolorOne']; ?>" colspan
="2">
208 <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
/>
209 <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
/>
210 <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
/>
213 <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
/>
214 <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
/>
215 <input type
="checkbox" name
="sql_auto_increment" value
="1" id
="checkbox_auto_increment" style
="vertical-align: middle" /><label
for="checkbox_auto_increment"><?php
echo $strAddAutoIncrement; ?
></label
><br
/>
216 <input type
="checkbox" name
="constraints" value
="1" id
="checkbox_constraints" style
="vertical-align: middle" /><label
for="checkbox_constraints"><?php
echo $strAddConstraints; ?
></label
><br
/>
218 if (isset($_COOKIE) && isset($_COOKIE['pma_switch_to_new']) && $_COOKIE['pma_switch_to_new'] == 'true') {
219 $pma_switch_to_new = 'true';
222 <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
> 
; 
;
224 <td align
="<?php echo $cell_align_right; ?>" valign
="bottom" bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
225 <input type
="submit" name
="submit_copy" value
="<?php echo $strGo; ?>" />
232 if (PMA_MYSQL_INT_VERSION
>= 40101) {
233 // MySQL supports setting default charsets / collations for databases since
235 echo ' <!-- Change database charset -->' . "\n"
236 . ' <tr><td colspan="3"><img src="' . $GLOBALS['pmaThemeImage'] . 'spacer.png' . '" width="1" height="1" border="0" alt="" /></td></tr>' . "\n"
237 . ' <tr><td colspan="3" class="tblHeaders">';
238 if ($cfg['PropertiesIconic']) {
239 echo '<img src="' . $pmaThemeImage . 's_asci.png" border="0" width="16" height="16" hspace="2" align="middle" />';
241 echo ' <label for="select_db_collation">' . $strCollation . '</label>: ' . "\n"
242 . ' </td></tr>' . "\n"
243 . ' <form method="post" action="./db_operations.php">' . "\n"
244 . ' <tr bgcolor="' . $cfg['BgcolorOne'] . '"><td colspan="2" nowrap="nowrap">'
245 . PMA_generate_common_hidden_inputs($db, $table, 3)
246 . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION
, 'db_collation', 'select_db_collation', $db_collation, FALSE, 3)
247 . ' </td><td align="right">'
248 . ' <input type="submit" name="submitcollation" value="' . $strGo . '" style="vertical-align: middle" />' . "\n"
249 . ' </td></tr>' . "\n"
257 && !$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == FALSE) {
258 echo '<div class="error"><h1>' . $strError . '</h1>'
259 . sprintf( $strRelationNotWorking, '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $url_query . '">', '</a>')
262 } // end if (!$is_information_schema)
263 // not sure about leaving the PDF dialog for information_schema
266 <form method
="post" action
="pdf_schema.php">
269 if ($num_tables > 0) {
270 $takeaway = $url_query . '&table=' . urlencode($table);
273 if (($cfgRelation['pdfwork'] && $num_tables > 0) ||
275 && $cfgRelation['relwork'] && $cfgRelation['commwork']
276 && isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])
278 <hr
/><table border
="0" cellpadding
="2" cellspacing
="0">
282 if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?
>
283 <!-- Work on PDF Pages
-->
285 <td colspan
="3" class="tblHeaders">
287 if ($cfg['PropertiesIconic']) {
288 echo '<img src="' . $pmaThemeImage . 'b_pdfdoc.png" border="0" width="16" height="16" hspace="2" align="middle" />';
292 <tr bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
295 echo '<a href="pdf_pages.php?' . $takeaway . '">';
296 if ($cfg['PropertiesIconic']) {
297 echo '<img src="' . $pmaThemeImage . 'b_edit.png" border="0" width="16" height="16" hspace="2" align="middle" />';
299 echo ''. $strEditPDFPages . '</a>';
306 // We only show this if we find something in the new pdf_pages table
308 $test_query = 'SELECT * FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
309 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
310 $test_rs = PMA_query_as_cu($test_query, NULL, PMA_DBI_QUERY_STORE
);
312 if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) { ?
>
313 <tr bgcolor
="<?php echo $cfg['BgcolorTwo']; ?>">
316 echo PMA_generate_common_hidden_inputs($db);
317 if ($cfg['PropertiesIconic']) {
318 echo '<img src="' . $pmaThemeImage . 'b_view.png" border="0" width="16" height="16" hspace="2" align="middle" />';
320 echo $strDisplayPDF; ?
>: 
;
324 <tr bgcolor
="<?php echo $cfg['BgcolorTwo']; ?>">
325 <td width
="20"> 
;</td
>
327 <label
for="pdf_page_number_opt"><?php
echo $strPageNumber; ?
></label
>
328 <select name
="pdf_page_number" id
="pdf_page_number_opt">
330 while ($pages = @PMA_DBI_fetch_assoc
($test_rs)) {
331 echo ' <option value="' . $pages['page_nr'] . '">' . $pages['page_nr'] . ': ' . $pages['page_descr'] . '</option>' . "\n";
333 PMA_DBI_free_result($test_rs);
338 <input type
="checkbox" name
="show_grid" id
="show_grid_opt" /><label
for="show_grid_opt"><?php
echo $strShowGrid; ?
></label
><br
/>
339 <input type
="checkbox" name
="show_color" id
="show_color_opt" checked
="checked" /><label
for="show_color_opt"><?php
echo $strShowColor; ?
></label
><br
/>
340 <input type
="checkbox" name
="show_table_dimension" id
="show_table_dim_opt" /><label
for="show_table_dim_opt"><?php
echo $strShowTableDimension; ?
></label
><br
/>
341 <input type
="checkbox" name
="all_tab_same_wide" id
="all_tab_same_wide" /><label
for="all_tab_same_wide"><?php
echo $strAllTableSameWidth; ?
></label
><br
/>
342 <input type
="checkbox" name
="with_doc" id
="with_doc" checked
="checked" /><label
for="with_doc"><?php
echo $strDataDict; ?
></label
><br
/>
344 <label
for="orientation_opt"><?php
echo $strShowDatadictAs; ?
></label
>
345 <select name
="orientation" id
="orientation_opt">
346 <option value
="L"><?php
echo $strLandscape;?
></option
>
347 <option value
="P"><?php
echo $strPortrait;?
></option
>
350 <label
for="paper_opt"><?php
echo $strPaperSize; ?
></label
>
351 <select name
="paper" id
="paper_opt">
353 foreach ($cfg['PDFPageSizes'] AS $key => $val) {
354 echo '<option value="' . $val . '"';
355 if ($val == $cfg['PDFDefaultPageSize']) {
356 echo ' selected="selected"';
358 echo ' >' . $val . '</option>' . "\n";
365 <tr bgcolor
="<?php echo $cfg['BgcolorTwo']; ?>">
366 <td width
="20"> 
;</td
>
367 <td colspan
="3" align
="right"> 
; 
;<input type
="submit" value
="<?php echo $strGo; ?>" /></td
>
370 <td colspan
="3"><img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width
="1" height
="1" border
="0" alt
="" /></td
>
377 && $cfgRelation['relwork'] && $cfgRelation['commwork']
378 && isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])
381 <!-- import docSQL files
-->
382 <tr bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
385 echo '<a href="db_details_importdocsql.php?' . $takeaway . '">';
386 if ($cfg['PropertiesIconic']) {
387 echo '<img src="' . $pmaThemeImage . 'b_docsql.png" border="0" width="16" height="16" hspace="2" align="middle" />';
389 echo $strImportDocSQL . '</a>';
396 if (($cfgRelation['pdfwork'] && $num_tables > 0) ||
398 && $cfgRelation['relwork'] && $cfgRelation['commwork']
399 && isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])
407 * Displays the footer
410 require_once('./footer.inc.php');