本文整理汇总了PHP中wordfence::runInstallCalled方法的典型用法代码示例。如果您正苦于以下问题:PHP wordfence::runInstallCalled方法的具体用法?PHP wordfence::runInstallCalled怎么用?PHP wordfence::runInstallCalled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wordfence
的用法示例。
在下文中一共展示了wordfence::runInstallCalled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runInstall
public static function runInstall()
{
if (self::$runInstallCalled) {
return;
}
self::$runInstallCalled = true;
if (function_exists('ignore_user_abort')) {
ignore_user_abort(true);
}
$previous_version = get_option('wordfence_version', '0.0.0');
update_option('wordfence_version', WORDFENCE_VERSION);
//In case we have a fatal error we don't want to keep running install.
//EVERYTHING HERE MUST BE IDEMPOTENT
//Remove old legacy cron job if exists
wp_clear_scheduled_hook('wordfence_scheduled_scan');
$schema = new wfSchema();
$schema->createAll();
//if not exists
wfConfig::setDefaults();
//If not set
$restOfSite = wfConfig::get('cbl_restOfSiteBlocked', 'notset');
if ($restOfSite == 'notset') {
wfConfig::set('cbl_restOfSiteBlocked', '1');
}
//Install new schedule. If schedule config is blank it will install the default 'auto' schedule.
wordfence::scheduleScans();
if (wfConfig::get('autoUpdate') == '1') {
wfConfig::enableAutoUpdate();
//Sets up the cron
}
if (!wfConfig::get('apiKey')) {
$api = new wfAPI('', wfUtils::getWPVersion());
try {
$keyData = $api->call('get_anon_api_key');
if ($keyData['ok'] && $keyData['apiKey']) {
wfConfig::set('apiKey', $keyData['apiKey']);
} else {
throw new Exception("Could not understand the response we received from the Wordfence servers when applying for a free API key.");
}
} catch (Exception $e) {
error_log("Could not fetch free API key from Wordfence: " . $e->getMessage());
return;
}
}
wp_clear_scheduled_hook('wordfence_daily_cron');
wp_clear_scheduled_hook('wordfence_hourly_cron');
if (is_main_site()) {
wp_schedule_event(time(), 'daily', 'wordfence_daily_cron');
//'daily'
wp_schedule_event(time(), 'hourly', 'wordfence_hourly_cron');
}
$db = new wfDB();
if ($db->columnExists('wfHits', 'HTTPHeaders')) {
//Upgrade from 3.0.4
global $wpdb;
$prefix = $wpdb->base_prefix;
$count = $db->querySingle("select count(*) as cnt from {$prefix}" . "wfHits");
if ($count > 20000) {
$db->queryWrite("delete from {$prefix}" . "wfHits order by id asc limit " . ($count - 20000));
}
$db->dropColumn('wfHits', 'HTTPHeaders');
}
//Upgrading from 1.5.6 or earlier needs:
$db->createKeyIfNotExists('wfStatus', 'level', 'k2');
if (wfConfig::get('isPaid') == 'free') {
wfConfig::set('isPaid', '');
}
//End upgrade from 1.5.6
/** @var wpdb $wpdb */
global $wpdb;
$prefix = $wpdb->base_prefix;
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfConfig modify column val longblob");
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfBlocks add column permanent tinyint UNSIGNED default 0");
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfStatus modify column msg varchar(1000) NOT NULL");
//3.1.2 to 3.1.4
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfBlocks modify column blockedTime bigint signed NOT NULL");
//3.2.1 to 3.2.2
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfLockedOut modify column blockedTime bigint signed NOT NULL");
$db->queryWriteIgnoreError("drop table if exists {$prefix}" . "wfFileQueue");
$db->queryWriteIgnoreError("drop table if exists {$prefix}" . "wfFileChanges");
$result = $wpdb->get_row("SHOW FIELDS FROM {$prefix}wfStatus where field = 'id'");
if (!$result || strtolower($result->Key) != 'pri') {
//Adding primary key to this table because some backup apps use primary key during backup.
$db->queryWriteIgnoreError("alter table {$prefix}wfStatus add id bigint UNSIGNED NOT NULL auto_increment PRIMARY KEY");
}
$optScanEnabled = $db->querySingle("select val from {$prefix}" . "wfConfig where name='scansEnabled_options'");
if ($optScanEnabled != '0' && $optScanEnabled != '1') {
$db->queryWrite("update {$prefix}" . "wfConfig set val='1' where name='scansEnabled_options'");
}
$optScanEnabled = $db->querySingle("select val from {$prefix}" . "wfConfig where name='scansEnabled_heartbleed'");
if ($optScanEnabled != '0' && $optScanEnabled != '1') {
//Enable heartbleed if no value is set.
wfConfig::set('scansEnabled_heartbleed', 1);
}
if (wfConfig::get('cacheType') == 'php' || wfConfig::get('cacheType') == 'falcon') {
wfCache::removeCacheDirectoryHtaccess();
}
// IPv6 schema changes for 6.0.1
$tables_with_ips = array('wfCrawlers', 'wfBadLeechers', 'wfBlockedIPLog', 'wfBlocks', 'wfHits', 'wfLeechers', 'wfLockedOut', 'wfLocs', 'wfLogins', 'wfReverseCache', 'wfScanners', 'wfThrottleLog', 'wfVulnScanners');
foreach ($tables_with_ips as $ip_table) {
//.........这里部分代码省略.........
示例2: runInstall
public static function runInstall()
{
if (self::$runInstallCalled) {
return;
}
self::$runInstallCalled = true;
if (function_exists('ignore_user_abort')) {
ignore_user_abort(true);
}
$previous_version = get_option('wordfence_version', '0.0.0');
update_option('wordfence_version', WORDFENCE_VERSION);
//In case we have a fatal error we don't want to keep running install.
//EVERYTHING HERE MUST BE IDEMPOTENT
//Remove old legacy cron job if exists
wp_clear_scheduled_hook('wordfence_scheduled_scan');
$schema = new wfSchema();
$schema->createAll();
//if not exists
wfConfig::setDefaults();
//If not set
$restOfSite = wfConfig::get('cbl_restOfSiteBlocked', 'notset');
if ($restOfSite == 'notset') {
wfConfig::set('cbl_restOfSiteBlocked', '1');
}
//Install new schedule. If schedule config is blank it will install the default 'auto' schedule.
wordfence::scheduleScans();
if (wfConfig::get('autoUpdate') == '1') {
wfConfig::enableAutoUpdate();
//Sets up the cron
}
if (!wfConfig::get('apiKey')) {
$api = new wfAPI('', wfUtils::getWPVersion());
try {
$keyData = $api->call('get_anon_api_key');
if ($keyData['ok'] && $keyData['apiKey']) {
wfConfig::set('apiKey', $keyData['apiKey']);
} else {
throw new Exception("Could not understand the response we received from the Wordfence servers when applying for a free API key.");
}
} catch (Exception $e) {
error_log("Could not fetch free API key from Wordfence: " . $e->getMessage());
return;
}
}
wp_clear_scheduled_hook('wordfence_daily_cron');
wp_clear_scheduled_hook('wordfence_hourly_cron');
if (is_main_site()) {
wp_schedule_event(time(), 'daily', 'wordfence_daily_cron');
//'daily'
wp_schedule_event(time(), 'hourly', 'wordfence_hourly_cron');
}
$db = new wfDB();
if ($db->columnExists('wfHits', 'HTTPHeaders')) {
//Upgrade from 3.0.4
global $wpdb;
$prefix = $wpdb->base_prefix;
$count = $db->querySingle("select count(*) as cnt from {$prefix}" . "wfHits");
if ($count > 20000) {
$db->queryWrite("delete from {$prefix}" . "wfHits order by id asc limit " . ($count - 20000));
}
$db->dropColumn('wfHits', 'HTTPHeaders');
}
//Upgrading from 1.5.6 or earlier needs:
$db->createKeyIfNotExists('wfStatus', 'level', 'k2');
if (wfConfig::get('isPaid') == 'free') {
wfConfig::set('isPaid', '');
}
//End upgrade from 1.5.6
/** @var wpdb $wpdb */
global $wpdb;
$prefix = $wpdb->base_prefix;
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfConfig modify column val longblob");
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfBlocks add column permanent tinyint UNSIGNED default 0");
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfStatus modify column msg varchar(1000) NOT NULL");
//3.1.2 to 3.1.4
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfBlocks modify column blockedTime bigint signed NOT NULL");
//3.2.1 to 3.2.2
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfLockedOut modify column blockedTime bigint signed NOT NULL");
$db->queryWriteIgnoreError("drop table if exists {$prefix}" . "wfFileQueue");
$db->queryWriteIgnoreError("drop table if exists {$prefix}" . "wfFileChanges");
$result = $wpdb->get_row("SHOW FIELDS FROM {$prefix}wfStatus where field = 'id'");
if (!$result || strtolower($result->Key) != 'pri') {
//Adding primary key to this table because some backup apps use primary key during backup.
$db->queryWriteIgnoreError("alter table {$prefix}wfStatus add id bigint UNSIGNED NOT NULL auto_increment PRIMARY KEY");
}
$optScanEnabled = $db->querySingle("select val from {$prefix}" . "wfConfig where name='scansEnabled_options'");
if ($optScanEnabled != '0' && $optScanEnabled != '1') {
$db->queryWrite("update {$prefix}" . "wfConfig set val='1' where name='scansEnabled_options'");
}
$optScanEnabled = $db->querySingle("select val from {$prefix}" . "wfConfig where name='scansEnabled_heartbleed'");
if ($optScanEnabled != '0' && $optScanEnabled != '1') {
//Enable heartbleed if no value is set.
wfConfig::set('scansEnabled_heartbleed', 1);
}
if (wfConfig::get('cacheType') == 'php' || wfConfig::get('cacheType') == 'falcon') {
wfCache::removeCacheDirectoryHtaccess();
}
// IPv6 schema changes for 6.0.1
$tables_with_ips = array('wfCrawlers', 'wfBadLeechers', 'wfBlockedIPLog', 'wfBlocks', 'wfHits', 'wfLeechers', 'wfLockedOut', 'wfLocs', 'wfLogins', 'wfReverseCache', 'wfScanners', 'wfThrottleLog', 'wfVulnScanners');
foreach ($tables_with_ips as $ip_table) {
//.........这里部分代码省略.........
示例3: runInstall
public static function runInstall()
{
if (self::$runInstallCalled) {
return;
}
self::$runInstallCalled = true;
update_option('wordfence_version', WORDFENCE_VERSION);
//In case we have a fatal error we don't want to keep running install.
//EVERYTHING HERE MUST BE IDEMPOTENT
//Remove old legacy cron job if exists
wp_clear_scheduled_hook('wordfence_scheduled_scan');
$restOfSite = wfConfig::get('cbl_restOfSiteBlocked', 'notset');
if ($restOfSite == 'notset') {
wfConfig::set('cbl_restOfSiteBlocked', '1');
}
$schema = new wfSchema();
$schema->createAll();
//if not exists
wfConfig::setDefaults();
//If not set
//Install new schedule. If schedule config is blank it will install the default 'auto' schedule.
wordfence::scheduleScans();
if (wfConfig::get('autoUpdate') == '1') {
wfConfig::enableAutoUpdate();
//Sets up the cron
}
if (!wfConfig::get('apiKey')) {
$api = new wfAPI('', wfUtils::getWPVersion());
try {
$keyData = $api->call('get_anon_api_key');
if ($keyData['ok'] && $keyData['apiKey']) {
wfConfig::set('apiKey', $keyData['apiKey']);
} else {
throw new Exception("Could not understand the response we received from the Wordfence servers when applying for a free API key.");
}
} catch (Exception $e) {
error_log("Could not fetch free API key from Wordfence: " . $e->getMessage());
return;
}
}
wp_clear_scheduled_hook('wordfence_daily_cron');
wp_clear_scheduled_hook('wordfence_hourly_cron');
wp_schedule_event(time(), 'daily', 'wordfence_daily_cron');
//'daily'
wp_schedule_event(time(), 'hourly', 'wordfence_hourly_cron');
$db = new wfDB();
if ($db->columnExists('wfHits', 'HTTPHeaders')) {
//Upgrade from 3.0.4
global $wpdb;
$prefix = $wpdb->base_prefix;
$count = $db->querySingle("select count(*) as cnt from {$prefix}" . "wfHits");
if ($count > 20000) {
$db->queryWrite("delete from {$prefix}" . "wfHits order by id asc limit " . ($count - 20000));
}
$db->dropColumn('wfHits', 'HTTPHeaders');
}
//Upgrading from 1.5.6 or earlier needs:
$db->createKeyIfNotExists('wfStatus', 'level', 'k2');
if (wfConfig::get('isPaid') == 'free') {
wfConfig::set('isPaid', '');
}
//End upgrade from 1.5.6
global $wpdb;
$prefix = $wpdb->base_prefix;
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfConfig modify column val longblob");
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfBlocks add column permanent tinyint UNSIGNED default 0");
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfStatus modify column msg varchar(1000) NOT NULL");
//3.1.2 to 3.1.4
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfBlocks modify column blockedTime bigint signed NOT NULL");
//3.2.1 to 3.2.2
$db->queryWriteIgnoreError("alter table {$prefix}" . "wfLockedOut modify column blockedTime bigint signed NOT NULL");
$db->queryWriteIgnoreError("drop table if exists {$prefix}" . "wfFileQueue");
$db->queryWriteIgnoreError("drop table if exists {$prefix}" . "wfFileChanges");
$optScanEnabled = $db->querySingle("select val from {$prefix}" . "wfConfig where name='scansEnabled_options'");
if ($optScanEnabled != '0' && $optScanEnabled != '1') {
$db->queryWrite("update {$prefix}" . "wfConfig set val='1' where name='scansEnabled_options'");
}
$optScanEnabled = $db->querySingle("select val from {$prefix}" . "wfConfig where name='scansEnabled_heartbleed'");
if ($optScanEnabled != '0' && $optScanEnabled != '1') {
//Enable heartbleed if no value is set.
wfConfig::set('scansEnabled_heartbleed', 1);
}
//Must be the final line
}