<?php
include_once '../../sys/inc/start.php';
include_once '../../sys/inc/compress.php';
include_once '../../sys/inc/sess.php';
include_once '../../sys/inc/home.php';
include_once '../../sys/inc/settings.php';
include_once '../../sys/inc/db_connect.php';
include_once '../../sys/inc/ipua.php';
include_once '../../sys/inc/fnc.php';
include_once '../../sys/inc/adm_check.php';
include_once '../../sys/inc/user.php';

$set['title']='Новая стройка';
include_once '../../sys/inc/thead.php';
title();
aut();

if (user_access('adm_mysql')){

if (isset($_POST['money']))
{
    
mysql_query("UPDATE `build` SET `ok` = '0' WHERE `ok` = '1'");
    
$ch = intval($_POST['ch']);
$mn = intval($_POST['mn']);
$main_time = time()+$ch*$mn*60*60*24;if ($main_time<=time())
$main_time = 0;

mysql_query("INSERT INTO `build` (`time`, `main_time`, `active`, `money`) values('$time', '$main_time', '1', '".intval($_POST['money'])."')");
$_SESSION['message'] = 'Стройка успешно запущена';
header('location: /build/');
}

echo "<form class='nav2' method=\"post\" name=\"message\" action=\"add.php\">\n";
echo "Сколько будет длиться?:<br />";
echo '<input type="text" name="ch" size="3" value="'.(isset($_POST['ch'])?"".intval($_POST['ch'])."":"1").'" />';
echo '<select name="mn">';
echo '  <option value="1" ' . (isset($_POST['mn']) && $_POST['mn'] == 1 ? "selected='selected'" : null) . '>Дней</option>';
echo '  <option value="7" ' . (isset($_POST['mn']) && $_POST['mn'] == 7 ? "selected='selected'" : null) . '>Недель</option>';
echo '  <option value="31" ' . (isset($_POST['mn']) && $_POST['mn'] == 31 ? "selected='selected'" : null).'>Месяцев</option>';
echo '</select><br /><br />';
echo 'По сколько монет получит команда победителей?:<br /><input name="money" type="text" style="width: 100px;"/><br /><br />';
echo '<input value="Создать" type="submit" name="ok" />';
echo "</form>";

    
}
include_once '../../sys/inc/tfoot.php';
?>