Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 744 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 4
Page 16 of 24 1 2 14 15 16 17 18 23 24
Re: MySQL dll - MD5 and SHA encryption working! [Re: Gho5tFac3K1llah] #41767
10/11/06 15:47
10/11/06 15:47
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline
Serious User
D3D  Offline
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
edit: Solved. Continue working on the demo..

Ok, I now have plain text, md5 and sha passwords working. Also I figured out how to extract data (strings) from the database, but I have a problem due to bad scripting I guess. So could anyone help me with the inkey problem in the script?

Run program -> press L -> enter username -> press ENTER -> enter password -> press ENTER (done)

The problem i'm having with the inkey thingy is when I login the first time and I enter the correct user+pass, all works no problem. However if I press L to login again it doesn't work anymore. (need to refresh inkey username+password somehow reset it) In the case I enter a wrong username and or password it should be reset too, but I have no luck with the inkey.

How do I reset the login function and inkey to be able to try login again when I enter a wrong username and or password. Or just want to login with another username? When I'm done with this I can upload a little example program for all to download and show how easy using this dll actualy is.

The script is a mess I know, but i'm still working on it and it will be cleaned afterwards removing what is not needed.

Dusty



Code:

plugindir = ".";

//--------------------------------------------------------------------
// DLL Declarations
//--------------------------------------------------------------------
dllfunction mySQL_Connectdb(w,x,y,z); // declaration of a DLL function
dllfunction mySQL_Closedb();
dllfunction mySQL_ExecQuery(string);
dllfunction mySQL_GetVal(x,y);
dllfunction mySQL_GetStr(string,x,y);
dllfunction mySQL_RowNumber();
dllfunction mySQL_IsConnected();

//--------------------------------------------------------------------
// VARIABLES
//--------------------------------------------------------------------

var video_mode = 7; // 800x600
var video_screen = 2; // window mode
var video_depth = 32; // 32bit color

var_nsave mysql_handle;

//--------------------------------------------------------------------
// STRINGS
//--------------------------------------------------------------------

string offline_text = [80]; // max 255 chars
string online_text = [80]; // max 255 chars
string login_text = [80]; // max 255 chars
string player_text = [80]; // max 255 chars
string username;
string password;
string query;

//--------------------------------------------------------------------
// FONTS
//--------------------------------------------------------------------

font standard_font = "Verdana",1,12; // Truetype font

//--------------------------------------------------------------------
// BITMAPS
//--------------------------------------------------------------------

bmap pcxLogin = <login.pcx>; // Skin for login panel

//--------------------------------------------------------------------
// PANELS
//--------------------------------------------------------------------

panel pnlLogin
{
bmap = pcxLogin;
layer = 18;
pos_x = 5;
pos_y = 420;
flags = refresh;
}

//--------------------------------------------------------------------
// TEXT
//--------------------------------------------------------------------

text txtUsername
{
layer = 30;
string = username;
pos_x = 26;
pos_y = 480;
font = standard_font;
red = 75;
green = 100;
blue = 180;
flags = visible;
}

text txtPassword
{
layer = 30;
string = password;
pos_x = 26;
pos_y = 528;
font = standard_font;
red = 75;
green = 100;
blue = 180;
flags = visible;
}

text txtOffline
{
layer = 28;
string = offline_text;
pos_x = 650;
pos_y = 40;
//flags = visible;
}

text txtOnline
{
layer = 28;
string = online_text;
pos_x = 650;
pos_y = 20;
//flags = visible;
}

text txtLogin
{
layer = 28;
string = login_text;
pos_x = 650;
pos_y = 60;
//flags = visible;
}

text txtPlayerMSG
{
layer = 28;
string = player_text;
pos_x = 15;
pos_y = 80;
//flags = visible;
}

//--------------------------------------------------------------------
// HEART OF THE GAME
//--------------------------------------------------------------------

function main()
{
screen_color.blue = 128;
// database,host,user,password
mySQL_Connectdb("gsa6db","www.mydomain.com","gsa6","xs4all");
//mySQL_Connectdb("gsa6db","localhost","gsa6","xs4all");

if(!mySQL_IsConnected()) // Connection failed
{
txtOnline.visible = off;
txtOffline.visible = on;
str_cpy(offline_text, "Connection failed");
//beep;
//exit; // Connection failed, exit to windows.
}
// Do something
while (mySQL_IsConnected()) // Connection established
{
txtOffline.visible = off;
txtOnline.visible = on;
str_cpy(online_text, "Connection established");
wait(1);
}
// mySQL_Closedb();
}

//--------------------------------------------------------------------
// FUNCTIONS
//--------------------------------------------------------------------

function refreshAuth()
{
str_cpy(username, "");
str_cpy(password, "");
}

function dbExtract()
{
//mySQL_ExecQuery("select * from Player where query='player_msg';");
//mySQL_ExecQuery("select * from Player;");
str_cpy(player_text, "Aquiring result");
sleep(1);
mySQL_GetStr(player_text,3,0); // 1,0 = username | 3,0 = welcome message
}

function userlogin()
{
// mySQL_Connectdb("gsa6db","localhost","gsa6","xs4all");
if(!mySQL_IsConnected())
{
beep;
exit; // Connection failed, exit to windows.
}

pnlLogin.visible = on; // Make the login visible with L key
inkey(username);
inkey(password);

// Plain text passwords
/*str_cat(query, "select * from Players WHERE player_nick='");
str_cat(query, username);
str_cat(query, "' AND player_pass='");
str_cat(query, password);
str_cat(query, "';");
*/

// SHA Password Encryption
/*str_cat(query, "select * from Players WHERE player_nick='");
str_cat(query, username);
str_cat(query, "' AND player_pass=SHA('");
str_cat(query, password);
str_cat(query, "');");
*/

// MD5 Password Encryption
str_cat(query, "select * from Players WHERE player_nick='");
str_cat(query, username);
str_cat(query, "' AND player_pass=MD5('");
str_cat(query, password);
str_cat(query, "');");

if(mySQL_ExecQuery(query)&&mySQL_RowNumber()==1)
{
// The query returned true, do something
txtLogin.visible = on;
str_cpy(login_text, "Login accepted");
txtPlayerMSG.visible = on;
//str_cpy(player_text, "extract from db");
str_cpy(player_text, query);
dbExtract();
}
else
{
txtLogin.visible = on;
str_cpy(login_text, "Login failed");
//exit; // No entry or failed, exit to Windows
}
// pnlLogin.visible = off; // Hide the login
// Now you can gather info from the db

//while(1)
//{
// do some more
// wait(1);
//}
//refreshAuth();
//mySQL_Closedb();
}
on_L = userlogin;



SQL
Code:
CREATE TABLE `Players` (
`player_id` int(10) unsigned NOT NULL auto_increment COMMENT 'player id',
`player_nick` varchar(16) NOT NULL default '' COMMENT 'player nick',
`player_pass` varchar(32) NOT NULL default '' COMMENT 'player password',
`player_msg` text NOT NULL COMMENT 'player message',
PRIMARY KEY (`player_id`),
KEY `player_nick` (`player_nick`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='GameStudio A6MySQL Database' AUTO_INCREMENT=2 ;



Username: demo
Password: demo
Code:
INSERT INTO `Players` VALUES (1, 'demo', 'fe01ce2a7fbac8fafaed7c982a04e229', 'Welcome to mydomain.com');






smile
Re: MySQL dll - MD5 and SHA encryption working! [Re: D3D] #41768
10/12/06 09:16
10/12/06 09:16
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
Captain_Kiyaku Offline

Dichotomic
Captain_Kiyaku  Offline

Dichotomic

Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
actually it should work if you call this:

str_cpy(username, "");
str_cpy(password, "");

well, i have a fixed string with a length of 200 so i do this at the end of my function to clear the string again:

str_cpy(strChatEntry[0], "#200");

You need to clear the string, not the inkey. theres nothing to clear. it only uses the string "username" for example. and if there is still text inside, it shoes that the next time you want to login


My Blog

"Tag und Nacht schrei ich mich heiser,
Wind weht alle Worte fort,
Tag und Nacht schrei ich mein Krähenwort!"

Subway To Sally - Krähenkönig
Re: MySQL dll - MD5 and SHA encryption working! [Re: Captain_Kiyaku] #41769
10/12/06 13:48
10/12/06 13:48
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline
Serious User
D3D  Offline
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
Yes you are right, in the begin of my script I forgot to make the strings fixed for username and password. Therefore this function doesn't work. Zeitwerk made me understand that last night and saved me from a long night with trial and error.

Code:

string username;
string password;
Function refreshAuth()
{
str_cpy(username, "");
str_cpy(password, "");
}



So now I have changed the code again to:

Code:

string username "#16";
string password "#32";
Function refreshAuth()
{
str_cpy(username, "");
str_cpy(password, "");
}



And this works perfect, but if you make it fixed at the begin of the script and afterwards empty the string with str_cpy(username, ""); does it stay fixed? I tried and it looks like that, or do I need to empty with str_cpy(username, "#16"); instead??

Dusty


smile
Re: MySQL dll - MD5 and SHA encryption working! [Re: D3D] #41770
10/12/06 20:35
10/12/06 20:35
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
Captain_Kiyaku Offline

Dichotomic
Captain_Kiyaku  Offline

Dichotomic

Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
well i defined a fix string like this:

strChat1 = str_create("#200");

and if i just do "str_cpy(strChat1, "");" i had problems with it, it cutted the length, it only worked with "str_cpy(strChat1, "#200");" so maybe you need to do that. at least only this method worked for me.


My Blog

"Tag und Nacht schrei ich mich heiser,
Wind weht alle Worte fort,
Tag und Nacht schrei ich mein Krähenwort!"

Subway To Sally - Krähenkönig
Re: MySQL dll - MD5 and SHA encryption working! [Re: Captain_Kiyaku] #41771
10/13/06 18:34
10/13/06 18:34
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
Captain_Kiyaku Offline

Dichotomic
Captain_Kiyaku  Offline

Dichotomic

Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
I have a question.
When i start my games with the mysql database (using my internal IP), everyone works fine. but when i try it over network, it somehow doesnt work, the client can't find the database on the server (or connect to it).
i even have a website running in my htdocs and people can success it from everywhere else. So that means it can connect to the database (using the same IP in the php files). But why doesn't it work with the game then? It can find the session and connects to it, but can't connect to the database :/
Do i need to change something in the config file?


My Blog

"Tag und Nacht schrei ich mich heiser,
Wind weht alle Worte fort,
Tag und Nacht schrei ich mein Krähenwort!"

Subway To Sally - Krähenkönig
Re: MySQL dll - MD5 and SHA encryption working! [Re: Captain_Kiyaku] #41772
10/13/06 21:26
10/13/06 21:26
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline
Serious User
D3D  Offline
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
Well, I can give exclusive access to a database, then try if you are able to connect from a remote location. If you can connect, again it must be a problem with the mysql server configuration, your router and or firewall. You tried this with freesql.org in the past.

Have you tried to connect to your mysql database server with a php script from another webhost at remote location? Also, is the ip address you have static or dynamic? Did you setup a (free)domain pointed to your external ip address? What does your host look like in the c-script? For privacy not show real ip here, but to sample:

-> www.myhost.com
-> 192.168.1.11 (intern ip)
-> http://192.168.1.11
-> 213.105.17.33 (extern ip)

Furthermore, your webserver has nothing to do with your mysql database server. Even though people can access your website and load your php scripts, this doesn't mean they should be able to connect to the database too.

The webserver uses port 80 (if not selected another port) and the database server run on port 3306, so even though people can connect to your webserver that doesn't say anything about the sql server. Just let the sql server and the webserver run on localhost and from the router forward the ports 80/3306 for both to the correct system. Also trough php admin you must setup a wildcard '%' in order to allow connections from remote locations.

Maybe you did something wrong during installation or configuration and now only allow access from localhost or the internal ip address of the computer running the mysql server. I made that mistake in the past thinking I setup the ip for the server, but instead I restricted access to it only from that ip address.

Dusty


smile
Re: MySQL dll - MD5 and SHA encryption working! [Re: D3D] #41773
10/14/06 00:00
10/14/06 00:00
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
Captain_Kiyaku Offline

Dichotomic
Captain_Kiyaku  Offline

Dichotomic

Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
Hi

well i didnt mean i can run my php scripts so the webserver works. i mean i connect to my database with php files, to registrate users. This website works perfect and it creates users. Even people from outside can access it. (though you have to do it like "http://123.123.123.123:3306/reg.php" cause i didnt forward port 80, shouldnt even be necessary for the mysql server)

I tried to use my internal AND external IP adress, and forwarded port 3306 and 3307.
I set the wildcard in the past allready (before it didnt work at all, of course).

i guess it might be a router problem. though i think if i connect in my network over my internal IP Adress, it should work... (like when you play in LAN and use that IP or do network connections for file transfer, etc)


My Blog

"Tag und Nacht schrei ich mich heiser,
Wind weht alle Worte fort,
Tag und Nacht schrei ich mein Krähenwort!"

Subway To Sally - Krähenkönig
Re: MySQL dll - MD5 and SHA encryption working! [Re: Captain_Kiyaku] #41774
10/14/06 02:29
10/14/06 02:29
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline
Senior Expert
PHeMoX  Offline
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
Quote:

and if i just do "str_cpy(strChat1, "");" i had problems with it, it cutted the length, it only worked with "str_cpy(strChat1, "#200");" so maybe you need to do that. at least only this method worked for me.




I think Code:
str_cpy(strChat1,"     ");

should work ... Wasn't there this rule that you need to define the amount of characters when using str_cpy?

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: MySQL dll - MD5 and SHA encryption working! [Re: D3D] #41775
10/14/06 05:48
10/14/06 05:48
Joined: Oct 2003
Posts: 206
N
nkl Offline
Member
nkl  Offline
Member
N

Joined: Oct 2003
Posts: 206
Hi!
It is a cool login code.
But people can see what password you typed.
In many login systems, the dialog box use password masking so any people can't see what password you typed.
How do I displaying the password character as an asterisk '*' instead of the characters that users type?
for example


Thanks for any advice on this problem
Thanks already.

Re: MySQL dll - MD5 and SHA encryption working! [Re: nkl] #41776
10/14/06 12:15
10/14/06 12:15
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline
Serious User
D3D  Offline
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
@ nkl:

For fast and easy fix, i'll suggest downloading the free font generator made by a user on this forum. Then replace the standard font for the password with a font file that has only * inside. There must be a way to do this with c-script too. However, i'm lazy and have used a font-file. Also I have changed the code I found here and post a little working sample for this dll soon.

Only want to ask Michael_Schwarz if he can tell me the secret about password in dll Although this login sth is very nice it's also a security risk, as anyone could intercept the master password for the database and insert his own highscore to cheat for instance. You don't want that

Was thinking about using the gshttp plugin I heard about on the forum and use that to make the first connection to a php file on my website and afterwards connect to the database with the mysql-dll to make things a little more difficult perhaps with encryption.

Code:

font standard_font = "Verdana",1,12; // Truetype font
font password_font = <pwfnt.tga>,12,10; // Astrix font

text txtUsername
{
layer = 30;
string = username;
pos_x = 27;
pos_y = 360;
font = standard_font;
red = 75;
green = 100;
blue = 180;
flags = visible;
}

text txtPassword
{
layer = 30;
string = password;
pos_x = 24;
pos_y = 409;
font = password_font;
}



@ PHeMoX:

Sometimes my strings must be always the same size (fixed), So at the top of my script I use(for example), string hello "#6"; and deeper in the script I would use str_cpy(hello,"#6"); to clear and make available for input again.

Dusty


smile
Page 16 of 24 1 2 14 15 16 17 18 23 24

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1