-
-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2108 from OnlineDynamic/accessibilityandsecurityd…
…ec24 Lockdown mod_status and phpinfo
- Loading branch information
Showing
7 changed files
with
148 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Allow server status reports generated by mod_status, | ||
# with the URL of http://servername/server-status | ||
# Uncomment and change the "192.0.2.0/24" to allow access from other hosts. | ||
|
||
<Location /server-status> | ||
SetHandler server-status | ||
Order deny,allow | ||
Deny from all | ||
Allow from localhost ip6-localhost | ||
</Location> | ||
|
||
|
||
# Keep track of extended status information for each request | ||
ExtendedStatus On | ||
|
||
# Determine if mod_status displays the first 63 characters of a request or | ||
# the last 63, assuming the request itself is greater than 63 chars. | ||
# Default: Off | ||
#SeeRequestTail On | ||
|
||
|
||
<IfModule mod_proxy.c> | ||
# Show Proxy LoadBalancer status in mod_status | ||
ProxyStatus On | ||
</IfModule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
order deny,allow | ||
deny from all | ||
Require local | ||
allow from all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
ob_start(); | ||
|
||
ob_start(); // Capturing | ||
phpinfo(); // phpinfo () | ||
$info = trim(ob_get_clean()); // output | ||
|
||
// Replace white space in ID and NAME attributes... if exists | ||
$info = preg_replace('/(id|name)(=["\'][^ "\']+) ([^ "\']*["\'])/i', '$1$2_$3', $info); | ||
|
||
$imp = new DOMImplementation(); | ||
$dtd = $imp->createDocumentType( | ||
'html', | ||
'-//W3C//DTD XHTML 1.0 Transitional//EN', | ||
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd' | ||
); | ||
$doc = $imp->createDocument( | ||
'http://www.w3.org/1999/xhtml', | ||
'html', | ||
$dtd | ||
); | ||
$doc->encoding = 'utf-8'; | ||
|
||
$info_doc = new DOMDocument('1.0', 'utf-8'); | ||
/* Parse phpinfo's output | ||
* operator @ used to avoid messages about undefined entities | ||
* or use loadHTML instead | ||
*/ | ||
@$info_doc->loadXML($info); | ||
|
||
$doc->documentElement->appendChild( // Adding HEAD element to HTML | ||
$doc->importNode( | ||
$info_doc->getElementsByTagName('head')->item(0), | ||
true // With all the subtree | ||
) | ||
); | ||
$doc->documentElement->appendChild( // Adding BODY element to HTML | ||
$doc->importNode( | ||
$info_doc->getElementsByTagName('body')->item(0), | ||
true // With all the subtree | ||
) | ||
); | ||
|
||
// Now you get a clean output and you are able to validate... | ||
/* | ||
echo ($doc->saveXML ()); | ||
// OR | ||
echo ($doc->saveHTML ()); | ||
*/ | ||
|
||
// By that way it's easy to add some style declaration : | ||
$style = $doc->getElementsByTagName('style')->item(0); | ||
$style->appendChild( | ||
$doc->createTextNode( | ||
'/* SOME NEW CSS RULES TO ADD TO THE FUNCTION OUTPUT */' | ||
) | ||
); | ||
|
||
// to add some more informations to display : | ||
$body = $doc->getElementsByTagName('body')->item(0); | ||
$element = $doc->createElement('p'); | ||
$element->appendChild( | ||
$doc->createTextNode( | ||
'FPP cleaned version of phpinfo()' | ||
) | ||
); | ||
$body->appendChild($element); | ||
|
||
// to add a new header : | ||
$head = $doc->getElementsByTagName('head')->item(0); | ||
$meta = $doc->createElement('meta'); | ||
$meta->setAttribute('name', 'author'); | ||
$meta->setAttribute('content', 'arimbourg at ariworld dot eu'); | ||
$head->appendChild($meta); | ||
|
||
// As you wish, take the rest of the output and add it for debugging | ||
$out = ob_get_clean(); | ||
|
||
$pre = $doc->createElement('div'); // or pre | ||
$pre->setAttribute('style', 'white-space: pre;'); // for a div element, useless with pre | ||
$pre->appendChild($doc->createTextNode($out)); | ||
$body->appendChild($pre); | ||
|
||
$doc->formatOutput = true; // For a nice indentation | ||
//echo ($doc->saveXML()); | ||
$exportbody = $doc->documentElement->lastChild; | ||
echo ($doc->saveHTML($exportbody)); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php phpinfo(); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters