PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.9
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.9
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / rosell-dk / htaccess-capability-tester / src / Testers / ServerSignatureTester.php

ServerSignatureTester.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.9, at vendor/rosell-dk/htaccess-capability-tester/src/Testers/ServerSignatureTester.php

94 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace HtaccessCapabilityTester\Testers;
4
5 /**
6 * Class for testing if ServerSignature works
7 *
8 * Testing the ServerSignature directive is of interest because the directive is a core feature.
9 * If a core feature doesn't work, well, it it would seem that .htaccess files are disabled completely.
10 * The test is thus special. If it returns *failure* it is highly probable that the .htaccess file has
11 * not been read.
12 *
13 * Unfortunately, the test requires PHP to examine if a server variable has been set. So the test is not
14 * unlikely to come out inconclusive due to a 403 Forbidden.
15 *
16 * Note that the test assumes that the ServerSignature directive has not been disallowed even though
17 * it is technically possible to do so by setting *AllowOverride* to *None* and by setting *AllowOverrideList*
18 * to a list that does not include *ServerSignature*.
19 *
20 * @package HtaccessCapabilityTester
21 * @author Bjørn Rosell <[email protected]>
22 * @since Class available since 0.7
23 */
24 class ServerSignatureTester extends CustomTester
25 {
26
27 /**
28 * Constructor.
29 *
30 * @return void
31 */
32 public function __construct()
33 {
34 $phpOn = <<<'EOD'
35 <?php
36 if (isset($_SERVER['SERVER_SIGNATURE']) && ($_SERVER['SERVER_SIGNATURE'] != '')) {
37 echo 1;
38 } else {
39 echo 0;
40 }
41 EOD;
42
43 $phpOff = <<<'EOD'
44 <?php
45 if (isset($_SERVER['SERVER_SIGNATURE']) && ($_SERVER['SERVER_SIGNATURE'] != '')) {
46 echo 0;
47 } else {
48 echo 1;
49 }
50 EOD;
51
52 // PS:
53 // There is a little edge case: When .htaccess is disabled AND phps are either not processed
54 // or access is denied. This ought to return *failure*, but it currently returns *inconclusive*.
55
56 $test = [
57 'subdir' => 'server-signature',
58 'subtests' => [
59 [
60 'subdir' => 'on',
61 'files' => [
62 ['.htaccess', 'ServerSignature On'],
63 ['test.php', $phpOn],
64 ],
65 'request' => [
66 'url' => 'test.php',
67 ],
68 'interpretation' => [
69 ['inconclusive', 'body', 'isEmpty'],
70 ['inconclusive', 'status-code', 'not-equals', '200'],
71 ['failure', 'body', 'equals', '0'],
72 ],
73 ],
74 [
75 'subdir' => 'off',
76 'files' => [
77 ['.htaccess', 'ServerSignature Off'],
78 ['test.php', $phpOff],
79 ],
80 'request' => 'test.php',
81 'interpretation' => [
82 ['inconclusive', 'body', 'isEmpty'],
83 ['success', 'body', 'equals', '1'],
84 ['failure', 'body', 'equals', '0'],
85 ['inconclusive']
86 ]
87 ]
88 ]
89 ];
90
91 parent::__construct($test);
92 }
93 }
94