<?php ob_start();?>
<?php
$get_user_check = mysqL_query("SELECT * FROM `pytox_community` WHERE `id` LIKE '{$_GET[userid]}' LIMIT 1");
$get_user = mysqL_query("SELECT * FROM `pytox_community` WHERE `id` LIKE '{$_GET[userid]}' LIMIT 1");

$userid = mysql_query("SELECT * FROM `pytox_community` WHERE `id` LIKE '{$_GET[userid]}' LIMIT 1");
while ($id = mysql_fetch_array($userid)) {
$get_gb = mysqL_query("SELECT * FROM `pytox_gb` WHERE `til` LIKE '{$id["bruger"]}' AND `show` LIKE '1' ORDER BY `id` DESC");
}


if (mysql_num_rows($get_user_check) == 0) {

print "<strong>Brugeren med id'et ".$_GET[userid]." kunne ikke findes i databasen!</strong>";

} else {
?>
<a href="?site=Com.users&amp;userid=<?php print $_GET[userid];?>">Brugerens-info</a> - <a href="?site=Com.users&amp;userid=<?php print $_GET[userid];?>&amp;choose=gb">Gæstebog</a> - <a href="?site=Pmail&amp;emne=Intet emne&amp;touser=<?php print $_GET[userid];?>">Send en Pmail</a>
<br />
<br />
<?php
while($db_users = mysql_fetch_array($get_user)) {

if ($_GET["choose"] == "gb") {
?>
<strong>Gæstebog</strong>
<br />
<br />
<a href="javascript:void(0)" onClick="addtag()">Vis/skjul beskedfelt</a>
<br />
<br />
<div id="addtag" class="blackborder" style="display:none;padding:2px;width:350px;">
<?php

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

if ($_COOKIE[pass] == md5($check_logon_com[kodeord]) && $_COOKIE[com] == "1") {
?>
<form action="?site=Com.users&amp;userid=<?php print $_GET[userid];?>&amp;choose=addtag" method="post">
Besked:
<br />
<textarea name="message" cols="30" rows="7"></textarea>
<br />
<br />

<!-- VALIDATE! -->
<?php
$kode[1] = mt_rand(99999, 0);
$kode[2] = mt_rand(99999, 0);
$kode[3] = mt_rand(99999, 0);

if (strlen($kode[1]) == 5) {
$sikkerhedskode = $kode[1];

} else if (strlen($kode[2]) == 5) {
$sikkerhedskode = $kode[2];

} else if (strlen($kode[3]) == 5) {
$sikkerhedskode = $kode[3];

} else {
$sikkerhedskode = "ERROR!";

}

if ($_GET["func"] == "" && $_GET["new"] == "") {
							if ($sikkerhedskode == "ERROR!") {
$_SEESION[tjekcode] = "1615165151561561651651";
							} else {
$_SESSION[tjekcode] = $sikkerhedskode;
							}
} else {
$_SESSION[tjekcode] = "";
}
?>
<strong>Valideringskode:</strong>
<br />
<?php
if ($sikkerhedskode == "ERROR!") {
print "DER SKETE EN FEJL! \"ERROR!\" ER IKKE EN GYLDIG SIKKERHEDSKODE. Opdater eller prøv igen senere.<br />";
}
?>
<img class="blackborder" src="../../img.php?text=<?php print $sikkerhedskode; ?>" alt="Loading..." title="<?php print $sikkerhedskode; ?>" align="middle" /> = <input type="text" name="validate" />
<!-- VALIDATE -->
<br />
<br />
<input type="submit" name="submit" value="Skriv" class="submit" onClick="goShow('writingto')" />
<br />
<div id="writingto" style="display:none;">
Skriver...
</div>
</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!";
}
}
?>
</div>
<br />
<br />
<table class="blackborder" style="border-bottom:1px solid #000;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)) {

$userid = mysql_query("SELECT * FROM `pytox_community` WHERE `bruger` LIKE '{$tag[fra]}' LIMIT 1");

	while ($taguid = mysql_fetch_array($userid)) {
?>
 <tr>
  <td style="border-bottom:1px dashed #000;" align="top">
Fra: <a href="?site=Com.users&userid=<?php print $taguid[id];?>"><?php print $tag[fra];?></a>, <?php print $tag[tid];?>
<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
$userrights = mysql_query("SELECT * FROM `pytox_community` WHERE `bruger` LIKE '{$tag[fra]}' LIMIT 1");
while ($rights = mysql_fetch_array($userrights)) {
 if ($rights[admin] == "1") {
print $tag[besked];
 } else {
print strip_tags($tag[besked], "<strong><b><u><i>");
 }
}
?>
</div>
<br />
<br />
  </td>
 </tr>
<?php
	}
}// afslutter while
}//afslutter tjek om der er beskeder
?>
</table>
<?php
} else if ($_GET["choose"] == "addtag") {

//print "Stadium 1";

$community = mysql_query("SELECT * FROM `pytox_community` WHERE `bruger` LIKE '{$_COOKIE[user]}' ORDER BY `bruger` ASC") or die(mysql_error());

while($useren = mysql_fetch_array($community)) {

//print "Stadium 2";

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

  if ($_POST["validate"] != $_SESSION[tjekcode]) {
print "<div style=\"color:#F00;\">Valideringskoden er ugyldig!</div>";
  } else {

//print "Stadium 3";

$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"]);

$useridget = mysql_query("SELECT * FROM `pytox_community` WHERE `id` LIKE '{$_GET[userid]}' LIMIT 1") or die(mysql_error());

 while ($imdu = mysql_fetch_array($useridget)) {

//print "Stadium \"Inside\"";

mysql_query("INSERT INTO `pytox_gb` (`id`, `ip`, `show`, `fra`, `til`, `tid`, `besked`) VALUES ('', '{$_SERVER[REMOTE_ADDR]}', '1', '{$_COOKIE[user]}', '{$imdu[bruger]}', '{$tid}', '{$replace[message]}')") or die(mysql_error());

 }

$location = "Location: index.php?site=Com.users&userid=".$_GET[userid]."&choose=gb";

print "Beskeden er oprettet gæstebogen, der ejes af brugeren med id'et: ".$_GET[userid].".";

header($location);
  }
 } else {

//print "Stadium 4";

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

}

} else {

?>
<strong>Brugernavn:</strong> <?php print $db_users[bruger]; ?>
<br />
<strong>Status:</strong>&nbsp;
<?php
if ($db_users[admin] == "1" && $db_users[crew] == "1") {
print "Administrator, Crewmedlem";
} else if ($db_users[admin] == "1") {
print "Administrator";
} else if ($db_users[crew] == "1") {
print "Crewmedlem";
} else {
print "Normal";
}
?>
<br />
<strong>Navn:</strong> <?php print $db_users[navn]; ?>
<br />
<strong>Alder:</strong> <?php print $db_users[alder]; ?>
<br />
<?php
if (eregi("+'http://'", $db_users[hjemmeside])) {
$website = $db_users[hjemmeside];
} else {
$website = "http://".$db_users[hjemmeside];
}
?>
<strong>Hjemmeside:</strong> <a href="?site=Redirect&amp;location=<?php print $website; ?>" target="_Blank"><?php print $db_users[hjemmeside]; ?></a>
<br />
<strong>Onlinetid:</strong> 
<?
if ($db_users[timer] < "1") {
print "0";
} else {
print $db_users[timer];
}

?> minutter (
<?php
$timerialt = $db_users[timer]/60;
print round($timerialt, 2);
?>
 timer)
<br />
<?php
$t = $timerialt;

if ($db_users[admin] == "1") {
$lvl = "Administrator";
} else if ($t >= "10000") {
$lvl = "21";
} else if ($t >= "7500") {
$lvl = "20";
} else if ($t >= "6000") {
$lvl = "19";
} else if ($t >= "5000") {
$lvl = "18";
} else if ($t >= "3600") {
$lvl = "17";
} else if ($t >= "2600") {
$lvl = "16";
} else if ($t >= "2000") {
$lvl = "15";
} else if ($t >= "1500") {
$lvl = "14";
} else if ($t >= "1100") {
$lvl = "13";
} else if ($t >= "900") {
$lvl = "12";
} else if ($t >= "650") {
$lvl = "11";
} else if ($t >= "450") {
$lvl = "10";
} else if ($t >= "300") {
$lvl = "9";
} else if ($t >= "200") {
$lvl = "8";
} else if ($t >= "130") {
$lvl = "7";
} else if ($t >= "80") {
$lvl = "6";
} else if ($t >= "50") {
$lvl = "5";
} else if ($t >= "20") {
$lvl = "4";
} else if ($t >= "10") {
$lvl = "3";
} else if ($t >= "3") {
$lvl = "2";
} else if ($t == "0") {
$lvl = "1";
} else {
$lvl = "0";
}
?>
<strong>Level:</strong> <?=$lvl?>
<br />
<br />
<br />
<br />
<br />
<strong>
<?php
if (eregi("$[x_s_z_X_s_Z]", $db_users["bruger"])) {
print $db_users[bruger]."' fritekst";
} else {
print $db_users[bruger]."'s fritekst";
}
?>
</strong>
 <div class="copy" style="display:inline;">(<a href="javascript:;" onClick="goShow('userText');">vis/skjul</a>)</div>:
<br />
<div id="userText" style="display:inline;">
<?php
if ($db_users[exist] == 0) {
?>
<div style="color:#F00;text-decoration:underline;font-weight:bold;">Denne bruger er blevet deaktiveret af administratorerne. Dette vil sige, at han ikke kan logge ind.</div>
<?php
} else {

print strip_tags($db_users[text], "<u><i><b><strong><br>");


}

?>
</div>
<br />
<br />
<strong>Information</strong> <div class="copy" style="display:inline;">(<a href="javascript:;" onClick="goShow('userInformation')">vis/skjul</a>)</div>:
<br />
<div id="userInformation" style="display:inline;">
<?php
$users_tag = mysql_query("SELECT * FROM `pytox_tagwall` WHERE `user` LIKE '{$db_users[bruger]}'");

print "Skrevne beskeder i tagwallen: ".mysql_num_rows($users_tag);
?>
<br />
<?php
$users_gb = mysql_query("SELECT * FROM `pytox_gb` WHERE `fra` LIKE '{$db_users[bruger]}' AND `show` LIKE '1'");

print "Skrevne beskeder i g&aelig;steb&oslash;ger: ".mysql_num_rows($users_gb);
?>
<br />
<?php
$users_pmail = mysql_query("SELECT * FROM `pytox_post` WHERE `fra` LIKE '{$db_users[bruger]}'");

print "Afsente PMail's: ".mysql_num_rows($users_pmail)." <i>(Hvis denne bruger er administrator medtælles og beskederne, der er sent til alle brugere)</i>";
?>
<br />
<?php
$users_artikler = mysql_query("SELECT * FROM `pytox_artikler` WHERE `forfatter` LIKE '{$db_users[bruger]}' AND `show` LIKE '1'");

print "Skrevede og godkendte artikler: ".mysql_num_rows($users_artikler);
?>
<br />
<?php
$users_nyheder = mysql_query("SELECT * FROM `pytox_nyheder` WHERE `forfatter` LIKE '{$db_users[bruger]}' AND `show` LIKE '1'");

print "Skrevede og godkendte nyheder: ".mysql_num_rows($users_nyheder);
?>
</div>
<br />
<br />
<?php
$admintjek = mysql_query("SELECT * FROM `pytox_community` WHERE `bruger` LIKE '{$_COOKIE[user]}' LIMIT 1");

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

if ($admin[admin] == "1") {
?>
<u><strong>Ekstra information (for administratorer)</strong></u> <div class="copy" style="display:inline;">(<a href="javascript:;" onClick="goShow('userAdmin')">vis/skjul</a>)</div>:
<br />
<br />
<div id="userAdmin" style="display:inline;">
Pycoins: <?=$db_users[coins]?>
<br />
Kodeordets længde: <?=strlen($db_users[kode])?>
<br />
<br />
<?php
if ($db_users[exist] == "1") {
print "<a href=\"?site=Userlist&amp;deactivatecom=true&amp;id=".$_GET[userid]."\" style=\"color:#063;\">Deaktiver ".$db_users[bruger]."</a>";
} else if ($db_users[exist] == "0") {
print "<a href=\"?site=Userlist&amp;activatecom=true&amp;id=".$_GET[userid]."\" style=\"color:#F00;\">Aktiver ".$db_users[bruger]."</a>";
} else {
print "Ukendt fejl opstod!";
}
?>
<br />
<br />
<div class="blackborder" style="width:400px;">
<form action="?site=Userlist&amp;choose=editusercom&amp;userid=<?=$_GET[userid]?>" method="post">
<?php
if ($db_users[admin] == "1" && $db_users[crew] == "1") {
?>
<select style="color:<?=$dropstatus?>;" name="dropstatus">
<option>Normal</option>
<option>Crewmedlem</option>
<option>Redaktør</option>
<option value="underadmin">Underadmin</option>
<option>Administrator</option>
<option value="both" selected="selected">Crewmedlem+Administrator</option>
</select>
<?php
} else if ($db_users[crew] == "1" && $db_users[admin] == "0") {
?>
<select style="color:<?=$dropstatus?>;" name="dropstatus">
<option>Normal</option>
<option selected="selected">Crewmedlem</option>
<option>Redaktør</option>
<option value="underadmin">Underadmin</option>
<option>Administrator</option>
<option value="both">Crewmedlem+Administrator</option>
</select>
<?php
} else if ($db_users[admin] == "1") {
?>
<select style="color:<?=$dropstatus?>;" name="dropstatus">
<option>Normal</option>
<option>Crewmedlem</option>
<option>Redaktør</option>
<option value="underadmin">Underadmin</option>
<option selected="selected">Administrator</option>
<option value="both">Crewmedlem+Administrator</option>
</select>
<?php
} else if ($db_users[admin] == "2") {
?>
<select style="color:<?=$dropstatus?>;" name="dropstatus">
<option>Normal</option>
<option>Crewmedlem</option>
<option selected="selected">Redaktør</option>
<option value="underadmin">Underadmin</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 value="underadmin">Underadmin</option>
<option>Administrator</option>
<option value="both">Crewmedlem+Administrator</option>
</select>
<?php
}
?>
-<input type="submit" value="Ændr" name="submitid" class="submit" /></form>
</div>
<br />
<br />
<br />

<br />
<br />
Følgende ting er ejet af <?=$db_users[bruger]?>
<br />
<br />
<?php
//////////////////////////
//////////////////////////
//////////////////////////

$brugerensid = $db_users[id];

$alle = mysql_query("SELECT * FROM `pytox_ting` WHERE `owner` LIKE '$brugerensid'") or die(mysql_error());
?>
<i>PyCo = PyCoins</i>
<br />
Der er ialt&nbsp;
<?php
if (mysql_num_rows($alle) == 0) {
print "Ingen ejede ting.";
} else if (mysql_num_rows($alle) == 1) {
print "En ejet ting.";
} else if (mysql_num_rows($alle) >= 2) {
print mysql_num_rows($alle)." ejede ting.";
} else {
print "ERROR!";
}
?>
<br />
<br />
<table class="blackborder" cellpadding="3" cellspacing="1">
<?php

$perlinje = 3;

	for ($i = 0;$i <= mysql_num_rows($alle);) {
?>
 <tr><!--start-->
<?php
//print "Stadium 1|-";


$inry = "SELECT * FROM `pytox_ting` WHERE `owner` LIKE '$db_users[id]' ORDER BY `id` ASC LIMIT ".$i.", ".$perlinje;
$query['tagwall'] = mysql_query($inry) or die(mysql_error());

while ($tag = mysql_fetch_array($query['tagwall'])) {

//print "Stadium 2|-";

if ($ue == 0) {
$ue = 1;
$bgcolore = "#CCC";
$colore = "#000";
} else if ($ue == 1) {
$ue = 0;
$bgcolore = "#FFF";
$colore = "#000";
} else {
$ue = 1;
$bgcolore = "#CCC";
$colore = "#000";
}

//print "<strong>".$tag[id]."</strong>";

$thinginfo = mysql_query("SELECT * FROM `pytox_tingdb` WHERE `id` LIKE '{$tag[thingid]}' LIMIT 1") or die(mysql_error());
while ($info = mysql_fetch_array($thinginfo)) {
//print "Stadium 3|-";
?>
  <td style="background-color:<?=$bgcolore?>;color:<?=$colore?>" align="center" valign="top">
<img src="<?=$info[image]?>" style="border:1px solid #000;" alt="<?=$info[name]?>" title="<?=$info[name]?>"  />
<br />
<strong>Navn</strong>: <?=$info[name]?>
<br />
<strong>Ting-id</strong>: <?=$tag[id]?>
<br />
<strong>Værdi</strong>: <?=$info[price]?> PyCo
<br />
<?php
$resale = $info[price]/2;
$resaleprint = settype($resale, 'integer');
?>
<strong>Gensalgsværdi</strong>: <?=round($resale)?> PyCo
<br />
<?php
//$owner = mysql_query("SELECT * FROM `pytox_community` WHERE `id` LIKE '{$tag[owner]}' LIMIT 1") or die(mysql_error());
//while ($ejer = mysql_fetch_array($owner)) {
//print "<strong>Ejer</strong>: <a href=\"?site=Com.users&amp;userid=".$ejer[id]."\">".$ejer[bruger]."</a>";
?>
<br />
<strong>På lager</strong>: <?=$info[instore]?>
<br />
<strong>Ejer</strong>: <?=$tag[owner]?>
<br />
<br />
<?php
$youown = mysql_query("SELECT * FROM `pytox_community` WHERE `bruger` LIKE '{$_COOKIE['user']}' LIMIT 1") or die(mysql_error());

while ($own = mysql_fetch_array($youown)) {

if ($own[id] == $tag[owner]) {
?>
<a href="?site=Shop&amp;choose=resale&amp;saleid=<?=$tag[id]?>"><strong>Sælg denne for genstansværdien</strong></a>
<?php
}
}
//} //slutter $ejer
} //slutter $info
?>
  </td>
<?php

}//slutter $tag
print "</tr>";
$i = $i+$perlinje;
	}//slutter for-statement
?>
</table>
<?php
////////////////////////////
////////////////////////////
////////////////////////////
////////////////////////////
}//Ejer noget?
?>
</div>
<?php
}
}

}
}
?>