Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Page 1 of 2 12 LastLast
Results 1 to 15 of 24

This is a discussion on So... Im trying to get this signature up in the Shared & Semi-Dedicated forum
I'm streaming audio and I want to get a signature up that displays my "currently playing" song. This is easily done with a PNG and ...

  1. #1
    JPC Addict Daiver's Avatar
    Join Date
    Jul 2005
    Posts
    191

    So... Im trying to get this signature up

    I'm streaming audio and I want to get a signature up that displays my "currently playing" song. This is easily done with a PNG and a PHP script. However, I can't get that sig to work. I get the same error every time.

    cannot be displayed, because it contains errors.

    Here's the script:

    Code:
    <?php
    // Ruff Dawg's 'Now Playing Sig w/ Background v. 1.5 May 7, 2004
    // Special thanks to the originator, DJ Rampage
    
    // This image you can call immediately from an html file in the image tag
    // (i.e. <img src="black.php">)    easy huh?
    
        Header("Content-type: image/png");
    
    /////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////*Configurables*//////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////
    
    /////////////////////*Background Picture File*////////////////////////
    
    /* Replace "sicpic.png" with your own
    picture file (must be a .png) */
    
        $im = imagecreatefrompng("banneraf.png");
    
    /////////////////////////////*Host Information*/////////////////////////////
    
        $host = "Obviously, my IP is in here"; // No 'http://' in the host
        $port = "and the port too.....";
    
    //////////////////////////////////*Text Colors*////////////////////////////////
    
    // text colors are in RGB
    
        $text_color1 = ImageColorAllocate($im,0,255,0);
        $text_color2 = ImageColorAllocate($im,0,255,0);
    
    ////////////////////////////////////*Text Size*/////////////////////////////////
    
        $text_size = "4";
    
    //////////////////////////////*Text Alignment*/////////////////////////////
    
    //X alignment
    
        $x1 = "68";
        $x2 = "60";
        $x3 = "90";
    
    //Y alignment
    
        $y1 = "0";
        $y2 = "16";
        $y3 = "33";
    
    ///////////////////////////*Offline Message*///////////////////////////////
    
        $offline1 = "We're Sorry";
        $offline2 = "We are Currently Offline";
        $offline3 = "Please Check Later";
    
    
    //////////////////////////////////////////////////////////////////////////////////////////////////
    /////*DON'T TOUCH THE CODE BELOW UNLESS//////////
    ///YOU KNOW EXACTALLY WHAT YOU ARE DOING*//
    ///////////////////////////////////////////////////////////////////////////////////////////////
    
        $fp = fsockopen("$host", $port, &$errno, &$errstr, 30);
        if(!$fp) {
            $success=2;
        }
        if($success!=2){ //if connection
            fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n");
            while(!feof($fp)) {
                $page .= fgets($fp, 1000);
            }
            fclose($fp);
            $page = ereg_replace(".*<body>", "", $page); //extract data
            $page = ereg_replace("</body>.*", ",", $page); //extract data
            $numbers = explode(",",$page);
            $currentlisteners=$numbers[0];
            $connected=$numbers[1];
            if($connected==1)
                $wordconnected="yes";
            else
                $wordconnected="no";
            $peaklisteners=$numbers[2];
            $maxlisteners=$numbers[3];
            $reportedlisteners=$numbers[4];
        }
         
        if($success!=2 && $connected==1){
             
        $song=explode(" - ",$numbers[6]);
    
            $string1= $song[0];
            $string2= $song[1];
            $string3= "$currentlisteners/$maxlisteners";
        }
    
        else {
            $string1= $offline1;
            $string2= $offline2;
            $string3= $offline3;
        }
    
        $px = (imagesx($im)-5*strlen($string1))/2;
        ImageString($im,$text_size,$x1,$y1,$string1,$text_color1);
        $px = (imagesx($im)-5*strlen($string2))/2;
        ImageString($im,$text_size,$x2,$y2,$string2,$text_color1);
        $px = (imagesx($im)-5*strlen($string3))/2;
        ImageString($im,$text_size,$x3,$y3,$string3,$text_color2);
    
        ImagePng($im);
        imagedestroy($im);
    ?>
    I just can't get it going...

  2. #2
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    This line looks jacked up to me...
    Quote Originally Posted by Daiver
    PHP Code:
        $fp fsockopen("$host"$port, &$errno, &$errstr30); 
    I'd try this...
    PHP Code:
    $fp = @fsockopen($host$port$errno$errstr30); 
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

  3. #3
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    Comment out the line that reads "Header("Content-type: image/png");" and then call the script from your browser. If you don't specify a header, PHP automatically assumes text/html and will output text. Most of the time when an image generating script doesn't work it is because PHP is throwing an error before it writes the image, corrupting it. Commenting out that line will let you see the error message(s) and help you find the problem.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  4. #4
    JPC Addict Daiver's Avatar
    Join Date
    Jul 2005
    Posts
    191
    Well, the weird thing is that this script, exactly as it is, worked just fine on another server. I'm guessing it has to do with permissions or something.

    Anyway, I'll try those things and let you know.

  5. #5
    JPC Addict Daiver's Avatar
    Join Date
    Jul 2005
    Posts
    191
    BTW, what does "commenting out the line" mean? I really don't know the first thing about PHP or Linux. Pretty much the average Windows fart over here...

  6. #6
    JPC Addict
    Join Date
    Jul 2005
    Location
    Uk
    Posts
    128
    PHP Code:
    // Is a comment
    # is a comment
    /*
    Multi Line Comment
    */

     
    $fp = @fsockopen($host$port$errno$errstr30); 

    //Notice the colour difference? 
    Comments basically tell the php parser to ignore that line or multiple lines if using the multi line comment.

  7. #7
    JPC Addict Daiver's Avatar
    Join Date
    Jul 2005
    Posts
    191
    Hi,

    Yeah, I kinda understood that commenting thing and know that some PHP files (especially the "template" kind downloaded off the Internet) have comments in them. The question is, how do I "comment out"? Should I erase the comments or that line that you suggested in post #3?

    Thanks!

  8. #8
    JPC Addict Daiver's Avatar
    Join Date
    Jul 2005
    Posts
    191
    Quote Originally Posted by Vin DSL
    This line looks jacked up to me...I'd try this...
    PHP Code:
    $fp = @fsockopen($host$port$errno$errstr30); 
    Nope, that didn't do it.

  9. #9
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    "Commenting out" is a programmers term for changing actual code into comments so that the parser/compiler will ignore those instructions. To comment out the code as I suggested, just put two slashes in front of the line, as follows:

    PHP Code:
    // This image you can call immediately from an html file in the image tag
    // (i.e. <img src="black.php">)    easy huh?

        //Header("Content-type: image/png");

    ///////////////////////////////////////////////////////////////////////////////////////// 
    That will lead PHP to belive that that line is just a comment and not an instruction, so it won't be executed. That line tells the browser to expect the data that follows to be a png image, so without it the browser will be expecting text. Once you make that change, call the script again and see if any errors appear. Once you sort out the errors and run the script without errors in it you'll see a lot of random characters on the screen. This is a text-rendering of the binary data that is your image. When you get that, remove the // from the header() line and run the script again. You should see your image.

    Another thing to check, too (especially since you sid this script worked esewhere): make sure there are no spaces or blank lines after the last line of code, which should be (and is in your example) "?>." It is possible that extra data is being sent at the end of the image that the browser does not expect and that could be the root of your problem, even if the script runs correctly and doesn't generate any error messages. Also check that you uploaded the script in ASCII (or Text) mode and not binary.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  10. #10
    JPC Addict Daiver's Avatar
    Join Date
    Jul 2005
    Posts
    191
    Those two slashes "kinda" fixed the problem. Here's what I get now:

    Fatal error: Call to undefined function: imagecreatefrompng() in /xxx/xxx/xxx/xxx/sig.php on line 19

    Here's line 19:

    $im = imagecreatefrompng("banneraf.png");

  11. #11
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    It looks like the GD library on your server is out of date and doesn't support PNG images. I'd open a support ticket and ask to have it upgraded.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  12. #12
    JPC Addict Daiver's Avatar
    Join Date
    Jul 2005
    Posts
    191
    Thanks, will do. I've recieved that answer elsewhere, but I didn't think it was the reason. Two people from different places can't be wrong.

    Thanks!

  13. #13
    JPC Addict Daiver's Avatar
    Join Date
    Jul 2005
    Posts
    191
    Good thing support works fast here! Got it working.



    Thanks for the help!

  14. #14
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    Cool. Glad you got it working. Support here is always great.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  15. #15
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    Quote Originally Posted by Awalsh
    PHP Code:
    /*
    Multi Line Comment
    */ 
    I prefer stylin' it...

    PHP Code:
    /**
     * 
     * Multi Line Comment
     *
     **/ 
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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