/admin/phpMyAdmin_old/libraries/export/xml.php

https://bitbucket.org/steve_delbar/iepsm-projet-de-d-veloppement-internet-2013 · PHP · 154 lines · 72 code · 16 blank · 66 comment · 10 complexity · 05991d45bbbf612d36f930291fc87142 MD5 · raw file

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