functions.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?PHP
  2. /* functions for info plugin
  3. * Copyright (c) 1999-2002 The SquirrelMail Project Team
  4. * Licensed under the GNU GPL. For full terms see the file COPYING.
  5. *
  6. * Here are two functions for the info plugin
  7. * The first gets the CAPABILITY response from your IMAP server.
  8. * The second runs the passed IMAP test and returns the results
  9. * The third prints the results of the IMAP command
  10. * to options.php.
  11. * by: Jason Munro jason@stdbev.com
  12. */
  13. function get_caps($imap_stream) {
  14. $sid = sqimap_session_id();
  15. $query = "$sid CAPABILITY\r\n";
  16. fputs ($imap_stream, $query);
  17. $responses = sqimap_read_data_list($imap_stream, $sid, true, $responses, $message);
  18. return $responses;
  19. }
  20. function imap_test($imap_stream, $string) {
  21. global $default_charset;
  22. $message = '';
  23. $responses = array ();
  24. $sid = sqimap_session_id();
  25. $results = array();
  26. $query = "$sid ".trim($string)."\r\n";
  27. print "<TR><TD>".$query."</TD></TR>";
  28. fputs ($imap_stream, $query);
  29. $response = sqimap_read_data_list($imap_stream, $sid, false, $responses, $message);
  30. array_push($response, $message);
  31. return $response;
  32. }
  33. function print_response($response) {
  34. foreach($response as $index=>$value) {
  35. if (is_array($value)) {
  36. print_response($value);
  37. }
  38. else {
  39. $value = preg_replace("/</", "&lt;", $value);
  40. $value = preg_replace("/>/", "&gt;", $value);
  41. print $value."<BR>\n";
  42. }
  43. }
  44. }
  45. ?>