aboutsummaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorThedro Neely <thedroneely@gmail.com>2019-01-21 10:54:17 -0500
committertdro <tdro@users.noreply.github.com>2019-01-21 11:02:22 -0500
commit9a4ce5d03bf529264bf26672d0e6215164a0d0cf (patch)
treed08d2ef6129d8c8f0c4697679a5ef02e4263babe /public
parent2f8488167460091874d4d18a7279af08bedc0094 (diff)
downloadedwinmattiacci.com-9a4ce5d03bf529264bf26672d0e6215164a0d0cf.tar.gz
edwinmattiacci.com-9a4ce5d03bf529264bf26672d0e6215164a0d0cf.tar.bz2
edwinmattiacci.com-9a4ce5d03bf529264bf26672d0e6215164a0d0cf.zip
.gitignore: Ignore hot comments storage and error tester
Initial preparations for automated deployment
Diffstat (limited to 'public')
-rw-r--r--public/error/error.html225
1 files changed, 0 insertions, 225 deletions
diff --git a/public/error/error.html b/public/error/error.html
deleted file mode 100644
index 14467d7..0000000
--- a/public/error/error.html
+++ /dev/null
@@ -1,225 +0,0 @@
-<?php
-
-/**
- * Web Server HTTP status code response test
- *
- * For PHP applications that run on a web server that intercepts all
- * fast-cgi errors with the appropriate Http error template response. This program
- * will run through given HTTP error response codes.
- *
- * @author Thedro Neely <thedroneely@gmail.com>
- *
- * @copyright Copyright 2018, Thedro Neely.
- * @license https://github.com/tdro
- * @link https://github.com/tdro
- */
-
-declare(strict_types=1);
-
-$path = $_SERVER['DOCUMENT_ROOT'];
-$errorJsonFile = $path . '/error/error.json';
-$errorFile = $path . '/error/error.html';
-$debug = true;
-
-$errorList = [
- 400, 401, 402, 403, 404, 405, 406, 407, 408, 409,
- 410, 411, 412, 413, 414, 415, 416, 417, 418, 421,
- 422, 423, 424, 426, 428, 429, 431, 451, 500, 501,
- 502, 503, 504, 505, 511, 520, 522, 524
-];
-
-$parameters = [
- 'HttpResponseCode' => (int) $errorList[0],
- 'Run' => (int) 1,
-];
-
-/**
- * Functions
- */
-
-function read($file) {
- return json_decode(file_get_contents($file), true);
-}
-
-function write($file, $json) {
- file_put_contents($file, json_encode($json), 0);
-}
-
-function debug ($message, $debug) {
- if ($debug) {
- echo '<pre>' . $message . '</pre>';
- }
-}
-
-/**
- * Inline CSS styling
- */
-
-echo '
- <style>
-
- pre {
- background-color: black;
- color: white;
- max-width: 20em;
- padding: 0.5em;
- z-index: 10;
- }
-
- form { z-index: 10; }
-
- </style>
-';
-
-/**
- * Forms
- */
-
-if (isset($_POST["stop"])) {
- $parameters['Run'] = 0;
-}
-
-if (isset($_POST["start"])) {
- $parameters['Run'] = 1;
-}
-
-if ($parameters['Run'] === 1) {
- echo '
- <form action="/error/error.html" method="post" id="stop">
- <input type="hidden" name="stop" value=stop>
- </form>
-
- <button type="submit" form="stop">Stop</button>
- ';
-}
-
-if ($parameters['Run'] === 0) {
- echo '
- <form action="/error/error.html" method="post" id="start">
- <input type="hidden" name="start" value=start>
- </form>
-
- <form action="/error/error.html" method="post" id="previous">
- <input type="hidden" name="previous" value=previous>
- </form>
-
- <form action="/error/error.html" method="post" id="next">
- <input type="hidden" name="next" value=next>
- </form>
-
- <button type="submit" form="start">Start</button>
- <button type="submit" form="previous"><</button>
- <button type="submit" form="next">></button>
- ';
-}
-
-/**
- * Json File
- */
-
-if (!file_exists($errorJsonFile)) {
-
- debug('Socket file does not exist. Creating...', $debug);
- write($errorJsonFile, $parameters);
-
- if (!file_exists($errorJsonFile)) {
- debug('Socket file creation failed!', $debug);
- return;
- }
-}
-
-/**
- * Error Code and Array Keys
- */
-
-$getError = read($errorJsonFile)['HttpResponseCode'];
-debug('Current Error Code: ' . $getError . '<br>', $debug);
-
-$currentErrorKey = array_search($getError, $errorList);
-$nextErrorKey = $currentErrorKey + 1;
-
-$getErrorTotal = count($errorList) - 1;
-debug('Error List Count: ' . ($currentErrorKey + 1) . '/' . ($getErrorTotal + 1), $debug);
-
-/**
- * Error Run
- */
-
-if ($nextErrorKey <= $getErrorTotal) {
-
- if ($parameters['Run'] === 1) {
- echo '<meta http-equiv="refresh" content="1; url=/error/error.html">';
- }
-
- foreach ($parameters as $parameter) {
- $parameters['HttpResponseCode'] = $errorList[$nextErrorKey];
- }
-
- write($errorJsonFile, $parameters);
- var_dump(read($errorJsonFile));
- var_dump($_POST);
-
- /**
- * Send HTTP response code
- */
-
- http_response_code((int) $getError);
- return;
-
-}
-
-write($errorJsonFile, $parameters);
-debug('Error run completed.', $debug);
-var_dump($parameters);
-
-/**
- * Http Response Template Files
- */
-
-$http_response_status = [
- 400 => "Bad Request",
- 401 => "Unauthorized",
- 402 => "Payment Required",
- 403 => "Forbidden",
- 404 => "Not Found",
- 405 => "Method Not Allowed",
- 406 => "Not Acceptable",
- 407 => "Proxy Authentication Required",
- 408 => "Request Timeout",
- 409 => "Conflict",
- 410 => "Gone",
- 411 => "Length Required",
- 412 => "Precondition Failed",
- 413 => "Payload Too Large",
- 414 => "Requested URI Too Long",
- 415 => "Unsupported Media Type",
- 416 => "Requested Range Not Satisfiable",
- 417 => "Expectation Failed",
- 418 => "I'm a teapot",
- 421 => "Misdirected Request",
- 422 => "Unprocessable Entity",
- 423 => "Locked",
- 424 => "Failed Dependency",
- 426 => "Upgrade Required",
- 428 => "Precondition Required",
- 429 => "Too Many Requests",
- 431 => "Request Header Fields Too Large",
- 444 => "Connection Closed Without Response",
- 451 => "Unavailable For Legal Reasons",
- 500 => "Internal Server Error",
- 501 => "Not Implemented",
- 502 => "Bad Gateway",
- 503 => "Service Unavailable",
- 504 => "Gateway Timeout",
- 505 => "HTTP Version Not Supported",
- 506 => "Variant Also Negotiates",
- 507 => "Insufficient Storage",
- 508 => "Loop Detected",
- 510 => "Not Extended",
- 511 => "Network Authentication Required",
-];
-
-// var_dump($http_response_status);
-// echo key($http_response_status);
-
-?>