function sixscan_menu_install() { /* We show the amount of non-fixed vulnerabilities near 6Scan icon. If there are 0 - we do not show anything */ $vulnerability_count = get_option(SIXSCAN_OPTION_VULNERABITILY_COUNT); if ($vulnerability_count == 0) { $sixscan_menu_title = "6Scan"; } else { /* Only way to show number near menu is to use the same class, that is used by Plugins menu (when showing how many plugins are out of date ) */ $sixscan_menu_title = "6Scan<span class='update-plugins count-" . $vulnerability_count . "'><span class='plugin-count'>" . number_format_i18n($vulnerability_count) . "</span></span>"; } if (isset($_GET['sixscan_activated']) && $_GET['sixscan_activated'] == '1' || isset($_GET['activate']) && $_GET['activate'] == 'true' && sixscan_common_is_account_active() == FALSE) { $sixscan_menu_title .= sixscan_installation_error_description('OK', '', 'REGISTER_STARTED', '0'); } add_menu_page('6Scan', $sixscan_menu_title, 'manage_options', SIXSCAN_COMMON_DASHBOARD_URL, '', SIXSCAN_PLUGIN_URL . 'data/img/logo_small.png'); add_submenu_page(SIXSCAN_COMMON_DASHBOARD_URL, '6Scan Dashboard', 'Dashboard', 'manage_options', SIXSCAN_COMMON_DASHBOARD_URL, 'sixscan_menu_dashboard'); if (sixscan_common_is_account_operational() == TRUE) { add_submenu_page(SIXSCAN_COMMON_DASHBOARD_URL, '6Scan Settings', 'Settings', 'manage_options', SIXSCAN_COMMON_SETTINGS_URL, 'sixscan_menu_settings'); } add_submenu_page(SIXSCAN_COMMON_DASHBOARD_URL, '6Scan Support', 'Support', 'manage_options', SIXSCAN_COMMON_SUPPORT_URL, 'sixscan_menu_support'); }
function sixscan_installation_install($tmp_key) { try { /* Clear the operational flag. It will be set, if activation is successful */ sixscan_common_set_account_operational(FALSE); global $wp_filesystem; $current_wp_filesystem = $tmp_key == "" ? 'direct' : 'ftp'; if (is_multisite()) { $err_message = "6Scan Install <b>Error</b>: 6Scan currently does not support multisite installs. The support will be added soon"; return sixscan_menu_wrap_error_msg($err_message) . sixscan_installation_error_description("Multisite install failed", $current_wp_filesystem); } /* Make sure we can create signature file and update the site's .htaccess file */ if (sixscan_common_test_dir_writable($wp_filesystem->abspath()) == FALSE) { $err_message = "6Scan Install <b>Error</b>: Failed creating signature file at Wordpress directory " . ABSPATH . SIXSCAN_COMM_SIGNATURE_FILENAME . "<br/><br/>Please see <a href='http://codex.wordpress.org/Changing_File_Permissions' target='_blank'>this Wordpress article</a> for more information on how to add write permissions." . "<br/><br/>If you have additional questions, please visit our <a href='http://6scan.com/support' target='_blank'>community</a>"; return sixscan_menu_wrap_error_msg($err_message) . sixscan_installation_error_description("Failed creating signature file", $current_wp_filesystem); } if ($wp_filesystem->exists(SIXSCAN_HTACCESS_FILE) && sixscan_common_test_file_writable(SIXSCAN_HTACCESS_FILE) == FALSE) { $err_message = "6Scan Install <b>Error</b>: Failed writing .htaccess file " . SIXSCAN_HTACCESS_FILE . "<br/><br/>Please see <a href='http://codex.wordpress.org/Changing_File_Permissions' target='_blank'>this Wordpress article</a> for more information on how to add write permissions." . "<br/><br/>If you have additional questions, please visit our <a href='http://6scan.com/support' target='_blank'>community</a>"; return sixscan_menu_wrap_error_msg($err_message) . sixscan_installation_error_description("Failed writing .htaccess file", $current_wp_filesystem); } if ($wp_filesystem->is_writable(SIXSCAN_PLUGIN_DIR . "/6scan.php") == FALSE) { $err_message = "6Scan Install <b>Error</b>: Can't modify 6Scan directory. This usually happens when security permissions do not allow writing to the Wordpress directory." . "<br/><br/>Please see <a href='http://codex.wordpress.org/Changing_File_Permissions' target='_blank'>this Wordpress article</a> for more information on how to add write permissions." . "<br/><br/>If you have additional questions, please visit our <a href='http://6scan.com/support' target='_blank'>community</a>"; return sixscan_menu_wrap_error_msg($err_message) . sixscan_installation_error_description("Failed initializing WP_Filesystem()", $current_wp_filesystem); } if (ini_get("allow_url_fopen") == FALSE && !function_exists('curl_init')) { $err_message = "6Scan Install <b>Error</b>: No libcurl found <b>and</b> \"allow_url_fopen\" in your php.ini is disabled. 6Scan needs at least <b>one</b> transport layer to be enabled, in order to contact its server for automatic updates.<br>" . "*Please see <a href='http://6scan.freshdesk.com/solution/articles/3257-installing-curl-extension-on-a-system' target='_blank'> this FAQ entry</a> in order to enable Curl<br>" . "*Please see <a href='http://6scan.freshdesk.com/solution/categories/3294/folders/6728/articles/2681-i-am-seeing-an-error-that-is-similar-to-could-not-open-handle-for-fopen-' target='_blank'>this FAQ entry</a> for instructions on how to enable the \"allow_url_fopen\" flag<br>" . "<br/><br/>If you have additional questions, please visit our <a href='http://6scan.com/support' target='_blank'>community</a>"; return sixscan_menu_wrap_error_msg($err_message) . sixscan_installation_error_description("No libcurl found and allow_url_fopen is disabled", $current_wp_filesystem); } /* Rewrite the htaccess and 6scan-gate file */ $htaccess_install_result = sixscan_htaccess_install(); if ($htaccess_install_result !== TRUE) { return sixscan_menu_wrap_error_msg($htaccess_install_result['user_message']) . sixscan_installation_error_description($htaccess_install_result['short_description'], $current_wp_filesystem); } if (sixscan_common_is_regdata_present() == TRUE) { if (sixscan_communication_oracle_reg_reactivate(sixscan_common_get_site_id(), sixscan_common_get_api_token()) == TRUE) { /* There is no real install to go on, just reactivation */ sixscan_common_set_account_operational(TRUE); sixscan_common_set_account_active(TRUE); return TRUE; } else { sixscan_common_erase_regdata(); } } /* Register process */ $server_registration_result = sixscan_installation_register_with_server($tmp_key); if ($server_registration_result !== TRUE) { /* If something went wrong in the registration/verification process */ sixscan_common_erase_regdata(); return $server_registration_result . sixscan_installation_error_description("Server registration failed", $current_wp_filesystem); } /* Account is now active, but not yet operational ( operation is set by server, when user completes the registration */ sixscan_common_set_account_active(TRUE); /* Preparing options for further use */ update_option(SIXSCAN_OPTION_COMM_ORACLE_NONCE, 1); update_option(SIXSCAN_OPTION_COMM_LAST_SIG_UPDATE_NONCE, 0); update_option(SIXSCAN_OPTION_STAT_SUSPICIOUS_REQ_COUNT, 0); update_option(SIXSCAN_OPTION_STAT_OK_REQ_COUNT, 0); update_option(SIXSCAN_OPTION_WAF_REQUESTED, array()); update_option(SIXSCAN_OPTION_LOGIN_SETTINGS, array()); update_option(SIXSCAN_VULN_MESSAGE_DISMISSED, FALSE); } catch (Exception $e) { /* Exception aborts the process */ sixscan_common_erase_regdata(); sixscan_common_set_account_active(FALSE); sixscan_common_set_account_operational(FALSE); return $e . sixscan_installation_error_description("Exception occured while installing", $current_wp_filesystem); } return TRUE; }