diff --git a/doc-src/badge b/doc-src/badge index 1c368eb690..5499e334ca 100644 --- a/doc-src/badge +++ b/doc-src/badge @@ -1,4 +1,4 @@ -Install the %%site.name%% badge on you blog or web site to show the latest updates +Install the %%site.name%% badge on your blog or web site to show the latest updates from you and your friends! diff --git a/lib/common.php b/lib/common.php index 016b04481d..7af376d1b4 100644 --- a/lib/common.php +++ b/lib/common.php @@ -19,7 +19,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -define('STATUSNET_VERSION', '0.8.2rc2'); +define('STATUSNET_VERSION', '0.8.2'); define('LACONICA_VERSION', STATUSNET_VERSION); // compatibility define('STATUSNET_CODENAME', 'Life and How to Live It'); diff --git a/scripts/console.php b/scripts/console.php new file mode 100755 index 0000000000..41dd43f281 --- /dev/null +++ b/scripts/console.php @@ -0,0 +1,162 @@ +#!/usr/bin/env php +. + */ + +# Abort if called from a web server + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$helptext = << + * + * @param string $prompt + * @return mixed string on success, false on fail or EOF + */ +function readline_emulation($prompt) +{ + if(file_exists(trim(shell_exec('which bash')))) { + $encPrompt = escapeshellarg($prompt); + $command = "read -er -p $encPrompt && echo \"\$REPLY\""; + $encCommand = escapeshellarg($command); + $metaCommand = "bash -c $encCommand"; + + // passthru passes our STDIN and TTY to the child... + // We can pull the returned string via output buffering. + ob_start(); + $retval = false; + passthru($metaCommand, $retval); + $line = ob_get_contents(); + ob_end_clean(); + + if ($retval == 0) { + return $line; + } elseif ($retval == 127) { + // Couldn't execute bash even though we thought we saw it. + // Shell probably spit out an error message, sorry :( + // Fall through to fgets()... + } else { + // EOF/ctrl+D + return false; + } + } + + // Fallback... we'll have no editing controls, EWWW + if (feof(STDIN)) { + return false; + } + print $prompt; + return fgets(STDIN); +} + +function console_help() +{ + print "Welcome to StatusNet's interactive PHP console!\n"; + print "Type some PHP code and it'll execute...\n"; + print "\n"; + print "Hint: return a value of any type to output it via var_export():\n"; + print " \$profile = new Profile();\n"; + print " \$profile->find();\n"; + print " \$profile->fetch();\n"; + print " return \$profile;\n"; + print "\n"; + print "Note that PHP is cranky and you can easily kill your session by mistyping.\n"; + print "\n"; + print "Type ctrl+D or enter 'exit' to exit.\n"; +} + + +print "StatusNet interactive PHP console... type ctrl+D or enter 'exit' to exit.\n"; +$prompt = common_config('site', 'name') . '> '; +while (!feof(STDIN)) { + $line = read_input_line($prompt); + if ($line === false) { + print "\n"; + break; + } elseif ($line !== '') { + try { + if (trim($line) == 'exit') { + break; + } elseif (trim($line) == 'help') { + console_help(); + continue; + } + + // Let's do this! + $result = eval($line); + if ($result === false) { + // parse error + } elseif ($result === null) { + // no return + } else { + // return value from eval'd code + var_export($result); + } + } catch(Exception $e) { + print get_class($e) . ": " . $e->getMessage() . "\n"; + } + } + print "\n"; +} + +if (CONSOLE_READLINE && CONSOLE_INTERACTIVE) { + @readline_write_history(CONSOLE_HISTORY); +}