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 8 of 8
  1. #1
    New Coder
    Join Date
    Nov 2008
    Location
    In a house
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with echo please?

    I want this to show a link when the radio is online, I can not get it to work help?

    PHP Code:
    <?php


    $server 
    "{IP HERE, Took out for my reasons}"// IP address to your shoutcast server.
    $port "8010"// port of your shoutcast server
    $online "../../Images/Stats/On Air/On Air.gif"// Online Gif image
    $offline "../../Images/Stats/Off Air/Off Air.gif"// offline gif image




    // Start Data Collection
     
    $fp fsockopen("$server"$port$errno$errstr30);
          
    fputs($fp"GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)\r\n\r\n");
          while (!
    feof($fp)) {
              
    $content .= fgets($fp,128);
    }
          
    fclose($fp);
    // start data processing
          
    $debut strpos($content'<body>') + strlen('<body>');
          
    $fin strpos($content'</body>'$debut);
          
    $string substr($content$debut$fin $debut);
          
    $stats explode(','$string);

    // Start Image generation
    // Dedug Status echo "$stats[1]";
    //offline
    if ($stats[1] == "0" || !$stats) {
    header("Location: $offline");
    }

    //online
    if ($stats[1] == "1") {
    header("Location: $online");
    echo 
    '<p><a href="Http://www.google.com"> Listen Live</p></a>';
    }





    ?>

  • #2
    New Coder
    Join Date
    Nov 2008
    Location
    Melbourne, Australia
    Posts
    69
    Thanks
    8
    Thanked 1 Time in 1 Post
    PHP Code:
    echo '<p><a href="Http://www.google.com"> Listen Live</p></a>'
    try changing it to this...
    PHP Code:
    echo '<p><a href="Http://www.google.com"> Listen Live</a></p>'
    i dont know if that will do what you want...

  • #3
    New Coder
    Join Date
    Nov 2008
    Location
    In a house
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Its not showing up right,
    http://globalinterconnection.com/BSP...AOA/status.php
    Its 'on' right now, no link is showing though

  • #4
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    All you are doing is sending a .gif image to the browser. As such, it is not capable of being a link.

    Please describe in better detail what you are trying to accomplish.

  • #5
    New Coder
    Join Date
    Nov 2008
    Location
    In a house
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I want it so when it shows its online, underneath the On Air image to show a link in red that users will be able to click to listen to the radio... a pop up window (_new)
    Are you a DJ? Want to Set up a Shoutcast or Icecast Stream? Need a Voice Over? Need to Find a Stream Host? Want Help Setting up a stream? Need Some Stream Discounts? What about Stream Reviews? Want Need a DJ Panel? Need help setting one up? Need Some New Gear? Find all this plus more at: Broadcasting World

  • #6
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Then you are going to have to output your image and the link as part of an html page, not just sending the .gif image to the browser.

  • #7
    New Coder
    Join Date
    Nov 2008
    Location
    In a house
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How would I go about doing this?
    Are you a DJ? Want to Set up a Shoutcast or Icecast Stream? Need a Voice Over? Need to Find a Stream Host? Want Help Setting up a stream? Need Some Stream Discounts? What about Stream Reviews? Want Need a DJ Panel? Need help setting one up? Need Some New Gear? Find all this plus more at: Broadcasting World

  • #8
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Well, I don't know what the rest of your page looks like or where you would want it, so in general -

    The problem is your use of header(). That is what is causing the .gif to be sent to the browser instead of the html page.

    So, something along the lines of:
    PHP Code:
    if ($stats[1] == "0" || !$stats) {
    echo 
    $offline;
    }

    //online
    if ($stats[1] == "1") {
    echo 
    $online;
    echo 
    '<p><a href="http://example.com" target="_blank"> Listen Live</p></a>';

    Notes:

    1. You'll have to position this in the page where you'd like it displayed.
    2. The use of target="_blank" will accomplish the pop-up window, but it makes use of deprecated, invalid code. You would have to look into a JS solution otherwise.
    3. You'll need to correct the href= attribute to point to the correct page.


  •  

    Posting Permissions

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