FalconFour.com - Projects - Blog / Personal - Code -- Comments System -- Navigation Structure -- SFV checker -- Stats Sig/Av -- 32-character file rename batch file -- Simple Message Storage |
The problem was simple: make a way to dump text onto the internet so you can get to it from somewhere else.
The solution was simple - write a quick program on my way out the door to Blockbuster. I made it so I can save a list of movies on my desktop, then pull that list back up on my phone at the store. Also great for grocery lists, etc...
index.php
<?php
if (!isset($_GET['file'])) {
$files = glob('*.sms');
echo 'simple message storage<br>';
foreach ($files as $file) {
echo '<a href="?file='.str_replace('.sms','',$file).'">'.$file.'</a><br>';
}
echo '<a href="?file=new">new "sms" text</a><br>';
die();
} elseif ($_GET['file'] != 'new') {
$file = str_replace('/','',$_GET['file']);
$file = str_replace('\\','',$file);
$file = str_replace('.','',$file);
echo '<pre>';
echo htmlspecialchars(file_get_contents($file.'.sms'));
echo '</pre><br><a href="index.php">home</a>';
} elseif ($_GET['file'] == 'new') {
if (isset($_POST['text'])) {
if (!isset($_POST['title'])) die('oops, back');
$file = $_POST['title'];
$fh = fopen($file.'.sms','w');
fwrite($fh,stripslashes($_POST['text']));
fclose($fh);
die('<a href="index.php">back</a>');
}
echo '<form method="post" action="?file=new"><input type="text" name="title"><br>
<textarea name="text"></textarea><br>
<input type="submit">
</form>';
die();
}
?>
|
And that's it! It'll provide a link, "new 'sms' text", for you to create a new file with, and it'll place that in the same folder it's located in, and show it on the main screen when you're done. Isn't that cool?
|