<?php
defined('_IN_JOHNCMS') or die('Error: restricted access');
if($ban[1])
{
  echo functions::display_error('Siz ban olgansiz!');
  require_once ('../incfiles/end.php');
  exit;    
}

$req = mysql_query("SELECT * FROM `dnevniki` WHERE `id` = '".$id."' AND `dnid` = 'txt' LIMIT 1");
if(mysql_num_rows($req))
{
  $res = mysql_fetch_assoc($req);  
  $req_user = mysql_query("SELECT * FROM `users` WHERE `id` = '".$res['userid']."' LIMIT 1");
  $uz = mysql_fetch_assoc($req_user);
  if (($user_id==$res['userid'] or (($rights >= 6) and $rights > $uz['rights']))) 
  {
    $del = $_GET['del'];
    if($del)
    {
      mysql_query("DELETE FROM `dnevniki` WHERE `dnid` = 'txt' AND `id` = '".$id."' LIMIT 1");
      mysql_query("DELETE FROM `dnevniki` WHERE `dnid` = 'com' AND `com_id` = '".$id."'");
      mysql_query("DELETE FROM `dn_rdm` WHERE `dnid` = '".$id."'");
      echo '<div class="phdr"><a href="./">Kundaliklar</a> | Kundalikni o`chirish</div>';
      echo '<div class="menu">Kundalik o`chirildi!<br/>';
      echo '<a href="?act=showdn&amp;id='.$res['userid'].'">Davom etish</a></div>';
      echo '<div class="phdr">&nbsp;</div>';
      echo '<a href="./"><img src="./img/folder.png" /> Kundaliklar</a><br />';
      require_once ('../incfiles/end.php');
      exit;
    } 
    echo '<div class="phdr"><a href="./">Kundaliklar</a> | Kundalikni o`chirish</div>';
    echo '<div class="menu">Kundalikni o`chiramizmi?<br/>';     
    echo '<a href="?act=delrec&amp;del=del&amp;id='.$id.'">HA</a> | <a href="?act=view&amp;id='.$id.'">YO`Q</a></div>'; 
    echo '<div class="phdr">&nbsp;</div>';
    echo '<a href="./"><img src="./img/folder.png" /> Kundaliklar</a><br />';
  }
  else
  {
    echo '<div class="phdr"><a href="./">Kundaliklar</a> | Kundalikni o`chirish</div>';
    echo '<div class="menu">';
    echo 'Kundalikni o`chirib bo`lmaydi!<br/>';
    echo '<a href="./">Orqaga</a>';
    echo '</div>';
    echo '<div class="phdr">&nbsp;</div>';
  }
}
else
{
  echo '<div class="phdr"><a href="./">Kundaliklar</a> | Kundalikni o`chirish</div>';
  echo '<div class="menu">';
  echo 'Kundalikni o`chirib bo`lmaydi!<br/>';
  echo '<a href="./">Orqaga</a>';
  echo '</div>';
  echo '<div class="phdr">&nbsp;</div>';
}
?>