3 if (php_sapi_name() == "cli") {
4 $HISTORY_FILE = $_SERVER['HOME'] . "/.mal-history";
5 function mal_readline($prompt) {
7 static $history_loaded = false;
9 // Load the history file
10 if (! $history_loaded) {
11 $history_loaded = true;
12 if (is_readable($HISTORY_FILE)) {
13 if ($file = fopen($HISTORY_FILE, "r")) {
14 while (!feof($file)) {
16 if ($line) { readline_add_history($line); }
23 $line = readline($prompt);
24 if ($line === false) { return NULL; }
25 readline_add_history($line);
27 // Append to the history file
28 if (is_writable($HISTORY_FILE)) {
29 if ($file = fopen($HISTORY_FILE, "a")) {
30 fputs($file, $line . "\n");
38 function mal_readline($prompt) {}