<?php     
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);
    
if ($dbc->affected_rows == 1) {
    
    $qu = "SELECT * FROM `utilizatori` WHERE `utilizatori`.`uid`='".$dbc->real_escape_string($_GET['x'])."' LIMIT 1";
    $ru = $dbc->query($qu);
    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);
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ț activat!";                    
$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>Cofirmare activare cont</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 activat 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);  
    
$qa = "SELECT * FROM `anunturi` WHERE `aid`='".$dbc->real_escape_string($_GET['z'])."' LIMIT 1";
$ra = $dbc->query($qa);    
    while($row = $ra->fetch_assoc()){
        $anuntseo = $row['seo'];
        } 
$active =  "Anunțul tău a fost activat!<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);    
    while($row = $ra->fetch_assoc()){
        $anuntseo = $row['seo'];
        }        
$inactive = "Anunțul tău este ACTIV.<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>