Skip to Content
It is currently November 21st, 2019, 3:49 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: May 30th, 2013, 1:34 am 
Offline
SVS Member
SVS Member

Joined: December 28th, 2009, 12:33 pm
Posts: 1340
Has anyone seen a PHP script that will kick duplicate Shoutcast listeners?
I am trying to find something which will allow me to customize how many simultaneous slots an IP address can have, and it will kick any additional slots that the IP address is using.
Additionally, I'd like to find something that will kick the instances/slots that have been open longest (as opposed to the later, more recently connected slots/instances), so that in case a listener is opening multiple slots unintentionally (which I've seen plenty times), only their earlier instances will be kicked.
Does such a thing exist?
Thanks!

_________________
Isaac Levine - Spacial Volunteer Support (SVS)


Top
 Profile  
Reply with quote  
PostPosted: May 31st, 2013, 8:05 am 
Offline
SVS Member
SVS Member

Joined: May 8th, 2004, 9:00 am
Posts: 10450
Location: Denver, CO
If it's shoutcast V1 that's pretty easy to do from a php cron job point of view. I'll try to dig up the code I have used in the past years to do something similar that you can modify.

I am thinking out loud here. Here is how I would do this.

Create and update a table in the sam db with a list of the SCv1 connections - easy
Sort above list by IP address and time connected.
Query list into an array
Compare connectionX to connectionX-1 if not same go to next
if same then connectionX-1 is oldest
send kick code to shoutcast server
go to next until reaching EOF.

This could be done to multiple servers and even across servers if necessary.

_________________
- Rob Oyler, SVS
Image


Top
 Profile  
Reply with quote  
PostPosted: May 31st, 2013, 10:04 am 
Offline
SVS Member
SVS Member

Joined: December 28th, 2009, 12:33 pm
Posts: 1340
Any code you have would be appreciated - thanks!
The theory makes sense, but do you really need to use the database? Seems like it would make things more complicated than they need to be...

_________________
Isaac Levine - Spacial Volunteer Support (SVS)


Top
 Profile  
Reply with quote  
PostPosted: May 31st, 2013, 11:24 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7882
Location: Aachen (Germany)
Unless you have thousands of listeners, there is no need to store anything in the database.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: May 31st, 2013, 1:05 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7882
Location: Aachen (Germany)
Here's something I've hacked together.
https://dl.dropboxusercontent.com/u/737 ... stener.zip
It kicks all duplicate connections from the same hostname/IP and only leaves the one with the shortest connectiontime alive.
It needs PHP 5.3 minimum as it uses namespaces. The actual processing is in a Class in src/ and in vendor/ you'll find the HTTP library that is completely oversized for this kind of project, but I use that for all my stuff and didn't want to spend an hour reading about how to handle HTTP connections correctly.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: June 2nd, 2013, 1:58 am 
Offline
SVS Member
SVS Member

Joined: December 28th, 2009, 12:33 pm
Posts: 1340
Thanks a lot - will try it a bit later.
Is there a way to change how many connections are left open? I would maybe want to allow more than just one connection, for offices/locations with multiple listeners...

_________________
Isaac Levine - Spacial Volunteer Support (SVS)


Top
 Profile  
Reply with quote  
PostPosted: June 3rd, 2013, 4:35 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7882
Location: Aachen (Germany)
You'd need to modify the script to some extent in order to keep multiple connections.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: June 5th, 2013, 11:43 pm 
Offline
SVS Member
SVS Member

Joined: December 28th, 2009, 12:33 pm
Posts: 1340
Will take a look at it, and see if it's something I can figure out...
Thanks a lot!

_________________
Isaac Levine - Spacial Volunteer Support (SVS)


Top
 Profile  
Reply with quote  
PostPosted: May 18th, 2014, 10:31 am 
Offline
Senior User
Senior User

Joined: August 25th, 2012, 1:48 pm
Posts: 88
Hello

Am trying to use this solution as lately I am getting people who seem to have a problem with their web based player and continuously open a new connection every now and again.

I don't know if am doing the right thing, I edited the purge.php in 3 places with my stream information/password. Then I open index.php on one of my computers but I get a blank page. I have php 5.4 so not sure if it is supposed to work on a higher version, or am I missing the plot :roll: ?

Thanks

edited:
I also changed this

private $client = mystream:myport;
private $pass = 'mypassword';

and added my stream:myport on every bit where the localhost was mentioned on purge.php


Top
 Profile  
Reply with quote  
PostPosted: April 18th, 2019, 2:13 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7882
Location: Aachen (Germany)
MadNats wrote:
I also changed this

private $client = mystream:myport;
private $pass = 'mypassword';

and added my stream:myport on every bit where the localhost was mentioned on purge.php


Oof, it has been very long since I posted that here.
The link isn't even working anymore, so how did you even get the script?

Anyways: The $client variable is meant to be null as it's being replaced by the Guzzle Http Client a few lines later.

Opening in the browser might work as well, but this was actually meant to be a commandline script.
The script requires cURL to be available as a PHP extension in order to work. That should be enabled by default on most webhosts and in the default PHP binaries for Windows you can download from php.net

If it doesn't show anything at all, it's definitely broken.

Check your error_reporting:

Right below the comment in index.php add the following lines:
Code:
ini_set('display_errors''On');
error_reporting(E_ALL); 


That should show you whatever error occured.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group