autoRegisterTrial(); // take a snapshot of the files for integrity checking Utility::initFileSystem(); global $wp_filesystem; $integrity = new ActifendFileIntegrity( $wp_filesystem->abspath() ); $integrity->createBaseline(); // get the banned ips from db, if any update_option( 'actifend_banned_ips', ActifendScan::get_ips_from_db_table() ); // enable cron jobs Actifend::enable_actifend_crons(); if ( get_option( 'dsd_iniset_disabled' ) === true ) { debug_log("ini_set function is disabled. Cannot set memory limit and execution time!"); } debug_log("ActiFend plugin activated, but registration process not yet complete.!"); } catch (Exception $e) { echo $e->getMessage(); update_option( 'actifend_plugin_act_error', ob_get_contents() ); add_action( 'admin_notices', 'Actifend::activation_warning' ); deactivate_plugins( plugin_basename( __FILE__ ) ); } } //Registration process (Screen after installation) add_action( 'admin_menu', 'actifend_get_email' ); function actifend_get_email() { if ( !Actifend::isAdmin( wp_get_current_user() ) ) { debug_log( 'Current user does not have Admin privileges.' ); return; } $currentUrl = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $pluginActivated = get_option( 'actifendActivated', 0 ); if ( $pluginActivated === 0 ) { # Get post vars sand store $email_passed = ( !empty( $_POST['actifend_email'] ) ? $_POST['actifend_email'] : null ); $mapp = ( !empty( $_POST['app'] ) ? $_POST['app'] : 'false' ); if ( ! empty( $email_passed ) ) { update_option( 'mapp_user', $email_passed ); } $mapp = ( strtolower( $mapp ) == 'true' ? 1 : 0 ); update_option( 'mapp_activated', $mapp ); } $_currentUrl = explode( '?', $currentUrl ); $_currentUrl = ( count( $_currentUrl ) > 1 ? $_currentUrl[0] : $currentUrl ); $PHP_SELF = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; if ( $_currentUrl == $PHP_SELF && @$_COOKIE['ActifendRedirect'] == 'OK' ){ // unset cookie setcookie( 'ActifendRedirect', 'OK', 1 ); header( 'Location: ' . ACTIFEND_PLUGIN_URL ); exit; } add_menu_page('ActiFend', 'ActiFend', 'manage_options', 'get_actifend_email', 'actifend_show_form', plugins_url( 'actifend/images/ActiFend_16x21_icon.png' ), 1); debug_log("actifend_get_email executed!"); } function actifend_show_form() { debug_log( 'Entered actifend_show_form function.' ); if ( get_option( 'actifend_plugin_act_error', false ) ) { add_action( 'admin_notices', 'Actifend::activation_warning' ); } $actifend_dir = plugin_dir_path( __FILE__ ); if ( get_option('actifendActivated' ) == 0) { require_once( trailingslashit( $actifend_dir ) . 'form.php' ); } else { $utiObj = new Utility; global $current_user; $current_user = wp_get_current_user(); $result = $utiObj->getActifendInfo(); if ( $result->actifend_email != 'None' ) { $asset_id = $result->asset_id; $actifend_email = $current_user->user_email; $utiObj->get_asset_status( get_site_url(), $actifend_email ); $mapp = get_option( 'mapp_activated', 0 ); $template = ( $mapp == 0 ? 'store.php' : 'usage.php' ); require_once( trailingslashit($actifend_dir) . $template ); } else { debug_log( 'actifend_email not updated in the db.' ); } } } if ( !function_exists( 'actifend_onboarding_notice' ) ) { add_action( 'admin_notices', 'actifend_onboarding_notice' ); /** * actifend_email_optin_notice * serve admin notice if the user has not completed step 2 * @return void */ function actifend_onboarding_notice() { try { if ( Actifend::isAdmin( wp_get_current_user() ) ) { global $pagenow; $actifendActivated = get_option( 'actifendActivated' ); $mappActivated = get_option( 'mapp_activated', 0 ); if ( $pagenow == 'index.php' ) { if ( get_option( 'actifend_plan_changed' ) === true ) { $message = __('Site has been shifted to a FREE plan. ' . ' To enable all features please renew ' . 'subscription.'); echo '

ActiFend: ' . $message . '

'; } } if ( $pagenow == 'plugins.php' ) { $page_url = admin_url( 'admin.php?page=get_actifend_email' ); if ( $actifendActivated === 0 ) { $message = __('To access the ActiFend security ' . 'dashboard, please link your email ' . 'address to your ActiFend account for ' . 'authentication. '); $message .= "\x20Okay, Take me there."; echo '

ActiFend: ' . $message . '

'; } elseif ( $actifendActivated == 1 && $mappActivated === 0) { $message = __('Install Mobile App and Enable ActiFend ' . 'Mobile Security Center, for Actively ' . 'defending your website. '); $message .= "\x20OK. Take me there!"; echo '

ActiFend: ' . $message . '

'; } else { return; } debug_log( 'actifend_onboarding_notice executed!' ); } } } catch ( Exception $e ) { debug_log( $e->getMessage() ); return; } } } if (! function_exists( 'actifend_usage_notice' )) { add_action( 'admin_notices', 'actifend_usage_notice' ); /** * actifend_usage_notice * serve admin notice based on the effective usage of MSC * @return void */ function actifend_usage_notice() { try { if (Actifend::isAdmin( wp_get_current_user()) ) { global $pagenow; $ignoreNotice = get_user_meta( get_current_user_id(), 'dismiss_actifend_usage_notice' ); if ( $pagenow == 'index.php' && ! $ignoreNotice) { $page_url = admin_url( 'admin.php?page=get_actifend_email' ); $category = get_option( 'actifend_usage_category', 'HEALTHY' ); if (get_option( 'mapp_activated' ) == 1 && ( $category != 'HEALTHY' )) { if ( $category == 'CRITICAL' ) { $className = 'notice notice-error is-dismissible'; $message = __('Security Alerts are pending ... please use the ActiFend App and act on them.'); } else { $className = 'notice notice-warning is-dismissible'; $message = __('Vulnerabilities found in website ... please use the ActiFend App and act on them.'); } echo "

ActiFend: "; printf( $message . ' | Dismiss Notice', '?actifend_dismiss_usage_notice=0' ); echo "

"; } } } } catch (Exception $e) { debug_log( $e->getMessage() ); return; } } } function actifend_dismiss_usage_notice() { if ( isset( $_GET['actifend_dismiss_usage_notice'] ) && '0' == $_GET['actifend_dismiss_usage_notice'] ) { add_user_meta( get_current_user_id(), 'dismiss_actifend_usage_notice', 'true', true ); debug_log( 'Usage notice user meta data updated' ); } } function reset_dismiss_usage_notice() { update_user_meta( get_current_user_id(), 'dismiss_actifend_usage_notice', 'false'); debug_log( 'Usage notice user meta data reset!' ); } // block unauthenticated xmlrpc requests if desired if ( get_option( 'actifend_disable_xmlrpc', false ) === true ) { add_filter( 'xmlrpc_enabled', '__return_false' ); debug_log( 'XML-RPC disabled.' ); } // block system.multicall xmlrpc if ( get_option( 'actifend_disable_xmlrpc_pingback', false ) === true ) { add_filter( 'xmlrpc_methods', 'Utility::afend_remove_xmlrpc_pingback' ); debug_log( 'XML-RPC pingback method removed.' ); } // Add actifend crons to wordpress cron schedules add_filter( 'cron_schedules', 'Actifend::actifend_crons' ); // Add actions required for actifend to function Actifend::add_actifend_actions(); function blockBadQueries() { ActifendScan::find_and_block_bad_requests(); } function wordpressBackup() { $backup = new ActifendBackup; $backup->actifend_backup_process(); } function wordpressRestore() { $restore = new ActifendRestoreBackup; $restore->actifend_restore_process(); } function fileIntegrityCheck() { Utility::initFileSystem(); global $wp_filesystem; $integrity = new ActifendFileIntegrity( $wp_filesystem->abspath() ); $integrity->getModifiedFiles_bySize_and_mtime(); } function loginFailureAccess() { $loginObj = new ActifendAccessAlerts; $loginObj->actifend_push_logs( 'LOGIN-FAILED' ); } function logInSuccess() { $loginObj = new ActifendAccessAlerts; $loginObj->actifend_push_logs( 'LOGIN-SUCCESS' ); } function AccessLogs() { $loginObj = new ActifendAccessAlerts; $var = $loginObj->actifend_push_logs(); } function pluginUpdatelog() { $loginObj = new ActifendAccessAlerts; $loginObj->actifend_updatePlugin_logs(); debug_log( 'pluginUpdatelog function executed.' ); } function updateInstallationLogs() { $updateObj = new ActifendAccessAlerts; $updateObj->actifendUpdateInstallTrigger(); debug_log( 'updateInstallationLogs function executed.' ); } function availableWordPressUpdates() { $themeloginObj = new ActifendAccessAlerts; $themeloginObj->actifend_wordpress_updates_available(); debug_log( 'availableWordPressUpdates function executed.' ); } function actifendUpdatetheme() { $upthemeObj = new ActifendAccessAlerts; $upthemeObj->actifend_update_theme(); debug_log( 'actifendUpdatetheme function executed.' ); } function getBlockedIPList() { $ipObj = new ActifendIPBlock; $ipObj->actifendGetBlockedIpsList(); debug_log( 'getBlockedIPList function executed.' ); } function getIPListToBlock() { $blockIp = new ActifendIPBlock; $blockIp->actifendIpListForBlock(); debug_log( 'getIPListToBlock function executed.' ); } function DeleteBlockedIPs() { $delObj = new ActifendIPBlock; $delObj->actifend_delete_ip_list(); debug_log( 'DeleteBlockedIPs function executed.' ); } function do_eval_scan() { $ascan = new ActifendScan; $ascan->malScan( ABSPATH ); if (! empty( $ascan->infectedFiles ) && sizeof( $ascan->infectedFiles['eval'] ) > 0 ) { $ascan->sendInfectedFilesData( $ascan->infectedFiles ); } debug_log("do_eval_scan function executed."); } // Execute all processes that need to run every minute function processes_running_every_minute() { wordpressRestore(); wordpressBackup(); fileIntegrityCheck(); getIPListToBlock(); DeleteBlockedIPs(); } ?>