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

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

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