Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ICES Web Interface Script - Need help finishing it up.

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Source Clients
View previous topic :: View next topic  
Author Message
Anonymous
Guest





PostPosted: Tue Mar 13, 2007 4:36 pm    Post subject: ICES Web Interface Script - Need help finishing it up. Reply with quote

This is a quick and dirty web interface for ICES. If anyone wants to run through the php and clean it up, I'll build some css for it and make it a eye pleasing project. I also have another version that returns more information and uses more of the php-ices script's functions but I want to get this one squared away first.

Update: Fixed the index error and added some html get the returned html to validate on W3C.

Update 9/8/07: Added more to header to reset the session and clear out variables so we don't get a cached page on refreshing.


Code:
<?php
#########
#
# ICES CONTROL v1 (Basic Edition)
# Basic ICES Control via Web Interface 
# Pieced together by 420am - radioxenu.com
# You will have to turn off PHP's safemode for the exec command to work. This is considered a security risk.
#
#########
#
# Snippets of code and insipration from various sources, including but not limited to these fine folks
#
# This script borrows heavily from Nick's php-ices script.
# For more information on php-ices check out
# http://www.linickx.com/blog/archives/13/php-ices-beta-released/
#
# Thanks to William for his contributions to the ices/icecast community. I was inspired by his start/reload/stop scripts and believe I borrowed a line or two.
# William J. Galway
# http://www.galwayland.com
#
#########

# Change to the directory you have your conf file in. You could work the conf file into the exec command further down the script if you want to do that instead.
chdir('/path/to/your/conf');

# Kill session and reset variables os we don't get a cache page.
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
session_unset();

# Get ICES and IceCast Process ID's. Icecast PID is not needed and is commented out.
$pid = exec("ps -o \"%p\" --noheaders -C ices");
# $pidicecast = exec("ps -o \"%p\" --noheaders -C icecast");

$self=$_SERVER["PHP_SELF"];

echo "
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-transitional.dtd\">
<html>
<head>
<title>ICES Web Interface - Basic</title>
<meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\" />
<meta http-equiv=\"content-language\" content=\"en\" />
<meta name=\"robots\" content=\"noindex, nofollow\" />
</head>
<body>
";

#########
# If ICES doesn't have a Process ID it is not running. Return button to start it in this case.
if ($pid <=1) {

echo "
ICES NOT RUNNING!

<br /><br />

<table border=\"1\">
<tr>
<td>
<form enctype=\"multipart/form-data\" action=\"$self\" method=\"post\" >
<input type=\"hidden\" name=\"action\" value=\"START ICES\" />
<input type=\"submit\" value=\"START ICES\" />
</form>
</tr>
</td>
</table>
</body>
</html>
";
}

#########
# If ICES does have a Process ID it is running. Return buttons to reload the conf file and playlist, skip the current song or kill ICES.

else {
echo "
ICES running on: $pid

<br /><br />

<table border=\"1\">
<tr>
<td>
<form enctype=\"multipart/form-data\" action=\"$self\" method=\"post\" >
<input type=\"hidden\" name=\"action\" value=\"RELOAD\" />
<input type=\"submit\" value=\"RELOAD\" />
</form>
</td>
<td>
<form enctype=\"multipart/form-data\" action=\"$self\" method=\"post\" >
<input type=\"hidden\" name=\"action\" value=\"SKIP\" />
<input type=\"submit\" value=\"SKIP->\" />
</form>
</td>
<td>
<form enctype=\"multipart/form-data\" action=\"$self\" method=\"post\" >
<input type=\"hidden\" name=\"action\" value=\"KILL\" />
<input type=\"submit\" value=\"STOP\" />
</form>
</td>
</tr>
</table>
</body>
</html>
";
}

#########
# Define functions. I'm sure these can be cleaned up alot. But they work.

function ices_start() {
  $handle = popen('ices & 2>&1', 'r');
  pclose($handle);
}

function ices_kill() {
$pid = exec("ps -o \"%p\" --noheaders -C ices");
echo exec("kill -KILL $pid");
}

function ices_reload() {

$pid = exec("ps -o \"%p\" --noheaders -C ices");
echo exec("kill -SIGHUP $pid");
}

function ices_skip() {
$pid = exec("ps -o \"%p\" --noheaders -C ices");
echo exec("kill -USR1 $pid");
}

#########
# Match form actions to functions.

$action = $_POST['action'];

if ( $action == "START ICES" ) {
   ices_start();
}

if ( $action == "RELOAD" ) {
   ices_reload();
}

if ( $action == "SKIP" ) {
   ices_skip();
}

if ( $action == "KILL") {
   ices_kill();
}

?>


Last edited by Anonymous on Sat Sep 08, 2007 6:23 pm; edited 1 time in total
Back to top
Anonymous
Guest





PostPosted: Thu Mar 15, 2007 5:49 pm    Post subject: Reply with quote

no comments? Confused
Back to top
Anonymous
Guest





PostPosted: Thu Apr 19, 2007 4:44 pm    Post subject: Reply with quote

Works great!!

BG
Back to top
Anonymous
Guest





PostPosted: Fri Jun 01, 2007 8:52 am    Post subject: Reply with quote

Searching for a web intrafece source client , I came yp with yor code . But the problem is that because I am new to Linux I donīt now how to handle this code . Can you give me some help?

Thank you .
Back to top
Anonymous
Guest





PostPosted: Tue Jun 05, 2007 2:54 am    Post subject: Reply with quote

Create a php file with the code and place it in your web. Confirm your webserver has permission to the binary, logfiles, and configuration files.


spooky wrote:
Searching for a web intrafece source client , I came yp with yor code . But the problem is that because I am new to Linux I donīt now how to handle this code . Can you give me some help?

Thank you .
Back to top
Anonymous
Guest





PostPosted: Sat Sep 08, 2007 6:19 pm    Post subject: Reply with quote

wgalway wrote:
Create a php file with the code and place it in your web. Confirm your webserver has permission to the binary, logfiles, and configuration files.


spooky wrote:
Searching for a web intrafece source client , I came yp with yor code . But the problem is that because I am new to Linux I donīt now how to handle this code . Can you give me some help?

Thank you .


I believe you also need to make sure you have curl on your webserver.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Source Clients All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber