spamcop.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <?php
  2. /**
  3. * spamcop.php -- SpamCop plugin -- main page
  4. *
  5. * @copyright &copy; 1999-2007 The SquirrelMail Project Team
  6. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  7. * @version $Id$
  8. * @package plugins
  9. * @subpackage spamcop
  10. */
  11. /**
  12. * Include the SquirrelMail initialization file.
  13. */
  14. require('../../include/init.php');
  15. /* IMAP functions depend on date and mime */
  16. include_once(SM_PATH . 'functions/date.php');
  17. include_once(SM_PATH . 'functions/mime.php');
  18. /* IMAP functions */
  19. include_once(SM_PATH . 'functions/imap_general.php');
  20. include_once(SM_PATH . 'functions/imap_messages.php');
  21. /* plugin functions */
  22. include_once(SM_PATH . 'plugins/spamcop/functions.php');
  23. include_once(SM_PATH . 'functions/compose.php');
  24. /* GLOBALS */
  25. sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
  26. sqgetGlobalVar('passed_id', $passed_id, SQ_GET);
  27. sqgetGlobalVar('js_web', $js_web, SQ_GET);
  28. if (! sqgetGlobalVar('startMessage', $startMessage, SQ_GET) ) {
  29. $startMessage = 1;
  30. }
  31. if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) {
  32. $passed_ent_id = 0;
  33. }
  34. if (! sqgetGlobalVar('js_web', $js_web, SQ_GET) ) {
  35. $js_web = 0;
  36. }
  37. sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION);
  38. if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION) ) {
  39. $composesession = 0;
  40. sqsession_register($composesession, 'composesession');
  41. }
  42. /* END GLOBALS */
  43. // js_web variable is 1 only when link opens web based report page in new window
  44. // and in new window menu line or extra javascript code is not needed.
  45. if ($js_web) {
  46. displayHTMLHeader(_("SpamCop reporting"));
  47. echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n";
  48. } else {
  49. displayPageHeader($color,$mailbox);
  50. }
  51. /** is spamcop plugin disabled */
  52. if (! is_plugin_enabled('spamcop')) {
  53. error_box(_("Plugin is disabled."));
  54. // display footer (closes html tags) and stop script execution
  55. $oTemplate->display('footer.tpl');
  56. exit();
  57. }
  58. $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
  59. sqimap_mailbox_select($imap_stream, $mailbox);
  60. if ($spamcop_method == 'quick_email' ||
  61. $spamcop_method == 'thorough_email') {
  62. // Use email-based reporting -- save as an attachment
  63. $session = "$composesession"+1;
  64. $composesession = $session;
  65. sqsession_register($composesession,'composesession');
  66. if (!isset($compose_messages)) {
  67. $compose_messages = array();
  68. }
  69. if (!isset($compose_messages[$session]) || ($compose_messages[$session] == NULL)) {
  70. $composeMessage = new Message();
  71. $rfc822_header = new Rfc822Header();
  72. $composeMessage->rfc822_header = $rfc822_header;
  73. $composeMessage->reply_rfc822_header = '';
  74. $compose_messages[$session] = $composeMessage;
  75. sqsession_register($compose_messages,'compose_messages');
  76. } else {
  77. $composeMessage=$compose_messages[$session];
  78. }
  79. $message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
  80. $composeMessage = spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
  81. $passed_ent_id, $imap_stream);
  82. $compose_messages[$session] = $composeMessage;
  83. sqsession_register($compose_messages, 'compose_messages');
  84. $fn = getPref($data_dir, $username, 'full_name');
  85. $em = getPref($data_dir, $username, 'email_address');
  86. $HowItLooks = $fn . ' ';
  87. if ($em != '')
  88. $HowItLooks .= '<' . $em . '>';
  89. }
  90. echo "<p>";
  91. 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.");
  92. echo "</p>";
  93. ?>
  94. <table align="center" width="75%" border="0" cellpadding="0" cellspacing="0">
  95. <tr>
  96. <td align="left" valign="top">
  97. <?php if (isset($js_web) && $js_web) {
  98. echo '<form method="post" action="javascript:return false">';
  99. echo '<input type="button" value="' . _("Close Window") . "\" onclick=\"window.close(); return true;\" />\n";
  100. } else {
  101. ?><form method="post" action="<?php echo sqm_baseuri(); ?>src/right_main.php">
  102. <input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" />
  103. <input type="hidden" name="startMessage" value="<?php echo htmlspecialchars($startMessage) ?>" />
  104. <?php
  105. echo '<input type="submit" value="' . _("Cancel / Done") . "\" />";
  106. }
  107. ?></form>
  108. </td>
  109. <td align="right" valign="top">
  110. <?php if ($spamcop_method == 'thorough_email' ||
  111. $spamcop_method == 'quick_email') {
  112. if ($spamcop_method == 'thorough_email')
  113. $report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net';
  114. else
  115. $report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net';
  116. $form_action = sqm_baseuri() . 'src/compose.php';
  117. ?> <form method="post" action="<?php echo $form_action?>">
  118. <input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" />
  119. <input type="hidden" name="spamcop_is_composing" value="<?php echo htmlspecialchars($passed_id) ?>" />
  120. <input type="hidden" name="send_to" value="<?php echo htmlspecialchars($report_email)?>" />
  121. <input type="hidden" name="subject" value="reply anyway" />
  122. <input type="hidden" name="identity" value="0" />
  123. <input type="hidden" name="session" value="<?php echo $session?>" />
  124. <?php
  125. echo '<input type="submit" name="send" value="' . _("Send Spam Report") . "\" />\n";
  126. } else {
  127. $spam_message = mime_fetch_body ($imap_stream, $passed_id, $passed_ent_id, 50000);
  128. if (strlen($spam_message) == 50000) {
  129. $Warning = "\n[truncated by SpamCop]\n";
  130. $spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning;
  131. }
  132. $action_url="http://members.spamcop.net/sc";
  133. if (isset($js_web) && $js_web) {
  134. echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
  135. " enctype=\"multipart/form-data\">\n";
  136. } else {
  137. echo "<form method=\"post\" action=\"$action_url\" name=\"submitspam\"".
  138. " enctype=\"multipart/form-data\" target=\"_blank\">\n";
  139. } ?>
  140. <input type="hidden" name="action" value="submit" />
  141. <input type="hidden" name="oldverbose" value="1" />
  142. <input type="hidden" name="spam" value="<?php echo htmlspecialchars($spam_message); ?>" />
  143. <?php
  144. echo '<input type="submit" name="x1" value="' . _("Send Spam Report") . "\" />\n";
  145. }
  146. ?> </form>
  147. </td>
  148. </tr>
  149. </table>
  150. </body>
  151. </html>