home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / xamp / xampp-win32.exe / xampp / .tmp006.phpt < prev    next >
Encoding:
Text File  |  2004-03-24  |  1.9 KB  |  99 lines

  1. --TEST--
  2. Check extract_part_file
  3. --SKIPIF--
  4. <?php 
  5. /* vim600: sw=4 ts=4 fdm=marker syn=php
  6. */
  7. if (!extension_loaded("mailparse")) @dl("mailparse.so");
  8. if (!extension_loaded("mailparse")) print "skip"; ?>
  9. --POST--
  10. --GET--
  11. --FILE--
  12. <?php
  13. if (!extension_loaded("mailparse")) @dl("mailparse.so");
  14. $text = <<<EOD
  15. To: fred@bloggs.com
  16. Mime-Version: 1.0
  17. Content-Type: text/plain
  18. Subject: A simple MIME message
  19.  
  20. hello, this is some text hello.
  21. blah blah blah.
  22.  
  23. EOD;
  24.  
  25. $fp = tmpfile();
  26. fwrite($fp, $text);
  27. rewind($fp);
  28.  
  29.  
  30. $mime = mailparse_msg_create();
  31. mailparse_msg_parse($mime, $text);
  32.  
  33. echo "Extract to output\n";
  34. mailparse_msg_extract_part_file($mime, $fp);
  35.  
  36. echo "Extract and return as string\n";
  37. $result = mailparse_msg_extract_part_file($mime, $fp, null);
  38. echo "-->\n";
  39. echo $result;
  40.  
  41. echo "\nExtract to open file\n";
  42. $fpdest = tmpfile();
  43. mailparse_msg_extract_part_file($mime, $fp, $fpdest);
  44. echo "\nrewinding\n";
  45. rewind($fpdest);
  46. fpassthru($fpdest);
  47.  
  48. echo "\nExtract via user function\n";
  49. $cbdata = "";
  50. function callbackfunc($data) {
  51.     $GLOBALS["cbdata"] .= $data;
  52. }
  53. mailparse_msg_extract_part_file($mime, $fp, "callbackfunc");
  54. echo "callback data is:\n";
  55. var_dump($cbdata);
  56.  
  57. echo "\nExtract whole part to output\n";
  58. mailparse_msg_extract_whole_part_file($mime, $fp);
  59.  
  60. echo "\nExtract part from string to output\n";
  61. mailparse_msg_extract_part($mime, $text);
  62. fclose($fpdest);
  63. fclose($fp);
  64.  
  65. ?>
  66. --EXPECT--
  67. Extract to output
  68. hello, this is some text hello.
  69. blah blah blah.
  70. Extract and return as string
  71. -->
  72. hello, this is some text hello.
  73. blah blah blah.
  74.  
  75. Extract to open file
  76.  
  77. rewinding
  78. hello, this is some text hello.
  79. blah blah blah.
  80.  
  81. Extract via user function
  82. callback data is:
  83. string(48) "hello, this is some text hello.
  84. blah blah blah.
  85. "
  86.  
  87. Extract whole part to output
  88. To: fred@bloggs.com
  89. Mime-Version: 1.0
  90. Content-Type: text/plain
  91. Subject: A simple MIME message
  92.  
  93. hello, this is some text hello.
  94. blah blah blah.
  95.  
  96. Extract part from string to output
  97. hello, this is some text hello.
  98. blah blah blah.
  99.