summaryrefslogtreecommitdiff
path: root/shell/bin/editor.php
blob: a136cd2dac5d4b319ab639c1692304bfc7718f34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
class p_editor extends prog {
	public static function main($args, $env) {
		if (isset($_POST['stdin'])) {
			if (false) {//if (isset($args[1])) {
				echo $args[0].': saving to `'.$args[1]."'\n";
				file_put_contents($args[1],$_POST['stdin']);
			} else {
				echo $_POST['stdin'];
			}
		} else {
			if (isset($args[1]) && file_exists($args[1])) {
				$text = file_get_contents($args[1]);
			} else {
				$text = '';
			}
			echo '<div class="editor">';
			echo '<input type="hidden" name="stdout_dest" value="'.$_POST['c'].'" />';
			echo '<textarea name="stdin">'.htmlentities($text).'</textarea>'."\n";
			echo '<input type="submit" value="save" />';
			echo '</div>';
		}
	}
}