Last active
March 6, 2017 06:50
-
-
Save Hydriz/4755021 to your computer and use it in GitHub Desktop.
A script to output some server statistics to visitors
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
<?php | |
/** | |
* | |
* host_stats.php | |
* | |
* Based on the Internet Archive's host_stats.php | |
* Outputs information about the server hosting | |
* this file. | |
* | |
* Requires Apache web server with PHP. | |
* | |
* WARNING: This file may accidentally expose some | |
* private information about your web server, please | |
* use it with extreme care. | |
*/ | |
function makeHeader() { | |
$output = "<html> | |
<head> | |
<title>Host statistics</title> | |
</head> | |
<style>"; | |
$output .= makeStyle(); | |
$output .= "</style> | |
<body>"; | |
return $output; | |
} | |
function makeStyle() { | |
return "div { | |
border:1px dashed gray; | |
margin:10px; | |
padding:5px; | |
background-color:wheat; | |
font-family:monospace; | |
white-space: pre; | |
} | |
b { | |
font-size: 10pt; | |
background-color: #dddddd; | |
display:block; | |
}"; | |
} | |
function runquery($query) { | |
$result = shell_exec($query); | |
$output = "<div><b>$query</b> | |
$result | |
</div>"; | |
return $output; | |
} | |
function initialisePage() { | |
$output = makeHeader(); | |
$output .= runquery("whoami"); | |
$output .= runquery("df -h"); | |
return $output; | |
} | |
// Build page | |
echo initialisePage(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment