Help ticket #3449:

Improve data validation to avoid save a host/subnet or a IPv4 with
invalid mask. The reported error is on javascript and only happen on
IE8,but this fix will prevent the same issue happening in the future on
a different browser.
Move this global declaration to the proper file rather than backend code
Put a timeout of 30 seconds to aid with Ticket #3412