<?php 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);
$rwcp = $rcp->fetch_assoc();
$countpag = $rwcp['countp'];

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

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

$qcuo = "SELECT COUNT(*) AS countuo FROM utilizatori WHERE `online`=\"1\"";
$rcuo = $dbc->query($qcuo);
$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'];

$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'];

$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'];

$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(isset($actualizat) == 1){echo '<div class="w3-panel w3-green"><h3><i class="fa fa-check"></i> Anunțul a fost aprobat</h3></div>';}
if(isset($neactualizat) == 2){echo '<div class="w3-panel w3-red"><h3><i class="fa fa-check"></i> Anunțul nu a putut fi aprobat</h3></div>';}
if(isset($refuzat) == 1){echo '<div class="w3-panel w3-blue"><h3><i class="fa fa-check"></i> Anunțul a fost refuzat</h3></div>';}
if(isset($nerefuzat) == 2){echo '<div class="w3-panel w3-red"><h3><i class="fa fa-check"></i> Anunțul nu a putut fi refuzat</h3></div>';}
if(isset($acta) == 1){echo '<div class="w3-panel w3-green"><h3><i class="fa fa-check"></i> Anunțul a fost actualizat</h3></div>';}
if(isset($neacta) == 2){echo '<div class="w3-panel w3-red"><h3><i class="fa fa-check"></i> Anunțul nu a putut fi actualizat</h3></div>';}
?>

<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);
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>

<?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();
    } 
?>