Announcement

Collapse
No announcement yet.

"Kick Source" script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • "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 ([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($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:[email protected]" style="color:black;">aintschie</a></font>

    </body>

    </html>
    Attached Files

  • #2
    Anyone managed to get this script working ?

    it seems to get stuck on the login section, i think it mught have something to do with the following line but i could be wrong....

    if($_SERVER['PHP_AUTH_USER'] != "$login_user" || $_SERVER['PHP_AUTH_PW'] != "$login_password") {

    Comment


    • #3
      Not working

      When the user name is user and password is 1234 and when I change it to something else it stops working.

      Can somone PLEASE tell me why?

      DJ Mikey

      Comment


      • #4
        I'll share my Perl Version for you guys. Its much simpler.

        #!/usr/bin/perl
        use LWP::UserAgent;
        my $ua = LWP::UserAgent->new;
        $ua->timeout(10);
        $ua->env_proxy;
        $ua->agent(Mozilla);
        $pass="tranceistotallygay";
        $host="localhost";
        $port="8666";


        my $response = $ua->get("http://$host:$port/admin.cgi?pass=$pass&mode=kicksrc");

        if ($response->is_success) {
        print $response->decoded_content; # or whatever
        }
        else {
        die $response->status_line;
        }

        That'll kick my live dj currently connected. Its not as robust as the above script but works well for me. hope it helps.

        Comment


        • #5
          This kicks them from the DNAS, right? I'm really looking for something to kick them from sc_trans (the new beta is NICE!).

          Comment


          • #6
            yes, mine kicks them from the DNAS.. I only use the sc_trans as a media player. I intergrated VLC into my server so I can do mpg/flash video streaming. sorry I wasn't clear about how my script works. =)

            Comment


            • #7
              That's okay. I have our resident codemonkey working on a way to kick from sc_trans, but it's taking time.

              Comment


              • #8
                I got it working (kick page)

                Hi

                For some really odd reason it wont work on my server ( http://eastsidehosting.com ) but its a shared server and I put it on my home server and it worked just fine. I am not sure WHY. Maybe someone has some insight why this is?

                The only port I have open is port 80 for the web server.

                If somone has a idea why this is working please let me know.

                Michael

                Comment


                • #9
                  Windows Media (audio) kick source

                  Do ANYONE know how to make a Windows Media (audio) kick source????

                  We have one for shoutcast but we cant find one for windows media streaming (audio)

                  Dose such thing exist???

                  Michael

                  Comment


                  • #10
                    You can`t kick a source on a windows media server.
                    There are too many ways get your data here (push, get, file, rebroadcast,...)
                    greets,
                    Michael

                    TechnoBase.FM | HouseTime.FM | HardBase.FM | TranceBase.FM | CoreTime.FM | We aRe oNe

                    Comment


                    • #11
                      PM from powerjaminradio: I dont understand your post about you cant kick windows streaming
                      Windows Media Service is a professional application.
                      Its not designed to support DJs.
                      Its designed to get data from external sources like encoders (push or pull), directorys (files), multicast streams, or special playlists.
                      If you want to change an specific source, you have to delete the publishing point and create a new one with the same name.
                      You can`t do this via an script and listeners will be disconnected if you delete a publishing point.
                      greets,
                      Michael

                      TechnoBase.FM | HouseTime.FM | HardBase.FM | TranceBase.FM | CoreTime.FM | We aRe oNe

                      Comment


                      • #12
                        Windows Media (audio) kick source

                        I've found a service that dose what I wanted done. Thay are in the UK but thay have US servers.



                        I would even say thay have GREAT prices

                        Comment


                        • #13
                          Originally posted by caraoge
                          Windows Media Service is a professional application.
                          Its not designed to support DJs.
                          Its designed to get data from external sources like encoders (push or pull), directorys (files), multicast streams, or special playlists.
                          If you want to change an specific source, you have to delete the publishing point and create a new one with the same name.
                          You can`t do this via an script and listeners will be disconnected if you delete a publishing point.
                          Just to clarify you can do all these things with a windows media server like kick source and also dj source switching.

                          This with now playing stats makes windows a viable option for dj use

                          but this is a shoutcast forum and not a windows media forum
                          www.streamsolutions.co.uk
                          SHOUTcast | Flash Media | Windows Media | Icecast 2 | Content Delivery |

                          Comment


                          • #14
                            Windows Media (audio) kick source

                            Well well I couldn't FIND a windows media forum

                            Comment


                            • #15
                              Thats why what we do is so "special"

                              www.streamsolutions.co.uk
                              SHOUTcast | Flash Media | Windows Media | Icecast 2 | Content Delivery |

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎