Source for file setup.php

Documentation is available at setup.php

  1. <?php
  2. /** 
  3.  *  setup.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: setup.php 14840 2020-01-07 07:42:38Z pdontthink $
  9.  */
  10.  
  11. /** Disable Quick Reporting by default */
  12. global $spamcop_quick_report;
  13. $spamcop_quick_report false;
  14.  
  15. /* Initialize the plugin */
  16.    global $squirrelmail_plugin_hooks;
  17.  
  18.    $squirrelmail_plugin_hooks['optpage_register_block']['spamcop'=
  19.        'spamcop_options';
  20.    $squirrelmail_plugin_hooks['loading_prefs']['spamcop'=
  21.        'spamcop_load';
  22.    $squirrelmail_plugin_hooks['read_body_header_right']['spamcop'=
  23.        'spamcop_show_link';
  24.    $squirrelmail_plugin_hooks['compose_send']['spamcop'=
  25.        'spamcop_while_sending';
  26. }
  27.  
  28.  
  29. // Load the settings
  30. // Validate some of it (make '' into 'default', etc.)
  31. function spamcop_load({
  32.    global $username$data_dir$spamcop_enabled$spamcop_delete,
  33.       $spamcop_method$spamcop_id$spamcop_quick_report;
  34.  
  35.    $spamcop_enabled getPref($data_dir$username'spamcop_enabled');
  36.    $spamcop_delete getPref($data_dir$username'spamcop_delete');
  37.    $spamcop_method getPref($data_dir$username'spamcop_method');
  38.    $spamcop_id getPref($data_dir$username'spamcop_id');
  39.     if ($spamcop_method == ''{
  40. // This variable is not used
  41. //      if (getPref($data_dir, $username, 'spamcop_form'))
  42. //         $spamcop_method = 'web_form';
  43. //      else
  44.  
  45. // Default to web_form. It is faster.
  46.         $spamcop_method 'web_form';
  47.         setPref($data_dir$username'spamcop_method'$spamcop_method);
  48.     }
  49.    if ($spamcop_quick_report && $spamcop_method=='quick_email'{
  50.        $spamcop_method 'web_form';
  51.        setPref($data_dir$username'spamcop_method'$spamcop_method);
  52.    }
  53.    if ($spamcop_id == '')
  54.       $spamcop_enabled 0;
  55. }
  56.  
  57.  
  58. // Show the link on the read-a-message screen
  59. function spamcop_show_link({
  60.    global $spamcop_enabled$spamcop_method$spamcop_quick_report;
  61.  
  62.    if ($spamcop_enabled)
  63.       return;
  64.  
  65.    /* GLOBALS */
  66.    sqgetGlobalVar('passed_id',    $passed_id,    SQ_FORM);
  67.    sqgetGlobalVar('passed_ent_id',$passed_ent_id,SQ_FORM);
  68.    sqgetGlobalVar('mailbox',      $mailbox,      SQ_FORM);
  69.    if sqgetGlobalVar('startMessage'$startMessageSQ_FORM) ) {
  70.        $startMessage = (int)$startMessage;
  71.    }
  72.    /* END GLOBALS */
  73.  
  74.    // catch unset passed_ent_id
  75.    if (sqgetGlobalVar('passed_ent_id'$passed_ent_idSQ_FORM) ) {
  76.     $passed_ent_id 0;
  77.    }
  78.  
  79.    echo "<br>\n";
  80.  
  81.     /* 
  82.        Catch situation when user use quick_email and does not update 
  83.        preferences. User gets web_form link. If prefs are set to 
  84.        quick_email format - they will be updated after clicking the link
  85.      */
  86.     if ($spamcop_quick_report && $spamcop_method=='quick_email'{
  87.         $spamcop_method 'web_form';
  88.     }
  89.    
  90.    if ($spamcop_method == 'web_form'{
  91. ?><script language="javascript" type="text/javascript">
  92. document.write('<a href="../plugins/spamcop/spamcop.php?passed_id=<?php echo urlencode($passed_id)?>&amp;js_web=1&amp;mailbox=<?php echo urlencode($mailbox)?>&amp;passed_ent_id=<?php echo urlencode($passed_ent_id)?>" target="_blank">');
  93. document.write("<?php echo _("Report as Spam")?>");
  94. document.write("</a>");
  95. </script><noscript>
  96. <a href="../plugins/spamcop/spamcop.php?passed_id=<?php echo urlencode($passed_id)?>&amp;mailbox=<?php echo urlencode($mailbox)?>&amp;startMessage=<?php echo urlencode($startMessage)?>&amp;passed_ent_id=<?php echo urlencode($passed_ent_id)?>">
  97. <?php echo _("Report as Spam")?></a>
  98. </noscript><?php
  99.    else {
  100. ?><a href="../plugins/spamcop/spamcop.php?passed_id=<?php echo urlencode($passed_id)?>&amp;mailbox=<?php echo urlencode($mailbox)?>&amp;startMessage=<?php echo urlencode($startMessage)?>&amp;passed_ent_id=<?php echo urlencode($passed_ent_id)?>">
  101. <?php echo _("Report as Spam")?></a>
  102. <?php
  103.    }
  104. }
  105.  
  106.  
  107. // Show the link to our own custom options page
  108. function spamcop_options({
  109.    global $optpage_blocks;
  110.    
  111.    $optpage_blocks[array(
  112.       'name' => _("SpamCop - Spam Reporting"),
  113.       'url' => '../plugins/spamcop/options.php',
  114.       '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."),
  115.       'js' => false
  116.    );
  117. }
  118.  
  119.  
  120. // When we send the email, we optionally trash it then too
  121. function spamcop_while_sending({
  122.    global $mailbox$spamcop_delete$auto_expunge
  123.       $username$key$imapServerAddress$imapPort$imap_stream_options;
  124.  
  125.    // load sqgetGlobalVar()
  126.    include_once(SM_PATH 'functions/global.php');
  127.  
  128.    // check if compose.php is called by spamcop plugin
  129.    if (sqgetGlobalVar('spamcop_is_composing' $spamcop_is_composing)) {
  130.        if ($spamcop_delete{
  131.            $imapConnection sqimap_login($username$key$imapServerAddress$imapPort0$imap_stream_options);
  132.            sqimap_mailbox_select($imapConnection$mailbox);
  133.            sqimap_msgs_list_delete($imapConnection$mailbox$spamcop_is_composing);
  134.            if ($auto_expunge)
  135.                sqimap_mailbox_expunge($imapConnection$mailboxtrue);
  136.        }
  137.        // change default email composition setting. Plugin always operates in right frame.
  138.        // make sure that compose.php redirects to right page. Temporally override.
  139.        global $compose_new_win;
  140.        $compose_new_win false;
  141.    }
  142. }

Documentation generated on Mon, 13 Jan 2020 04:25:18 +0100 by phpDocumentor 1.4.3