summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspiderr <spiderr@bitweaver.org>2020-06-20 11:23:29 -0400
committerspiderr <spiderr@bitweaver.org>2020-06-20 11:23:29 -0400
commit6f8c8a8775e8ab8d37efc8298050f17f6c9bfa7b (patch)
tree0c763c21a1a5d3e6b121042e1a8c819c053b14a3
parent852e0d5ba40ba83969dd7a78210ba556af33af10 (diff)
downloadkernel-6f8c8a8775e8ab8d37efc8298050f17f6c9bfa7b.tar.gz
kernel-6f8c8a8775e8ab8d37efc8298050f17f6c9bfa7b.tar.bz2
kernel-6f8c8a8775e8ab8d37efc8298050f17f6c9bfa7b.zip
clean up argv parsing; fix SCRIPT_URI SCRIPT_URL in CLI
-rw-r--r--config_defaults_inc.php28
1 files changed, 16 insertions, 12 deletions
diff --git a/config_defaults_inc.php b/config_defaults_inc.php
index 51b8e73..4d30a8d 100644
--- a/config_defaults_inc.php
+++ b/config_defaults_inc.php
@@ -28,8 +28,8 @@ if( !empty( $gShellScript ) ) {
'REQUEST_METHOD' => 'GET',
'REQUEST_URI' => __FILE__,
'REQUEST_URI' => __FILE__,
- 'SCRIPT_URI' => __FILE__,
- 'SCRIPT_URL' => __FILE__,
+ 'SCRIPT_URI' => $_SERVER['SCRIPT_FILENAME'],
+ 'SCRIPT_URL' => $_SERVER['SCRIPT_NAME'],
'SERVER_ADDR' => $siteName,
'SERVER_ADMIN' => 'root@'.$siteName,
'SERVER_NAME' => '',
@@ -47,18 +47,22 @@ if( !empty( $gShellScript ) ) {
$gArgs = array();
if( $argv ) {
foreach( $argv AS $arg ) {
- switch( $arg ) {
- case '--debug':
- $gDebug = TRUE;
- break;
- case strpos( $arg, '--' ) === 0:
- if( strpos( $arg, '=' ) ) {
- $gArgs[substr( $arg, 2, strpos( $arg, '=' )-2 )] = (int)substr( $arg, (strpos( $arg, '=' ) +1) );
- } else {
- $gArgs[substr( $arg, 2 )] = TRUE;
- }
+ $argKey = $arg;
+ if( strpos( $arg, '--' ) === 0 ) {
+ $argKey = substr( $arg, 2 );
+ }
+ $argValue = TRUE;
+ if( strpos( $arg, '=' ) ) {
+ $argKey = substr( $arg, 2, strpos( $arg, '=' )-2 );
+ $argValue = substr( $arg, (strpos( $arg, '=' ) +1) );
+ }
+ switch( $argKey ) {
+ case 'debug':
+ $gDebug = $argValue;
break;
}
+ $gArgs[$argKey] = $argValue;
+ $_REQUEST[$argKey] = $argValue;
}
}
}