PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 3.1.0
Defender Security – Malware Scanner, Login Security & Firewall v3.1.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / component / security-tweaks / prevent-php.php

prevent-php.php in Defender Security – Malware Scanner, Login Security & Firewall 3.1.0, at src/component/security-tweaks/prevent-php.php

78 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WP_Defender\Component\Security_Tweaks;
4
5 use Calotes\Base\Component;
6 use WP_Defender\Component\Security_Tweaks\Servers\Server;
7
8 /**
9 * Class Prevent_PHP
10 * @package WP_Defender\Component\Security_Tweaks
11 */
12 class Prevent_PHP extends Component {
13 public $slug = 'prevent-php-executed';
14
15 /**
16 * Check whether the issue has been resolved or not.
17 *
18 * @return bool
19 */
20 public function check() {
21 return Server::create( Server::get_current_server() )->from( $this->slug )->check();
22 }
23
24 /**
25 * Here is the code for processing, if the return is true, we add it to resolve list, WP_Error if any error.
26 * @param string $current_server
27 *
28 * @return bool|\WP_Error
29 */
30 public function process( $current_server ) {
31 return Server::create( $current_server )->from( $this->slug )->process();
32 }
33
34 /**
35 * This is for un-do stuff that has be done in @process.
36 * @param string|null $current_server
37 *
38 * @return bool|\WP_Error
39 */
40 public function revert( $current_server = null ) {
41 if ( is_null( $current_server ) ) {
42 $current_server = Server::get_current_server();
43 }
44 return Server::create( $current_server )->from( $this->slug )->revert();
45 }
46
47 /**
48 * Shield up.
49 *
50 * @return bool
51 */
52 public function shield_up() {
53 return true;
54 }
55
56 /**
57 * Return a summary data of this tweak.
58 *
59 * @return array
60 */
61 public function to_array() {
62 return [
63 'slug' => $this->slug,
64 'title' => __( 'Prevent PHP Execution', 'wpdef' ),
65 'errorReason' => __( 'PHP execution is currently allowed in all directories.', 'wpdef' ),
66 'successReason' => __( 'You\'ve disabled PHP execution, good stuff.', 'wpdef' ),
67 'misc' => [
68 'active_server' => Server::get_current_server(),
69 'apache_rules' => Server::create( 'apache' )->from( $this->slug )->get_rules_for_instruction(),
70 'nginx_rules' => Server::create( 'nginx' )->from( $this->slug )->get_rules(),
71 'wp_content_dir' => WP_CONTENT_DIR
72 ],
73 'bulk_description' => __( 'By default, a plugin/theme vulnerability could allow a PHP file to get uploaded into your site\'s directories and in turn execute harmful scripts that can wreak havoc on your website. We will disable PHP execution for you.', 'wpdef' ),
74 'bulk_title' => __( 'PHP Execution', 'wpdef' )
75 ];
76 }
77 }
78