Usage
This function runs automatically, so it is not called manually. Is this incorrect?
Source File
Located in /libs/Security.php on line 414.
6 Hooks
Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.
Filters
This function has no filter hooks available. Request one?
Actions
"nebula_spambot_prevention""nebula_spambot_prevention"
"nebula_spambot_prevention"
"nebula_spambot_prevention"
"nebula_spambot_prevention"
"qm/info"
Need a new action hook? Request one here.
PHP
public function spam_domain_prevention(){
if ( $this->is_minimal_mode() ){return null;}
$this->timer('Spam Domain Prevention', 'start', '[Nebula] Security');
//Use session cookie array
$session_cookie_data = $this->prep_new_session_cookie();
if ( isset($_COOKIE['session']) ){
$session_cookie_data = json_decode(stripslashes($_COOKIE['session']), true);
if ( !is_array($session_cookie_data) ){
$session_cookie_data = $this->prep_new_session_cookie();
}
}
//Skip if already marked or user is logged in
if ( (isset($session_cookie_data['spam_domain']) && $session_cookie_data['spam_domain'] === false) || is_user_logged_in() ){
return null;
}
if ( $this->get_option('spam_domain_prevention') ){
$spam_domain_array = $this->get_spam_domain_list();
$ip_address = $this->get_ip_address();
if ( count($spam_domain_array) > 1 ){
//Referrer
if ( isset($this->super->server['HTTP_REFERER']) && $this->contains(strtolower($this->super->server['HTTP_REFERER']), $spam_domain_array) ){
$this->ga_send_exception('(Security) Spam domain prevented. Referrer: ' . $this->super->server['HTTP_REFERER'], true, array('security_note' => 'Spam Referrer'));
do_action('nebula_spambot_prevention');
header('HTTP/1.1 403 Forbidden (Err: NSDPR)');
wp_die('Access forbidden.', '403 Forbidden', array('response' => 403, 'back_link' => false));
}
//Remote Host
if ( isset($this->super->server['REMOTE_HOST']) && $this->contains(strtolower($this->super->server['REMOTE_HOST']), $spam_domain_array) ){
$this->ga_send_exception('(Security) Spam domain prevented. Hostname: ' . $this->super->server['REMOTE_HOST'], true, array('security_note' => 'Spam Hostname'));
do_action('nebula_spambot_prevention');
header('HTTP/1.1 403 Forbidden (Err: NSDPH)');
wp_die('Access forbidden.', '403 Forbidden', array('response' => 403, 'back_link' => false));
}
//Server Name
if ( isset($this->super->server['SERVER_NAME']) && $this->contains(strtolower($this->super->server['SERVER_NAME']), $spam_domain_array) ){
$this->ga_send_exception('(Security) Spam domain prevented. Server Name: ' . $this->super->server['SERVER_NAME'], true, array('security_note' => 'Spam Server Name'));
do_action('nebula_spambot_prevention');
header('HTTP/1.1 403 Forbidden (Err: NSDPS)');
wp_die('Access forbidden.', '403 Forbidden', array('response' => 403, 'back_link' => false));
}
//Network Hostname
if ( isset($ip_address) && $this->contains(strtolower(gethostbyaddr($ip_address)), $spam_domain_array) ){
$this->ga_send_exception('(Security) Spam domain prevented. Network Hostname: ' . $ip_address, true, array('security_note' => 'Spam Network Hostname'));
do_action('nebula_spambot_prevention');
header('HTTP/1.1 403 Forbidden (Err: NSDPN)');
wp_die('Access forbidden.', '403 Forbidden', array('response' => 403, 'back_link' => false));
}
//Requested URL
if ( isset($this->super->server['REQUEST_URI']) && $this->contains(strtolower($this->super->server['REQUEST_URI']), $spam_domain_array) ){
$this->ga_send_exception('(Security) Spam domain prevented. URL: ' . $this->super->server['REQUEST_URI'], true, array('security_note' => 'Spam domain in the requested URL'));
do_action('nebula_spambot_prevention');
header('HTTP/1.1 403 Forbidden (Err: NSDPU)');
wp_die('Access forbidden.', '403 Forbidden', array('response' => 403, 'back_link' => false));
}
} else {
$this->ga_send_exception('(Security) spammers.txt has no entries!', false);
}
//Mark as checked in session cookie
$session_cookie_data['spam_domain'] = false;
$this->set_cookie('session', json_encode($session_cookie_data), time()+HOUR_IN_SECONDS*4, false); //Needs to be able to be read by JavaScript
}
do_action('qm/info', 'Spam Domain Check Performed');
$this->timer('Spam Domain Prevention', 'end');
}
Override
This function can not be short-circuited with an override filter. Request one?