Source for file decodeheader.php

Documentation is available at decodeheader.php

  1. <?php
  2. /**
  3. * SquirrelMail Test Plugin
  4. *
  5. * This page tests the decodeHeader function.
  6. *
  7. * @copyright 2006-2020 The SquirrelMail Project Team
  8. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  9. * @version $Id: decodeheader.php 14840 2020年01月07日 07:42:38Z pdontthink $
  10. * @package plugins
  11. * @subpackage test
  12. */
  13. define ('SM_PATH', '../../');
  14. include_once(SM_PATH . 'include/validate.php');
  15. include_once(SM_PATH . 'functions/mime.php');
  16. global $oTemplate, $color;
  17. displayPageHeader ($color, 'none');
  18. $header = array("< & \xC3", // plain text
  19. '=?iso-8859-1?Q?=3C_&__=C3?=', // Q encoding
  20. '=?iso-8859-1?B?PCAmICDD?=', // B encoding
  21. '=?utf-8?Q?=3C_&__=C3=80?=', // Q encoding other charset
  22. '=?utf-8?B?PCAmICDDgA==?=', // B encoding other charset
  23. );
  24. if (sqGetGlobalVar('lossy', $lossy, SQ_GET )) {
  25. if ($lossy) {
  26. $lossy_encoding = true;
  27. } else {
  28. if ($default_charset == 'utf-8')
  29. $default_charset = 'iso-8859-1';
  30. $lossy_encoding = false;
  31. }
  32. }
  33. echo "<strong>decodeHeader() Test:</strong>\n";
  34. if ($default_charset == 'utf-8' || $lossy_encoding) {
  35. echo '<p><a href="decodeheader.php?lossy=0">Test with lossy_encoding OFF</a></p>';
  36. } else {
  37. echo '<p><a href="decodeheader.php?lossy=1">Test with lossy_encoding ON</a></p>';
  38. }
  39. echo '<p>Default charset: ' . $default_charset . "<br />\n"
  40. . 'Lossy_encoding: ' . ($lossy_encoding ? 'true' : 'false') . '</p>';
  41. echo '<p>The results of this test depend on your current language (translation) selection (see Options==>Display Preferences) (and the character set it employs) and your $lossy_encoding setting (see config/config.php or conf.pl ==> 10 ==> 5).</p>';
  42. echo '<pre>';
  43. echo "(MDN) 000:\n html chars are not encoded,\n space is not encoded,\n 8bit chars are unmodified\n";
  44. foreach ($header as $test) {
  45. echo htmlentities (decodeHeader ($test, false, false, false));
  46. echo "\n";
  47. }
  48. echo "--------\n";
  49. echo "(compose) 001:\n html chars are not encoded,\n space is not encoded,\n 8bit chars may be converted or not (depends on \$lossy_encoding and \$default_charset)\n";
  50. foreach ($header as $test) {
  51. echo htmlentities (decodeHeader ($test, false, false, true));
  52. echo "\n";
  53. }
  54. echo "--------\n";
  55. echo "010\n";
  56. foreach ($header as $test) {
  57. echo htmlentities (decodeHeader ($test, false, true, false));
  58. echo "\n";
  59. }
  60. echo "--------\n";
  61. echo "011\n";
  62. foreach ($header as $test) {
  63. echo htmlentities (decodeHeader ($test, false, true, true));
  64. echo "\n";
  65. }
  66. echo "--------\n";
  67. echo "(download) 100\n";
  68. foreach ($header as $test) {
  69. echo htmlentities (decodeHeader ($test, true, false, false));
  70. echo "\n";
  71. }
  72. echo "--------\n";
  73. echo "101\n";
  74. foreach ($header as $test) {
  75. echo htmlentities (decodeHeader ($test, true, false, true));
  76. echo "\n";
  77. }
  78. echo "--------\n";
  79. echo "(default) 110\n";
  80. foreach ($header as $test) {
  81. echo htmlentities (decodeHeader ($test, true, true, false));
  82. echo "\n";
  83. }
  84. echo "--------\n";
  85. echo "111\n";
  86. foreach ($header as $test) {
  87. echo htmlentities (decodeHeader ($test, true, true, true));
  88. echo "\n";
  89. }
  90. echo "--------\n";
  91. echo '</pre></body></html>';

Documentation generated on 2020年1月13日 04:24:28 +0100 by phpDocumentor 1.4.3

AltStyle によって変換されたページ (->オリジナル) /