Changing file perm.
authorphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 22 Jan 2002 12:56:43 +0000 (12:56 +0000)
committerphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 22 Jan 2002 12:56:43 +0000 (12:56 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2206 7612ce4b-ef26-0410-bec9-ea0150e637f0

plugins/spamcop/README [new file with mode: 0755]
plugins/spamcop/options.php [new file with mode: 0755]
plugins/spamcop/setup.php [new file with mode: 0755]

diff --git a/plugins/spamcop/README b/plugins/spamcop/README
new file mode 100755 (executable)
index 0000000..d0a6e5c
--- /dev/null
@@ -0,0 +1,62 @@
+SpamCop Reporting -- Version 1.5
+
+Helps you identify spam and send a proper message to the correct address to
+SpamCop.  (See http://spamcop.net/ for more information)
+
+
+Features
+========
+
+* Quick one-click interface to report spam via email
+* Alternate, but immediate form-based processing
+
+
+Description
+===========
+
+Tired of getting spam?  SpamCop helps you report it to the proper people.
+It even creates spam reports and will mail them off for you.  All that is
+required to send a spam report is about a few seconds of your time and about
+five clicks.
+
+It is strongly suggested you set up a mail forwarder account and have it
+forwarded to your current mailbox.  Sometimes mail reported with SpamCop
+gets on weird spam mailing lists.  If your happens to get on the list, you
+can then just delete the forwarder and get a new one.  Make sure to use the
+forwarder to sign up for SpamCop and get the required information for the
+plugin.
+
+This plugin is also an example of how to use the identity hooks.  Just open
+up setup.php and read the comments.
+
+
+Future Work
+===========
+
+* Dunno
+
+
+Installation
+============
+
+As with other plugins, just uncompress the archive in the plugins
+directory, go back to the main directory, run configure and add the plugin.
+
+Questions/comments/flames/etc can be sent to the SquirrelMail Plugins list.
+
+
+Changes
+=======
+1.5 - Reworked system to match up with SpamCop changes.  Modified code to
+      keep it up-to-date with current SquirrelMail changes.
+
+1.4 - Added forms-based reporting, thanks to Stefan Sels
+
+1.3 - Fixed table rendition -- added &nbsp;
+
+1.2 - Added support for the multiple identities in SquirrelMail 1.1.2
+      (not required to use the plugin)
+      
+1.1 - Fixed a stupid bug
+
+1.0 - Initial version
diff --git a/plugins/spamcop/options.php b/plugins/spamcop/options.php
new file mode 100755 (executable)
index 0000000..13140bf
--- /dev/null
@@ -0,0 +1,139 @@
+<?php
+   chdir ("..");
+   require_once('../src/validate.php');
+
+   displayPageHeader($color, "None");   
+
+   if (! isset($action))
+      $action = '';
+   if ($action == 'enable')
+      setPref($data_dir, $username, 'spamcop_enabled', 1);
+   elseif ($action == 'disable')
+      setPref($data_dir, $username, 'spamcop_enabled', '');
+   elseif ($action == 'save')
+      setPref($data_dir, $username, 'spamcop_delete', '');
+   elseif ($action == 'delete')
+      setPref($data_dir, $username, 'spamcop_delete', 1);
+   elseif ($action == 'meth' && isset($meth))
+      setPref($data_dir, $username, 'spamcop_method', $meth);
+   elseif ($action == 'save_id' && isset($ID))
+      setPref($data_dir, $username, 'spamcop_id', $ID);
+
+   global $spamcop_enabled, $spamcop_delete;
+   spamcop_load();
+
+   ?>
+      <br>
+      <table width=95% align=center border=0 cellpadding=2 cellspacing=0><tr><td bgcolor="<?php echo $color[0] ?>">
+         <center><b><?php echo _("Options") ?> - Message Filtering</b></center>
+      </td></tr></table>
+      <br>
+      
+      <table align=center>
+        <tr>
+         <td align=right>SpamCop link is:</td>
+         <td><?PHP if ($spamcop_enabled) { 
+         ?>Enabled (<a href="options.php?action=disable">Disable it</a>)
+         <?PHP } else {
+         ?>Disabled (<a href="options.php?action=enable">Enable it</a>)
+         <?PHP }
+         ?></td>
+       </tr>
+        <tr>
+         <td align=right valign=top>Delete spam when reported:<br>
+           <font size="-2">(Only works with email-based reporting)</font>
+         </td>
+         <td valign=top><?PHP if ($spamcop_delete) { 
+         ?>Enabled (<a href="options.php?action=save">Disable it</a>)
+         <?PHP } else {
+         ?>Disabled (<a href="options.php?action=delete">Enable it</a>)
+         <?PHP }
+         ?></td>
+       </tr>
+       <tr>
+         <td align=right>Spam Reporting Method:</td>
+         <form method=post action=options.php><td>
+           <select name=meth>
+             <option value="quick_email"<?PHP
+               if ($spamcop_method == 'quick_email') echo ' SELECTED'
+               ?>>Quick email-based reporting</option>
+             <option value="thorough_email"<?PHP
+               if ($spamcop_method == 'thorough_email') echo ' SELECTED'
+               ?>>Thorough email-based reporting</option>
+             <option value="web_form"<?PHP
+               if ($spamcop_method == 'web_form') echo ' SELECTED'
+               ?>>Web-based form</option>
+           </select>
+           <input type=hidden name=action value=meth>
+           <input type=submit value="Save Method">
+         </td></form>
+       </tr>
+       <tr>
+         <td valign=top align=right>Your SpamCop authorization code:<br>
+           <font size="-2">(see below)</font>
+         </td>
+         <form method=post action=options.php><td valign=top>
+           <input type=text size=30 name="ID" value="<?PHP
+             echo htmlspecialchars($spamcop_id) ?>">
+           <input type=hidden name=action value=save_id>
+           <input type=submit value="Save ID">
+         </td></form>
+       </tr>
+      </table>
+
+<p>SpamCop is a free service that greatly assists in finding the true source
+of the spam and helps in letting the proper people know about the abuse.</p>
+
+<p>To use it, you must get a SpamCop authorization code.  There is a free <a
+href="http://spamcop.net/anonsignup.shtml">sign up page</a> so you can use
+SpamCop.</p>
+
+<p><b>Before you sign up, be warned:</b>  Some users have reported that the
+email addresses used with SpamCop find their way onto spam lists.  To be
+safe, you can just create an email forwarding account and have all SpamCop
+reports get sent to there.  Also, if it gets flooded with spam, you can then
+just delete that account with no worries about losing your real email address.
+Just go create an email forwarder somewhere (<a 
+href="http://www.yahoo.com/">Yahoo!</a> has a <a
+href="http://dir.yahoo.com/Business_and_Economy/Business_to_Business/Communications_and_Networking/Internet_and_World_Wide_Web/Email_Providers/Forwarding_Services/Free_Forwarding/">list
+of places</a>) so that messages from system administrators and whatnot can
+be sent to you.</p>
+
+<p>Once you have signed up with SpamCop and have received your SpamCop
+authorization code, you need to enable this plugin -- just click the link
+above.  Once enabled, you go about your normal life.  If you encounter a
+spam message in your mailbox, just view it.  On the right-hand side, near
+the top of where the message is displayed, you will see a link to report 
+this message as spam.  Clicking on it brings you to a confirmation page.
+Confirming that you want the spam report sent will do different things with
+different reporting methods.</p>
+
+<p><b>Email-based Reporting</b><br>
+Pressing the button forwards the message to the SpamCop service and will
+optionally delete the message.  From there, you just need to go to your 
+INBOX and quite soon a message should appear from SpamCop.  (It gets sent to
+the account you registered with, so make sure that your mail forwarder works!)
+Open it up, click on the appropriate link at the top, and a new browser 
+window will open.</p>
+
+<p>Currently, the quick reporting just forwards the request to the thorough
+reporting.  Also, it appears that this is for members (non-free) only.
+Hopefully this will change soon.</p>
+
+<p><b>Web-based Reporting</b><br>
+When you press the button on the confirmation page, this will pop open a new
+browser window and the SpamCop service should appear inside.  The message
+will not be deleted (working on that part), but you won't need to wait for a
+response email to start the spam reporting.</p>
+
+<p>The SpamCop service will display information as it finds it, so scroll
+down until you see a form button.  It might pause a little while it is
+looking up information, so be a little patient.  Read what it says, and 
+submit the spam.  Close the browser window.  Press Cancel or click on the
+appropriate mail folder to see messages and/or delete the spam.</p>
+
+<p><b>For more information</b> about SpamCop, it's services, spam in general, 
+and many related topics, try reading through SpamCop's <a
+href="http://spamcop.net/help.shtml">Help and Feedback</a> section.</p>
+
+</body></html>
diff --git a/plugins/spamcop/setup.php b/plugins/spamcop/setup.php
new file mode 100755 (executable)
index 0000000..f4d064c
--- /dev/null
@@ -0,0 +1,115 @@
+<?php
+
+
+/* Initialize the plugin */
+function squirrelmail_plugin_init_spamcop() {
+   global $squirrelmail_plugin_hooks, $data_dir, $username,
+      $spamcop_is_composing;
+
+   $squirrelmail_plugin_hooks['optpage_register_block']['spamcop'] =
+      'spamcop_options';
+   $squirrelmail_plugin_hooks['loading_prefs']['spamcop'] =
+      'spamcop_load';
+   $squirrelmail_plugin_hooks['read_body_header_right']['spamcop'] =
+      'spamcop_show_link';
+      
+   if (isset($spamcop_is_composing)) {
+      $squirrelmail_plugin_hooks['compose_send']['spamcop'] =
+         'spamcop_while_sending';
+   }
+}
+
+
+// Load the settings
+// Validate some of it (make '' into 'default', etc.)
+function spamcop_load() {
+   global $username, $data_dir, $spamcop_enabled, $spamcop_delete,
+      $spamcop_method, $spamcop_id;
+
+   $spamcop_enabled = getPref($data_dir, $username, 'spamcop_enabled');
+   $spamcop_delete = getPref($data_dir, $username, 'spamcop_delete');
+   $spamcop_method = getPref($data_dir, $username, 'spamcop_method');
+   $spamcop_id = getPref($data_dir, $username, 'spamcop_id');
+   if ($spamcop_method == '') {
+      if (getPref($data_dir, $username, 'spamcop_form'))
+         $spamcop_method = 'web_form';
+      else
+         $spamcop_method = 'thorough_email';
+      setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
+   }
+   if ($spamcop_id == '')
+      $spamcop_enabled = 0;
+}
+
+
+// Show the link on the read-a-message screen
+function spamcop_show_link() {
+   global $passed_id, $mailbox, $ent_num, $spamcop_enabled, $startMessage,
+      $spamcop_method;
+
+   // This was stolen from printer_friendly
+   // Do I really need/want it?
+   if (!trim($mailbox))
+      $mailbox = 'INBOX';
+
+   if (! $spamcop_enabled)
+      return;
+
+   echo "<br>\n";
+   
+   if ($spamcop_method == 'web_form') {
+?><script language=javascript>
+document.write('<a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP
+echo urlencode($passed_id); ?>&js_web=1&mailbox=<?PHP
+echo urlencode($mailbox); ?>" target="_blank">');
+document.write("<?PHP echo _("Report as Spam"); ?>");
+document.write("</a>");
+</script><noscript>
+<a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP
+echo urlencode($passed_id); ?>&mailbox=<?PHP
+echo urlencode($mailbox); ?>&startMessage=<?PHP
+echo urlencode($startMessage); ?>"><?PHP
+echo _("Report as Spam"); ?></a>
+</noscript><?PHP
+   } else {
+?><a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP
+echo urlencode($passed_id); ?>&mailbox=<?PHP
+echo urlencode($mailbox); ?>&startMessage=<?PHP
+echo urlencode($startMessage); ?>"><?PHP
+echo _("Report as Spam"); ?></a><?PHP
+   }
+}
+
+
+// Show the link to our own custom options page
+function spamcop_options()
+{
+   global $optpage_blocks;
+   
+   $optpage_blocks[] = array(
+      'name' => _("SpamCop - Spam Reporting"),
+      'url' => '../plugins/spamcop/options.php',
+      'desc' => _("Help fight the battle against unsolicited email.  SpamCop reads the spam email and determines the correct addresses to send complaints to.  Quite fast, really smart, and easy to use."),
+      'js' => false
+   );
+}
+
+
+// When we send the email, we optionally trash it then too
+function spamcop_while_sending()
+{
+   global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge, 
+      $username, $key, $imapServerAddress, $imapPort;
+
+   if ($spamcop_delete) {
+      $imapConnection = sqimap_login($username, $key, $imapServerAddress, 
+         $imapPort, 0);
+      sqimap_mailbox_select($imapConnection, $mailbox);
+      sqimap_messages_delete($imapConnection, $spamcop_is_composing, 
+         $spamcop_is_composing, $mailbox);
+      if ($auto_expunge)
+         sqimap_mailbox_expunge($imapConnection, $mailbox, true);
+   }
+}
+
+?>