php Authentication script?
Hi,
I used to run stream via icecast streaming server which had php authentication capabilities.
My question is, is it possible to do the same with FMS? Put this sort of code in main.asc to verify a viewers credential before allowing him to watch. At the moment the domain/swf restrictions work well but this could add a little more security into the mix?
Something like this to determine whether a user has an active subscription to watch a certain video
<?php
function MySQLConnect( )
{
$db_host="localhost";
$db_username="xyz";
$db_password="xyz";
$db_name="xyz";
$connection= mysql_connect( $db_host, $db_username, $db_password );
if (!$connection)
{ return "FAILED"; }
mysql_select_db( $db_name, $connection ) or die ("FAILED");
return $connection;
}
function basic_icecast_check_user_allowed ( $username , $password )
{
$allow_user_auth_query = "
select
xyz_members.login,
xyz_members.pass
from
xyzr_members,xyz_payments
where
xyz_payments.member_id=xyz_members.member_id and
xyz_members.status=1 and
xyz_payments.expire_date>NOW() and
xyz_members.login='$username' and
xyz_members.pass='$password'
limit 1 "
$find_allowed = mysql_query ( $allow_user_auth_query );
$auth_stream_count = mysql_num_rows ( $find_allowed );
if ( $auth_stream_count==0 )
{ return array(0,"User Invalid",0); }
$test_allowed = mysql_fetch_assoc( $find_allowed );
if ( $auth_stream_count==1 )
{
return array(1,"Found",0 );
}
return array(0,"Password Invalid",0);
}
?>
