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

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

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

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

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

if ($_GET["deactivate"] == "true" && isset($_GET[id])) {

mysql_query("UPDATE `pytox_community` SET `exist` = '0' WHERE `id` LIKE '{$_GET[id]}'");

print "Brugeren er nu deaktiveret og kan ikke logge ind!<br /><a href=\"?site=Userlist\">Tilbage til brugerlisten</a>";

} else if ($_GET["activate"] == "true" && isset($_GET[id])) {

mysql_query("UPDATE `pytox_community` SET `exist` = '1' WHERE `id` LIKE '{$_GET[id]}'");

print "Brugeren er nu aktiveret igen og kan logge ind igen!<br /><a href=\"?site=Userlist\">Tilbage til brugerlisten</a>";

} else if ($_GET["choose"] == "edituser" && isset($_GET["userid"])) {

	if ($_POST["dropstatus"] == "Normal") {
mysql_query("UPDATE `pytox_community` SET `admin` = '0', `crew` = '0' WHERE `id` LIKE '{$_GET[userid]}'");
print "Brugeren er nu <i>Normal</i>";
	} else if ($_POST["dropstatus"] == "Crewmedlem") {
mysql_query("UPDATE `pytox_community` SET `admin` = '0', `crew` = '1' WHERE `id` LIKE '{$_GET[userid]}'");
print "Brugeren er nu <i>Crewmedlem</i>";
	} else if ($_POST["dropstatus"] == "Redaktør") {
mysql_query("UPDATE `pytox_community` SET `admin` = '2', `crew` = '1' WHERE `id` LIKE '{$_GET[userid]}'");
print "Brugeren er nu <i>Redaktør</i>";
	} else if ($_POST["dropstatus"] == "Administrator") {
mysql_query("UPDATE `pytox_community` SET `admin` = '1', `crew` = '0' WHERE `id` LIKE '{$_GET[userid]}'");
print "Brugeren er nu <i>Administrator</i>";
	} else if ($_POST["dropstatus"] == "both") {
mysql_query("UPDATE `pytox_community` SET `admin` = '1', `crew` = '1' WHERE `id` LIKE '{$_GET[userid]}'");
print "Brugeren er nu <i>Crewmedlem+Administrator</i>";
	} else {
print "INGEN ændring blev foretaget!!";
	}

?>
<br />
<a href="?site=Userlist">Tilbage til brugerlisten</a>
<?php

} else {
?>
<table class="blackborder" cellpadding="0" cellspacing="1" style="width:750px;">
 <tr>
  <td align="left" style="width:150px;">
<strong>Bruger:</strong>
  </td>
  <td align="center" style="width:300px;">
<strong>Mulighed:</strong>
  </td>
  <td align="right" style="width:250px;">
<strong>Status:</strong>
  </td>
 </tr>
<?php
while($user = mysql_fetch_array($db_users)) {

print "<tr>";

if ($user[exist] == "1") {
print "<td align=\"left\" style=\"width:150px;border-bottom:1px solid #000;\"><a href=\"?site=Com.users&userid=".$user[id]."\" style=\"color:#063;\">".$user[bruger]."</a></td>";
} else if ($user[exist] == "0") {
print "<td align=\"left\" style=\"width:150px;border-bottom:1px solid #000;\"><a href=\"?site=Com.users&userid=".$user[id]."\" style=\"color:#F00;\">".$user[bruger]."</a></td>";
} else {
print "ERROR!";
}

if ($user[exist] == "1") {
print "<td align=\"center\" style=\"width:300px;border-bottom:1px solid #000;color:#00F;\"><a href=\"?site=Userlist&amp;deactivate=true&amp;id=".$user[id]."\" style=\"color:#063;\">Deaktiver denne bruger</a></td>";
} else if ($user[exist] == "0") {
print "<td align=\"center\" style=\"width:300px;border-bottom:1px solid #000;color:#F00;\"><a href=\"?site=Userlist&amp;activate=true&amp;id=".$user[id]."\" style=\"color:#F00;\">Aktiver denne bruger</a></td>";
} else {
print "ERROR!";
}

if ($user[exist] == "1") {
$dropstatus = "#063";
} else if ($user[exist] == "0") {
$dropstatus = "#F00";
} else {
$dropstatus = "#000";
}

?>
<td align=\"right\" style=\"width:300px;border-bottom:1px solid #000;\">
<form action="?site=Userlist&amp;choose=edituser&amp;userid=<?=$user[id]?>" method="post">
<?php
if ($user[admin] == "1" && $user[crew] == "1") {
?>
<select style="color:<?=$dropstatus?>;" name="dropstatus">
<option>Normal</option>
<option>Crewmedlem</option>
<option>Redaktør</option>
<option>Administrator</option>
<option value="both" selected="selected">Crewmedlem+Administrator</option>
</select>
<?php
} else if ($user[crew] == "1" && $user[admin] == "0") {
?>
<select style="color:<?=$dropstatus?>;" name="dropstatus">
<option>Normal</option>
<option selected="selected">Crewmedlem</option>
<option>Redaktør</option>
<option>Administrator</option>
<option value="both">Crewmedlem+Administrator</option>
</select>
<?php
} else if ($user[admin] == "1") {
?>
<select style="color:<?=$dropstatus?>;" name="dropstatus">
<option>Normal</option>
<option>Crewmedlem</option>
<option>Redaktør</option>
<option selected="selected">Administrator</option>
<option value="both">Crewmedlem+Administrator</option>
</select>
<?php
} else if ($user[admin] == "2") {
?>
<select style="color:<?=$dropstatus?>;" name="dropstatus">
<option>Normal</option>
<option>Crewmedlem</option>
<option selected="selected">Redaktør</option>
<option>Administrator</option>
<option value="both">Crewmedlem+Administrator</option>
</select>
<?php
} else {
?>
<select style="color:<?=$dropstatus?>;" name="dropstatus">
<option selected="selected">Normal</option>
<option>Crewmedlem</option>
<option>Redaktør</option>
<option>Administrator</option>
<option value="both">Crewmedlem+Administrator</option>
</select>
<?php
}
?>
-<input type="submit" value="Ændr" name="submitid" class="submit" /></form>
<?php

print "</tr>";
}
?>
</table>
<?php
}

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

 }

}

}

?>