<?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/".$lang."/ru.php";

  $title=$titlepage = $TEXT['param_new'];
  $helppage = "";

  require_once "../config.php";
  require_once "../util/top.php";

  if($result2['administrator'] == 0) puterror2($TEXT['error-loginform2']);

  if(empty($_POST['fs'])) puterror2($TEXT['ondisk_err1']);
  if(strlen($_POST['fs'])>255) puterror2($TEXT['ondisk_err2']);
  if(empty($_POST['tm'])) puterror2($TEXT['ondisk_err3']);
  if(strlen($_POST['tm'])>255) puterror2($TEXT['ondisk_err4']);

  if(isset($_POST['fs'])) $fs=trim($_POST['fs']);
    else $fs="";
     if (empty($fs)) puterror2($TEXT['ondisk_err5']);

  if(isset($_POST['tm'])) $tm=trim($_POST['tm']);
    else $tm="";
     if (empty($tm)) puterror2($TEXT['ondisk_err6']);

  $_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 = mysql_query($query_chk);
     if (!$result_chk) puterror2($TEXT['error-tbl38']);
       if (mysql_num_rows($result_chk)>0) puterror2($TEXT['global-est']);

  //*************************************
  //Информация для лога
  $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['fullname'];
  //*************************************
  $query = "INSERT INTO `tbl_ondisk` ( `ond_id`, `disk_name`, `mp`) VALUES ( NULL , '".$_POST['fs']."' , '".$_POST['tm']."')";
  if(mysql_query($query))
  {
    $query2 = "INSERT INTO tbl_logs ( `log_id` , `data` , `ip` , `who` , `doing` , `what` ) VALUES ( NULL , NOW() , '$ip' , '$who' , '$doing' , '$what')";
        if(mysql_query($query2))
           {
           echo "<html><head>
                 <meta HTTP-EQUIV='Refresh' CONTENT='0; URL=index.php' />
                 </head></html>";
           } else puterror2($TEXT['error-log']);
  } else puterror2($TEXT['error-tbl38']);
 require_once "../util/bottom.php";
?>
