Go Back   Winamp Forums > SHOUTcast > SHOUTcast Discussions

 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 17th April 2006, 11:32   #1
aintschy
Junior Member
 
Join Date: Apr 2006
Posts: 1
"Kick Source" script

Hi folks,
i've coded a tiny script for sb. to kick the source of (unlimited) SHOUTcast servers. this is useful if you've got several djs streaming via the same server. perhaps some shoutcast users may profit from this script, too.

features:
- password protection
- xtra password protection to kick source
- view status of selected server
- kick source easily
- unlimited servers supported

requires:
- php 4/5

tested with:
- php 5 (xampp localhost)

configuration:
- type in var. values for user/pw
- enter servers and paramters in arrays

PHP Code:
<?php

// COPYRIGHT 2006 by aintschie (stationscript@gmx.net)

// SET ALL CONFIG VALUES

$login_user        "user";
$login_password        "1234";
$kick_password         "kickit";
$timeout        5;            // SECONDS TO WAIT FOR CONNECTION


$shoutcast_ip        = array("127.0.0.1",    "127.0.0.2");
$shoutcast_name        = array("Stream #1",    "Stream #2");    
$shoutcast_port        = array("8000",        "8000");
$shoutcast_password    = array("pw1",    "pw2");

if(
$_SERVER***91;'PHP_AUTH_USER'***93; != "$login_user" || $_SERVER***91;'PHP_AUTH_PW'***93; != "$login_password") {
 
header('WWW-Authenticate: Basic realm="SHOUTcast | KICK SOURCE"');
 
header('HTTP/1.0 401 Unauthorized');
 echo 
'<html><head><title>SHOUTcast - Kick source</title></head><body bgcolor="#C6E2FF" text="black">';
 echo 
'<h1>SHOUTcast - Source manager<hr width="100%" size="1" color="black" noshade></h1>';
 echo 
'<font face="Verdana" size="3" color="red"><b>Authorisation failed</b></font><br>';
 echo 
'<font face="Verdana" size="2"><b>Reload this page and <a href="'.$_SERVER***91;'PHP_SELF'***93;.'" style="color: black;">try login again</a></b></font></body></html>';
 exit; }  
?>

<html>
<head>
<title>SHOUTcast - Kick source</title>
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<style>
 td {
  border:1px black solid; }
 font { font-family: Verdana; }
</style>
</head>

<body bgcolor="#C6E2FF" text="black">

<h1>SHOUTcast - Source manager

<hr width="100%" size="1" color="black" noshade></h1>

<font size="2">Select stream:</font>
<form method="get" style="margin: 0px;">
 <select name="id" style="border: 1px solid black;">
  <option value="0">>> Please choose</option>
  <?php
    $id 
$_REQUEST***91;'id'***93;;

    if(!isset(
$_REQUEST***91;'id'***93;) || $id == ''$id 0;

    for(
$x=0;$x<count($shoutcast_ip);$x++) {
     if(
$x == $id) echo "  <option value=\"$x\" selected>".$shoutcast_name***91;$x***93;." | ".$shoutcast_ip***91;$x***93;.":".$shoutcast_port***91;$x***93;."</option>\n";
     else echo 
"  <option value=\"$x\">".$shoutcast_name***91;$x***93;." | ".$shoutcast_ip***91;$x***93;.":".$shoutcast_port***91;$x***93;."</option>\n";
    }
  
?>
 </select>
 <input name="send2" type="submit" value=">> Select!" style="border: 1px solid black;">
</form>
<br>

<?php

 $kickit 
$_POST***91;'password_kick'***93;;

 if(isset(
$_POST***91;'send'***93;)) {

  if(
$kickit != "$kick_password") {

    
$mess "Password wrong. Source(s) not kicked";
    
$col  "red";

   echo 
"<table width=\"400\" cellpadding=\"2\">
     <tr>
      <td width=\"100%\" bgcolor=\"$col\"><font size=\"2\"><b>Notice</b></font></td>
     </tr>
     <tr>
      <td width=\"100%\" bgcolor=\"white\" height=\"60\"><font size=\"2\">$mess</font></td>
     </tr>
    </table><br>"
;
  echo 
"<meta http-equiv=refresh content=4;URL=".$_SERVER***91;'PHP_SELF'***93;."?id=$id>"; }

  else {

   if(
$_POST***91;'kick_all'***93; ==  'true') { $start 0$end  count($shoutcast_ip); }
   else  { 
$start $id$end  $start+1; }

   for(
$s=$start;$s<$end;$s++)
   {

    
$fp = @fsockopen($shoutcast_ip***91;$s***93;, $shoutcast_port***91;$s***93;, &$errno, &$errstr$timeout);

    if (
$fp) {
     
$mess "Source <b>".$shoutcast_ip***91;$s***93;."</b> successfully kicked.";
     
$col  "green";

     @
fputs($fp,"GET /admin.cgi?pass=".$shoutcast_password***91;$s***93;."&mode=kicksrc HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n");
     @
fclose($fp); }
    else {
     
$mess "Connection parameters wrong. Source <b>".$shoutcast_ip***91;$s***93;."</b> not kicked.";
     
$col  "red"; } 

   echo 
"<table width=\"400\" cellpadding=\"2\">
     <tr>
      <td width=\"100%\" bgcolor=\"$col\"><font size=\"2\"><b>Notice</b></font></td>
     </tr>
     <tr>
      <td width=\"100%\" bgcolor=\"white\" height=\"60\"><font size=\"2\">$mess</font></td>
     </tr>
    </table><br>"
;
  } 
// END FOR
  
echo "<meta http-equiv=refresh content=4;URL=".$_SERVER***91;'PHP_SELF'***93;."?id=$id>";
 }  
}

?>

<li><font size="2"><b>Service description</b><br>This service is used to kick your SHOUTcast source via webclient</font>

<li><font size="2"><b>Source details</b></font><br>
<?php
 $fp 
= @fsockopen($shoutcast_ip***91;$id***93;, $shoutcast_port***91;$id***93;, &$errno, &$errstr$timeout);
 if(
$fp) {
  
fputs($fp,"GET /admin.cgi?pass=".$shoutcast_password***91;$id***93;." HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n");
  while(!
feof($fp)) { $cont .= fgets($fp128); }
  
$cont strip_tags($cont);
  if(
ereg("Server is currently down"$cont)) { echo "<font size=\"2\"><font color=\"red\">Server is down/source is disconnected</font> >> Kickin' source has <b>no</b> effect</font>"; }
  elseif(
ereg("Server is currently up"$cont)) { echo "<font size=\"2\"><font color=\"green\">Server is up/source is connected</font> >> Kickin' source has effect</font>"; }
  else { echo 
"<font size=\"2\" color=\"red\">Unknown server/source status</font>"; }
   }
 else  echo 
"<font size=\"2\" color=\"red\">Couldn't connect to server. Is server really up?</font>";
?>



<li><font size="2"><b>Kick source</b><br>Enter password and click "Kick source now!" to kick source:</font><br>

<form method="post" style="margin: 0px;">
<input type="hidden" name="id" value="<? echo $id?>">
<input type="checkbox" name="kick_all" value="true" checked style="border: 1px solid black;"><font size="1">Kick all sources</font><br>
<input type="password" name="password_kick" style="border: 1px solid black;">
<input type="submit" value=">> Kick source now!" name="send" style="border: 1px solid black;">
</form>

<hr width="100%" size="1" color="black" noshade>

<font size="1">&copy; 2006 by <a href="mailto:stationscript@gmx.net" style="color:black;">aintschie</a></font>

</body>

</html>
Attached Files
File Type: zip kicksource.zip (2.1 KB, 1145 views)
aintschy is offline   Reply With Quote
 
Go Back   Winamp 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