Skip to content

Instantly share code, notes, and snippets.

@wuliupo
Last active November 4, 2016 07:05
Show Gist options
  • Select an option

  • Save wuliupo/f93d744d4e660b855c0ca5a7d05bb408 to your computer and use it in GitHub Desktop.

Select an option

Save wuliupo/f93d744d4e660b855c0ca5a7d05bb408 to your computer and use it in GitHub Desktop.
Test http call
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<h1>Test http call (<?php echo mt_rand(10,100)?>)</h1>
</head>
<body>
<h1>Test http call</h1>
<ul>
<li><a href="call.php">Test</a></li>
<li><a href="call.php?m=view">View</a></li>
<li><a href="call.php?m=clear">Clear</a></li>
</ul>
<hr>
<pre>
<?php
$m = @$_GET['m'];
$file = 'call.txt';
if ($m == 'view') {
@var_dump(json_decode(file_get_contents($file), true));
echo '<script>setInterval(function(){location.reload();}, 2000);</script>';
} else if ($m == 'clear') {
@unlink($file);
echo "Clear success!\r\nJumping to view mode...";
echo '<script>setTimeout(function(){location.href="./call.php?m=view";}, 500);</script>';
} else {
$data = array(
'$_GET' => $_GET,
'$_POST' => $_POST,
'php://input' => @file_get_contents('php://input'),
'$_SERVER' => $_SERVER
);
file_put_contents($file, json_encode($data));
var_dump($data);
}
?>
</pre>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment