Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ver()
- return 0.1
- end
- function errors(_iError)
- if(_iError == nil) then
- _iError = 503
- end
- if(_iError ~= 0) then
- if(_iError == 403) then
- gui.windowSimple({"Brak uprawnien", "", "", "", "[ENTER] Kontynuuj"})
- elseif(_iError == 401) then
- gui.windowSimple({"Brak uprawnien", "podano bledne dane", "", "", "[ENTER] Kontynuuj"})
- elseif(_iError == 408) then
- gui.windowSimple({"Twoja sesja wygasla", "zaloguj sie ponownie", "", "", "[ENTER] Kontynuuj"})
- elseif(_iError == 503) then
- gui.windowSimple({"Usluga chwilowo niedostepna", "", "", "", "[ENTER] Kontynuuj"})
- else
- gui.windowSimple({"Wystapil blad", "", "", "", "[ENTER] Kontynuuj"})
- end
- listener.waitEnter()
- end
- return _iError
- end
- function session(_sUcmsRoot, _sUsername, _sKey)
- local data = {}
- local arr = nil
- gui.windowSimple({"", "", "Pobieranie danych...", "", ""})
- data = net.httpToArray(_sUcmsRoot.."p/api/ucms_session&lite=1&username=".._sUsername.."&session=".._sKey)
- arr = json.decode(data[1])
- data = nil
- ucms.errors(arr.ucms_error)
- if(arr.ucms_error ~= 0) then
- arr = false
- end
- return arr
- end
- function login(_sUcmsRoot)
- while true do
- local username = nil
- local password = nil
- username = gui.windowSimpleInput({"Login:", "", ""}, 27, nil, true)
- password = gui.windowSimpleInput({"Haslo:", "", ""}, 27, true, true)
- if username == nil or password == nil then
- gui.windowSimple({"Podano bledne dane", "", "", "", "[ENTER] Zaloguj"})
- listener.waitEnter()
- else
- gui.windowSimple({"", "Trwa logowanie...", "", "Prosze czekac", ""})
- password = sha256.sha256(password)
- while true do
- local data = {}
- local arr = nil
- data = net.httpToArray(_sUcmsRoot.."p/api/ucms_login&lite=1&username="..username.."&password="..password)
- arr = json.decode(data[1])
- if(arr.ucms_error == 0) then
- gui.windowSimple({"", "Zalogowano", "", "", "[ENTER] Kontynuuj"})
- listener.waitEnter()
- else
- ucms.errors(arr.ucms_error)
- data = nil
- arr = false
- end
- return arr
- end
- end
- end
- end
- function query(_sUcmsRoot, _oObject, _sApiOption, _sParameters)
- local data = {}
- local arr = nil
- if(_oObject.username == nil) then
- _oObject.username = ""
- end
- if(_oObject.session == nil) then
- _oObject.session = ""
- end
- gui.windowSimple({"", "", "Pobieranie danych...", "", ""})
- data = net.httpToArray(_sUcmsRoot.."p/api/".._sApiOption.."&lite=1&username=".._oObject.username.."&session=".._oObject.key.._sParameters)
- arr = json.decode(data[1])
- data = nil
- ucms.errors(arr.ucms_error)
- if(arr.ucms_error ~= 0) then
- _oObject.ucms_error = arr.ucms_error
- arr = _oObject
- end
- return arr
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement