Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-06-2008, 02:08 AM   PM User | #1
NickolasM.
New Coder

 
Join Date: Nov 2008
Location: In a house
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
NickolasM. is an unknown quantity at this point
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>';
}





?>
NickolasM. is offline   Reply With Quote
Old 12-06-2008, 02:51 AM   PM User | #2
kryssy23
New Coder

 
Join Date: Nov 2008
Location: Melbourne, Australia
Posts: 69
Thanks: 8
Thanked 1 Time in 1 Post
kryssy23 is an unknown quantity at this point
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...
kryssy23 is offline   Reply With Quote
Old 12-06-2008, 02:59 AM   PM User | #3
NickolasM.
New Coder

 
Join Date: Nov 2008
Location: In a house
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
NickolasM. is an unknown quantity at this point
Its not showing up right,
http://globalinterconnection.com/BSP...AOA/status.php
Its 'on' right now, no link is showing though
NickolasM. is offline   Reply With Quote
Old 12-06-2008, 03:33 AM   PM User | #4
PappaJohn
Senior Coder

 
Join Date: Apr 2007
Location: Quakertown PA USA
Posts: 1,028
Thanks: 1
Thanked 125 Times in 123 Posts
PappaJohn will become famous soon enough
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.
PappaJohn is offline   Reply With Quote
Old 12-06-2008, 07:26 PM   PM User | #5
NickolasM.
New Coder

 
Join Date: Nov 2008
Location: In a house
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
NickolasM. is an unknown quantity at this point
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
NickolasM. is offline   Reply With Quote
Old 12-06-2008, 08:01 PM   PM User | #6
PappaJohn
Senior Coder

 
Join Date: Apr 2007
Location: Quakertown PA USA
Posts: 1,028
Thanks: 1
Thanked 125 Times in 123 Posts
PappaJohn will become famous soon enough
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.
PappaJohn is offline   Reply With Quote
Old 12-06-2008, 08:02 PM   PM User | #7
NickolasM.
New Coder

 
Join Date: Nov 2008
Location: In a house
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
NickolasM. is an unknown quantity at this point
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
NickolasM. is offline   Reply With Quote
Old 12-06-2008, 09:50 PM   PM User | #8
PappaJohn
Senior Coder

 
Join Date: Apr 2007
Location: Quakertown PA USA
Posts: 1,028
Thanks: 1
Thanked 125 Times in 123 Posts
PappaJohn will become famous soon enough
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.
PappaJohn is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:15 AM.


Advertisement
Log in to turn off these ads.