User
Pass
2FA
 
 

Shocker this topic is for you :D

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Trash Bin -> Trash -> Programming / Scripting / Database
Author Message1706
deco20

[Mentally Stable]



Status: Offline
(since 17-04-2009 16:11)
Joined: 06 Mar 2009
Posts: 7, Topics: 3
Location: Iran, Islamic Republic of

Reputation: 85.4
Votes: 4

Post Posted: 12-03-2009, 22:02:05 | Translate post to: ... (Click for more languages)

Te rog ajuta-ma si pe mine sa fac gen un index.php

Code:
<html>
<head>

<title>CounterStrike Server Status</title>
     <style type="text/css">
        body {
           background-color: black;
           color: white;
           font-size: 10px;
           font-family:
        }
     </style>


</head><body>
<br><br><br><br><br>



<table border="0" class="margins" cellspacing=1 cellpadding=0 align=center>
<tr>
<td align=center>
       <table border="0" width="458">
    <tr>
         <script type="text/javascript">
</script>
      </td>
    </tr>
       </table>
 
      <table width="100%" cellspacing=1 cellpadding=0 align="center">
   <tr>
      <form method="get" action="check.php">
      <b>Server: </b> <input name="adress" type="text" value="" style="width:200px"><B><br><br>

      
   Port Server </b><input name="port" type="text" value="27015" style="width:43px"><br><br><br>
   <center>   <input type="submit" value="verifica"></center>
      </form>
   </tr>
      </table>
   </tr>
      </table>
</td>
</tr>
</table>
</body>
</html>




la urmatoarele functii:




Code:
<?php // Half-Life Game Class
class hl
{
    var $maxlen = 2048;
    var $q_info   = "\xFF\xFF\xFF\xFFTSource Engine Query\x00";
    var $q_num    = "\xFF\xFF\xFF\xFF\x57";
    var $q_rules  = "\xFF\xFF\xFF\xFF\x56";
    var $q_player = "\xFF\xFF\xFF\xFF\x55";
    var $s_info   = false;
    var $response = false;

    function microtime_float()
    {
        list($usec, $sec) = explode(" ", microtime());
 
        return ((float)$usec + (float)$sec);
    }

    function get_challenge($socket)
    { 
        socket_set_timeout($socket, 2);
   
        $time_begin = $this->microtime_float();
   
        // get challenge number from server
        fwrite($socket, $this->q_num);
        $challenge = fread($socket, $this->maxlen);
   
   $time_end  = $this->microtime_float();
   
   // response time
   $this->response = $time_end - $time_begin;
   $this->response = ($this->response * 1000);
   $this->response = (int)$this->response;
   
   $challenge = substr($challenge, 5, 4);

        return $challenge;
    }
   
    function get_info($socket)
    {
        // get server info data
   socket_set_timeout($socket, 3);
   fwrite($socket, $this->q_info);
   $this->s_info['info'] = fread($socket, $this->maxlen);
    }

    function get_rules($socket)
    {
        // get server rules data
   $challenge = $this->get_challenge($socket);
   $this->q_rules = $this->q_rules
                  . $challenge;
        socket_set_timeout($socket, 3);
   fwrite($socket, $this->q_rules);
   $this->s_info['rules'] = fread($socket, $this->maxlen);
    }

    function get_players($socket)
    {
        // get server player data
   $challenge = $this->get_challenge($socket);
   $this->q_player = $this->q_player
                  . $challenge;
   socket_set_timeout($socket, 3);
   fwrite ($socket, $this->q_player);
   $this->s_info['player'] = fread($socket, $this->maxlen);
    }

    function getstream($host, $port, $queryport)
    {   
        // get the full info data from server
        $socket = fsockopen('udp://'. $host, $port, $errno, $errstr, 30);
   
   if ($socket === false)
   {
            echo "Error: $errno - $errstr<br>\n";
        }
   else
   {
       $this->get_info($socket);
       /* at this time: rules not important
           $this->get_rules($socket);
       */
       $this->get_players($socket);
        }
        fclose($socket);
   
   if ($this->s_info['info'])
   {
       return true;
   }
   else
   {
       return false;
   }
    }

    function getvalue_byte($def)
    {
        // get value (byte) from raw data
        $tmp = $this->s_info[$def][0];
   $this->s_info[$def] = substr($this->s_info[$def], 1);

   return ord($tmp);
    }
   
    function getvalue_string($def)
    {
   
        // get value (string) from raw data
        $tmp = '';
   $index = 0;
   
   while (ord($this->s_info[$def][$index]) != 0)
   {
       $tmp .= $this->s_info[$def][$index];
       $index++;
   }
   $this->s_info[$def] = substr($this->s_info[$def], $index+1);

   return $tmp;
    }
   
    function getvalue_sint($def)
    {
        // get value (int16) from raw data
   $tmp = substr($this->s_info[$def], 0, 2);
   $this->s_info[$def] = substr($this->s_info[$def], 2);
   $array = @unpack('Sshort', $tmp);
 
        return $array['short'];            
    }

    function getvalue_lint($def)
    {
        // get value (int32) from raw data
        $tmp = substr($this->s_info[$def], 0, 4);
   $this->s_info[$def] = substr($this->s_info[$def], 4);
   $array = @unpack('Lint', $tmp);
   
   return $array['int'];
    }

    function getvalue_float($def)
    {
        // get value (float) from raw data
   $tmp = substr($this->s_info[$def], 0, 4);
   $this->s_info[$def] = substr($this->s_info[$def], 4);
   $array = @unpack('ffloat', $tmp);

   return $array['float'];
    }
       
    function getrules($phgdir)
    {
        $srv_rules['sets'] = false;
   
        // response time
   $srv_rules['response'] = $this->response . ' ms';
       
   // game setting pics
   $sets['pass'] = '<img src="' . $phgdir . 'privileges/pass.gif" alt="pw">';
       
   // set array key to info
        $def = 'info';
   
        // get the servertype (hl1 or source)
   $servertype = $this->s_info['info'][4];

   // filter the not needed code
   $this->s_info['info'] = substr($this->s_info['info'], 5);
   
   // if server running hl1 game get the following values
   if ($servertype == 'm')
   {
       $srv_rules['gameip']      = $this->getvalue_string($def);
       $srv_rules['hostname']    = $this->getvalue_string($def);
       $srv_rules['mapname']     = $this->getvalue_string($def);
       $srv_rules['gamedir']     = $this->getvalue_string($def);
       $srv_rules['gametype']    = $this->getvalue_string($def);
       $srv_rules['nowplayers']  = $this->getvalue_byte($def);
       $srv_rules['maxplayers']  = $this->getvalue_byte($def);
            $srv_rules['netver']      = $this->getvalue_byte($def);
       $srv_rules['dedicated']   = $this->getvalue_byte($def);
       $srv_rules['os']          = $this->getvalue_byte($def);
       $srv_rules['password']    = $this->getvalue_byte($def);
       $srv_rules['is_mod']      = $this->getvalue_byte($def);
            $srv_rules['url_info']    = $this->getvalue_string($def);
            $srv_rules['url_down']    = $this->getvalue_string($def);
       $srv_rules['unused']      = $this->getvalue_string($def);
       $srv_rules['mod_version'] = $this->getvalue_lint($def);
       $srv_rules['mod_size']    = $this->getvalue_lint($def);
            $srv_rules['sv_only']     = $this->getvalue_byte($def);
       $srv_rules['cus_cl']      = $this->getvalue_byte($def);
            $srv_rules['secure']      = $this->getvalue_byte($def);
            $srv_rules['bots']        = $this->getvalue_byte($def);
       
       // path to map picture
       $srv_rules['map_path'] = 'maps/hl';
        }
   
   if ($servertype == 'I')
   {
       $srv_rules['netver']     = $this->getvalue_byte($def);
       $srv_rules['hostname']   = $this->getvalue_string($def);
       $srv_rules['mapname']    = $this->getvalue_string($def);
       $srv_rules['gamedir']    = $this->getvalue_string($def);
       $srv_rules['gametype']   = $this->getvalue_string($def);
       $srv_rules['app_id']     = $this->getvalue_sint($def);
       $srv_rules['nowplayers'] = $this->getvalue_byte($def);
       $srv_rules['maxplayers'] = $this->getvalue_byte($def);
       $srv_rules['bots']       = $this->getvalue_byte($def);
       $srv_rules['dedicated']  = $this->getvalue_byte($def);
       $srv_rules['os']         = $this->getvalue_byte($def);
       $srv_rules['password']   = $this->getvalue_byte($def);
       $srv_rules['secure']     = $this->getvalue_byte($def);
       $srv_rules['version']    = $this->getvalue_string($def);

            // path to map picture
       $srv_rules['map_path'] = 'maps/hl2';
   }

   // set default map picture
   $srv_rules['map_default'] = 'default.jpg';
       
        // set gamename with gametype value (because no gametype info in hl data
   $srv_rules['gamename'] = $srv_rules['gametype'] . '<br>';
   
   // privileges pictures
   if ($srv_rules['password'] == 1)
        {
       $srv_rules['sets'] = $sets['pass'];
        }
   if ($srv_rules['sets'] === false)
   {
       $srv_rules['sets'] = '-';
   }

        // server general info
        $srv_rules['htmlinfo'] =
        '<tr><td align="left">Mapname:</td><td align="left">'
        . $srv_rules['mapname']
        . '</td></tr>' ."\n"
        . '<tr><td align="left">Players:</td><td align="left">'
        . $srv_rules['nowplayers'] . ' / ' . $srv_rules['maxplayers']
        . '</td></tr>' . "\n"
        . '<tr><td align="left">Response:</td><td align="left">'
        . $srv_rules['response']
        . '</td></tr>' . "\n"
        . '<tr><td align="left">Privileges:</td><td align="left">'
        . $srv_rules['sets']
        . '</td></tr>' . "\n";

        // server detail info
        $srv_rules['htmldetail'] =
        '<tr valign="top"><td align="left">Gamename:</td><td align="left">'
        . $srv_rules['gamename']
        . '</td></tr>' . "\n"
        . '<tr valign="top"><td align="left">Gamedir:</td><td align="left">'
        . $srv_rules['gamedir']
        . '</td></tr>' . "\n"
        . '<tr valign="top"><td align="left">Mapname:</td><td align="left">'
        . $srv_rules['mapname']
        . '</td></tr>' . "\n"
        . '<tr valign="top"><td align="left">Players:</td><td align="left">'
        . $srv_rules['nowplayers'] . ' / ' . $srv_rules['maxplayers']
        . '</td></tr>' . "\n"
        . '<tr valign="top"><td align="left">Response:</td><td align="left">'
        . $srv_rules['response']
        . '</td></tr>' . "\n"
        . '<tr valign="top"><td align="left">Privileges:</td><td align="left">'
        . $srv_rules['sets']
        . '</td></tr>' . "\n";
   
   // return all server rules
   return $srv_rules;
    }
   
    function getplayers()
    {
        $players = array();
   
        // set array key to player
   $def = 'player';

   // set html thead
   $thead = "<tr><th>Rank</th><th>Name</th><th>Frags</th><th colspan=2>Time</th></tr>";
   
        // filter the not needed code
   $this->s_info[$def] = substr($this->s_info[$def], 5);
   
   // how many player must search
   $nowplayers = $this->getvalue_byte($def);
       
   // get the data of each player
   while ($nowplayers != 0)
   {
       $index = $this->getvalue_byte($def);
       $nick  = $this->getvalue_string($def);
       $frags = $this->getvalue_lint($def);
       $time  = $this->getvalue_float($def);
      
       $minutes = floor($time / 60);
       $h       = floor($minutes / 60);
       $seconds = floor($time - ($minutes * 60));
       $minutes = $minutes - ($h * 60);
      
       $time = sprintf("%02s:%02s:%02s", $h, $minutes, $seconds);

       // scan connecting players
       if ($time == '00:00:00')
       {
           $nick =  'new connection';
      $frags = '-';
       }
      
            $players[$nowplayers] = $frags . " " . $time . " " . "\"$nick\"";
       $nowplayers--;
   }
   
   // check the connected players and sort the ranking
   if ($players)
   {
       sort($players, SORT_NUMERIC);
   }
   else
   {
       $thead .= "<tr align=center><td>--</td><td>--</td><td>--</td><td colspan=2>--</td></tr>\n";
   }

   // store the html table line to the info array
   $srv_player = $thead;

   // check how many players scanned
   $clients = count($players);
   $clients = $clients - 1;
       
   // manage the player data in the following code
   $index = 1;
   
   while ($clients != -1)
   {
       list ($cache[$index], $player[$index]) = split ('\"', $players[$clients]);
       list ($points[$index], $ping[$index]) =  split(' ', $cache[$index]);

       // strip html code from player name
       $player[$index] = htmlentities($player[$index]);

            $tdata = "<tr align=center><td>$index.</td><td>$player[$index]</td><td>$points[$index]</td><td colspan=2>$ping[$index]</td></tr>\n";
   
       $srv_player = $srv_player . $tdata;
       $clients--;
       $index++;
   }
         
   return $srv_player;
    }
}


TE ROG HELP ME - - - - [/code]

0 0
  
Back to top
View user's profile Send private message
Shocker

[Freakz owner]



Status: Offline
(since 08-02-2020 12:17)
Joined: Momentul zero
Posts: 33986, Topics: 1350
Location: localhost

Reputation: 6485.6
Votes: 829

   
Post Posted: 13-03-2009, 12:38:35 | Translate post to: ... (Click for more languages)

Cu ce sa te ajut? Ai fisierele, vezi de unde le-ai luat, explicatii ceva

FREAKZ COMMUNITY @ Facebook
WOW FREAKZ @ Facebook
0 0
  
Back to top
View user's profile Send private message
DarkK1dx
[Banned user]


Banned


Status: Offline
(since 12-04-2009 19:29)
Joined: 28 Mar 2009
Posts: 13, Topics: 1
Location: Romania

Reputation: 85.7
Votes: 5

Post Posted: 29-03-2009, 14:31:31 | Translate post to: ... (Click for more languages)

Cand te referi la un index.php, la ce iti trebuie ? - Tracker / Site / forum ?

Ca te ajut si eu cu ce pot, stiu si eu putin php.

0 0
  
Back to top
View user's profile Send private message
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Trash Bin -> Trash -> Programming / Scripting / Database  


The time now is 29-04-2024, 01:37:23
Copyright info

Based on phpBB ro/com
B

 
 
 







I forgot my password


This message appears only once, so
like us now until it's too late ! :D
x