summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-03-15 22:16:26 +1100
committerMichael Save <savetheinternet@tinyboard.org>2012-03-15 22:16:26 +1100
commit224c7763076bc6c59aaddaa6fb47091b95ffb46e (patch)
treedf885456f2028f58380356ccc87e41d19d3c544e
parentaf7b5b5d78b5981a2b47cea0afa614bc70a6c7f5 (diff)
pass command line arguments to http client
-rw-r--r--tools/inc/cli.php9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/inc/cli.php b/tools/inc/cli.php
index 8fdb6c39..1dcf12a6 100644
--- a/tools/inc/cli.php
+++ b/tools/inc/cli.php
@@ -30,7 +30,7 @@ if(!getenv('TINYBOARD_PATH')) {
chdir(realpath('inc') . '/..');
}
-echo 'Tinyboard: ' . getcwd() . "\n";
+putenv('TINYBOARD_PATH=' . getcwd());
require 'inc/functions.php';
require 'inc/display.php';
@@ -47,7 +47,7 @@ $mod = Array(
);
function get_httpd_privileges() {
- global $config, $shell_path;
+ global $config, $shell_path, $argv;
if(php_sapi_name() != 'cli')
die("get_httpd_privileges(): invoked from HTTP client.\n");
@@ -65,15 +65,18 @@ function get_httpd_privileges() {
// replace "/inc/cli.php" with its new filename
passthru("cat " . escapeshellarg($shell_path . '/' . $_SERVER['PHP_SELF']) . " | sed \"s/'\/inc\/cli\.php'/'\/{$inc_filename}'/\" > {$filename}");
- // copy environment
$inc_header = "<?php\n";
+ // copy environment
$env = explode("\n", shell_exec('printenv | grep ^TINYBOARD'));
foreach($env as $line) {
if(!empty($line))
$inc_header .= "putenv('" . addslashes($line) . "');\n";
}
+ // copy command line arguments
+ $inc_header .= "\$argv = " . var_export($argv, true) . ";\n";
+
// copy this file
file_put_contents($inc_filename, $inc_header . substr($inc = file_get_contents(__FILE__), strpos($inc, "\n")));