<?php

require_once('conf/dbc.php');
require_once('conf/session_start.php');
require_once('conf/ban.php');
if ((isset($_SESSION['id'])) and (isset($_SESSION['nick'])))  {
  $h=getenv("HTTP_REFERER");
  if (empty($h)) {
  ?>
  <script type="text/javascript">
  document.location.href = "index.php";
  </script>
  <?php
  exit();
  }
$user=abs(intval($_SESSION['id']));
  $query_read = "update users set read_ad = '0' where id = '$user'";
  $result_read = mysqli_query($dbc, $query_read) or die ('Ошибка передачи запроса к БД');
  ?>
  <script type="text/javascript">
  document.location.href = "<?php echo "$h";?>";
  </script>
  <?php
}
else {
?>
<script type="text/javascript">
  document.location.href = "reg.php?err_login=1";
</script>
<?php
}
mysqli_close($dbc);
?>

