<?
/*
// +--------------------------------------------------------------------------+
// | Only for   http://board.bt-technik.com/                                  
// | Weitergabe an andere Boards ist Untersagt nur für privaten gebrauch
// |				By djbrocken
// +--------------------------------------------------------------------------+

 */
require "include/bittorrent.php";

dbconn(false);

loggedinorreturn();

$act = $_GET["act"];
// DELETE FORUM ACTION
if (get_user_class() < UC_MODERATOR) {
    stderr("Error", "Wo willst du Knilch eigendlich hin?? Das geht Dich hier garnix an!!");
    exit;
    } 

//ADD NEW RULE SECTION PAGE/FORM
if ($_GET["act"] == "newsect")
{
stdhead("Regel Hinzufügen");

begin_frame("Regeln Hinzufügen");

print("<form method=\"post\" action=\"rulesedit.php?act=addsect\">");
print("<table border=\"0\" cellspacing=\"0\" cellpadding=\"10\" align=\"center\">\n");
print("<tr><td>Title:</td><td><input style=\"width: 400px;\" type=\"text\" name=\"title\"/></td></tr>\n");
print("<tr><td style=\"vertical-align: top;\">Regeln:<br><a href=tags.php>[BB Tags]</a></td><td><textarea cols=90 rows=20 name=\"text\"></textarea><br>\n");
print("<br><a href=tags.php>[BB Tags]</a> sind <b>an</b></td></tr>\n");

print("<tr><td colspan=\"2\" align=\"center\"><input type=\"radio\" name='public' value=\"yes\" checked>Für Jeden sichtbar<input type=\"radio\" name='public' value=\"no\">&nbsp;User ab einer bestimmten Klasse  <input type=\"text\" name='class' value=\"0\" size=1></td></tr>\n");
print("<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Hinzufügen\" style=\"width: 60px;\"></td></tr>\n");
print("</table></form>");
end_frame();
stdfoot();
}
//ADD NEW RULE SECTION TO DATABASE
elseif ($_GET["act"]=="addsect"){
$title = sqlesc($_POST["title"]);
$text = sqlesc($_POST["text"]);
$public = sqlesc($_POST["public"]);
$class = sqlesc($_POST["class"]);
mysql_query("insert into rules (title, text, public, class) values($title, $text, $public, $class)") or sqlerr(__FILE__,__LINE__);
header("Refresh: 0; url=rulesedit.php");
}
//EDIT RULE
elseif ($_GET["act"] == "edit"){
$id = $_POST["id"];
$res = @mysql_fetch_array(@mysql_query("select * from rules where id='$id'"));
stdhead("Edit Rules");

begin_frame("Edit Rule Section");

print("<form method=\"post\" action=\"rulesedit.php?act=edited\">");
print("<table border=\"0\" cellspacing=\"0\" cellpadding=\"10\" align=\"center\">\n");
print("<tr><td>Title:</td><td><input style=\"width: 400px;\" type=\"text\" name=\"title\" value=\"$res[title]\" /></td></tr>\n");
print("<tr><td style=\"vertical-align: top;\">Regeln:<br><a href=tags.php>[BB Tags]</a></td><td><textarea cols=90 rows=20 name=\"text\">" . stripslashes($res["text"]) . "</textarea><br><a href=tags.php>[BB Tags]</a> sind <b>an</b></td></tr>\n");

print("<tr><td colspan=\"2\" align=\"center\"><input type=\"radio\" name='public' value=\"yes\" ".($res["public"]=="yes"?"checked":"").">Für jeden User<input type=\"radio\" name='public' value=\"no\" ".($res["public"]=="no"?"checked":"").">Ab einer Bestimmten Klasse: <input type=\"text\" name='class' value=\"$res[class]\" size=1>)</td></tr>\n");
print("<tr><td colspan=\"2\" align=\"center\"><input type=hidden value=$res[id] name=id><input type=\"submit\" value=\"Save\" style=\"width: 60px;\"></td></tr>\n");
print("</table>");
end_frame();
stdfoot();
}
//DO EDIT RULE, UPDATE DB
elseif ($_GET["act"]=="edited"){
$id = $_POST["id"];
$title = sqlesc($_POST["title"]);
$text = sqlesc($_POST["text"]);
$public = sqlesc($_POST["public"]);
$class = sqlesc($_POST["class"]);
mysql_query("update rules set title=$title, text=$text, public=$public, class=$class where id=$id") or sqlerr(__FILE__,__LINE__);
header("Refresh: 0; url=rulesedit.php");
}
else{
// STANDARD MENU OR HOMEPAGE ETC
$res = mysql_query("select * from rules order by id");
stdhead();

begin_frame("Regel Bearbeiten");
print("<br><table width=100% border=0 cellspacing=0 cellpadding=10>");
print("<tr><td align=center><a href=rulesedit.php?act=newsect>Neuen Regeln Thead Hinzufügen</a></td></tr></table>\n");

begin_frame("Theads Regeln");

while ($arr=mysql_fetch_assoc($res))
{
	begin_frame($arr[title]);
	print("<form method=post action=rulesedit.php?act=edit&id=><table width=95% border=0 cellspacing=0 cellpadding=>");
	print("<tr><td width=100%>");
	print(format_comment($arr["text"]));
	print("</td></tr><tr><td><input type=hidden value=$arr[id] name=id><input type=submit value='Bearbeiten'></td></tr></table></form>");
	end_frame();
}

echo "<br><br>";

end_frame();

echo "<br><br>";

end_frame();

stdfoot();
}
?>