Source for file spamcop.php

Documentation is available at spamcop.php

  1. <?php
  2. /**
  3. ** spamcop.php -- SpamCop plugin
  4. *
  5. ** Copyright (c) 1999-2020 The SquirrelMail Project Team
  6. ** Licensed under the GNU GPL. For full terms see the file COPYING.
  7. *
  8. ** $Id: spamcop.php 14840 2020年01月07日 07:42:38Z pdontthink $
  9. **/
  10. define ('SM_PATH','../../');
  11. /* SquirrelMail required files. */
  12. require_once(SM_PATH . 'include/validate.php');
  13. require_once(SM_PATH . 'functions/imap.php');
  14. function getMessage_RFC822_Attachment ($message, $composeMessage, $passed_id,
  15. $passed_ent_id='', $imapConnection) {
  16. global $attachments, $attachment_dir , $username, $data_dir , $uid_support ;
  17. $hashed_attachment_dir = getHashedDir ($username, $attachment_dir);
  18. $localfilename = GenerateRandomString (32, 'FILE', 7);
  19. if (!$passed_ent_id) {
  20. $body_a = sqimap_run_command ($imapConnection,
  21. 'FETCH '.$passed_id.' RFC822',
  22. TRUE, $response, $readmessage,
  23. $uid_support);
  24. } else {
  25. $body_a = sqimap_run_command ($imapConnection,
  26. 'FETCH '.$passed_id.' BODY['.$passed_ent_id.']',
  27. TRUE, $response, $readmessage, $uid_support);
  28. $message = $message->parent;
  29. }
  30. if ($response == 'OK') {
  31. $subject = encodeHeader ($message->rfc822_header->subject);
  32. array_shift ($body_a);
  33. $body = implode ('', $body_a) . "\r\n";
  34. $full_localfilename = "$hashed_attachment_dir/$localfilename";
  35. $fp = fopen ( $full_localfilename, 'w');
  36. fwrite ($fp, $body);
  37. fclose ($fp);
  38. $composeMessage->initAttachment('message/rfc822','email.txt', $localfilename);
  39. }
  40. return $composeMessage;
  41. }
  42. /* GLOBALS */
  43. sqgetGlobalVar ('username', $username, SQ_SESSION );
  44. sqgetGlobalVar ('key', $key, SQ_COOKIE );
  45. sqgetGlobalVar ('onetimepad', $onetimepad, SQ_SESSION );
  46. sqgetGlobalVar ('mailbox', $mailbox, SQ_GET );
  47. sqgetGlobalVar ('passed_id', $passed_id, SQ_GET );
  48. if (! sqgetGlobalVar ('startMessage', $startMessage, SQ_GET ) ) {
  49. $startMessage = 1;
  50. }
  51. if (! sqgetGlobalVar ('passed_ent_id', $passed_ent_id, SQ_GET ) ) {
  52. $passed_ent_id = 0;
  53. }
  54. sqgetGlobalVar ('compose_messages', $compose_messages, SQ_SESSION );
  55. if(! sqgetGlobalVar ('composesession', $composesession, SQ_SESSION ) ) {
  56. $composesession = 0;
  57. sqsession_register ($composesession, 'composesession');
  58. }
  59. global $imap_stream_options; // in case not defined in config
  60. /* END GLOBALS */
  61. displayPageHeader ($color, $mailbox);
  62. $imap_stream = sqimap_login ($username, $key, $imapServerAddress,
  63. $imapPort, 0, $imap_stream_options);
  64. sqimap_mailbox_select ($imap_stream, $mailbox);
  65. if ($spamcop_method == 'quick_email' ||
  66. $spamcop_method == 'thorough_email') {
  67. // Use email-based reporting -- save as an attachment
  68. $session = "$composesession"+1;
  69. $composesession = $session;
  70. sqsession_register ($composesession,'composesession');
  71. if (!isset($compose_messages)) {
  72. $compose_messages = array();
  73. }
  74. if (!isset($compose_messages[$session]) || ($compose_messages[$session] == NULL)) {
  75. $composeMessage = new Message ();
  76. $rfc822_header = new Rfc822Header ();
  77. $composeMessage->rfc822_header = $rfc822_header;
  78. $composeMessage->reply_rfc822_header = '';
  79. $compose_messages[$session] = $composeMessage;
  80. sqsession_register ($compose_messages,'compose_messages');
  81. } else {
  82. $composeMessage=$compose_messages[$session];
  83. }
  84. $message = sqimap_get_message ($imap_stream, $passed_id, $mailbox);
  85. $composeMessage = getMessage_RFC822_Attachment ($message, $composeMessage, $passed_id,
  86. $passed_ent_id, $imap_stream);
  87. $compose_messages[$session] = $composeMessage;
  88. sqsession_register ($compose_messages, 'compose_messages');
  89. $fn = getPref ($data_dir, $username, 'full_name');
  90. $em = getPref ($data_dir, $username, 'email_address');
  91. $HowItLooks = $fn . ' ';
  92. if ($em != '')
  93. $HowItLooks .= '<' . $em . '>';
  94. }
  95. echo "<p>";
  96. echo _ ("Sending this spam report will give you back a reply with URLs that you can click on to properly report this spam message to the proper authorities. This is a free service. By pressing the \"Send Spam Report\" button, you agree to follow SpamCop's rules/terms of service/etc.");
  97. echo "</p>";
  98. ?>
  99. <table align="center" width="75%" border="0" cellpadding="0" cellspacing="0">
  100. <tr>
  101. <td align="left" valign="top">
  102. <?php if (isset($js_web) && $js_web) {
  103. echo "<form method=\"post\" action=\"javascript:return false\">\n";
  104. echo '<input type="button" value="' . _ ("Close Window") . "\" onClick=\"window.close(); return true;\" />\n";
  105. } else {
  106. ?><form method="post" action="<?php echo sqm_baseuri (); ?>src/right_main.php">
  107. <input type="hidden" name="mailbox" value="<?php echo sm_encode_html_special_chars ($mailbox) ?>" />
  108. <input type="hidden" name="startMessage" value="<?php echo sm_encode_html_special_chars ($startMessage) ?>" />
  109. <?php
  110. echo '<input type="submit" value="' . _ ("Cancel / Done") . "\" />\n";
  111. }
  112. ?></form>
  113. </td>
  114. <td align="right" valign="top">
  115. <?php if ($spamcop_method == 'thorough_email' ||
  116. $spamcop_method == 'quick_email') {
  117. if ($spamcop_method == 'thorough_email')
  118. $report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net';
  119. else
  120. $report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net';
  121. $form_action = sqm_baseuri () . 'src/compose.php';
  122. ?> <form method="post" action="<?php echo $form_action?>">
  123. <input type="hidden" name="smtoken" value="<?php echo sm_generate_security_token (); ?>" />
  124. <input type="hidden" name="mailbox" value="<?php echo sm_encode_html_special_chars ($mailbox) ?>" />
  125. <input type="hidden" name="spamcop_is_composing" value="<?php echo sm_encode_html_special_chars ($passed_id) ?>" />
  126. <input type="hidden" name="send_to" value="<?php echo sm_encode_html_special_chars ($report_email)?>" />
  127. <input type="hidden" name="subject" value="reply anyway" />
  128. <input type="hidden" name="identity" value="0" />
  129. <input type="hidden" name="session" value="<?php echo $session?>" />
  130. <?php
  131. echo '<input type="submit" name="send" value="' . _ ("Send Spam Report") . "\" />\n";
  132. } else {
  133. $spam_message = mime_fetch_body ($imap_stream, $passed_id, $passed_ent_id, 50000);
  134. if (strlen ($spam_message) == 50000) {
  135. $Warning = "\n[truncated by SpamCop]\n";
  136. $spam_message = substr ($spam_message, 0, 50000 - strlen ($Warning)) . $Warning;
  137. }
  138. if (isset($js_web) && $js_web) {
  139. ?> <form method="post" action="http://members.spamcop.net/sc" name="submitspam"
  140. enctype="multipart/form-data"><?php
  141. } else {
  142. ?> <form method="post" action="http://members.spamcop.net/sc" name="submitspam"
  143. enctype="multipart/form-data" target="_top"><?php
  144. } ?>
  145. <input type="hidden" name="action" value="submit" />
  146. <input type="hidden" name="oldverbose" value="1" />
  147. <input type="hidden" name="spam" value="<?php echo sm_encode_html_special_chars ($spam_message); ?>" />
  148. <?php
  149. echo '<input type="submit" name="x1" value="' . _ ("Send Spam Report") . "\" />";
  150. }
  151. ?>
  152. </form>
  153. </td></tr>
  154. </table>
  155. </body></html>

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

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