<h2> </h2>
<?php
if ($_SESSION['lvl']>=1) {
	if (isset($_GET['userid'])) $userid=preg_replace("/[^0-9]/i","",$_GET['userid']);
	if (!isset($userid) || !$userid) $userid=$_SESSION['id'];
  if (($_SESSION['id']==$userid) || ($_SESSION['lvl']>=3)) {
		if ($arr_member=mysql_fetch_array(mysql_query("select * from users where id=$userid"))) {
			if (isset($_GET['apl'])) {
				if (!isset($_GET['dnchg'])) {if (isset($_GET['npassword'])) $npassword=md5($_GET['npassword']);} else $npassword=$arr_member['password'];
				$nemail='-';if (isset($_GET['nemail'])) if (strlen($_GET['nemail'])<30) $nemail=addslashes(preg_replace("/[>'\"]/i","",$_GET['nemail']));
				if (isset($_GET['hdmail'])) $hdmail=1;else $hdmail=0;
				if (isset($_GET['nabout'])) $nabout=addslashes($_GET['nabout']);else $nabout='';
				if (isset($_GET['nstyle'])) $nstyle=preg_replace("/[^a-z0-9]/i","",$_GET['nstyle']);else $nstyle='default';
				if (!mysql_num_rows($sql=mysql_query("select * from styles where name='$nstyle'"))) $nstyle='default';
				if (mysql_query("update `styles` set used=used-1 where name='$arr_member[style]'") &&	mysql_query("update `styles` set used=used+1 where name='$nstyle'"));
				else echo "    ";
				if (mysql_query("update users set password='$npassword',email='$nemail',hdmail=$hdmail,about='$nabout',style='$nstyle' where id=$userid")!=FALSE) {
					if ($userid==$_SESSION['id']) $_SESSION['style']=$nstyle;
					echo "<h3 class=bold>   ",$userid,"  !</h3>";
				}
				else echo "<h3 class=bold>     !</h3>";
				echo "<input type=button onClick=location.href='index.php?page=users' value='  '>
							<input type=button onClick=location.href='index.php?page=edusr' value='  '>";
			} else
				if ($userid!=NULL) {
					echo "
					<form action=index.php method=GET>
					<input type=hidden name=page value=edusr>
					<input type=hidden name=userid value=$userid>
					<input type=hidden name=apl>
					<table border=0>
					<tr><td align=right><b>#$arr_member[id]</b><td align=center><b>$arr_member[login]</b></td></tr>
					<tr><td align=right></td><td><input type=password name=npassword>   <input type=checkbox name=dnchg checked></td></tr>
					<tr><td align=right>ICQ / E-mail</td><td><input type=text name=nemail maxlength=29 value='$arr_member[email]'>  e-mail <input type=checkbox name=hdmail ";if ($arr_member['hdmail']) echo "checked";echo "></td></tr>
					<tr><td align=right></td><td><textarea name=nabout rows=3 cols=20>$arr_member[about]</textarea></td></tr>
					<tr><td align=right></td><td><select name=nstyle>";
					if (mysql_num_rows($sql=mysql_query("select * from styles"))) 
						while ($line=mysql_fetch_array($sql)) {
							echo "<option value='$line[name]' ";if ($line['name']==$arr_member['style']) echo "selected";echo ">$line[link]";
						}
					echo "</select></td></tr><tr height=100 ><td align=center colspan=2><input type=submit value=Ok>&nbsp;<input type=reset value=Reset></td></tr>
					</table>
					</form>";	
				} else echo "<h3 class=bold> #$userid     <h3>";
		} else echo "<h3 class=bold> #$userid     <h3>";
	}	else echo "<h3 class=bold>     </h3>";
}	else echo "<h3 class=bold>     </h3><input type=button onClick=location.href='index.php?page=users' value='   '>";
?>
