Jump to content

[SOLVED] PHP cURL to kick Shoutcast Source


grunshaw

Recommended Posts

Hi guys,

I'm guessing most (or at least a lot) of people will have some knowledge of the SHOUTcast administration interface. Basically, what I am doing is building an admin interface that each DJ has a login for, so, I dont want to give out the administration login details for the server, but I want to be able to have DJs kick the Auto DJ source.

 

The link looks like this

 

http://djcp.co.uk:8000/admin.cgi?mode=kicksrc

 

The code I have so far is like this

<?

$url="http://djcp.co.uk:8000/admin.cgi?mode=kicksrc";

// The usual - init a curl session and set the url
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $base_url);

// Set your login and password for authentication
curl_setopt($ch, CURLOPT_USERPWD, 'admin:xxxxxxx');

// You can use CURLAUTH_BASIC, CURLAUTH_DIGEST, CURLAUTH_GSSNEGOTIATE,
// CURLAUTH_NTLM, CURLAUTH_ANY, and CURLAUTH_ANYSAFE
//
// You can use the bitwise | (or) operator to combine more than one method.
// If you do this, CURL will poll the server to see what methods it supports and pick the best one.
//
// CURLAUTH_ANY is an alias for CURLAUTH_BASIC | CURLAUTH_DIGEST |
// CURLAUTH_GSSNEGOTIATE | CURLAUTH_NTLM
//
// CURLAUTH_ANYSAFE is an alias for CURLAUTH_DIGEST | CURLAUTH_GSSNEGOTIATE |
// CURLAUTH_NTLM
//
// Personally I prefer CURLAUTH_ANY as it covers all bases
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

// This is occassionally required to stop CURL from verifying the peer's certificate.
// CURLOPT_SSL_VERIFYHOST may also need to be TRUE or FALSE if
// CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2 - check the existence of a
// common name and also verify that it matches the hostname provided)
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

// Optional: Return the result instead of printing it
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// The usual - get the data and close the session
$data = curl_exec($ch);
curl_close($ch); 
?>

I thought this might work ouf of the box (obviously substituting the relevant variables), but it doesn't, it just hangs.

 

Is there any way I can simplify this at all?

 

Tahnks in advance

James.

Link to comment
Share on other sites

I think you may have miss-understood me.

 

I am building a DJ Control panel for the station, this is what contains different actions that different levels of users can execute. MySQL does not answer my question for what I want to do. I'm already using MySQL for the control panel to store user details and show details so I can display them on the main page so users visiting hte site can see who is on air.

 

what I want to do is to be able to kick the source from the admin panel that I am creating, thats why I need help with the segment of code above to make it work.

 

James.

Link to comment
Share on other sites

Ok...with much research and looking at this in a different way after seeing a different script, i have managed to acheive what I wanted. So, here for the other people that may find this useful is what i have now done.

 

I scrapped the cURL idea and use fsockopen instead.

 

$timeout = 5;
$pass="xxxxxxxxx";
$ip="12.34.56.78";
$port="8080";

$fp = @fsockopen($ip, $port, &$errno, &$errstr, $timeout); 
if($fp) { 
  fputs($fp,"GET /admin.cgi?pass=".$pass."&mode=kicksrc  HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n"); 

echo "Success, Source kicked. <a href='home.php'>Go Back</a>"; }

 

I hope someone else can find use in this snippet.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.