Location: PHPKode > projects > phpSC > modules/serv_config_edit.php
if(isset($_POST['MaxUser'])) {

function WriteElement($element) {
	if($_POST[$element] != "") {
$config_file ="$element=".$_POST[$element]."\n";
	} else {
$config_file =";$element=\n";
return $config_file;

	if($_POST['MaxUser'] != "") {
$config_file ="MaxUser=".$_POST['MaxUser']."\n";
	} else {
$config_file ="MaxUser=32\n";
	if($_POST[Password] != "") {
$config_file .="Password=".$_POST['Password']."\n";
	} else {
$config_file .="Password=changme\n";
	if($_POST['PortBase'] != "") {
$config_file .="PortBase=".$_POST['PortBase']."\n";
	} else {
$config_file .="PortBase=8000\n";
$config_file .= WriteElement("LogFile");
$config_file .= WriteElement("RealTime");
$config_file .= WriteElement("ScreenLog");
$config_file .= WriteElement("ShowLastSongs");
$config_file .= WriteElement("TchLog");
$config_file .= WriteElement("WebLog");
$config_file .= WriteElement("W3CEnable");
$config_file .= WriteElement("W3CLog");
$config_file .= WriteElement("SrcIP");
$config_file .= WriteElement("DestIP");
$config_file .= WriteElement("Yport");
$config_file .= WriteElement("NameLookups");
$config_file .= WriteElement("RelayPort");
$config_file .= WriteElement("AdminPassword");
$config_file .= WriteElement("AutoDumpUsers");
$config_file .= WriteElement("AutoDumpSourceTime");
$config_file .= WriteElement("ContentDir");
$config_file .= WriteElement("IntroFile");
$config_file .= WriteElement("BackupFile");
$config_file .= WriteElement("TitleFormat");
$config_file .= WriteElement("URLFormat");
$config_file .= WriteElement("PublicServer");
$config_file .= WriteElement("AllowRelay");
$config_file .= WriteElement("AllowPublicRelay");
$config_file .= WriteElement("MetaInterval");
$config_file .= WriteElement("ListenerTimer");
$config_file .= WriteElement("BanFile");
$config_file .= WriteElement("RipFile");
$config_file .= WriteElement("RIPOnly");
$config_file .= WriteElement("Unique");
$config_file .= WriteElement("Include");
$config_file .= WriteElement("CpuCount");
$config_file .= WriteElement("Sleep");
$config_file .= WriteElement("CleanXML");
$filename = _DNAS_CONFIG;
$file = fopen($filename,'w');
if(fwrite($file,$config_file)) {
$port = conf_port($filename);
$ip = conf_ip($filename);
$sql = "UPDATE servers SET ip = '$ip', port = '$port' WHERE servers.id = '".$_SESSION['server_id']."'";
mysql_query($sql,$conn) or die (mysql_error());
$message = "Configuration file updated.";
} else {
$message = "Couldn't write the new configuration file.";

$contents = file_get_contents(_DNAS_CONFIG);
$settings = explode("\n",$contents);
for($i = 0; $i <= 37; $i++) {
	if(substr($settings[$i],0,1) == ";") {
function getSetting($haystack, $setting) {
if(isset($haystack)) {
$void = strlen($setting) + 1;
$setme = substr($haystack,$void);
return $setme;
$setme = "";
return $setme;

<div align="center">Help: <a onClick="ShowHelp()" href="#">On</a> | <a onClick="HideHelp()" href="#">Off</a></div>
<center><?= $message ?></center><pre>
<form method="post" action"index.php?module=server_config_edit">
<div id='1'>
; SHOUTcast Distributed Network Audio Server configuration file
; Copyright (C) 1998-2004 Nullsoft, Inc.
; All Rights Reserved.
; Last modified Mar 17 2004

; This file is part of ShoutCONTORL Shoutcast Control Panel
; Certain Variables have been changed, and you should not attempt
; to use this text as a configuration file for a manually
; installed Shoutcast server.
<div id='message'>

; ***************************
; Required stuff
; ***************************

; MaxUser.  The maximum number of simultaneous listeners allowed.
; Compute a reasonable value for your available upstream bandwidth (i.e. if
; you have 256kbps upload DSL, and want to broadcast at 24kbps, you would
; choose 256kbps/24kbps=10 maximum listeners.)  Setting this value higher
; only wastes RAM and screws up your broadcast when more people connect
; than you can support.
MaxUser=<label><input name="MaxUser" type="text" value="<?= getSetting($settings['0'],"MaxUser") ?>" size="10"></label>
<div id='2'>
; Password.  While SHOUTcast never asks a listener for a password, a 
; password is required to broadcast through the server, and to perform
; administration via the web interface to this server.  This server should
; consist of only letters and numbers, and is the same server your broadcaster
; will need to enter in the SHOUTcast Source Plug-in for Winamp.  THIS VALUE
Password=<label><input name="Password" type="text" value="<?= getSetting($settings['1'],"Password") ?>"></label>
<div id='41'>
; PortBase. This is the IP port number your server will run on.  The
; value, and the value + 1 must be available.  If you get a fatal error when
; the DNAS is setting up a socket on startup, make sure nothing else on the
; machine is running on the same port (telnet localhost portnumber -- if you
; get connection refused then you're clear to use that port).  Ports < 1024 
; may require root privledges on *nix machines.  The default port is 8000.
PortBase=<label><input name="PortBase" type="text" value="<?= getSetting($settings['2'],"PortBase") ?>" size="10"></label>
<div id='3'>
<p>; ***************************
; Optional Parameters
; ***************************

; ***************************
; Logging configuration
; ***************************

; LogFile: file to use for logging. Can be '/dev/null' or 'none'
; or empty to turn off logging. The default is ./sc_serv.log
; on *nix systems or sc_serv_dir\sc_serv.log on win32.
; Note: on win32 systems if no path is specified the location is
; in the same dir as the executable, on *nix systems it is in the
; current directory.
LogFile=<input name="LogFile" type="text" value="<?= getSetting($settings['3'],"LogFile") ?>">
<div id='4'>
; RealTime displays a status line that is updated every second
; with the latest information on the current stream (*nix and win32 
; console systems only)
RealTime=<input name="RealTime" type="text" value="<?= getSetting($settings['4'],"RealTime") ?>">
<div id='5'>
; ScreenLog controls whether logging is printed to the screen or not
; on *nix and win32 console systems. It is useful to disable this when 
; running servers in background without their own terminals. Default is 1
ScreenLog=<input name="ScreenLog" type="text" value="<?= getSetting($settings['5'],"ScreenLog") ?>">
<div id='6'>
; ShowLastSongs specifies how many songs to list in the /played.html
; page.  The default is 10.  Acceptable entries are 1 to 20.
ShowLastSongs=<input name="ShowLastSongs" type="text" value="<?= getSetting($settings['6'],"ShowLastSongs") ?>">
<div id='7'>
; TchLog decides whether or not the DNAS logfile should track yp 
; directory touches.  Adds and removes still appear regardless of
; this setting.
; Default is yes
TchLog=<input name="TchLog" type="text" value="<?= getSetting($settings['7'],"TchLog") ?>">
<div id='8'>
; WebLog decides whether or not hits to http:// on this DNAS will
; be logged.  Most people leave this off because the DSP plug-in
; uses http:// calls to update titles and get the listener count,
; which takes up a lot of log space eventually.  If you want to
; see people making hits on your admin.cgi or index pages, turn
; this back on.  Note that this setting does NOT affect XML stats
; counters for hits to http:// pages.
; Default is no.
WebLog=<input name="WebLog" type="text" value="<?= getSetting($settings['8'],"WebLog") ?>">
<div id='9'>
; W3CEnable turns on W3C Logging.  W3C logs contain httpd-like accounts
; of every track played for every listener, including byte counts those listeners
; took.  This data can be parsed with tools like Analog and WebTrends, or given
; to third parties like Arbitron and Measurecast for their reporting systems.
; Default is Yes (enabled).
W3CEnable=<input name="W3CEnable" type="text" value="<?= getSetting($settings['9'],"W3CEnable") ?>">
<div id='10'>
; W3CLog describes the name of the logfile for W3C logging.  Default logfile is
; sc_w3c.log, in the same directory wherever the DNAS gets started from.
W3CLog=<input name="W3CLog" type="text" value="<?= getSetting($settings['10'],"W3CLog") ?>">
<div id='11'>

; ***************************
; Network configuration
; ***************************
<div id='12'>
; SrcIP, the interface to listen for source connections on (or to make relay 
; connections on if relaying). Can and usually will be ANY or  
; (Making it will keep other machines from being able to
; broadcast using your shoutcast server )
SrcIP=<input name="SrcIP" type="text" value="<?= getSetting($settings['11'],"SrcIP") ?>">
<div id='13'>
; DestIP, IP to listen for clients on (and to contact yp.shoutcast.com)
; can and usually will be be ANY. If your machine has multiple IP addresses,
; set this to the one you want it to be accessed by.
DestIP=<input name="DestIP" type="text" value="<?= getSetting($settings['12'],"DestIP") ?>">
<div id='14'>
; Yport, port to connect to yp.shoutcast.com on. For people behind caching 
; webproxies, change this to the alternate port (666 is what it might be, 
; check www.shoutcast.com if you have problems). Otherwise, leave this at 80.
; We're actively working on re-opening port 666, but as of release the only
; working port is port 80.
Yport=<input name="Yport" type="text" value="<?= getSetting($settings['13'],"Yport") ?>">
<div id='15'>
; NameLookups.  Specify 1 to perform reverse DNS on connections.
; This option may increase the time it takes to connect to your
; server if your DNS server is slow.  Default is 0 (off).
NameLookups=<input name="NameLookups" type="text" value="<?= getSetting($settings['14'],"NameLookups") ?>">
<div id='16'>
; RelayPort and RelayServer specify that you want to be a relay server.
; Relay servers act as clients to another server, and rebroadcast.
; Set RelayPort to 0, RelayServer to empty, or just leave these commented
; out to disable relay mode.
RelayPort=<input name="RelayPort" type="text" value="<?= getSetting($settings['15'],"RelayPort") ?>"><br>
RelayServer=<input name="RelayServer" type="text" value="<?= getSetting($settings['16'],"RelayServer") ?>">
<div id='17'>
; ***************************
; Server configuration
; ***************************
<div id='18'>
; AdminPassword.  This password (if specified) changes the
; behavior of Password to be a broadcast-only password, and
; limits HTTP administration tasks to the password specified
; here.  The broadcaster, with the password above, can still
; log in and view connected users, but only the AdminPassword
; will grant the right to kick, ban, and specify reserve hosts.
; The default is undefined (Password allows control for both 
; source and admin)
AdminPassword=<input name="AdminPassword" type="text" value="<?= getSetting($settings['17'],"AdminPassword") ?>">
<div id='19'>
; AutoDumpUsers controls whether listeners are disconnected if the source
; stream disconnects. The default is 0.
AutoDumpUsers=<input name="AutoDumpUsers" type="text" value="<?= getSetting($settings['18'],"AutoDumpUsers") ?>">
<div id='20'>
; AutoDumpSourceTime specifies how long, in seconds, the source stream is
; allowed to be idle before the server disconnects it. 0 will let the source
; stream idle indefinately before disconnecting. The default is 30.
AutoDumpSourceTime=<input name="AutdoDumpSourceTime" type="text" value="<?= getSetting($settings['19'],"AutoDumpSourceTime") ?>">
<div id='21'>
; ContentDir specifies the directory location on disk of where to stream
; on-demand content from.  Subdirectories are supported as of DNAS 1.8.2.
; Default is ./content, meaning a directory named content in the same directory
; as where sc_serv was invoked from.
ContentDir=<input name="ContentDir" type="text" value="<?= getSetting($settings['20'],"ContentDir") ?>">
<div id='22'>
; IntroFile can specify a mp3 file that will be streamed to listeners right
; when they connect before they hear the live stream.
; Note that the intro file MUST be the same samplerate/channels as the 
; live stream in order for this to work properly. Although bitrate CAN
; vary, you can use '%d' to specify the bitrate in the filename
; (i.e. C:\intro%d.mp3 would be C:\intro64.mp3 if you are casting at 64kbps).
; The default is no IntroFile
IntroFile=<input name="IntroFile" type="text" value="<?= getSetting($settings['21'],"IntroFile") ?>">
<div id='23'>
; BackupFile can specify a mp3 file that will be streamed to listeners over
; and over again when the source stream disconnects. AutoDumpUsers must be
; 0 to use this feature. When the source stream reconnects, the listeners
; are rejoined into the live broadcast.
; Note that the backup file MUST be the same samplerate/channels as the 
; live stream in order for this to work properly. Although bitrate CAN
; vary, you can use '%d' to specify the bitrate in the filename
; (i.e. C:\backup%d.mp3 would be C:\backup32.mp3 if you are casting at 32kbps).
; The default is no BackupFile
BackupFile=<input name="BackupFile" type="text" value="<?= getSetting($settings['22'],"BackupFile") ?>">
<div id='24'>
; TitleFormat specifies a format string for what title is sent to the listener.
; For example, a string of 'Justin Radio' forces the title 'Justin Radio' even
; when the source changes the title. You can use up to one '%s' in the string
; which lets you contain the title from the source. For example, if your 
; TitleFormat is 'Justin Radio: %s', and the source plug-in's title is 
; 'Billy plays the blues', then the net title is 
; 'Justin Radio: Billy plays the blues'. Note: only works on non-relay servers.
; The default is no format string.
TitleFormat=<input name="TitleFormat" type="text" value="<?= getSetting($settings['23'],"TitleFormat") ?>">
<div id='25'>
; URLFormat specifies a format string for what url is sent to the listener.
; Behaves like TitleFormat (see above).
; The default is no format string.
URLFormat=<input name="URLFormat" type="text" value="<?= getSetting($settings['24'],"URLFormat") ?>">
<div id='26'>
; PublicServer can be always, never, or default (the default, heh)
; Any setting other than default will override the public status
; of the source plug-in or of a SHOUTcast server that is being relayed.
PublicServer=<input name="PublicServer" type="text" value="<?= getSetting($settings['25'],"PublicServer") ?>">
<div id='27'>
; AllowRelay determines whether or not other SHOUTcast servers will be
; permitted to relay this server.  The default is Yes.
AllowRelay=<input name="AllowRelay" type="text" value="<?= getSetting($settings['26'],"AllowRelay") ?>">
<div id='28'>
; AllowPublicRelay, when set to No, will tell any relaying servers not
; to list the server in the SHOUTcast directory (non-public), provided
; the relaying server's Public flag is set to default.  The default is
; Yes.
AllowPublicRelay=<input name="AllowPublicRelay" type="text" value="<?= getSetting($settings['27'],"AllowPublicRelay") ?>">
<div id='29'>
; MetaInterval specifies how often, in bytes, metadata sent.
; You should really leave this at the default of 8192, but the option is 
; provided anyway.
MetaInterval=<input name="MetaInterval" type="text" value="<?= getSetting($settings['28'],"MetaInterval") ?>">
<div id='30'>
; *****************************
; Access Control
; *****************************
<div id='31'>
; ListenerTimer is a value in minutes of maximum permitted time for
; a connected listener.  If someone is connected for longer than this
; amount of time, in minutes, they are disconnected.  When undefined,
; there is no limit defined.  Default is undefined.
ListenerTimer=<input name="ListenerTimer" type="text" value="<?= getSetting($settings['29'],"ListenerTimer") ?>">
<div id='32'>
; BanFile is the text file sc_serv reads and writes to/from
; for the list of clients prohibited to connect to this
; server.  It's automatically generated via the web
; interface.
BanFile=<input name="BanFile" type="text" value="<?= getSetting($settings['30'],"BanFile") ?>">
<div id='33'>
; RipFile is the text file sc_serv reads and writes to/from
; for the list of client IPs which are *ALWAYS* permitted
; to connect to this server (useful for relay servers).
; This file is automatically generated via the web
; interface.  Note that if your server is FULL, and someone
; from a Reserved IP connects, the DNAS will force the person
; listening for the longest time off to make room for the new
; connection.
RipFile=<input name="RipFile" type="text" value="<?= getSetting($settings['31'],"RipFile") ?>">
<div id='34'>
; RIPOnly, when set to Yes, will only allow IP addresses listed in the Reserved
; IP list to connect and relay.  All other connections for listening will be denied.
; This is really only useful for servers whose sole purpose is to provide the
; primary feed to all public relays.  Setting this value to Yes also forces the
; server into Private mode, since listing this server in the directory would
; be pointless.  Default is No.
RIPOnly=<input name="RIPOnly" type="text" value="<?= getSetting($settings['32'],"RIPOnly") ?>">
<div id='35'>
; *****************************
; Extended Logging 
; *****************************
<div id='36'>
; The old features previously at this location, HistoryLog and CurrentLog, are
; no longer used and succeded by W3C Logging and XML, respectively.

; ***************************
; Mass Configuration
; ***************************

; Unique: assigns a variable name for use in any config item which points to a
; file.  Useful for servers running lots of SHOUTcast servers that have similar
; configuration parameters, excepting logfile names, banfile names, etc.  Any
; parameter that takes a pathname can include the character $, which will
; substitute $ for the variable assigned here.  Keep in mind that the unique
; variable can only be used after it is defined, so don't try to use a unique
; variable substitution in a path before you define it.  For example, you 
; could set:
; and then define Log=/usr/local/shoutcast/$.log in an included configuration 
; file.  Default is Unique=$, so that by default any file with $ in the name 
; won't substitute anything at all.
Unique=<input name="Unique" type="text" value="<?= getSetting($settings['33'],"Unique") ?>">
<div id='37'>
; Include: instructs the sc_serv to read from the named configuration file,
; *at the point of insertion of the Include statement*, and process as though
; the included file was part of itself.  Note that all configuration parameters
; in the DNAS config file are processed first to last, so if an item is defined
; twice in a configuration, the last item to process will be the one that takes
; effect.  For this reason, it's usually a good idea to use the Includes first
; in a config file.
; example:
; Include=/usr/local/shoutcast/common.conf
; Default is not applicable.
Include=<input name="Include" type="text" value="<?= getSetting($settings['34'],"Include") ?>">
<div id='38'>
; *****************************
; Tweaks
; *****************************

; CpuCount is used to explicitly limit the DNAS to dominating a finite
; amount of processors in multiprocessor systems.  By default, 
; SHOUTcast creates one thread for every processor it detects in the
; host system, and assigns listeners equally across all the threads.
; In the event SHOUTcast doesn't correctly determine the number of
; CPUs in your host, or if you for whatever reason want to force
; the DNAS to not use other processors, you can say so here.
; Default behavior is to use as many processors as the DNAS detects on
; your system.
CpuCount=<input name="CpuCount" type="text" value="<?= getSetting($settings['35'],"CpuCount") ?>">
<div id='39'>
; Sleep defines the granularity of the client threads for sending data.
; DNAS 1.7.0, per client thread, will send up to 1,024 bytes of data
; per socket (or less depending on the window available), and then
; sleep for the provided duration before repeating the whole process.
; Note that making this value smaller will vastly increase CPU usage on 
; your machine.  Increasing reduces CPU, but increasing this value too far 
; will cause skips.  The value which seems most optimal for 128kbps 
; streaming is 833 (833 microseconds per client poll) on our test labs.
; We wouldn't recommend setting it any lower than 100, or any higher than 
; 1,024.  If you have a slower machine, set this number lower to fix
; skips.
; Default value is 833.
Sleep=<input name="Sleep" type="text" value="<?= getSetting($settings['36'],"Sleep") ?>">
<div id='40'>
; CleanXML strips some whitespace and linefeeds from XML output which
; confuses some (poorly written) XML parsers.  If you get XML rendering errors,
; try turning this on.  Default is No (off).
<p>CleanXML=<input name="CleanXML" type="text" value="<?= getSetting($settings['37'],"CleanXML") ?>"></p></p><p align="center"><input type="submit" name="Submit" value="Write .conf File" /></p></form>
<script type="text/javascript" language="javascript">
new Effect.Pulsate(document.getElementById('message'));
function ShowHelp()
new Effect.Appear(document.getElementById('1'));
new Effect.Appear(document.getElementById('2'));
new Effect.Appear(document.getElementById('41'));
new Effect.Appear(document.getElementById('3'));
new Effect.Appear(document.getElementById('4'));
new Effect.Appear(document.getElementById('5'));
new Effect.Appear(document.getElementById('6'));
new Effect.Appear(document.getElementById('7'));
new Effect.Appear(document.getElementById('8'));
new Effect.Appear(document.getElementById('9'));
new Effect.Appear(document.getElementById('10'));
new Effect.Appear(document.getElementById('11'));
new Effect.Appear(document.getElementById('12'));
new Effect.Appear(document.getElementById('13'));
new Effect.Appear(document.getElementById('14'));
new Effect.Appear(document.getElementById('15'));
new Effect.Appear(document.getElementById('16'));
new Effect.Appear(document.getElementById('17'));
new Effect.Appear(document.getElementById('18'));
new Effect.Appear(document.getElementById('19'));
new Effect.Appear(document.getElementById('20'));
new Effect.Appear(document.getElementById('21'));
new Effect.Appear(document.getElementById('22'));
new Effect.Appear(document.getElementById('23'));
new Effect.Appear(document.getElementById('24'));
new Effect.Appear(document.getElementById('25'));
new Effect.Appear(document.getElementById('26'));
new Effect.Appear(document.getElementById('27'));
new Effect.Appear(document.getElementById('28'));
new Effect.Appear(document.getElementById('29'));
new Effect.Appear(document.getElementById('30'));
new Effect.Appear(document.getElementById('31'));
new Effect.Appear(document.getElementById('32'));
new Effect.Appear(document.getElementById('33'));
new Effect.Appear(document.getElementById('34'));
new Effect.Appear(document.getElementById('35'));
new Effect.Appear(document.getElementById('36'));
new Effect.Appear(document.getElementById('37'));
new Effect.Appear(document.getElementById('38'));
new Effect.Appear(document.getElementById('39'));
new Effect.Appear(document.getElementById('40'));

function HideHelp()
new Effect.SwitchOff(document.getElementById('1'));
new Effect.SwitchOff(document.getElementById('2'));
new Effect.SwitchOff(document.getElementById('41'));
new Effect.SwitchOff(document.getElementById('3'));
new Effect.SwitchOff(document.getElementById('4'));
new Effect.SwitchOff(document.getElementById('5'));
new Effect.SwitchOff(document.getElementById('6'));
new Effect.SwitchOff(document.getElementById('7'));
new Effect.SwitchOff(document.getElementById('8'));
new Effect.SwitchOff(document.getElementById('9'));
new Effect.SwitchOff(document.getElementById('10'));
new Effect.SwitchOff(document.getElementById('11'));
new Effect.SwitchOff(document.getElementById('12'));
new Effect.SwitchOff(document.getElementById('13'));
new Effect.SwitchOff(document.getElementById('14'));
new Effect.SwitchOff(document.getElementById('15'));
new Effect.SwitchOff(document.getElementById('16'));
new Effect.SwitchOff(document.getElementById('17'));
new Effect.SwitchOff(document.getElementById('18'));
new Effect.SwitchOff(document.getElementById('19'));
new Effect.SwitchOff(document.getElementById('20'));
new Effect.SwitchOff(document.getElementById('21'));
new Effect.SwitchOff(document.getElementById('22'));
new Effect.SwitchOff(document.getElementById('23'));
new Effect.SwitchOff(document.getElementById('24'));
new Effect.SwitchOff(document.getElementById('25'));
new Effect.SwitchOff(document.getElementById('26'));
new Effect.SwitchOff(document.getElementById('27'));
new Effect.SwitchOff(document.getElementById('28'));
new Effect.SwitchOff(document.getElementById('29'));
new Effect.SwitchOff(document.getElementById('30'));
new Effect.SwitchOff(document.getElementById('31'));
new Effect.SwitchOff(document.getElementById('32'));
new Effect.SwitchOff(document.getElementById('33'));
new Effect.SwitchOff(document.getElementById('34'));
new Effect.SwitchOff(document.getElementById('35'));
new Effect.SwitchOff(document.getElementById('36'));
new Effect.SwitchOff(document.getElementById('37'));
new Effect.SwitchOff(document.getElementById('38'));
new Effect.SwitchOff(document.getElementById('39'));
new Effect.SwitchOff(document.getElementById('40'));
Return current item: phpSC