Jump to content

MySQL insert with variables?


swish

Recommended Posts

How would you go about inserting into mysql (remote server) with some the the tcadmin variables (IP, Port, ect) using the install/uninstall scripts?

 

I have tried a few things and cant seem to get it to work...

 

LFA...work your magic lol

Link to comment
Share on other sites

It's easy: you have to use $argv & $argc vars in php :)

$argc is command line arguments count and $argv is an array with values.

so if you run your script in install/uninstall like this:

{php path}\php.exe {script path}\myscript.php %serverip% %serverport%

you'll got $argv like this:

Array
(
   [0] => myscript.php
   [1] => %serverip%
   [2] => %serverport%
)

 

Of course, it's better to make something better, like:

script.php -serverip=%serverip% -serverport=%serverport%

but you'll have to handle this by hand or use a framework ;)

Link to comment
Share on other sites

Alright folks, over the past few days I have been helping swish get TCAdmin integrated with LGSL. I am happy to announce that we have done it! Here are the scripts that we wrote for it:

 

First off, in the install script for the paticular game put this:

 

 

 

start C:\iexplore.exe "http://www.yoursite.com/tcalgsl.php?ip=%serverip%&port=%serverport%"
ping google.com
taskkill -im iexplore.exe

 

The reason we are using Internet Explorer instead of PHP to run the script is because you would need to install PHP on everyone of your remote servers to run it. The reason we put a ping in there was so that it will take a while before it killed the task :D (Ghetto I know, if you know of a better way, post it.)

 

 

(Obviously you need to change C:\iexplorer.exe to the actual location )

 

 

 

And here is the php script that you will need to put on your website.

 

tcalgsl.php:

<?php


$con = mysql_connect("localhost","USER","PASS");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DATABASE", $con); 

//end connection string 

//Define the variables
$ip = $_GET['ip'];
$port = $_GET['port']; 

//START THE QUERY USING THE VARIABLES
mysql_query(”INSERT INTO `lgsl` (`id`, `status`, `ip`, `q_port`, `c_port`, `s_port`, `type`, `cache`, `cache_time`, `zone`, `disabled`) VALUES
(”, ‘0′, ‘$ip’, ‘$port’, ‘$port’, ‘0′, ‘halo’, ”, ”, ‘0′, ‘0′)”); 

mysql_close($con);
?>

 

You could take this code and change the game name and add it for every game if you wanted to.

As always, have fun!

Link to comment
Share on other sites

TO change it a bit to include the proper info here with proper query port and such here ya go

 

<?php

// make sure you only run this query from the install/uninstall scripts otherwise it will insert random info into your db 
//connect to your remote DB first...

$con = mysql_connect("localhost","USERNAME","PASSWORD");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }
mysql_select_db("DATABASE_NAME", $con); 

//end connection string

//Define the variables
$ip = $_GET['ip'];
$port = $_GET['port'];
$qport = $_GET['qport'];

//START THE QUERY USING THE VARIABLES
mysql_query("INSERT INTO `lgsl` (`id`, `status`, `ip`, `q_port`, `c_port`, `s_port`, `type`, `cache`, `cache_time`, `zone`, `disabled`) VALUES
('', '1', '$ip', '$qport', '$port', '0', 'GAMETYPE_HERE', '', '', '0', '0')");


mysql_close($con);
?>

 

start C:\iexplore.exe "http://www.yoursite.com/tcalgsl.php?ip=%serverip%&qport=%queryport%&port=%serverport%"
ping google.com
taskkill -im iexplore.exe

Link to comment
Share on other sites

The pause command won't work instead of pinging google?

start C:\iexplore.exe "http://www.yoursite.com/tcalgsl.php?ip=%serverip%&qport=%queryport%&port=%serverport%"
pause
pause
taskkill -im iexplore.exe

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use