squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

spamcop.php
Go to the documentation of this file.
1 <?php
11 define('SM_PATH','../../');
12 
13  /* SquirrelMail required files. */
14 require_once(SM_PATH . 'include/validate.php');
15 require_once(SM_PATH . 'functions/imap.php');
16 
17 function getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
18  $passed_ent_id='', $imapConnection) {
20 
21  $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
22  $localfilename = GenerateRandomString(32, 'FILE', 7);
23 
24  if (!$passed_ent_id) {
26  'FETCH '.$passed_id.' RFC822',
27  TRUE, $response, $readmessage,
28  $uid_support);
29  } else {
31  'FETCH '.$passed_id.' BODY['.$passed_ent_id.']',
32  TRUE, $response, $readmessage, $uid_support);
33  $message = $message->parent;
34  }
35  if ($response == 'OK') {
36  $subject = encodeHeader($message->rfc822_header->subject);
37  array_shift($body_a);
38  $body = implode('', $body_a) . "\r\n";
39 
40  $full_localfilename = "$hashed_attachment_dir/$localfilename";
41  $fp = fopen( $full_localfilename, 'w');
42  fwrite ($fp, $body);
43  fclose($fp);
44 
45  $composeMessage->initAttachment('message/rfc822','email.txt', $localfilename);
46  }
47  return $composeMessage;
48 }
49 
50 
51 /* GLOBALS */
52 
53 sqgetGlobalVar('username', $username, SQ_SESSION);
54 sqgetGlobalVar('key', $key, SQ_COOKIE);
55 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
56 
57 sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
58 sqgetGlobalVar('passed_id', $passed_id, SQ_GET);
59 
60 if (! sqgetGlobalVar('startMessage', $startMessage, SQ_GET) ) {
61  $startMessage = 1;
62 }
63 if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) {
64  $passed_ent_id = 0;
65 }
66 
67 sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION);
68 
69 if(! sqgetGlobalVar('composesession', $composesession, SQ_SESSION) ) {
70  $composesession = 0;
71  sqsession_register($composesession, 'composesession');
72 }
73 /* END GLOBALS */
74 
75 
77 
79  $imapPort, 0);
81 
82  if ($spamcop_method == 'quick_email' ||
83  $spamcop_method == 'thorough_email') {
84  // Use email-based reporting -- save as an attachment
85  $session = "$composesession"+1;
86  $composesession = $session;
87  sqsession_register($composesession,'composesession');
88  if (!isset($compose_messages)) {
89  $compose_messages = array();
90  }
91  if (!isset($compose_messages[$session]) || ($compose_messages[$session] == NULL)) {
92  $composeMessage = new Message();
94  $composeMessage->rfc822_header = $rfc822_header;
95  $composeMessage->reply_rfc822_header = '';
96  $compose_messages[$session] = $composeMessage;
97  sqsession_register($compose_messages,'compose_messages');
98  } else {
99  $composeMessage=$compose_messages[$session];
100  }
101 
102 
104  $composeMessage = getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
105  $passed_ent_id, $imap_stream);
106 
107  $compose_messages[$session] = $composeMessage;
108  sqsession_register($compose_messages, 'compose_messages');
109 
110  $fn = getPref($data_dir, $username, 'full_name');
111  $em = getPref($data_dir, $username, 'email_address');
112 
113  $HowItLooks = $fn . ' ';
114  if ($em != '')
115  $HowItLooks .= '<' . $em . '>';
116  }
117 
118 
119 echo "<p>";
120 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.");
121 echo "</p>";
122 
123 ?>
124 
125 <table align="center" width="75%" border="0" cellpadding="0" cellspacing="0">
126 <tr>
127 <td align="left" valign="top">
128 <?php if (isset($js_web) && $js_web) {
129  echo "<form method=\"post\" action=\"javascript:return false\">\n";
130  echo '<input type="button" value="' . _("Close Window") . "\" onClick=\"window.close(); return true;\" />\n";
131 } else {
132  ?><form method="post" action="<?php echo sqm_baseuri(); ?>src/right_main.php">
133  <input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" />
134  <input type="hidden" name="startMessage" value="<?php echo htmlspecialchars($startMessage) ?>" />
135  <?php
136  echo '<input type="submit" value="' . _("Cancel / Done") . "\" />\n";
137 }
138  ?></form>
139 </td>
140 <td align="right" valign="top">
141 <?php if ($spamcop_method == 'thorough_email' ||
142  $spamcop_method == 'quick_email') {
143  if ($spamcop_method == 'thorough_email')
144  $report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net';
145  else
146  $report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net';
147  $form_action = sqm_baseuri() . 'src/compose.php';
148 ?> <form method="post" action="<?php echo $form_action?>">
149  <input type="hidden" name="smtoken" value="<?php echo sm_generate_security_token(); ?>" />
150  <input type="hidden" name="mailbox" value="<?php echo htmlspecialchars($mailbox) ?>" />
151  <input type="hidden" name="spamcop_is_composing" value="<?php echo htmlspecialchars($passed_id) ?>" />
152  <input type="hidden" name="send_to" value="<?php echo htmlspecialchars($report_email)?>" />
153  <input type="hidden" name="subject" value="reply anyway" />
154  <input type="hidden" name="identity" value="0" />
155  <input type="hidden" name="session" value="<?php echo $session?>" />
156 <?php
157  echo '<input type="submit" name="send" value="' . _("Send Spam Report") . "\" />\n";
158  } else {
159  $spam_message = mime_fetch_body ($imap_stream, $passed_id, $passed_ent_id, 50000);
160 
161  if (strlen($spam_message) == 50000) {
162  $Warning = "\n[truncated by SpamCop]\n";
163  $spam_message = substr($spam_message, 0, 50000 - strlen($Warning)) . $Warning;
164  }
165  if (isset($js_web) && $js_web) {
166 ?> <form method="post" action="http://members.spamcop.net/sc" name="submitspam"
167  enctype="multipart/form-data"><?php
168  } else {
169 ?> <form method="post" action="http://members.spamcop.net/sc" name="submitspam"
170  enctype="multipart/form-data" target="_top"><?php
171  } ?>
172  <input type="hidden" name="action" value="submit" />
173  <input type="hidden" name="oldverbose" value="1" />
174  <input type="hidden" name="spam" value="<?php echo htmlspecialchars($spam_message); ?>" />
175 <?php
176  echo '<input type="submit" name="x1" value="' . _("Send Spam Report") . "\" />";
177  }
178 ?>
179 </form>
180 </td></tr>
181 </table>
182 </body></html>
$body
if(isset($ldap_server) && $ldap_server[0] &&! extension_loaded('ldap')) $body
Definition: bug_report.php:106
sqgetGlobalVar
sqgetGlobalVar($name, &$value, $search=SQ_INORDER)
Definition: global.php:344
$imapConnection
$imapConnection
Definition: message_details_bottom.php:74
getPref
getPref($data_dir, $username, $string, $default='')
Definition: db_prefs.php:316
$imapServerAddress
$imapServerAddress
Definition: config_default.php:202
sqimap_login
sqimap_login($username, $password, $imap_server_address, $imap_port, $hide)
Definition: imap_general.php:481
$rfc822_header
$rfc822_header
Definition: compose.php:362
$data_dir
$data_dir
Definition: config_default.php:499
SQ_SESSION
const SQ_SESSION
Definition: global.php:18
SM_PATH
const SM_PATH
Definition: spamcop.php:11
displayPageHeader
displayPageHeader($color, $mailbox, $xtra='', $session=false)
Definition: page_header.php:105
$mailbox
$mailbox
Definition: options.php:28
sqm_baseuri
sqm_baseuri()
Definition: strings.php:315
html
Definition: html.class.php:18
$username
global $username
Definition: validate.php:55
mime_fetch_body
mime_fetch_body($imap_stream, $id, $ent_id=1, $fetch_size=0)
Definition: mime.php:100
sqimap_mailbox_select
sqimap_mailbox_select($imap_stream, $mailbox)
Definition: imap_mailbox.php:238
$uid_support
$uid_support
Definition: config_default.php:643
getMessage_RFC822_Attachment
getMessage_RFC822_Attachment($message, $composeMessage, $passed_id, $passed_ent_id='', $imapConnection)
Definition: spamcop.php:17
$message
$message
Definition: download.php:54
getHashedDir
getHashedDir($username, $dir, $hash_dirs='')
Definition: prefs.php:109
$attachments
$attachments
Definition: printer_friendly_bottom.php:113
Rfc822Header
Definition: Rfc822Header.class.php:26
$attachment_dir
$attachment_dir
Definition: config_default.php:517
SQ_GET
const SQ_GET
Definition: global.php:16
encodeHeader
encodeHeader($string)
Definition: mime.php:759
sqsession_register
sqsession_register($var, $name)
Definition: global.php:289
_
_($str)
Definition: gettext.php:160
$subject
if(isset($messages[$mbx_response['UIDVALIDITY']]["$passed_id"])) if(!is_object($message)) $subject
Definition: download.php:64
sqimap_get_message
sqimap_get_message($imap_stream, $id, $mailbox)
Definition: imap_messages.php:1050
sqimap_run_command
sqimap_run_command($imap_stream, $query, $handle_errors, &$response, &$message, $unique_id=false, $filter=false, $outputstream=false, $no_return=false)
Definition: imap_general.php:58
$imapPort
$imapPort
Definition: config_default.php:210
Message
Definition: Message.class.php:27
$color
$color
Definition: load_prefs.php:28
SQ_COOKIE
const SQ_COOKIE
Definition: global.php:19
NULL
if(!defined('PAGE_NAME')) define('PAGE_NAME' NULL
Definition: validate.php:16
GenerateRandomString
GenerateRandomString($size, $chars, $flags=0)
Definition: strings.php:614
$imap_stream
$imap_stream
Definition: spamcop.php:78