View previous topic :: View next topic |
Author |
Message |
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Fri Jul 22, 2016 3:45 am Post subject: IO: load, read, write and save from and to stream file |
|
|
I've tried to make a simple Login form use CE create form. It just contain user name and password as a user database (store in local file as a text file). Not use internet or MySqL as a database.
Now, i want use user database file store, load, read , write and save as stream file as part this CT file. I am use io:file statement.
Is it possible ?. And how put a lookup function to check new or exist user by check the user database file?
Code: |
-----------------------------------------------------------------------
--- load user data file stored in stream
function loadTableCode(n2)
local t2 = findTableFile(n2)
if t2 ~= nil then
local s2 = t2.Stream
local c2 = readStringLocal(s2.Memory,s2.Size)
return c2 ~= nil and loadstring(c2)
end
end
local f2 = loadTableCode('userdata.txt')
print(type(f2))
if type(f2) == 'function' then f2() else print('not loaded') end --- need put a function in txt file?
-----------------------------------------------------------------------
--- Check for new / exist user from user database
function getUserLogin()
local a = control_getCaption(UDF1.CEEdit1)
a = tostring(a)
if a == "" then
showMessage("Please input user name and password")
return
end
local b = control_getCaption(UDF1.CEedit2)
b = tostring(b)
if b == "" then
showMessage("Please input your email and password")
return
end
local a = control_getCaption(UDF1.CEEdit1)
a = tostring(a)
fh = io.open("userdata.txt") --- io.open("E:\\userdata.txt") use local drive
while true do
line = fh:read()
if line == nil then break end
-- print (line)
if string.find(line,a) then
showMessage("Login accepted !")
fh:close()
break
else
showMessage("You must register first!")
control_setCaption(UDF1.CEEdit1,"")
control_setCaption(UDF1.CEEdit2,"")
a = ""
b = ""
fh:close()
break
end
end
end
function userRegister()
local a = control_getCaption(UDF1.CEEdit1)
a = tostring(a)
if a == "" then
showMessage("Please input your email and password")
return
end
local b = control_getCaption(UDF1.CEedit2)
b = tostring(b)
if b == "" then
showMessage("Please input your email and password")
return
end
local file = io.open("userdata.txt") --- io.open("E:\\test.txt")
while true do
line = file:read()
if line == nil then break end
-- print (line)
if string.find(line,a) then
showMessage("You already registered")
control_setCaption(UDF1.CEEdit1,"")
control_setCaption(UDF1.CEEdit2,"")
a = ""
b = ""
file:close()
break
else
local file = io.open("userdata.txt") ---io.open("E:\\test.txt", "a")
file:write(a.."/"..b, "\n")
showMessage("Registering Complete !")
beep()
control_setCaption(UDF1.CEEdit1,"")
control_setCaption(UDF1.CEEdit2,"")
file:close()
break
end
end
end
--
function CEButton1Click(sender)
getUserLogin()
end
--
function CEButton2Click(sender)
userRegister()
end
--
function CEButton3Click(sender)
closeCE();
return caFree
end
|
Thank and regards
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Fri Jul 22, 2016 8:16 am Post subject: |
|
|
Not sure of the method to save a file back into the table, but you would use findTableFile(filename) to retrieve it.
There would also be a major flaw in this implementation approach.
When you release a new version of the table, it's going to wipe out their local copy of the file.
Side note, I wouldn't want my email and password sitting out there in some text file.
|
|
Back to top |
|
|
usernotfound Expert Cheater Reputation: 0
Joined: 21 Feb 2016 Posts: 115
|
Posted: Fri Jul 22, 2016 12:05 pm Post subject: |
|
|
I don't think anyone's gonna download something that stores and saves their information like that...
|
|
Back to top |
|
|
predprey Master Cheater Reputation: 24
Joined: 08 Oct 2015 Posts: 486
|
Posted: Fri Jul 22, 2016 12:36 pm Post subject: |
|
|
Implement a hash, a salt, and an AES-256 encryption onto the password function
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Fri Jul 22, 2016 7:21 pm Post subject: |
|
|
Thanks for you all.
Here are just about the possibility of applying the statements lua IO; to manage database files. Is it possible or not.
Of course we will not share or store our private data such as email and password, etc. with risky situation, anyhow I am trying here is to create a login system that requires the user to verify before being allowed to use the game trainer.
Thank for hint findTableFile(filename) from Zanzer and Implement a hash, a salt, and an AES-256 encryption as suggest by predprey.
So, the conclusion is better use online database such as MySQL to store user database with encryption. Maybe use LuasSocket or other method.
Rgds
|
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Sat Jul 23, 2016 9:46 am Post subject: |
|
|
Lua socket is ideal, and yes you should use online database for this, never save information as a plain.
Implement as little as possible on the client more on the server.
I do not know if there luasocket plugin for C.E 6.5.1, but you could user the getInternet function,which allows you to get/post, though it's missing some functions that I found them useful.
hope DB could add the lua socket class functions into C.E.
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Thu Jul 28, 2016 9:08 am Post subject: |
|
|
Thanks DaSpammer,
I still try implementing LuaSocket for my project.
Regards
|
|
Back to top |
|
|
Lynxz Gaming Expert Cheater Reputation: 4
Joined: 01 Jul 2017 Posts: 208 Location: help
|
Posted: Wed Dec 05, 2018 8:47 am Post subject: Re: IO: load, read, write and save from and to stream file |
|
|
Aylin maybe i can help you, my discord is Lynxz Gaming#9443
_________________
my english is bad
discord : rynx#9828 |
|
Back to top |
|
|
noobes Advanced Cheater Reputation: 0
Joined: 17 Dec 2018 Posts: 89
|
Posted: Fri Dec 28, 2018 1:20 pm Post subject: |
|
|
f1 = io.input ("C:\\Users\\"..UDF1.CEEDit5.text.."\\Desktop\\"..UDF1.CEEdit4.text)
repeat
s1 = f1:read ("*l") -- read one line
if s1 then -- if not end of file (EOF)
UDF1.CEEdit2.text = s1 -- print that line
end
until not s1 -- until end of file
f1:close () -- close that file now
end
|
|
Back to top |
|
|
|