basexml.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /*
  3. * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  4. * Copyright (C) 2003-2010 Frederico Caldeira Knabben
  5. *
  6. * == BEGIN LICENSE ==
  7. *
  8. * Licensed under the terms of any of the following licenses at your
  9. * choice:
  10. *
  11. * - GNU General Public License Version 2 or later (the "GPL")
  12. * http://www.gnu.org/licenses/gpl.html
  13. *
  14. * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  15. * http://www.gnu.org/licenses/lgpl.html
  16. *
  17. * - Mozilla Public License Version 1.1 or later (the "MPL")
  18. * http://www.mozilla.org/MPL/MPL-1.1.html
  19. *
  20. * == END LICENSE ==
  21. *
  22. * These functions define the base of the XML response sent by the PHP
  23. * connector.
  24. */
  25. /**
  26. * SetXmlHeaders
  27. *
  28. * @return void
  29. */
  30. function SetXmlHeaders()
  31. {
  32. ob_end_clean();
  33. // Prevent the browser from caching the result.
  34. // Date in the past
  35. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
  36. // always modified
  37. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  38. // HTTP/1.1
  39. header('Cache-Control: no-store, no-cache, must-revalidate');
  40. header('Cache-Control: post-check=0, pre-check=0', false);
  41. // HTTP/1.0
  42. header('Pragma: no-cache');
  43. // Set the response format.
  44. header('Content-Type: text/xml; charset=utf-8');
  45. }
  46. function CreateXmlHeader( $command, $resourceType, $currentFolder )
  47. {
  48. SetXmlHeaders();
  49. // Create the XML document header.
  50. echo '<?xml version="1.0" encoding="utf-8" ?>' ;
  51. // Create the main "Connector" node.
  52. echo '<Connector command="' . $command . '" resourceType="' . $resourceType . '">' ;
  53. // Add the current folder node.
  54. echo '<CurrentFolder path="' . ConvertToXmlAttribute($currentFolder) . '" url="' . ConvertToXmlAttribute(GetUrlFromPath($resourceType, $currentFolder, $command)) . '" />' ;
  55. $GLOBALS['HeaderSent'] = true ;
  56. }
  57. function CreateXmlFooter()
  58. {
  59. echo '</Connector>' ;
  60. }
  61. /**
  62. * SendError
  63. *
  64. * @param unknown_type $number Number
  65. * @param unknown_type $text Text
  66. * @return void
  67. */
  68. function SendError($number, $text)
  69. {
  70. if ( $_GET['Command'] == 'FileUpload' )
  71. SendUploadResults($number, "", "", $text);
  72. if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] )
  73. {
  74. SendErrorNode($number, $text);
  75. CreateXmlFooter();
  76. }
  77. else
  78. {
  79. SetXmlHeaders();
  80. // Create the XML document header
  81. echo '<?xml version="1.0" encoding="utf-8" ?>' ;
  82. echo '<Connector>' ;
  83. SendErrorNode($number, $text);
  84. echo '</Connector>' ;
  85. }
  86. exit ;
  87. }
  88. function SendErrorNode($number, $text)
  89. {
  90. if ($text)
  91. echo '<Error number="' . $number . '" text="' . htmlspecialchars($text) . '" />' ;
  92. else
  93. echo '<Error number="' . $number . '" />' ;
  94. }