Forum Moderators: coopster

Message Too Old, No Replies

MP3 Toolbox PHP script problem

Not getting the correct URL

         

Soundfx4

5:14 am on Mar 2, 2006 (gmt 0)

10+ Year Member



This problem is probably going to be difficult to explain, and as you can probably tell by the subject and description, it is pretty much impossible to sum this up in a few words.

I downloaded a PHP script that allows me to stream music on demand via a web interface. It generates a .pls file with the path to my server and the command to start streaming a song.

The problem I'm having is that it is not sending the correct URL. When I look at winamp it says this:

[/private/index.php?cmd=stream&mp3=%2FFullmetal%20Alchemist%2FFULLMETAL%20ALCHEMIST%20COMPLETE%20BEST%20%5B320k%5D%2F07%20Rewrite.mp3&dir_id=0...]

you can see where the URL is missing, but I don't know why it's doing this. I asked on the MP3 Toolbox forums and one of the admins said this, "the pls script needs access to the HTTP_HOST environmental variable in php, so if your web-server is not passing that then mp3 toolbox will not be able to know what domain to put in the PLS file."

Now I know nothing about PHP, so I have little to no idea what he is talking about, and in turn I have no idea what to do.

This probably sounds really sloppy and doesn't describe the problem as well as it should be described, but to be honest, I don't know what else to say without someone asking me for any particular information. So if anyone can help me with the information I have provided, I would REALLY appreciate it, and if you need any particular piece of information PLEASE do not hesitate to ask me for it.

Thank you.

coopster

7:53 pm on Mar 2, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



HTTP_HOST is a $_SERVER [php.net] variable. You might try SERVER_NAME instead.

Soundfx4

2:24 am on Mar 3, 2006 (gmt 0)

10+ Year Member



I replaced HTTP_HOST in the php file to SERVER_NAME and it is working better, however, it isn't sending port 8080. My stupid ISP (Verizon) blocks 80 so I have to use 8080. I'll play around with it later, but that piece of information you gave me was really helpful, it gave me a push in the right direction, and now I have a little better idea of how it works, and what I need to search for. If you have anything else to contribute I would appreciate it!

Thanks again!

(I just realized that kind of sounds sarcastic, but I'm wasn't trying to be sarcastic at all)

oh btw, here is one of the commands in the php file if it helps at all (this is after I replaced HTTP_HOST with SERVER_NAME)

$file_stream = 'http://'.$HTTP_SERVER_VARS["SERVER_NAME"].''.$PHP_SELF.'?cmd=radio'.$authpoint;

coopster

2:45 am on Mar 3, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Newer server setups don't use the deprecated HTTP_SERVER_VARS anymore. You might also want to add a little piece of security to that PHP_SELF variable before you append your port. I believe I have this correct ...

$file_stream = 'http://'.$_SERVER['SERVER_NAME'].':8080'.strip_tags [php.net]($_SERVER['PHP_SELF']).'?cmd=radio'.$authpoint;

Soundfx4

4:11 am on Mar 3, 2006 (gmt 0)

10+ Year Member



You fricken rule! HAHA, thank you so much! I replaced the other commands with the string that you gave me, and it works on my intranet, the internet, AND as localhost.

Thank you again!

btw, what did that additional bit of security do that you put in there?

Thanks again!

coopster

11:15 pm on Mar 3, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



PHP_SELF is user-supplied data. Anything that is user-supplied cannot be trusted. I just stripped any tags out.

A bigger concern is if $PHP_SELF worked before. That means you have register_globals [php.net] turned on in your server configuration.

Soundfx4

1:03 am on Mar 4, 2006 (gmt 0)

10+ Year Member



Is that usually a big problem? If so, does that link explain everything I need to know about register_globals?

Thanks.

coopster

1:09 am on Mar 4, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It's a good start ;)