-
Notifications
You must be signed in to change notification settings - Fork 0
/
bedrock-wf-userini.php
65 lines (47 loc) · 1.44 KB
/
bedrock-wf-userini.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* create/update user.ini file for wordfence
* MUST RUN THIS SCRIPT FROM THE ROOT OF THE PROJECT (one up from /web)
*
* ; Wordfence WAF
* auto_prepend_file = '~/files/web/wordfence-waf.php'
* : END Wordfence WAF
*
*/
$user_ini_path = __DIR__ . '/web/.user.ini';
$waf_path = __DIR__ . '/web/wordfence-waf.php';
//Write the Waf file
/**
* // Before removing this file, please verify the PHP ini setting `auto_prepend_file` does not point to this.
*
* if (file_exists(__DIR__.'/app/plugins/wordfence/waf/bootstrap.php')) {
* define("WFWAF_LOG_PATH", __DIR__.'/app/wflogs/');
* include_once __DIR__.'/app/plugins/wordfence/waf/bootstrap.php';
* }
*/
ob_start();
?>
// Before removing this file, please verify the PHP ini setting `auto_prepend_file` does not point to this.
if (file_exists(__DIR__.'/app/plugins/wordfence/waf/bootstrap.php')) {
define("WFWAF_LOG_PATH", __DIR__.'/app/wflogs/');
include_once __DIR__.'/app/plugins/wordfence/waf/bootstrap.php';
}
<?php
$waf_file_contents = ob_get_clean();
if ( file_put_contents( $waf_path, $waf_file_contents ) ) {
echo 'New wordfence-waf.php written.';
} else {
echo 'The waf file was not written.';
}
//Write the user INI
$new_userini = "
; Wordfence WAF
auto_prepend_file = '$waf_path'
: END Wordfence WAF
";
echo $new_userini;
if ( file_put_contents( $user_ini_path, $new_userini ) ) {
echo 'New .user.ini written.';
} else {
echo 'The file was not written.';
}