lua_utils.lua: fix issue with prefs assignment via string input fields

This commit fixes a nil value issue happening when trying to assign
preferences with string input fields.
This commit is contained in:
Arianna Avanzini 2015-05-03 02:24:20 +02:00
parent cb54f100d5
commit 939ffa6c7d

View file

@ -1417,11 +1417,15 @@ end
function prefsInputField(label, comment, key, value)
if(_GET[key] ~= nil) then
k = "ntopng.prefs."..key
v = tonumber(_GET[key])
if((v > 0) and (v < 86400)) then
v_s = _GET[key]
v = tonumber(v_s)
if(v ~= nil and (v > 0) and (v < 86400)) then
-- print(k.."="..v)
ntop.setCache(k, tostring(v))
value = v
elseif (v_s ~= nil) then
ntop.setCache(k, v_s)
value = v_s
end
end