<?php
/*
Plugin Name: افزونه امنیتی وردفنس | سایت نوین وردپرس
Plugin URI: https://wpnovin.com/product/word-fence-pro-security-plugins/
Description: <code><strong>#378697</strong></code> افزونه امنیتی برای تامین امنیت سایت های وردپرسی
Author: <strong>w w w . W P N O V I N . c o m</strong>
Version: 8.1.4
Author URI: https://wpnovin.com/product/word-fence-pro-security-plugins/
Text Domain: wordfence
Domain Path: /languages
Network: true
Requires at least: 4.7
Requires PHP: 7.4
License: GPLv3

*/


   require 'novin-update/wpnovin-atuo-update.php';
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
	'http://dl3.wpnovin.com/Source/Plugins/Wordfence/kfldkfrioklfmvf.json',
	__FILE__,
	'Wordfence'
);



const ActivatorRemainingDays     = 365 * 10;
function initWordfenceActivator() {
    try {
        wfOnboardingController::_markAttempt1Shown();
        wfConfig::set( 'onboardingAttempt3', wfOnboardingController::ONBOARDING_LICENSE );
        if ( empty( wfConfig::get( 'apiKey' ) ) ) {
            wordfence::ajax_downgradeLicense_callback();
        }
        wfConfig::set( 'isPaid', true );
        wfConfig::set( 'keyType', wfLicense::KEY_TYPE_PAID_CURRENT );
        wfConfig::set( 'premiumNextRenew', time() + ActivatorRemainingDays * 86400 );
        wfWAF::getInstance()->getStorageEngine()->setConfig( 'wafStatus', wfFirewall::FIREWALL_MODE_ENABLED );
    } catch ( Exception $exception ) {
        add_action( 'admin_notices', function () use ( $exception ) { ?>
            <div class="notice notice-error">
            <p><?php
                printf(
                    esc_html__( 'error' ),
                    esc_html( $exception->getMessage() )
                ); ?></p>
            </div><?php
        } );
    }
}
add_action( 'plugins_loaded', function () {
    if ( class_exists( 'wfLicense' ) ) {
        initWordfenceActivator();
        wfLicense::current()->setType( wfLicense::TYPE_RESPONSE );
        wfLicense::current()->setPaid( true );
        wfLicense::current()->setRemainingDays( ActivatorRemainingDays );
        wfLicense::current()->setConflicting( false );
        wfLicense::current()->setDeleted( false );
        wfLicense::current()->getKeyType();
    }
} );

if(defined('WP_INSTALLING') && WP_INSTALLING){
	return;
}

if (!defined('ABSPATH')) {
	exit;
}
define('WORDFENCE_VERSION', '8.1.4');
define('WORDFENCE_BUILD_NUMBER', '1756145765');
define('WORDFENCE_BASENAME', function_exists('plugin_basename') ? plugin_basename(__FILE__) :
	basename(dirname(__FILE__)) . '/' . basename(__FILE__));

global $wp_plugin_paths;
foreach ($wp_plugin_paths as $dir => $realdir) {
	if (strpos(__FILE__, $realdir) === 0) {
		define('WORDFENCE_FCPATH', $dir . '/' . basename(__FILE__));
		define('WORDFENCE_PATH', trailingslashit($dir));
		break;
	}
}
if (!defined('WORDFENCE_FCPATH')) {
	/** @noinspection PhpConstantReassignmentInspection */
	define('WORDFENCE_FCPATH', __FILE__);
	/** @noinspection PhpConstantReassignmentInspection */
	define('WORDFENCE_PATH', trailingslashit(dirname(WORDFENCE_FCPATH)));
}
if (!defined('WF_IS_WP_ENGINE')) {
	define('WF_IS_WP_ENGINE', isset($_SERVER['IS_WPE']));
}
if (!defined('WF_IS_FLYWHEEL')) {
	define('WF_IS_FLYWHEEL', isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Flywheel/') === 0);
}
if (!defined('WF_IS_PRESSABLE')) {
	define('WF_IS_PRESSABLE', (defined('IS_ATOMIC') && IS_ATOMIC) || (defined('IS_PRESSABLE') && IS_PRESSABLE));
}

require(dirname(__FILE__) . '/lib/wfVersionSupport.php');
/**
 * @var string $wfPHPDeprecatingVersion
 * @var string $wfPHPMinimumVersion
 * @var string $wfWordPressDeprecatingVersion
 * @var string $wfWordPressMinimumVersion
 */

if (!defined('WF_PHP_UNSUPPORTED')) {
	define('WF_PHP_UNSUPPORTED', version_compare(PHP_VERSION, $wfPHPMinimumVersion, '<'));
}

if (WF_PHP_UNSUPPORTED) {
	add_action('all_admin_notices', 'wfUnsupportedPHPOverlay');

	function wfUnsupportedPHPOverlay() {
		include "views/unsupported-php/admin-message.php";
	}
	return;
}

if (!defined('WF_WP_UNSUPPORTED')) {
	require(ABSPATH . 'wp-includes/version.php'); /** @var string $wp_version */
	define('WF_WP_UNSUPPORTED', version_compare($wp_version, $wfWordPressMinimumVersion, '<'));
}

if (WF_WP_UNSUPPORTED) {
	add_action('all_admin_notices', 'wfUnsupportedWPOverlay');
	
	function wfUnsupportedWPOverlay() {
		include "views/unsupported-wp/admin-message.php";
	}
	return;
}

if(get_option('wordfenceActivated') != 1){
	add_action('activated_plugin','wordfence_save_activation_error'); function wordfence_save_activation_error(){ update_option('wf_plugin_act_error',  ob_get_contents()); }
}
if(! defined('WORDFENCE_VERSIONONLY_MODE')){ //Used to get version from file.
	//Duplicate block of wfUtils::memoryLimit(), copied here to avoid needing to include the class at this point of execution
	$maxMemory = ini_get('memory_limit');
	if (!(is_string($maxMemory) || is_numeric($maxMemory)) || !preg_match('/^\s*\d+[GMK]?\s*$/i', $maxMemory)) { $maxMemory = '128M'; } //Invalid or unreadable value, default to our minimum
	$last = strtolower(substr($maxMemory, -1));
	$maxMemory = (int) $maxMemory;
	
	if ($last == 'g') { $maxMemory = $maxMemory * 1024 * 1024 * 1024; }
	else if ($last == 'm') { $maxMemory = $maxMemory * 1024 * 1024; }
	else if ($last == 'k') { $maxMemory = $maxMemory * 1024; }
	
	if ($maxMemory < 134217728 /* 128 MB */ && $maxMemory > 0 /* Unlimited */) {
		$disabled = ini_get('disable_functions');
		if (!is_string($disabled) || strpos(ini_get('disable_functions'), 'ini_set') === false) {
			@ini_set('memory_limit', '128M'); //Some hosts have ini set at as little as 32 megs. 128 is the min sane amount of memory.
		}
	}

	/**
	 * Constant to determine if Wordfence is installed on another WordPress site one or more directories up in
	 * auto_prepend_file mode.
	 */
	define('WFWAF_SUBDIRECTORY_INSTALL', class_exists('wfWAF') &&
		!in_array(realpath(dirname(__FILE__) . '/vendor/wordfence/wf-waf/src/init.php'), get_included_files()));
	if (!WFWAF_SUBDIRECTORY_INSTALL) {
		require_once(dirname(__FILE__) . '/vendor/wordfence/wf-waf/src/init.php');
		if (!wfWAF::getInstance()) {
			define('WFWAF_AUTO_PREPEND', false);
			require_once(dirname(__FILE__) . '/waf/bootstrap.php');
		}
	}
	
	//Modules

	//Load
	require_once(dirname(__FILE__) . '/lib/wordfenceConstants.php');
	require_once(dirname(__FILE__) . '/lib/wfI18n.php');
	require_once(dirname(__FILE__) . '/lib/wordfenceClass.php');
	require_once(dirname(__FILE__) . '/lib/Diff/functions.php');
	require_once(dirname(__FILE__) . '/lib/Diff/main.php');

	wordfence::install_actions();
}