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

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

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

if ($_POST["besked"] != "" && $_POST["submit"] == "Skriv!" && isset($_COOKIE[user])) {

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

mysql_query("INSERT INTO `pytox_tagwall` (`id`, `ip`, `user`, `message`, `time`) VALUES ('', '$_SERVER[REMOTE_ADDR]', '$_COOKIE[user]', '$replace[besked]', '$time')");

header("Location: index.php?site=Tagwall&message=newtagcorrect");
} else {
header("Location: index.php?message=failure&errorid=27173");
}
} else {
?>
Velkommen til tagwallen.
<br />
<br />
<script type="text/javascript">
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////

function tagwall(choose) {
 if (choose == 'show') {
document.getElementById('tagwallShow').style.display = 'none';
document.getElementById('tagwallHide').style.display = 'block';
document.getElementById('beskedboks').style.display = 'block';
 } else if (choose == 'hide') {
document.getElementById('tagwallShow').style.display = 'block';
document.getElementById('tagwallHide').style.display = 'none';
document.getElementById('beskedboks').style.display = 'none';
 }
}
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
</script>
<a href="javascript:tagwall('show')" title="Skriv besked" id="tagwallShow" style="width:40px;">Skriv</a>
<a href="javascript:tagwall('hide')" title="Skjul besked-boksen" id="tagwallHide" style="display:none;width:150px;">Skjul besked-boksen</a>
<br />
<table class="blackborder" id="beskedboks" cellpadding="0" cellspacing="0" style="display:none;">
 <tr>
  <td>
<div class="small"><i>OBS: Du skal være logget på communityet før du kan skrive, ellers vil formularen ikke blive vist!</i></div>
<br />
<?php

while($check_logon_com = mysql_fetch_array($db_community)) {

if ($_COOKIE[pass] == md5($check_logon_com[kodeord]) && $_COOKIE[com] == "1") {
?>
<strong>INGEN BILLEDER I TAGWALLEN! DET VIL MEDFØRER DEAKTIVATION!</strong>
<br />
<form action="?site=Tagwall&opret=true" method="post">
Brugernavn: <input type="text" name="username" value="<?php print $_COOKIE[user]; ?>" disabled="disabled" />
<br />
Besked:
<br />
<textarea cols="30" rows="10" name="besked"></textarea>
<br />
<br />
<input type="submit" name="submit" value="Skriv!" class="submit" />
</form>
<?php
} else if (mysql_num_rows($db_community) == 0) {
print "Du skal være logget på, før du kan se communityet!";
} else {
print "Du skal være logget på, før du kan se communityet!";
}
}
?>
  <td>
 </tr>
</table>
<br />
<?php
}
?>
<?php

if (mysql_num_rows($tagwall_numbers) == 0) {
$antal = "ingen";
$text = "beskeder";
} else if (mysql_num_rows($tagwall_numbers) == 1) {
$antal = mysql_num_rows($tagwall_numbers);
$text = "besked";
} else if (mysql_num_rows($tagwall_numbers) > 1) {
$antal = mysql_num_rows($tagwall_numbers);
$text = "beskeder";
}

print "<div class=\"small\" style=\"font-weight:bold;\">Der er i øjeblikket ".$antal." ".$text." i tagwallen.</div><br />";
?>
<br />
<input type="button" name="Update" value="Opdater tagwall" onClick="document.location.reload();" class="submit" />
<br />
<br />
<?php

while($tagwall = mysql_fetch_array($db_tagwall)) {
?>
<div class="tag">
<strong>
<?php
$tagwall[message] = str_replace(":S", "<img src=\"../gfx/smileys/S.GIF\" alt=\":S\" />", $tagwall[message]);
$tagwall[message] = str_replace(":D", "<img src=\"../gfx/smileys/D.gif\" alt=\":D\" />", $tagwall[message]);
$tagwall[message] = str_replace(":(", "<img src=\"../gfx/smileys/(.gif\" alt=\":(\" />", $tagwall[message]);
$tagwall[message] = str_replace(":)", "<img src=\"../gfx/smileys/).gif\" alt=\":)\" />", $tagwall[message]);
$tagwall[message] = str_replace(":'(", "<img src=\"../gfx/smileys/'(.gif\" alt=\":'(\" />", $tagwall[message]);
$tagwall[message] = str_replace(":P", "<img src=\"../gfx/smileys/P.GIF\" alt=\":P\" />", $tagwall[message]);

$tagwall[message] = str_replace(":s", "<img src=\"../gfx/smileys/S.GIF\" alt=\":S\" />", $tagwall[message]);
$tagwall[message] = str_replace(":d", "<img src=\"../gfx/smileys/D.gif\" alt=\":D\" />", $tagwall[message]);
$tagwall[message] = str_replace(":(", "<img src=\"../gfx/smileys/(.gif\" alt=\":(\" />", $tagwall[message]);
$tagwall[message] = str_replace(":)", "<img src=\"../gfx/smileys/).gif\" alt=\":)\" />", $tagwall[message]);
$tagwall[message] = str_replace(":'(", "<img src=\"../gfx/smileys/'(.gif\" alt=\":'(\" />", $tagwall[message]);
$tagwall[message] = str_replace(":p", "<img src=\"../gfx/smileys/P.GIF\" alt=\":P\" />", $tagwall[message]);

$prevelegier = mysql_query("SELECT * FROM `pytox_community` WHERE `bruger` LIKE '{$tagwall[user]}' LIMIT 1");

while($tambu = mysql_fetch_array($prevelegier)) {

if ($tambu[admin] == "1") {
$style = "color:#123456;";
} else if ($tambu[crew] == "1") {
$style = "color:#FFF;";
} else {
$style = "color:#000;";
}
}


print "<a style=\"".$style."\" href=\"?site=Com.users&amp;user=".$tagwall[user]."\">".$tagwall[user]."</a> - ".$tagwall[time];
?>
</strong>
<br />
<?php
$bannede = mysql_query("SELECT * FROM `pytox_community` WHERE `bruger` LIKE '{$tagwall[user]}' LIMIT 1");

while($banned = mysql_fetch_array($bannede)) {

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

$tag = strip_tags($tagwall[message], "<b><strong><u><i><img>");

} else if ($banned[exist] == "0") {

$tag = "Denne bruger er blevet deaktiveret, og hans beskeder bliver ikke vist.";
}
}

print $tag;
?>
</div>
<br />
<br />
<?php
}
?>