View Full Version : win - nix php/mysql scripts
I use mysql for my teamspeak server installed on w2k unit.
But all my php scripts I wrote to handle teamspeak data are sittin' on my Nix ( Linux fedora unit ) since I use Apachee server to publish my http://ts.erastoten.com/devs.php subdomain teamspeak page.
In other words I had to write script that will remotely connect to MySQL at windows unit form Linux unit.
At each page I put link to "look at the source code (php script)".
Such as this one:
php page: http://ts.erastoten.com/connect_it.php
source of this page: http://ts.erastoten.com/source/source_connectit.php
__________________________________________________ ____________________________
All source code you can find at http://ts.erastoten.com
__________________________________________________ ____________________________
Also there you can find several very useful tools - related to handling data through command line win/unit and terminal Nix unit.
Here is the link again:
http://ts.erastoten.com/devs.php
Have questions!? don't hesitate just ask.
zoran
Omg... well.. umh.. not like this..
if ($month==='01')$m = "Jan";if ($month==='02')$m = "Feb";if ($month==='03')$m = "Mar";
if ($month==='04')$m = "Apr";if ($month==='05')$m = "May";if ($month==='06')$m = "Jun";
if ($month==='07')$m = "Jul";if ($month==='08')$m = "Aug";if ($month==='09')$m = "Sep";
if ($month==='10')$m = "Oct";if ($month==='11')$m = "Nov";if ($month==='12')$m = "Dec";
Do it like this..
$months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
$m = $months[($month-1)];
There are also other things I wouldn't do myself, but that's not my code. Anyway, nice scripts. :)
One more thing..
$order = $_GET['ord_by'];
Have you ever heard about security? :p
Yeah I could use array ( have to admit I'm abit rusty, but I'm getin' there ... :) ) in months case, but really I do not care as long as it works and it's not that long script so I don't think it will speed up the process. To bad php doesn't suport vectors...
Security!,... hmm... what is that? Maybe you can enlighten me... :rolleyes:
You probably ment to say:
"why don't you use the strip_tags() funciton". Something like this.
$order=strip_tags($_GET['ord_by']);
Or local IP, un, and pw that aren't real... :rolleyes:
Yeah you can add users and play with my MySQL db, but hay don't make me paraphrase my self all this is just testing field... So be my guest and knock your self out.
Anyways thnks for suggestions.... anything else?
crazyandy
06-02-2007, 17:04
Hi
Does this script only work if the database is on MYSQL or would you be able to convert it so that it will read out of the server.dbs file in the teamspeak client.
This script is exactly what I have been looking for, for ages.
Thanks Andy.
## Edit ##
In case i didnt make it clear I ment the part of the script that shows the regested users and when they where last on.
Thanks Andy.
@Andy
First of all why don't you convert your db in to MySQL and save you all trouble...?
But if you want to stay with sqlite here are some directions:
Yes, you can use this script to pull out data form sqlite. Just you have to do some changes such as:
Instead of mysql_connect() MySQL function you have to use sqlite_open() sqlite function.
So instead of :
$db = mysql_connect("192.168.50.13:3306","myun","mypw");
You have to write:
$db = sqlite_open('mysqlitedb', 0666, $sqliteerror);
$result = sqlite_query($db, "SELECT i_client_id, i_client_server_id, b_client_privilege_serveradmin, s_client_name, dt_client_created, dt_client_lastonline FROM ts2_clients ORDER BY ".$order);
var_dump(sqlite_fetch_array($result));
where mysqlitedb is:
The filename of the SQLite database. If the file does not exist, SQLite will attempt to create it. PHP must have write permissions to the file if data is inserted, the database schema is modified or to create the database if it does not exist. I guess that would be "server.dbs"...
0666 is mode:
The mode of the file. Intended to be used to open the database in read-only mode. The default value for mode is 0666 and this is the recommended value.
$sqliteerror is error_message:
Passed by reference and is set to hold a descriptive error message explaining why the database could not be opened if there was an error.
so you usually write:
if ($db = sqlite_open('mysqlitedb', 0666, $sqliteerror)) {
//do you things here
}
else {
die($sqliteerror);}
sqlite_close($db);
/* Under the "// do you things here" put changes in connectiong to sqlite and sql statements I made above and rest of my original code. For further references it is best to go and check this link with all sqlite functions really good explained:
http://www.php.net/manual/en/ref.sqlite.php
Also there is another one
http://livedocs.phpdoc.info/index.php?l=en&q=function.sqlite-open
Zoran
crazyandy
07-02-2007, 16:09
Hi thanks for the help, but i have tryed to understand what you told me to do and I cant get it to work.
I think as u said 'First of all why don't you convert your db in to MySQL and save you all trouble...?' that this is a better idea.
I am now researching how to setup MYSQL.
Question???
Will this script work as it is if i get MYSQL setup?
Thanks for all your help,
Andy
For how to setup MySQL go here.
http://forum.goteamspeak.com/showthread.php?t=25224
And before I say 'yes this script will work as it is'
you have to tell me:
1. What platfrom, OS, you used to install teamspeak, win or nix?
2. Are your php scripts going to be at same unit where you have teamspeak?
3. Are your php scripts going to be at same unit where you will install MySQL?
All depends, but If you have to do some changes that will be only in function: mysql_connect(... ). Everything else can be used as is, so nothing changed.
Zoran
Why don't you use functions like strtotime() (http://php.net/manual/en/function.strtotime.php) and date() (http://php.net/manual/en/function.date.php)?
:confused:
crazyandy
08-02-2007, 20:26
Emmm not usre yet if MYSQL or Teamspeak will be at same machine, But i will be running them all on Linux, probly Fedora Core 4 or maybe core 5 or 6. Not sure weither to upgrade yet.
But any way thanks for the help and ill let you know when I have MYSQL setup and the teamspeak database on it.
PS. Ill read that link thanks.
Andy
Why don't you use functions like strtotime() (http://php.net/manual/en/function.strtotime.php) and date() (http://php.net/manual/en/function.date.php)?
:confused:
why? :cool:
Where would be all fun then? :D
There is an old chinese proverb:
Don't feed me with fish, Teach me how to catch it.
Those that know meaning of it will never ask "why didn't you".... :D, at least not explicitely...
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.