I think that this script is helpful, but it would also be nice if I
could maintain one global copy of my todo list that I can edit from
anywhere. So, I created a php interface that will interact with a
local todo.sh to accomplish this. You could run this on your home
computer if you have a webserver running, or if you don't (like me),
you just use an automated scp command to copy down the todo.txt files
when they change.
So far as the php code goes, I coded quickly, but it appears to work
without problems. I put in only the essential features b/c I want to
be able to access this page using my phone's browser, so I needed to
keep the html size down. Still, code focus on the input line and does
an automatic refresh when items are added or removed. It also pre
formats the -h output so that it's easy to read.
Please let me know what you think.
<?php
$output = null;
$input = $_POST['input'];
if ($input == '' ) { $input = 'list'; }
?>
<html>
<head>
<?php if ( (strtolower($input) != 'list') && (strtolower($input) !=
'ls') && (strtolower($input) != 'listall') && (strtolower($input) !=
'lsa') && (strtolower($input) != 'listpri') && (strtolower($input) !=
'lsp') && (strtolower($input) != '-h') ) { echo "<meta
http-equiv=\"refresh\" content=\"3\">\n"; } ?>
<title>USERNAME Todo List</title>
</head>
<body onload="document.todo.input.focus()">
<br />
<form name="todo" action="t.php" method="post">
<input type="text" size=75 name="input">
<input type="submit" value="Submit">
</form>
<hr />
<?php
function t_echo($value)
{
print "$value <br \/>";
}
exec('/home/USERNAME/bin/todo.sh -p -v -f -d /home/USERNAME/.todo
'.escapeshellcmd($input), $output);
if ($input == '-h') { echo "<pre>"; }
array_walk($output, 't_echo');
?>
</body></html>