23
21
'options' => array(
24
22
array('type' => 'hidden', 'name' => 'data'),
26
'options_text' => 'strOptions',
24
'options_text' => 'strOptions'
27
/* Export structure */
28
$plugin_list['xml']['options'][] =
29
array('type' => 'bgroup', 'name' => 'export_struc', 'text' => 'strXMLExportStructs');
30
$plugin_list['xml']['options'][] =
31
array('type' => 'bool', 'name' => 'export_functions', 'text' => 'strXMLExportFunctions');
32
$plugin_list['xml']['options'][] =
33
array('type' => 'bool', 'name' => 'export_procedures', 'text' => 'strXMLExportProcedures');
34
$plugin_list['xml']['options'][] =
35
array('type' => 'bool', 'name' => 'export_tables', 'text' => 'strXMLExportTables');
36
$plugin_list['xml']['options'][] =
37
array('type' => 'bool', 'name' => 'export_triggers', 'text' => 'strXMLExportTriggers');
38
$plugin_list['xml']['options'][] =
39
array('type' => 'bool', 'name' => 'export_views', 'text' => 'strXMLExportViews');
40
$plugin_list['xml']['options'][] =
41
array('type' => 'egroup');
44
$plugin_list['xml']['options'][] =
45
array('type' => 'bool', 'name' => 'export_contents', 'text' => 'strXMLExportContents');
82
108
. '- ' . $GLOBALS['strServerVersion'] . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 3) . $crlf
83
109
. '- ' . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf
84
110
. '-->' . $crlf . $crlf;
112
$head .= '<pma_xml_export version="1.0"' . (($export_struct) ? ' xmlns:pma="http://www.phpmyadmin.net/some_doc_url/"' : '') . '>' . $crlf;
114
if ($export_struct) {
115
$result = PMA_DBI_fetch_result('SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME` = \''.$db.'\' LIMIT 1');
116
$db_collation = $result[0]['DEFAULT_COLLATION_NAME'];
117
$db_charset = $result[0]['DEFAULT_CHARACTER_SET_NAME'];
119
$head .= ' <!--' . $crlf;
120
$head .= ' - Structure schemas' . $crlf;
121
$head .= ' -->' . $crlf;
122
$head .= ' <pma:structure_schemas>' . $crlf;
123
$head .= ' <pma:database name="' . $db . '" collation="' . $db_collation . '" charset="' . $db_charset . '">' . $crlf;
125
if (count($tables) == 0) {
129
foreach ($tables as $table) {
130
// Export tables and views
131
$result = PMA_DBI_fetch_result('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), 0);
132
$tbl = $result[$table][1];
134
$is_view = PMA_isView($db, $table);
142
if ($is_view && ! isset($GLOBALS[$what . '_export_views'])) {
146
if (! $is_view && ! isset($GLOBALS[$what . '_export_tables'])) {
150
$head .= ' <pma:' . $type . ' name="' . $table . '">' . $crlf;
153
$tbl = str_replace("\n", "\n ", $tbl);
155
$head .= $tbl . ';' . $crlf;
156
$head .= ' </pma:' . $type . '>' . $crlf;
158
if (isset($GLOBALS[$what . '_export_triggers']) && $GLOBALS[$what . '_export_triggers']) {
160
$triggers = PMA_DBI_get_triggers($db, $table);
162
foreach ($triggers as $trigger) {
163
$code = $trigger['create'];
164
$head .= ' <pma:trigger name="' . $trigger['name'] . '">' . $crlf;
166
// Do some formatting
167
$code = substr(rtrim($code), 0, -3);
169
$code = str_replace("\n", "\n ", $code);
171
$head .= $code . $crlf;
172
$head .= ' </pma:trigger>' . $crlf;
181
if (isset($GLOBALS[$what . '_export_functions']) && $GLOBALS[$what . '_export_functions']) {
183
$functions = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
185
foreach ($functions as $function) {
186
$head .= ' <pma:function name="' . $function . '">' . $crlf;
188
// Do some formatting
189
$sql = PMA_DBI_get_definition($db, 'FUNCTION', $function);
192
$sql = str_replace("\n", "\n ", $sql);
194
$head .= $sql . $crlf;
195
$head .= ' </pma:function>' . $crlf;
204
if (isset($GLOBALS[$what . '_export_procedures']) && $GLOBALS[$what . '_export_procedures']) {
206
$procedures = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
208
foreach ($procedures as $procedure) {
209
$head .= ' <pma:procedure name="' . $procedure . '">' . $crlf;
211
// Do some formatting
212
$sql = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure);
215
$sql = str_replace("\n", "\n ", $sql);
217
$head .= $sql . $crlf;
218
$head .= ' </pma:procedure>' . $crlf;
229
$head .= ' </pma:database>' . $crlf;
230
$head .= ' </pma:structure_schemas>' . $crlf;
85
237
return PMA_exportOutputHandler($head);
97
249
function PMA_exportDBHeader($db) {
99
$db = str_replace(' ', '_', $db);
100
$head = '<!--' . $crlf
101
. '- ' . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
103
. '<' . $db . '>' . $crlf;
104
return PMA_exportOutputHandler($head);
253
if (isset($GLOBALS[$what . '_export_contents']) && $GLOBALS[$what . '_export_contents']) {
254
$head = ' <!--' . $crlf
255
. ' - ' . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
257
. ' <database name="' . $db . '">' . $crlf;
259
return PMA_exportOutputHandler($head);
149
316
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
150
$db = str_replace(' ', '_', $db);
151
$table = str_replace(' ', '_', $table);
152
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
154
$columns_cnt = PMA_DBI_num_fields($result);
155
for ($i = 0; $i < $columns_cnt; $i++) {
156
$columns[$i] = stripslashes(str_replace(' ', '_', PMA_DBI_field_name($result, $i)));
160
$buffer = ' <!-- ' . $GLOBALS['strTable'] . ' ' . $table . ' -->' . $crlf;
161
if (!PMA_exportOutputHandler($buffer)) {
165
while ($record = PMA_DBI_fetch_row($result)) {
166
$buffer = ' <' . $table . '>' . $crlf;
319
if (isset($GLOBALS[$what . '_export_contents']) && $GLOBALS[$what . '_export_contents']) {
320
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
322
$columns_cnt = PMA_DBI_num_fields($result);
167
323
for ($i = 0; $i < $columns_cnt; $i++) {
168
if (isset($record[$i]) && !is_null($record[$i])) {
169
$buffer .= ' <' . $columns[$i] . '>' . htmlspecialchars($record[$i])
170
. '</' . $columns[$i] . '>' . $crlf;
324
$columns[$i] = stripslashes(str_replace(' ', '_', PMA_DBI_field_name($result, $i)));
173
$buffer .= ' </' . $table . '>' . $crlf;
328
$buffer = ' <!-- ' . $GLOBALS['strTable'] . ' ' . $table . ' -->' . $crlf;
175
329
if (!PMA_exportOutputHandler($buffer)) {
333
while ($record = PMA_DBI_fetch_row($result)) {
334
$buffer = ' <table name="' . htmlspecialchars($table) . '">' . $crlf;
335
for ($i = 0; $i < $columns_cnt; $i++) {
336
// If a cell is NULL, still export it to preserve the XML structure
337
if (!isset($record[$i]) || is_null($record[$i])) {
338
$record[$i] = 'NULL';
340
$buffer .= ' <column name="' . $columns[$i] . '">' . htmlspecialchars(utf8_encode((string)$record[$i]))
341
. '</column>' . $crlf;
343
$buffer .= ' </table>' . $crlf;
345
if (!PMA_exportOutputHandler($buffer)) {
349
PMA_DBI_free_result($result);
179
PMA_DBI_free_result($result);
182
353
} // end of the 'PMA_getTableXML()' function