<?php
/*
Fretsweb - A Frets on Fire chart server
Copyright (C) 2009, Daan Sprenkels
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once "common.php";
require_once 'log.php';
require_once 'langnames.php';
//Login Test
session_start();
if($_SESSION['in'] < 2)
{
header('location: login.php?need=admin');
die();
}
include_once "log.php";
session_start();
$info = '';
if($_GET['change'] == 1)
$info = "<p class=\"info\">Configuration saved</p>";
if(isset($_POST['saver']))
{
//Get the old configuration
$sql = "SELECT `name`, `value` FROM `contest_config`";
$query = mysql_query($sql);
while($row = mysql_fetch_assoc($query))
$oldconfig[$row['name']] = $row['value'];
if(!isset($_POST['allowallplayers']))
$_POST['allowallplayers'] = 'false';
if(!isset($_POST['showuploadurl']))
$_POST['showuploadurl'] = 'false';
if(!isset($_POST['allowjoinrequests']))
$_POST['allowjoinrequests'] = 'false';
if(!isset($_POST['allowsongrequests']))
$_POST['allowsongrequests'] = 'false';
if(!isset($_POST['allowforum']))
$_POST['allowforum'] = 'false';
unset($_POST['saver']);
if(strlen($_POST['moderator_password']) < 4)
{
unset($_POST['moderator_password'], $_POST['moderator_passwordc']);
$OK = true;
}
else
{
if($_POST['moderator_password'] == $_POST['moderator_passwordc'])
$OK = true;
else
$OK = false;
}
if($OK)
{
//Send query's for each POST value
foreach( $_POST as $name => $value )
{
$sql = "UPDATE `contest_config` SET `value` = '$value' WHERE `name` = '$name'";
mysql_query($sql);
}
//Get the new configuration
$sql = "SELECT `name`, `value` FROM `contest_config`";
$query = mysql_query($sql);
while($row = mysql_fetch_assoc($query))
$newconfig[$row['name']] = $row['value'];
$feedadd = '';
if($oldconfig['contest_points'] != $newconfig['contest_points'])
$feedadd .= "The points system has been editted to {$_POST['contest_points']}.\n";
if($oldconfig['allowallplayers'] != $newconfig['allowallplayers'])
if($newconfig['allowallplayers'] == 1)
$feedadd .= "From now on, everyone is allowed. Just upload, and you'll be automaticly added to the database.\n";
else
$feedadd .= "From now on, not everyone is allowed anymore. If you upload your scores, you won't be added to the database.\n";
if($oldconfig['allowjoinrequests'] != $newconfig['allowjoinrequests'])
if($newconfig['allowjoinrequests'] == 1)
$feedadd .= "You can now use the join option, this is used to join Fretsweb.\n";
else
$feedadd .= "The join function is disabled right now. You cannot join Fretsweb anymore.\n";
if($oldconfig['language'] != $newconfig['language'])
$feedadd .= "The default language has been changed to {$newconfig['language']}. If you don't understand this language, then choose another language at the bottom of the page. You need to have your cookies enabled to do that.\n";
if($oldconfig['allowsongrequests'] != $newconfig['allowsongrequests'])
if($newconfig['allowsongrequests'] == 1)
$feedadd .= "Now you can request songs: Choose request songs at the bottom of the screen.\n";
else
$feedadd .= "Now you cannot request songs anymore. The administrator probably thought we had enough songs.\n";
if($oldconfig['allowforum'] != $newconfig['allowforum'])
if($newconfig['allowforum'] == 1)
$feedadd .= "The forum is enabled. You can add your own post at forum.\n";
else
$feedadd .= "The forum is disabled. You cannot post anymore.\n";
if(strlen($feedadd) > 3)
{
cfeed('Configuration change', $feedadd, 'configchange');
}
//Link not needed anymore
clog('Configuration changed');
mysql_close($db_link);
//Refresh the page, you won't notice it while in browser.
header('location: ' . $_SERVER['PHP_SELF'] . '?change=1');
die();
}
else
{
$info = 'Moderator passwords are not identical.';
}
}
?>
<html>
<head>
<title>Configuration</title>
<link href="../css.php" rel="stylesheet" type="text/css" />
<link href="../images/favicon.png" rel="icon">
</head>
<body>
<center>
<h2>Edit Configuration</h2>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">
<?php echo "<p class=\"info\" align=\"center\">$info</p>"; ?>
<p title="This title will appear above your main page.">Title: <input type="text" name="title" value="<?php echo $title; ?>" maxlength="500"></p>
<p title="The language of Fretsweb">Language: <select name="language"><?php
$language_options = scandir('../lang');
foreach($language_options as $language_option)
if(substr($language_option, -4) == '.php')
if(substr($language_option, 0, -4) == $language)
echo '<option value="'.substr($language_option, 0, -4).'" selected>' . $langname[substr($language_option, 0, -4)] . '</option>';
else
echo '<option value="'.substr($language_option, 0, -4).'">' . $langname[substr($language_option, 0, -4)] . '</option>';
?></select></p>
<p title="The points list, seperate the numbers with comma's. (,)">Points list: <input type="text" name="contest_points" value="<?php echo implode(',' , $ContestPoints ); ?>" maxlength="500">
</p>
<p title="Allow all players. (Add them automaticly to the database.) NOTE: If allow all players AND enable join requests is turned on, instead of automaticly adding the player, a join request will be written.">Allow all players: <input type="checkbox" name="allowallplayers" value="true"<?php if($allowallplayers) echo ' checked'; ?>>
</p>
<p title="Allow join requests. (join.php is enabled) The admin can accept them, or deny them in the Join requests panel">Enable join requests: <input type="checkbox" name="allowjoinrequests" value="true"<?php if($allowjoinrequests) echo ' checked'; ?>>
</p>
<p title="Allow song requests. (asksong.php is enabled) The admin can accept them, or deny them in the Song requests panel">Enable song requests: <input type="checkbox" name="allowsongrequests" value="true"<?php if($allowsongrequests) echo ' checked'; ?>>
</p>
<p title="Show the uploadurl on the main pages.">Show uploadurl: <input type="checkbox" name="showuploadurl" value="true"<?php if($showuploadurl) echo ' checked'; ?>>
</p>
<p title="Enable the forum page for use.">Enable forum: <input type="checkbox" name="allowforum" value="true"<?php if($allowforum) echo ' checked'; ?>>
<p title="This is the feed option.">RSS feed: <select name="feed">
<option value="9"<?php if($feed == 9) echo ' selected'; ?>>Only show user messages</option>
<option value="7"<?php if($feed == 7) echo ' selected'; ?>>Also show special messages. (Like: Yea, we've got 25 songs!)</option>
<option value="6"<?php if($feed == 6) echo ' selected'; ?>>Also show configuration changes. (Like: forum is disabled.)</option>
<option value="5"<?php if($feed == 5) echo ' selected'; ?>>Also show song changes. </option>
<option value="4"<?php if($feed == 4) echo ' selected'; ?>>Also show chart overviews. (Like: K0en took the lead with 324 points)</option>
<option value="3"<?php if($feed == 3) echo ' selected'; ?>>Also show player updates. (Like: added player Daan)</option>
<option value="2"<?php if($feed == 2) echo ' selected'; ?>>Also show forum commits.</option>
<option value="1"<?php if($feed == 1) echo ' selected'; ?>>Also show every uploaded score.</option>
<option value="0"<?php if($feed == 0) echo ' selected'; ?>>Disable feed</option>
</select>
</p>
<p>
Moderator password (twice):
<input type="password" name="moderator_password">
<input type="password" name="moderator_passwordc">
</p>
<p>
<input type="submit" name="saver" value="Save">
<input type="reset" value="Reset">
</p>
</form>
<p><b><a href="index.php">Back to main administration panel</a></b><p>
</center>
</body>
</html>