diff --git a/tools/inc/cli.php b/tools/inc/cli.php index 5305c1ac..fbb3cfc5 100644 --- a/tools/inc/cli.php +++ b/tools/inc/cli.php @@ -1,5 +1,36 @@ -1, 'type' => ADMIN, @@ -7,4 +38,44 @@ $mod = Array( 'boards' => Array('*') ); +function get_httpd_privileges() { + global $config, $shell_path; + + if(php_sapi_name() != 'cli') + die("get_httpd_privileges(): invoked from HTTP client.\n"); + + echo "Dropping priviledges...\n"; + + if(!is_writable('.')) + die("get_httpd_privileges(): web directory is not writable\n"); + + if(!is_writable('inc/')) + die("get_httpd_privileges(): inc/ directory is not writable\n"); + + $filename = '.' . md5(rand()) . '.php'; + + echo "Copying rebuilder to web directory...\n"; + + copy($shell_path . '/' . $_SERVER['PHP_SELF'], $filename); + copy(__FILE__, 'inc/cli.php'); + + chmod($filename, 0666); + chmod('inc/cli.php', 0666); + + if(preg_match('/^https?:\/\//', $config['root'])) { + $url = $config['root'] . $filename; + } else { + // assume localhost + $url = 'http://localhost' . $config['root'] . $filename; + } + + echo "Downloading $url\n"; + + passthru('curl -s -N ' . escapeshellarg($url)); + + unlink($filename); + unlink('inc/cli.php'); + + exit(0); +} diff --git a/tools/rebuild.php b/tools/rebuild.php index 56f94aa9..0dfd9899 100755 --- a/tools/rebuild.php +++ b/tools/rebuild.php @@ -1,12 +1,5 @@ #!/usr/bin/php