Created
November 19, 2015 14:52
-
-
Save walterdavis/84c75ce31ce7e7e792e3 to your computer and use it in GitHub Desktop.
Form debugger
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 | |
header('Content-type: text/html; charset=utf-8'); | |
function clean($mxdInput){ | |
//recursive function for multidimensional arrays | |
if(is_string($mxdInput)) return htmlspecialchars($mxdInput); | |
$out = array(); | |
foreach($mxdInput as $k=>$v){ | |
$out[$k] = clean($v); | |
} | |
return $out; | |
} | |
function isAjax() { | |
return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && | |
($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')); | |
} | |
$request = array(); | |
if(count($_POST) > 0){ | |
$request['post'] = print_r(clean($_POST),true); | |
} | |
if(count($_GET) > 0){ | |
$request['get'] = print_r(clean($_GET),true); | |
} | |
if(count($_FILES) > 0){ | |
$request['files'] = print_r($_FILES,true); | |
} | |
if(count($_SESSION) > 0){ | |
$request['session'] = print_r(clean($_SESSION),true); | |
} | |
if(count($_COOKIE) > 0){ | |
$request['cookie'] = print_r(clean($_COOKIE),true); | |
} | |
if(isAjax()){ | |
print_r( $request ); | |
exit; | |
} | |
$out = ''; | |
foreach($request as $key => $val){ | |
$out .= '<h2>' . strtoupper($key) . '</h2><pre><code>' . $val . '</code></pre><hr />'; | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Reflector</title> | |
<link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8"/> | |
</head> | |
<body> | |
<div> | |
<h1>Reflector</h1> | |
<p>This page shows all the form submissions sent to it.</p> | |
<?= $out ?> | |
<p><a href="javascript:history.go(-1);" title="Back">Back</a></p> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment