Jump to content
  • 0

C# -> PHP -> MYSQL or C# -> Emulator


Zell

Question


  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  411
  • Reputation:   260
  • Joined:  04/25/12
  • Last Seen:  

Hello, Is there a "easy" and safe way to make a application write in C# insert a value in DB?

 

What I thought is to send the request to a PHP and the PHP on server make the insertion. But whow?

 

Or its better send a socket/packet to emulator to make this?

Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  657
  • Reputation:   662
  • Joined:  11/12/12
  • Last Seen:  

Why not use C# to do this directly? First of, download and install the MySQL C# library : https://dev.mysql.com/downloads/connector/net/6.9.html and then add the MySql.Data reference to your project.

 

I made a basic sample you can start with (attached files to this post), it's... really straightforward :

_sql.Connect("127.0.0.1", "ragnarok", "username", "password", "3306");
_sql.Execute("SELECT `userid` FROM `login`");

For more information, you can go ahead and read this codeproject article : http://www.codeproject.com/Articles/43438/Connect-C-to-MySQL

 

If this isn't what you're looking for, please clarify xD

DemoSql.rar

Edited by Tokei
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  411
  • Reputation:   260
  • Joined:  04/25/12
  • Last Seen:  

What is it that you're trying to achieve?

 

Cause I'm programming a Launcher/Auto Patcher/Shield, and I want to insert a value on DB to players only can login if by the launcher. When player logged I will check on sql if Launcher is = 1, and when log off, Launcher became = 0.

 

http://i.imgur.com/k7WT06f.gifv

 

 

Why not use C# to do this directly? First of, download and install the MySQL C# library : https://dev.mysql.com/downloads/connector/net/6.9.html and then add the MySql.Data reference to your project.

 

I made a basic sample you can start with (attached files to this post), it's... really straightforward :

_sql.Connect("127.0.0.1", "ragnarok", "username", "password", "3306");
_sql.Execute("SELECT `userid` FROM `login`");

For more information, you can go ahead and read this codeproject article : http://www.codeproject.com/Articles/43438/Connect-C-to-MySQL

 

If this isn't what you're looking for, please clarify xD

 

I think is this, thanks Toekei, I will check for this when arrive home.

 

But I have some doubts. Its safe to put this kind of connect directy by the application?

 

And the server will give privileges to run the application execute the insert ? Because what I want is to change a value in DB that the emulator uses .

 

Example: Player login on launcher (see the gif up), The application insert in my "ragnarok" db, launcher = 1 where login and password = used on launcher.

 

I do not know if I was clear , and excuse me my English and grammar , I'm a little rusty . Thank you again.

Edited by Zell
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  657
  • Reputation:   662
  • Joined:  11/12/12
  • Last Seen:  

I think is this, thanks Toekei, I will check for this when arrive home.

 

But I have some doubts. Its safe to put this kind of connect directy by the application?

 

And the server will give privileges to run the application execute the insert ? Because what I want is to change a value in DB that the emulator uses .

 

Example: Player login on launcher (see the gif up), The application insert in my "ragnarok" db, launcher = 1 where login and password = used on launcher.

 

I do not know if I was clear , and excuse me my English and grammar , I'm a little rusty . Thank you again.

 

Ah, no, I thought this was for 'personal' use. You can't use this method in a launcher because the security risk is way too high. You have two options...

 

Create a new packet to communicate with the server

What you would have to do is create a connection with the server itself, probably read the clientinfo.xml, and then send the information you want to the server. In packets.h you would add a new packet that you can treat yourself. This is similar to what a WPE tool would do I guess.

 

Keep using SQL

You could stick with SQL... Create a new user with very limited access (only grant them the insert command). That way you could use the code above but by using that restricted account, they wouldn't be able to do anything even if they found out your connection username/password. The only abuse I can think of is that someone might end up spamming the DB with insert commands, but... this can happen with any other solution you come up with anyway.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  411
  • Reputation:   260
  • Joined:  04/25/12
  • Last Seen:  

 

I think is this, thanks Toekei, I will check for this when arrive home.

 

But I have some doubts. Its safe to put this kind of connect directy by the application?

 

And the server will give privileges to run the application execute the insert ? Because what I want is to change a value in DB that the emulator uses .

 

Example: Player login on launcher (see the gif up), The application insert in my "ragnarok" db, launcher = 1 where login and password = used on launcher.

 

I do not know if I was clear , and excuse me my English and grammar , I'm a little rusty . Thank you again.

 

Ah, no, I thought this was for 'personal' use. You can't use this method in a launcher because the security risk is way too high. You have two options...

 

Create a new packet to communicate with the server

What you would have to do is create a connection with the server itself, probably read the clientinfo.xml, and then send the information you want to the server. In packets.h you would add a new packet that you can treat yourself. This is similar to what a WPE tool would do I guess.

 

Keep using SQL

You could stick with SQL... Create a new user with very limited access (only grant them the insert command). That way you could use the code above but by using that restricted account, they wouldn't be able to do anything even if they found out your connection username/password. The only abuse I can think of is that someone might end up spamming the DB with insert commands, but... this can happen with any other solution you come up with anyway.

 

 

Hmm, the problem is that a person with high knowledge could insert cash points, or other values in DB, right? Or there is a way to give permission to note the all tables?

 

Maybe I have to pick the first solution, more "safe", I think I will take a look at Openkore bots and see the connections maked by it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...