Merhaba
<?php
function source_query($ip){
    $cut = explode(":", $ip);
    $HL2_address = $cut[0];
    $HL2_port = $cut[1];
    $HL2_command = "\377\377\377\377TSource Engine Query\0";
    $HL2_socket = fsockopen("udp://".$HL2_address, $HL2_port, $errno, $errstr,3);
    fwrite($HL2_socket, $HL2_command); 
    $JunkHead = fread($HL2_socket,4);
    $CheckStatus = socket_get_status($HL2_socket);
    if($CheckStatus["unread_bytes"] == 0)return 0;
    $do = 1;
    while($do){
        $str = fread($HL2_socket,1);
        $HL2_stats.= $str;
        $status = socket_get_status($HL2_socket);
        if($status["unread_bytes"] == 0){
               $do = 0;
        }
    }
    fclose($HL2_socket);
    $x = 0;
    while ($x <= strlen($HL2_stats)){
        $x++;
        $result.= substr($HL2_stats, $x, 1);    
    }
    // ord ( string $string );
    $result = str_split($result);
    $info['network'] = ord($result[0]);$char = 1;
    while(ord($result[$char]) != "%00"){$info['name'] .= $result[$char];$char++;}$char++;
    while(ord($result[$char]) != "%00"){$info['map'] .= $result[$char];$char++;}$char++;
    while(ord($result[$char]) != "%00"){$info['dir'] .= $result[$char];$char++;}$char++;
    while(ord($result[$char]) != "%00"){$info['description'] .= $result[$char];$char++;}$char++;
    $info['appid'] = ord($result[$char].$result[($char+1)]);$char += 2;        
    $info['players'] = ord($result[$char]);$char++;    
    $info['max'] = ord($result[$char]);$char++;    
    $info['bots'] = ord($result[$char]);$char++;    
    $info['dedicated'] = ord($result[$char]);$char++;    
    $info['os'] = chr(ord($result[$char]));$char++;    
    $info['password'] = ord($result[$char]);$char++;    
    $info['secure'] = ord($result[$char]);$char++;    
    while(ord($result[$char]) != "%00"){$info['version'] .= $result[$char];$char++;}
    return $info;
} 
{
   if( !function_exists('str_split') ){
        function str_split($string, $split_length=1){
            $array = array();
            $len = strlen($string);
            do{
                    $part = '';
                    for ($j = 0; $j < $split_length; $j++){
                    $part .= $string{$i};
                    $i++;
                }
                $array[] = $part;
            }
            while ($i < $len);
            return $array;
        }
    } 
	}
{	
	$q = source_query('212.68.42.100:27015');
echo "<b>Sunucu adi: </b>".$q['name']."<br/>";
echo "<b>Harita: </b>".$q['map']."<br/>";
echo "<b>Oyun: </b>".$q['description']."<br/>";
echo "<b>Oyuncu Sayisi: </b>".$q['players']."/".$q['max']." ";
}
?>
Böyle bi kod var elimde. Tüm kodu incelemenize gerek yok. Son bölümü yani:
{	
	$q = source_query('212.68.42.100:27015');
echo "<b>Sunucu adi: </b>".$q['name']."<br/>";
echo "<b>Harita: </b>".$q['map']."<br/>";
echo "<b>Oyun: </b>".$q['description']."<br/>";
echo "<b>Oyuncu Sayisi: </b>".$q['players']."/".$q['max']." ";
}
bölümünü 2.php diye kaydetmek. Kalan kodu da 1.php 'ye kaydetmek istiyorum. Sonra 2.php 'yi açtığımda sonucu vermesini istiyorum. Bunu nasıl yapabilirim? include ile mi? Eğer öyleyse nasıl yapabilirim?
Teşekkürler.