<?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 (mysql_result(mysql_query("SELECT COUNT(*) FROM `build` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1"), 0)==0){
header("Location: /index.php?".SID);
exit;
}   
    
if (isset($_POST['money']))
{
$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("UPDATE `build` SET `main_time` = '$main_time', `money` = '".intval($_POST['money'])."' WHERE `id`='".intval($_GET['id'])."'");

$_SESSION['message'] = 'Стройка успешно отредактирована';
header('location: /build/');
}

echo "<form class='nav2' method=\"post\" name=\"message\" action=\"edit.php?id=".intval($_GET['id'])."\">\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';
?>