<?php
if (PHP_SAPI === 'cli') {
echo 'Usage:' . PHP_EOL;
echo " run: php -S localhost:8080 {$argv[0]}" . PHP_EOL;
echo ' browse http://localhost:8080/' . PHP_EOL;
exit;
}
function h($s) { echo htmlspecialchars($s, ENT_QUOTES, "UTF-8"); }
$server_received_html = filter_input(INPUT_POST, "user-edited-html");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="https://cdn.tinymce.com/4/tinymce.min.js"></script>
<script>
// https://www.tinymce.com/docs/configure/
tinymce.init({
selector: "#editor",
// https://github.com/tinymce/tinymce/issues/2352
// Languages are not available via CDN #2352
// language: "ja",
width: 600,
height: 300,
// https://www.tinymce.com/docs/plugins/
plugins: "textcolor lists image link preview",
// menubar: "edit view", //false,
// statusbar: false,
toolbar:
["undo redo | formatselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent",
"fontsizeselect forecolor image link preview"
],
});
</script>
</head>
<body>
<form method="post">
<textarea id="editor" name="user-edited-html"><?php h($server_received_html); ?></textarea>
<input type="submit" value="submit">
</form>
<h2>loopback</h2>
<?php if ($server_received_html) { ?>
<pre><?php h($server_received_html); ?></pre>
<?php } ?>
</body>
</html>