UTF-8 .ini (hacked highscore)

Previous topic - Next topic

Albert

Hi! Some funny coder hacked the highscore system. (maybe they reverse engineering the secret code, and made a custom script to submit scores)
And they sumbitted some kanji or whatever as name. Some player reported the game now freezes when trying to open the highscore.ini
I tested it, and for big surprise NETWEBGET() created an UTF-8 ini, containing the kanji:
...
n9=ありがとう
s9=6104
...
(I googled it and wiki says it's an ancient Japanese word, meaning: hard to be, special, rare)
So it's UTF-8, great! NETWEBGET() made a good job, but INIOPEN freezes...

I1m trying to find a workaround for this, but i'm open for ideas.

MrTAToad


Albert

#2
 :nw:This is the game:
http://www.glbasic.com/showroom.php?site=games&game=legendaryquestofsandorrozsaxmasspecial&lang=en

I solved the problem, I wrote STRIPHIGHSCORE(fromfilename$, tofilename$). Here is my code:
Code (glbasic) Select

FUNCTION STRIPHIGHSCORE: filename$, fname2$
LOCAL b=TRUE
LOCAL ok=OPENFILE(1, filename$, 1)
LOCAL ok=ok AND OPENFILE(2, fname2$, 0)
IF ok
WHILE ENDOFFILE(1)=FALSE
  LOCAL tmp%
  READUBYTE 1, tmp
  IF (tmp<32 OR tmp>127) AND (tmp<>10 AND tmp<>13) THEN tmp=ASC(" ")
  WRITEUBYTE 2, tmp
WEND
CLOSEFILE 1
CLOSEFILE 2
ENDIF
ENDFUNCTION

FUNCTION CoreHighScores: names$[], scores[], str$
LOCAL ct, i, proxy$, port
PRINT ".: WebGet scores :.", 0, 0, TRUE
SHOWSCREEN

INIOPEN "inis/xmas.ini"
proxy$ = INIGET$("server", "proxy")
port   = INIGET$("server", "port")
KILLFILE "scores.ini"
IF port=0 OR proxy$="NO_DATA"
NETWEBGET("www.glbasic.com", "/"+str$, 80, "scores.ini")
ELSE
NETWEBGET(proxy$, "http://www.glbasic.com/" + str$, port, "scores.ini")
ENDIF

STRIPHIGHSCORE("scores.ini","sc.ini")
INIOPEN "sc.ini"
ct = INIGET$("scores", "count")
DIM names$[ct]
DIM scores[ct]

FOR i=1 TO ct
DEBUG  "iniget "+i+"\n"
names$[i-1] = INIGET$("scores", "n"+i)
scores[i-1] = INIGET$("scores", "s"+i)
NEXT
ENDFUNCTION

FUNCTION WriteHighScores: names$[], scores[], username$, thescore
LOCAL ct, i, str$, proxy$, port

str$ = "highscores/listgame.php"
str$ = str$ + "?game=yourgame"
str$ = str$ + "&name="+username$
str$ = str$ + "&score="+thescore
str$ = str$ + "&secret=12345678"

CoreHighScores(names$[], scores[], str$)
ENDFUNCTION

FUNCTION ReadHighScores: names$[], scores[]
LOCAL ct, i, str$, proxy$, port

str$ = "highscores/listgame.php"
str$ = str$ + "?game=yourgame"

CoreHighScores(names$[], scores[], str$)
ENDFUNCTION

Kitty Hello

Can yout attach the ini file that freezes Iniopen? That should not be.

Albert

Ok, I attached (renamed to txt). On my machine all the Japan and China codepage and font and whatever installed, so I see in the scores.ini Japanese text, but on my other machine it's just four rectangular shape.

Hmm did you cleared the highscore list for me? Thank you!

[attachment deleted by admin]

Kitty Hello

no, I did not clear it. Uh-Oh.