--- 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 = <<<EOF
<?php
@@ -120,6 +141,9 @@
// password for site configuration
\$GLOBALS['configpass'] = '$new_configpass';
+// IPv4 and IPv6
+$ipv6_settings
+
EOF;
$error = 'Couldn\'t write to the config file (./greyhound-config.php).';
@@ -136,15 +160,29 @@
}
else
{
- $rebootblurb = $need_reboot ? "\n<small>Please restart Greyhound using Amarok's script manager for public IP and multithreading options to take effect.</small>" : '';
+ $rebootblurb = $need_reboot ? "\n<small>Please restart Greyhound using Amarok's script manager for public IP, multithreading, and IPv6 options to take effect.</small>" : '';
}
$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');
}