62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
|
|
if (isset($_POST['code'])) {
|
|
if (trim($_POST['code']) !== '') {
|
|
require '../vendor/indent/parser.php';
|
|
|
|
$output_dir = 'sources';
|
|
$output_file = $output_dir.'/'.time().'.txt';
|
|
|
|
if (!is_dir($output_dir)) {
|
|
mkdir($output_dir);
|
|
}
|
|
|
|
file_put_contents($output_file, indent($_POST['code']));
|
|
|
|
header('Location: '.$output_file);
|
|
die(0);
|
|
} else {
|
|
$error = 'Invalid value.';
|
|
}
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE HTML>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Markup language indenter</title>
|
|
<link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css" />
|
|
<link rel="stylesheet" href="/bootstrap/css/bootstrap-theme.min.css" />
|
|
<link rel="stylesheet" href="/css/main.css" />
|
|
</head>
|
|
<body>
|
|
|
|
<h1>Markup language indenter</h1>
|
|
|
|
<p>Give me your source code and let me indent it!</p>
|
|
|
|
<hr />
|
|
|
|
<?php if(!empty($error)): ?>
|
|
<div class="alert alert-danger"><p><?php echo htmlentities($error); ?></p></div>
|
|
<?php endif; ?>
|
|
|
|
<form data-action="/index.php" action="/bot.html" method="post">
|
|
<div class="form-group">
|
|
<textarea class="form-control" required name="code" rows="15"></textarea>
|
|
</div>
|
|
<div class="form-group">
|
|
<input class="btn btn-primary" type="submit" value="Indent it!" />
|
|
</div>
|
|
</form>
|
|
|
|
<hr />
|
|
|
|
<p>Developed by <a href="http://www.deblan.tv/">Simon Vieille</a> - <a href="https://guest:guest@svn.deblan.org/websvn/listing.php?repname=indentation.deblan.org">Open-source project</a></p>
|
|
|
|
<script type="text/javascript" src="//codeorigin.jquery.com/jquery-1.10.2.min.js"></script>
|
|
<script type="text/javascript" src="/js/main.js"></script>
|
|
</body>
|
|
</html>
|