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

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

if ($_COOKIE[pass] == $check_logon_com[kode] && $_COOKIE[com] == "1") {

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

///////////////////////////////////////////////////////////////////////////////////////////
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

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

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

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


mysql_query("UPDATE `pytox_community` SET `email` = '{$_POST[nEmail]}', `navn` = '{$replace[nNavn]}', `hjemmeside` = '{$_POST[nHttp]}', `text` = '{$replace[nText]}', `alder` = '{$_POST[nAge]}' WHERE `bruger` LIKE '{$_SESSION[nUser]}'");

print "Din bruger er nu rettet...";

} else if ($_GET["edit"] == "password") {

$_SESSION[ptpass] = $check_logon_com[kode];
?>
<form action="?site=Edituser&amp;editing=password" method="post">
Nuværende password:
<br />
<input type="password" name="ptpass" />
<br />
<br />
Nyt password:
<br />
<input type="password" name="newpass1" />
<br />
Gentag nyt password:
<br />
<input type="password" name="newpass2" />
<br />
<br />
<input type="submit" value="Ændr!" name="submit" class="submit" />
</form>
<?php

} else if ($_GET[editing] == "password") {

if ($_POST[ptpass] != "" || $_POST[newpass1] != "" || $_POST[newpass2] != "") {

	if (md5($_POST[ptpass]) == $check_logon_com["kode"]) {
		if ($_POST[newpass1] ==  $_POST[newpass2]) {
		  if (strlen($_POST[newpass1]) >= 6 && strlen($_POST[newpass2])) {
$dennykode = md5($_POST[newpass1]);
		mysql_query("UPDATE `pytox_community` SET  `kode` = '{$dennykode}' WHERE `bruger` LIKE '{$_COOKIE[user]}' LIMIT 1");

		$tjek_edit_pass = mysql_query("SELECT * FROM `pytox_community` WHERE `bruger` LIKE '{$_COOKIE[user]}' ORDER BY `bruger` ASC");
		while ($tjekking_tjek = mysql_fetch_array($tjek_edit_pass)) {

			if ($tjekking_tjek[kode] == $_POST[newpass1]) {
				print "Du har nu ændret dit password!";
			} else {
				print "Der skete fa'me en fejl!";
			}
		}

		  } else {
			print "Dit password skal bestå af mindst 6 tegn!";
		  }
		} else {
			print "De to passwords er ens!<br />";
		}
	} else {
		print "Dit rigtige password stemmer ikke overens med det du skrev!<br />";
	}

} else {
print "Én eller flere af felterne blev ikke udfyldt!";
}

} else if ($_GET["edit"] == "gb") {

$get_gb = mysqL_query("SELECT * FROM `pytox_gb` WHERE `til` LIKE '{$_COOKIE[user]}' AND `show` LIKE '1' ORDER BY `id` DESC");

?>
<script type="text/javascript">

function tag(id) {
document.getElementById(id).style.display = "inline";
}

</script>
Gæstebogs-administration..
<br />
<br />
<?php
if ($_GET["action"] == "delete" && isset($_GET["id"])) {

$tjek_gb = mysqL_query("SELECT * FROM `pytox_gb` WHERE `til` LIKE '{$_COOKIE[user]}' AND `show` LIKE '1' AND `id` LIKE '$_GET[id]' ORDER BY `id` DESC");

while ($tjek = mysql_fetch_array($tjek_gb)) {
 if ($tjek[til] == $_COOKIE[user]) {

mysql_query("UPDATE `pytox_gb` SET `show` = '0' WHERE `id`='{$_GET[id]}' LIMIT 1") or die(mysql_error());

//header("Location: index.php?site=Edituser&edit=gb");

 } else {
 print "Beskeden er ikke til dig!";
  }
}
} else {
///////////////////////
?>
<table class="blackborder" style="border-bottom:0px;background-color:#EEE;color:#000;width:500px;" cellpadding="2" cellspacing="1">
<?php
if (mysql_num_rows($get_gb) == 0) {
?>
 <tr>
  <td>
Der er ingen beskeder i gæstebogen
  </td>
 </tr>
<?php
} else {

while ($tag = mysql_fetch_array($get_gb)) {

?>
 <tr>
  <td style="border-bottom:1px dashed #000;" align="top">
Fra: <a href="?site=Com.users&user=<?php print $tag[fra];?>"><?php print $tag[fra];?></a>, <?php print $tag[tid];?> - <a href="?site=Edituser&edit=gb&action=delete&id=<?php print $tag[id];?>">Slet!</a>
<br />
<a href="javascript:void(0)" onClick="tag('t<?php print $tag[id];?>')">Se beskeden</a>
<br />
<br />
<div id="t<?php print $tag[id];?>" class="blackborder" style="display:none;">
<?php print $tag[besked];?>
</div>
  </td>
 </tr>
<?php
}// afslutter while
}//afslutter tjek om der er beskeder
?>
</table>
<?php
///////////////////////
}

} else if ($_GET['edit'] == "top10") {

$getexisting = mysql_query("SELECT * FROM `pytox_community` WHERE `bruger` LIKE '{$_COOKIE[user]}' LIMIT 1") or die(mysql_error());

while ($exist = mysql_fetch_array($getexisting)) {
?>
<strong>Administrér top 10</strong>
<br />
<i><strong>OBS:</strong> Top 10-listen tælles som ugyldig, hvis oferskrift-feltet er tomt!</i>
<br />
<br />
<form action="?site=Edituser&amp;edit=top10&amp;editing=yes" method="post">
<table class="blackborder" style="width:200px;" cellpadding="1" cellspacing="0">
 <tr>
  <td>
<strong>Overksrift:</strong>
  </td>
  <td>
<input type="text" name="header" value="<?=$exist[topheader]?>" />
  </td>
 </tr>
<?php
while($i <= 9) {
$i++;
?>
 <tr>
  <td>
<strong>Punkt <?=$i?></strong>
  </td>
  <td>
<input type="text" name="top<?=$i?>" value="<?=$exist['top'.$i]?>" />
  </td>
 </tr>
<?php
}
?>
 <tr>
  <td>
  <input type="submit" class="submit" value="Sådan!" />
  <input type="hidden" name="<?=md5($_COOKIE[user].$_COOKIE[pass])?>" value="<?=md5($_COOKIE[pass].$_COOKIE[user])?>" />
  </td>
 </tr>
</table>
</form>
<br />
<br />
<?php
}
if ($_GET['editing'] == "yes") {

if ($_POST[md5($_COOKIE[user].$_COOKIE[pass])] == md5($_COOKIE[pass].$_COOKIE[user])) {

mysql_query("UPDATE `pytox_community` SET `topheader` = '$_POST[header]', `top1` = '{$_POST[top1]}', `top2` = '{$_POST[top2]}', `top3` = '{$_POST[top3]}', `top4` = '{$_POST[top4]}', `top5` = '{$_POST[top5]}', `top6` = '{$_POST[top6]}', `top7` = '{$_POST[top7]}', `top8` = '{$_POST[top8]}', `top9` = '{$_POST[top9]}', `top10` = '{$_POST[top10]}' WHERE `id` = $useridentity LIMIT 1") or die(mysql_error());

header("Location: index.php?site=Edituser&msg=top10good");

} else {
print "Der opstod en fejl! Du kom sandsynligvis ikke fra \"Administrér top 10\"..";
}

}

} else {

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

$_SESSION[nUser] = $user[bruger];

if ($_GET['msg'] == "top10good") {
print "<strong>Din Top 10 blev rettet!</strong><br /><br />";
}
?>
<a href="?site=Com.users&amp;userid=<?=$user[id];?>">Min bruger</a>
<br />
<br />
<a href="?site=Edituser&amp;edit=top10">Administrér top 10</a>
<br />
<br />
<a href="?site=Edituser&amp;edit=gb">G&aelig;stebogs-administration</a>
<br />
<br />
<a href="?site=Edituser&amp;edit=password">Ændr mit password</a>
<br />
<br />
Dine Pycoins: <a href="?site=Support&amp;support=pycoins"><?php print $user[coins];?></a>
<br />
<br />
<form action="?site=Edituser&editing=true" method="post">
Bruger:
<br />
<input type="text" name="nUser" value="<?php print $user[bruger]; ?>" disabled="disabled" />
<br />
Dit navn:
<br />
<input type="text" name="nNavn" value="<?php print $user[navn]; ?>" />
<br />
Din email adresse:
<br />
<input type="text" name="nEmail" value="<?php print $user[email]; ?>" />
<br />
Din hjemmeside:
<br />
<input type="text" name="nHttp" value="<?php print $user[hjemmeside]; ?>" />
<br />
Din alder:
<br />
<input type="text" name="nAge" value="<?php print $user[alder]; ?>" />
<br />
Fritekst:
<br />
<textarea cols="15" rows="7" name="nText"><?php print $user[text]; ?></textarea>
<br />
<br />
<i><div class="copy"><?=$user[timer]?></div></i>
<br />
<br />
<input type="submit" name="nSubmit" value="Ret!" class="submit" />
</form>
<?php
}

}


///////////////////////////////////////////////////////////////////////////////////////////
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\


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

}//slutter if om man er logget ind

}//slutter while

?>