help with php script

Status
Not open for further replies.

Pain

Member
Feb 20, 2016
102
17
53
Wrong thread title
Hallo , i'm very noob with php, and i try to learn it, but i need help , i try to make a line with the status of my server :
Code:
    <section class="hk_hero_section">
        <!-- tiny header starts -->
        <div class="hk_tiny_header tiny_header2">
            <div class="container">
                <div class="row">
                    <div class="col-md-12">
                        <div class="contact_email">
                            <span><i class="fa fa-clock-o"></i>24/7 Support</span><a href="tel:1234567890"><p>(123) 4567890</p></a>        |
                            <span><i class=""></i>Status do Servidor: </span><?php include("teamspeak/status.php");?>
                        </div>
                        <div class="hk_contact_lang">
                            <ul>
                                <li class="hk_login_modal">
                                    <a href="#"><span class="fa fa-lock"></span><p>Login</p></a>
                                    <div class="login_modal_wrapper">
                                        <form action="#">
                                            <div class="hk_input_wrapper">
                                                <input type="text" placeholder="Username">
                                                <span class="fa fa-user"></span>
                                            </div>
                                            <div class="hk_input_wrapper">
                                                <input type="password" placeholder="Password">
                                                <span class="fa fa-lock"></span>
                                            </div>
                                            <p>Forget Password? <a href="#">Click Here</a></p>
                                            <input class="hk_btn hk_login_btn" type="submit" value="Login Account">
                                        </form>
                                    </div>
                                </li>
                                <li class="lang">
                                    <a href="#"><span class="lng">eng</span> <span class="caret"></span></a>
                                    <ul class="hk_lang_dropdown">
                                        <li><a href="#">English</a></li>
                                        <li><a href="#">arabic</a></li>
                                        <li><a href="#">German</a></li>
                                        <li><a href="#">Spanish</a></li>
                                    </ul>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>

and i create i file : status.php

Code:
<?php
// load framework library
require_once("../libraries/TeamSpeak3/TeamSpeak3.php"); // path to teamspeak framework

// data logging
$ts3_login="serveradmin";  // Login
$ts3_password="----";  // Password
$ts3_host="----";  // Server IP adress
$ts3_queryport="10011";  // query port (default 10011)
$ts3_voiceport="9009";  // voice port (default 9987)


    try {
        //connect serverquery.
        $ts3_VirtualServer = TeamSpeak3::factory("serverquery://$serverquery_username:$serverquery_pass@$serverip:$serverquery_port/?server_port=$serverport");
      
        echo "Online </br>";
        echo "Slots: ".$ts3_VirtualServer->virtualserver_clientsonline." / ".$ts3_VirtualServer->virtualserver_maxclients;
    }
  
    catch(Exception $e){
        // grab errors and show server as offline
        echo "Offline";
    }

}

// check error

catch(Exception $e){
echo "<p class='server_error'> ERROR: </p>" , $e->getMessage(), "\n";
}
?>
---
i will a line so : Status: Online

someone know whats wrong with the code ?
 
Last edited:

LeU5er

Security Researcher
Aug 6, 2016
448
45
118
I've just looked briefly over the code and maybe this was your error :D

You have to change your variables because under your comment //data logging you defined some other variables than them which are stored in your "$ts3_VirtualServer" variable. As example you have to change "$serverquery_username" to "$ts3_login" but of course you have to do this with those all others, too.
I hope I could help you ;)
 

Pain

Member
Feb 20, 2016
102
17
53
I've just looked briefly over the code and maybe this was your error :D

You have to change your variables because under your comment //data logging you defined some other variables than them which are stored in your "$ts3_VirtualServer" variable. As example you have to change "$serverquery_username" to "$ts3_login" but of course you have to do this with those all others, too.
I hope I could help you ;)

don't work , i have now this :
Code:
<?php
// load framework library
require_once("../libraries/TeamSpeak3/TeamSpeak3.php"); // path to teamspeak framework

// data logging
    $serverquery_username = "serveradmin"; //Serverquery login username
    $serverquery_pass = ""; //Serverquery login password
    $serverip = ""; //Teamspeak 3 server IP, only IP not port
    $serverquery_port = "10011"; //Serverquery port
    $serverport = "9987"; //Teamspeak 3 server port


    try {
        //connect serverquery.
        $ts3_VirtualServer = TeamSpeak3::factory("serverquery://$serverquery_username:$serverquery_pass@$serverip:$serverquery_port/?server_port=$serverport");
      
        echo "Online </br>";
        echo "Slots: ".$ts3_VirtualServer->virtualserver_clientsonline." / ".$ts3_VirtualServer->virtualserver_maxclients;
    }
  
    catch(Exception $e){
        // grab errors and show server as offline
        echo "Offline";
    }

}

// check error

catch(Exception $e){
echo "<p class='server_error'> ERROR: </p>" , $e->getMessage(), "\n";
}
?>
 

Terror

Member
Dec 4, 2015
12
3
35
this should work

PHP:
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

// load framework library
require_once("../libraries/TeamSpeak3/TeamSpeak3.php"); // path to teamspeak framework

// data logging
$serverquery_username = "serveradmin"; //Serverquery login username
$serverquery_pass = ""; //Serverquery login password
$serverip = ""; //Teamspeak 3 server IP, only IP not port
$serverquery_port = "10011"; //Serverquery port
$serverport = "9987"; //Teamspeak 3 server port


try {
    //connect serverquery.
    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://$serverquery_username:$serverquery_pass@$serverip:$serverquery_port/?server_port=$serverport");
 
    echo "Online </br>";
    echo "Slots: ".$ts3_VirtualServer->virtualserver_clientsonline." / ".$ts3_VirtualServer->virtualserver_maxclients;
}

catch(Exception $e){
    // grab errors and show server as offline
    echo "Offline";
  
    echo "<p class='server_error'> ERROR: </p>" , $e->getMessage(), "\n";
}
 

Kieran

Tag me
Contributor
Jan 1, 2016
459
286
122
Shouldn't you do
PHP:
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://" . $serverquery_username . ":" . $serverquery_pass . "@" . $serverip . ":" . $serverquery_port . "/?server_port=" . $serverport);
?
 
Status
Not open for further replies.
Top