250 |
kaklik |
1 |
<?php |
|
|
2 |
/* $Id: xml.php,v 2.8 2006/01/17 17:03:02 cybot_tm Exp $ */ |
|
|
3 |
// vim: expandtab sw=4 ts=4 sts=4: |
|
|
4 |
|
|
|
5 |
/** |
|
|
6 |
* Set of functions used to build XML dumps of tables |
|
|
7 |
*/ |
|
|
8 |
|
|
|
9 |
/** |
|
|
10 |
* Outputs comment |
|
|
11 |
* |
|
|
12 |
* @param string Text of comment |
|
|
13 |
* |
|
|
14 |
* @return bool Whether it suceeded |
|
|
15 |
*/ |
|
|
16 |
function PMA_exportComment($text) { |
|
|
17 |
return PMA_exportOutputHandler('<!-- ' . $text . ' -->' . $GLOBALS['crlf']); |
|
|
18 |
} |
|
|
19 |
|
|
|
20 |
/** |
|
|
21 |
* Outputs export footer |
|
|
22 |
* |
|
|
23 |
* @return bool Whether it suceeded |
|
|
24 |
* |
|
|
25 |
* @access public |
|
|
26 |
*/ |
|
|
27 |
function PMA_exportFooter() { |
|
|
28 |
return TRUE; |
|
|
29 |
} |
|
|
30 |
|
|
|
31 |
/** |
|
|
32 |
* Outputs export header |
|
|
33 |
* |
|
|
34 |
* @return bool Whether it suceeded |
|
|
35 |
* |
|
|
36 |
* @access public |
|
|
37 |
*/ |
|
|
38 |
function PMA_exportHeader() { |
|
|
39 |
global $crlf; |
|
|
40 |
global $cfg; |
|
|
41 |
|
|
|
42 |
if ($GLOBALS['output_charset_conversion']) { |
|
|
43 |
$charset = $GLOBALS['charset_of_file']; |
|
|
44 |
} else { |
|
|
45 |
$charset = $GLOBALS['charset']; |
|
|
46 |
} |
|
|
47 |
|
|
|
48 |
$head = '<?xml version="1.0" encoding="' . $charset . '" ?>' . $crlf |
|
|
49 |
. '<!--' . $crlf |
|
|
50 |
. '-' . $crlf |
|
|
51 |
. '- phpMyAdmin XML Dump' . $crlf |
|
|
52 |
. '- version ' . PMA_VERSION . $crlf |
|
|
53 |
. '- http://www.phpmyadmin.net' . $crlf |
|
|
54 |
. '-' . $crlf |
|
|
55 |
. '- ' . $GLOBALS['strHost'] . ': ' . $cfg['Server']['host']; |
|
|
56 |
if (!empty($cfg['Server']['port'])) { |
|
|
57 |
$head .= ':' . $cfg['Server']['port']; |
|
|
58 |
} |
|
|
59 |
$head .= $crlf |
|
|
60 |
. '- ' . $GLOBALS['strGenTime'] . ': ' . PMA_localisedDate() . $crlf |
|
|
61 |
. '- ' . $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 |
|
|
62 |
. '- ' . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf |
|
|
63 |
. '-->' . $crlf . $crlf; |
|
|
64 |
return PMA_exportOutputHandler($head); |
|
|
65 |
} |
|
|
66 |
|
|
|
67 |
/** |
|
|
68 |
* Outputs database header |
|
|
69 |
* |
|
|
70 |
* @param string Database name |
|
|
71 |
* |
|
|
72 |
* @return bool Whether it suceeded |
|
|
73 |
* |
|
|
74 |
* @access public |
|
|
75 |
*/ |
|
|
76 |
function PMA_exportDBHeader($db) { |
|
|
77 |
global $crlf; |
|
|
78 |
$head = '<!--' . $crlf |
|
|
79 |
. '- ' . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf |
|
|
80 |
. '-->' . $crlf |
|
|
81 |
. '<' . $db . '>' . $crlf; |
|
|
82 |
return PMA_exportOutputHandler($head); |
|
|
83 |
} |
|
|
84 |
|
|
|
85 |
/** |
|
|
86 |
* Outputs database footer |
|
|
87 |
* |
|
|
88 |
* @param string Database name |
|
|
89 |
* |
|
|
90 |
* @return bool Whether it suceeded |
|
|
91 |
* |
|
|
92 |
* @access public |
|
|
93 |
*/ |
|
|
94 |
function PMA_exportDBFooter($db) { |
|
|
95 |
global $crlf; |
|
|
96 |
return PMA_exportOutputHandler('</' . $db . '>' . $crlf); |
|
|
97 |
} |
|
|
98 |
|
|
|
99 |
/** |
|
|
100 |
* Outputs create database database |
|
|
101 |
* |
|
|
102 |
* @param string Database name |
|
|
103 |
* |
|
|
104 |
* @return bool Whether it suceeded |
|
|
105 |
* |
|
|
106 |
* @access public |
|
|
107 |
*/ |
|
|
108 |
function PMA_exportDBCreate($db) { |
|
|
109 |
return TRUE; |
|
|
110 |
} |
|
|
111 |
|
|
|
112 |
|
|
|
113 |
/** |
|
|
114 |
* Outputs the content of a table |
|
|
115 |
* |
|
|
116 |
* @param string the database name |
|
|
117 |
* @param string the table name |
|
|
118 |
* @param string the end of line sequence |
|
|
119 |
* @param string the url to go back in case of error |
|
|
120 |
* @param string SQL query for obtaining data |
|
|
121 |
* |
|
|
122 |
* @return bool Whether it suceeded |
|
|
123 |
* |
|
|
124 |
* @access public |
|
|
125 |
*/ |
|
|
126 |
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { |
|
|
127 |
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED); |
|
|
128 |
|
|
|
129 |
$columns_cnt = PMA_DBI_num_fields($result); |
|
|
130 |
for ($i = 0; $i < $columns_cnt; $i++) { |
|
|
131 |
$columns[$i] = stripslashes(PMA_DBI_field_name($result, $i)); |
|
|
132 |
} |
|
|
133 |
unset($i); |
|
|
134 |
|
|
|
135 |
$buffer = ' <!-- ' . $GLOBALS['strTable'] . ' ' . $table . ' -->' . $crlf; |
|
|
136 |
if (!PMA_exportOutputHandler($buffer)) { |
|
|
137 |
return FALSE; |
|
|
138 |
} |
|
|
139 |
|
|
|
140 |
while ($record = PMA_DBI_fetch_row($result)) { |
|
|
141 |
$buffer = ' <' . $table . '>' . $crlf; |
|
|
142 |
for ($i = 0; $i < $columns_cnt; $i++) { |
|
|
143 |
if ( isset($record[$i]) && !is_null($record[$i])) { |
|
|
144 |
$buffer .= ' <' . $columns[$i] . '>' . htmlspecialchars($record[$i]) |
|
|
145 |
. '</' . $columns[$i] . '>' . $crlf; |
|
|
146 |
} |
|
|
147 |
} |
|
|
148 |
$buffer .= ' </' . $table . '>' . $crlf; |
|
|
149 |
|
|
|
150 |
if (!PMA_exportOutputHandler($buffer)) { |
|
|
151 |
return FALSE; |
|
|
152 |
} |
|
|
153 |
} |
|
|
154 |
PMA_DBI_free_result($result); |
|
|
155 |
|
|
|
156 |
return TRUE; |
|
|
157 |
} // end of the 'PMA_getTableXML()' function |
|
|
158 |
?> |