<?php session_start(); ?>
<?
include ("../var.php");
?>
<?
include("../stop.php");
?>
<?
include("header.php")
?>
<?
include ("config.php");
?>
<!-- CONTINUTUL !!!! -->
<?
$uid = $_GET["id"];
$id = $_GET["id"];
$action = $_GET["action"];
if($action=="edit")
{
// Aici puteti modifica numele directorului de upload (daca ati pus alt nume)
$uploadpath = "../avatar/";

// Aici este setata marimea maxima, in KiloBytes, care este permisa (dar marime maxima depinde si de setarile serverului)
$max_size = 200;

// Aici puteti schimba tipul, extensia fisierelor permise pt. upload
$allowtype = array('bmp', 'gif', 'jpg', 'jpeg', 'png',);

$filename = $_FILES['fisiere']['name'];
$filename=str_replace(".php"," ",$filename);
if(isset($_POST['submit'])) {
  if (isset ($_FILES['fisiere'])) {
    $uploadpath = $uploadpath . basename($filename);
	$type = end(explode(".", strtolower($filename)));

    // Daca fisierul are extensia permisa
    if (in_array($type, $allowtype)) {
	  // Verifica daca fisierul are marimea permisa

if ($_FILES['fisiere']['size']<=$max_size*1000) {
        if(move_uploaded_file($_FILES['fisiere']['tmp_name'], $uploadpath)) { 
          echo "Fisierul:<b> ". basename($filename). "</b> a fost incarcat cu succes:"; 
$fisier = $filename;
$user=$_SESSION['nume'];
$getuser="SELECT * from utilizatori a, b_templates b where b.templateid=a.templateclass and a.nume='$user'";
$getuser2=mysql_query($getuser) or die("Could not get user info");
$getuser3=mysql_fetch_array($getuser2);
$uprecords="Update utilizatori set avatar='$fisier' where id='$getuser3[id]'";
$uprecords1="Update utilizatori set setavatar='1' where id='$getuser3[id]'";
  
  mysql_query($uprecords1) or die("Could not update records"); 
  mysql_query($uprecords) or die("Could not update records"); 
		}
        else { 
          echo "<b>A aparut o eroare la urcarea fisierului pe server, <br /> posibil ca marimea fisierului sa depaseasca permisiunile setate de server.</b>"; 
        }
	  }
	  else { echo 'Fisierul <b>'. $_FILES['fisiere']['name']. '</b> depaseste marimea permisa de maxim <i><b>'. $max_size. 'KB</b></i>'; }
    }
	else { echo 'Fisierul <b>'. $_FILES['fisiere']['name']. '</b> nu are tipul de extensie permis'; }
  }
}
?> 
<?
if(isset($_SESSION['nume'])) {
      	$usersa = ''.$_SESSION['nume'].'';
?>
<div class='hl'>Avatar</div>
<div class='txt'>

</div>
</form>
<?
$user=$_SESSION['nume'];
$query="SELECT * from utilizatori a, b_templates b where b.templateid=a.templateclass and a.nume='$user'";
$res=mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($res))
{
$avatar = $row['avatar'];
}
echo "<img src='../avatar/$avatar' align='left' alt='avatar' /></br>";
}

?>
<small>Maximum size: 61440 bytes and 150 x 150 px</small><br/><br/>
 <br/><br/>
</div>
<div style="width:333px; text-align:center;">
<form action="profile.php?action=edit" method="POST" enctype="multipart/form-data"> 
Upload Fisier: 
<input type="file" name="fisiere" /> <br />
<input type="submit" name='submit' value="Save Profile" /> 
</form>
</div>
<?
}
else if($id=="$uid")
{
$profil="SELECT * from utilizatori where id='$uid'"; //grab from sql users on in last 15 minutes
$profil2=mysql_query($profil) or die("Could not get users");
while($profil3=mysql_fetch_array($profil2))
{    
$date = $profil3['data'];
$date_formated = date('H:i:s d/m/Y', $date);

$last = $profil3['lasttime'];
$last_formated = date('H:i:s d/m/Y', $last);

    
$rank =  $profil3['status'];
$avatar = $profil3["avatar"];
$nume =$profil3["nume"];
$views = $profil3['views']+1;
$show = $profil3['views'];
$action = $profil3['stare'];
$email = $profil3['email'];
$ip = $profil3['ip'];
$ptup = $profil3["ptup"];
$ptdown = $profil3["ptdown"];


echo "<div class='txt'>
<img src='../avatar/$avatar'/><br/>";

if(isset($_SESSION['nume'])) {
      	$userb = ''.$_SESSION['nume'].'';
 $getuser="SELECT * from utilizatori WHERE nume='$userb'";
  $getuser2=mysql_query($getuser) or die("COuld not draw cookies");
  $getuser3=mysql_fetch_array($getuser2);
  if(strlen($getuser3[nume])>1)
  {
    $_SESSION['user']=$getuser3[nume];        
if($getuser3[status]>=2)
    {
print "<a href=\"ban.php?avt=$uid\">Delete Avatar</a></br></br>";       
        
}}}

echo "<b>Name: </b> $nume<br/>
<b>Registered: </b> " . $date_formated. "<br/>
<b>Last visit: </b>  " . $last_formated. "<br/>
</div>

<div class='hl'>Statistics<br/>
";
$num = mysql_query("SELECT * FROM fisiere WHERE user='$nume'");
$num_rows = mysql_num_rows($num);

echo "</div>
<div class='txt'>
<b>Public files:</b>  $num_rows ( <a href='userup.php?rid=$nume'><img src='../interfata/search.gif' align='absmiddle' title='More from this user' /> find</a> )<br/>
";
$que=mysql_query("SELECT * FROM fisiere where user='$nume'");
while($row=mysql_fetch_array($que)){$array[]=$row['size'];
$sz=array_sum($array);
if ($sz<1024) {$sz="$sz bytes";}
elseif (($sz>=1024)&&($sz<1048576)) {$sz=strtr(round($sz/1024,2),".",",")." KB";}
elseif (($sz>=1048576)&&($sz<134217728)) {$sz=strtr(round($sz/1024/1024,2),".",",")." MB";}
elseif ($sz>=134217728) {$sz=strtr(round($sz/1024/1024/1024,2),".",",")." GB";}
}

echo "<b>Public files space:</b>".$sz."<br/>";

$quedown=mysql_query("SELECT * FROM utilizatori WHERE nume='$nume'");
while($row=mysql_fetch_array($quedown)){$arraydown[]=$row['download'];
$szdown=array_sum($arraydown);
if ($szdown<1024) {$szdown="$szdown bytes";}
elseif (($szdown>=1024)&&($szdown<1048576)) {$szdown=strtr(round($szdown/1024,2),".",",")." KB";}
elseif (($szdown>=1048576)&&($szdown<134217728)) {$szdown=strtr(round($szdown/1024/1024,2),".",",")." MB";}
elseif ($szdown>=134217728) {$szdown=strtr(round($szdown/1024/1024/1024,2),".",",")." GB";}
}

echo "<b>File Download:</b> ".$szdown."<br/>";

if(!$act){mysql_query("UPDATE utilizatori SET views='$views' WHERE id='$uid'");}

if(isset($_SESSION['nume'])) {
      	$usernames = ''.$_SESSION['nume'].'';
$stare = "View Profile User $nume ";
if(!$act){mysql_query("UPDATE utilizatori SET stare='$stare' WHERE nume='$usernames'");}
}

echo "<b>Profile Views :</b> $show</br>";
echo "<b>Status : </b> ";
$recent=date("U")-900;
 if($last>"$recent")
	  {
		echo "<b>O</b>nline";
	   }else{
		 echo "<b>O</b>ffline";
		}  
echo "</br><b>Last Action:</b>$action<br/>";
echo "<b>Points Upload:</b>$ptup</br>";
echo "<b>Points Download:</b>$ptdown</br>";
echo "</div>";

echo "<div class='hl'>Stop!<br/>
</div></br>";
?>
<!-- Panou Moderator -->
<?
if(isset($_SESSION['nume'])) {
      	$userb = ''.$_SESSION['nume'].'';
 $getuser="SELECT * from utilizatori WHERE nume='$userb'";
  $getuser2=mysql_query($getuser) or die("COuld not draw cookies");
  $getuser3=mysql_fetch_array($getuser2);
  if(strlen($getuser3[nume])>1)
  {
    $_SESSION['user']=$getuser3[nume];        
if($getuser3[status]==2)
    {
echo "<div class='hl'>Control Panel Moderator<br/>
</div></br>";
echo "<b>Email:</b> $profil3[email]</br>";
echo "<b>Ip:</b> $profil3[ip]</br>";
$rank =  $profil3['status'];
echo "</b><font class='modr'>Rank:</b><b>";
if ($rank=="") {} else {
 if($rank =="4"){echo 'Owner';} 
 if($rank =="3"){echo 'Administrator';} 
 if($rank =="2"){echo 'Moderator';}
 if($rank =="1"){echo 'Avansat';} 
 if($rank =="0"){echo 'User';} }
echo "</a></font></b></a><br />";

$ustat="SELECT * from utilizatori where id='$uid'"; //grab from sql users on in last 15 minutes
$ustat2=mysql_query($ustat) or die("Could not get users");
while($ustat3=mysql_fetch_array($ustat2))
{ 

print "<b>Warns:</b> $ustat3[warn] </br> <b>Baned:</b> $ustat3[banned]</br>";
print "<div class='hl'>Actions<br/></div>";
$stare = $ustat3["banned"];
if($stare=="Yes")
{
$motivbad = $ustat3["motiv"];
$userbad = $ustat3["reclamant"];
echo "Banat de: $userbad</br>";
echo "Motiv: $motivbad</br>";

print "<i>Daca consideri ca userul este banat pe nedrept anunta un proprietar!!!</i>";
}else{

print "<form action=\"ban.php?ban=$ustat3[id]\" method=\"POST\">";
print "<input type=\"hidden\" name=\"userok\" value='$userb'><br>";
echo "<b>Motiv:</b><br/><textarea name=\"motiv\" cols='20' rows='6'  maxlength='240'></textarea>";
print "<input type=\"submit\" name=\"submit\" value=\"Baneaza\">";
}
print "</br>";
   $_SESSION['user']=$getuser3[nume];        
if($getuser3[warn]==0)
    {
print "<a href=\"ban.php?warn=$ustat3[id]\">1 Warn User $ustat3[nume]</a></br></br>";
}
   $_SESSION['user']=$getuser3[nume];        
if($getuser3[warn]==1)
    {
print "<a href=\"ban.php?warn2=$ustat3[id]\">2 Warn User $ustat3[nume]</a></br></br>";
}
   $_SESSION['user']=$getuser3[nume];        
if($getuser3[warn]==2)
    {
print "<a href=\"ban.php?warn3=$ustat3[id]\">3 Warn User $ustat3[nume]</a></br>";
}
}}}}
?>
<!-- Panou Administratorr -->
<?
if(isset($_SESSION['nume'])) {
      	$userb = ''.$_SESSION['nume'].'';
 $getuser="SELECT * from utilizatori WHERE nume='$userb'";
  $getuser2=mysql_query($getuser) or die("COuld not draw cookies");
  $getuser3=mysql_fetch_array($getuser2);
  if(strlen($getuser3[nume])>1)
  {
    $_SESSION['user']=$getuser3[nume];        
if($getuser3[status]==3)
    {
echo "<div class='hl'>Control Panel Administrator<br/>
</div></br>";
echo "<b>Email:</b> $profil3[email]</br>";
echo "<b>Ip:</b> $profil3[ip]</br>";
$rank =  $profil3['status'];
echo "</b><font class='modr'>Rank:</b><b>";
if ($rank=="") {} else {
 if($rank =="4"){echo 'Owner';} 
 if($rank =="3"){echo 'Administrator';} 
 if($rank =="2"){echo 'Moderator';}
 if($rank =="1"){echo 'Avansat';} 
 if($rank =="0"){echo 'User';} }
echo "</a></font></b></a><br />";

$ustat="SELECT * from utilizatori where id='$uid'"; //grab from sql users on in last 15 minutes
$ustat2=mysql_query($ustat) or die("Could not get users");
while($ustat3=mysql_fetch_array($ustat2))
{ 

print "<b>Warns:</b> $ustat3[warn] </br> <b>Baned:</b> $ustat3[banned]</br>";
print "<div class='hl'>Actions<br/></div>";
$stare = $ustat3["banned"];
if($stare=="Yes")
{
$motivbad = $ustat3["motiv"];
$userbad = $ustat3["reclamant"];
echo "Banat de: $userbad</br>";
echo "Motiv: $motivbad</br>";

print "</br><a href=\"ban.php?unban=$ustat3[id]\">Unbann User $ustat3[nume]</a></br>";
}else{

print "<form action=\"ban.php?ban=$ustat3[id]\" method=\"POST\">";
print "<input type=\"hidden\" name=\"userok\" value='$userb'><br>";
echo "<b>Motiv:</b><br/><textarea name=\"motiv\" cols='20' rows='6'  maxlength='240'></textarea>";
print "<input type=\"submit\" name=\"submit\" value=\"Baneaza\">";
}
print "</br>";
   $_SESSION['user']=$getuser3[nume];        
if($getuser3[warn]==0)
    {
print "<a href=\"ban.php?warn=$ustat3[id]\">1 Warn User $ustat3[nume]</a></br></br>";
}
   $_SESSION['user']=$getuser3[nume];        
if($getuser3[warn]==1)
    {
print "<a href=\"ban.php?warn2=$ustat3[id]\">2 Warn User $ustat3[nume]</a></br></br>";
}
   $_SESSION['user']=$getuser3[nume];        
if($getuser3[warn]==2)
    {
print "<a href=\"ban.php?warn3=$ustat3[id]\">3 Warn User $ustat3[nume]</a></br>";
}
}}}}
?>
<!-- Panou Author -->
<?
if(isset($_SESSION['nume'])) {
      	$userb = ''.$_SESSION['nume'].'';
 $getuser="SELECT * from utilizatori WHERE nume='$userb'";
  $getuser2=mysql_query($getuser) or die("COuld not draw cookies");
  $getuser3=mysql_fetch_array($getuser2);
  if(strlen($getuser3[nume])>1)
  {
    $_SESSION['user']=$getuser3[nume];        
if($getuser3[status]==5)
    {
echo "<div class='hl'>Control Panel Author<br/>
</div></br>";
echo "<b>Email:</b> $email</br>";
echo "<b>Ip:</b> $ip</br>";
$ustat="SELECT * from utilizatori where id='$uid'"; //grab from sql users on in last 15 minutes
$ustat2=mysql_query($ustat) or die("Could not get users");
while($ustat3=mysql_fetch_array($ustat2))
{ 

print "<b>Warns:</b> $ustat3[warn] </br> <b>Baned:</b> $ustat3[banned]</br>";
print "<div class='hl'>Actions<br/></div>";
$stare = $ustat3["banned"];
if($stare=="Yes")
{
$motivbad = $ustat3["motiv"];
$userbad = $ustat3["reclamant"];
echo "Banat de: $userbad</br>";
echo "Motiv: $motivbad</br>";

print "</br><a href=\"ban.php?unban=$ustat3[id]\">Unbann User $ustat3[nume]</a></br>";
}else{

print "<form action=\"ban.php?ban=$ustat3[id]\" method=\"POST\">";
print "<input type=\"hidden\" name=\"userok\" value='$userb'><br>";
echo "<b>Motiv:</b><br/><textarea name=\"motiv\" cols='20' rows='6'  maxlength='240'></textarea>";
print "<input type=\"submit\" name=\"submit\" value=\"Baneaza\">";
}
print "</br>";
print "</br><a href=\"ban.php?delete=$ustat3[id]\">Delete User $ustat3[nume]</a></br>";

   $_SESSION['user']=$getuser3[nume];        
if($getuser3[warn]==0)
    {
print "<a href=\"ban.php?warn=$ustat3[id]\">1 Warn User $ustat3[nume]</a></br></br>";
}
   $_SESSION['user']=$getuser3[nume];        
if($getuser3[warn]==1)
    {
print "<a href=\"ban.php?warn2=$ustat3[id]\">2 Warn User $ustat3[nume]</a></br></br>";
}
   $_SESSION['user']=$getuser3[nume];        
if($getuser3[warn]==2)
    {
print "<a href=\"ban.php?warn3=$ustat3[id]\">3 Warn User $ustat3[nume]</a></br>";
}
}}}}
?>
<!-- Panou Proprietar -->
<?
if(isset($_SESSION['nume'])) {
      	$userb = ''.$_SESSION['nume'].'';
 $getuser="SELECT * from utilizatori WHERE nume='$userb'";
  $getuser2=mysql_query($getuser) or die("COuld not draw cookies");
  $getuser3=mysql_fetch_array($getuser2);
  if(strlen($getuser3[nume])>1)
  {
    $_SESSION['user']=$getuser3[nume];        
if($getuser3[status]==4)
    {
echo "<div class='hl'>Control Panel Proprietar<br/>
</div></br>";
echo "<b>Email:</b> $profil3[email]</br>";
echo "<b>Ip:</b> $profil3[ip]</br>";
$rank =  $profil3['status'];
echo "</b><font class='modr'>Rank:</b><b>";
if ($rank=="") {} else {
 if($rank =="4"){echo 'Owner';} 
 if($rank =="3"){echo 'Administrator';} 
 if($rank =="2"){echo 'Moderator';}
 if($rank =="1"){echo 'Avansat';} 
 if($rank =="0"){echo 'User';} }
echo "</a></font></b></a><br />";

$ustat="SELECT * from utilizatori where id='$uid'"; //grab from sql users on in last 15 minutes
$ustat2=mysql_query($ustat) or die("Could not get users");
while($ustat3=mysql_fetch_array($ustat2))
{ 

print "<b>Warns:</b> $ustat3[warn] </br> <b>Baned:</b> $ustat3[banned]</br>";
print "<div class='hl'>Actions<br/></div>";
$stare = $ustat3["banned"];
if($stare=="Yes")
{
$motivbad = $ustat3["motiv"];
$userbad = $ustat3["reclamant"];
echo "Banat de: $userbad</br>";
echo "Motiv: $motivbad</br>";

print "</br><a href=\"ban.php?unban=$ustat3[id]\">Unbann User $ustat3[nume]</a></br>";
}else{

print "<form action=\"ban.php?ban=$ustat3[id]\" method=\"POST\">";
print "<input type=\"hidden\" name=\"userok\" value='$userb'><br>";
echo "<b>Motiv:</b><br/><textarea name=\"motiv\" cols='20' rows='6'  maxlength='240'></textarea>";
print "<input type=\"submit\" name=\"submit\" value=\"Baneaza\">";
}
print "</br>";
   $_SESSION['user']=$getuser3[nume];        
if($getuser3[warn]==0)
    {
print "<a href=\"ban.php?warn=$ustat3[id]\">1 Warn User $ustat3[nume]</a></br></br>";
}
   $_SESSION['user']=$getuser3[nume];        
if($getuser3[warn]==1)
    {
print "<a href=\"ban.php?warn2=$ustat3[id]\">2 Warn User $ustat3[nume]</a></br></br>";
}
   $_SESSION['user']=$getuser3[nume];        
if($getuser3[warn]==2)
    {
print "<a href=\"ban.php?warn3=$ustat3[id]\">3 Warn User $ustat3[nume]</a></br>";
}
}}}}}}
?>
</select>
<!-- SFARSIT CONTINUT!!! -->
<?
include ("flooter.php");
?>