Announcement

Collapse
No announcement yet.

Looking For A Kick Source Script For My Internet Station With A Specific Requirement

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

  • 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

  • #2
    if you know a bit of php its simple because
    you just need to use,
    So Long, and Thanks for All the Fish.

    Comment


    • #3
      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.

      Comment


      • #4
        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!

        Comment


        • #5
          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 !

          Comment


          • #6
            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

            Comment


            • #7
              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 .

              Comment


              • #8
                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.

                Comment

                Working...
                X