1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
<?php
/**
* SquirrelMail Spam Buttons Plugin
* Copyright (c) 2005-2008 Paul Lesniewski <paul@squirrelmail.org>,
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* @package plugins
* @subpackage spam_buttons
*
*/
/**
* Validate that this plugin is configured correctly
*
* @return boolean Whether or not there was a
* configuration error for this plugin.
*
*/
function spam_buttons_check_configuration_do()
{
include_once(SM_PATH . 'plugins/spam_buttons/functions.php');
global $is_spam_resend_destination, $is_not_spam_resend_destination,
$is_spam_shell_command, $is_not_spam_shell_command,
$show_not_spam_button, $show_is_spam_button,
$sb_report_spam_by_move_to_folder,
$sb_report_not_spam_by_move_to_folder,
$sb_report_spam_by_custom_function,
$sb_report_not_spam_by_custom_function;
// make sure base config is available
//
if (!spam_buttons_init())
{
do_err('Spam Buttons plugin is missing its main configuration file', FALSE);
return TRUE;
}
$spam_methods = 0;
if (!empty($sb_report_spam_by_move_to_folder)) $spam_methods++;
if (!empty($is_spam_shell_command)) $spam_methods++;
if (!empty($is_spam_resend_destination)) $spam_methods++;
if (!empty($sb_report_spam_by_custom_function)) $spam_methods++;
$ham_methods = 0;
if (!empty($sb_report_not_spam_by_move_to_folder)) $ham_methods++;
if (!empty($is_not_spam_shell_command)) $ham_methods++;
if (!empty($is_not_spam_resend_destination)) $ham_methods++;
if (!empty($sb_report_not_spam_by_custom_function)) $ham_methods++;
// make sure "Is Spam" reporting method is properly configured
//
if ($show_is_spam_button && $spam_methods == 0)
{
do_err('Spam Buttons plugin is configured to show the "Is Spam" button, but there is no reporting method configured. Please specify either $sb_report_spam_by_move_to_folder, $is_spam_shell_command, $is_spam_resend_destination or $sb_report_spam_by_custom_function', FALSE);
return TRUE;
}
// make sure "Is Not Spam" reporting method is properly configured
//
if ($show_not_spam_button && $ham_methods == 0)
{
do_err('Spam Buttons plugin is configured to show the "Is Not Spam" button, but there is no reporting method configured. Please specify either $sb_report_not_spam_by_move_to_folder, $is_not_spam_shell_command, $is_not_spam_resend_destination or $sb_report_not_spam_by_custom_function', FALSE);
return TRUE;
}
/* we now allow more than one reporting type ---
// make sure "Is Spam" reporting method is not "overly" configured
//
if ($show_is_spam_button && $spam_methods > 1)
{
do_err('Spam Buttons plugin is configured to show the "Is Spam" button, but more than one reporting method has been specified. Please choose $sb_report_spam_by_move_to_folder, $is_spam_shell_command, $is_spam_resend_destination or $sb_report_spam_by_custom_function, but not more than one', FALSE);
return TRUE;
}
// make sure "Is Not Spam" reporting method is not "overly" configured
//
if ($show_not_spam_button && $ham_methods > 1)
{
do_err('Spam Buttons plugin is configured to show the "Is Not Spam" button, but more than one reporting method has been specified. Please choose $sb_report_not_spam_by_move_to_folder, $is_not_spam_shell_command, $is_not_spam_resend_destination or $sb_report_not_spam_by_custom_function, but not more than one', FALSE);
return TRUE;
}
--- we now allow more than one reporting type */
//TODO: I think we could also verify similar things as below for any extra buttons too?
// check that custom reporting functions have been implemented
//
if (!empty($sb_report_spam_by_custom_function) && !function_exists($sb_report_spam_by_custom_function))
{
do_err('Spam Buttons plugin is configured to report spam by the use of a custom PHP function, but that function was not found. Please check $sb_report_spam_by_custom_function and that it points to a valid PHP function that is defined or loaded in the Spam Buttons configuration file', FALSE);
return TRUE;
}
if (!empty($sb_report_not_spam_by_custom_function) && !function_exists($sb_report_not_spam_by_custom_function))
{
do_err('Spam Buttons plugin is configured to report ham (non-spam) by the use of a custom PHP function, but that function was not found. Please check $sb_report_not_spam_by_custom_function and that it points to a valid PHP function that is defined or loaded in the Spam Buttons configuration file', FALSE);
return TRUE;
}
// only need to do this pre-1.5.2, as 1.5.2 will make this
// check for us automatically
//
if (!check_sm_version(1, 5, 2))
{
// try to find Compatibility, and then that it is v2.0.7+
//
if (function_exists('check_plugin_version')
&& check_plugin_version('compatibility', 2, 0, 7, TRUE))
{ /* no-op */ }
// something went wrong
//
else
{
do_err('Spam Buttons plugin requires the Compatibility plugin version 2.0.7+', FALSE);
return TRUE;
}
}
// check for exec being disabled
//
$disable_functions = explode(',', ini_get('disable_functions'));
if (in_array('exec', $disable_functions)
&& (!empty($is_spam_shell_command) || !empty($is_not_spam_shell_command)))
{
do_err('You have disabled the "exec" command in your PHP configuration and are using the report-by-shell-command method for the Spam Buttons plugin. Spam and/or Ham reports will not work until you fix one or the other.', FALSE);
return TRUE;
}
// check for problems when in safe_mode
//
if (ini_get('safe_mode')
&& (!empty($is_spam_shell_command) || !empty($is_not_spam_shell_command)))
{
$safe_mode_exec_dir = ini_get('safe_mode_exec_dir');
do_err('You have safe_mode enabled in your PHP configuration and are using the report-by-shell-command method for the Spam Buttons plugin. Please double check that your reporting command is in an allowable directory and has ownership that allows access by the web server. (Your safe_mode_exec_dir is "' . $safe_mode_exec_dir . '".)', FALSE);
return FALSE;
}
return FALSE;
}
|