Skip to content

Instantly share code, notes, and snippets.

@NoMan2000
Last active December 30, 2015 22:49
Show Gist options
  • Save NoMan2000/7897202 to your computer and use it in GitHub Desktop.
Save NoMan2000/7897202 to your computer and use it in GitHub Desktop.
Check for the PHP document root.
<?php
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
echo "$header: $value <br />\n";
}
$headers_response = apache_response_headers();
foreach ($headers_response as $header_response => $value) {
echo "$header_response: $value <br />\n";
}
echo "<br/>";
echo $_SERVER['SERVER_ADMIN'];
$rootServer = $_SERVER["DOCUMENT_ROOT"];
var_dump($_SERVER['HTTP_USER_AGENT']);
if(stristr($_SERVER['HTTP_USER_AGENT'], "Windows")&&($_SERVER['SERVER_ADMIN'] == "michael.soileau@cellcontrol.com")){
echo "This is a Windows machine!";
}
echo "<br/><br/>";
echo dirname($rootServer);
echo "<br/><br/>";
echo basename($rootServer);
echo "<br/><br/>";
echo parse_url($rootServer);
echo "<br/><br/>";
echo realpath($rootServer);
?>
<?php
/*
vhosts must be configured correctly for this to work.
DocumentRoot "C:/Apache24/htdocs/ecommerce_testing/ex2/html"
ServerName http://anet.dev:80
Note the use of forward slashes. By default, Windows directories are backslashes.
Do not use that as it will cause serious problems. use ./ to indicate inside of the current root.
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment