Results 1 to 4 of 4

Thread: Final script: *status-server*

  1. #1
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts

    Final script: *status-server*

    The final script is server status ("independent")
    I'll leave it here, can someone come in handy
    =================================
    PHP Code:
    <?php
    //для потомков: by Damage 2015(C)!
    {
    $xuivrot="";
    $server_ip '12.13.14.15'//ipserver 
    $server_port '28960'//portserver
    $rcon_password 'SuperRconPassword123abc';
    function 
    currentplayers($infaoservere2)
    {
    $backinfo='';
    preg_match_all('/(\d+) (\d+) "([^"]+)"/'$infaoservere2$players3);
    $backinfo=sizeof($players3[3]); 
    return 
    $backinfo;
    }
    function 
    utochinfo($samainfaoservere)
    {
        if(
    $samainfaoservere=='zom')
        {
         
    $vozvratka='Zombies/Zom-mod'
         return 
    $vozvratka//поднимаем в прошлую функцию
         
    sleep(0.1);
        }
        else if(
    $samainfaoservere=='tdm')
        {  
    $vozvratka='Team DeathMatch'sleep(0.1); return $vozvratka; }
        else if(
    $samainfaoservere=='dm')
        {  
    $vozvratka='Deathmatch'sleep(0.1); return $vozvratka; }
         else if(
    $samainfaoservere=='sd')
        {  
    $vozvratka='Search and Destroy'sleep(0.1); return $vozvratka; }
        else if(
    $samainfaoservere=='mp_toujane')
        {  
    $vozvratka='Toujane, Tunissia'sleep(0.1); return $vozvratka; }
        else if(
    $samainfaoservere=='mp_carentan')
        {  
    $vozvratka='Carentan, France'sleep(0.1); return $vozvratka; }
        else if(
    $samainfaoservere=='mp_burgundy')
        {  
    $vozvratka='Bugundy'sleep(0.1); return $vozvratka; }
         else { return 
    $samainfaoservere; }
    }
    function 
    lookinfo($InfoOservere
    {
    $linesinfo explode('\\'$InfoOservere);
    {
    for(
    $i=1;$i<count($linesinfo);$i+=1)
    {
    usleep(10000);
    if(
    $linesinfo[$i] == 'g_gametype') {  echo "<div style=\"color:red;\"><br>Game type: " utochinfo($linesinfo[$i+1]); usleep(10000); } //режим игры
    if($linesinfo[$i] == 'mapname') {  echo "<div style=\"color:green;\"><br>Server map: " utochinfo($linesinfo[$i+1]); usleep(10000); }  //карта 
    if($linesinfo[$i] == 'sv_hostname') {  echo "<div style=\"color:blue;\"><br>Server name: " utochinfo($linesinfo[$i+1]); usleep(10000); } //название сервера
    if($linesinfo[$i] == 'sv_maxclients') {  echo "<div style=\"color:orange;\"><br>Max clients: " utochinfo($linesinfo[$i+1]) . " Client(s)"usleep(10000); } //макс. слотов
    if($linesinfo[$i] == 'mod') {  echo "<div style=\"color:purple;\"><br>Current players: " .     currentplayers($InfoOservere)  . " Client(s)"usleep(10000); }
    }
    }
    }
    $errno $errstr null;
    $server_info "udp://" $server_ip;
    $sendpacket "\xff\xff\xff\xffgetstatus"// \xff\xff\xff\xffrcon thyPassword status  // \xff\xff\xff\xffgetstatus
    @$connectpacket fsockopen($server_info$server_port$errno$errstr$timeout);
    if(!
    $connectpacket

    die(
    'Нету подключения к серверу/Или сервер несуществует!'); 
    }
    socket_set_timeout ($connectpacket10);
    {
    fwrite ($connectpacket$sendpacket); //диалог с мастер-сервером.
    $infoserver '';
    while (
    $status1 fread ($connectpacket10000)) //постоянное автообновление, и чек полученый инфы.
    {
        
    $infoserver .= $status1;
        if(
    $infoserver!='яяяяdisconnect' && $infoserver!='яяяяneedcdkey' && $infoserver!='яяяяprint Invalid password.')
        {
        
    //echo $infoserver; //-= FULL INFO
            
    lookinfo($infoserver); //==--INFO FILTERS--==
        
    }
        else if(
    $infoserver=='яяяяdisconnect') { echo "Сервер не отвечает на запросы!"; } if($infoserver=='яяяяneedcdkey') { echo "Ключ диска не введен!"; } if($infoserver=='яяяяprint Invalid password.') { echo "Неверный пароль"; }
        
    //lookinfo($infoserver);
        
    }
    }
    fclose ($connectpacket);   //
    }

    ?>
    Many superfluous, who prevents clean, can refine the pattern!
    FILE.php == https://dropmefiles.com/DtWVz == FILE.phpClick image for larger version. 

Name:	ServerStatusScript.jpg 
Views:	79 
Size:	73.4 KB 
ID:	907
    Last edited by maxdamage99; 2nd August 2015 at 09:05.

  2. The Following User Says Thank You to maxdamage99 For This Useful Post:

    kung foo man (2nd August 2015)

  3. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,725
    Thanks
    17
    Thanked 1,080 Times in 682 Posts
    Why do you first have a variable for your rcon pass:
    Code:
    $rcon_password = 'SuperRconPassword123abc';
    and then just hardcode it in your query:
    Code:
    $sendpacket = "\xff\xff\xff\xffgetstatus"; // \xff\xff\xff\xffrcon thyPassword status  // \xff\xff\xff\xffgetstatus
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  4. The Following User Says Thank You to IzNoGoD For This Useful Post:

    Kemi (2nd December 2015)

  5. #3
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,014
    Thanks
    2,110
    Thanked 1,086 Times in 753 Posts
    When sharing scripts, they should use a common language, and in an international forum it's obviously English. ^^
    timescale 0.01

  6. The Following User Says Thank You to kung foo man For This Useful Post:

    Kemi (2nd December 2015)

  7. #4
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    The script is "dirty", sorry
    P.S: This is my first full-length script to PHP.

Posting Permissions

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