From 4a8189ac7d37698e23101a1472d76336665b67b3 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 5 Nov 2009 17:18:16 -0500 Subject: update version number --- lib/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common.php b/lib/common.php index 016b04481..7af376d1b 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'); -- cgit v1.2.3 From 4b7a36ea1932cfd2245560fa9949dc32fe2d2fc7 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 6 Nov 2009 14:31:39 +0100 Subject: console.php terminal script provides interactive PHP console in StatusNet environment, handy for testing! Uses readline for line input editing if available; falls back to bash+readline if not native, and takes fgets() in worst case. Currently a bit awkward in that each input line is parsed separately, so loops and function defs have to be squished to one line. --- scripts/console.php | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100755 scripts/console.php diff --git a/scripts/console.php b/scripts/console.php new file mode 100755 index 000000000..e65529a8d --- /dev/null +++ b/scripts/console.php @@ -0,0 +1,153 @@ +#!/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 run!\n"; + print "\n"; + print "Note that PHP is cranky and you can easily kill your session.\n"; +} + + +$prompt = common_config('site', 'name') . '> '; +while (!feof(STDIN)) { + $line = read_input_line($prompt); + if ($line === false) { + print "\n"; + break; + } elseif ($line !== '') { + try { + if ($line == 'exit') { + break; + } elseif ($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); +} -- cgit v1.2.3 From 1e1b2f778387bdbd0a22a06e94b1e145565b43dd Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 6 Nov 2009 15:03:03 +0100 Subject: console.php: fix up the help and include a handy cut-n-paste'able example --- scripts/console.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/console.php b/scripts/console.php index e65529a8d..f1b089a7c 100755 --- a/scripts/console.php +++ b/scripts/console.php @@ -110,12 +110,21 @@ function readline_emulation($prompt) function console_help() { print "Welcome to StatusNet's interactive PHP console!\n"; - print "Type some PHP code and it'll run!\n"; + print "Type some PHP code and it'll execute...\n"; print "\n"; - print "Note that PHP is cranky and you can easily kill your session.\n"; + print "Hint: return a value of any time 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); @@ -124,14 +133,14 @@ while (!feof(STDIN)) { break; } elseif ($line !== '') { try { - if ($line == 'exit') { + if (trim($line) == 'exit') { break; - } elseif ($line == 'help') { + } elseif (trim($line) == 'help') { console_help(); continue; } - // Let's do this + // Let's do this! $result = eval($line); if ($result === false) { // parse error -- cgit v1.2.3 From 8516c4eef0f5c1a5d1a0a1a6c077475875eed297 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 6 Nov 2009 15:04:23 +0100 Subject: typo :P --- scripts/console.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/console.php b/scripts/console.php index f1b089a7c..41dd43f28 100755 --- a/scripts/console.php +++ b/scripts/console.php @@ -112,7 +112,7 @@ 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 time to output it via var_export():\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"; -- cgit v1.2.3 From 134319649f41796d804777f5740c5dae978f1a7a Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 8 Nov 2009 11:38:33 +0100 Subject: Fix typo in doc/badge (bug 1958) --- doc-src/badge | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc-src/badge b/doc-src/badge index 1c368eb69..5499e334c 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! -- cgit v1.2.3