gnet and php


Tweet
(Posted 10 months ago) cpsmith0191

I've managed to get Blitmax working with Mark Sibleys PHP code on my local sever and am almost ready to pop a gnet lobby onto my website.
The only way I can grant access to the lobby (table : gnet_servers) is by including in Mark Sibleys PHP file the following:
$conn = @mysql_connect("myserver.local",$guest,$guest);
$db = mysql_select_db("gnet", $conn);
'guest ' being a user I have granted ( delete, insert, select, update ) rights to in the gnet database table, gnet.servers, using mysql admin.
Is there another way of doing this ? as Mark Sibleys code hasn't included this.
I know its a bit of a niche area but gnet works a treat and the more lobbies the better.
A second question concerns the removal of a game after 300 seconds on the Lobby.
Marks PHP file does this but only to the local readout, the record remains in the DB table.
Have other used the MYSQL EVENT, to trigger the removal of the record from the database?
Thanks for any input, Have fun cps.

(Posted 10 months ago) RonTek commented:

Hey,welcome back cpsmith! I have posted the gnet masterserver code that the site is currently using: https://www.blitzcoder.org/forum/topic.php?id=426 let me know if you find this working.

(Posted 10 months ago) cpsmith0191 commented:

Many thanks, I've come at this via Html forms posting getting to php scripts that store variables, then using blitz (post, get) in place of forms and then onto putting the vars into a database.
I've obviously still got some learning to do on sql. I'll digest your masterserver code then apply it, hopefully learning on the way.
Thanks again for the pointers, have fun cps.

(Posted 10 months ago) RonTek commented:

sure thing! it should be a simple typical php + mysql setup, let me know if you ran into some issues.

(Posted 10 months ago) cpsmith0191 commented:

Have tried your mysql script by using mysql (etc) < 'your script' and it sets up the database and table as it should. (Thanks, I can now write a script to set up a database saving time when seting up a new datbase. Didn't know such a thing was possible.) It replaces the manual creation of the database and table inside the msql admin program.
However I still have the same problem in that I have to include $conn = @mysql_connect("myserver.local",$guest,$guest); $db = mysql_select_db("gnet", $conn);
lines inside the gnet.php file for either a read or write operation into the table gnet_servers.
I have also tried it with 'any user' and 'no pasword' which works as well but only if I include the required lines in gnet.php.
From this I assume that I have to do something to my database.
From my short exposure to mysql I have always had to open a database/table by initially supplying the server name, user name and password before inserting or extracting data.
Is it possible that for gnet.php to work I have to have my database open ie not close it at the end of each set of queries. (I'm doing that on web page that displays the data in the table gnet_servers.)
I'm of to try that now, IE I've just thought of this whilst typing. Thanks for your input, have fun cps.

(Posted 10 months ago) cpsmith0191 commented:

Just downloaded another version of what looks like Mark Sibleys gnet.php code which includes some lines before the Ping function. These lines include the mysql connect function.
Incidently this php code has a working ping function. Other than this its the same code. I wonder if someone had the same problem or maybe my version of gnet.php has the top few lines missing ?
Anyway now onto getting mysql to automatically delete after 300 seconds. Have fun cps.

(Posted 10 months ago) RonTek commented:

However I still have the same problem in that I have to include $conn = @mysql_connect("myserver.local",$guest,$guest); $db = mysql_select_db("gnet", $conn); lines inside the gnet.php file for

The gnet.php download is already complete and setup with that statement around line 24. This is the exact copy that the gnet section is using and you just fill in with your database details.

I am not sure why you have to enter it again and it also has the ping command. still not working for you?

(Posted 9 months ago) cpsmith0191 commented:

Line 24 in my original gnet.php is at the start of the add_server function, line 24 in my new coipy of gnet.php is the mysql-connet line. I think I some how got an incomplete gnet.php file.
The ping function looks the same in both but I get a return of a line feed (html) from the first gnet.php and a IP addr from the new copy of gnet.php so there must be a difference in the processing part of gnet.php. As the new copy works and has the expected (or expected by me) inclusion of the mysql_connect lines I'll go with that, just hope that the permisions I've given the guest user don't leave my database open to abuse. The one change I've made is to include mysql_close($conn) after the switch routines and before the exit. (old school maybe) Thanks again for your input I am off to get the automatic removal of a server after 300 seconds working. Have fun cps. PS The ping on your website works fine as does everything else.

(Posted 9 months ago) RonTek commented:

that's great! It should give you the same results as there are no special extensions needed.

Again for setting up the database, it's just the typical procedure and there's an import or run sql query function that you can just paste the above sql code via PHPMyAdmin (installed on every php hosting even free ones)

GNet Import Blitz3D BlitzMax PHP MySQL Run SQL Query

(Posted 9 months ago) cpsmith0191 commented:

Ah nice one, another thing I've learned. I Was wondering how to run a script on my web based server. Have run into one problem with my web host (infinityfree), it only allows one user name for my database and I don't want to put my user name and password into a gnet.php file (can't create a guest user with limited rights). I can make gnet.php executable only, but I'm not sure that will prevent my access codes leaking. I'm going to hunt around for a web host that allows me to create a guest user on my database. Everthing seems to be working on my localhost version so hopefully I'll be able to post my gnet lobby soon. Many thanks, have fun cps.

(Posted 9 months ago) RonTek commented:

Sure thing, I hope this finally solves your GNet Master server dilemma.

it only allows one user name for my database and I don't want to put my user name and password into a gnet.php file (can't create a guest user with limited rights). I'm going to hunt around for a web host that allows me to create a guest user on my database.

I have not seen any free host that will allow guest access and it is not a common setup. Also, since nobody cannot see the php script as it is server side, it is just normal to put your access details in there. Even though your access details got exposed nobody can execute it as well unless you turn on Remote MySQL Access in CPanel.

(Posted 9 months ago) cpsmith0191 commented:

Thanks for the info. I've already set up a second web site with freeoda.com which I'll use for the gnet lobby, that way if I do drop a clanger my original website will be safe.
I have tried my copy of Htracker (web site copier) and that didn't find the executable files on my site (also remote access is off), so I think you are right. Happy coding, have fun cps.

(Posted 9 months ago) RonTek commented:

That's awesome. I might have heard of that free hosting before, looks nice except they will put ads once your site becomes popular.

How long you have tried this hosting? are you also getting their paid plan? what's the performance?

Reply To Topic (minimum 10 characters)

Please log in to reply