Advertisement
Guest User

Untitled

a guest
Nov 17th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <?php
  2. //--configuration--//
  3. $db_host = 'localhost';
  4. $db_name = 'ts3script';
  5. $db_username = 'root';
  6. $db_password = 'roswell';
  7. $server_name = 'Lafumisterie';
  8. //-----------------//
  9.  
  10.  
  11. function ts3info()
  12. {
  13. global $db_host, $db_name, $db_username, $db_password, $server_name;
  14. require_once("libraries/TeamSpeak3/TeamSpeak3.php");
  15. try {
  16. $ts3_VirtualServer = TeamSpeak3::factory("serverquery://serveradmin:Zwhyso0z@91.134.173.38:10011/?server_port=9987") ;
  17. $arr_ClientList = $ts3_VirtualServer->clientList(array("client_type" => ""));
  18. $server_status = $ts3_VirtualServer->virtualserver_status;
  19. $server_actuallyusers = $ts3_VirtualServer->virtualserver_clientsonline - $ts3_VirtualServer->virtualserver_queryclientsonline;
  20. $server_maxusers= $ts3_VirtualServer->virtualserver_maxclients;
  21.  
  22. $conn = new mysqli($db_host, $db_username, $db_password, $db_name);
  23. if ($conn->connect_error) {
  24. die("Connection failed: " . $conn->connect_error);
  25. }
  26.  
  27. $sql = "DELETE FROM client";
  28. if ($conn->query($sql) === TRUE) {
  29. echo "status 0 successfully";
  30. } else {
  31. echo "Error updating record: " . $conn->error;
  32. }
  33.  
  34.  
  35.  
  36.  
  37. $sql = "UPDATE server SET servername = '$server_name', serverstatus = '$server_status', nombre_client = '$server_actuallyusers' WHERE id=1";
  38. if ($conn->query($sql) === TRUE) {
  39. echo "Record updated successfully";
  40. } else {
  41. echo "Error updating record: " . $conn->error;
  42. }
  43.  
  44. foreach($arr_ClientList as $ts3_Client)
  45. {
  46.  
  47. $conn->query("REPLACE INTO client (clientname) VALUES ('$ts3_Client')");
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. }
  59.  
  60. }
  61. catch(TeamSpeak3_Exception $e)
  62. {
  63.  
  64. echo 'status : <font color="#FF0000">offline</font><br />';
  65. }
  66. $conn->close();
  67. }
  68. while (true) {
  69.  
  70. ts3info();
  71. sleep(60);
  72. }
  73. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement