32 lines
761 B
PHP
32 lines
761 B
PHP
<?php
|
|
|
|
namespace Sandpiper\Actions;
|
|
|
|
class index extends \Sandpiper\AbstractAction
|
|
{
|
|
|
|
public function __construct()
|
|
{
|
|
}
|
|
|
|
public function handle() {
|
|
global $settings;
|
|
|
|
$uri_root = dirname("http://" . $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]);
|
|
|
|
$toml_response_code = $this->get_response_code("$uri_root/settings.toml");
|
|
|
|
if($toml_response_code >= 200 && $toml_response_code < 300)
|
|
send_error(503, "Error: The settings file is visible from the web!");
|
|
|
|
header("content-type: text/plain");
|
|
exit("Your setup looks ok :-)");
|
|
}
|
|
|
|
protected function get_response_code($url) {
|
|
stream_context_set_default([ 'http' => [ 'method' => 'HEAD' ] ]);
|
|
|
|
$headers = get_headers($url);
|
|
return intval(explode(" ", $headers[0])[1]);
|
|
}
|
|
}
|