diff --git a/wwwroot/inc/functions.php b/wwwroot/inc/functions.php
index 26691b8a0..f922c1a50 100644
--- a/wwwroot/inc/functions.php
+++ b/wwwroot/inc/functions.php
@@ -5117,6 +5117,38 @@ function showNotice ($message, $option = '')
setMessage ('neutral', $message, $option == 'inline');
}
+// asks ok/cancel question
+// return TRUE/FALSE/NULL
+// NULL = waiting for choice
+// adds 'answer' to request post data and repeats request
+function showChoice ($question)
+{
+ if (isset ($_POST['answer']))
+ return ($_POST['answer'] === 'true' ? TRUE : FALSE);
+
+ $form = "
';
+
+ $msg = $question;
+ $question = str_replace ('
', '\n', $question);
+ $question = str_replace ("'", "\'", $question);
+ $msg .= <<
+ answer = confirm('$question');
+ $('input#answer').val(answer);
+ $('form#choice').submit();
+
+ENDMSG;
+
+ setMessage ('warning', $msg, FALSE);
+
+ return NULL;
+}
+
// do not call this directly, use showError and its siblings instead
// $type could be 'error', 'warning', 'success' or 'neutral'
function setMessage ($type, $message, $direct_rendering)
diff --git a/wwwroot/inc/ophandlers.php b/wwwroot/inc/ophandlers.php
index 2e43b7a32..736eeae61 100644
--- a/wwwroot/inc/ophandlers.php
+++ b/wwwroot/inc/ophandlers.php
@@ -1010,11 +1010,42 @@ function addIPAllocation ()
return;
}
- if($address['reserved'] && $address['name'] != '')
+ $autorelease = getConfigVar ('IPV4_AUTO_RELEASE');
+ if ($autorelease > 0)
{
- showWarning("IP ".ip_format($ip_bin)." reservation \"".$address['name']."\" is removed");
- //TODO ask to take reserved IP or not !
+ $reserved = $ipname = FALSE;
+ if ($autorelease >= 1 && $address['reserved'] == 'yes')
+ $reserved = TRUE;
+ if ($autorelease >= 2 && $address['name'] != '')
+ $ipname = TRUE;
+
+ if ($reserved || $ipname)
+ {
+ $choice = showChoice ('Assign IP '.ip_format ($ip_bin).' Name: "'.$address['name'].'"?
'.
+ ($reserved ? 'IP reservation will be removed!
' : '').
+ ($ipname ? 'IP name "'.$address['name'].'" and comment will be removed!' : '')
+ );
+
+ if ($choice === NULL) // waiting for choice
+ return;
+
+ if($choice !== TRUE)
+ {
+ showWarning ('IP '.ip_format ($ip_bin).' Name: "'.$address['name'].'" NOT assigned
'.
+ ($reserved ? 'IP is still reserved!
' : '').
+ ($ipname ? 'IP name "'.$address['name'].'" and comment unchanged' : ''));
+
+ return buildRedirectURL (NULL, NULL, array ('hl_ip' => ip_format ($ip_bin)));
+ }
+
+ showWarning ('IP '.ip_format ($ip_bin).' Name: "'.$address['name'].'" assigned
'.
+ ($reserved ? 'IP is NO longer reserved!
' : '').
+ ($ipname ? 'IP name "'.$address['name'].'" and comment removed!' : ''));
+ }
}
+ else
+ if ($address['reserved'] == 'yes' && $address['name'] != '')
+ showWarning ('IP '.ip_format ($ip_bin).' Name: "'.$address['name'].'" is already reserved!');
bindIPToObject
(