Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Idiot's Guide to PHP Auth. Needed

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server
View previous topic :: View next topic  
Author Message
Liquid_Squelch



Joined: 11 Mar 2006
Posts: 56

PostPosted: Mon Dec 17, 2007 6:26 pm    Post subject: Idiot's Guide to PHP Auth. Needed Reply with quote

Ok,
I am not a PHP programmer.
I have no idea how to do much in PHP....


I'm trying to setup my icecast server to only allow users who are currently logged into my website to open the live feed.

I think I'm ok on querying if a user is "on-line" by stealing code from other plug-in files from my site.

I understand the basics (user logs into my site, clicks link to live feed... Icecast server checks for authentication... user checks OK (or not), and is then either granted access to the feed...or redirected elsewhere).

I just need a simple script that I can work with...... from the website PHP side to pass the info back to the icecast server. (ok, user is online, so lets send the data to allow access to the feed)

And also.. which lines are critical on the icecast.xml file? Is it the listener_add / listener_remove tags?

Thanks for your help.... I'm completely lost here as a php nOOb.
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Mon Dec 17, 2007 10:47 pm    Post subject: Reply with quote

Just to be clear, php is a commonly used method for this but any language can be used as long as the POST/header information can be handled.

All that is required to authenticate a listener is a single header on the reply (default is icecast-auth-user: 1) but can be whatever you want.

listener_add is the most useful as that authenticates a new listener, listener_remove is useful for signoff handling. Check the top of auth_url.c for POST details as well as the docs.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Liquid_Squelch



Joined: 11 Mar 2006
Posts: 56

PostPosted: Fri Feb 01, 2008 10:00 pm    Post subject: Reply with quote

Karl,
Thanks for your reply... and sorry I didn't get back to you earlier, been stuck on other projects.

Since I'm not a coder, I really don't understand much..

Basically... I only need to know how to send the info back to my icecast server that says OK - He can listen..


My proposed file looks like this:

Is the user signed into the site (I can code this)

If yes then
Send info to Icecast to allow user to connect to feed (I need help w/ this one line)

If no then:
Redirect user to page that explains why he can't listen (I can code this)


So, you see, I really only need to know how to send the OK message from my website to the icecast server..



What command would be run via PHP or ANYTHING that will send the info to my Icecast server??


Thanks.. and sorry if I am a bit thick headed here...I'm really no good at writing my own.. i'm just good at taking what works, and copy/pasting so it works for me Smile

And as far as the user add and remove, I just wanted them for info blocks on my site....I can write those at a later date.
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Fri Feb 01, 2008 11:02 pm    Post subject: Reply with quote

To allow a new listener to stream you'd need to pass back the header that allows them in, so assuming the default setting, it would be

header ('icecast-auth-user: 1');

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Liquid_Squelch



Joined: 11 Mar 2006
Posts: 56

PostPosted: Sat Feb 02, 2008 7:07 am    Post subject: Reply with quote

Thanks Karl,

That did the trick Smile

I like how it defaults to http authentication if it fails url authentication.
This way, I can grant users access if they want to access the mounts via a pda or something similar....or 'power users' who I won't make visit the site.
Back to top
View user's profile Send private message
Liquid_Squelch



Joined: 11 Mar 2006
Posts: 56

PostPosted: Sun Feb 03, 2008 3:58 am    Post subject: Reply with quote

Karl,

The simple script that you helped me with works great....

Here is the code that works:

[code ] ,<? .php

HEADER ('icecast-auth-user: 1');


?>
[/code]

When I write my site authentication script around the icecast authentication script, it looks like the header info isn't read anymore...

Would you have any idea why?

Here is my script.. and the class2.php is the main coding file for my site

Code:

<?. php
require_once('path/to/class2.php');

if(!USER){
     require_once(HEADERF);
     $title = 'Oops!';
     $text = 'You have to login bla bla bla..';
     $ns->tablerender($title, $text, 'my_mod');//explain it
     require_once(FOOTERF);     
     exit;
}
header ('icecast-auth-user:1');

? >


I'm pretty sure you can't help with with the e107 info, but i thought maybe there is something that I "broke" because of the "IF" statement in there, and the header info not functioning..

If I remove the icecast-auth-user line, and replace with another redirect, and the launch the php file while logged into the site, I do get the desired redirect.....so that would tell me that the coding is correct...

but I'm not sure that icecast is seeing the headers once is in an IF statement

What do you think?
Thanks again for the help

[/code]
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Sun Feb 03, 2008 4:36 am    Post subject: Reply with quote

I have little to go on really and I'm not a php guru but the fact that an if is involved won't affect it but check what is actually sent back to icecast, use a packet sniffer or mimic the connection yourself.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber