Go Back   Winamp & Shoutcast Forums > Shoutcast > Shoutcast Discussions

Reply
Thread Tools Search this Thread Display Modes
Old 14th August 2008, 12:25   #1
knightrider2218
Junior Member
 
Join Date: Aug 2008
Posts: 9
Looking For A Kick Source Script For My Internet Station With A Specific Requirement

Hi There!
I am looking for the code for a working kick source script to kick the playing stream off the air so the dj can connect. The one specific requirement about this script that I have is that I only want the auto dj stream to be kicked. I don't want people to be able to kick a live dj off the air.
Any help would be appreciated.
From KN
knightrider2218 is offline   Reply With Quote
Old 14th August 2008, 17:42   #2
Jkey
Forum King
 
Join Date: Jul 2004
Location: E*arth
Posts: 3,031
if you know a bit of php its simple because
you just need to use,
http://yourServer:8000/admin.cgi?pas...d&mode=kicksrc

So Long, and Thanks for All the Fish.
Jkey is offline   Reply With Quote
Old 14th August 2008, 17:53   #3
Jkey
Forum King
 
Join Date: Jul 2004
Location: E*arth
Posts: 3,031
here is a cut down version of the required code
it may contain errors as im in a rush so if users
wish to correct me then do so.


<?php
/****************************************/

$scip = "localhost";
$scport = "8000";
$scpass = "AdminPassword";


/****************************************/


$scCon = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
if(!$scCon) {
$scsuccess=1;
}
if($scsuccess!=1){
fputs($scCon,"GET /admin.cgi?pass=$scpass&mode=kicksrc HTTP/1.0\r\nUser-Agent: Shoutcast Source Kicker (Mozilla Compatible)\r\n\r\n");
}
exit;


?>

So Long, and Thanks for All the Fish.
Jkey is offline   Reply With Quote
Old 22nd August 2008, 19:16   #4
BELLonline
Senior Member
 
Join Date: Sep 2006
Posts: 254
What I do is with the AutoDJ stream I set the 'Stream IRC' setting to [playlist] (it can be anything), as no one uses the IRC setting anyway. Then it is easy enough to write a PHP script that checks that the IRC setting says [playlist] and then kicks it.

If IRC is blank or anything other than [playlist] then the script exits and the page refreshes after 5 seconds.

You don't have to use the IRC setting, it can be done with any of them but I chose that one because it's the least used.

I know it's a bit of a bodge, but it works!
BELLonline is offline   Reply With Quote
Old 23rd August 2008, 00:46   #5
Chybeck
Junior Member
 
Chybeck's Avatar
 
Join Date: Aug 2008
Location: Marseille (FRANCE)
Posts: 9
I made it for u in PHP CLI.
Usage: nano kicksource.sh , paste it, chmod +x kicksource.sh , and ./kicksource.sh .
U can also do it as kicksource.php ; then remove the first line and replace chr(10) by '<br>'.

PHP Code:
#!/usr/bin/php
<?php
/*
kicksource.sh
[usage ./kicksource.sh]
*/
set_time_limit(120); // DJ has 2 minutes to connect.

$scip "127.0.0.1";           
$scport 8000;                    
$scpass "moo";          

for (
$i 0$i <= 24$i++) // 24*5 = 120secondes max
{
$buffer '';
$handle = @fsockopen($scip$scport, &$errno, &$errstr2);
fputs($handle,"GET /admin.cgi?pass=".$scpass." HTTP/1.0\r\nUser-Agent: Shoutcast Source Kicker (Mozilla Compatible)\r\n\r\n");
if (
$handle
{
    while (!
feof($handle)) {
        
$buffer .= fgets($handle4096);
    }
    if (
ereg('<b>127.0.0.1</b>' $buffer))
    {
        
$handle2 = @fsockopen($scip$scport, &$errno, &$errstr2);
        
fputs($handle2,"GET /admin.cgi?pass=".$scpass."&mode=kicksrc HTTP/1.0\r\nUser-Agent: Shoutcast Source Kicker (Mozilla Compatible)\r\n\r\n");
        echo 
date("H:i:s").' : Localhost has been kicked. Waiting for source...'.chr(10);
    }
    elseif (
ereg ('<b>([[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3})</b>'$buffer$regs))
        exit(
date("H:i:s").' : DJ '.$regs[1].' connected ! . Stopping Script.'.chr(10));
    elseif (
ereg('Server is currently down'$buffer))
        echo 
date("H:i:s").' : Waiting for source...'.chr(10);
    else
        exit(
date("H:i:s").' : Error: Unable to connect to stream.'.chr(10));
    
fclose($handle);
}
else
    exit(
date("H:i:s").' : Error: Unable to connect to stream.'.chr(10));
    
flush();
sleep(5);
}
echo 
date("H:i:s").' : Time Limit of 2mn . Script Aborted.'.chr(10);
?>
But it's gonna be useless with sc_trans 2.0 witch is coming !
Chybeck is offline   Reply With Quote
Old 23rd August 2008, 10:14   #6
knightrider2218
Junior Member
 
Join Date: Aug 2008
Posts: 9
I just have one question about something you wrote regarding the tool you used to create this thing:
[B]I made it for u in PHP CLI.
Usage: nano kicksource.sh , paste it, chmod +x kicksource.sh , and ./kicksource.sh .
U can also do it as kicksource.php ; then remove the first line and replace chr(10) by '<br>'.

[PHP]
#!/usr/bin/php
<?php
/*
kicksource.sh
[usage ./kicksource.sh]
Those kicksource.sh things..Do I need some sort of a tool or can I just create a kicksource.php, put all that code in, and I'll be ready to go?
Thanks so much, this means a lot.
From KN
knightrider2218 is offline   Reply With Quote
Old 23rd August 2008, 14:47   #7
Chybeck
Junior Member
 
Chybeck's Avatar
 
Join Date: Aug 2008
Location: Marseille (FRANCE)
Posts: 9
Yes u can.

PHP Code:
<?php
/*
kicksource.php
[Usage www.moo.com/kicksource.php]
*/
set_time_limit(120); // DJ has 2 minutes to connect.

$scip "127.0.0.1";           
$scport 8000;                    
$scpass "moo";          

for (
$i 0$i <= 24$i++) // 24*5 = 120secondes max
{
$buffer '';
$handle = @fsockopen($scip$scport, &$errno, &$errstr2);
fputs($handle,"GET /admin.cgi?pass=".$scpass." HTTP/1.0\r\nUser-Agent: Shoutcast Source Kicker (Mozilla Compatible)\r\n\r\n");
if (
$handle)
{
    while (!
feof($handle)) {
        
$buffer .= fgets($handle4096);
    }
    if (
ereg('<b>127.0.0.1</b>' $buffer))
    {
        
$handle2 = @fsockopen($scip$scport, &$errno, &$errstr2);
        
fputs($handle2,"GET /admin.cgi?pass=".$scpass."&mode=kicksrc HTTP/1.0\r\nUser-Agent: Shoutcast Source Kicker (Mozilla Compatible)\r\n\r\n");
        echo 
date("H:i:s").' : Localhost has been kicked. Waiting for source...<br />';
    }
    elseif (
ereg ('<b>([[:digit:]]{1,3}.[[:digit:]]{1,3}.[[:digit:]]{1,3}.[[:digit:]]{1,3})</b>'$buffer$regs))
        exit(
date("H:i:s").' : DJ '.$regs[1].' connected ! . Stopping Script.<br />');
    elseif (
ereg('Server is currently down'$buffer))
        echo 
date("H:i:s").' : Waiting for source...<br />';
    else
        exit(
date("H:i:s").' : Error: Unable to connect to stream.<br />');
    
fclose($handle);
}
else
    exit(
date("H:i:s").' : Error: Unable to connect to stream.<br />');
    
flush();
sleep(5);
}
echo 
date("H:i:s").' : Time Limit of 2mn . Script Aborted.<br />';
?>
If you want to use kicksource.sh , apt-get install php-cli .
Chybeck is offline   Reply With Quote
Old 21st October 2008, 15:41   #8
ReloadRadio.net
Junior Member
 
Join Date: Oct 2008
Location: London
Posts: 1
this doesnt work for some reason...

ERROR i get...

Warning: fputs(): supplied argument is not a valid stream resource in /home/MYSITE/public_html/kicksource.php on line 16
09:41:00 : Error: Unable to connect to stream.
ReloadRadio.net is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Shoutcast > Shoutcast Discussions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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