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

$time = date("H:i:s d/m - Y");

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

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

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

	if ($admin["exist"] == "1") {

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

if ($_POST["message"] != "") {

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

mysql_query("INSERT INTO `pytox_crewchat` (`id`, `ip`, `user`, `message`, `time`) VALUES ('', '{$_SERVER[REMOTE_ADDR]}', '{$_COOKIE[user]}', '{$replace[message]}', '{$tid}')") or die(mysql_error());

header("Location: index.php?site=Crewchat");

} else {
print "Du mangler at skrive en besked!";
}

} else {

?>
Under opbygning!
<br />
<br />
<form action="?site=Crewchat&new=true" method="post">
Bruger: <input type="text" value="<?php print $_COOKIE["user"];?>" disabled="disabled" />
<br />
Besked: <textarea class="small" name="message" style="width:310px;height:15px;"></textarea>
<br />
<input type="submit" name="submit" value="Send besked" class="submit" />
</form>
<br />
<br />
<table cellpadding="2" cellspacing="0" class="blackborder" style="width:480px;">
<?php
$crewchat = mysql_query("SELECT * FROM `pytox_crewchat` ORDER BY `id` DESC");

while($chat = mysql_fetch_array($crewchat)) {
?>
 <tr>
 <!-- style="border-bottom : 1px dashed #000;" -->
  <td>
<?php
//$userid = mysql_query("SELECT * FROM `pytox_community` WHERE `bruger` LIKE '{$chat[user]}' LIMIT 1");

//while ($id = mysql_fetch_array($userid)) {
?>
<strong><?php print $chat[user];?></strong> - <?php print $chat[time];?>
<?php
/*<a href="?site=Com.user&amp;userid=<?=$id[id];?>"><?php print $chat[user];?></a> - <?php print $chat[time];?>*/
?>
<br />
<?php print $chat[message];?>
<?php
//}
?>
<br />
  </td>
 </tr>
<?php
}
?>
</table>
<?php	
}

	} else {
	header("Location: index.php?message=failure&errorid=60065");
	}//slutter exist-tjek

 }//slutter tjek om man er admin eller crew
}//slutter cookie-tjek

}//slutter while
?>