/** * Menu Page Third Party Options * */ public function menu3rdPartyOptions() { global $screen_layout_columns; $options_sfs[] = array('avhfdas[general][use_sfs]', __('Check with Stop Forum Spam', 'avh-fdas'), 'checkbox', 1, __('If checked, the visitor\'s IP will be checked with Stop Forum Spam', 'avh-fdas')); $options_sfs[] = array('avhfdas[sfs][whentoemail]', __('Email threshold', 'avh-fdas'), 'text', 3, __('When the frequency of the IP address of the spammer in the stopforumspam database equals or exceeds this threshold an email is send.<BR />A negative number means an email will never be send.', 'avh-fdas')); $options_sfs[] = array('avhfdas[sfs][whentodie]', __('IP termination threshold', 'avh-fdas'), 'text', 3, __('When the frequency of the IP address of the spammer in the stopforumspam database equals or exceeds this threshold the connection is terminated.<BR />A negative number means the connection will never be terminated.', 'avh-fdas')); $options_sfs[] = array('avhfdas[sfs][whentodie_email]', __('E-Mail termination threshold', 'avh-fdas'), 'text', 3, __('When the frequency of the e-mail address of the spammer in the stopforumspam database equals or exceeds this threshold the connection is terminated.<BR />A negative number means the connection will never be terminated.', 'avh-fdas')); $options_sfs[] = array('avhfdas[sfs][sfsapikey]', __('API Key', 'avh-fdas'), 'text', 15, __('You need a Stop Forum Spam API key to report spam.', 'avh-fdas')); $options_sfs[] = array('avhfdas[sfs][error]', __('Email error', 'avh-fdas'), 'checkbox', 1, __('Receive an email when the call to Stop Forum Spam Fails', 'avh-fdas')); $options_php[] = array('avhfdas[general][use_php]', __('Check with Honey Pot Project', 'avh-fdas'), 'checkbox', 1, __('If checked, the visitor\'s IP will be checked with Honey Pot Project', 'avh-fdas')); $options_php[] = array('avhfdas[php][phpapikey]', __('API Key:', 'avh-fdas'), 'text', 15, __('You need a Project Honey Pot API key to check the Honey Pot Project database.', 'avh-fdas')); $options_php[] = array('avhfdas[php][whentoemailtype]', __('Email type threshold:', 'avh-fdas'), 'dropdown', '0/1/2/3/4/5/6/7', 'Search Engine/Suspicious/Harvester/Suspicious & Harvester/Comment Spammer/Suspicious & Comment Spammer/Harvester & Comment Spammer/Suspicious & Harvester & Comment Spammer', __('When the type of the spammer in the Project Honey Pot database equals or exceeds this threshold an email is send.<BR />Both the type threshold and the score threshold have to be reached in order to receive an email.', 'avh-fdas')); $options_php[] = array('avhfdas[php][whentoemail]', __('Email score threshold', 'avh-fdas'), 'text', 3, __('When the score of the spammer in the Project Honey Pot database equals or exceeds this threshold an email is send.<BR />A negative number means an email will never be send.', 'avh-fdas')); $options_php[] = array('avhfdas[php][whentodietype]', __('Termination type threshold', 'avh-fdas'), 'dropdown', '-1/0/1/2/3/4/5/6/7', 'Never/Search Engine/Suspicious/Harvester/Suspicious & Harvester/Comment Spammer/Suspicious & Comment Spammer/Harvester & Comment Spammer/Suspicious & Harvester & Comment Spammer', __('When the type of the spammer in the Project Honey Pot database equals or exceeds this threshold and the score threshold, the connection is terminated.', 'avh-fdas')); $options_php[] = array('avhfdas[php][whentodie]', __('Termination score threshold', 'avh-fdas'), 'text', 3, __('When the score of the spammer in the Project Honey Pot database equals or exceeds this threshold and the type threshold is reached, the connection terminated.<BR />A negative number means the connection will never be terminated.<BR /><strong>This option will always be the last one checked.</strong>', 'avh-fdas')); $options_php[] = array('avhfdas[php][usehoneypot]', __('Use Honey Pot', 'avh-fdas'), 'checkbox', 1, __('If you have set up a Honey Pot you can select to have the URL below to be added to the message when terminating the connection.<BR />You have to select <em>Show Message</em> in the General Options for this to work.', 'avh-fdas')); $options_php[] = array('avhfdas[php][honeypoturl]', __('Honey Pot URL', 'avh-fdas'), 'text', 30, __('The link to the Honey Pot as suggested by Project Honey Pot.', 'avh-fdas')); $options_sh[] = array('avhfdas[general][use_sh]', __('Check with Spamhaus', 'avh-fdas'), 'checkbox', 1, __('If checked, the visitor\'s IP will be checked at Spamhaus', 'avh-fdas')); $options_sh[] = array('avhfdas[spamhaus][email]', __('Email', 'avh-fdas'), 'checkbox', 1, __('Send an email when a connection is terminated based on the IP found at Spamhaus', 'avh-fdas')); if (isset($_POST['updateoptions'])) { check_admin_referer('avh_fdas_options'); $formoptions = $_POST['avhfdas']; $options = $this->_core->getOptions(); $all_data = array_merge($options_sfs, $options_php, $options_sh); foreach ($all_data as $option) { $section = substr($option[0], strpos($option[0], '[') + 1); $section = substr($section, 0, strpos($section, '][')); $option_key = rtrim($option[0], ']'); $option_key = substr($option_key, strpos($option_key, '][') + 2); $current_value = $options[$section][$option_key]; // Every field in a form is set except unchecked checkboxes. Set an unchecked checkbox to 0. $newval = isset($formoptions[$section][$option_key]) ? esc_attr($formoptions[$section][$option_key]) : 0; if ('sfs' == $section && ('whentoemail' == $option_key || 'whentodie' == $option_key || 'whentodie_email' == $option_key)) { $newval = (int) $newval; } if ('php' == $section && ('whentoemail' == $option_key || 'whentodie' == $option_key)) { $newval = (int) $newval; } if ($newval != $current_value) { // Only process changed fields $options[$section][$option_key] = $newval; } } $note = ''; if ('' === trim($options['php']['phpapikey']) && 1 == $options['general']['use_php']) { $options['general']['use_php'] = 0; $note = '<br \\><br \\>' . __('You can not use Project Honey Pot without an API key. Use of Project Honey Pot has been disabled', 'avh-fdas'); } $this->_core->saveOptions($options); $this->_message = __('Options saved', 'avh-fdas'); $this->_message .= $note; $this->_status = 'updated fade'; $this->_displayMessage(); } $actual_options = array_merge($this->_core->getOptions(), $this->_core->getData()); $hide2 = ''; switch ($screen_layout_columns) { case 2: $width = 'width:49%;'; break; default: $width = 'width:98%;'; $hide2 = 'display:none;'; } $data['options_sfs'] = $options_sfs; $data['options_php'] = $options_php; $data['options_sh'] = $options_sh; $data['actual_options'] = $actual_options; echo '<div class="wrap avhfdas-wrap">'; echo $this->_displayIcon('options-general'); echo '<h2>AVH First Defense Against Spam: ' . __('3rd Party Options', 'avh-fdas') . '</h2>'; echo '<form name="avhfdas-options" id="avhfdas-options" method="POST" action="admin.php?page=' . AVH_FDAS_Define::MENU_SLUG_3RD_PARTY . '" accept-charset="utf-8" >'; wp_nonce_field('avh_fdas_options'); wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); echo ' <div id="dashboard-widgets-wrap">'; echo ' <div id="dashboard-widgets" class="metabox-holder">'; echo ' <div class="postbox-container" style="' . $width . '">' . "\n"; do_meta_boxes($this->_hooks['avhfdas_menu_3rd_party'], 'normal', $data); echo ' </div>'; echo ' <div class="postbox-container" style="' . $hide2 . $width . '">' . "\n"; do_meta_boxes($this->_hooks['avhfdas_menu_3rd_party'], 'side', $data); echo ' </div>'; echo ' </div>'; echo ' </div>'; // dashboard-widgets-wrap echo '<p class="submit"><input class="button-primary" type="submit" name="updateoptions" value="' . __('Save Changes', 'avh-fdas') . '" /></p>'; echo '</form>'; $this->_printAdminFooter(); echo '</div>'; }