# HG changeset patch # User Dan # Date 1243365982 14400 # Node ID 8663af0e27c7715ea13341b29643df3e1153a3cd # Parent efabb54a418d62a4b5fd90d3c37e4efa6d0d3af8 A little more work on reboot support. Still not enabled, but should work eventually. diff -r efabb54a418d -r 8663af0e27c7 uiconfig.php --- a/uiconfig.php Tue May 26 15:25:58 2009 -0400 +++ b/uiconfig.php Tue May 26 15:26:22 2009 -0400 @@ -55,7 +55,9 @@ if ( $authed && isset($_POST['submit']) ) { + $tried = true; $need_reboot = ( isset($_POST['public']) !== $GLOBALS['public'] || + isset($_POST['ipv6']) !== $GLOBALS['enable_ipv6'] || isset($_POST['allow_fork']) !== $GLOBALS['allow_fork']); // compile the new config file @@ -63,17 +65,32 @@ $allowcontrol = ( isset($_POST['allowcontrol']) ) ? 'true' : 'false'; $allow_fork = ( isset($_POST['allow_fork']) ) ? 'true' : 'false'; $use_auth = ( isset($_POST['use_auth']) ) ? 'true' : 'false'; + $ipv6_settings = ( isset($_POST['ipv6']) ) ? '$GLOBALS[\'enable_ipv4\'] = false; +$GLOBALS[\'enable_ipv6\'] = true;' : '$GLOBALS[\'enable_ipv4\'] = true; +$GLOBALS[\'enable_ipv6\'] = false;'; + $GLOBALS['enable_ipv6'] = isset($_POST['ipv6']); // for auth_data, we're going to merge the data from POST with the current auth_data array. $auth_data = $GLOBALS['auth_data']; $auth_changed = false; - foreach ( $auth_data as $user => $pass ) + if ( isset($_POST['users']) ) { - if ( !in_array($user, $_POST['users']) ) + foreach ( $auth_data as $user => $pass ) { + if ( !in_array($user, $_POST['users']) ) + { + $auth_changed = true; + unset($auth_data[$user]); + } + } + } + else + { + if ( !empty($auth_data) ) + { + $auth_data = array(); $auth_changed = true; - unset($auth_data[$user]); - } + } } if ( isset($_POST['users_add']) ) { @@ -85,7 +102,11 @@ } $auth_data = var_export_string($auth_data); - $new_configpass = ( isset($_POST['configpass']) && is_string($_POST['newconfigpass']) && $_POST['newconfigpass'] != '____________________' ) ? sha1($_POST['newconfigpass']) : $GLOBALS['configpass']; + $new_configpass = ( isset($_POST['newconfigpass']) && is_string($_POST['newconfigpass']) && $_POST['newconfigpass'] != '____________________' ) ? sha1($_POST['newconfigpass']) : $GLOBALS['configpass']; + if ( isset($_POST['newconfigpass']) && $_POST['newconfigpass'] === true ) + $new_configpass = ''; + + $needpass = ( $new_configpass != '' ); $config_file = <<Please restart Greyhound using Amarok's script manager for public IP and multithreading options to take effect." : ''; + $rebootblurb = $need_reboot ? "\nPlease restart Greyhound using Amarok's script manager for public IP, multithreading, and IPv6 options to take effect." : ''; } $success = "Configuration changes successful.{$passblurb}{$rebootblurb}"; - $httpd->threader->ipc_send(array('action' => 'reloadconfig', 'propagate' => true)); + if ( $httpd->threader->is_child() ) + { + $httpd->threader->ipc_send(array('action' => 'reloadconfig', 'propagate' => true)); + } + else + { + grey_reload_config(); + } if ( $need_reboot && REBOOT_SUPPORT ) { - $addr = $GLOBALS['public'] ? '0.0.0.0' : '127.0.0.1'; - $fork = $GLOBALS['allow_fork']; + if ( $GLOBALS['enable_ipv6'] ) + { + $addr = isset($_POST['public']) ? '::' : '::1'; + } + else + { + $addr = isset($_POST['public']) ? '0.0.0.0' : '127.0.0.1'; + } + $fork = isset($_POST['allow_fork']); $httpd->reboot($addr, null, $fork); } } @@ -167,10 +205,12 @@ $smarty->assign('needpass', $needpass); $smarty->assign('use_auth', $use_auth); $smarty->assign('public', $GLOBALS['public']); + $smarty->assign('ipv6', $GLOBALS['enable_ipv6']); $smarty->assign('allowcontrol', $GLOBALS['allowcontrol']); $smarty->assign('allow_fork', $GLOBALS['allow_fork']); $smarty->assign('use_auth', $GLOBALS['use_auth']); $smarty->assign('users', $GLOBALS['auth_data']); + $smarty->assign('reboot_support', REBOOT_SUPPORT); $smarty->assign('error', $error); $smarty->display('config.tpl'); }