SphereCommunity
Registration - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Registration (/Thread-Registration)



Registration - Llirik - 09-30-2015 07:38 PM

This is right script?

[FUNCTION f_account_register]
if !<file.inuse>
file.mode.create=1
file.mode.append=1
file.mode.writeflag=1
if <file.open accounts/sphereacct.scp>
db.query SELECT * FROM register WHERE activ=0
if <db.row.numrows>
for i 0 <eval <db.row.numrows>-1>
file.writeline [<db.row.<eval <local.i>>.0>]
file.writeline password=<db.row.<eval <local.i>>.1>
db.execute UPDATE register SET activ=1 WHERE login=<db.row.<eval <local.i>>.0>
endfor
endif
file.close
ACCOUNT UPDATE
endif
else
serv.log Write error(f_test)
endif


RE: Registration - XuN - 09-30-2015 09:43 PM

Do you have any special need of using FILE commands there? ACCOUNT ADD <db.row.<dlocal.i>.0> <db.row.<dlocal.i>.1> will do the job.


RE: Registration - Llirik - 10-01-2015 01:52 AM

[FUNCTION f_account_register]
db.query SELECT * FROM register WHERE activ=0
if <db.row.numrows>
for i 0 <eval <db.row.numrows>-1>
ACCOUNT ADD <db.row.<dlocal.i>.0> <db.row.<dlocal.i>.1>
db.execute UPDATE register SET activ=1 WHERE login=<db.row.<eval <local.i>>.0>
endfor
endif
ACCOUNT UPDATE

Right?


RE: Registration - Coruja - 10-01-2015 07:40 AM

ACCOUNT UPDATE is used only to move your temporary accounts from sphereacct.scp to permanently create it sphereaccu.scp. So you can remove this ACCOUNT UPDATE since you're not using these files anymore

also for security reasons you must always use ' ' on values and " " around the SQL function. This can prevent some SQL exploits like ppl trying to hack your SQL command to add more fields, etc

Code:
[FUNCTION f_account_register]
DB.QUERY "SELECT * FROM register WHERE activ='0'"
IF (<DB.ROW.NUMROWS>)
  FOR 0 <eval <DB.ROW.NUMROWS>-1>
    ACCOUNT ADD <DB.ROW.<LOCAL._FOR>.0> <DB.ROW.<LOCAL._FOR>.1>
    DB.EXECUTE "UPDATE register SET activ='1' WHERE login='<DB.ROW.<LOCAL._FOR>.0>' LIMIT 1"
  ENDFOR
ENDIF



RE: Registration - Llirik - 08-15-2016 09:08 AM

This is right?

[ITEMDEF i_account_register]
ID=i_guildstone

ON=@CREATE
TIMERF 1, f_account_register

[FUNCTION f_account_register]
db.query SELECT * FROM register WHERE activ="0"
if <db.row.numrows>
serv.account add <db.row.login> <db.row.pass>
db.execute UPDATE register SET activ="1" WHERE login="<db.row.login>"
serv.account update
serv.log Account created: <db.row.login>
endif
TIMERF 1, f_account_register

Or

db.query SELECT * FROM register WHERE activ="0" limit 1 // limit???
if <db.row.numrows>
serv.account add <db.row.login> <db.row.pass>
db.execute UPDATE register SET activ="1" WHERE login="<db.row.login>" limit 1 // limit???
serv.account update
serv.log Account created: <db.row.login>
endif

Thank you!


RE: Registration - Llirik - 08-15-2016 10:31 AM

db.query SELECT * FROM register WHERE activ="0"
if <db.row.numrows>
serv.account add <db.row.login> <db.row.pass>
db.execute UPDATE register SET activ="1" WHERE login="<db.row.login>" and activ="0" limit 1
serv.account update
serv.log Account created: <db.row.login>
endif

;-)