Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Php image creating problem

    Hello,

    im working on fixing a server banner for my server. To get the information from the server i have done, but the part to make it to a picture is making me crazy.

    So for the moment it tries to create a picture but i wont work. So i would like some help to see if i missed something in my code.
    index file
    PHP Code:
    <?php
    header
    ("Content-Type: image/png");
    putenv('GDFONTPATH=' realpath('.'));
    $font '4864';
    include 
    'function.php';

    $q source_query('188.126.64.20:27076');

    $im $imagecreate(300100) or die ("Cannot Intialize new GD image stream");
    $background_color imagecolorallocate($im255255255);
    $black imagecolorallocate($im000);
    $str1="/";
    $string=$q['players'].$str1.$q['max'];
    imagettftext($im150220$black$font"Kaptenen <3");
    imagettftext($im100240$black$font"Game: ");
    imagettftext($im1005540$black$font$q['description']);
    imagettftext($im100260$black$font"Players: ");
    imagettftext($im1005560$black$font$string);
    imagettftext($im10260$black$font"Why is the room gone :o?");
    imagepng($im);
    imagedestroy($im);

    ?>
    Function file
    PHP Code:
    <?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$x1);    
        }
        
        
    // 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;


    ?>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    You need to expand on "doesn't work". Make sure error reporting is enabled:
    PHP Code:
    ini_set('display_errors'1);
    error_reporting(E_ALL); 
    You should also determine which is failing by determining if its image creation or the socket communication that's no good.

    The one thing that jumps out immediately is this:
    PHP Code:
    $im $imagecreate(300100) or die ("Cannot Intialize new GD image stream"); 
    $imagecreate isn't declared anywhere, so unless you specify $imagecreate = 'imagecreate';, than that will throw a fatal error.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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