Community Forums Today's Posts     Member List     Archive    
Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 2005
    Location
    Psychomento, Killerfornia - USA
    Posts
    3

    Simple "Online/Offline" Status Script

    Here is a small but simple script I made for those folks who just want to show that their Teamspeak server is "offline" or "online" via their webpage.

    Save the below script to a file called "ts_status.php"
    PHP Code:
    <?PHP
    $ts_ip 
    "123.45.67.89"// Change to your server's IP external or domain name
    $ts_port "51234"// Make sure this port is open on the router or firewall

    $output = @fsockopen("$ts_ip"$ts_port$errno$errstr2);
    socket_set_timeout($output000002);

    if (!
    $output) {
        echo 
    "<FONT COLOR=#DD0000><B>OFFLINE</B></FONT>";
    } else {
        echo 
    "<FONT COLOR=#00DD00><B>ONLINE</B></FONT>";
    }
    @
    fclose($output);
    ?>
    Upload the "ts_status.php" file to your FTP Domain.

    Then you need to add this line of scipt to whatever page you want the staus to show on:
    Code:
    <?PHP include("/home/www/public_html/ts_status.php"); ?>
    make sure you enter the correct path to where you place the file on your FTP domain. Upload and view the status of your Teamspeak server. Be sure to check the results by turning your server off and on.

    You can view a sample demo on this website: http://www.fbi-clan.org/portal.php

  2. #2
    Join Date
    Aug 2005
    Location
    france
    Posts
    1
    your script is exactly what i was looking for.

    so I tried it but i got an error :

    "Warning: socket_set_timeout(): supplied argument is not a valid stream resource in ...../ts_status.php on line 6"

    and the status is always shown "offline"

    do you know where it can come from please ?

    (excuse my poor english )

  3. #3
    Join Date
    Aug 2005
    Location
    UK
    Posts
    3
    Thanks man, that really helped, I thought it would be harder than that, like I would need .bat files or something.

    And to answer your question cerunsen, you need to add the TCP Query port. If your TS2 server is a local one (as in, it's part of your network) go to the TS2 Server directory and look for server.ini, in there should be the TCP Query port. Copy it and past it into the PHP file.

    I did it for mine and it works

  4. #4
    Join Date
    Oct 2004
    Location
    Germany
    Posts
    1,301
    This script above only checks if the Teamspeak Daemon is running.
    It dosn't check if your Virtual Server with maybe server port 8767 is running.

    I would use this Script from www.germeshausen.de
    PHP Code:
    <?php
    function check_ts($ip$tcp$udp$timeout=1) { //Function for the Check
    $fp = @fsockopen($ip$tcp$errno$errstr$timeout);
    if (!
    $fp) {
      
    $stat false;
    } else {
      if (
    fgets($fp) == "[TS]\r\n") {
     
    fputs($fp"SEL $udp\r\n");
     if (
    fgets($fp) == "OK\r\n") {
       
    $stat true;
     } else {
       
    $stat false;
     }
      } else {
     
    $stat false;
      }
      if (
    is_resource($fp))
     @
    fclose($fp);
      return 
    $stat;
    }
    }

    if (
    check_ts("localhost"512348767)) { //Change IP, Query-Port and TS-Port
     
    echo "<FONT COLOR=#00DD00><B>ONLINE</B></FONT>";
    } else {
     echo 
    "<FONT COLOR=#DD0000><B>OFFLINE</B></FONT>";
    }
    ?>

  5. #5
    Join Date
    May 2006
    Location
    UK
    Posts
    2
    hello!
    I am trying to setup this script, i done as its told me to, but i get all time Offline eve if the server and prots are open.
    Can any one help mne please? i really want to make this work,
    Thanks
    Antonio

  6. #6
    Bastian Guest
    As PHP is a server side application, your website hoster must have allowed outgoing connections to other servers. If this functionality is disabled or blocked by a firewall or proxy, you won't be able to run such a script.

  7. #7
    Join Date
    May 2006
    Location
    UK
    Posts
    2
    Quote Originally Posted by Bastian
    As PHP is a server side application, your website hoster must have allowed outgoing connections to other servers. If this functionality is disabled or blocked by a firewall or proxy, you won't be able to run such a script.
    How do i know if its disabled or now? in my host? will it be saying somewher ein my host panel?
    Thanks

  8. #8
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,299
    Simply remove the @-char in front of the fsockopen()-function.

  9. #9
    Join Date
    Oct 2006
    Location
    USA
    Posts
    6

    Exclamation

    Quote Originally Posted by marcelrx View Post
    This script above only checks if the Teamspeak Daemon is running.
    It dosn't check if your Virtual Server with maybe server port 8767 is running.

    I would use this Script from www.germeshausen.de
    PHP Code:
    <?php
    function check_ts($ip$tcp$udp$timeout=1) { //Function for the Check
    $fp = @fsockopen($ip$tcp$errno$errstr$timeout);
    if (!
    $fp) {
      
    $stat false;
    } else {
      if (
    fgets($fp) == "[TS]\r\n") {
     
    fputs($fp"SEL $udp\r\n");
     if (
    fgets($fp) == "OK\r\n") {
       
    $stat true;
     } else {
       
    $stat false;
     }
      } else {
     
    $stat false;
      }
      if (
    is_resource($fp))
     @
    fclose($fp);
      return 
    $stat;
    }
    }

    if (
    check_ts("localhost"512348767)) { //Change IP, Query-Port and TS-Port
     
    echo "<FONT COLOR=#00DD00><B>ONLINE</B></FONT>";
    } else {
     echo 
    "<FONT COLOR=#DD0000><B>OFFLINE</B></FONT>";
    }
    ?>
    So hey is this what I do?:



    <?php
    function check_ts($ip, $tcp, $udp, $timeout=1) { //Function for the Check
    $fp = @fsockopen($ip, $tcp, $errno, $errstr, $timeout);
    if (!$fp) {
    $stat = false;
    } else {
    if (fgets($fp) == "[TS]\r\n") {
    fputs($fp, "SEL $udp\r\n");
    if (fgets($fp) == "OK\r\n") {
    $stat = true;
    } else {
    $stat = false;
    }
    } else {
    $stat = false;
    }
    if (is_resource($fp))
    @fclose($fp);
    return $stat;
    }
    }

    if (check_ts("my ip here", 51234, 8767)) { //
    echo "<FONT COLOR=#00DD00><B>ONLINE</B></FONT>";
    } else {
    echo "<FONT COLOR=#DD0000><B>OFFLINE</B></FONT>";
    }
    ?>

  10. #10
    Join Date
    Oct 2006
    Location
    UK
    Posts
    1,029
    Quote Originally Posted by Mickey View Post
    So hey is this what I do?:



    <?php
    function check_ts($ip, $tcp, $udp, $timeout=1) { //Function for the Check
    $fp = @fsockopen($ip, $tcp, $errno, $errstr, $timeout);
    if (!$fp) {
    $stat = false;
    } else {
    if (fgets($fp) == "[TS]\r\n") {
    fputs($fp, "SEL $udp\r\n");
    if (fgets($fp) == "OK\r\n") {
    $stat = true;
    } else {
    $stat = false;
    }
    } else {
    $stat = false;
    }
    if (is_resource($fp))
    @fclose($fp);
    return $stat;
    }
    }

    if (check_ts("my ip here", 51234, 8767)) { //
    echo "<FONT COLOR=#00DD00><B>ONLINE</B></FONT>";
    } else {
    echo "<FONT COLOR=#DD0000><B>OFFLINE</B></FONT>";
    }
    ?>

    No exactly

    You need to enter your IP of your TS server in the place where it says "my ip here"

    Stick that code in a file called ts_status.php

    And then were you want it on your web server

    <?PHP include("./ts_status.php"); ?>

  11. #11
    Join Date
    Jan 2013
    Posts
    1
    I also have the similar problem ... :
    I want to sync the database from localhost to server vice versa ... any php codes, coz sometimes we have to work offline . I basically want may be a button with the name update or something which can sync both ends server and localhost both ways .... help please ...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Team Speak Tool
    By -t-Lumis in forum [TeamSpeak 2] Addons & Scripts
    Replies: 32
    Last Post: 09-09-2006, 14:41
  2. Simple asp script?
    By BikrTrash in forum [TeamSpeak 2] Addons & Scripts
    Replies: 1
    Last Post: 16-05-2005, 21:27
  3. mic not picking up anything
    By majom in forum [TeamSpeak 2] Client Support
    Replies: 1
    Last Post: 17-10-2004, 22:51
  4. Webpage status perl script
    By Hitman69 in forum [TeamSpeak 2] Addons & Scripts
    Replies: 4
    Last Post: 21-07-2004, 23:32
  5. Teamspeak 2 stats script for Perl (simple)
    By Makull in forum [TeamSpeak 2] Server Support
    Replies: 1
    Last Post: 27-08-2002, 15:21

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •