<?php
include("connect.php");
include("login_cookies.php");

while($admin = mysql_fetch_array($db_admin)) {

if ($_COOKIE["pass"] == $admin["kode"]) {

 if ($admin["admin"] == "1" || $admin["crew"] == "1") {

	if ( $_GET["opret"] == "true") {

if ($_POST[header] == "" || $_POST[thenew] == "" || $_POST[author] == "") {

header("Location: index.php?message=failure&errorid=27173");

} else {

$_POST[header] = str_replace("&Oslash;", "Ø", $_POST[header]);
$_POST[header] = str_replace("&øslash;", "ø", $_POST[header]);
$_POST[header] = str_replace("&Aring;", "Å", $_POST[header]);
$_POST[header] = str_replace("&aring;", "å", $_POST[header]);
$_POST[header] = str_replace("&Aelig;", "Æ", $_POST[header]);
$_POST[header] = str_replace("&aelig;", "æ", $_POST[header]);

$_POST[thenew] = str_replace("&Oslash;", "Ø", $_POST[thenew]);
$_POST[thenew] = str_replace("&øslash;", "ø", $_POST[thenew]);
$_POST[thenew] = str_replace("&Aring;", "Å", $_POST[thenew]);
$_POST[thenew] = str_replace("&aring;", "å", $_POST[thenew]);
$_POST[thenew] = str_replace("&Aelig;", "Æ", $_POST[thenew]);
$_POST[thenew] = str_replace("&aelig;", "æ", $_POST[thenew]);

$sql = "INSERT INTO `pytox_nyheder` VALUES ('', '1', '1', '$_POST[header]', '$_POST[thenew]', '$_COOKIE[user]')";

$result = mysql_query($sql, $conn) or die(mysql_error());
print $result;
}
} else {
?>
<form action="?site=Crewadminmakenews&opret=true" method="post">
Overskrift: <input type="text" name="header" />
<br />
Nyheden:
<br />
<textarea name="thenew" cols="35" rows="10"></textarea>
<br />
Forfatter: <input type="text" name="author" value="<?php print $_COOKIE["user"];?>" disabled="disabled">
<br />
<br />
<input type="submit" name="submit" value="Skriv!" class="submit" />
</form>
<?php
}

 }

}

}
?>