<?php
if($page == 'acces'){

if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
    }else{

    ?>
<?php include FORM; ?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter">
 
 <div class="w3-row">
   
   <div class="w3-quarter w3-hide-small">&nbsp;</div>
   
   <div class="w3-half w3-margin-top w3-margin-bottom w3-card">
   <h3 class="w3-center w3-margin-bottom w3-border-bottom w3-bluepm">Autentificare</h3>
   
<?php if(isset($e_err)){ ?>
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$e_err?></h5>
       </div>
   </div>
<?php } ?>

<?php if(isset($p_err)){ ?>
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$p_err?></h5>
       </div>
   </div>
<?php } ?>

<?php if(isset($err_login)){ ?>
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$err_login?></h5>
       </div>
   </div>
<?php } ?>

<?php if(isset($try)){ ?>
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$try?></h5>
       </div>
   </div>
<?php } ?>
   
   <form class="w3-container" action="" method="post">
   <div class="w3-margin-bottom">
   <label>Adresa de e-mail</label>
   <input class="w3-input" type="email" name="email" placeholder="Treceți adresa dvs. de e-mail" required=""/>
   </div>
   
   <div class="w3-margin-bottom">
   <label>Parola</label>
   <input class="w3-input" type="password" name="parola" placeholder="Introduceți parola" required=""/>
   </div>
   
   <div class="w3-margin-bottom w3-center">
   <button class="w3-button w3-bluepm w3-hover-seagreen" type="submit"><i class="fa fa-unlock"></i> Accesează</button>
   </div>
   
   <input type="hidden" name="acces" value="true"/>
   </form>
   
   <div class="w3-bar w3-white">
   
   <a href="contnou.html" class="w3-bar-item w3-button w3-bluepm w3-hover-seagreen" style="width:40%">Cont nou</a>
   <a href="recuperareparola.html" class="w3-bar-item w3-button w3-red w3-hover-black" style="width:60%">Recuperare parolă</a>
   
   </div>
   
   </div>
   
  <div class="w3-quarter w3-hide-small">&nbsp;</div>
   
 </div>

</div>

</div>


<?php }
 }elseif($page == 'act'){
    
if(isset($_GET['x'], $_GET['y'], $_GET['z']) && filter_var($_GET['x']) && (strlen($_GET['y']) == 32) && filter_var($_GET['z'])) {

$q = "UPDATE `anunturi` SET `verificat` = NULL WHERE (`uid`='" . $dbc->real_escape_string($_GET['x']) . "' AND `verificat`='" . $dbc->real_escape_string($_GET['y']) . "' AND `aid`='" . $dbc->real_escape_string($_GET['z']) . "') LIMIT 1";
    
$r = $dbc->query($q) or die($dbc->error);
    
if ($dbc->affected_rows == 1) {
    
    $qu = "SELECT * FROM `utilizatori` WHERE `utilizatori`.`uid`='".$dbc->real_escape_string($_GET['x'])."' LIMIT 1";
    $ru = $dbc->query($qu) or die($dbc->error);
    while($row = $ru->fetch_assoc()){
        $uemail = $row['email'];
        }
    
$qa = "SELECT * FROM `anunturi` WHERE `anunturi`.`aid`='".$dbc->real_escape_string($_GET['z'])."' LIMIT 1";
$ra = $dbc->query($qa) or die($dbc->error);
while($row = $ra->fetch_assoc()){
        $titluanunt = $row['titlu'];
        $continutanunt = $row['descriere'];
        $anuntseo = $row['seo'];
        }
    
require_once(SML.'Send_Mail.php');
$to = $uemail;
$subject = BASE_NAME." :: Anunț confirmat!";                    
$body = "<!DOCTYPE HTML>
      <head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
      
      <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
      <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">
      <title>Confirmare anunț</title>
      </head>
      <body>
      <div style=\"margin:16px;width:800px;max-width:100%;\">
      
      <div style=\"margin:16px;padding:16px;\">
      <p>Bun găsit!</p>
      <p>Avem vești bune pentru dumneavoastră!</p>
      <p><strong>Anunțul dumneavoastră a fost confirmat cu succes!</strong></p>
      <p>A mai rămas un pas până la publicarea lui de către un moderator.</p>\n\n";
$body .= '<p>Anunțul v-a fi publicat la adresa: '.BASE_URL.$anuntseo.'.html<br /></p><br/>';
$body .= '<p>---</p>
          <p>Salutări calde,<br />
              &nbsp;&nbsp;&nbsp;&nbsp; Echipa <a href="'. BASE_URL . '" style="text-decoration:none;">'.BASE_NAME.'</a></p>
          </div></div>
</body>
</html>';                    
Send_Mail($to,$subject,$body);

// Send to admin
/*
require_once(SML.'Send_Mail.php');
$to = $rwset['aemail'];
$subject = BASE_NAME." :: Anunț nou!";                    
$body = "<!DOCTYPE HTML>
      <head>
      
      <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
      <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">
      <title>Anunț nou!</title>
      </head>
      <body>
      <div style=\"margin:16px;width:800px;max-width:100%;\">
      
      <div style=\"margin:16px;padding:16px;\">
      <p>Salut Admin!</p>
      <p>Un nou anunț a fost adăugat!</p>
      <p>Conținutul acestui este:</p>
      <p>Titlu anunț:<br/>
         Conținut anunț:<br/>
         Adăugat de:<br/>
         De la adresa IP:<br />
         La data: 
      </p>
      <p>Pentru moderare, utilizați opțiunile de mai jos:</p>\n\n";
$body .= '<p>Anunțul v-a fi publicat la adresa: '.BASE_URL.$anuntseo.'.html<br /></p><br/>';
$body .= '<p>---</p>
          <p>Salutări calde,<br />
              &nbsp;&nbsp;&nbsp;&nbsp; Echipa <a href="'. BASE_URL . '" style="text-decoration:none;">'.BASE_NAME.'</a></p>
          </div></div>
</body>
</html>';                    
Send_Maila($toa,$subjecta,$bodya);
*/

    
$qa = "SELECT * FROM `anunturi` WHERE `aid`='".$dbc->real_escape_string($_GET['z'])."' LIMIT 1";
$ra = $dbc->query($qa) or die($dbc->error);    
    while($row = $ra->fetch_assoc()){
        $anuntseo = $row['seo'];
        } 
$active =  "Anunțul tău a fost confirmat!<br/>(Veți fi redirectat ->".BASE_URL.$anuntseo.".html)";
$url = BASE_URL.$anuntseo.".html";
header( "refresh:5;url=$url" );
    } else {        
    $qa = "SELECT * FROM `anunturi` WHERE `aid`='".$dbc->real_escape_string($_GET['z'])."' LIMIT 1";
    $ra = $dbc->query($qa) or die($dbc->error);    
    while($row = $ra->fetch_assoc()){
        $anuntseo = $row['seo'];
        }        
$inactive = "Anunțul tău este deja confirmat.<br/>(Veți fi redirectat->".BASE_URL.$anuntseo.".html)";
$url = BASE_URL.$anuntseo.".html";
header( "refresh:5;url=$url" );
    }
    //$dbc->close();
 }
?>
<?php //include FORM; ?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter">
 
 <div class="w3-row">
   <div class="w3-rest w3-card w3-container w3-indigo w3-margin-bottom">
   <h3>Activare anunț</h3>
   
<?php if(isset($active)){ ?>
<div class="w3-panel w3-padding w3-green w3-center"><?php echo $active; ?><br/><br/>
<p><i class="fa fa-check-square-o w3-center" style="font-size:100px;"></i></p>
</div>
<?php } ?>

<?php if(isset($inactive)){ ?>
<div class="w3-panel w3-padding w3-red w3-center"><?php echo $inactive; ?><br/><br/>
<p><i class="fa fa-close w3-center" style="font-size:100px;"></i></p>
</div>
<?php } ?>   
   </div>
  </div>
 </div>
</div>

<?php

 }elseif($page == 'acta'){
    
 if(isset($_GET['y'], $_GET['a']) && filter_var($_GET['y']) && filter_var($_GET['a'])) {
    $titlupagina = 'Aptobare anunț';
$qcheck = "SELECT * FROM `anunturi` WHERE `anunturi`.`aid`='".$dbc->real_escape_string($_GET['a'])."' LIMIT 1";
$rcheck = $dbc->query($qcheck);
$rck = $rcheck->fetch_assoc();
$refuzat = $rck['refuzat'];

if($refuzat == 0){
$q = "UPDATE `anunturi` SET `aprobat`='1' WHERE `anunturi`.`aid`='".$dbc->real_escape_string($_GET['a'])."' LIMIT 1";
$r = $dbc->query($q);    
if ($dbc->affected_rows == 1) {
$rau = $dbc->query("SELECT * 
                   FROM `anunturi` 
                   WHERE `anunturi`.`aid`='".$dbc->real_escape_string($_GET['a'])."' 
                   LIMIT 1");
while($row = $rau->fetch_assoc()){$uid = $row['uid'];}

$qu = "SELECT * FROM `utilizatori` WHERE `utilizatori`.`uid`='".$uid."' LIMIT 1";
$ru = $dbc->query($qu);
$rwu = $ru->fetch_assoc();
$uemail = $rwu['email'];

$ra = $dbc->query("SELECT * 
                   FROM `anunturi` 
                   WHERE `anunturi`.`aid`='".$dbc->real_escape_string($_GET['a'])."' 
                   LIMIT 1");
while($rwa = $ra->fetch_assoc()){
        $titluanunt = $rwa['titlu'];
        $continutanunt = $rwa['descriere'];
        $anuntseo = $rwa['seo'];
        }
    
require_once(SML.'Send_Mail.php');
$to = $uemail;
$subject = BASE_NAME." :: Anunț aprobat!";                    
$body = "<!DOCTYPE HTML>
      <head>
      
      <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
      <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">
      <title>Anunț aprobat</title>
      </head>
      <body>
      <div style=\"margin:16px;width:800px;max-width:100%;\">      
      <div style=\"margin:16px;padding:16px;\">
      <p>Bun găsit!</p>
      <p>Avem vești bune pentru dumneavoastră!</p>
      <p><strong>Anunțul dumneavoastră a fost aprobat!</strong></p>\n\n";
$body .= '<p>Anunțul este publicat la adresa: '.BASE_URL.$anuntseo.'.html<br /></p><br/>';
$body .= '<p>---</p>
          <p>Salutări calde,<br />
              &nbsp;&nbsp;&nbsp;&nbsp; Echipa <a href="'. BASE_URL . '" style="text-decoration:none;">'.BASE_NAME.'</a></p>
          </div></div>
</body>
</html>';                    
Send_Mail($to,$subject,$body);    
$ra = $dbc->query("SELECT * 
                   FROM `anunturi` 
                   WHERE `aid`='".$dbc->real_escape_string($_GET['a'])."' 
                   LIMIT 1");    
while($row = $ra->fetch_assoc()){$anuntseo = $row['seo'];} 
$active =  "Anunțul a fost aprobat!<br/>(Veți fi redirectat către anunț ->".BASE_URL.$anuntseo.".html)";
$url = BASE_URL.$anuntseo.".html";
header( "refresh:5;url=$url" );
    } else {        
$ra = $dbc->query("SELECT * 
                   FROM `anunturi` 
                   WHERE `aid`='".$dbc->real_escape_string($_GET['a'])."' 
                   LIMIT 1");    
while($row = $ra->fetch_assoc()){$anuntseo = $row['seo'];}        
$inactive = "Anunțul este deja APROBAT.<br/>(Veți fi redirectat către anunț ->".BASE_URL.$anuntseo.".html)";
$url = BASE_URL.$anuntseo.".html";
header( "refresh:5;url=$url" );
    }
    //$dbc->close();
 }else{
    $status = 'Anunțul nu poate fi aprobat, deoarece este refuzat.';
 }
 }
 
// Refuzare Anunt
if(isset($_GET['n'], $_GET['a']) && filter_var($_GET['n']) && filter_var($_GET['a'])) {
    $titlupagina = 'Refuzare anunț';
$qcheck = "SELECT * FROM `anunturi` WHERE `anunturi`.`aid`='".$dbc->real_escape_string($_GET['a'])."' LIMIT 1";
$rcheck = $dbc->query($qcheck);
$rck = $rcheck->fetch_assoc();
$aprobat = $rck['aprobat'];

if($aprobat == 0){
$q = "UPDATE `anunturi` SET `refuzat`='1', `motiv`='Anunțul nu poate fi aprobat, datorită conținutului său.' WHERE `anunturi`.`aid`='".$dbc->real_escape_string($_GET['a'])."' LIMIT 1";
$r = $dbc->query($q);    
if ($dbc->affected_rows == 1) {
$rau = $dbc->query("SELECT * 
                   FROM `anunturi` 
                   WHERE `anunturi`.`aid`='".$dbc->real_escape_string($_GET['a'])."' 
                   LIMIT 1");
while($row = $rau->fetch_assoc()){$uid = $row['uid'];}

$qu = "SELECT * FROM `utilizatori` WHERE `utilizatori`.`uid`='".$uid."' LIMIT 1";
$ru = $dbc->query($qu);
$rwu = $ru->fetch_assoc();
$uemail = $rwu['email'];

$ra = $dbc->query("SELECT * 
                   FROM `anunturi` 
                   WHERE `anunturi`.`aid`='".$dbc->real_escape_string($_GET['a'])."' 
                   LIMIT 1");
while($rwa = $ra->fetch_assoc()){
        $titluanunt = $rwa['titlu'];
        $continutanunt = $rwa['descriere'];
        $anuntseo = $rwa['seo'];
        $motiv = $rwa['motiv'];
        }
    
require_once(SML.'Send_Mail.php');
$to = $uemail;
$subject = BASE_NAME." :: Anunț REFUZAT!";                    
$body = "<!DOCTYPE HTML>
      <head>
      
      <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
      <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">
      <title>Anunț REFUZAT</title>
      </head>
      <body>
      <div style=\"margin:16px;width:800px;max-width:100%;\">      
      <div style=\"margin:16px;padding:16px;\">
      <p>Bun găsit!</p>
      <p>Avem vești nu prea bune pentru dumneavoastră!</p>
      <p><strong>Anunțul dumneavoastră a fost refuzat!</strong></p>\n\n";
$body .= '<p style="color:red;">Motivul refuzului: <strong>'.$motiv.'</strong></p><br/>';
$body .= '<p>---</p>
          <p>Salutări calde,<br />
              &nbsp;&nbsp;&nbsp;&nbsp; Echipa <a href="'. BASE_URL . '" style="text-decoration:none;">'.BASE_NAME.'</a></p>
          </div></div>
</body>
</html>';                    
Send_Mail($to,$subject,$body);    
$ra = $dbc->query("SELECT * 
                   FROM `anunturi` 
                   WHERE `aid`='".$dbc->real_escape_string($_GET['a'])."' 
                   LIMIT 1");    
while($row = $ra->fetch_assoc()){$anuntseo = $row['seo'];} 
$active =  "Anunțul a fost refuzat!";
$url = BASE_URL;
header( "refresh:5;url=$url" );
    } else {        
$ra = $dbc->query("SELECT * 
                   FROM `anunturi` 
                   WHERE `aid`='".$dbc->real_escape_string($_GET['a'])."' 
                   LIMIT 1");    
while($row = $ra->fetch_assoc()){$anuntseo = $row['seo'];}        
$inactive = "Anunțul este deja REFUZAT.";
$url = BASE_URL;
header( "refresh:5;url=$url" );
    }
    //$dbc->close();
 }else{
    $status = 'Anunțul nu poate fi refuzat, deoarece este aprobat.';
 }
 
 }
?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter">
 
 <div class="w3-row">
   <div class="w3-rest w3-card w3-container w3-text-white w3-margin-bottom" style="background-color:#117594;">
   <h3><?=$titlupagina?></h3>
   
<?php if(isset($active)){ ?>
<div class="w3-panel w3-padding w3-green w3-center"><?php echo $active; ?><br/><br/>
<p><i class="fa fa-check-square-o w3-center" style="font-size:100px;"></i></p>
</div>
<?php } ?>

<?php if(isset($status)){ ?>
<div class="w3-panel w3-padding w3-orange w3-text-white w3-center"><?php echo $status; ?><br/><br/>
<p><i class="fa fa-ban w3-center" style="font-size:100px;"></i></p>
</div>
<?php } ?>

<?php if(isset($inactive)){ ?>
<div class="w3-panel w3-padding w3-red w3-center"><?php echo $inactive; ?><br/><br/>
<p><i class="fa fa-close w3-center" style="font-size:100px;"></i></p>
</div>
<?php } ?>   
   </div>
  </div>
 </div>
</div>   
    
    
 <?php    
 }elseif($page == 'activare'){
    
  
  if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire'.$pagext)) {
    $url = BASE_URL.'index.html';			
    ob_end_clean();
    header("Location: $url");
    exit();	
  }else{
    
if(isset($_GET['x'], $_GET['y']) && filter_var($_GET['x'], FILTER_VALIDATE_EMAIL) && (strlen($_GET['y']) == 32)) {

$q = "UPDATE `utilizatori` SET `activ` = NULL WHERE (`email`='" . $dbc->real_escape_string($_GET['x']) . "' AND `activ`='" . $dbc->real_escape_string($_GET['y']) . "') LIMIT 1";
    
$r = $dbc->query($q);
    
if ($dbc->affected_rows == 1) {    
    
require_once(SML.'Send_Mail.php');
$to = $dbc->real_escape_string($_GET['x']);
$subject = BASE_NAME." :: Cont activat!";                    
$body = "<!DOCTYPE HTML>
      <head>
      
      <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
      <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">
      <title>Cofirmare activare cont</title>
      </head>
      <body>
      <div style=\"margin:16px;width:800px;max-width:100%;\">
      
      <div style=\"margin:16px;padding:16px;\">
      <p>Bun re-găsit!</p>
      <p>Avem vești bune pentru dumneavoastră!</p>
      <p><strong>Contul dumneavoastră a fost activat cu succes!</strong></p>
      <p>Datele dumneavoastră de autentificare sunt:</p>\n\n";
$body .= '<p>E-mail: '.$dbc->real_escape_string($_GET['x']).'<br />
          Parola: ******</p><br/>';
$body .= '<p><strong>Notă!</strong><br />
          <em>Dacă nu ați fost dumneavoastră persoana care s-a înregistrat pe site-ul '.BASE_NAME.', ignorați acest mesaj. Dacă nu este primul mesaj de acest fel, vă rugăm să ne transmiteți un răspuns scurt la acest e-mail. Mulțumim!</em></p>
          <p>---</p>
          <p>Salutări calde,<br />
              &nbsp;&nbsp;&nbsp;&nbsp; Echipa <a href="'. BASE_URL . '" style="text-decoration:none;">'.BASE_NAME.'</a></p>
          </div></div>
</body>
</html>';
                    
Send_Mail($to,$subject,$body);
    
    
        $active =  "Contul tău a fost activat! Acum te poți autentifica.";
    } else {
        $inactive = "Contul tău este deja ACTIV.";
    }
    //$dbc->close();
 }
?>
<?php include FORM; ?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter">
 
 <div class="w3-row">
   <div class="w3-rest w3-card w3-container w3-indigo w3-margin-bottom">
   <h3>Activare cont</h3>
   
<?php if(isset($active)){ ?>
<div class="w3-panel w3-padding w3-green w3-center"><?php echo $active; ?><br/><br/>
<p><i class="fa fa-check-square-o w3-center" style="font-size:100px;"></i></p>
</div>
<?php } ?>

<?php if(isset($inactive)){ ?>
<div class="w3-panel w3-padding w3-red w3-center"><?php echo $inactive; ?><br/><br/>
<p><i class="fa fa-close w3-center" style="font-size:100px;"></i></p>
</div>
<?php } ?>   
   </div>
  </div>
 </div>
</div>
<?php }
  
    
 }elseif($page == 'recuperare'){
    
  
  if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire'.$pagext)) {
    $url = BASE_URL.'index.html';			
    ob_end_clean();
    header("Location: $url");
    exit();	
  }else{
    
if(isset($_GET['x'], $_GET['y']) && filter_var($_GET['x'], FILTER_VALIDATE_EMAIL) && (strlen($_GET['y']) == 32)) {

function randomPassword() {
    $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
    $pass = array(); //remember to declare $pass as an array
    $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
    for ($i = 0; $i < 8; $i++) {
        $n = rand(0, $alphaLength);
        $pass[] = $alphabet[$n];
    }
    return implode($pass); //turn the array into a string
}
$password = randomPassword();
    
$r = $dbc->query("UPDATE `utilizatori` SET `activ` = NULL, `pass`=SHA('$password') WHERE (`email`='" . $dbc->real_escape_string($_GET['x']) . "' AND `activ`='" . $dbc->real_escape_string($_GET['y']) . "') LIMIT 1") or die($dbc->error);
    
if ($dbc->affected_rows == 1) {    
    
require_once(SML.'Send_Mail.php');
$to = $dbc->real_escape_string($_GET['x']);
$subject = BASE_NAME." :: Noua parolă!";                    
$body = "<!DOCTYPE HTML>
      <head>
      
      <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
      <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">
      <title>Noua parolă</title>
      </head>
      <body>
      <div style=\"margin:16px;width:800px;max-width:100%;\">
      
      <div style=\"margin:16px;padding:16px;\">
      <p>Bun regăsit!</p>
      <p>Avem vești bune pentru dumneavoastră!</p>
      <p><strong>Parola dvs. a fost resetată cu succes!</strong></p>
      <p>Noile dumneavoastră date de autentificare sunt:</p>\n\n";
$body .= '<p>E-mail: '.$dbc->real_escape_string($_GET['x']).'<br />
          Parola: '.$password.'</p><br/>';
$body .= '<p>---</p>
          <p>Salutări calde,<br />
              &nbsp;&nbsp;&nbsp;&nbsp; Echipa <a href="'. BASE_URL . '" style="text-decoration:none;">'.BASE_NAME.'</a></p>
          </div></div>
</body>
</html>';
                    
Send_Mail($to,$subject,$body);
    
    
        $active =  "Parola a fost resetată! Acum vă puteți autentifica.<br/>A fost trimis un e-mail cu noua dvs. parolă";
    } else {
        $inactive = "Legătura este expirată sau parola a fost deja resetată.";
    }
    //$dbc->close();
 }
?>
<?php include FORM; ?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter">
 
 <div class="w3-row">
   <div class="w3-rest w3-card w3-container w3-bluepm w3-margin-bottom">
   <h3>Activare cont</h3>
   
<?php if(isset($active)){ ?>
<div class="w3-panel w3-padding w3-seagreen w3-center"><?php echo $active; ?><br/><br/>
<p><i class="fa fa-check-square-o w3-center" style="font-size:100px;"></i></p>
</div>
<?php } ?>

<?php if(isset($inactive)){ ?>
<div class="w3-panel w3-padding w3-red w3-center"><?php echo $inactive; ?><br/><br/>
<p><i class="fa fa-close w3-center" style="font-size:100px;"></i></p>
</div>
<?php } ?>   
   </div>
  </div>
 </div>
</div>
<?php }
  
    
 }elseif($page == 'admin'){
    
    if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire'.$pagext)) {
    if($_SESSION['level'] == 1){

if (strpos($_SERVER['REQUEST_URI'], '?show=pagini') !== false){  
  $titget = 'Pagini';
 }
 elseif (strpos($_SERVER['REQUEST_URI'], '?show=anunturi') !== false){  
  $titget = 'Anunțuri';
 }
 elseif (strpos($_SERVER['REQUEST_URI'], '?show=categorii') !== false){  
  $titget = 'Categorii';
 }
 elseif (strpos($_SERVER['REQUEST_URI'], '?show=scategorii') !== false){  
  $titget = 'Sub-categorii';
 }
 elseif (strpos($_SERVER['REQUEST_URI'], '?show=utilizatori') !== false){  
  $titget = 'Utilizatori';
 }
 elseif (strpos($_SERVER['REQUEST_URI'], '?show=promovare') !== false){  
  $titget = 'Promovare';
 }
 elseif (strpos($_SERVER['REQUEST_URI'], '?show=info') !== false){  
  $titget = 'Informații';
 }
 elseif (strpos($_SERVER['REQUEST_URI'], '?show=setari') !== false){  
  $titget = 'Setări';
 }
 elseif (strpos($_SERVER['REQUEST_URI'], '?show=feed') !== false){  
  $titget = 'Feed';
 }
 else{
    $titget = 'Prezentare';
 }
?>

<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_adm.php'; ?>
</div>
<div class="w3-threequarter">


<div class="w3-row w3-text-white" style="background-color:#117594;">
<h3 class="w3-container"><?=$titget?></h3>
</div>

<?php if($titget == 'Prezentare'){
$qcp = "SELECT COUNT(*) AS countp FROM anunturi WHERE aprobat=0";
$rcp = $dbc->query($qcp) or die($dbc->error);
$rwcp = $rcp->fetch_assoc();
$countpag = $rwcp['countp'];

$qca = "SELECT COUNT(*) AS counta FROM anunturi WHERE aprobat=1";
$rca = $dbc->query($qca) or die($dbc->error);
$rwca = $rca->fetch_assoc();
$counta = $rwca['counta'];

$qcu = "SELECT COUNT(*) AS countu FROM utilizatori";
$rcu = $dbc->query($qcu) or die($dbc->error);
$rwcu = $rcu->fetch_assoc();
$countu = $rwcu['countu'];

$qcuo = "SELECT COUNT(*) AS countuo FROM utilizatori WHERE `online`=\"1\"";
$rcuo = $dbc->query($qcuo) or die($dbc->error);
$rwcuo = $rcuo->fetch_assoc();
if($rwcuo['countuo'] >= '1'){
$countuo = $rwcuo['countuo'];
  }else{
    $countuo = '0';
  }
?>
<div class="w3-row-padding w3-margin-top w3-margin-bottom">
    <div class="w3-quarter">
      <div class="w3-container w3-red w3-padding-16">
        <div class="w3-left"><i class="fa fa-bullhorn w3-xxxlarge"></i></div>
        <div class="w3-right">
          <h3><?=$countpag?></h3>
        </div>
        <div class="w3-clear"></div>
        <h4>Anunțuri inactive</h4>
      </div>
    </div>
    <div class="w3-quarter">
      <div class="w3-container w3-blue w3-padding-16">
        <div class="w3-left"><i class="fa fa-bullhorn w3-xxxlarge"></i></div>
        <div class="w3-right">
          <h3><?=$counta?></h3>
        </div>
        <div class="w3-clear"></div>
        <h4>Anunțuri active</h4>
      </div>
    </div>
    <div class="w3-quarter">
      <div class="w3-container w3-teal w3-padding-16">
        <div class="w3-left"><i class="fa fa-users w3-xxxlarge"></i></div>
        <div class="w3-right">
          <h3><?=$countu?></h3>
        </div>
        <div class="w3-clear"></div>
        <h4>Utilizatori</h4>
      </div>
    </div>
    <div class="w3-quarter">
      <div class="w3-container w3-green w3-text-white w3-padding-16">
        <div class="w3-left"><i class="fa fa-users w3-xxxlarge"></i></div>
        <div class="w3-right">
          <h3><?=$countuo?></h3>
        </div>
        <div class="w3-clear"></div>
        <h4>Utilizatori online</h4>
      </div>
    </div>
  </div>
  
  <div class="w3-grafphics">
  <canvas id="status" width="400" height="150"></canvas>
  </div>

<?php
$tm = date('n');
$qad = "SELECT data_publicarii FROM anunturi";
$rad = $dbc->query($qad);
while($rwd = $rad->fetch_assoc()){
    $datab = date('n', strtotime($rwd['data_publicarii']));
    $databa = date('Y', strtotime($rwd['data_publicarii']));
     }
    if($datab == '1'){$dtbs = '1';$luna = 'Ianuarie';}
elseif($datab == '2'){$dtbs = '2';$luna = 'Februarie';}
elseif($datab == '3'){$dtbs = '3';$luna = 'Martie';}
elseif($datab == '4'){$dtbs = '4';$luna = 'Aprilie';}
elseif($datab == '5'){$dtbs = '5';$luna = 'Mai';}
elseif($datab == '6'){$dtbs = '6';$luna = 'Iunie';}
elseif($datab == '7'){$dtbs = '7';$luna = 'Iulie';}
elseif($datab == '8'){$dtbs = '8';$luna = 'August';}
elseif($datab == '9'){$dtbs = '9';$luna = 'Septembrie';}
elseif($datab == '10'){$dtbs = '10';$luna = 'Octombrie';}
elseif($datab == '11'){$dtbs = '11';$luna = 'Noiembrie';}
elseif($datab == '12'){$dtbs = '12';$luna = 'Decembrie';}

$qcad = "SELECT COUNT(*) AS counta FROM anunturi 
                         WHERE YEAR(date(data_publicarii))=$databa 
                         AND MONTH(date(data_publicarii))=$dtbs";
$rcad = $dbc->query($qcad);
$rwcad = $rcad->fetch_assoc();
$clsm = $rwcad['counta'];

if($datab == '1'){
    $datab1 = '12';
    $sms = $datab1;
}else{
    $sms = $datab-1;
}

    if($sms == '1'){$dtbs1 = '1';$sluna = 'Ianuarie';}
elseif($sms == '2'){$dtbs1 = '2';$sluna = 'Februarie';}
elseif($sms == '3'){$dtbs1 = '3';$sluna = 'Martie';}
elseif($sms == '4'){$dtbs1 = '4';$sluna = 'Aprilie';}
elseif($sms == '5'){$dtbs1 = '5';$sluna = 'Mai';}
elseif($sms == '6'){$dtbs1 = '6';$sluna = 'Iunie';}
elseif($sms == '7'){$dtbs1 = '7';$sluna = 'Iulie';}
elseif($sms == '8'){$dtbs1 = '8';$sluna = 'August';}
elseif($sms == '9'){$dtbs1 = '9';$sluna = 'Septembrie';}
elseif($sms == '10'){$dtbs1 = '10';$sluna = 'Octombrie';}
elseif($sms == '11'){$dtbs1 = '11';$sluna = 'Noiembrie';}
elseif($sms == '12'){$dtbs1 = '12';$sluna = 'Decembrie';}

$qcads = "SELECT COUNT(*) AS counta FROM anunturi 
                         WHERE YEAR(date(data_publicarii))=$databa 
                         AND MONTH(date(data_publicarii))=$dtbs1";
$rcads = $dbc->query($qcads);
$rwcads = $rcads->fetch_assoc();
$csms = $rwcads['counta'];

if($datab == '1'){
    $datab1 = '11';
    $smt = $datab1;
}else{
    $smt = $datab-2;
}

//$smt = $datab-2;
    if($smt == '1'){$dtbs2 = '1';$tluna = 'Ianuarie';}
elseif($smt == '2'){$dtbs2 = '2';$tluna = 'Februarie';}
elseif($smt == '3'){$dtbs2 = '3';$tluna = 'Martie';}
elseif($smt == '4'){$dtbs2 = '4';$tluna = 'Aprilie';}
elseif($smt == '5'){$dtbs2 = '5';$tluna = 'Mai';}
elseif($smt == '6'){$dtbs2 = '6';$tluna = 'Iunie';}
elseif($smt == '7'){$dtbs2 = '7';$tluna = 'Iulie';}
elseif($smt == '8'){$dtbs2 = '8';$tluna = 'August';}
elseif($smt == '9'){$dtbs2 = '9';$tluna = 'Septembrie';}
elseif($smt == '10'){$dtbs2 = '10';$tluna = 'Octombrie';}
elseif($smt == '11'){$dtbs2 = '11';$tluna = 'Noiembrie';}
elseif($smt == '12'){$dtbs2 = '12';$tluna = 'Decembrie';}

$qcadt = "SELECT COUNT(*) AS counta FROM anunturi 
                         WHERE YEAR(date(data_publicarii))=$databa 
                         AND MONTH(date(data_publicarii))=$dtbs2";
$rcadt = $dbc->query($qcadt);
$rwcadt = $rcadt->fetch_assoc();
$csmt = $rwcadt['counta'];

if($datab == '1'){
    $datab1 = '10';
    $smq = $datab1;
}else{
    $smq = $datab-3;
}

//$smq = $datab-3;
    if($smq == '1'){$dtbs3 = '1';$qluna = 'Ianuarie';}
elseif($smq == '2'){$dtbs3 = '2';$qluna = 'Februarie';}
elseif($smq == '3'){$dtbs3 = '3';$qluna = 'Martie';}
elseif($smq == '4'){$dtbs3 = '4';$qluna = 'Aprilie';}
elseif($smq == '5'){$dtbs3 = '5';$qluna = 'Mai';}
elseif($smq == '6'){$dtbs3 = '6';$qluna = 'Iunie';}
elseif($smq == '7'){$dtbs3 = '7';$qluna = 'Iulie';}
elseif($smq == '8'){$dtbs3 = '8';$qluna = 'August';}
elseif($smq == '9'){$dtbs3 = '9';$qluna = 'Septembrie';}
elseif($smq == '10'){$dtbs3 = '10';$qluna = 'Octombrie';}
elseif($smq == '11'){$dtbs3 = '11';$qluna = 'Noiembrie';}
elseif($smq == '12'){$dtbs3 = '12';$qluna = 'Decembrie';}

$qcadq = "SELECT COUNT(*) AS counta FROM anunturi 
                         WHERE YEAR(date(data_publicarii))=$databa 
                         AND MONTH(date(data_publicarii))=$dtbs3";
$rcadq = $dbc->query($qcadq);
$rwcadq = $rcadq->fetch_assoc();
$csmq = $rwcadq['counta'];

?>

<script src="<?=PATH?>lib/js/Chart.min.js"></script>
<script src="<?=PATH?>lib/js/moment.js"></script>
  <script>
var ctx = document.getElementById('status').getContext('2d');
var status = new Chart(ctx, {
    type: 'line',
    data: {
        labels: ['<?=$qluna?>', '<?=$tluna?>', '<?=$sluna?>', '<?=$luna?>'],
        datasets: [{
            label: '# Anunțuri',
            data: [<?=$csmq?>, <?=$csmt?>, <?=$csms?>, <?=$clsm?>],
            backgroundColor: [
                'rgba(69, 120, 208, 0.2)',
                'rgba(54, 162, 235, 0.2)'                
            ],
            borderColor: [
                'rgba(255, 99, 132, 1)',
                'rgba(54, 162, 235, 1)'
            ],
            borderWidth: 1
        }]
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero: true
                }
            }]
        }
    }
});
</script>
<?php } ?>

<?php if($titget == 'Anunțuri'){ ?>

<?php
/*if(!empty($actualizat)){echo $actualizat;}
if(!empty($neactualizat)){echo $neactualizat;}
if(!empty($refuzat)){echo $refuzat;}
if(!empty($nerefuzat)){echo $nerefuzat;}
if(!empty($acta)){echo $acta;}
if(!empty($neacta)){echo $neacta;}*/
?>

<div class="w3-responsive">
<table class="w3-table-all">
<tr>
  <th class="w3-hide-small">ID</th>
  <th>Titlu</th>
  <th>Acțiuni</th>
</tr>
<?php
$qanunt = "SELECT * FROM anunturi";
$ranunt = $dbc->query($qanunt);
while($ra = $ranunt->fetch_assoc()){    
      
      $qusr = "SELECT * FROM `utilizatori` WHERE `uid`='{$ra['uid']}' LIMIT 1";
      $rusr = $dbc->query($qusr);
          while($rowusr = $rusr->fetch_assoc()){
            $usruid       = $rowusr['uid'];
            $usremail     = $rowusr['email'];
            $usrprenume   = $rowusr['prenume'];
            $usrnume      = $rowusr['nume'];                        
           }
      $getusermail = explode("@", $usremail);
      $eusername = $getusermail[0];
      
      $qcat = "SELECT * FROM `categorii` WHERE `cat_id`='{$ra['cat_id']}' LIMIT 1";
      $rcat = $dbc->query($qcat);
          while($rowcat = $rcat->fetch_assoc()){
            $cat_titlu  = $rowcat['titlu'];                                    
           }
      
      $qscat = "SELECT * FROM `scategorii` WHERE `scat_id`='{$ra['scat_id']}' LIMIT 1";
      $rscat = $dbc->query($qscat);
          while($rowscat = $rscat->fetch_assoc()){
            $scat_titlu  = $rowscat['titlu'];                                    
           }
?>
<tr>
 <td class="w3-hide-small"><?=$ra['aid']?></td>
 <td><?=$ra['titlu']?></td>
 <td><div class="w3-bar" style="margin:0px;padding:0px;">
 
<a onclick="document.getElementById('vezia<?=$ra['aid']?>').style.display='block'" class="w3-button w3-bar-item w3-indigo w3-hover-teal w3-padding-small" title="Vezi anunțul" style="text-decoration:none;"><i class="fa fa-eye"></i></a>

<div id="vezia<?=$ra['aid']?>" class="w3-modal w3-margin-top">
    <div class="w3-modal-content w3-animate-top w3-card-4" style="width:800px;max-width:100%;">
      <header class="w3-container w3-indigo"> 
        <span onclick="document.getElementById('vezia<?=$ra['aid']?>').style.display='none'" 
        class="w3-button w3-display-topright w3-hover-red">&times;</span>
        <h3><i class="fa fa-eye"></i> <?=$ra['titlu']?></h3>
      </header>
      <div class="w3-container">        
        <div class="w3-row-padding">   
   
   <div class="w3-border-bottom">   
   <strong>Conținutul anunțului:</strong><br/>
   <p style="white-space: pre-line;"><?=$ra['descriere']?></p>
   </div>
   
   <div class="w3-border-bottom">
   <strong>Categorie:</strong> <?=$cat_titlu?>, 
   <strong>Sub-categorie:</strong> <?=$scat_titlu?>, 
   <strong>Etichetele anunțului:</strong> <?=$ra['etichete']?>
   </div>
   
   <div class="w3-row">
   <div class="w3-border-bottom">
   <?php
   $qimg = "SELECT * FROM `imagini` WHERE `aid`='{$ra['aid']}'";
    $rimg = $dbc->query($qimg);
      while($rowimg = $rimg->fetch_assoc()){
        $poza = $rowimg['nume_fisier'];     
      ?>
      
   <img class="w3-col" src="<?=PATH?>imagini/<?=$poza?>" style="width:250px;height:200px;object-fit:cover;" alt="<?=$poza?>"/>
   
   <?php } ?>
   </div></div>
   
   <div class="w3-margin-bottom">   
   <strong>Adăugat de:</strong> 
   <?php if($usrprenume){echo $usrprenume;if($usrnume){echo ' '.$usrnume;}echo ' ('.$usremail.')';}else{echo 'user-'.$eusername.'-adydev-'.$usruid;} ?><br/>
   <strong>La data:</strong>
   <?php echo date('d F Y, H:i', strtotime($ra['data_publicarii'])); ?><br/>
   <strong>De la adresa IP:</strong> <?=$ra['ip']?>
   </div>
   
</div>        
      </div>
      <footer class="w3-container w3-center w3-indigo">
        <p>Doar adminul poate vedea un anunț nepublicat.</p>
      </footer>
    </div>
  </div>
 
 <a onclick="document.getElementById('edita<?=$ra['aid']?>').style.display='block'" class="w3-button w3-bar-item w3-blue w3-hover-teal w3-padding-small" title="Editare anunț" style="text-decoration:none;"><i class="fa fa-pencil-square-o"></i></a>

<div id="edita<?=$ra['aid']?>" class="w3-modal w3-margin-top">
    <div class="w3-modal-content w3-animate-top w3-card-4" style="width:800px;max-width:100%;">
      <header class="w3-container w3-indigo"> 
        <span onclick="document.getElementById('edita<?=$ra['aid']?>').style.display='none'" 
        class="w3-button w3-display-topright w3-hover-red">&times;</span>
        <h3><i class="fa fa-pencil-square-o"></i> Editare anunț</h3>
      </header>
      <div class="w3-container">        
        <div class="w3-row-padding">   

<form action="" method="post">
<div class="w3-margin-top">   
<input class="w3-input w3-border w3-round" type="text" name="titlu" value="<?=$ra['titlu']?>" placeholder="Titlul anunțului.."/></div>
   
<div class="w3-margin-top">   
<textarea class="w3-input w3-border w3-round" rows="5" style="white-space: pre-line;" name="descriere"><?=$ra['descriere']?></textarea>
</div>
   
<div class="w3-container w3-margin-top">

<select class="w3-input w3-col w3-xlarge w3-border w3-white srccat" name="categorie" id="categorie<?=$ra['aid']?>" style="width:48%;margin-right:1%;padding-left:8%;">
<?php if(empty($ra['categorie'])){?>
   <option value="" selected="" disabled="" class="w3-hide">Selectați o categorie</option>
<?php } ?>
   <?php
$qcat = "SELECT * FROM `categorii` ORDER BY `titlu` ASC";
$rcat = $dbc->query($qcat) or die($dbc->error);
while($rc = $rcat->fetch_array()){    
       echo '<option value="'.$rc['cat_id'].'" class="w3-light-gray w3-hover-indigo w3-large w3-card" style="text-transform:uppercase;">'.$rc['titlu'].'</option>';      
      }
?>   
</select>
<select class="w3-input w3-col w3-xlarge w3-border w3-white srccat" name="scat" id="scat<?=$ra['aid']?>" style="width:48%;margin-right:1%;padding-left:8%;">
<option value="" disabled="" selected="" class="w3-hide">Selectați categoria</option>
</select>

<script type="text/javascript">
$(document).ready(function(){

    $('#categorie<?=$ra['aid']?>').on("change",function () {
        var cat_id = $(this).find('option:selected').val();
        $.ajax({
            url: "ajax.php",
            type: "POST",
            //data: "cat_id = "+catId,
            data: {cat_id : cat_id},
            cache: false,
            success: function (response) {
                console.log(response);
                $("#scat<?=$ra['aid']?>").html(response);
            },
        });
    }); 

});

</script>

</div>

<div class="w3-margin-top w3-margin-bottom">   
<input class="w3-input w3-border w3-round" type="text" name="etichete" value="<?=$ra['etichete']?>" placeholder="Etichetele anunțului.."/></div>

<div class="w3-margin-bottom w3-center">
<button class="w3-button w3-green w3-hover-indigo" type="submit"><i class="fa fa-check"></i> Actualizare</button>
</div>

<input type="hidden" name="aid" value="<?=$ra['aid']?>"/>
<input type="hidden" name="aeditareanunt" value="true"/>
</form>
   
</div>        
      </div>
      <footer class="w3-container w3-center w3-indigo">
        <p>Doar adminul poate edita un anunț în această zonă.</p>
      </footer>
    </div>
  </div>
  
  <form action="" method="post"/>
  <button class="w3-button w3-bar-item w3-red w3-hover-black w3-padding-small" title="Șterge anunț" style="text-decoration:none;"><i class="fa fa-trash-o"></i></button>
  <input type="hidden" name="aid" value="<?=$ra['aid']?>"/>
  <input type="hidden" name="admdeletead" value="true"/>
  </form>

<?php if(($ra['aprobat'] == '0') && ($ra['refuzat'] == '0')){ ?>

 <div class="w3-bar-item" style="margin:0px;padding:0px;">
 <form action="" method="post">
 <button type="submit" class="w3-button w3-green w3-hover-teal w3-padding-small" title="Aprobă anunțul">
 <i class="fa fa-check"></i></button>
 <input type="hidden" name="aid" value="<?=$ra['aid']?>"/>
 <input type="hidden" name="aprobanunt" value="true"/> 
 </form>
 </div>
 
<a onclick="document.getElementById('refuza<?=$ra['aid']?>').style.display='block'" class="w3-button w3-bar-item w3-red w3-hover-black w3-padding-small" title="Refuză anunțul" style="text-decoration:none;"><i class="fa fa-ban"></i></a>
 
 <div id="refuza<?=$ra['aid']?>" class="w3-modal w3-margin-top">
    <div class="w3-modal-content w3-animate-top w3-card-4" style="width:400px;max-width:100%;">
      <header class="w3-container w3-indigo"> 
        <span onclick="document.getElementById('refuza<?=$ra['aid']?>').style.display='none'" 
        class="w3-button w3-display-topright w3-hover-red">&times;</span>
        <h3><i class="fa fa-ban"></i> Refuzare anunț</h3>
      </header>
      <div class="w3-container">        
        <div class="w3-row-padding">
<form class="w3-container" action="" method="post">
   <div class="w3-margin-top w3-margin-bottom">   
   <textarea class="w3-input w3-border" name="motiv" placeholder="Motivul refuzului.." required=""></textarea>
   </div>   
      
   <div class="w3-margin-bottom w3-center">
   <button class="w3-button w3-red w3-hover-black" type="submit"><i class="fa fa-ban"></i> Refuză</button>
   </div>
   <input type="hidden" name="aid" value="<?=$ra['aid']?>"/>
   <input type="hidden" name="refuzanunt" value="true"/>   
   </form>
</div>

      </div>
      <footer class="w3-container w3-center w3-indigo">
        <p>Un anunț refuzat nu va fi vizibil.</p>
      </footer>
    </div>
  </div>
 
<?php }
if($ra['aprobat'] == '1'){
    echo '<div class="w3-text-green" style="margin-top:4px;">&nbsp; <i class="fa fa-check"></i> Aprobat</div>';
}
if($ra['refuzat'] == '1'){
    echo '<div class="w3-text-red" style="margin-top:4px;">&nbsp; <i class="fa fa-times"></i> Refuzat('.$ra['motiv'].')</div>';
}
?>
 
 </div>
 
 </td>
</tr>
<?php } ?>
</table>
</div>
<?php } ?>
<?php if($titget == 'Categorii'){ ?>
<div class="w3-responsive">
<?php if(isset($actc) == 1){ ?>
<div class="w3-panel w3-padding-large w3-green">
<i class="fa fa-check"></i> Categoria a fost actualizată</div>
<?php } ?>
<?php if(isset($neactc) == 2){ ?>
<div class="w3-panel w3-padding-large w3-red">
<i class="fa fa-remove"></i> Categoria nu a fost actualizată</div>
<?php } ?>

<?php if(isset($delc) == 1){ ?>
<div class="w3-panel w3-padding-large w3-green">
<i class="fa fa-check"></i> Categoria a fost ștearsă</div>
<?php } ?>
<?php if(isset($nedelc) == 2){ ?>
<div class="w3-panel w3-padding-large w3-red">
<i class="fa fa-remove"></i> Categoria nu a putut fi ștearsă</div>
<?php } ?>

<table class="w3-table-all">
<tr>
  <th class="w3-hide-small">ID</th>
  <th>Titlu</th>
  <th>Acțiuni</th>
</tr>
<?php
$qcat = "SELECT * FROM `categorii` ORDER BY `titlu` ASC";
$rcat = $dbc->query($qcat);
while($rc = $rcat->fetch_assoc()){
?>
<tr>
 <td class="w3-hide-small"><?=$rc['cat_id']?></td>
 <td><?=$rc['titlu']?></td>
 <td><div class="w3-bar" style="margin:0px;padding:0px;">
 
 <a onclick="document.getElementById('edit<?=$rc['cat_id']?>').style.display='block'" class="w3-button w3-bar-item w3-green w3-hover-blue w3-padding-small" title="Editează categoria" style="text-decoration:none;"><i class="fa fa-pencil-square-o"></i></a>
 
 <div id="edit<?=$rc['cat_id']?>" class="w3-modal w3-margin-top">
    <div class="w3-modal-content w3-animate-top w3-card-4" style="width:640px;max-width:100%;">
      <header class="w3-container w3-green"> 
        <span onclick="document.getElementById('edit<?=$rc['cat_id']?>').style.display='none'" 
        class="w3-button w3-display-topright w3-hover-red">&times;</span>
        <h3><i class="fa fa-pencil-square-o"></i> Editare categorie</h3>
      </header>
      <div class="w3-container">        
        <div class="w3-row-padding">
<form class="w3-container" action="" method="post">
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="titlu" class="w3-small" style="margin-bottom:-4px;">Titlu *</label>   
   <input class="w3-input w3-border" name="titlu" placeholder="Titlul categoriei" required="" value="<?php if(!empty($rc['titlu'])){echo $rc['titlu'];} ?>"/>
   </div>
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="descriere" class="w3-small" style="margin-bottom:-4px;">Descriere</label>   
   <textarea class="w3-input w3-border" name="descriere" placeholder="Descriere categoriei" required=""><?php if(!empty($rc['descriere'])){echo $rc['descriere'];} ?></textarea>
   </div>   
      
   <div class="w3-margin-bottom w3-center">
   <button class="w3-button w3-blue w3-hover-green" type="submit"><i class="fa fa-check"></i> Actualizare</button>
   </div>
   <input type="hidden" name="cid" value="<?=$rc['cat_id']?>"/>
   <input type="hidden" name="aeditarecat" value="true"/>   
   </form>
</div>

      </div>
      <footer class="w3-container w3-center w3-green">
        <p>* Prin schimbarea numelui se schimbă și adresa, ar putea afecta către motoarele de căutare.</p>
      </footer>
    </div>
  </div>
 
 <div class="w3-bar-item" style="margin:0px;padding:0px;">
 <form action="" method="post">
 <button type="submit" class="w3-button w3-red w3-hover-black w3-padding-small">
 <i class="fa fa-remove"></i></button>
 <input type="hidden" name="cid" value="<?=$rc['cat_id']?>"/>
 <input type="hidden" name="astergecat" value="true"/> 
 </form>
 </div>
 
 </div>
 
 </td>
</tr>
<?php } ?>
</table>
</div>
<?php if(isset($starecatN) == 1){ ?>
<div class="w3-panel w3-padding-large w3-green">
<i class="fa fa-check"></i> Categoria a fost adăugată</div>
<?php }elseif(isset($starecatN) == 2){ ?>
<div class="w3-panel w3-padding-large w3-red">
<i class="fa fa-remove"></i> Categoria nu a fost adăugată</div>
<?php } ?>
<div class="w3-row w3-blue w3-center w3-margin-top">
<form action="" method="post">
<div class="w3-container">
<textarea rows="3" class="w3-input w3-margin-top" name="cat_Dnoua" placeholder="Completați o descriere despre categorie..." style="">
</textarea>
</div>
</div>
<div class="w3-row w3-blue w3-center w3-margin-bottom">
<div class="w3-threequarter w3-container">
<input class="w3-input w3-margin-top w3-margin-bottom" name="cat_Tnoua" value="" placeholder="Numele categoriei..."/>
</div>
<div class="w3-quarter w3-container">
<button type="submit" class="w3-button w3-block w3-white w3-hover-black w3-margin-top w3-margin-bottom">Adaugă categorie</button>
</div>
<input type="hidden" name="adaugarecategorie" value="true"/>
</form>
</div>
<?php } ?>
<?php if($titget == 'Sub-categorii'){ ?>
<div class="w3-responsive">

<?php if(isset($actsc) == 1){ ?>
<div class="w3-panel w3-padding-large w3-green">
<i class="fa fa-check"></i> Sub-Categoria a fost actualizată</div>
<?php }elseif(isset($neactsc) == 2){ ?>
<div class="w3-panel w3-padding-large w3-red">
<i class="fa fa-remove"></i> Sub-categoria nu a putut fi actualizată</div>
<?php } ?>

<?php if(isset($delsc) == 1){ ?>
<div class="w3-panel w3-padding-large w3-green">
<i class="fa fa-check"></i> Sub-Categoria a fost ștearsă</div>
<?php }elseif(isset($nedelsc) == 2){ ?>
<div class="w3-panel w3-padding-large w3-red">
<i class="fa fa-remove"></i> Sub-categoria nu a putut fi ștearsă</div>
<?php } ?>

<table class="w3-table-all">
<tr>
  <th class="w3-hide-small">ID</th>
  <th class="w3-hide-small">Categorie</th>
  <th>Sub-categorie</th>
  <th>Acțiuni</th>
</tr>
<?php
$qscat = "SELECT `scategorii`.`scat_id`, `scategorii`.`cat_id`,`scategorii`.`titlu`,`scategorii`.`descriere`,`categorii`.`titlu` AS `cTitlu` FROM `scategorii`, `categorii` WHERE `scategorii`.`cat_id`=`categorii`.`cat_id` ORDER BY `scategorii`.`titlu` ASC";
          
$rscat = $dbc->query($qscat);
while($rsc = $rscat->fetch_assoc()){
?>
<tr>
 <td class="w3-hide-small"><?=$rsc['scat_id']?></td>
 <td class="w3-hide-small"><?=$rsc['cTitlu']?></td>
 <td><?=$rsc['titlu']?></td>
 <td><div class="w3-bar" style="margin:0px;padding:0px;">

 
<a onclick="document.getElementById('edit<?=$rsc['scat_id']?>').style.display='block'" class="w3-button w3-bar-item w3-green w3-hover-blue w3-padding-small" title="Editează sub-categoria" style="text-decoration:none;"><i class="fa fa-pencil-square-o"></i></a>
 
 <div id="edit<?=$rsc['scat_id']?>" class="w3-modal w3-margin-top">
    <div class="w3-modal-content w3-animate-top w3-card-4" style="width:640px;max-width:100%;">
      <header class="w3-container w3-green"> 
        <span onclick="document.getElementById('edit<?=$rsc['scat_id']?>').style.display='none'" 
        class="w3-button w3-display-topright w3-hover-red">&times;</span>
        <h3><i class="fa fa-pencil-square-o"></i> Editare sub-categorie</h3>
      </header>
      <div class="w3-container">        
        <div class="w3-row-padding">
<form class="w3-container" action="" method="post">
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="titlu" class="w3-small" style="margin-bottom:-4px;">Titlu *</label>   
   <input class="w3-input w3-border" name="titlu" placeholder="Titlul sub-categoriei" required="" value="<?php if(!empty($rsc['titlu'])){echo $rsc['titlu'];} ?>"/>
   </div>
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="categorie" class="w3-small" style="margin-bottom:-4px;">Categorie</label>   
   <select class="w3-input w3-col w3-xlarge w3-border w3-white srccata" name="cid" style="padding-left:8%;" required="">
   <?php if($rsc['cat_id'] == 0){?>
<option value="" selected="" disabled="" class="w3-hide">Selectați o categorie</option>
<?php } ?>
 <?php
$qcat = "SELECT * FROM `categorii` ORDER BY `titlu` ASC";
$rcat = $dbc->query($qcat);
while($rc = $rcat->fetch_array()){    
       echo '<option value="'.$rc['cat_id'].'" class="w3-light-gray w3-hover-blue w3-large w3-card"';if($rc['cat_id'] == $rsc['cat_id']){echo ' selected=""';}echo '> '.$rc['titlu'].'</option>';      
      }
?>   
</select>
   </div>
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="descriere" class="w3-small" style="margin-bottom:-4px;">Descriere</label>   
   <textarea class="w3-input w3-border" name="descriere" placeholder="Descriere sub-categoriei" required=""><?php if(!empty($rsc['descriere'])){echo $rsc['descriere'];} ?></textarea>
   </div>   
      
   <div class="w3-margin-bottom w3-center">
   <button class="w3-button w3-blue w3-hover-green" type="submit"><i class="fa fa-check"></i> Actualizare</button>
   </div>   
   <input type="hidden" name="scid" value="<?=$rsc['scat_id']?>"/>
   <input type="hidden" name="aeditarescateg" value="true"/>   
   </form>
</div>

      </div>
      <footer class="w3-container w3-center w3-green">
        <p>* Prin schimbarea numelui se schimbă și adresa, ar putea afecta către motoarele de căutare.</p>
      </footer>
    </div>
  </div>

 
 <div class="w3-bar-item" style="margin:0px;padding:0px;">
 <form action="" method="post">
 <button type="submit" class="w3-button w3-red w3-hover-black w3-padding-small">
 <i class="fa fa-remove"></i></button>
 <input type="hidden" name="scid" value="<?=$rsc['scat_id']?>"/>
 <input type="hidden" name="astergescateg" value="true"/> 
 </form>
 </div>
 
 </div>
 
 </td>
</tr>
<?php } ?>
</table>
</div>

<?php if(isset($stareScatN) == 1){ ?>
<div class="w3-panel w3-padding-large w3-green">
<i class="fa fa-check"></i> Sub-Categoria a fost adăugată</div>
<?php }elseif(isset($stareScatN) == 2){ ?>
<div class="w3-panel w3-padding-large w3-red">
<i class="fa fa-remove"></i> Sub-Categoria nu a fost adăugată</div>
<?php } ?>
<div class="w3-row w3-blue w3-center w3-margin-top">
<form action="" method="post">

<div class="w3-container">
<select class="w3-input w3-half w3-xlarge w3-border w3-white srccat w3-margin-top" name="catID" style="padding-left:12%;" required="">
<option value="" selected="" disabled="" class="w3-hide">Selectați o categorie</option>
 <?php
$qcat = "SELECT * FROM categorii";
$rcat = $dbc->query($qcat);
while($rc = $rcat->fetch_array()){
       echo '<option value="'.$rc['cat_id'].'" class="w3-light-gray w3-hover-indigo w3-large w3-card">&#xf009; '.$rc['titlu'].'</option>';      
      }
?>   
</select>
</div>

<div class="w3-container">
<textarea rows="3" class="w3-input w3-margin-top" name="scat_Dnoua" placeholder="Completați o descriere despre sub-categorie..." style="">
</textarea>
</div>
</div>
<div class="w3-row w3-blue w3-center w3-margin-bottom">
<div class="w3-threequarter w3-container">
<input class="w3-input w3-margin-top w3-margin-bottom" name="scat_Tnoua" value="" placeholder="Numele sub-categoriei..."/>
</div>
<div class="w3-quarter w3-container">
<button type="submit" class="w3-button w3-block w3-white w3-hover-black w3-margin-top w3-margin-bottom">Adaugă sub-categorie</button>
</div>
<input type="hidden" name="adaugarescategorie" value="true"/>
</form>
</div>

<?php } ?>
<?php if($titget == 'Utilizatori'){ ?>
<div class="w3-responsive">

<?php if(isset($msent) == 1){ ?>
<div class="w3-panel w3-padding-large w3-green">
<i class="fa fa-check"></i> Mesajul a fost transmis</div>
<?php } 
if(isset($mnotsent) == 2){ ?>
<div class="w3-panel w3-padding-large w3-red">
<i class="fa fa-remove"></i> Mesajul nu a fost transmis</div>
<?php } ?>

<?php if(isset($actep) == 1){ ?>
<div class="w3-panel w3-padding-large w3-green">
<i class="fa fa-check"></i> Profilul a fost actualizat</div>
<?php } 
if(isset($nactep) == 1){ ?>
<div class="w3-panel w3-padding-large w3-red">
<i class="fa fa-remove"></i> Profilul nu a fost actualizat</div>
<?php } ?>

<?php if(isset($blockp) == 1){ ?>
<div class="w3-panel w3-padding-large w3-green">
<i class="fa fa-check"></i> Profilul a fost blocat</div>
<?php } 
if(isset($nblockp) == 1){ ?>
<div class="w3-panel w3-padding-large w3-red">
<i class="fa fa-remove"></i> Profilul nu a fost blocat! Posibil să fie Admin.</div>
<?php } ?>

<?php if(isset($unblockp) == 1){ ?>
<div class="w3-panel w3-padding-large w3-green">
<i class="fa fa-check"></i> Profilul a fost deblocat</div>
<?php } 
if(isset($nunblockp) == 1){ ?>
<div class="w3-panel w3-padding-large w3-red">
<i class="fa fa-remove"></i> Profilul nu a fost deblocat</div>
<?php } ?>

<table class="w3-table-all">
<tr>
  <th class="w3-hide-small">ID</th>
  <th class="w3-hide-small">Level</th>
  <th class="w3-hide-small">Prenume</th>
  <th>Adresa de e-mai</th>
  <th class="w3-right" style="margin-right:20px;">Acțiuni</th>
</tr>
<?php
$qusr = "SELECT * FROM utilizatori";
$rusr = $dbc->query($qusr);
while($ru = $rusr->fetch_assoc()){
?>
<tr>
 <td class="w3-hide-small"><?=$ru['uid']?></td>
 <td class="w3-hide-small"><?=$ru['level']?></td>
 <td class="w3-hide-small"><?=$ru['prenume']?></td>
 <td><?=$ru['email']?></td>
 <td class="w3-right"><div class="w3-bar" style="margin:0px;padding:0px;">

<?php if($_SESSION['user_id'] !== $ru['uid']){?>
<a onclick="document.getElementById('mesaj<?=$ru['uid']?>').style.display='block'" class="w3-button w3-bar-item w3-blue w3-hover-green w3-padding-small" title="Trimite mesaj" style="text-decoration:none;"><i class="fa fa-envelope-o"></i></a>
 
 <div id="mesaj<?=$ru['uid']?>" class="w3-modal w3-margin-top">
    <div class="w3-modal-content w3-animate-top w3-card-4" style="width:640px;max-width:100%;">
      <header class="w3-container w3-green"> 
        <span onclick="document.getElementById('mesaj<?=$ru['uid']?>').style.display='none'" 
        class="w3-button w3-display-topright w3-hover-red">&times;</span>
        <h3><i class="fa fa-envelope-o"></i> Trimite mesaj</h3>
      </header>
      <div class="w3-container">        
        <div class="w3-row-padding">
<form class="w3-container" action="" method="post">
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="subiect" class="w3-small" style="margin-bottom:-4px;">Subiect</label>   
   <input class="w3-input w3-border" name="subiect" placeholder="Subiectul mesajului" required=""/>
   </div>
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="continut" class="w3-small" style="margin-bottom:-4px;">Mesaj</label>   
   <textarea class="w3-input w3-border" name="continut" placeholder="Conținutul mesajului..." required="" style="white-space: pre;"></textarea>
   </div>   
      
   <div class="w3-margin-bottom w3-center">
   <button class="w3-button w3-blue w3-hover-green" type="submit"><i class="fa fa-check"></i> Trimite</button>
   </div>
   <input type="hidden" name="uid" value="<?=$ru['uid']?>"/>
   <input type="hidden" name="atrimitemesaj" value="true"/>   
   </form>
</div>

      </div>
      <footer class="w3-container w3-center w3-green">
        <p style="margin-top:8px;">Mesajul v-a ajunge către adresa de e-mail: <strong><?=$ru['email']?></strong></p>
      </footer>
    </div>
  </div>
<?php } ?>
 
 <a onclick="document.getElementById('edit<?=$ru['uid']?>').style.display='block'" class="w3-button w3-bar-item w3-green w3-hover-indigo w3-padding-small" title="Editează profil" style="text-decoration:none;"><i class="fa fa-pencil-square-o"></i></a>
 
 <div id="edit<?=$ru['uid']?>" class="w3-modal w3-margin-top">
    <div class="w3-modal-content w3-animate-top w3-card-4" style="width:640px;max-width:100%;">
      <header class="w3-container w3-green"> 
        <span onclick="document.getElementById('edit<?=$ru['uid']?>').style.display='none'" 
        class="w3-button w3-display-topright w3-hover-red">&times;</span>
        <h3><i class="fa fa-pencil-square-o"></i> Editează profil</h3>
      </header>
      <div class="w3-container">        
        <div class="w3-row-padding">
<form class="w3-container" action="" method="post">
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="Nume" class="w3-small" style="margin-bottom:-4px;">Numele</label>   
   <input class="w3-input w3-border" name="nume" placeholder="Numele de familie..." value="<?php if(!empty($ru['nume'])){echo $ru['nume'];} ?>"/>
   </div>
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="Prenume" class="w3-small" style="margin-bottom:-4px;">Prenumele</label>   
   <input class="w3-input w3-border" name="prenume" placeholder="Prenumele..." value="<?php if(!empty($ru['prenume'])){echo $ru['prenume'];} ?>"/>
   </div>
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="Mobil" class="w3-small" style="margin-bottom:-4px;">Mobil (Ex. 40753023777)</label>   
   <input class="w3-input w3-border" name="mobil" placeholder="Numărul de mobil..." value="<?php if(!empty($ru['mobil'])){echo $ru['mobil'];} ?>"/>
   </div>
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="Moneda" class="w3-small" style="margin-bottom:-4px;">Moneda</label>
   <select name="moneda" class="w3-select srccur" style="padding-left:40px;">
   <?php if(!empty($ru['moneda'])){$selected = ' selected=""';}
   if($ru['moneda'] == 'RON'){?>
    <option value="EUR">EURO</option>
    <option value="<?=$ru['moneda']?>"<?=$selected?>><?=$ru['moneda']?></option>
   <?php }elseif($ru['moneda'] == 'EUR'){ ?>
   <option value="<?=$ru['moneda']?>"<?=$selected?>><?=$ru['moneda']?></option>
   <option value="RON">RON</option>
   <?php }else{ ?>
     <option value="RON" selected="">Monda implicită</option>
     <option value="EUR">EURO</option>
     <option value="RON">RON</option>
     <?php } ?>
   </select>   
   </div>
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="Rol" class="w3-small" style="margin-bottom:-4px;">Rol</label>
   <select name="level" class="w3-select srccur" style="padding-left:40px;">
   <?php if(!empty($ru['level'])){$selected = ' selected=""';}
   if($ru['level'] == '0'){?>
    <option value="1">Admin</option>
    <option value="<?=$ru['level']?>"<?=$selected?>>Utilizator</option>
   <?php }elseif($ru['level'] == '1'){ ?>
   <option value="<?=$ru['level']?>"<?=$selected?>>Admin</option>
   <option value="0">Utilizator</option>
   <?php } ?>
   </select>   
   </div>
      
   <div class="w3-margin-bottom w3-center">
   <button class="w3-button w3-blue w3-hover-green" type="submit"><i class="fa fa-check"></i> Trimite</button>
   </div>
   <input type="hidden" name="uid" value="<?=$ru['uid']?>"/>
   <input type="hidden" name="aeditareprofil" value="true"/>   
   </form>
</div>

      </div>
      <footer class="w3-container w3-center w3-green">
        <p style="margin-top:8px;">Editarea profilului corespndent adresei de e-mail: <strong><?=$ru['email']?></strong></p>
      </footer>
    </div>
  </div>
 
 <?php if($ru['blk'] == 0){ ?>
 <div class="w3-bar-item" style="margin:0px;padding:0px;">
 <form action="" method="post">
 <button type="submit" class="w3-button w3-blue w3-hover-black w3-padding-small">
 <i class="fa fa-unlock" title="Blocare utilizator"></i></button>
 <input type="hidden" name="uid" value="<?=$ru['uid']?>"/>
 <input type="hidden" name="level" value="<?=$ru['level']?>"/>
 <input type="hidden" name="blockusr" value="true"/> 
 </form>
 </div>
 <?php }else{ ?>
 <div class="w3-bar-item" style="margin:0px;padding:0px;">
 <form action="" method="post">
 <button type="submit" class="w3-button w3-red w3-hover-black w3-padding-small">
 <i class="fa fa-lock" title="Deblocare utilizator"></i></button>
 <input type="hidden" name="uid" value="<?=$ru['uid']?>"/>
 <input type="hidden" name="unblockusr" value="true"/> 
 </form>
 </div>
 <?php } ?>

 </div>
 
 </td>
</tr>
<?php } ?>
</table>
</div>
<?php } ?>
<?php if($titget == 'Promovare'){ ?>
<div class="w3-container w3-center w3-margin w3-xxlarge w3-text-gray">Această secțiune nu este disponibilă!</div>
<?php } ?>
<?php if($titget == 'Informații'){?>
<div class="w3-container w3-center w3-margin w3-xxlarge w3-text-gray">Această secțiune nu este disponibilă!</div>
<?php } ?>

<?php if($titget == 'Pagini'){ ?>
<div class="w3-responsive">

<?php if(isset($actp) == 1){ ?>
<div class="w3-panel w3-padding-large w3-green">
<i class="fa fa-check"></i> Pagina a fost actualizată</div>
<?php } 
if(isset($nactp) == 1){ ?>
<div class="w3-panel w3-padding-large w3-red">
<i class="fa fa-remove"></i> Pagina NU a fost actualizată</div>
<?php } ?>

<table class="w3-table-all">
<tr>
  <th class="w3-hide">ID</th>
  <th>Titlu</th>
  <th class="w3-hide-small">Descriere</th>
  <th class="w3-right" style="margin-right:15px;">Acțiuni</th>
</tr>
<?php
$qpagina = "SELECT * FROM `pagina` WHERE `sys`='0'";
$rpagina = $dbc->query($qpagina);
while($rp = $rpagina->fetch_assoc()){
?>
<tr>
 <td class="w3-hide"><?=$rp['pid']?></td>
 <td><?=$rp['titlu']?></td>
 <td class="w3-hide-small"><?=$rp['descriere']?></td>
 <td class="w3-right"><div class="w3-bar" style="margin:0px;padding:0px;">
 
 <a onclick="document.getElementById('edit<?=$rp['pid']?>').style.display='block'" class="w3-button w3-bar-item w3-green w3-hover-indigo w3-padding-small" title="Editează pagina" style="text-decoration:none;"><i class="fa fa-pencil-square-o"></i></a>
 
 <div id="edit<?=$rp['pid']?>" class="w3-modal w3-margin-top">
    <div class="w3-modal-content w3-animate-top w3-card-4" style="width:640px;max-width:100%;">
      <header class="w3-container w3-green"> 
        <span onclick="document.getElementById('edit<?=$rp['pid']?>').style.display='none'" 
        class="w3-button w3-display-topright w3-hover-red">&times;</span>
        <h3><i class="fa fa-pencil-square-o"></i> Editează pagina</h3>
      </header>
      <div class="w3-container">        
        <div class="w3-row-padding">
<form class="w3-container" action="" method="post">
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="Titlu" class="w3-small" style="margin-bottom:-4px;">Titlul paginii</label>   
   <input class="w3-input w3-border" name="titlu" placeholder="Titlul paginii..." value="<?php if(!empty($rp['titlu'])){echo $rp['titlu'];} ?>"/>
   </div>
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="Descriere" class="w3-small" style="margin-bottom:-4px;">Descrierea paginii</label>
   <textarea rows="3" class="w3-input w3-border" name="descriere" placeholder="Completați o descriere a paginii..."><?php if(!empty($rp['descriere'])){echo $rp['descriere'];} ?></textarea>
   </div>
   
   <div class="w3-margin-top w3-margin-bottom">
   <label for="Conținut" class="w3-small" style="margin-bottom:-4px;">Conținutul paginii</label>
   <textarea rows="4" class="w3-input w3-border" name="continut" placeholder="Completați un conținut al paginii..." style="white-space: pre;"><?php if(!empty($rp['continut'])){echo $rp['continut'];} ?></textarea>
   </div>
   
      
   <div class="w3-margin-bottom w3-center">
   <button class="w3-button w3-blue w3-hover-green" type="submit"><i class="fa fa-check"></i> Actualizează</button>
   </div>
   <input type="hidden" name="pid" value="<?=$rp['pid']?>"/>
   <input type="hidden" name="aeditarepagina" value="true"/>   
   </form>
</div>

      </div>
      <footer class="w3-container w3-center w3-green">
        <p style="margin-top:8px;">Editarea paginii v-a reflecta în iformațiile META, utile pentru motoarele de căutare.</p>
      </footer>
    </div>
  </div> 
 

 </div>
 </td>
</tr>
<?php } ?>
</table>
</div>

<?php } ?>

<?php if($titget == 'Setări'){ ?>
<?php if(isset($setact)){ ?>
<div class="w3-row">
<div class="w3-panel w3-blue" style="padding:7px;margin:0;">Datele au fost actualizate</div>
</div><?php }elseif(isset($setneact)){ ?>
<div class="w3-row">
<div class="w3-panel w3-red" style="padding:7px;margin:0;">Datele nu au fost actualizate</div>
</div><?php }?>
<div class="w3-bar w3-white">
<button class="w3-bar-item w3-button tablink w3-green" onclick="openSet(event,'baza')">Bază
</button>
<button class="w3-bar-item w3-button tablink" onclick="openSet(event,'mail')">E-mail
</button>
<button class="w3-bar-item w3-button tablink" onclick="openSet(event,'webmaster')">Webmaster
</button>
<button class="w3-bar-item w3-button tablink" onclick="openSet(event,'head')">Header
</button>
<button class="w3-bar-item w3-button tablink" onclick="openSet(event,'foot')">Footer
</button>
<button class="w3-bar-item w3-button tablink" onclick="openSet(event,'contact')">Contact
</button>
<button class="w3-bar-item w3-button tablink" onclick="openSet(event,'logo')">Logo &amp; Banner
</button>
</div>
<?php
$rset = $dbc->query("SELECT * FROM `setari` LIMIT 1");
$rwset = $rset->fetch_assoc();
?>
  
<form action="" method="post">
<div id="baza" class="w3-container w3-border setare">
<h2>Bază</h2>    
<div class="w3-row">

<div class="w3-row w3-margin-bottom">
<label for="nume_site" class="w3-small" style="margin-bottom:-5px;">Nume Site</label>
<input class="w3-input w3-card" type="text" name="nume_site" placeholder="Denumirea site-ului..." value="<?php if(!empty($rwset['nume'])){echo $rwset['nume'];} ?>" required=""/>
</div>

<div class="w3-row w3-margin-bottom">
<label for="domeniu" class="w3-small" style="margin-bottom:-5px;">Nume Domeniu</label>
<input class="w3-input w3-card" type="text" name="domeniu" placeholder="Numele domeniului..." value="<?php if(!empty($rwset['domeniu'])){echo $rwset['domeniu'];} ?>" required=""/>
</div>

<div class="w3-row w3-margin-bottom">
<label for="prefix" class="w3-small" style="margin-bottom:-5px;">Prefix domeniu</label>
<select class="w3-select w3-card" name="www" style="padding-left:25px;">
<?php if($rwset['www'] == 0){ ?> 
 <option value="0" selected="">Fără www.</option>
 <option value="1">Cu www.</option>
<?php }elseif($rwset['www'] == 1){ ?> 
 <option value="0">Fără www.</option>
 <option value="1" selected="">Cu www.</option>
<?php } ?>
</select>
</div>

<div class="w3-row w3-margin-bottom">
<label for="https" class="w3-small" style="margin-bottom:-5px;">HTTPS</label>
<select class="w3-select w3-card" name="https" style="padding-left:25px;">
<?php if($rwset['https'] == 0){ ?> 
 <option value="0" selected="">Nu</option>
 <option value="1">Da</option>
<?php }elseif($rwset['https'] == 1){ ?> 
 <option value="0">Nu</option>
 <option value="1" selected="">Da</option>
<?php } ?>
</select>
</div>

</div>
</div>

<div id="mail" class="w3-container w3-border setare" style="display:none">
<h2>E-mail</h2>
<div class="w3-row">

<div class="w3-row w3-margin-bottom">
<label for="tipmail" class="w3-small" style="margin-bottom:-5px;">Metodă de trimitere e-mail</label>
<select class="w3-select w3-card" name="tipmail" style="padding-left:25px;">
<?php if($rwset['tipmail'] == 0){ ?> 
 <option value="0" selected="">PHP_Mail()</option>
 <option value="1">SMTP</option>
<?php }elseif($rwset['tipmail'] == 1){ ?> 
 <option value="0">PHP_Mail()</option>
 <option value="1" selected="">SMTP</option>
<?php } ?>
</select>
</div>

<div class="w3-row w3-margin-bottom">
<label for="mailfrom" class="w3-small" style="margin-bottom:-5px;">Trimis de către</label>
<input class="w3-input w3-card" type="text" name="mailfrom" placeholder="Trimis de către..." value="<?php if(!empty($rwset['mailfrom'])){echo $rwset['mailfrom'];} ?>"/>
</div>

<div class="w3-row w3-margin-bottom">
<label for="mailhost" class="w3-small" style="margin-bottom:-5px;">Adresă server de e-mail</label>
<input class="w3-input w3-card" type="text" name="mailhost" placeholder="Adresă server de e-mail..." value="<?php if(!empty($rwset['mailhost'])){echo $rwset['mailhost'];} ?>"/>
</div>

<div class="w3-row w3-margin-bottom">
<label for="mailuser" class="w3-small" style="margin-bottom:-5px;">Adresă de e-mail</label>
<input class="w3-input w3-card" type="e-mail" name="mailuser" placeholder="Adresă de e-mail..." value="<?php if(!empty($rwset['mailuser'])){echo $rwset['mailuser'];} ?>"/>
</div>

<div class="w3-row w3-margin-bottom">
<label for="mailpass" class="w3-small" style="margin-bottom:-5px;">Parola contului de e-mail</label>
<input class="w3-input w3-card" type="password" name="mailpass" placeholder="Parola contului de e-mail..." value="<?php if(!empty($rwset['mailpass'])){echo $rwset['mailpass'];} ?>"/>
</div>

<div class="w3-row w3-margin-bottom">
<label for="mailport" class="w3-small" style="margin-bottom:-5px;">Portul server de e-mail</label>
<input class="w3-input w3-card" type="number" name="mailport" placeholder="Portul server de e-mail..." value="<?php if(!empty($rwset['mailport'])){echo $rwset['mailport'];} ?>"/>
</div>

</div>
</div>

<div id="webmaster" class="w3-container w3-border setare" style="display:none">
<h2>Webmaster</h2>
<div class="w3-row">

<div class="w3-row w3-margin-bottom">
<label for="wgoogle" class="w3-small" style="margin-bottom:-5px;">Google Webmaster Key</label>
<input class="w3-input w3-card" type="text" name="wgoogle" placeholder="Codul de la Google Seach Console..." value="<?php if(!empty($rwset['wgoogle'])){echo $rwset['wgoogle'];} ?>"/>
</div>

<div class="w3-row w3-margin-bottom">
<label for="wbing" class="w3-small" style="margin-bottom:-5px;">Bing Webmaster Key</label>
<input class="w3-input w3-card" type="text" name="wbing" placeholder="Codul de la Bing Webmaster..." value="<?php if(!empty($rwset['wbing'])){echo $rwset['wbing'];} ?>"/>
</div>

<div class="w3-row w3-margin-bottom">
<label for="wyandex" class="w3-small" style="margin-bottom:-5px;">Yandex Webmaster Key</label>
<input class="w3-input w3-card" type="text" name="wyandex" placeholder="Codul de la Yandex Webmaster..." value="<?php if(!empty($rwset['wyandex'])){echo $rwset['wyandex'];} ?>"/>
</div>

<div class="w3-row w3-margin-bottom">
<label for="wwot" class="w3-small" style="margin-bottom:-5px;">WOT Webmaster Key</label>
<input class="w3-input w3-card" type="text" name="wyandex" placeholder="Codul de la WOT Site..." value="<?php if(!empty($rwset['wwot'])){echo $rwset['wwot'];} ?>"/>
</div>

<div class="w3-row w3-margin-bottom">
<label for="wnorton" class="w3-small" style="margin-bottom:-5px;">Norton Webmaster Key</label>
<input class="w3-input w3-card" type="text" name="wnorton" placeholder="Codul de la Norton Site..." value="<?php if(!empty($rwset['wnorton'])){echo $rwset['wnorton'];} ?>"/>
</div>

<div class="w3-row w3-margin-bottom">
<label for="robots" class="w3-small w3-border-bottom" style="margin-bottom:-5px;">Roboți (Aceștia pot stopa motoarele de căutare ca să mai viziteze site-ul)</label><br/>
<input class="w3-input w3-card" type="text" name="robots" placeholder="Etichete pentru roboți" value="<?php if(!empty($rwset['robots'])){echo $rwset['robots'];} ?>"/>
Exemplu: &lt;meta name="robots" content="<strong>index</strong>,<strong>follow</strong>,<strong>archive</strong>"/&gt; sau nu <strong>no</strong> legat înaintea fiecăruia.
</div>

<div class="w3-row w3-margin-bottom">
<label for="revisit" class="w3-small" style="margin-bottom:-5px;">Revizitează după (minutes, days,...)</label>
<input class="w3-input w3-card" type="number" name="revisit" placeholder="Când să reviziteze roboții site-ul..." value="<?php if(!empty($rwset['revisit'])){echo $rwset['revisit'];} ?>"/>
Exemplu: <strong>7 days</strong>
</div>

</div>
</div>

<div id="head" class="w3-container w3-border setare" style="display:none">
<h2>Header Tag's</h2>
<div class="w3-row">
<textarea class="w3-input w3-border w3-margin-bottom" name="headc" rows="8" style="white-space: pre-line;"><?php if(!empty($rwset['headc'])){echo $rwset['headc'];} ?></textarea>
</div>
</div>

<div id="foot" class="w3-container w3-border setare" style="display:none">
<h2>Footer Tag's</h2>
<div class="w3-row">
<textarea class="w3-input w3-border w3-margin-bottom" name="footc" rows="8" style="white-space: pre-line;"><?php if(!empty($rwset['footc'])){echo $rwset['footc'];} ?></textarea>
</div>
</div>

<div id="contact" class="w3-container w3-border setare" style="display:none">
<h2>Date de contact</h2>
<div class="w3-row">

<div class="w3-row w3-margin-bottom">
<label for="mobil" class="w3-small" style="margin-bottom:-5px;">Numărul de mobil</label>
<input class="w3-input w3-card" type="number" name="mobil" placeholder="Numărul de mobil.." value="<?php if(!empty($rwset['mobil'])){echo $rwset['mobil'];} ?>"/>
Exemplu: 40753023777
</div>

<div class="w3-row w3-margin-bottom">
<label for="mobil" class="w3-small" style="margin-bottom:-5px;">Adresa de e-mail pentru notificări</label>
<input class="w3-input w3-card" type="email" name="aemail" placeholder="Adresa de e-mail pentru notificări.." value="<?php if(!empty($rwset['aemail'])){echo $rwset['aemail'];} ?>"/>
</div>


</div>
</div>

<div id="logo" class="w3-container w3-border setare" style="display:none">
<h2>Logo &amp; Banner</h2>
<div class="w3-row">

<div class="w3-row w3-container w3-card w3-margin-bottom">
<label for="logo" class="w3-small" style="margin-bottom:-5px;">logo.png (asset/img/logo.png)<br/>(Dimensiunile pentru imaginea logo sunt: 269px / 95px)</label><br/>
<img src="asset/img/logo.png" alt="" title="" style="whidth:269px;height:95px;"/><br/>
<input class="w3-button" type="file" name="logo"/><br/>
<em>Notă! Dacă imaginea nu este încărcată, se v-a afișa numele site-ului.</em>
</div>

<div class="w3-row w3-container w3-card w3-margin-bottom">
<label for="mobil" class="w3-small" style="margin-bottom:-5px;">Imaginea bannerului sau conținutul acestuia.</label><br/>
<img src="asset/img/logo.png" alt="" title="" style="whidth:269px;height:95px;"/><br/>
<input class="w3-button" type="file" name="banner"/>
<textarea class="w3-input w3-border w3-margin-bottom" name="cod_banner" rows="8" style="white-space: pre-line;"><?php if(!empty($rwset['banner'])){echo $rwset['banner'];} ?></textarea>
Dacă nu există nici imagine și nici cod, se va afișa numele site-ului și descrierea.
</div>


</div>
</div>

<div class="w3-row w3-center w3-margin-top w3-margin-bottom">
<button class="w3-button w3-green w3-hover-blue">Actualizare</button>
</div>

<input type="hidden" name="actsetariform" value="true"/>
</form>
<script>
function openSet(evt, setName) {
  var i, x, tablinks;
  x = document.getElementsByClassName("setare");
  for (i = 0; i < x.length; i++) {
    x[i].style.display = "none";
  }
  tablinks = document.getElementsByClassName("tablink");
  for (i = 0; i < x.length; i++) {
    tablinks[i].className = tablinks[i].className.replace(" w3-green", "");
  }
  document.getElementById(setName).style.display = "block";
  evt.currentTarget.className += " w3-green";
}
</script>
<?php } ?>

<?php if($titget == 'Feed'){ ?>
<div class="w3-row">
<h3>Feed Anunțuri</h3>

<div class="w3-half">
Ultimele 15 Anunturi
<p>Adresa RSS Feed: <ins><?=BASE_URL?>feed.xml</ins></p>
<div style="width:300px;padding:10px;border:dashed 0.5px #000;">
<?php
 $domOBJ = new DOMDocument();
 $domOBJ->load(BASE_URL."feed.xml"); 
 $content = $domOBJ->getElementsByTagName("item");
 foreach( $content as $data ){
   $title = $data->getElementsByTagName("title")->item(0)->nodeValue;
   $link = $data->getElementsByTagName("link")->item(0)->nodeValue;
   echo '<div style="margin:0px;padding:4px;border-bottom: solid 1px #C0C0C0;">
   <a href="'.$link.'" title="'.$title.'" target="_blank" style="text-decoration:none;">'.$title.'</a>
   </div>';
 }
?>
</div>

<div class="w3-center w3-margin">
<a href="http://www.feedvalidator.org/check.cgi?url=<?=BASE_URL?>feed.xml" target="_blank">
<img src="http://www.feedvalidator.org/images/valid-rss-rogers.png" alt="FEED Validator" title="FEED Validator" style="whidth:88px;height:31px;" loading="lazy"/>
</a></div>

</div>

<div class="w3-half">
<p class="w3-border-bottom">Cod de implementare în PHP</p>
<div class="w3-code w3-small w3-black w3-text-green" id="sursa">
&lt;div style="width:300px;padding:10px;border:dashed 0.5px #000;"&gt;<br/>
&lt;?php<br/>
&nbsp;$domOBJ = new DOMDocument();<br/>
&nbsp;$domOBJ->load("<?=BASE_URL?>feed.xml");<br/>
&nbsp;$content = $domOBJ->getElementsByTagName("item");<br/><br/>
&nbsp;foreach( $content as $data ){<br/>
&nbsp;&nbsp;$title = $data->getElementsByTagName("title")->item(0)->nodeValue;<br/>
&nbsp;&nbsp;$link = $data->getElementsByTagName("link")->item(0)->nodeValue;<br/>
&nbsp;&nbsp;echo '&lt;div style="margin:0px;padding:4px;border-bottom: solid 1px #C0C0C0;"&gt;<br/>
&nbsp;&nbsp;&lt;a href="'.$link.'" title="'.$title.'" target="_blank" style="text-decoration:none;"&gt;'.$title.'&lt;/a&gt;<br/>
&nbsp;&nbsp;&lt;/div&gt;';<br/>
&nbsp;}<br/>
?&gt;<br/>
&lt;/div&gt;
</div>
<button class="w3-button w3-blue w3-hover-indigo w3-right" onclick="copyToClipboard('#sursa')">Copiază Sursa</button>

<div class="w3-row w3-margin-bottom">
<p class="w3-border-bottom">Mod de implementare în WordPress</p>
Acesta este un exemplu valabil de implementare pentru<br/>Wordpress din zona Aspect->Piese->(RSS)
<div class="w3-border">
<div class="w3-container w3-padding w3-xlarge w3-light-gray">RSS: Cele mai noi anunțuri</div>

<div class="w3-container w3-margin-top">
<label>Introdu aici URL-ul fluxului RSS:</label><br/>
<input class="w3-input w3-padding w3-border w3-padding-small" style="margin-top:-6px;" type="text" value="<?=BASE_URL?>feed.xml"/>
</div>

<div class="w3-container w3-margin-top">
<label>Dă-i fluxului un titlu (opțional):</label><br/>
<input class="w3-input w3-padding w3-border w3-padding-small" style="margin-top:-6px;" type="text" value="Cele mai noi anunțuri"/>
</div>

<div class="w3-container w3-margin-top">
<label>Câte elemente vrei să afișezi?</label>
<select class="w3-select w3-border w3-padding-small fedelemw" style="width:80px;padding-left:15px;">
<option selected="">1</option>
 <?php 
 foreach (range(2, 20) as $number) {
    echo '<option>'.$number.'</option>';    
    }
?> 
</select>
</div>

<div class="w3-container w3-margin-top">
<input type="checkbox" class="w3-check"/>
<label>Afișezi conținutul elementului?</label>
</div>

<div class="w3-container w3-margin-top">
<input type="checkbox" class="w3-check" disabled=""/>
<label style="text-decoration:line-through;">Afișezi autorul elementului dacă este disponibil?</label>
</div>

<div class="w3-container w3-margin-top">
<input type="checkbox" class="w3-check"/>
<label>Afișezi data elementului?</label>
</div>

<div class="w3-container w3-margin-top w3-margin-bottom">
<span class="w3-text-red"><ins>Șterge</ins></span> | 
<span class="w3-text-blue"><ins>Gata</ins></span>
<div class="w3-right">
<button class="w3-light-gray w3-hover-white w3-border w3-large">Vizibilitate</button>
<button class="w3-blue w3-border w3-large">Salvează</button>
</div>
</div>

</div>
</div>
</div>
<script>
function copyToClipboard(element) {
  var $temp = $("<div>");
  $("body").append($temp);
  $temp.val($(element).text()).select();
  document.execCommand("copy");
  $temp.remove();
}
</script>
</div>
<?php } ?>
</div></div>

<?php
//echo 'Level '.$_SESSION['level'];
    }else{
        $url = PATH.'cont.html';
        ob_end_clean();
        header("Location: $url");
        exit();
       }
 }else{
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
    }
    
 
 }elseif($page == 'anunturi'){
    
    function lungime_text($x, $length){
  if(strlen($x)<=$length)  {
    echo $x;
  }else{
    $y=substr($x,0,$length) . '...';
    echo $y;
  }
 }
$qsrc = "SELECT * FROM `anunturi` WHERE `verificat` IS NULL AND `aprobat`=1";
$ressrc = $dbc->query($qsrc);
?>

<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-rest">
<?php include APP.'searchform.php'; ?>
<div class="w3-row w3-container w3-text-white" style="background-color:#117594;">
<h5 style="padding:5px;">Toate anunțurile (<?=$ca?>)</h5>
</div>
<div class="w3-row w3-margin-top">
<?php
while($rsrc = $ressrc->fetch_array()){
    
      $qsrcimg = "SELECT * FROM `imagini` WHERE `aid`=\"".$rsrc['aid']."\" LIMIT 1";
      $rsrcimg = $dbc->query($qsrcimg);
      $rsimg = $rsrcimg->fetch_assoc();
      
      $qgetuser = "SELECT * FROM `utilizatori` WHERE `uid`={$rsrc['uid']}";
      $rgetuser = $dbc->query($qgetuser);
      $rowgetusr = $rgetuser->fetch_assoc();

?>

<a href="<?=PATH.$rsrc['seo']?>.html">
<div class="w3-col l3 m4 s12 w3-hover-light-gray w3-text-black w3-margin-bottom">
<div class="w3-col" style="width:96%;margin:1%;margin-bottom:0;">
<img src="<?=BASE_URL.'imagini/'.$rsimg['nume_fisier']?>" style="object-fit:cover;width:100%;height:150px;max-height:100%;" alt="<?php echo lungime_text($rsrc['titlu'], 36); ?>" title="<?php echo $rsrc['titlu']; ?>" loading="lazy" class="w3-card"/>
</div>
<div class="w3-col" style="width:96%;margin:1%;">
<h4 class="w3-card" style="font-size:16px;padding-left:4px;margin-bottom:0;">
<?php echo lungime_text($rsrc['titlu'], 20); ?></h4>
<div class="w3-row w3-green" style="margin-top:0;">
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-money"></i> <?php if($rsrc['pret'] > 0){echo '<strong>'.$rsrc['pret'].'</strong> '.$rowgetusr['moneda'];}else{echo 'GRATUIT';} ?>
</div>
</div>

</div>

</div></a>

<!--<a href="/<?=$rsrc['seo']?>.html">
<div class="w3-half w3-card w3-hover-light-gray w3-margin-bottom">
<div class="w3-col w3-hide-small" style="width:26%;">
<img src="/imagini/<?=$rsimg['nume_fisier']?>" alt="<?=$rsrc['titlu']?>" style="width:120px;max-width:100%;height:120px;"/>
</div>
<div class="w3-col w3-hide-medium w3-hide-large" style="width:30%;">
<img src="/imagini/<?=$rsimg['nume_fisier']?>" alt="<?=$rsrc['titlu']?>" style="width:70px;max-width:100%;height:70px;"/>
</div>
<div class="w3-col w3-hide-small" style="width:74%;">
<h5 class="w3-border-bottom">
<?php echo lungime_text($rsrc['titlu'], 40); ?></h5>
<div style="text-align: justify;padding-left:5px;padding-right:5px;">
<span><?php echo lungime_text($rsrc['descriere'], 90); ?></span></div>
<div class="w3-row w3-border-top w3-green">
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-money"></i> Preț: <?php if($rsrc['pret'] > 0){echo '<strong>'.$rsrc['pret'].'</strong> '.$rowgetusr['moneda'];}else{echo 'GRATUIT';} ?>
</div>
</div>

<div class="w3-row w3-border-top">
<div class="w3-left" style="padding-left:5px;">
<i class="fa fa-map-marker"></i> <?php echo $rsrc['judet']; ?>
</div>
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-clock-o"></i> <?php echo date('d F Y, H:i', strtotime($rsrc['data_publicarii'])); ?>
</div>
</div>

</div>

<div class="w3-col w3-hide-medium w3-hide-large" style="width:70%;">
<h5 class="w3-border-bottom">
<?php echo lungime_text($rsrc['titlu'], 20); ?>
</h5>
<span><?php echo lungime_text($rsrc['descriere'], 54); ?></span>
</div>

</div>
</a>-->
<?php } ?></div>
</div>
</div>
    
 <?php   
    
 }elseif($page == 'anunturile-mele'){
    
  
  
  if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    
    $qcont = "SELECT * FROM `utilizatori` WHERE `uid`='".$_SESSION['user_id']."' LIMIT 1";
    $rcont = $dbc->query($qcont);
    $rowct = $rcont->fetch_assoc(); 
    
    $qanunt = "SELECT * FROM `anunturi` WHERE `uid`='".$_SESSION['user_id']."'";
    $ranunt = $dbc->query($qanunt);
?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_usr.php'; ?>
</div>
<div class="w3-threequarter">
<div class="w3-row w3-indigo">
<h3 class="w3-container"><i class="fa fa-bullhorn"></i> Anunțurile mele</h3>
</div>

<?php if(isset($stareanunt) == 1){?>
<div class="w3-panel w3-padding w3-green">
<i class="fa fa-check"></i> Anunțul a fost șters</div>
<?php }elseif(isset($stareanunt) == 2){ ?>
<div class="w3-panel w3-padding w3-red">
<i class="fa fa-remove"></i> Anunțul nu a fost șters</div>
<?php } ?>

<div class="w3-row w3-margin-top">
<div class="w3-responsive">
<table class="w3-table-all">
<tr>
<th>Nr.</th>
<th>Titlu anunț</th>
<th class="w3-center">Vizualizări</th>
<th>Data adăugării</th>
<th></th>
</tr>
<?php if($ranunt->num_rows > 0){
    $nr = 1;
    while($rwa = $ranunt->fetch_assoc()){        
echo '<tr class="w3-hover-pale-blue">
  <td>'.$nr++.'</td>
  <td><a class="w3-text-black" href="'.PATH.$rwa['seo'].'.html" style="text-decoration:none;">'.$rwa['titlu'].'</a></td>
  <td class="w3-center">'.$rwa['vizualizari'].'</td>
  <td>'.$rwa['data_publicarii'].'</td>
  <td><div class="w3-center">
  <form action="editare-anunt.html" method="post">  
  <button class="w3-button w3-col w3-padding-small w3-hover-none" style="width:15%;"><i class="fa fa-pencil-square-o w3-text-blue w3-hover-text-black"></i></button>
  <input type="hidden" name="aid" value="'.$rwa['aid'].'"/>
  <input type="hidden" name="uid" value="'.$_SESSION['user_id'].'"/>
  </form>
  <form action="" method="post">  
  <button class="w3-button w3-col w3-padding-small w3-hover-none" style="width:15%;"><i class="fa fa-trash-o w3-text-red w3-hover-text-black"></i></button>
  <input type="hidden" name="aid" value="'.$rwa['aid'].'"/>
  <input type="hidden" name="uid" value="'.$_SESSION['user_id'].'"/>
  <input type="hidden" name="sterganuntulmeu" value="true"/>
  </form>';
  

if($rwa['aprobat'] == '1'){
    echo '<div class="w3-text-green" style="margin-top:4px;">&nbsp; <i class="fa fa-check"></i> Aprobat</div>';
}
if(($rwa['aprobat'] == '0') && ($rwa['refuzat'] == '0')){
    echo '<div class="w3-text-blue" style="margin-top:4px;">&nbsp; <i class="fa fa-clock-o"></i> În curs de verificare</div>';
}
if($rwa['refuzat'] == '1'){
    echo '<div class="w3-text-red" style="margin-top:4px;">&nbsp; <i class="fa fa-times"></i> Refuzat <i class="fa fa-info-circle w3-right" title="'.$rwa['motiv'].'"></i></div>';
}

  
echo '</div></td>
</tr>';
     }
   }else{ ?>
<tr>
<td class="w3-center" colspan="4">Nu ați adăugat niciun anunț!</td>
</tr>
<?php } ?>

</table>
</div>

</div>

</div></div>
<?php
 }else{
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
 }
  
      
 }elseif($page == 'cautare'){
    
   $judet   = $_POST['judet'];
$cautare = $_POST['caut'];
if(!empty($judet)){
$qsrc = "SELECT * FROM `anunturi` WHERE `judet`='".$judet."' 
                  AND (`verificat` IS NULL) 
                  AND (`aprobat`=1) 
                  AND (`titlu` LIKE '%".$cautare."%' 
                  OR `descriere` LIKE '%".$cautare."%' 
                  OR `etichete` LIKE '%".$cautare."%')";
                }else{
$qsrc = "SELECT * FROM `anunturi` WHERE `verificat` IS NULL 
                  AND (`aprobat`=1) 
                  AND (`titlu` LIKE '%".$cautare."%' 
                  OR `descriere` LIKE '%".$cautare."%' 
                  OR `etichete` LIKE '%".$cautare."%')";
                  }
$ressrc = $dbc->query($qsrc);
?>

<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter">
<?php include APP.'searchform.php'; ?>
<div class="w3-row w3-container w3-text-white w3-hide-small" style="background-color:#117594;">
<h5 style="padding:5px;">Rezultatul căutării pentru <strong><ins><?=$cautare?></ins></strong><?php if($judet == true){ ?> in județul <strong><ins><?=$judet?></ins></strong><?php } ?></h5>
</div>

<div class="w3-row w3-container w3-text-white w3-hide-medium w3-hide-large" style="background-color:#117594;">
<h5 style="padding:5px;">Caut <strong><ins><?=$cautare?></ins></strong><?php if($judet == true){ ?> in <strong><ins><?=$judet?></ins></strong><?php } ?></h5>
</div>

<div class="w3-row w3-margin-top">
<?php
function lungime_text($x, $length){
  if(strlen($x)<=$length)  {
    echo $x;
  }else{
    $y=substr($x,0,$length) . '...';
    echo $y;
  }
 }
while($rsrc = $ressrc->fetch_array()){
    
      $qsrcimg = "SELECT * FROM `imagini` WHERE `aid`=\"".$rsrc['aid']."\" LIMIT 1";
      $rsrcimg = $dbc->query($qsrcimg);
      $rsimg = $rsrcimg->fetch_assoc();
      
      $qgetuser = "SELECT * FROM `utilizatori` WHERE `uid`={$rsrc['uid']}";
      $rgetuser = $dbc->query($qgetuser);
      $rowgetusr = $rgetuser->fetch_assoc();

?>
<a href="<?=PATH.$rsrc['seo']?>.html">
<div class="w3-half w3-card w3-hover-light-gray w3-margin-bottom">
<div class="w3-col w3-hide-small" style="width:26%;">
<img src="<?=PATH?>imagini/<?=$rsimg['nume_fisier']?>" alt="<?=$rsrc['titlu']?>" title="<?=$rsrc['titlu']?>" loading="lazy" style="width:120px;max-width:100%;height:120px;"/>
</div>
<div class="w3-col w3-hide-medium w3-hide-large" style="width:35%;">
<img src="<?=PATH?>imagini/<?=$rsimg['nume_fisier']?>" alt="<?=$rsrc['titlu']?>" title="<?=$rsrc['titlu']?>" loading="lazy" style="width:70px;max-width:100%;height:70px;"/>
</div>
<div class="w3-col w3-hide-small" style="width:74%;">
<h5 class="w3-border-bottom">
<?php echo lungime_text($rsrc['titlu'], 40); ?></h5>
<div style="text-align: justify;padding-left:5px;padding-right:5px;">
<span><?php echo lungime_text($rsrc['descriere'], 90); ?></span></div>
<div class="w3-row w3-border-top w3-green">
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-money"></i> Preț: <?php if($rsrc['pret'] > 0){echo '<strong>'.$rsrc['pret'].'</strong> '.$rowgetusr['moneda'];}else{echo 'GRATUIT';} ?>
</div>
</div>

<div class="w3-row w3-border-top">
<div class="w3-left" style="padding-left:5px;">
<i class="fa fa-map-marker"></i> <?php echo $rsrc['judet']; ?>
</div>
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-clock-o"></i> <?php echo date('d F Y, H:i', strtotime($rsrc['data_publicarii'])); ?>
</div>
</div>

</div>

<div class="w3-col w3-hide-medium w3-hide-large" style="width:65%;">
<h6 class="w3-border-bottom">
<?php echo lungime_text($rsrc['titlu'], 22); ?>
</h6>
<span><?php echo lungime_text($rsrc['descriere'], 52); ?></span>
</div>

</div>
</a>
<?php }
if($ressrc->num_rows == 0){
    echo '<p class="w3-center">Căutarea dumneavoastră nu a întors niciun rezultat!</p>';
}
if(!empty($cautare)){
if($ressrc->num_rows >= 1){
    $qselsrc = "SELECT * FROM `cautari` WHERE `titlu`=\"$cautare\"";
    $rselsrc = $dbc->query($qselsrc);    
    
    if($rselsrc->num_rows >= 1){
    $qsavesrc = "UPDATE `cautari` SET `valoare`=`valoare` + 1, `ultima_data`=NOW() WHERE `titlu`=\"$cautare\"";
    $rsavesrc = $dbc->query($qsavesrc);
    }
    
    if($rselsrc->num_rows == 0){
    $qsavesrc = "INSERT INTO `cautari`(`srcid`, `titlu`, `valoare`, `prima_data`, `ultima_data`) VALUES ('0', '$cautare', '1', NOW(), NOW())";
    $rsavesrc = $dbc->query($qsavesrc);
    }
 }
 }
?></div>
</div></div> 
    
  <?php  
    
 }elseif($page == 'confidentialitate'){
    
    if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
    }else{
    ?>
<?php include FORM; ?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter"> 
<div class="w3-row">
<div class="w3-rest w3-text-white w3-container w3-margin-top w3-margin-bottom w3-card" style="background-color:#117594;">
<h3 class="w3-center w3-margin-bottom w3-padding w3-border-bottom"><?=$row['titlu']?></h3>
</div>
<p><?=$row['descriere']?></p>  
   
</div>

</div>

</div>
<?php }
    
 }elseif($page == 'cont'){
    
    if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    
    $qcont = "SELECT * FROM `utilizatori` WHERE `uid`='".$_SESSION['user_id']."' LIMIT 1";
    $rcont = $dbc->query($qcont);
    $rowct = $rcont->fetch_assoc();
    
    $email = $rowct['email'];
    $default = BASE_URL."imagini/no-image-icon.png";
    $size = 250;
    
    $grav_url = "https://www.gravatar.com/avatar/" . md5( strtolower( trim( $email ) ) ) . "?d=" . urlencode( $default ) . "&s=" . $size;



?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_usr.php'; ?>
</div>
<div class="w3-threequarter">
<div class="w3-row w3-text-white" style="background-color:#117594;">
<h3 class="w3-container"><i class="fa fa-user"></i> Profilul meu</h3>
</div>


<div class="w3-row w3-margin-top">
<div class="w3-quarter">
<div class="w3-card">
<img class="w3-image" src="<?php echo $grav_url; ?>" alt="<?=$rowct['prenume']?>" style="width:100%;max-width:100%;"/>
</div>
<div class="w3-center w3-margin-bottom">
<a href="https://ro.gravatar.com/" target="_blank">Schimbi imaginea?</a>
</div>
</div>
<div class="w3-threequarter">

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-large w3-card" value="<?=$rowct['prenume']?>" disabled=""/>
<label class="w3-right w3-small" for="prenume" style="margin-top:-46px;margin-right:5px;"><em>Prenume</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-large w3-card" value="<?=$rowct['nume']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-46px;margin-right:5px;"><em>Nume</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-large w3-card" value="<?=$rowct['email']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-46px;margin-right:5px;"><em>E-mail</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-large w3-card" value="<?=$rowct['moneda']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-46px;margin-right:5px;"><em>Moneda</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-large w3-card" value="<?=$rowct['data_r']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-46px;margin-right:5px;"><em>Data înregistrării</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-large w3-card" value="<?=$rowct['data_m']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-46px;margin-right:5px;"><em>Ultima modificare</em></label>
</div>

<div class="w3-container w3-margin-bottom">
<p>Notă!<br/>Adresa de e-mail nu se poate modifica.<br/>Aceasta nu este făcută niciodată publică de către "<?=BASE_NAME?>".</p>
</div>

</div>

</div>


</div></div>
<?php
 }else{
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
 }
    
 }elseif($page == 'contact'){
    
    if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
    }else{
    ?>
<?php include FORM; ?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter"> 
<div class="w3-row">
<div class="w3-rest w3-text-white w3-container w3-margin-top w3-margin-bottom w3-card" style="background-color:#117594;">
<h3 class="w3-center w3-margin-bottom w3-padding w3-border-bottom"><?=$row['titlu']?></h3>
</div>
<p><?=$row['descriere']?></p>  
   
</div>

</div>

</div>
<?php }
    
 }elseif($page == 'contnou'){
    
    if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
    }else{
    ?>
<?php include FORM; ?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter"> 
 
 <div class="w3-row">
 
 <div class="w3-quarter w3-hide-small">&nbsp;</div>
        
   <div class="w3-half w3-margin-top w3-margin-bottom w3-card">
   <h3 class="w3-center w3-margin-bottom w3-padding w3-border-bottom w3-bluepm">Cont nou</h3>

<?php if(isset($exist)) {?>   
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$exist?></h5>
       </div>
   </div>
<?php } ?>
   
<?php if(isset($e_err)) {?>
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$e_err?></h5>
       </div>
   </div>
<?php } ?>

<?php if(isset($err_p1)) {?>
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$err_p1?></h5>
       </div>
   </div>
<?php } ?>

<?php if(isset($err_p2)) {?>
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$err_p2?></h5>
       </div>
   </div>
<?php } ?>

<?php if(isset($finalizat)) {?>
   <div class="w3-container">
       <div class="w3-panel w3-green w3-center">
            <?=$finalizat?>
       </div>
   </div>
<?php } ?>

<?php if(isset($sys_err)) {?>
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$sys_err?></h5>
       </div>
   </div>
<?php } ?>

<?php if(isset($try)) {?>
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$try?></h5>
       </div>
   </div>
<?php } ?>
   
   <form class="w3-container" action="" method="post">
   <div class="w3-margin-bottom">
   <label>Adresa de e-mail</label>
   <input class="w3-input w3-border" type="email" name="email" value="<?php if(isset($trimmed['email'])) echo $trimmed['email']; ?>" placeholder="Treceți adresa dvs. de e-mail" required=""/>
   </div>
   
   <div class="w3-margin-bottom">
   <label>Parola</label>
   <input class="w3-input w3-border" type="password" name="parola1" value="<?php if (isset($trimmed['parola1'])) echo $trimmed['parola1']; ?>" placeholder="Introduceți parola" required=""/>
   </div>
   
   <div class="w3-margin-bottom">
   <label>Verificare parolă</label>
   <input class="w3-input ve-border" type="password" name="parola2" value="<?php if (isset($trimmed['parola2'])) echo $trimmed['parola2']; ?>" placeholder="Re-introduceți parola" required=""/>
   </div>
   
   <div class="w3-margin-bottom">
   <span><strong>Sunt de acord cu:</strong> </span><br/>
   <input class="w3-check" type="checkbox" name="atermeni" value="0" id="checkTenable"/>
   <label><a href="<?=PATH?>termeni.html" target="_blank" style="text-decoration:none;">Termenii și Condițiile</a></label><br/>
   
   <input class="w3-check" type="checkbox" name="apolitica" value="0" id="checkGenable" disabled="disabled"/>
   <label><a href="<?=PATH?>confidentialitate.html" target="_blank" style="text-decoration:none;">Politica de confidențialitate</a></label><br/>
   
   <input class="w3-check" type="checkbox" name="astiri" value="0"/>
   <label>Abonarea la știri</label>
   </div>
   
   <div class="w3-margin-bottom w3-center">
   <button class="w3-button w3-bluepm w3-hover-seagreen" type="submit" id="ischeckenable" disabled="disabled"><i class="fa fa-unlock"></i> Înregistrare</button>
   </div>
   
   <input type="hidden" name="contnou" value="true"/>
   </form>
   
   <div class="w3-bar w3-white w3-hide-small_ w3-border-top">
   
   <a href="<?=PATH?>acces.html" class="w3-bar-item w3-button w3-bluepm w3-hover-seagreen" style="width:40%;">Acces</a>
   <a href="<?=PATH?>recuperareparola.html" class="w3-bar-item w3-button w3-bluepm w3-hover-seagreen" style="width:60%;">Recuperare parolă</a>
   
   </div>
   
   </div>
   
   <div class="w3-quarter w3-hide-small">&nbsp;</div>
   
 </div>

</div>

</div>

<script>
$(function() {
    $('#checkTenable').click(function() {
        if ($(this).is(':checked')) {
            $('#checkGenable').removeAttr('disabled');
        } else {
            $('#checkGenable').attr('disabled', 'disabled');
            $('#ischeckenable').attr('disabled', 'disabled');
        }
    });
    
    $('#checkGenable').click(function() {
        if ($(this).is(':checked')) {
            $('#ischeckenable').removeAttr('disabled');
        } else {
            $('#ischeckenable').attr('disabled', 'disabled');
        }
    });
});
</script>
<?php }
    
 }elseif($page == 'cookies'){
    
    if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
    }else{
    ?>
<?php include FORM; ?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter"> 
<div class="w3-row">
<div class="w3-rest w3-text-white w3-container w3-margin-top w3-margin-bottom w3-card" style="background-color:#117594;">
<h3 class="w3-center w3-margin-bottom w3-padding w3-border-bottom"><?=$row['titlu']?></h3>
</div>
<p><?=$row['descriere']?></p>  
   
</div>

</div>

</div>
<?php }
    
 }elseif($page == 'editare-anunt'){
    
    if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    
    $qcont = "SELECT * FROM `utilizatori` WHERE `uid`='".$_SESSION['user_id']."' LIMIT 1";
    $rcont = $dbc->query($qcont);
    $rowct = $rcont->fetch_assoc(); 
    
    $qanunt = "SELECT * FROM `anunturi` WHERE `aid`='".$_POST['aid']."'";
    $ranunt = $dbc->query($qanunt);
    $rwa   = $ranunt->fetch_assoc();    
    
?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_usr.php'; ?>
</div>
<div class="w3-threequarter">
<div class="w3-row w3-indigo">
<h3 class="w3-container"><i class="fa fa-pencil-square-o"></i> Editare anunț</h3>
</div>

<?php
if(isset($err_edit_anunt)){echo '<div class="w3-panel w3-red w3-padding">'.$err_edit_anunt.'</div>';}
if(isset($incercdinnou)){echo '<div class="w3-panel w3-red w3-padding">'.$incercdinnou.'</div>';}
if(isset($notupload)){echo '<div class="w3-panel w3-red w3-padding">'.$notupload.'</div>';}
if(isset($editedanunt)){echo '<div class="w3-panel w3-green w3-padding">'.$editedanunt.'</div>';}


?>

<?php if(isset($stareEanunt) == 1){?>
<div class="w3-panel w3-padding w3-green">
<i class="fa fa-check"></i> Anunțul a fost actualizat</div>
<?php }elseif(isset($stareEanunt) == 2){ ?>
<div class="w3-panel w3-padding w3-red">
<i class="fa fa-remove"></i> Anunțul nu a fost actualizat</div>
<?php } ?>

<div class="w3-row w3-margin-top">

<div class="w3-rest w3-card w3-container w3-margin-bottom">   
   
   <form class="" action="" method="post" enctype="multipart/form-data">
   
   <div class="w3-row-padding w3-margin-bottom w3-margin-top">   
   <input class="w3-input w3-card w3-white" type="text" placeholder="Titlul anunțului" name="titlu" value="<?php if(isset($rwa['titlu'])){echo $rwa['titlu'];}elseif(isset($_POST['titlu'])){echo $_POST['titlu'];} ?>" required="" maxlength="60"/>
   <?php if(isset($err_titlu)){ ?>
   <div class="w3-panel w3-red w3-padding"><?=$err_titlu?></div>
   <?php } ?>
   </div>
   
   <div class="w3-row-padding w3-margin-bottom">   
   <textarea class="w3-input w3-card w3-white" placeholder="Conținutul anunțului" name="continut" required="" maxlength="5000" rows="5" style="white-space: pre-line;"><?php if(isset($rwa['descriere'])){echo $rwa['descriere'];}elseif(isset($_POST['continut'])){echo $_POST['continut'];} ?></textarea>
   <?php if(isset($err_continut)){ ?>
   <div class="w3-panel w3-red w3-padding"><?=$err_continut?></div>
   <?php } ?>
   </div>
   
   <div class="w3-row-padding w3-margin-bottom">   
   <input class="w3-input w3-card w3-white" type="text" placeholder="Etichete separate prin virgulă ( , )" name="eticheta" value="<?php if(isset($rwa['etichete'])){echo $rwa['etichete'];}elseif(isset($_POST['eticheta'])){echo $_POST['eticheta'];} ?>" required="" maxlength="60"/>
   <?php if(isset($err_eticheta)){ ?>
   <div class="w3-panel w3-red w3-padding"><?=$err_eticheta?></div>
   <?php } ?>
   </div>
   
   <div class="w3-row-padding w3-margin-bottom">     
      <div class="w3-rest">
      <?php $qfoto = "SELECT * FROM `imagini` WHERE `aid`='".$_POST['aid']."'";
    $rfoto = $dbc->query($qfoto);
    while($rwf   = $rfoto->fetch_assoc()){ ?>
    <img src="<?=PATH?>imagini/<?=$rwf['nume_fisier']?>" alt="" style="width:100px;height:100px;border:none;"/>
      <?php } ?>
      <p><input class="w3-input w3-card w3-white" type="file" name="poze[]"/></p>
      
      </div>      
   </div>   
   
   <div class="w3-row-padding w3-margin-bottom">
   <div class="w3-third w3-margin-bottom">
       <select class="w3-input w3-large w3-card w3-white srclocatie" style="padding-left:50px;" name="judetul" required="">       
        <?php
        $qjud = "SELECT * FROM judet";
        $rjud = $dbc->query($qjud);
        if(isset($rwa['judet'])){
            echo '<option value="'.$rwa['judet'].'" selected="">'.$rwa['judet'].'</option>';
        }else{
        echo '<option value="" selected="" disabled="">Selectați județul</option>';
        }
        while($rj = $rjud->fetch_assoc()){            
            echo '<option value="'.$rj['nume'].'">'.$rj['nume'].'</option>';
        }
        ?>        
       </select>
   </div>
   <div class="w3-third w3-margin-bottom">
       <select class="w3-input w3-large w3-card w3-white deliveryselect" style="padding-left:50px;" name="livrare" required="">
       <?php if(!isset($rwa['livrare'])){
        echo '<option value="" selected="" disabled="">Cum livrați?</option>
              <option value="posta">Prin poștă</option>
              <option value="curier">Prin curier</option>
              <option value="predare">Predare personală</option>
              <option value="online">Online (Produs digital)</option>';
        }else{
        if($rwa['livrare'] == 'posta'){
            $livrare = 'Prin poștă';
            echo '<option value="'.$rwa['livrare'].'" selected="" >'.$livrare.'</option>';
            echo '<option value="curier">Prin curier</option>
                  <option value="predare">Predare personală</option>
                  <option value="online">Online (Produs digital)</option>';
        }elseif($rwa['livrare'] == 'curier'){
            $livrare = 'Prin curier';
            echo '<option value="posta">Prin poștă</option>'; 
            echo '<option value="'.$rwa['livrare'].'" selected="" >'.$livrare.'</option>';
            echo '<option value="predare">Predare personală</option>
                  <option value="online">Online (Produs digital)</option>';
        }elseif($rwa['livrare'] == 'predare'){
            $livrare = 'Predare personală';
            echo '<option value="posta">Prin poștă</option>';           
            echo '<option value="curier">Prin curier</option>';
            echo '<option value="'.$rwa['livrare'].'" selected="" >'.$livrare.'</option>';
            echo '<option value="online">Online (Produs digital)</option>';
        }elseif($rwa['livrare'] == 'online'){
            $livrare = 'Online (Produs digital)';
            echo '<option value="posta">Prin poștă</option>';            
            echo '<option value="curier">Prin curier</option>
                  <option value="predare">Predare personală</option>';
                  echo '<option value="'.$rwa['livrare'].'" selected="" >'.$livrare.'</option>';
        }        
        
        } ?>        
       </select>
   </div>
   <div class="w3-third w3-margin-bottom">
       <input class="w3-input w3-large w3-card w3-white" name="pretul" type="number" value="<?php if(isset($rwa['pret'])){echo $rwa['pret'];}elseif(isset($_POST['pretul'])){echo $_POST['pretul'];} ?>" min="1" placeholder="Prețul.." required=""/> <div class="w3-right" style="position:relative;margin-top:-32px;margin-right:30px;" title="Pentru a modifica moneda, mergeti la editare profil"><?=$rowct['moneda']?><?php if(empty($_SESSION['user_id'])){echo 'RON';} ?></div>
   </div>
   </div>
   
   
   <div class="w3-center w3-margin-top w3-margin-bottom">
<input type="hidden" name="uip" value="<?php echo $_SERVER["REMOTE_ADDR"]; ?>"/>
<input type="hidden" name="aid" value="<?=$_POST['aid']?>"/>
<input type="hidden" name="editezanuntulmeu" value="true"/>
<button class="w3-button w3-blue w3-hover-black" type="submit"><i class="fa fa-save"></i>  Actualizați anunțul</button>

</form>

   </div>     
   
   </div>

</div>

</div></div>
<?php
 }else{
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
 }
    
 }elseif($page == 'editare-profil'){
    
    if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    
    $qcont = "SELECT * FROM `utilizatori` WHERE `uid`='".$_SESSION['user_id']."' LIMIT 1";
    $rcont = $dbc->query($qcont);
    $rowct = $rcont->fetch_assoc();

?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_usr.php'; ?>
</div>
<div class="w3-threequarter">
<div class="w3-row w3-indigo">
<h3 class="w3-container"><i class="fa fa-pencil"></i> Editare profil</h3>
</div>
<?php if(isset($actualizare) == '1'){?>
<div class="w3-panel w3-padding w3-green"><i class="fa fa-check"></i> Profilul dvs. a fost actualizat!</div>
<?php }elseif(isset($actualizare) == '2'){ ?>
<div class="w3-panel w3-padding w3-red"><i class="fa fa-times"></i> Profilul dvs. nu a fost actualizat!</div>
<?php } ?>
<div class="w3-row w3-margin-top">
<form action="" method="post">
<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input name="prenume" class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['prenume']?>" placeholder="Prenumele dvs." value="<?=$rowct['prenume']?>"/>
<label class="w3-right w3-small" for="prenume" style="margin-top:-50px;margin-right:5px;"><em>Prenume</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input name="nume" class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['nume']?>" placeholder="Numele dvs." value="<?=$rowct['nume']?>"/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>Nume</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input name="mobil" class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['mobil']?>" placeholder="Mobil (ex. 407****)" value="<?=$rowct['mobil']?>"/>
<label class="w3-right w3-small" for="mobil" style="margin-top:-50px;margin-right:5px;"><em>Mobil</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<select name="moneda" class="w3-input w3-white w3-xlarge w3-card">
<?php if($rowct['moneda'] == "RON"){ ?>
<option value="EUR">EURO</option>
<option value="<?=$rowct['moneda']?>" selected=""><?=$rowct['moneda']?></option>
<?php }elseif($rowct['moneda'] == "EUR"){ ?>
<option value="<?=$rowct['moneda']?>" selected="">EURO</option>
<option value="RON">RON</option>
<?php }else{ ?>
<option value="" selected="">Selectați moneda</option>
<option value="EUR">EURO</option>
<option value="RON">RON</option>
<?php } ?>
</select>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:45px;"><em>Moneda</em></label>
</div>

<div class="w3-margin-bottom w3-center">
<button type="submit" class="w3-button w3-hover-green w3-blue w3-xlarge w3-round-large">Actualizare</button>
</div>

<input type="hidden" name="uid" value="<?=$rowct['uid']?>"/>
<input type="hidden" name="actualizareprofil" value="true"/>
</form>

<div class="w3-margin-bottom">
<p>Notă!<br/>
Adresa de e-mail nu se poate modifica, aceasta nu este și nu v-a fi publică, este unică.</p>
</div>

</div>


</div></div>
<?php
 }else{
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
 }
    
 }elseif($page == 'index'){
//include(BASE);
function lungime_text($x, $length){
  if(strlen($x)<=$length)  {
    echo $x;
  }else{
    $y=substr($x,0,$length) . '...';
    echo $y;
  }
 }
$rlast = $dbc->query("SELECT * FROM `anunturi` 
                               WHERE `verificat` IS NULL 
                               AND `aprobat`=1 
                               ORDER BY `data_publicarii` DESC 
                               LIMIT 10");

$rpop = $dbc->query("SELECT * FROM `anunturi` 
                              WHERE `verificat` IS NULL 
                              AND `aprobat`=1 
                              ORDER BY `vizualizari` DESC 
                              LIMIT 10");
?>

<div class="w3-row-padding">
<div class="w3-quarter w3-hide-small w3-hide-medium">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-rest">
<?php include APP.'searchform.php'; ?>
 
 <div class="w3-row">
   <div class="w3-half">
   
   <div class="w3-margin-bottom w3-hide-small w3-mobile">
   <h3 class="w3-card w3-text-white w3-container" style="margin-right:2px;padding-top:2px;padding-bottom:2px;background-color:#117594;">Ultimele anunțuri</h3>
   </div>
   
   <div class="w3-margin-bottom w3-hide-large w3-hide-medium">
   <h3 class="w3-card w3-text-white w3-container w3-margin-right w3-mobile" style="padding-top:2px;padding-bottom:2px;background-color:#117594;">Ultimele anunțuri</h3>
   </div>
   
<?php
   while($rowlast = $rlast->fetch_assoc()){
       $qgetimage = "SELECT * FROM `imagini` WHERE `aid`={$rowlast['aid']}";
       $rgetimage = $dbc->query($qgetimage);
       $rowgetimg = $rgetimage->fetch_assoc();
       
       $qgetuser = "SELECT * FROM `utilizatori` WHERE `uid`={$rowlast['uid']}";
       $rgetuser = $dbc->query($qgetuser);
       $rowgetusr = $rgetuser->fetch_assoc();         
?>
<a href="<?=PATH.$rowlast['seo']?>.html">
<div class="w3-col l6 m12 s12 w3-hover-light-gray w3-text-black w3-margin-bottom">
<div class="w3-col" style="width:96%;margin:1%;margin-bottom:0;">
<img src="<?=BASE_URL.'imagini/'.$rowgetimg['nume_fisier']?>" style="object-fit:cover;width:100%;height:150px;max-height:100%;" alt="<?php echo lungime_text($rowlast['titlu'], 36); ?>" title="<?php echo $rowlast['titlu']; ?>" loading="lazy" class="w3-card"/>
</div>
<div class="w3-col" style="width:96%;margin:1%;">
<h4 class="w3-card" style="font-size:16px;padding-left:4px;margin-bottom:0;">
<?php echo lungime_text($rowlast['titlu'], 20); ?></h4>
<div class="w3-row w3-green" style="margin-top:0;">
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-money"></i> <?php if($rowlast['pret'] > 0){echo '<strong>'.$rowlast['pret'].'</strong> '.$rowgetusr['moneda'];}else{echo 'GRATUIT';} ?>
</div>
</div>

</div>

</div></a>
<?php } ?>
   </div>
   
   <div class="w3-half">
   
   <div class="w3-margin-bottom w3-hide-small">
   <h3 class="w3-card w3-text-white w3-container" style="margin-left:2px;padding-top:2px;padding-bottom:2px;background-color:#117594;">Cele mai populare</h3>
   </div>
   
   <div class="w3-margin-bottom w3-hide-large w3-hide-medium">
   <h3 class="w3-card w3-text-white w3-container w3-mobile" style="padding-top:2px;padding-bottom:2px;background-color:#117594;">Cele mai populare</h3>
   </div>
      
<?php   
while($rowpop = $rpop->fetch_assoc()){
       $qgetimage = "SELECT * FROM `imagini` WHERE `aid`={$rowpop['aid']}";
       $rgetimage = $dbc->query($qgetimage);
       $rowgetimg = $rgetimage->fetch_assoc();
       
       $qgetuser = "SELECT * FROM `utilizatori` WHERE `uid`={$rowpop['uid']}";
       $rgetuser = $dbc->query($qgetuser);
       $rowgetusr = $rgetuser->fetch_assoc();         
?>
<a href="<?=PATH.$rowpop['seo']?>.html">
<div class="w3-col l6 m12 s12 w3-hover-light-gray w3-text-black w3-margin-bottom">
<div class="w3-col" style="width:96%;margin:1%;margin-bottom:0;">
<img src="<?=BASE_URL.'imagini/'.$rowgetimg['nume_fisier']?>" data-src="<?=BASE_URL.'imagini/'.$rowgetimg['nume_fisier']?>" style="object-fit:cover;width:100%;height:150px;max-height:100%;" alt="<?php echo $rowpop['titlu']; ?>" title="<?php echo $rowpop['titlu']; ?>" loading="lazy" class="w3-card"/>
</div>

<div class="w3-col" style="width:96%;margin:1%;">
<h4 class="w3-card" style="font-size:16px;padding-left:4px;margin-bottom:0;">
<?php echo lungime_text($rowpop['titlu'], 20); ?></h4>
<div class="w3-row w3-border-top w3-green">
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-money"></i> Preț: <?php if($rowpop['pret'] > 0){echo '<strong>'.$rowpop['pret'].'</strong> '.$rowgetusr['moneda'];}else{echo 'GRATUIT';} ?>
</div>
</div>

</div>

</div></a>
<?php } ?>
   </div>
 </div>

</div>

</div>

<?php }elseif($page == 'nou'){

  if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
$qnousr = "SELECT * FROM `utilizatori` WHERE `uid`={$_SESSION['user_id']} LIMIT 1";
$rnousr = $dbc->query($qnousr) or die($dbc->error);
$rownousr = $rnousr->fetch_assoc();
 }
?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter">
<?php include APP.'searchform.php'; ?> 
 <div class="w3-row">
   <div class="w3-rest w3-card w3-container w3-margin-bottom w3-mobile">
   <h3 class="w3-container w3-center w3-border-bottom w3-padding">Adăugare anunț</h3>


<?php // Limitare Anunturi
/*if(isset($_SESSION['user_id'])){
    
$qvna = 'SELECT COUNT(*) AS una FROM anunturi WHERE uid="'.$_SESSION['user_id'].'"';
$rvna = $dbc->query($qvna);
$rwvna = $rvna->fetch_assoc();
$ruc = $rwvna['una'];
$rut = $rownousr['limita'];
$rms = $rut - $ruc;
?>
<?php if($ruc == 0){?>
<div class="w3-panel w3-green w3-center"><h5>Aveți <?=$rms?> anunțuri disponibile.</h5></div>
<?php }elseif($ruc <= $rownousr['limita']){ ?>
<div class="w3-panel w3-green w3-center"><h5>Aveți un număr de <?=$ruc?> anunțuri, mai puteți adăuga <?=$rms?> anunț.</h5></div>
<?php }elseif($ruc == $rownousr['limita']){ ?>
<div class="w3-panel w3-red w3-center"><h5>Ați atins numărul maxim de anunțuri.</h5></div>
<?php } }*/ ?>

<?php

if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    
    ?>


   
   <form class="" action="" method="post" enctype="multipart/form-data">
   
   <div class="w3-row-padding w3-margin-bottom w3-margin-top">   
   <input class="w3-input w3-card w3-white" type="text" placeholder="Titlul anunțului" name="titlu" value="<?php if(isset($_POST['titlu'])){echo $_POST['titlu'];} ?>" required="" maxlength="60"/>
   <?php if(isset($err_titlu)){ ?>
   <div class="w3-panel w3-red w3-padding"><?=$err_titlu?></div>
   <?php } ?>
   </div>
   
   <div class="w3-row-padding w3-margin-bottom w3-margin-top">   
   
<div class="w3-half">
<select class="w3-input w3-col w3-xlarge w3-border w3-white srccata" name="cat_id" style="padding-left:8%;" id="categorie" required="">
<?php if(empty($ra['categorie'])){?>
   <option value="" selected="" disabled="" class="w3-hide">Selectați o categorie</option>
<?php } ?>
   <?php
$qcat = "SELECT * FROM categorii ORDER BY titlu ASC";
$rcat = $dbc->query($qcat) or die($dbc->error);
while($rc = $rcat->fetch_array()){
    
       echo '<option value="'.$rc['cat_id'].'" class="w3-light-gray w3-hover-indigo w3-large w3-card" style="text-transform:uppercase;">&#xf00b; '.$rc['titlu'].'</option>';  
      }
?>   
</select>
</div>

<div class="w3-half">
<select class="w3-input w3-col w3-xlarge w3-border w3-white srccata w3-hide" name="scat_id" style="padding-left:8%;" id="scat">
</select>
</div><!--
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){

    $('#categorie').on("change",function () {
        var cat_id = $(this).find('option:selected').val();
        $.ajax({
            url: "ajax.php",
            type: "POST",
            //data: "cat_id = "+catId,
            data: {cat_id : cat_id},
            success: function (response) {
                console.log(response);
                $("#scat").html(response);
            },
        });
    }); 

});

</script>-->
   
   <?php if(isset($err_titlu)){ ?>
   <div class="w3-panel w3-red w3-padding"><?=$err_titlu?></div>
   <?php } ?>
   </div>
   
   <div class="w3-row-padding w3-margin-bottom">   
   <textarea class="w3-input w3-card w3-white" placeholder="Conținutul anunțului" name="continut" required="" maxlength="5000" rows="5" style="white-space: pre-line;"><?php if(isset($_POST['continut'])){echo $_POST['continut'];} ?></textarea>
   <?php if(isset($err_continut)){ ?>
   <div class="w3-panel w3-red w3-padding"><?=$err_continut?></div>
   <?php } ?>
   </div>
   
   <div class="w3-row-padding w3-margin-bottom">   
   <input class="w3-input w3-card w3-white" type="text" placeholder="Etichete separate prin virgulă ( , )" name="eticheta" value="<?php if(isset($_POST['eticheta'])){echo $_POST['eticheta'];} ?>" required="" maxlength="60"/>
   <?php if(isset($err_eticheta)){ ?>
   <div class="w3-panel w3-red w3-padding"><?=$err_eticheta?></div>
   <?php } ?>
   </div>
   
   <div class="w3-row-padding w3-margin-bottom">     
      <div class="w3-rest w3-card w3-light-gray">
         <p><input class="w3-input w3-button w3-light-gray" type="file" name="poze[]" multiple="" id="fileupload"/></p>
         <div id="dvPreview"></div>
      </div>
      
     <?php if(isset($filelarge)){echo $filelarge;} ?>
     <?php if(isset($fileuploaded)){echo $fileuploaded;} ?>
     
     <div class="validation w3-text-red" style="display:none;"> <strong>Sunt permise maxim 5 imagini! Alegeți din nou...</strong> </div>
     
     
     <script language="javascript" type="text/javascript">
window.onload = function () {
    var fileUpload = document.getElementById("fileupload");
    fileUpload.onchange = function () {
        if (typeof (FileReader) != "undefined") {
            var dvPreview = document.getElementById("dvPreview");
            dvPreview.innerHTML = "";
            var regex = /^([a-zA-Z0-9\s_\\.\-:])+(.jpg|.jpeg|.gif|.png)$/;
            for (var i = 0; i < fileUpload.files.length; i++) {
                var file = fileUpload.files[i];
                if (regex.test(file.name.toLowerCase())) {
                    var reader = new FileReader();
                    reader.onload = function (e) {
                        var img = document.createElement("IMG");
                        img.height = "100";
                        img.width = "120";
                        img.style = "padding:4px;";
                        img.src = e.target.result;
                        dvPreview.appendChild(img);
                    }
                    reader.readAsDataURL(file);
                } else {
                    alert(file.name + " nu are o extensie permisă.");
                    dvPreview.innerHTML = "";
                    return false;
                }
            }
        } else {
            alert("This browser does not support HTML5 FileReader.");
        }
    }
 };
 
 $('#fileupload').change(function(){
   //get the input and the file list
   var input = document.getElementById('fileupload');
   if(input.files.length>5){
       $('.validation').css('display','block');
   }else{
       $('.validation').css('display','none');
   }
});
</script>
            
   </div>   
   
   <div class="w3-row-padding w3-margin-bottom">
   <div class="w3-third w3-margin-bottom">
       <select class="w3-input w3-large w3-card w3-white srclocatie" style="padding-left:50px;" name="judetul" required="">       
        <?php
        $qjud = "SELECT * FROM judet";
        $rjud = $dbc->query($qjud) or die($dbc->error);
        echo '<option value="" selected="" disabled="">Selectați județul</option>';
        //foreach ($dbc->query($qjud) as $rj) {
        while($rj = $rjud->fetch_assoc()){            
            echo '<option value="'.$rj['nume'].'">'.$rj['nume'].'</option>';
        }
        ?>        
       </select>
   </div>
   <div class="w3-third w3-margin-bottom">
       <select class="w3-input w3-large w3-card w3-white deliveryselect" style="padding-left:50px;" name="livrare" required="">       
        <option value="" selected="" disabled="">Cum livrați?</option>
        <option value="posta">Prin poștă</option>
        <option value="curier">Prin curier</option>
        <option value="predare">Predare personală</option>
        <option value="online">Online (Produs digital)</option>
       </select>
   </div>
   <div class="w3-third w3-margin-bottom">
       <input class="w3-input w3-large w3-card w3-white" name="pretul" type="number" value="<?php if(isset($_POST['pretul'])){echo $_POST['pretul'];} ?>" min="1" placeholder="Prețul.." required=""/> <div class="w3-right" style="position:relative;margin-top:-32px;margin-right:30px;" title="Pentru a modifica moneda, mergeti la editare profil"><?=$rownousr['moneda']?><?php if(empty($_SESSION['user_id'])){echo 'RON';} ?></div>
   </div>
   </div>
<?php }else{ ?>
<div class="w3-center w3-margin w3-padding-32 w3-text-red">
<i class="fa fa-ban" style="font-size: 64px;"></i><br/><br/>
<strong>Trebuie să aveți cont pentru a plasa un anunț!</strong> <br/><br/>
<a href="contnou.html"><i class="fa fa-user-plus"></i> Vreau un cont nou!</a>
</div>
<?php } ?>
    
   
   <div class="w3-center w3-margin-top w3-margin-bottom">
<?php
if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
?>
<input type="hidden" name="uip" value="<?php echo $_SERVER["REMOTE_ADDR"]; ?>"/>
<?php //if($ruc == $rownousr['limita']){}else{ ?>
<input type="hidden" name="anuntnou" value="true"/>
<button class="w3-button w3-blue w3-hover-black" type="submit">Adaugă anunțul</button>
<?php //}
if(isset($err_id)){echo '<div class="w3-panel w3-red w3-padding">'.$err_id.'</div>';}
if(isset($err_add_anunt)){echo '<div class="w3-panel w3-red w3-padding">'.$err_add_anunt.'</div>';}
if(isset($incercdinnou)){echo '<div class="w3-panel w3-red w3-padding">'.$incercdinnou.'</div>';}
if(isset($notupload)){echo '<div class="w3-panel w3-red w3-padding">'.$notupload.'</div>';}
if(isset($addedanunt)){echo '<div class="w3-panel w3-green w3-padding">'.$addedanunt.'</div>';}


?>
</form>
<?php }else{ ?>
<a onclick="document.getElementById('acces').style.display='block'" class="w3-button w3-green w3-hover-black" style="text-decoration:none;">Autentificare</a>
<?php } ?>
   </div>     
   
   </div>
 </div> 


</div>
</div>

<?php

  }elseif($page == 'noutati'){
    
  if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
    }else{
    ?>
<?php include FORM; ?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter"> 
<div class="w3-row">
<div class="w3-rest w3-text-white w3-container w3-margin-top w3-margin-bottom w3-card" style="background-color:#117594;">
<h3 class="w3-center w3-margin-bottom w3-padding w3-border-bottom"><?=$row['titlu']?></h3>
</div>
<p><?=$row['descriere']?></p>  
   
</div>

</div>

</div>
<?php
  
    }
  
  }elseif($page == 'recuperareparola'){
    
    
  
  if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
    }else{
    ?>
<?php include FORM; ?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter"> 
 
 <div class="w3-row">
 
 <div class="w3-quarter w3-hide-small">&nbsp;</div>
        
   <div class="w3-half w3-margin-top w3-margin-bottom w3-card">
   <h3 class="w3-center w3-margin-bottom w3-padding w3-border-bottom w3-bluepm">Recuperare parolă</h3>

<?php if(isset($nuexista)) {?>   
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$nuexista?></h5>
       </div>
   </div>
<?php } ?>
   
<?php if(!empty($multetrimiteri)) {?>
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$multetrimiteri?></h5>
       </div>
   </div>
<?php } ?>

<?php if(isset($err_p1)) {?>
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$err_p1?></h5>
       </div>
   </div>
<?php } ?>

<?php if(isset($err_p2)) {?>
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$err_p2?></h5>
       </div>
   </div>
<?php } ?>

<?php if(isset($finalizat)) {?>
   <div class="w3-container">
       <div class="w3-panel w3-seagreen w3-center">
            <h5 style="margin-top:4px;"><?=$finalizat?></h5>
       </div>
   </div>
<?php } ?>


<?php 
$status = explode("=", $_SERVER["REQUEST_URI"]);
if(isset($status[1])) {?>
   <div class="w3-container">
       <div class="w3-panel w3-seagreen w3-center">
            <h5 style="margin-top:4px;"><h5 style="margin-top:4px;">Procesul de recuperare a început!</h5><p>Un e-mail de confirmare a fost trimis la adresa dvs.<br/>Vă rugăm să faceți clic pe linkul din e-mailul respectiv, pentru a vă recupera parola.<br/>Ar trebui să ajungă în cel mult 5 minute.</p></h5>
       </div>
   </div>
<?php } ?>

<?php if(isset($sys_err)) {?>
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$sys_err?></h5>
       </div>
   </div>
<?php } ?>

<?php if(isset($try)) {?>
   <div class="w3-container">
       <div class="w3-panel w3-red w3-center">
            <h5 style="margin-top:4px;"><?=$try?></h5>
       </div>
   </div>
<?php } ?>
   
   <form class="w3-container" action="" method="post">
   <div class="w3-margin-bottom">
   <label>Adresa de e-mail</label>
   <input class="w3-input w3-border" type="email" name="resetemail" placeholder="Treceți adresa dvs. de e-mail" required=""/>
   </div>
   
   <div class="w3-margin-bottom">
   <span><strong>Sunt de acord cu:</strong> </span><br/>
   <input class="w3-check" type="checkbox" name="atermeni" value="0" id="checkTenable"/>
   <label><a href="<?=PATH?>termeni.html" target="_blank" style="text-decoration:none;">Termenii și Condițiile</a></label><br/>
   
   <input class="w3-check" type="checkbox" name="apolitica" value="0" id="checkGenable" disabled="disabled"/>
   <label><a href="<?=PATH?>confidentialitate.html" target="_blank" style="text-decoration:none;">Politica de confidențialitate</a></label><br/>   
   
   </div>
   
   <div class="w3-margin-bottom w3-center">
   <button class="w3-button w3-red w3-hover-black" type="submit" id="ischeckenable" disabled="disabled"><i class="fa fa-unlock"></i> Recuperare parolă</button>
   </div>
   
   <input type="hidden" name="recuperareparola" value="true"/>
   </form>
   <form></form>
   
   <div class="w3-bar w3-white w3-hide-small_ w3-border-top">
   
   <a href="<?=PATH?>contnou.html" class="w3-bar-item w3-button w3-bluepm w3-hover-seagreen" style="width:40%;">Cont nou</a>
   <a href="<?=PATH?>acces.html" class="w3-bar-item w3-button w3-bluepm w3-hover-seagreen" style="width:60%;">Acces</a>
   
   </div>
   
   </div>
   
   <div class="w3-quarter w3-hide-small">&nbsp;</div>
   
 </div>

</div>

</div>

<?php }
  
  
  
  
  }elseif($page == 'regulament'){
    
    ?>
    
    <div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter">
<?php include APP.'searchform.php'; ?>

 <!--<div class="w3-row">
   <div class="w3-rest w3-card w3-container w3-margin-bottom">   
   <img title="Harta României" alt="Harta României" class="img-responsive" width="50%" src="/asset/svg/ro.svg"/>
   <div id="mapdata"></div>
   </div>
 </div>
 
 <div class="w3-row">
   <div class="w3-rest w3-card w3-container w3-indigo w3-margin-bottom">
   <h3>Anunțuri Promovate</h3>
   </div>
 </div> -->
 
 <div class="w3-row-padding">
   <div class="w3-half w3-padding">
   <h3 class="w3-container w3-indigo w3-card" style="padding-bottom:5px;">Ultimele anunțuri</h3>
<?php
function lungime_text($x, $length){
  if(strlen($x)<=$length)  {
    echo $x;
  }else{
    $y=substr($x,0,$length) . '...';
    echo $y;
  }
 }
   $qlast5 = "SELECT * FROM `anunturi` WHERE `verificat` IS NULL ORDER BY `data_publicarii` DESC LIMIT 5";
   $rlast5 = $dbc->query($qlast5);
   while($rowlast5 = $rlast5->fetch_assoc()){
       $qgetimage = "SELECT * FROM `imagini` WHERE `aid`={$rowlast5['aid']}";
       $rgetimage = $dbc->query($qgetimage);
       $rowgetimg = $rgetimage->fetch_assoc();
       
       $qgetuser = "SELECT * FROM `utilizatori` WHERE `uid`={$rowlast5['uid']}";
       $rgetuser = $dbc->query($qgetuser);
       $rowgetusr = $rgetuser->fetch_assoc();         
?>
<a href="/<?=$rowlast5['seo']?>.html">
<div class="w3-row w3-hover-light-gray w3-text-black w3-card w3-margin-bottom">
<div class="w3-col w3-hide-small" style="width:26%;">
<img src="<?=BASE_URL.PATH.'imagini/'.$rowgetimg['nume_fisier']?>" style="width:100px;height:100px;" alt="" class="w3-margin"/>
</div>
<div class="w3-col w3-hide-medium w3-hide-large" style="width:30%;">
<img src="<?=BASE_URL.PATH.'imagini/'.$rowgetimg['nume_fisier']?>" style="width:70px;height:70px;" alt=""/>
</div>
<div class="w3-col w3-hide-small" style="width:74%;">
<h5 class="w3-border-bottom">
<?php echo lungime_text($rowlast5['titlu'], 36); ?></h5>
<div style="text-align: justify;padding-left:5px;padding-right:5px;">
<span><?php echo lungime_text($rowlast5['descriere'], 90); ?></span></div>
<div class="w3-row w3-border-top w3-blue">
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-money"></i> Preț: <?php if($rowlast5['pret'] > 0){echo '<strong>'.$rowlast5['pret'].'</strong> '.$rowgetusr['moneda'];}else{echo 'GRATUIT';} ?>
</div>
</div>

<div class="w3-row w3-border-top">
<div class="w3-left" style="padding-left:5px;">
<i class="fa fa-map-marker"></i> <?php echo $rowlast5['judet']; ?>
</div>
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-clock-o"></i> <?php echo date('d F Y, H:i', strtotime($rowlast5['data_publicarii'])); ?>
</div>
</div>

</div>

<div class="w3-col w3-hide-medium w3-hide-large" style="width:70%;">
<h6 class="w3-border-bottom">
<?php echo lungime_text($rowlast5['titlu'], 22); ?>
</h6>
<span><?php echo lungime_text($rowlast5['descriere'], 42); ?></span>
</div>
</div></a>
<?php } ?>
   </div>
   
   <div class="w3-half w3-padding">
   <h3 class="w3-container w3-indigo" style="padding-bottom:5px;">Cele mai populare</h3>
<?php
function lungime_text2($x, $length){
  if(strlen($x)<=$length){
    echo $x;
  }else{
    $y=substr($x,0,$length) . '...';
    echo $y;
  }
 }
   $qlast5 = "SELECT * FROM `anunturi` WHERE `verificat` IS NULL ORDER BY `vizualizari` DESC LIMIT 5";
   $rlast5 = $dbc->query($qlast5);
   while($rowlast5 = $rlast5->fetch_assoc()){
       $qgetimage = "SELECT * FROM `imagini` WHERE `aid`={$rowlast5['aid']}";
       $rgetimage = $dbc->query($qgetimage);
       $rowgetimg = $rgetimage->fetch_assoc();
       
       $qgetuser = "SELECT * FROM `utilizatori` WHERE `uid`={$rowlast5['uid']}";
       $rgetuser = $dbc->query($qgetuser);
       $rowgetusr = $rgetuser->fetch_assoc();         
?>
<a href="<?=PATH.$rowlast5['seo']?>.html">
<div class="w3-row w3-hover-light-gray w3-text-black w3-card w3-margin-bottom">
<div class="w3-col w3-hide-small" style="width:26%;">
<img src="<?=BASE_URL.PATH.'imagini/'.$rowgetimg['nume_fisier']?>" style="width:100px;height:100px;" alt="" class="w3-margin"/>
</div>
<div class="w3-col w3-hide-medium w3-hide-large" style="width:30%;">
<img src="<?=BASE_URL.PATH.'imagini/'.$rowgetimg['nume_fisier']?>" style="width:70px;height:70px;" alt=""/>
</div>
<div class="w3-col w3-hide-small" style="width:74%;">
<h5 class="w3-border-bottom">
<?php echo lungime_text2($rowlast5['titlu'], 36); ?></h5>
<div style="text-align: justify;padding-left:5px;padding-right:5px;">
<span><?php echo lungime_text2($rowlast5['descriere'], 90); ?></span></div>
<div class="w3-row w3-border-top w3-blue">
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-money"></i> Preț: <?php if($rowlast5['pret'] > 0){echo '<strong>'.$rowlast5['pret'].'</strong> '.$rowgetusr['moneda'];}else{echo 'GRATUIT';} ?>
</div>
</div>

<div class="w3-row w3-border-top">
<div class="w3-left" style="padding-left:5px;">
<i class="fa fa-map-marker"></i> <?php echo $rowlast5['judet']; ?>
</div>
<div class="w3-right" style="padding-right:5px;">
<i class="fa fa-clock-o"></i> <?php echo date('d F Y, H:i', strtotime($rowlast5['data_publicarii'])); ?>
</div>
</div>

</div>

<div class="w3-col w3-hide-medium w3-hide-large" style="width:70%;">
<h6 class="w3-border-bottom">
<?php echo lungime_text2($rowlast5['titlu'], 22); ?>
</h6>
<span><?php echo lungime_text2($rowlast5['descriere'], 42); ?></span>
</div>
</div></a>
<?php } ?>
   </div>
 </div>

</div></div>
    
    <?php
  
  
  }elseif($page == 'schimbare-parola'){
    
    if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    
    $qcont = "SELECT * FROM `utilizatori` WHERE `uid`='".$_SESSION['user_id']."' LIMIT 1";
    $rcont = $dbc->query($qcont);
    $rowct = $rcont->fetch_assoc();
    
    $email = $rowct['email'];
    $default = BASE_URL.PATH."imagini/no-image-icon.png";
    $size = 250;
    
    $grav_url = "https://www.gravatar.com/avatar/" . md5( strtolower( trim( $email ) ) ) . "?d=" . urlencode( $default ) . "&s=" . $size;



?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_usr.php'; ?>
</div>
<div class="w3-threequarter">
<div class="w3-row w3-indigo">
<h3 class="w3-container"><i class="fa fa-key"></i> Schimbare parolă</h3>
</div>


<div class="w3-row w3-margin-top">
<div class="w3-quarter">
<div class="w3-card">
<img class="w3-image" src="<?php echo $grav_url; ?>" alt="<?=$rowct['prenume']?>" style="width:100%;max-width:100%;"/>
</div>
<div class="w3-center">
<a href="https://ro.gravatar.com/" target="_blank">Schimbi imaginea?</a>
</div>
</div>
<div class="w3-threequarter">

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['prenume']?>" disabled=""/>
<label class="w3-right w3-small" for="prenume" style="margin-top:-50px;margin-right:5px;"><em>Prenume</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['nume']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>Nume</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['email']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>E-mail</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['moneda']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>Moneda</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['data_r']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>Data înregistrării</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['data_m']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>Ultima modificare</em></label>
</div>

</div>

</div>


</div></div>
<?php
 }else{
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
 }
  
  
  }elseif($page == 'setarile-mele'){
    
    if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    
    $qcont = "SELECT * FROM `utilizatori` WHERE `uid`='".$_SESSION['user_id']."' LIMIT 1";
    $rcont = $dbc->query($qcont);
    $rowct = $rcont->fetch_assoc();
    
    $email = $rowct['email'];
    $default = BASE_URL.PATH."imagini/no-image-icon.png";
    $size = 250;
    
    $grav_url = "https://www.gravatar.com/avatar/" . md5( strtolower( trim( $email ) ) ) . "?d=" . urlencode( $default ) . "&s=" . $size;



?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_usr.php'; ?>
</div>
<div class="w3-threequarter">
<div class="w3-row w3-indigo">
<h3 class="w3-container"><i class="fa fa-cogs"></i> Setările mele</h3>
</div>


<div class="w3-row w3-margin-top">
<div class="w3-quarter">
<div class="w3-card">
<img class="w3-image" src="<?php echo $grav_url; ?>" alt="<?=$rowct['prenume']?>" style="width:100%;max-width:100%;"/>
</div>
<div class="w3-center">
<a href="https://ro.gravatar.com/" target="_blank">Schimbi imaginea?</a>
</div>
</div>
<div class="w3-threequarter">

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['prenume']?>" disabled=""/>
<label class="w3-right w3-small" for="prenume" style="margin-top:-50px;margin-right:5px;"><em>Prenume</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['nume']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>Nume</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['email']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>E-mail</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['moneda']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>Moneda</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['data_r']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>Data înregistrării</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['data_m']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>Ultima modificare</em></label>
</div>

</div>

</div>


</div></div>
<?php
 }else{
    $url = PATH.'/index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
 }
  
  
  }elseif($page == 'statistici-profil'){
    
    if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    
    $qcont = "SELECT * FROM `utilizatori` WHERE `uid`='".$_SESSION['user_id']."' LIMIT 1";
    $rcont = $dbc->query($qcont);
    $rowct = $rcont->fetch_assoc();
    
    $email = $rowct['email'];
    $default = BASE_URL.PATH."imagini/no-image-icon.png";
    $size = 250;
    
    $grav_url = "https://www.gravatar.com/avatar/" . md5( strtolower( trim( $email ) ) ) . "?d=" . urlencode( $default ) . "&s=" . $size;



?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_usr.php'; ?>
</div>
<div class="w3-threequarter">
<div class="w3-row w3-indigo">
<h3 class="w3-container"><i class="fa fa-pie-chart"></i> Statistici profil</h3>
</div>


<div class="w3-row w3-margin-top">
<div class="w3-quarter">
<div class="w3-card">
<img class="w3-image" src="<?php echo $grav_url; ?>" alt="<?=$rowct['prenume']?>" style="width:100%;max-width:100%;"/>
</div>
<div class="w3-center">
<a href="https://ro.gravatar.com/" target="_blank">Schimbi imaginea?</a>
</div>
</div>
<div class="w3-threequarter">

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['prenume']?>" disabled=""/>
<label class="w3-right w3-small" for="prenume" style="margin-top:-50px;margin-right:5px;"><em>Prenume</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['nume']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>Nume</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['email']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>E-mail</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['moneda']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>Moneda</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['data_r']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>Data înregistrării</em></label>
</div>

<div class="w3-half w3-margin-bottom" style="padding-left:7px;">
<input class="w3-input w3-white w3-xlarge w3-card" value="<?=$rowct['data_m']?>" disabled=""/>
<label class="w3-right w3-small" for="nume" style="margin-top:-50px;margin-right:5px;"><em>Ultima modificare</em></label>
</div>

</div>

</div>


</div></div>
<?php
 }else{
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
 }
  
  
  }elseif($page == 'termeni'){
    
    
  if(isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'iesire.html')) {
    $url = PATH.'index.html';
    ob_end_clean();
    header("Location: $url");
    exit();
    }else{
    ?>
<?php include FORM; ?>
<div class="w3-row-padding">
<div class="w3-quarter">
<?php include APP.'sidebar_gen.php'; ?>
</div>
<div class="w3-threequarter"> 
<div class="w3-row">
<div class="w3-rest w3-text-white w3-container w3-margin-top w3-margin-bottom w3-card" style="background-color:#117594;">
<h3 class="w3-center w3-margin-bottom w3-padding w3-border-bottom"><?=$row['titlu']?></h3>
</div>
<p><?=$row['descriere']?></p>  
   
</div>

</div>

</div>
<?php }
  
  }

?>

