Skip to content

Instantly share code, notes, and snippets.

@kossoy
Created October 4, 2011 14:35
Show Gist options
  • Save kossoy/1261794 to your computer and use it in GitHub Desktop.
Save kossoy/1261794 to your computer and use it in GitHub Desktop.
Dummy file dumper
<?php
header('Content-Type: text/html; charset=UTF-8');
# Folder-DB no in web root
define('DB_FOLDER', dirname(__FILE__) . '/../svalka/');
if (isset($_REQUEST['submit'])) {
// Handle the form submit
if('' == $_REQUEST['file-name']) die('Empty filename');
file_put_contents(
DB_FOLDER . $_REQUEST['file-name'],
$_REQUEST['file-contents']
);
}
// Show created files
if ($handle = opendir(DB_FOLDER)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "<p class='fname'>$file:</p>";
echo '<div class="content">' . file_get_contents(DB_FOLDER .$file) . '</div>';
}
}
closedir($handle);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Content uploader</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
.content {
margin: 5px;
margin-bottom: 50px;
padding: 5px;
background: #c4c4c4;
width: 300px;
border: 1px solid #768fad;
}
.fname {
width: 320px;
padding: 2px;
border-bottom: 1px solid #00234c;
}
</style>
</head>
<body>
<form action="ivan.php" method="post" accept-charset="utf-8">
<p>
<label for="file-name">File name:</label>
<input type="text" name="file-name" id="file-name"/>
</p>
<p>
<label for="file-contents">Message:</label>
</p>
<p>
<textarea id="file-contents" name="file-contents" rows="8" cols="40"></textarea>
</p>
<p><input name="submit" type="submit" value="Continue &rarr;"></p>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment