'; $msg .= 'New Plugin Name: ' . $antihacker_new_plugin; $msg .= '
'; $msg .= 'Date : ' . $dt . '
'; $msg .= 'Domain: ' . $dom . '
'; $msg .= '
'; $msg .= 'This email was sent from your website ' . $dom . ' by Anti Hacker plugin.
'; $email_from = 'wordpress@' . $dom; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: " . $email_from . "\r\n" . 'Reply-To: ' . $ah_admin_email . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $to = $ah_admin_email; $subject = 'Alert: New Plugin was installed at: ' . $dom; wp_mail($to, $subject, $msg, $headers, ''); return 1; } $qpluginsnow = antihacker_q_plugins_now(); $qplugins = antihacker_q_plugins(); if ( ($qplugins == 0 and $qpluginsnow > 0) or ($qplugins > $qpluginsnow ) ) { antihacker_save_name_plugins(); $qplugins = antihacker_q_plugins(); } if ($qpluginsnow > $qplugins) { $nplugins = get_site_option('antihacker_name_plugins', ''); $nplugins = explode(PHP_EOL, $nplugins); $all_plugins = get_plugins(); $all_plugins_keys = array_keys($all_plugins); if (count($all_plugins) < 1) return; $my_plugins_now = ''; $loopCtr = 0; foreach ($all_plugins as $plugin_item) { $plugin_title = $plugin_item['Name']; $my_plugins_now[$loopCtr] = $plugin_title; $loopCtr++; } $antihacker_new_plugin = ''; for ($i = 0; $i < $qpluginsnow; $i++) { $plugin_name = $my_plugins_now[$i]; if ( ! in_array($plugin_name, $nplugins)) { $antihacker_new_plugin = $plugin_name; break; } } add_action('plugins_loaded', 'antihacker_alert_plugin'); antihacker_save_name_plugins(); } // if ($qpluginsnow > $qplugins) if ($qpluginsnow < $qplugins) { antihacker_save_name_plugins(); } } // End Report new plugin installed... if(is_admin()) { if(isset($_GET['page'])){ if ($_GET['page'] == 'anti-hacker') { add_filter('contextual_help', 'ah_contextual_help', 10, 3); function ah_contextual_help($contextual_help, $screen_id, $screen) { $myhelp = '
Improve system security and help prevent unauthorized access to your account.'; $myhelp .= '
Read the StartUp guide at Anti Hacker Settings page.'; $myhelp .= '
Visit the plugin site for more details.'; $screen->add_help_tab(array( 'id' => 'wptuts-overview-tab', 'title' => __('Overview', 'plugin_domain'), 'content' => '

' . $myhelp . '

', )); return $contextual_help; } } } } function ahfindip() { $antihackerip = ''; if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $antihackerip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $antihackerip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $antihackerip = $_SERVER['REMOTE_ADDR']; } $antihackerip = trim($antihackerip); if (!empty($antihackerip)) return $antihackerip; else return 'unknow'; } function ah_whitelisted($antihackerip, $amy_whitelist) { for ($i = 0; $i < count($amy_whitelist); $i++) { if (trim($amy_whitelist[$i]) == $antihackerip) return 1; } return 0; } function ah_successful_login($user_login) { global $amy_whitelist; global $my_radio_all_logins; global $antihackerip; global $ah_admin_email; if (ah_whitelisted($antihackerip, $amy_whitelist) and $my_radio_all_logins <> 'Yes' ) { return 1;} $dt = date("Y-m-d H:i:s"); $dom = $_SERVER['SERVER_NAME']; $msg = 'This email was sent from your website '.$dom. ' by the AntiHacker plugin.
'; $msg .= 'Date : ' . $dt . '
'; $msg .= 'Ip: ' . $antihackerip . '
'; $msg .= 'Domain: ' . $dom . '
'; $msg .= 'Role: ' . $user_login; $msg .= '
'; $msg .= 'Add this IP to your withelist to stop this email and change your Notification Settings.'; $email_from = 'wordpress@'.$dom; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: ".$email_from. "\r\n" . 'Reply-To: ' . $user_login . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $to = $ah_admin_email; $subject = 'Login Successful at: '.$dom; wp_mail( $to, $subject, $msg, $headers, '' ); return 1; } function ah_activated() { $antihackerip = ahfindip() ; global $my_whitelist; global $ah_admin_email; if(is_admin()) { if (empty($my_whitelist)) { if ( get_site_option( 'my_whitelist') !== false ) { $return = update_site_option('my_whitelist', $antihackerip); } else { $return = add_site_option('my_whitelist', $antihackerip); } } } } function ah_my_deactivation() { global $ah_admin_email, $antihackerip; $current_user = wp_get_current_user(); $user_login = $current_user->user_login; $dt = date("Y-m-d H:i:s"); $dom = $_SERVER['SERVER_NAME']; $url = $_SERVER['PHP_SELF']; $msg = 'Alert: the Anti Hacker plugin was been deactivated from plugins page.'; $msg .= '
'; $msg .= 'Date : ' . $dt . '
'; $msg .= 'Ip: ' . $antihackerip . '
'; $msg .= 'Domain: ' . $dom . '
'; $msg .= 'Role: ' . $user_login; $msg .= '
'; $msg .= 'This email was sent from your website ' . $dom . ' by Anti Hacker plugin.
'; $email_from = 'wordpress@' . $dom; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: " . $email_from . "\r\n" . 'Reply-To: ' . $user_login . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $to = $ah_admin_email; $subject = 'Plugin Deactivated at: ' . $dom; wp_mail($to, $subject, $msg, $headers, ''); return 1; } function ah_email_display() { ?> My Wordpress user email:

'1' ) { return;} $dt = date("Y-m-d H:i:s"); $dom = $_SERVER['SERVER_NAME']; $msg = 'This email was sent from your website '.$dom. ' by the AntiHacker plugin.
'; $msg .= 'Date : ' . $dt . '
'; $msg .= 'Ip: ' . $antihackerip . '
'; $msg .= 'Domain: ' . $dom . '
'; $msg .= 'Role: ' . $user_login; $msg .= '
'; $msg .= 'Failed login'; $email_from = 'wordpress@'.$dom; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: ".$email_from. "\r\n" . 'Reply-To: ' . $user_login . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $to = $ah_admin_email; $subject = 'Failed Login at: '.$dom; wp_mail( $to, $subject, $msg, $headers, '' ); return; } if (get_site_option('my_radio_xml_rpc', 'No') == 'Yes') add_filter( 'xmlrpc_enabled', '__return_false' ); if (get_site_option('my_radio_xml_rpc', 'No') == 'Pingback') add_filter( 'xmlrpc_methods', 'ahpremove_xmlrpc_pingback_ping' ); function ahpremove_xmlrpc_pingback_ping( $methods ) { unset( $methods['pingback.ping'] ); return $methods; } ; ///////////////////////////////////////// // Disable Json WordPress Rest API (also embed from WordPress 4.7). // Take a look our faq page (at our site) for details.' function antihacker_after_inic() { $ah_current_WP_version = get_bloginfo('version'); function ah_Force_Auth_Error() { add_filter( 'rest_authentication_errors', 'ah_only_allow_logged_in_rest_access' ); } function ah_Disable_Via_Filters() { // Filters for WP-API version 1.x add_filter( 'json_enabled', '__return_false' ); add_filter( 'json_jsonp_enabled', '__return_false' ); // Filters for WP-API version 2.x add_filter( 'rest_enabled', '__return_false' ); add_filter( 'rest_jsonp_enabled', '__return_false' ); // Remove REST API info from head and headers remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' ); remove_action( 'wp_head', 'rest_output_link_wp_head', 10 ); remove_action( 'template_redirect', 'rest_output_link_header', 11 ); } function ah_only_allow_logged_in_rest_access( $access ) { if( ! is_user_logged_in() ) { // die('123'); return new WP_Error( 'rest_cannot_access', __( 'Only authenticated users can access API.', 'disable-json-api' ), array( 'status' => rest_authorization_required_code() ) ); } return $access; } if ( version_compare( $ah_current_WP_version, '4.7', '>=' ) ) { ah_Force_Auth_Error(); } else { ah_Disable_Via_Filters(); } } $antihacker_rest_api = trim(get_site_option('antihacker_rest_api', 'No')); if($antihacker_rest_api <> 'No') add_action( 'plugins_loaded', 'antihacker_after_inic' ); ?>