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
|
27 |
|
public function __construct() |
33
|
|
|
{ |
34
|
|
|
$phpOn = <<<'EOD' |
35
|
27 |
|
<?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
|
27 |
|
<?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
|
27 |
|
'subdir' => 'server-signature', |
58
|
|
|
'subtests' => [ |
59
|
|
|
[ |
60
|
27 |
|
'subdir' => 'on', |
61
|
|
|
'files' => [ |
62
|
|
|
['.htaccess', 'ServerSignature On'], |
63
|
27 |
|
['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
|
27 |
|
'subdir' => 'off', |
76
|
|
|
'files' => [ |
77
|
|
|
['.htaccess', 'ServerSignature Off'], |
78
|
27 |
|
['test.php', $phpOff], |
79
|
|
|
], |
80
|
27 |
|
'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
|
27 |
|
parent::__construct($test); |
92
|
27 |
|
} |
93
|
|
|
} |
94
|
|
|
|