Skip to content

Instantly share code, notes, and snippets.

@Hydriz
Last active March 6, 2017 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hydriz/4755021 to your computer and use it in GitHub Desktop.
Save Hydriz/4755021 to your computer and use it in GitHub Desktop.
A script to output some server statistics to visitors
<?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