<?php
  ///////////////////////////////////////////////////
  //2010 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  $lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
  if(is_file ("../lang/".$lang."/".$lang.".php")) {include "../lang/".$lang."/".$lang.".php";}
     else {include "../lang/ru/ru.php";}

  $title = $TEXT['param_new'];

  require_once "../config_a.php";
  require_once "../utils/functions.php";
  require_once "../utils/top_adm.php";

  if($result2['administrator'] == 0) {puterror($result2['skin'],$TEXT['error-loginform2']); require_once "../utils/bottom_adm.php"; exit();}

  if(empty($_POST['fs'])) {puterror($result2['skin'],$TEXT['ondisk_err1']); require_once "../utils/bottom_adm.php"; exit();}
  if(strlen($_POST['fs'])>255) {puterror($result2['skin'],$TEXT['ondisk_err2']); require_once "../utils/bottom_adm.php"; exit();}
  if(empty($_POST['tm'])) {puterror($result2['skin'],$TEXT['ondisk_err3']); require_once "../utils/bottom_adm.php"; exit();}
  if(strlen($_POST['tm'])>255) {puterror($result2['skin'],$TEXT['ondisk_err4']); require_once "../utils/bottom_adm.php"; exit();}

  if(isset($_POST['fs'])) {$fs=trim($_POST['fs']);}
    else {$fs="";}
     if(empty($fs)) {puterror($result2['skin'],$TEXT['ondisk_err5']); require_once "../utils/bottom_adm.php"; exit();}

  if(isset($_POST['tm'])) {$tm=trim($_POST['tm']);}
    else {$tm="";}
     if(empty($tm)) {puterror($result2['skin'],$TEXT['ondisk_err6']); require_once "../utils/bottom_adm.php"; exit();}

  $_POST['fs'] = rep($_POST['fs']);
  $_POST['tm'] = rep($_POST['tm']);

  $query_chk = "SELECT `disk_name` FROM `tbl_ondisk` WHERE `disk_name`='".$_POST['mp']."' ";
     $result_chk = mysqli_query($dbcnx,$query_chk);
     if(!$result_chk) {puterror($result2['skin'],$TEXT['error-tbl9']); require_once "../utils/bottom_adm.php"; exit();}
       if(mysqli_num_rows($result_chk)>0) {puterror($result2['skin'],$TEXT['error-double']); require_once "../utils/bottom_adm.php"; exit();}

  //*************************************
  //Информация для лога
  $ip = $_SERVER['REMOTE_ADDR'];
  $doing = $TEXT['log-ondisk1'];
  $what = $TEXT['ondisk_fs']." &laquo;".$_POST['fs']."&raquo;, ".$TEXT['ondisk_tm']." &laquo;".$_POST['tm']."&raquo;";
  $who = $result2['familiya']." ".$result2['name'];
  //*************************************

  $query = "INSERT INTO `tbl_ondisk` ( `ond_id`, `disk_name`, `mp`) VALUES ( NULL , '".$_POST['fs']."' , '".$_POST['tm']."')";
  if(mysqli_query($dbcnx,$query))
  {
    $query2 = "INSERT INTO tbl_logs ( `log_id` , `data` , `ip` , `who` , `doing` , `what` ) VALUES ( NULL , NOW() , '$ip' , '$who' , '$doing' , '$what')";
        if(mysqli_query($dbcnx,$query2))
           {
           echo "<html><head>
                 <meta HTTP-EQUIV='Refresh' CONTENT='0; URL=index.php' />
                 </head></html>";
           } else {puterror($result2['skin'],$TEXT['error-log']); require_once "../utils/bottom_adm.php"; exit();}
  } else {puterror($result2['skin'],$TEXT['error-tbl9']); require_once "../utils/bottom_adm.php"; exit();}
 require_once "../utils/bottom_adm.php";
?>