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
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 ([email protected])
// 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['PHP_AUTH_USER'] != "$login_user" || $_SERVER['PHP_AUTH_PW'] != "$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['PHP_SELF'].'" 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['id'];
if(!isset($_REQUEST['id']) || $id == '') $id = 0;
for($x=0;$x<count($shoutcast_ip);$x++) {
if($x == $id) echo " <option value=\"$x\" selected>".$shoutcast_name[$x]." | ".$shoutcast_ip[$x].":".$shoutcast_port[$x]."</option>\n";
else echo " <option value=\"$x\">".$shoutcast_name[$x]." | ".$shoutcast_ip[$x].":".$shoutcast_port[$x]."</option>\n";
}
?>
</select>
<input name="send2" type="submit" value=">> Select!" style="border: 1px solid black;">
</form>
<br>
<?php
$kickit = $_POST['password_kick'];
if(isset($_POST['send'])) {
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['PHP_SELF']."?id=$id>"; }
else {
if($_POST['kick_all'] == 'true') { $start = 0; $end = count($shoutcast_ip); }
else { $start = $id; $end = $start+1; }
for($s=$start;$s<$end;$s++)
{
$fp = @fsockopen($shoutcast_ip[$s], $shoutcast_port[$s], &$errno, &$errstr, $timeout);
if ($fp) {
$mess = "Source <b>".$shoutcast_ip[$s]."</b> successfully kicked.";
$col = "green";
@fputs($fp,"GET /admin.cgi?pass=".$shoutcast_password[$s]."&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[$s]."</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['PHP_SELF']."?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[$id], $shoutcast_port[$id], &$errno, &$errstr, $timeout);
if($fp) {
fputs($fp,"GET /admin.cgi?pass=".$shoutcast_password[$id]." HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n");
while(!feof($fp)) { $cont .= fgets($fp, 128); }
$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">© 2006 by <a href="mailto:[email protected]" style="color:black;">aintschie</a></font>
</body>
</html>
Comment