<? php
if(! isset($_POST['action']))
{
$file = file("bots/intervals.dat");
echo"<div class=\"form\">\n";
echo"<form method =\"post\"
echo"Next. question\"quiz\": <br/>\n";
echo"<input type=\"text\"name=\"bot1\"maxlength=\"15\"value=\"".intval($file[0])."\"/> <br/>\n";
echo"Next. question\"Angry quiz\": <br/>\n";
echo"<input type=\"text\"name=\"bot2\"maxlength=\"15\"value=\"".intval($file[1])."\"/> <br/>\n";
echo"The time between the posts of the Joker: <br/>\n";
echo"<input type=\"text\"name=\"bot3\"maxlength=\"15\"value=\"".intval($file[2])."\"/> <br/>\n";
echo"<input type=\"hidden\"name=\"action\"value=\"save\"/>\n";
echo"<input type=\"submit\"value=\"Sohranit\"/> </form> </div> <br/>\n";
}
else
{
$bot1 = intval($_POST['bot1']);
$bot2 = intval($_POST['bot2']);
$bot3 = intval($_POST['bot3']);

$error ="";

if($bot1 <5 | | $bot1> 120)$error. ="Next. the question\"quiz\"can be set in the range from 5 to 120 seconds.! <br/>\n";
if($bot2 <5 | | $bot2> 120)$error. ="Next. the question\"Angry quiz\"can be set in the range from 5 to 120 seconds.! <br/>\n";
if($bot3 <60)$error. ="bot\"Joker\"can not tell jokes more often than once a minute! <br/>\n";

if(! empty($error))
{
echo $error;
break;
}

$file = fopen("bots/intervals.dat","w");
$data ="$bot1\n";
$data. ="$bot2\n";
$data. ="$bot3";
fwrite($file, $data);
fclose($file);

echo"Data saved successfully! <br/>\n";
}
?>